summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html')
-rw-r--r--toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html84
1 files changed, 0 insertions, 84 deletions
diff --git a/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html b/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html
deleted file mode 100644
index 471c5339d..000000000
--- a/toolkit/components/webextensions/test/mochitest/test_chrome_ext_background_page.html
+++ /dev/null
@@ -1,84 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<head>
- <title>WebExtension test</title>
- <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
- <script src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
- <script src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
- <script type="text/javascript" src="chrome_head.js"></script>
- <script type="text/javascript" src="head.js"></script>
- <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/>
-</head>
-<body>
-
-<script type="text/javascript">
-"use strict";
-
-Cu.import("resource://testing-common/TestUtils.jsm");
-
-/* eslint-disable mozilla/balanced-listeners */
-
-add_task(function* testAlertNotShownInBackgroundWindow() {
- ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(),
- "Alerts should not be present at the start of the test.");
-
- let consoleOpened = TestUtils.topicObserved("web-console-created");
-
-
- let extension = ExtensionTestUtils.loadExtension({
- background: function() {
- browser.test.log("background script executed");
-
- alert("I am an alert in the background.");
-
- browser.test.notifyPass("alertCalled");
- },
- });
-
- yield extension.startup();
-
- info("startup complete loaded");
-
- yield extension.awaitFinish("alertCalled");
-
-
- let alertWindows = Services.wm.getEnumerator("alert:alert");
- ok(!alertWindows.hasMoreElements(), "Should not show alert");
-
-
- // Make sure the message we output to the console is seen.
- // This message is in ext-backgroundPage.js
- let events = Cc["@mozilla.org/consoleAPI-storage;1"]
- .getService(Ci.nsIConsoleAPIStorage).getEvents();
-
- // This is the warning that is output after the first `alert()` call is made.
- let alertWarningEvent = events[events.length - 2];
- is(alertWarningEvent.arguments[0], "alert() is not supported in background windows; please use console.log instead.");
-
- // This is the actual alert text that should be present in the console
- // instead of as an `alert`.
- let alertEvent = events[events.length - 1];
- is(alertEvent.arguments[0], "I am an alert in the background.");
-
-
- // Wait for the browser console window to open.
- yield consoleOpened;
-
- let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
- require("devtools/client/framework/devtools-browser");
- let {HUDService} = require("devtools/client/webconsole/hudservice");
-
- // And then double check that we have an actual browser console.
- let haveConsole = !!HUDService.getBrowserConsole();
- ok(haveConsole, "Expected browser console to be open");
-
- if (haveConsole) {
- yield HUDService.toggleBrowserConsole();
- }
-
- yield extension.unload();
-});
-</script>
-
-</body>
-</html>