mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1202501 - [webext] Clean up WebExtension tests (r=gabor)
This commit is contained in:
parent
e974ed1c63
commit
da4cdc43c0
@ -1,7 +1,7 @@
|
||||
[DEFAULT]
|
||||
skip-if = os == 'android' || buildapp == 'b2g' || os == 'mac'
|
||||
|
||||
[browser_extensions_simple.js]
|
||||
[browser_ext_simple.js]
|
||||
[browser_ext_browserAction_simple.js]
|
||||
[browser_ext_tabs_executeScript.js]
|
||||
[browser_ext_tabs_query.js]
|
||||
|
@ -636,6 +636,20 @@ Extension.prototype = {
|
||||
return {};
|
||||
},
|
||||
|
||||
broadcast(msg, data) {
|
||||
return new Promise(resolve => {
|
||||
let count = Services.ppmm.childCount;
|
||||
Services.ppmm.addMessageListener(msg + "Complete", function listener() {
|
||||
count--;
|
||||
if (count == 0) {
|
||||
Services.ppmm.removeMessageListener(msg + "Complete", listener);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
Services.ppmm.broadcastAsyncMessage(msg, data);
|
||||
});
|
||||
},
|
||||
|
||||
runManifest(manifest) {
|
||||
let permissions = manifest.permissions || [];
|
||||
let webAccessibleResources = manifest.web_accessible_resources || [];
|
||||
@ -666,7 +680,8 @@ Extension.prototype = {
|
||||
}
|
||||
let serial = this.serialize();
|
||||
data["Extension:Extensions"].push(serial);
|
||||
Services.ppmm.broadcastAsyncMessage("Extension:Startup", serial);
|
||||
|
||||
return this.broadcast("Extension:Startup", serial);
|
||||
},
|
||||
|
||||
callOnClose(obj) {
|
||||
@ -696,7 +711,7 @@ Extension.prototype = {
|
||||
|
||||
Management.emit("startup", this);
|
||||
|
||||
this.runManifest(manifest);
|
||||
return this.runManifest(manifest);
|
||||
}).catch(e => {
|
||||
dump(`Extension error: ${e} ${e.fileName}:${e.lineNumber}\n`);
|
||||
Cu.reportError(e);
|
||||
@ -714,19 +729,13 @@ Extension.prototype = {
|
||||
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
|
||||
let count = Services.ppmm.childCount;
|
||||
|
||||
Services.ppmm.addMessageListener("Extension:FlushJarCacheComplete", function listener() {
|
||||
count--;
|
||||
if (count == 0) {
|
||||
// We can't delete this file until everyone using it has
|
||||
// closed it (because Windows is dumb). So we wait for all the
|
||||
// child processes (including the parent) to flush their JAR
|
||||
// caches. These caches may keep the file open.
|
||||
file.remove(false);
|
||||
}
|
||||
this.broadcast("Extension:FlushJarCache", {path: file.path}).then(() => {
|
||||
// We can't delete this file until everyone using it has
|
||||
// closed it (because Windows is dumb). So we wait for all the
|
||||
// child processes (including the parent) to flush their JAR
|
||||
// caches. These caches may keep the file open.
|
||||
file.remove(false);
|
||||
});
|
||||
Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path});
|
||||
},
|
||||
|
||||
shutdown() {
|
||||
|
@ -483,6 +483,7 @@ var ExtensionManager = {
|
||||
extension = new BrowserExtensionContent(data);
|
||||
this.extensions.set(data.id, extension);
|
||||
DocumentManager.startupExtension(data.id);
|
||||
Services.cpmm.sendAsyncMessage("Extension:StartupComplete");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6,22 +6,22 @@
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script_start.js"],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script_end.js"],
|
||||
"run_at": "document_end"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script_idle.js"],
|
||||
"run_at": "document_idle"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_idle"
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ support-files =
|
||||
file_script_bad.js
|
||||
file_script_redirect.js
|
||||
file_script_xhr.js
|
||||
file_contentscript_page1.html
|
||||
file_sample.html
|
||||
|
||||
[test_simple_extensions.html]
|
||||
[test_ext_simple.html]
|
||||
[test_ext_geturl.html]
|
||||
[test_extension_contentscript.html]
|
||||
[test_extension_webrequest.html]
|
||||
[test_generate_extension.html]
|
||||
[test_sandbox_var.html]
|
||||
[test_ext_contentscript.html]
|
||||
[test_ext_webrequest.html]
|
||||
[test_ext_generate.html]
|
||||
[test_ext_sandbox_var.html]
|
||||
|
@ -5,6 +5,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -30,13 +31,7 @@ add_task(function* test_contentscript()
|
||||
|
||||
let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
|
||||
ok(true, "page loaded");
|
||||
let win = window.open("file_sample.html");
|
||||
|
||||
yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
|
||||
info("test page loaded");
|
||||
@ -50,15 +45,6 @@ add_task(function* test_contentscript()
|
||||
yield extension.unload();
|
||||
info("extension unloaded");
|
||||
});
|
||||
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
@ -5,6 +5,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
@ -40,7 +40,7 @@ let extensionData = {
|
||||
background: "(" + backgroundScript.toString() + ")()",
|
||||
manifest: {
|
||||
"content_scripts": [{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_start"
|
||||
}]
|
||||
@ -56,11 +56,7 @@ add_task(function* test_contentscript() {
|
||||
yield extension.startup();
|
||||
info("extension loaded");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
let win = window.open("file_sample.html");
|
||||
|
||||
yield Promise.all([waitForLoad(win), extension.awaitFinish("geturl")]);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -29,7 +30,7 @@ let extensionData = {
|
||||
background: "(" + backgroundScript.toString() + ")()",
|
||||
manifest: {
|
||||
"content_scripts": [{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"matches": ["http://mochi.test/*/file_sample.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_start"
|
||||
}]
|
||||
@ -45,11 +46,7 @@ add_task(function* test_contentscript() {
|
||||
yield extension.startup();
|
||||
info("extension loaded");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
let win = window.open("file_sample.html");
|
||||
|
||||
yield Promise.all([waitForLoad(win), extension.awaitFinish()]);
|
||||
|
||||
@ -58,15 +55,6 @@ add_task(function* test_contentscript() {
|
||||
yield extension.unload();
|
||||
info("extension unloaded");
|
||||
});
|
||||
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
@ -5,6 +5,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
@ -5,6 +5,7 @@
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -119,15 +120,6 @@ function* test_once()
|
||||
// Run the test twice to make sure it works with caching.
|
||||
add_task(test_once);
|
||||
add_task(test_once);
|
||||
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
Loading…
Reference in New Issue
Block a user