Backed out 4 changesets (bug 1473614) for xpcshell failures on test_sync.js. CLOSED TREE
authorNarcis Beleuzu <nbeleuzu@mozilla.com>
Sun, 05 Aug 2018 18:17:36 +0300
changeset 485302 bcd31adc1e7a2bac67c7f9dcce38eb42d1f66c48
parent 485301 541bad93631c1dfbb89fd0c7c32fb11662df2d40
child 485303 7a3737f257d51c78110bbab40017dbb593410518
child 485307 29d7c031259062bcc09215618787a008778df1fe
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1473614
milestone63.0a1
backs out027922b5ef0442e4ebb07043d2b57961e6195a78
1d28e128807c3969771d1722bc567713606add73
1ee58097b1412972a3ce2a6be6114025747f3f0a
87a0ebcd004ffb9c15716b36635286bb4e3bd167
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 4 changesets (bug 1473614) for xpcshell failures on test_sync.js. CLOSED TREE Backed out changeset 027922b5ef04 (bug 1473614) Backed out changeset 1d28e128807c (bug 1473614) Backed out changeset 1ee58097b141 (bug 1473614) Backed out changeset 87a0ebcd004f (bug 1473614)
testing/marionette/doc/internals/sync.rst
testing/marionette/sync.js
testing/marionette/test/unit/test_sync.js
--- a/testing/marionette/doc/internals/sync.rst
+++ b/testing/marionette/doc/internals/sync.rst
@@ -1,16 +1,10 @@
 sync module
 ===========
 
 Provides an assortment of synchronisation primitives.
 
-.. js:autoclass:: MessageManagerDestroyedPromise
-  :members:
-
 .. js:autoclass:: PollPromise
   :members:
 
-.. js:autoclass:: Sleep
-  :members:
-
 .. js:autoclass:: TimedPromise
   :members:
--- a/testing/marionette/sync.js
+++ b/testing/marionette/sync.js
@@ -11,20 +11,22 @@ const {
   error,
   TimeoutError,
 } = ChromeUtils.import("chrome://marionette/content/error.js", {});
 const {Log} = ChromeUtils.import("chrome://marionette/content/log.js", {});
 
 XPCOMUtils.defineLazyGetter(this, "logger", Log.get);
 
 this.EXPORTED_SYMBOLS = [
-  "MessageManagerDestroyedPromise",
+  /* exported PollPromise, TimedPromise */
   "PollPromise",
-  "Sleep",
   "TimedPromise",
+
+  /* exported MessageManagerDestroyedPromise */
+  "MessageManagerDestroyedPromise",
 ];
 
 const {TYPE_ONE_SHOT, TYPE_REPEATING_SLACK} = Ci.nsITimer;
 
 /**
  * @callback Condition
  *
  * @param {function(*)} resolve
@@ -79,35 +81,20 @@ const {TYPE_ONE_SHOT, TYPE_REPEATING_SLA
  *     Defaults to 10 milliseconds.
  *
  * @return {Promise.<*>}
  *     Yields the value passed to ``func``'s
  *     ``resolve`` or ``reject`` callbacks.
  *
  * @throws {*}
  *     If ``func`` throws, its error is propagated.
- * @throws {TypeError}
- *     If `timeout` or `interval`` are not numbers.
- * @throws {RangeError}
- *     If `timeout` or `interval` are not unsigned integers.
  */
 function PollPromise(func, {timeout = 2000, interval = 10} = {}) {
   const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
-  if (typeof func != "function") {
-    throw new TypeError();
-  }
-  if (!(typeof timeout == "number" && typeof interval == "number")) {
-    throw new TypeError();
-  }
-  if ((!Number.isInteger(timeout) || timeout < 0) ||
-      (!Number.isInteger(interval) || interval < 0)) {
-    throw new RangeError();
-  }
-
   return new Promise((resolve, reject) => {
     const start = new Date().getTime();
     const end = start + timeout;
 
     let evalFn = () => {
       new Promise(func).then(resolve, rejected => {
         if (error.isError(rejected)) {
           throw rejected;
@@ -144,43 +131,28 @@ function PollPromise(func, {timeout = 20
  *
  * @param {Condition} func
  *     Function to run, which will have its ``reject``
  *     callback invoked after the ``timeout`` duration is reached.
  *     It is given two callbacks: ``resolve(value)`` and
  *     ``reject(error)``.
  * @param {timeout=} [timeout=1500] timeout
  *     ``condition``'s ``reject`` callback will be called
- *     after this timeout, given in milliseconds.
+ *     after this timeout.
  * @param {Error=} [throws=TimeoutError] throws
  *     When the ``timeout`` is hit, this error class will be
  *     thrown.  If it is null, no error is thrown and the promise is
  *     instead resolved on timeout.
  *
  * @return {Promise.<*>}
  *     Timed promise.
- *
- * @throws {TypeError}
- *     If `timeout` is not a number.
- * @throws {RangeError}
- *     If `timeout` is not an unsigned integer.
  */
 function TimedPromise(fn, {timeout = 1500, throws = TimeoutError} = {}) {
   const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
 
-  if (typeof fn != "function") {
-    throw new TypeError();
-  }
-  if (typeof timeout != "number") {
-    throw new TypeError();
-  }
-  if (!Number.isInteger(timeout) || timeout < 0) {
-    throw new RangeError();
-  }
-
   return new Promise((resolve, reject) => {
     // Reject only if |throws| is given.  Otherwise it is assumed that
     // the user is OK with the promise timing out.
     let bail = () => {
       if (throws !== null) {
         let err = new throws();
         reject(err);
       } else {
@@ -201,37 +173,16 @@ function TimedPromise(fn, {timeout = 150
     return res;
   }, err => {
     timer.cancel();
     throw err;
   });
 }
 
 /**
- * Pauses for the given duration.
- *
- * @param {number} timeout
- *     Duration to wait before fulfilling promise in milliseconds.
- *
- * @return {Promise}
- *     Promise that fulfills when the `timeout` is elapsed.
- *
- * @throws {TypeError}
- *     If `timeout` is not a number.
- * @throws {RangeError}
- *     If `timeout` is not an unsigned integer.
- */
-function Sleep(timeout) {
-  if (typeof timeout != "number") {
-    throw new TypeError();
-  }
-  return new TimedPromise(() => {}, {timeout, throws: null});
-}
-
-/**
  * Detects when the specified message manager has been destroyed.
  *
  * One can observe the removal and detachment of a content browser
  * (`<xul:browser>`) or a chrome window by its message manager
  * disconnecting.
  *
  * When a browser is associated with a tab, this is safer than only
  * relying on the event `TabClose` which signalises the _intent to_
--- a/testing/marionette/test/unit/test_sync.js
+++ b/testing/marionette/test/unit/test_sync.js
@@ -1,55 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-const {
-  PollPromise,
-  Sleep,
-  TimedPromise,
-} = ChromeUtils.import("chrome://marionette/content/sync.js", {});
+const {PollPromise} = ChromeUtils.import("chrome://marionette/content/sync.js", {});
 
 const DEFAULT_TIMEOUT = 2000;
 
-add_test(function test_PollPromise_funcTypes() {
-  for (let type of ["foo", 42, null, undefined, true, [], {}]) {
-    Assert.throws(() => new PollPromise(type), /TypeError/);
-  }
-  new PollPromise(() => {});
-  new PollPromise(function() {});
-
-  run_next_test();
-});
-
-add_test(function test_PollPromise_timeoutTypes() {
-  for (let timeout of ["foo", null, true, [], {}]) {
-    Assert.throws(() => new PollPromise(() => {}, {timeout}), /TypeError/);
-  }
-  for (let timeout of [1.2, -1]) {
-    Assert.throws(() => new PollPromise(() => {}, {timeout}), /RangeError/);
-  }
-  new PollPromise(() => {}, {timeout: 42});
-
-  run_next_test();
-});
-
-add_test(function test_PollPromise_intervalTypes() {
-  for (let interval of ["foo", null, true, [], {}]) {
-    Assert.throws(() => new PollPromise(() => {}, {interval}), /TypeError/);
-  }
-  for (let interval of [1.2, -1]) {
-    Assert.throws(() => new PollPromise(() => {}, {interval}), /RangeError/);
-  }
-  new PollPromise(() => {}, {interval: 42});
-
-  run_next_test();
-});
-
-add_task(async function test_PollPromise_retvalTypes() {
+add_task(async function test_PollPromise_types() {
   for (let typ of [true, false, "foo", 42, [], {}]) {
     strictEqual(typ, await new PollPromise(resolve => resolve(typ)));
   }
 });
 
 add_task(async function test_PollPromise_timeoutElapse() {
   let nevals = 0;
   let start = new Date().getTime();
@@ -105,39 +67,8 @@ add_task(async function test_PollPromise
 add_task(async function test_PollPromise_interval() {
   let nevals = 0;
   await new PollPromise((resolve, reject) => {
     ++nevals;
     reject();
   }, {timeout: 100, interval: 100});
   equal(2, nevals);
 });
-
-add_test(function test_TimedPromise_funcTypes() {
-  for (let type of ["foo", 42, null, undefined, true, [], {}]) {
-    Assert.throws(() => new TimedPromise(type), /TypeError/);
-  }
-  new TimedPromise(() => {});
-  new TimedPromise(function() {});
-
-  run_next_test();
-});
-
-add_test(function test_TimedPromise_timeoutTypes() {
-  for (let timeout of ["foo", null, true, [], {}]) {
-    Assert.throws(() => new TimedPromise(() => {}, {timeout}), /TypeError/);
-  }
-  for (let timeout of [1.2, -1]) {
-    Assert.throws(() => new TimedPromise(() => {}, {timeout}), /RangeError/);
-  }
-  new TimedPromise(() => {}, {timeout: 42});
-
-  run_next_test();
-});
-
-add_task(async function test_Sleep() {
-  await Sleep(0);
-  for (let type of ["foo", true, null, undefined]) {
-    Assert.throws(() => Sleep(type), /TypeError/);
-  }
-  Assert.throws(() => Sleep(1.2), /RangeError/);
-  Assert.throws(() => Sleep(-1), /RangeError/);
-});