1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test for content script unrecognized property on manifest</title>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
const BASE = "http://mochi.test:8888/chrome/toolkit/components/extensions/test/mochitest";
add_task(async function test_contentscript() {
function background() {
browser.runtime.onMessage.addListener(async (msg) => {
if (msg == "loaded") {
// NOTE: we're removing the tab from here because doing a win.close()
// from the chrome test code is raising a "TypeError: can't access
// dead object" exception.
let tabs = await browser.tabs.query({active: true, currentWindow: true});
await browser.tabs.remove(tabs[0].id);
browser.test.notifyPass("content-script-loaded");
}
});
}
function contentScript() {
chrome.runtime.sendMessage("loaded");
}
let extensionData = {
manifest: {
content_scripts: [
{
"matches": ["http://mochi.test/*/file_sample.html"],
"js": ["content_script.js"],
"run_at": "document_idle",
"unrecognized_property": "with-a-random-value",
},
],
},
background,
files: {
"content_script.js": contentScript,
},
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
SimpleTest.waitForExplicitFinish();
let waitForConsole = new Promise(resolve => {
SimpleTest.monitorConsole(resolve, [{
message: /Reading manifest: Warning processing content_scripts.*.unrecognized_property: An unexpected property was found/,
}]);
});
ExtensionTestUtils.failOnSchemaWarnings(false);
await extension.startup();
ExtensionTestUtils.failOnSchemaWarnings(true);
window.open(`${BASE}/file_sample.html`);
await Promise.all([extension.awaitFinish("content-script-loaded")]);
info("test page loaded");
await extension.unload();
SimpleTest.endMonitorConsole();
await waitForConsole;
});
</script>
</body>
</html>
|