summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-02-13 19:11:37 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-02-13 19:11:37 +0100
commit43d44975b1f49df640916cca5f6a0b138696da3c (patch)
tree98b95bb1043fc6a599e3c02fbb9b1ee7a363bf89 /toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
parent6bb02d95f70000b150569089987701c8244d7d5d (diff)
downloadUXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar
UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.gz
UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.lz
UXP-43d44975b1f49df640916cca5f6a0b138696da3c.tar.xz
UXP-43d44975b1f49df640916cca5f6a0b138696da3c.zip
Remove WebExtension support from the platform.
- Conditional code - WE APIs - WE toolkit theming
Diffstat (limited to 'toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html')
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html116
1 files changed, 0 insertions, 116 deletions
diff --git a/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html b/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
deleted file mode 100644
index 39f1bfabd..000000000
--- a/toolkit/components/webextensions/test/mochitest/test_ext_contentscript.html
+++ /dev/null
@@ -1,116 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>Test for content script</title>
- <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>
-
-<script type="text/javascript">
-"use strict";
-
-add_task(function* test_contentscript() {
- function background() {
- browser.runtime.onMessage.addListener(([msg, expectedStates, readyState], sender) => {
- if (msg == "chrome-namespace-ok") {
- browser.test.sendMessage(msg);
- return;
- }
-
- browser.test.assertEq("script-run", msg, "message type is correct");
- browser.test.assertTrue(expectedStates.includes(readyState),
- `readyState "${readyState}" is one of [${expectedStates}]`);
- browser.test.sendMessage("script-run-" + expectedStates[0]);
- });
- }
-
- function contentScriptStart() {
- browser.runtime.sendMessage(["script-run", ["loading"], document.readyState]);
- }
- function contentScriptEnd() {
- browser.runtime.sendMessage(["script-run", ["interactive", "complete"], document.readyState]);
- }
- function contentScriptIdle() {
- browser.runtime.sendMessage(["script-run", ["complete"], document.readyState]);
- }
-
- function contentScript() {
- let manifest = browser.runtime.getManifest();
- void manifest.applications.gecko.id;
- chrome.runtime.sendMessage(["chrome-namespace-ok"]);
- }
-
- let extensionData = {
- manifest: {
- applications: {gecko: {id: "contentscript@tests.mozilla.org"}},
- content_scripts: [
- {
- "matches": ["http://mochi.test/*/file_sample.html"],
- "js": ["content_script_start.js"],
- "run_at": "document_start",
- },
- {
- "matches": ["http://mochi.test/*/file_sample.html"],
- "js": ["content_script_end.js"],
- "run_at": "document_end",
- },
- {
- "matches": ["http://mochi.test/*/file_sample.html"],
- "js": ["content_script_idle.js"],
- "run_at": "document_idle",
- },
- {
- "matches": ["http://mochi.test/*/file_sample.html"],
- "js": ["content_script.js"],
- "run_at": "document_idle",
- },
- ],
- },
- background,
-
- files: {
- "content_script_start.js": contentScriptStart,
- "content_script_end.js": contentScriptEnd,
- "content_script_idle.js": contentScriptIdle,
- "content_script.js": contentScript,
- },
- };
-
- let extension = ExtensionTestUtils.loadExtension(extensionData);
-
- let loadingCount = 0;
- let interactiveCount = 0;
- let completeCount = 0;
- extension.onMessage("script-run-loading", () => { loadingCount++; });
- extension.onMessage("script-run-interactive", () => { interactiveCount++; });
-
- let completePromise = new Promise(resolve => {
- extension.onMessage("script-run-complete", () => { completeCount++; resolve(); });
- });
-
- let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
-
- yield extension.startup();
-
- let win = window.open("file_sample.html");
-
- yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
- info("test page loaded");
-
- win.close();
-
- is(loadingCount, 1, "document_start script ran exactly once");
- is(interactiveCount, 1, "document_end script ran exactly once");
- is(completeCount, 1, "document_idle script ran exactly once");
-
- yield extension.unload();
- info("extension unloaded");
-});
-</script>
-
-</body>
-</html>