Bug 940537 - Convert to Promise.jsm in debugger UI. r=jlongster draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Fri, 18 Dec 2015 18:19:20 -0600
changeset 316460 c8f8eaeb7e8e44dfb2ed23fa8825c9eead46f084
parent 316459 2bce811a2aeab002669d028beebc85e0aaa6bef5
child 316461 cc7b41da3c0fca6665dd3e6f16d5af8128c6a84f
push id8560
push userjryans@gmail.com
push dateSat, 19 Dec 2015 00:21:55 +0000
reviewersjlongster
bugs940537
milestone46.0a1
Bug 940537 - Convert to Promise.jsm in debugger UI. r=jlongster
devtools/client/debugger/debugger-controller.js
devtools/client/debugger/test/mochitest/browser_dbg_blackboxing-04.js
devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js
devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-01.js
devtools/client/debugger/test/mochitest/browser_dbg_debugger-statement.js
devtools/client/debugger/test/mochitest/browser_dbg_search-global-02.js
devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js
devtools/client/debugger/test/mochitest/browser_dbg_stack-05.js
devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js
devtools/client/debugger/test/mochitest/head.js
--- a/devtools/client/debugger/debugger-controller.js
+++ b/devtools/client/debugger/debugger-controller.js
@@ -134,17 +134,17 @@ const { onReducerEvents } = require("./c
 const waitUntilService = require("devtools/client/shared/redux/middleware/wait-service");
 var services = {
   WAIT_UNTIL: waitUntilService.NAME
 };
 
 var {TargetFactory} = require("devtools/client/framework/target");
 var {Toolbox} = require("devtools/client/framework/toolbox");
 var DevToolsUtils = require("devtools/shared/DevToolsUtils");
-var promise = require("devtools/shared/deprecated-sync-thenables");
+var promise = require("promise");
 var Editor = require("devtools/client/sourceeditor/editor");
 var DebuggerEditor = require("devtools/client/sourceeditor/debugger");
 var {Tooltip} = require("devtools/client/shared/widgets/Tooltip");
 var FastListWidget = require("devtools/client/shared/widgets/FastListWidget");
 
 XPCOMUtils.defineConstant(this, "EVENTS", EVENTS);
 
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
--- a/devtools/client/debugger/test/mochitest/browser_dbg_blackboxing-04.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_blackboxing-04.js
@@ -25,24 +25,23 @@ function test() {
       .then(testBlackBoxStack)
       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
       .then(null, aError => {
         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
       });
   });
 }
 
-function blackBoxSources() {
+let blackBoxSources = Task.async(function*() {
   let finished = waitForThreadEvents(gPanel, "blackboxchange", 3);
-
-  toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_one.js"));
-  toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_two.js"));
-  toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_three.js"));
+  yield toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_one.js"));
+  yield toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_two.js"));
+  yield toggleBlackBoxing(gPanel, getSourceActor(gSources, EXAMPLE_URL + "code_blackboxing_three.js"));
   return finished;
-}
+});
 
 function testBlackBoxStack() {
   let finished = waitForSourceAndCaretAndScopes(gPanel, ".html", 21).then(() => {
     is(gFrames.itemCount, 4,
       "Should get 4 frames (one -> two -> three -> doDebuggerStatement).");
     is(gDebugger.document.querySelectorAll(".dbg-stackframe-black-boxed").length, 3,
       "And 'one', 'two', and 'three' should each have their own black boxed frame.");
   });
--- a/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_breakpoints-disabled-reload.js
@@ -87,17 +87,17 @@ function test() {
         yield ensureSourceIs(gPanel, "-02.js", true);
         yield verifyView({ disabled: false });
 
         callInTab(gTab, "firstCall");
         yield waitForSourceAndCaretAndScopes(gPanel, "-01.js", 1);
         yield verifyView({ disabled: false });
 
         executeSoon(() => gDebugger.gThreadClient.resume());
-        yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1);
+        yield waitForSourceAndCaretAndScopes(gPanel, "-02.js", 6);
         yield verifyView({ disabled: false });
       });
     }
 
     function testWhenBreakpointDisabledAndSecondSourceShown() {
       return Task.spawn(function*() {
         yield ensureSourceIs(gPanel, "-02.js", true);
         yield verifyView({ disabled: true });
--- a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-01.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-01.js
@@ -194,17 +194,17 @@ function test() {
       yield resumeAndTestBreakpoint(29);
       yield resumeAndTestBreakpoint(30);
       yield resumeAndTestNoBreakpoint();
 
       let sourceShown = waitForSourceShown(gPanel, ".html");
       reload(gPanel),
       yield sourceShown;
 
-      testAfterReload();
+      yield testAfterReload();
 
       // Reset traits back to default value
       client.mainRoot.traits.conditionalBreakpoints = true;
       closeDebuggerAndFinish(gPanel);
     });
 
     callInTab(gTab, "ermahgerd");
   });
--- a/devtools/client/debugger/test/mochitest/browser_dbg_debugger-statement.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_debugger-statement.js
@@ -71,16 +71,18 @@ function testDebuggerStatement([aGrip, a
     gClient.request({ to: aResponse.threadActor, type: "resume" }, () => {
       ok(true, "The pause handler was triggered on a debugger statement.");
       deferred.resolve();
     });
   });
 
   // Reach around the debugging protocol and execute the debugger statement.
   callInTab(gTab, "runDebuggerStatement");
+
+  return deferred.promise;
 }
 
 function closeConnection() {
   let deferred = promise.defer();
   gClient.close(deferred.resolve);
   return deferred.promise;
 }
 
--- a/devtools/client/debugger/test/mochitest/browser_dbg_search-global-02.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_search-global-02.js
@@ -52,17 +52,17 @@ function test() {
       setText(gSearchBox, "!function");
 
       return deferred.promise;
     }
 
     function doFirstJump() {
       let deferred = promise.defer();
 
-      waitForSourceAndCaret(gPanel, "-01.js", 4).then(() => {
+      waitForSourceAndCaret(gPanel, "-01.js", 4, 9).then(() => {
         info("Current source url:\n" + getSelectedSourceURL(gSources));
         info("Debugger editor text:\n" + gEditor.getText());
 
         ok(getSelectedSourceURL(gSources).includes("-01.js"),
            "The currently shown source is incorrect (1).");
         is(gSources.visibleItems.length, 2,
            "Not all the sources are shown after the global search (1).");
 
@@ -78,17 +78,17 @@ function test() {
       EventUtils.sendKey("DOWN", gDebugger);
 
       return deferred.promise;
     }
 
     function doSecondJump() {
       let deferred = promise.defer();
 
-      waitForSourceAndCaret(gPanel, "-02.js", 4).then(() => {
+      waitForSourceAndCaret(gPanel, "-02.js", 4, 9).then(() => {
         info("Current source url:\n" + getSelectedSourceURL(gSources));
         info("Debugger editor text:\n" + gEditor.getText());
 
         ok(getSelectedSourceURL(gSources).includes("-02.js"),
            "The currently shown source is incorrect (2).");
         is(gSources.visibleItems.length, 2,
            "Not all the sources are shown after the global search (2).");
 
@@ -103,17 +103,17 @@ function test() {
       EventUtils.sendKey("DOWN", gDebugger);
 
       return deferred.promise;
     }
 
     function doWrapAroundJump() {
       let deferred = promise.defer();
 
-      waitForSourceAndCaret(gPanel, "-01.js", 4).then(() => {
+      waitForSourceAndCaret(gPanel, "-01.js", 4, 9).then(() => {
         info("Current source url:\n" + getSelectedSourceURL(gSources));
         info("Debugger editor text:\n" + gEditor.getText());
 
         ok(getSelectedSourceURL(gSources).includes("-01.js"),
            "The currently shown source is incorrect (3).");
         is(gSources.visibleItems.length, 2,
            "Not all the sources are shown after the global search (3).");
 
@@ -130,17 +130,17 @@ function test() {
       EventUtils.sendKey("DOWN", gDebugger);
 
       return deferred.promise;
     }
 
     function doBackwardsWrapAroundJump() {
       let deferred = promise.defer();
 
-      waitForSourceAndCaret(gPanel, "-02.js", 7).then(() => {
+      waitForSourceAndCaret(gPanel, "-02.js", 7, 11).then(() => {
         info("Current source url:\n" + getSelectedSourceURL(gSources));
         info("Debugger editor text:\n" + gEditor.getText());
 
         ok(getSelectedSourceURL(gSources).includes("-02.js"),
            "The currently shown source is incorrect (4).");
         is(gSources.visibleItems.length, 2,
            "Not all the sources are shown after the global search (4).");
 
--- a/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_search-global-05.js
@@ -88,17 +88,17 @@ function testExpandCollapse() {
 
 function testClickLineToJump() {
   let deferred = promise.defer();
 
   let sourceResults = gDebugger.document.querySelectorAll(".dbg-source-results");
   let firstHeader = sourceResults[0].querySelector(".dbg-results-header");
   let firstLine = sourceResults[0].querySelector(".dbg-results-line-contents");
 
-  waitForSourceAndCaret(gPanel, "-01.js", 1, 1).then(() => {
+  waitForSourceAndCaret(gPanel, "-01.js", 1, 5).then(() => {
     info("Current source url:\n" + getSelectedSourceURL(gSources));
     info("Debugger editor text:\n" + gEditor.getText());
 
     ok(isCaretPos(gPanel, 1, 5),
       "The editor didn't jump to the correct line (1).");
     is(gEditor.getSelection(), "A",
       "The editor didn't select the correct text (1).");
     ok(getSelectedSourceURL(gSources).includes("-01.js"),
@@ -117,17 +117,17 @@ function testClickLineToJump() {
 function testClickMatchToJump() {
   let deferred = promise.defer();
 
   let sourceResults = gDebugger.document.querySelectorAll(".dbg-source-results");
   let secondHeader = sourceResults[1].querySelector(".dbg-results-header");
   let secondMatches = sourceResults[1].querySelectorAll(".dbg-results-line-contents-string[match=true]");
   let lastMatch = Array.slice(secondMatches).pop();
 
-  waitForSourceAndCaret(gPanel, "-02.js", 1, 1).then(() => {
+  waitForSourceAndCaret(gPanel, "-02.js", 13, 3).then(() => {
     info("Current source url:\n" + getSelectedSourceURL(gSources));
     info("Debugger editor text:\n" + gEditor.getText());
 
     ok(isCaretPos(gPanel, 13, 3),
       "The editor didn't jump to the correct line (2).");
     is(gEditor.getSelection(), "a",
       "The editor didn't select the correct text (2).");
     ok(getSelectedSourceURL(gSources).includes("-02.js"),
--- a/devtools/client/debugger/test/mochitest/browser_dbg_stack-05.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_stack-05.js
@@ -36,17 +36,17 @@ function test() {
          "The second source is selected in the widget.");
       ok(isCaretPos(gPanel, 6),
          "Editor caret location is correct.");
       is(gEditor.getDebugLocation(), 5,
          "Editor debug location is correct.");
     }
 
     function testOldestFrame() {
-      const shown = waitForSourceAndCaret(gPanel, "-01.js", 1).then(() => {
+      const shown = waitForSourceAndCaret(gPanel, "-01.js", 5).then(() => {
         is(gFrames.selectedIndex, 0,
            "Second frame should be selected after click.");
         is(gClassicFrames.selectedIndex, 1,
            "Second frame should be selected in the mirrored view as well.");
         is(gSources.selectedIndex, 0,
            "The first source is now selected in the widget.");
         ok(isCaretPos(gPanel, 5),
            "Editor caret location is correct (3).");
--- a/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_stack-06.js
@@ -33,29 +33,29 @@ function performTest() {
     "Newest frame should also be selected in the mirrored view.");
   is(gSources.selectedIndex, 1,
     "The second source is selected in the widget.");
   is(gEditor.getText().search(/firstCall/), -1,
     "The first source is not displayed.");
   is(gEditor.getText().search(/debugger/), 166,
     "The second source is displayed.");
 
-  waitForSourceAndCaret(gPanel, "-01.js", 1).then(waitForTick).then(() => {
+  waitForSourceAndCaret(gPanel, "-01.js", 5).then(waitForTick).then(() => {
     is(gFrames.selectedIndex, 0,
       "Oldest frame should be selected after click.");
     is(gClassicFrames.selectedIndex, 1,
       "Oldest frame should also be selected in the mirrored view.");
     is(gSources.selectedIndex, 0,
       "The first source is now selected in the widget.");
     is(gEditor.getText().search(/firstCall/), 118,
       "The first source is displayed.");
     is(gEditor.getText().search(/debugger/), -1,
       "The second source is not displayed.");
 
-    waitForSourceAndCaret(gPanel, "-02.js", 1).then(waitForTick).then(() => {
+    waitForSourceAndCaret(gPanel, "-02.js", 6).then(waitForTick).then(() => {
       is(gFrames.selectedIndex, 1,
         "Newest frame should be selected again after click.");
       is(gClassicFrames.selectedIndex, 0,
         "Newest frame should also be selected again in the mirrored view.");
       is(gSources.selectedIndex, 1,
         "The second source is selected in the widget.");
       is(gEditor.getText().search(/firstCall/), -1,
         "The first source is not displayed.");
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -14,19 +14,16 @@ Services.prefs.setBoolPref("devtools.deb
 var { BrowserToolboxProcess } = Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
 var { DebuggerServer } = require("devtools/server/main");
 var { DebuggerClient, ObjectClient } = require("devtools/shared/client/main");
 var { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm", {});
 var EventEmitter = require("devtools/shared/event-emitter");
 const { promiseInvoke } = require("devtools/shared/async-utils");
 var { Toolbox } = require("devtools/client/framework/toolbox")
 
-// Override promise with deprecated-sync-thenables
-promise = Cu.import("resource://devtools/shared/deprecated-sync-thenables.js", {}).Promise;
-
 const EXAMPLE_URL = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
 const FRAME_SCRIPT_URL = getRootDirectory(gTestPath) + "code_frame-script.js";
 
 registerCleanupFunction(function* () {
   info("finish() was called, cleaning up...");
   Services.prefs.setBoolPref("devtools.debugger.log", gEnableLogging);
 
   while (gBrowser && gBrowser.tabs && gBrowser.tabs.length > 1) {