mirror of
https://github.com/osnr/TabFS.git
synced 2024-06-14 11:45:07 +02:00
improve test reliability; try clear scriptsForTab (doesn't work yet)
This commit is contained in:
parent
b8181bd6f5
commit
5f15ab1c37
|
@ -84,14 +84,13 @@ const BrowserState = { scriptsForTab: {} };
|
||||||
|
|
||||||
chrome.debugger.onEvent.addListener((source, method, params) => {
|
chrome.debugger.onEvent.addListener((source, method, params) => {
|
||||||
console.log(source, method, params);
|
console.log(source, method, params);
|
||||||
if (method === "Page.") {
|
if (method === "Page.frameStartedLoading") {
|
||||||
// we're gonna assume we're always plugged into both Page and Debugger.
|
// we're gonna assume we're always plugged into both Page and Debugger.
|
||||||
BrowserState.scriptsForTab[source.tabId] = [];
|
BrowserState.scriptsForTab[source.tabId] = [];
|
||||||
|
|
||||||
} else if (method === "Debugger.scriptParsed") {
|
} else if (method === "Debugger.scriptParsed") {
|
||||||
BrowserState.scriptsForTab[source.tabId] = BrowserState.scriptsForTab[source.tabId] || [];
|
BrowserState.scriptsForTab[source.tabId] = BrowserState.scriptsForTab[source.tabId] || [];
|
||||||
BrowserState.scriptsForTab[source.tabId].push(params);
|
BrowserState.scriptsForTab[source.tabId].push(params);
|
||||||
// FIXME: clear these out when page changes in tab (how?)
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
5
test/Makefile
Normal file
5
test/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
run-test: test
|
||||||
|
./test
|
||||||
|
|
||||||
|
test: test.c
|
||||||
|
cc -o $@ $^
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
@ -24,20 +25,20 @@ char* expand(char* phrase) { // expand path with wildcard
|
||||||
|
|
||||||
// integration tests
|
// integration tests
|
||||||
int main() {
|
int main() {
|
||||||
assert(system("node extension/background.js --unhandled-rejections=strict") == 0); // run quick local JS tests
|
assert(system("node ../extension/background.js --unhandled-rejections=strict") == 0); // run quick local JS tests
|
||||||
|
|
||||||
// reload the extension so we know it's the latest code.
|
// reload the extension so we know it's the latest code.
|
||||||
system("echo reload > fs/mnt/runtime/reload"); // this may error, but it should still have effect
|
system("echo reload > ../fs/mnt/runtime/reload 2>/dev/null"); // this may error, but it should still have effect
|
||||||
// FIXME: race here
|
// spin until the extension reloads.
|
||||||
sleep(4);
|
struct stat st; while (stat("../fs/mnt/tabs", &st) != 0) {}
|
||||||
|
|
||||||
|
assert(file_contents_equal(expand("../fs/mnt/extensions/TabFS*/enabled"), "true"));
|
||||||
|
|
||||||
// FIXME: synthesize some kind of web page
|
// FIXME: synthesize some kind of web page
|
||||||
assert(system("echo about:blank > fs/mnt/tabs/create") == 0);
|
assert(system("echo about:blank > ../fs/mnt/tabs/create") == 0);
|
||||||
// FIXME: race here
|
// FIXME: race here
|
||||||
assert(file_contents_equal("fs/mnt/tabs/last-focused/url.txt", "about:blank"));
|
assert(file_contents_equal("../fs/mnt/tabs/last-focused/url.txt", "about:blank"));
|
||||||
assert(system("echo remove > fs/mnt/tabs/last-focused/control") == 0);
|
assert(system("echo remove > ../fs/mnt/tabs/last-focused/control") == 0);
|
||||||
|
|
||||||
assert(file_contents_equal(expand("fs/mnt/extensions/TabFS*/enabled"), "true"));
|
|
||||||
|
|
||||||
assert(1); printf("Done!\n");
|
assert(1); printf("Done!\n");
|
||||||
}
|
}
|
Loading…
Reference in a new issue