Bug 1239132 - Remove CPOW access from 'wait' function in shared-head.js r?pbro draft
authorJarda Snajdr <jsnajdr@gmail.com>
Mon, 12 Sep 2016 06:26:48 +0200
changeset 412577 5028350639414758715b2c398f93ff8b8304bb54
parent 412489 cfdb7af3af2e92e95f71ca2f1672bf5433beeb89
child 531015 3f47eb20322503081e98ab70a3adba28c8a5ce36
push id29202
push userbmo:jsnajdr@gmail.com
push dateMon, 12 Sep 2016 07:42:46 +0000
reviewerspbro
bugs1239132
milestone51.0a1
Bug 1239132 - Remove CPOW access from 'wait' function in shared-head.js r?pbro MozReview-Commit-ID: 1oifs1zuPZw
devtools/client/framework/test/shared-head.js
devtools/client/inspector/markup/test/head.js
devtools/client/responsivedesign/test/head.js
--- a/devtools/client/framework/test/shared-head.js
+++ b/devtools/client/framework/test/shared-head.js
@@ -286,19 +286,17 @@ function waitForTick() {
  * This shouldn't be used in the tests, but is useful when writing new tests or
  * debugging existing tests in order to introduce delays in the test steps
  *
  * @param {Number} ms
  *        The time to wait
  * @return A promise that resolves when the time is passed
  */
 function wait(ms) {
-  let def = defer();
-  content.setTimeout(def.resolve, ms);
-  return def.promise;
+  return new promise(resolve => setTimeout(resolve, ms));
 }
 
 /**
  * Open the toolbox in a given tab.
  * @param {XULNode} tab The tab the toolbox should be opened in.
  * @param {String} toolId Optional. The ID of the tool to be selected.
  * @param {String} hostType Optional. The type of toolbox host to be used.
  * @return {Promise} Resolves with the toolbox, when it has been opened.
--- a/devtools/client/inspector/markup/test/head.js
+++ b/devtools/client/inspector/markup/test/head.js
@@ -267,28 +267,16 @@ function searchUsingSelectorSearch(selec
   info("Entering \"" + selector + "\" into the selector-search input field");
   let field = getSelectorSearchBox(inspector);
   field.focus();
   field.value = selector;
   EventUtils.sendKey("return", inspector.panelWin);
 }
 
 /**
- * This shouldn't be used in the tests, but is useful when writing new tests or
- * debugging existing tests in order to introduce delays in the test steps
- * @param {Number} ms The time to wait
- * @return A promise that resolves when the time is passed
- */
-function wait(ms) {
-  let def = defer();
-  setTimeout(def.resolve, ms);
-  return def.promise;
-}
-
-/**
  * Check to see if the inspector menu items for editing are disabled.
  * Things like Edit As HTML, Delete Node, etc.
  * @param {NodeFront} nodeFront
  * @param {InspectorPanel} inspector
  * @param {Boolean} assert Should this function run assertions inline.
  * @return A promise that resolves with a boolean indicating whether
  *         the menu items are disabled once the menu has been checked.
  */
--- a/devtools/client/responsivedesign/test/head.js
+++ b/devtools/client/responsivedesign/test/head.js
@@ -196,22 +196,16 @@ var addTab = Task.async(function* (url) 
   let browser = tab.linkedBrowser;
 
   yield once(browser, "load", true);
   info("URL '" + url + "' loading complete");
 
   return tab;
 });
 
-function wait(ms) {
-  let def = promise.defer();
-  setTimeout(def.resolve, ms);
-  return def.promise;
-}
-
 /**
  * Waits for the next load to complete in the current browser.
  *
  * @return promise
  */
 function waitForDocLoadComplete(aBrowser = gBrowser) {
   let deferred = promise.defer();
   let progressListener = {