Bug 1497150 - Convert browser_toolbox_options_disable_js.js to async test. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 16 Oct 2018 22:17:18 +0000
changeset 500044 965bcae7a111f7d8af52dad76a6973b30411be96
parent 500043 99c45aca2d8a868eb9e6c3c5543af78954839934
child 500045 8ea8fc9bc95bd0ae8d61bd74c1eecab54d645902
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1497150
milestone64.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 1497150 - Convert browser_toolbox_options_disable_js.js to async test. r=jdescottes MozReview-Commit-ID: 132swUYwGZw Differential Revision: https://phabricator.services.mozilla.com/D8851
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,29 +2,22 @@
 /* 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";
 
-function test() {
-  addTab(TEST_URI).then(async (tab) => {
-    const target = await TargetFactory.forTab(tab);
-    gDevTools.showToolbox(target).then(testSelectTool);
-  });
-}
+add_task(async function() {
+  const tab = await addTab(TEST_URI);
+  const target = await TargetFactory.forTab(tab);
+  const toolbox = await gDevTools.showToolbox(target);
 
-function testSelectTool(toolbox) {
-  toolbox.once("options-selected", () => testToggleJS(toolbox));
-  toolbox.selectTool("options");
-}
-
-const testToggleJS = async function(toolbox) {
+  await toolbox.selectTool("options");
   ok(true, "Toolbox selected via selectTool method");
 
   await testJSEnabled();
   await testJSEnabledIframe();
 
   // Disable JS.
   await toggleJS(toolbox);
 
@@ -32,18 +25,19 @@ const testToggleJS = async function(tool
   await testJSDisabledIframe();
 
   // Re-enable JS.
   await toggleJS(toolbox);
 
   await testJSEnabled();
   await testJSEnabledIframe();
 
-  finishUp(toolbox);
-};
+  await toolbox.destroy();
+  gBrowser.removeCurrentTab();
+});
 
 async function testJSEnabled() {
   info("Testing that JS is enabled");
 
   // We use waitForTick here because switching docShell.allowJavascript to true
   // takes a while to become live.
   await waitForTick();
 
@@ -105,15 +99,8 @@ async function testJSDisabledIframe() {
     const iframe = doc.querySelector("iframe");
     const iframeDoc = iframe.contentDocument;
     const output = iframeDoc.getElementById("output");
     iframeDoc.querySelector("#logJSDisabled").click();
     ok(output.textContent !== "JavaScript Disabled",
        'output is not "JavaScript Disabled" in iframe');
   });
 }
-
-function finishUp(toolbox) {
-  toolbox.destroy().then(function() {
-    gBrowser.removeCurrentTab();
-    finish();
-  });
-}