Bug 1402503: Part 2 - Add test for extension slow script dialog. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Mon, 25 Sep 2017 11:49:39 -0700
changeset 434295 d2fef59cb50727486b4d59125668808a0b2e46e4
parent 434294 71d2e5d65943b2fcd77faf2eebdcf3e1b20741c3
child 434296 557dd09e0e29b0ac8f8e9e67a218e4b444edf6b4
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1402503
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1402503: Part 2 - Add test for extension slow script dialog. r=mixedpuppy MozReview-Commit-ID: BknBhAttKHS
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/browser_ext_slow_script.js
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -120,16 +120,18 @@ skip-if = debug || asan # Bug 1354681
 [browser_ext_settings_overrides_search.js]
 [browser_ext_sidebarAction.js]
 [browser_ext_sidebarAction_browser_style.js]
 [browser_ext_sidebarAction_context.js]
 [browser_ext_sidebarAction_contextMenu.js]
 [browser_ext_sidebarAction_tabs.js]
 [browser_ext_sidebarAction_windows.js]
 [browser_ext_simple.js]
+[browser_ext_slow_script.js]
+skip-if = !e10s || debug
 [browser_ext_tab_runtimeConnect.js]
 [browser_ext_tabs_audio.js]
 [browser_ext_tabs_captureVisibleTab.js]
 [browser_ext_tabs_create.js]
 [browser_ext_tabs_create_invalid_url.js]
 [browser_ext_tabs_detectLanguage.js]
 [browser_ext_tabs_discarded.js]
 [browser_ext_tabs_duplicate.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/extensions/test/browser/browser_ext_slow_script.js
@@ -0,0 +1,47 @@
+/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set sts=2 sw=2 et tw=80: */
+"use strict";
+
+add_task(async function test_slow_content_script() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["dom.ipc.reportProcessHangs", true]],
+  });
+
+  let extension = ExtensionTestUtils.loadExtension({
+    useAddonManager: "temporary",
+
+    manifest: {
+      name: "Slow Script Extension",
+
+      content_scripts: [{
+        matches: ["http://example.com/"],
+        js: ["content.js"],
+      }],
+    },
+
+    files: {
+      "content.js": function() {
+        while (true) {
+          // Busy wait.
+        }
+      },
+    },
+  });
+
+  await extension.startup();
+
+  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/");
+
+  let notification = await BrowserTestUtils.waitForGlobalNotificationBar(window, "process-hang");
+  let text = document.getAnonymousElementByAttribute(notification, "anonid", "messageText").textContent;
+
+  ok(text.includes("\u201cSlow Script Extension\u201d"),
+     "Label is correct");
+
+  let stopButton = notification.querySelector("[label='Stop It']");
+  stopButton.click();
+
+  await BrowserTestUtils.removeTab(tab);
+
+  await extension.unload();
+});