Backed out changeset e178424c2e2a (bug 1261714) for landed already on m-i
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Thu, 07 Jul 2016 06:22:16 +0200
changeset 304064 5a6bbd20aa4d45b211d419222ea3f1ae13a470f0
parent 304063 e178424c2e2a702ff2c7738e639c59bbed5a17cf
child 304065 79d1579dee2efce35b2afed4d13b70855719ec4c
push id30411
push userkwierso@gmail.com
push dateFri, 08 Jul 2016 00:26:45 +0000
treeherdermozilla-central@23dc78b7b57e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1261714
milestone50.0a1
backs oute178424c2e2a702ff2c7738e639c59bbed5a17cf
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
Backed out changeset e178424c2e2a (bug 1261714) for landed already on m-i
devtools/client/framework/test/browser_toolbox_options_disable_js.js
--- a/devtools/client/framework/test/browser_toolbox_options_disable_js.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_js.js
@@ -2,123 +2,108 @@
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests that disabling JavaScript for a tab works as it should.
 
 const TEST_URI = URL_ROOT + "browser_toolbox_options_disable_js.html";
 
+var doc;
+var toolbox;
+
 function test() {
   gBrowser.selectedTab = gBrowser.addTab();
   let target = TargetFactory.forTab(gBrowser.selectedTab);
 
   gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
     gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
+    doc = content.document;
     gDevTools.showToolbox(target).then(testSelectTool);
   }, true);
 
-  BrowserTestUtils.loadURI(gBrowser.selectedBrowser, TEST_URI);
+  content.location = TEST_URI;
 }
 
-function testSelectTool(toolbox) {
-  toolbox.once("options-selected", () => testToggleJS(toolbox));
+function testSelectTool(aToolbox) {
+  toolbox = aToolbox;
+  toolbox.once("options-selected", testJSEnabled);
   toolbox.selectTool("options");
 }
 
-let testToggleJS = Task.async(function* (toolbox) {
+function testJSEnabled(event, tool, secondPass) {
   ok(true, "Toolbox selected via selectTool method");
-
-  yield testJSEnabled();
-  yield testJSEnabledIframe();
-
-  // Disable JS.
-  yield toggleJS(toolbox);
-
-  yield testJSDisabled();
-  yield testJSDisabledIframe();
-
-  // Re-enable JS.
-  yield toggleJS(toolbox);
-
-  yield testJSEnabled();
-  yield testJSEnabledIframe();
-
-  finishUp(toolbox);
-});
-
-function* testJSEnabled() {
   info("Testing that JS is enabled");
 
-  // We use waitForTick here because switching docShell.allowJavascript to true
+  // We use executeSoon here because switching docSehll.allowJavascript to true
   // takes a while to become live.
-  yield waitForTick();
-
-  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
-    let doc = content.document;
+  executeSoon(function () {
     let output = doc.getElementById("output");
     doc.querySelector("#logJSEnabled").click();
     is(output.textContent, "JavaScript Enabled", 'Output is "JavaScript Enabled"');
+    testJSEnabledIframe(secondPass);
   });
 }
 
-function* testJSEnabledIframe() {
+function testJSEnabledIframe(secondPass) {
   info("Testing that JS is enabled in the iframe");
 
-  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
-    let doc = content.document;
-    let iframe = doc.querySelector("iframe");
-    let iframeDoc = iframe.contentDocument;
-    let output = iframeDoc.getElementById("output");
-    iframeDoc.querySelector("#logJSEnabled").click();
-    is(output.textContent, "JavaScript Enabled",
-                            'Output is "JavaScript Enabled" in iframe');
-  });
+  let iframe = doc.querySelector("iframe");
+  let iframeDoc = iframe.contentDocument;
+  let output = iframeDoc.getElementById("output");
+  iframeDoc.querySelector("#logJSEnabled").click();
+  is(output.textContent, "JavaScript Enabled",
+                          'Output is "JavaScript Enabled" in iframe');
+  if (secondPass) {
+    finishUp();
+  } else {
+    toggleJS().then(testJSDisabled);
+  }
 }
 
-function* toggleJS(toolbox) {
+let toggleJS = Task.async(function* () {
   let panel = toolbox.getCurrentPanel();
   let cbx = panel.panelDoc.getElementById("devtools-disable-javascript");
 
   if (cbx.checked) {
     info("Clearing checkbox to re-enable JS");
   } else {
     info("Checking checkbox to disable JS");
   }
 
   let browserLoaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
   cbx.click();
   yield browserLoaded;
-}
+  doc = content.document;
+});
 
-function* testJSDisabled() {
+function testJSDisabled() {
   info("Testing that JS is disabled");
 
-  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
-    let doc = content.document;
-    let output = doc.getElementById("output");
-    doc.querySelector("#logJSDisabled").click();
+  let output = doc.getElementById("output");
+  doc.querySelector("#logJSDisabled").click();
+
+  ok(output.textContent !== "JavaScript Disabled",
+     'output is not "JavaScript Disabled"');
+  testJSDisabledIframe();
+}
 
-    ok(output.textContent !== "JavaScript Disabled",
-       'output is not "JavaScript Disabled"');
+function testJSDisabledIframe() {
+  info("Testing that JS is disabled in the iframe");
+
+  let iframe = doc.querySelector("iframe");
+  let iframeDoc = iframe.contentDocument;
+  let output = iframeDoc.getElementById("output");
+  iframeDoc.querySelector("#logJSDisabled").click();
+  ok(output.textContent !== "JavaScript Disabled",
+     'output is not "JavaScript Disabled" in iframe');
+  toggleJS().then(function () {
+    testJSEnabled(null, null, true);
   });
 }
 
-function* testJSDisabledIframe() {
-  info("Testing that JS is disabled in the iframe");
-
-  yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function () {
-    let doc = content.document;
-    let iframe = doc.querySelector("iframe");
-    let iframeDoc = iframe.contentDocument;
-    let output = iframeDoc.getElementById("output");
-    iframeDoc.querySelector("#logJSDisabled").click();
-    ok(output.textContent !== "JavaScript Disabled",
-       'output is not "JavaScript Disabled" in iframe');
-  });
-}
-
-function finishUp(toolbox) {
+function finishUp() {
   toolbox.destroy().then(function () {
     gBrowser.removeCurrentTab();
+    toolbox = doc = null;
     finish();
   });
 }