forked from mirrors/gecko-dev
Bug 1532935 - Enable ESLint for dom/promise (manual changes). r=mccr8
Patch by Alec, updated by Standard8. Differential Revision: https://phabricator.services.mozilla.com/D29646 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6614404241
commit
6a56241703
18 changed files with 77 additions and 42 deletions
|
|
@ -15,7 +15,6 @@ obj*/**
|
||||||
dom/base/*.*
|
dom/base/*.*
|
||||||
dom/media/test/**
|
dom/media/test/**
|
||||||
!dom/media/test/marionette/yttest/*.js
|
!dom/media/test/marionette/yttest/*.js
|
||||||
dom/promise/**
|
|
||||||
dom/xhr/**
|
dom/xhr/**
|
||||||
|
|
||||||
# build/ third-party code
|
# build/ third-party code
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,9 @@
|
||||||
* 4) A subframe (frames[0]) which can be used as a second global for creating
|
* 4) A subframe (frames[0]) which can be used as a second global for creating
|
||||||
* promises.
|
* promises.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global verifyPromiseGlobal, getPromise, isXrayArgumentTest */
|
||||||
|
|
||||||
var label = "parent";
|
var label = "parent";
|
||||||
|
|
||||||
function passBasicPromise() {
|
function passBasicPromise() {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@
|
||||||
* 3) A subframe (frames[0]) which can be used as a second global for creating
|
* 3) A subframe (frames[0]) which can be used as a second global for creating
|
||||||
* promises.
|
* promises.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global verifyPromiseGlobal, expectedExceptionGlobal */
|
||||||
|
|
||||||
var label = "parent";
|
var label = "parent";
|
||||||
|
|
||||||
function testThrownException(global) {
|
function testThrownException(global) {
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,18 @@
|
||||||
<html>
|
<html>
|
||||||
<script>
|
<script>
|
||||||
function vendGetter(name) {
|
function vendGetter(name) {
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
return function() { throw "Getting " + String(name); };
|
return function() { throw "Getting " + String(name); };
|
||||||
}
|
}
|
||||||
function vendSetter(name) {
|
function vendSetter(name) {
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
return function() { throw "Setting " + String(name); };
|
return function() { throw "Setting " + String(name); };
|
||||||
}
|
}
|
||||||
var setupThrew = false;
|
var setupThrew = false;
|
||||||
try {
|
try {
|
||||||
// Neuter everything we can think of on Promise.
|
// Neuter everything we can think of on Promise.
|
||||||
for (var obj of [Promise, Promise.prototype]) {
|
for (var obj of [Promise, Promise.prototype]) {
|
||||||
propNames = Object.getOwnPropertyNames(obj);
|
let propNames = Object.getOwnPropertyNames(obj);
|
||||||
propNames = propNames.concat(Object.getOwnPropertySymbols(obj));
|
propNames = propNames.concat(Object.getOwnPropertySymbols(obj));
|
||||||
for (var propName of propNames) {
|
for (var propName of propNames) {
|
||||||
if ((propName == "prototype" ||
|
if ((propName == "prototype" ||
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* global TestFunctions */
|
||||||
|
|
||||||
postMessage("Done", "*");
|
postMessage("Done", "*");
|
||||||
|
|
||||||
var p = new Promise(function(resolve, reject) {
|
var p = new Promise(function(resolve, reject) {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ Debugger.prototype.onNewPromise.
|
||||||
dbg.onNewPromise = function(wp) { wrappedPromise = wp; };
|
dbg.onNewPromise = function(wp) { wrappedPromise = wp; };
|
||||||
|
|
||||||
var promise = new Promise(function() {});
|
var promise = new Promise(function() {});
|
||||||
|
// eslint-disable-next-line no-debugger
|
||||||
debugger;
|
debugger;
|
||||||
ok(wrappedPromise);
|
ok(wrappedPromise);
|
||||||
is(wrappedPromise.unsafeDereference(), promise);
|
is(wrappedPromise.unsafeDereference(), promise);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ function promiseResolve() {
|
||||||
ok(reject, "Promise.reject exists");
|
ok(reject, "Promise.reject exists");
|
||||||
|
|
||||||
resolve(42);
|
resolve(42);
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(true, "Then - resolveCb has been called");
|
ok(true, "Then - resolveCb has been called");
|
||||||
is(what, 42, "ResolveCb received 42");
|
is(what, 42, "ResolveCb received 42");
|
||||||
runTest();
|
runTest();
|
||||||
|
|
@ -40,7 +41,8 @@ function promiseResolveNoArg() {
|
||||||
ok(reject, "Promise.reject exists");
|
ok(reject, "Promise.reject exists");
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(true, "Then - resolveCb has been called");
|
ok(true, "Then - resolveCb has been called");
|
||||||
is(what, undefined, "ResolveCb received undefined");
|
is(what, undefined, "ResolveCb received undefined");
|
||||||
runTest();
|
runTest();
|
||||||
|
|
@ -53,7 +55,8 @@ function promiseResolveNoArg() {
|
||||||
function promiseReject() {
|
function promiseReject() {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
reject(42);
|
reject(42);
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(false, "Then - resolveCb has been called");
|
ok(false, "Then - resolveCb has been called");
|
||||||
runTest();
|
runTest();
|
||||||
}, function(what) {
|
}, function(what) {
|
||||||
|
|
@ -66,7 +69,9 @@ function promiseReject() {
|
||||||
function promiseRejectNoHandler() {
|
function promiseRejectNoHandler() {
|
||||||
// This test only checks that the code that reports unhandled errors in the
|
// This test only checks that the code that reports unhandled errors in the
|
||||||
// Promises implementation does not crash or leak.
|
// Promises implementation does not crash or leak.
|
||||||
var promise = new Promise(function(res, rej) {
|
|
||||||
|
new Promise(function(res, rej) {
|
||||||
|
// eslint-disable-next-line no-undef
|
||||||
noSuchMethod();
|
noSuchMethod();
|
||||||
});
|
});
|
||||||
runTest();
|
runTest();
|
||||||
|
|
@ -75,7 +80,8 @@ function promiseRejectNoHandler() {
|
||||||
function promiseRejectNoArg() {
|
function promiseRejectNoArg() {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
reject();
|
reject();
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(false, "Then - resolveCb has been called");
|
ok(false, "Then - resolveCb has been called");
|
||||||
runTest();
|
runTest();
|
||||||
}, function(what) {
|
}, function(what) {
|
||||||
|
|
@ -87,8 +93,10 @@ function promiseRejectNoArg() {
|
||||||
|
|
||||||
function promiseException() {
|
function promiseException() {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
var promise = new Promise(function(resolve, reject) {
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
throw 42;
|
throw 42;
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(false, "Then - resolveCb has been called");
|
ok(false, "Then - resolveCb has been called");
|
||||||
runTest();
|
runTest();
|
||||||
}, function(what) {
|
}, function(what) {
|
||||||
|
|
@ -102,7 +110,8 @@ function promiseGC() {
|
||||||
var resolve;
|
var resolve;
|
||||||
var promise = new Promise(function(r1, r2) {
|
var promise = new Promise(function(r1, r2) {
|
||||||
resolve = r1;
|
resolve = r1;
|
||||||
}).then(function(what) {
|
});
|
||||||
|
promise.then(function(what) {
|
||||||
ok(true, "Then - promise is still alive");
|
ok(true, "Then - promise is still alive");
|
||||||
runTest();
|
runTest();
|
||||||
});
|
});
|
||||||
|
|
@ -219,6 +228,7 @@ function promiseThenException() {
|
||||||
|
|
||||||
promise.then(function(what) {
|
promise.then(function(what) {
|
||||||
ok(true, "Then.resolve has been called");
|
ok(true, "Then.resolve has been called");
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
throw "booh";
|
throw "booh";
|
||||||
}).catch(function(e) {
|
}).catch(function(e) {
|
||||||
ok(true, "window.onerror has been called!");
|
ok(true, "window.onerror has been called!");
|
||||||
|
|
@ -361,6 +371,7 @@ function promiseRejectThenCatchExceptionThen() {
|
||||||
}, function(what) {
|
}, function(what) {
|
||||||
ok(true, "Then.reject has been called");
|
ok(true, "Then.reject has been called");
|
||||||
is(what, 42, "Value == 42");
|
is(what, 42, "Value == 42");
|
||||||
|
// eslint-disable-next-line no-throw-literal
|
||||||
throw (what + 1);
|
throw (what + 1);
|
||||||
}).catch(function(what) {
|
}).catch(function(what) {
|
||||||
ok(true, "Catch has been called");
|
ok(true, "Catch has been called");
|
||||||
|
|
@ -436,9 +447,9 @@ function promiseCatchNoArg() {
|
||||||
|
|
||||||
function promiseNestedPromise() {
|
function promiseNestedPromise() {
|
||||||
new Promise(function(resolve, reject) {
|
new Promise(function(resolve, reject) {
|
||||||
resolve(new Promise(function(resolve, reject) {
|
resolve(new Promise(function(res, rej) {
|
||||||
ok(true, "Nested promise is executed");
|
ok(true, "Nested promise is executed");
|
||||||
resolve(42);
|
res(42);
|
||||||
}));
|
}));
|
||||||
}).then(function(value) {
|
}).then(function(value) {
|
||||||
is(value, 42, "Nested promise is executed and then == 42");
|
is(value, 42, "Nested promise is executed and then == 42");
|
||||||
|
|
@ -448,9 +459,9 @@ function promiseNestedPromise() {
|
||||||
|
|
||||||
function promiseNestedNestedPromise() {
|
function promiseNestedNestedPromise() {
|
||||||
new Promise(function(resolve, reject) {
|
new Promise(function(resolve, reject) {
|
||||||
resolve(new Promise(function(resolve, reject) {
|
resolve(new Promise(function(res, rej) {
|
||||||
ok(true, "Nested promise is executed");
|
ok(true, "Nested promise is executed");
|
||||||
resolve(42);
|
res(42);
|
||||||
}).then(function(what) { return what + 1; }));
|
}).then(function(what) { return what + 1; }));
|
||||||
}).then(function(value) {
|
}).then(function(value) {
|
||||||
is(value, 43, "Nested promise is executed and then == 43");
|
is(value, 43, "Nested promise is executed and then == 43");
|
||||||
|
|
@ -475,11 +486,11 @@ function promiseWrongNestedPromise() {
|
||||||
|
|
||||||
function promiseLoop() {
|
function promiseLoop() {
|
||||||
new Promise(function(resolve, reject) {
|
new Promise(function(resolve, reject) {
|
||||||
resolve(new Promise(function(r1, r2) {
|
resolve(new Promise(function(res, rej) {
|
||||||
ok(true, "Nested promise is executed");
|
ok(true, "Nested promise is executed");
|
||||||
r1(new Promise(function(r1, r2) {
|
res(new Promise(function(resInner, rejInner) {
|
||||||
ok(true, "Nested nested promise is executed");
|
ok(true, "Nested nested promise is executed");
|
||||||
r1(42);
|
resInner(42);
|
||||||
}));
|
}));
|
||||||
}));
|
}));
|
||||||
}).then(function(value) {
|
}).then(function(value) {
|
||||||
|
|
@ -491,7 +502,8 @@ function promiseLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseStaticReject() {
|
function promiseStaticReject() {
|
||||||
var promise = Promise.reject(42).then(function(what) {
|
var promise = Promise.reject(42);
|
||||||
|
promise.then(function(what) {
|
||||||
ok(false, "This should not be called");
|
ok(false, "This should not be called");
|
||||||
}, function(what) {
|
}, function(what) {
|
||||||
is(what, 42, "Value == 42");
|
is(what, 42, "Value == 42");
|
||||||
|
|
@ -500,7 +512,8 @@ function promiseStaticReject() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseStaticResolve() {
|
function promiseStaticResolve() {
|
||||||
var promise = Promise.resolve(42).then(function(what) {
|
var promise = Promise.resolve(42);
|
||||||
|
promise.then(function(what) {
|
||||||
is(what, 42, "Value == 42");
|
is(what, 42, "Value == 42");
|
||||||
runTest();
|
runTest();
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
@ -514,7 +527,8 @@ function promiseResolveNestedPromise() {
|
||||||
r(42);
|
r(42);
|
||||||
}, function() {
|
}, function() {
|
||||||
ok(false, "This should not be called");
|
ok(false, "This should not be called");
|
||||||
})).then(function(what) {
|
}));
|
||||||
|
promise.then(function(what) {
|
||||||
is(what, 42, "Value == 42");
|
is(what, 42, "Value == 42");
|
||||||
runTest();
|
runTest();
|
||||||
}, function() {
|
}, function() {
|
||||||
|
|
@ -554,6 +568,8 @@ function promiseSimpleThenableReject() {
|
||||||
function promiseThenableThrowsBeforeCallback() {
|
function promiseThenableThrowsBeforeCallback() {
|
||||||
var thenable = { then(resolve) {
|
var thenable = { then(resolve) {
|
||||||
throw new TypeError("Hi there");
|
throw new TypeError("Hi there");
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unreachable
|
||||||
resolve(5);
|
resolve(5);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
|
@ -630,7 +646,7 @@ function promiseStrictHandlers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseStrictExecutorThisArg() {
|
function promiseStrictExecutorThisArg() {
|
||||||
var promise = new Promise(function(resolve, reject) {
|
new Promise(function(resolve, reject) {
|
||||||
"use strict";
|
"use strict";
|
||||||
ok(this === undefined, "thisArg should be undefined.");
|
ok(this === undefined, "thisArg should be undefined.");
|
||||||
runTest();
|
runTest();
|
||||||
|
|
@ -723,6 +739,7 @@ function promiseTestAsyncThenableResolution() {
|
||||||
Promise.resolve().then(function next() {
|
Promise.resolve().then(function next() {
|
||||||
k--;
|
k--;
|
||||||
if (k > 0) return Promise.resolve().then(next);
|
if (k > 0) return Promise.resolve().then(next);
|
||||||
|
return undefined;
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
ok(true, "Resolution of a chain of thenables should not be synchronous.");
|
ok(true, "Resolution of a chain of thenables should not be synchronous.");
|
||||||
runTest();
|
runTest();
|
||||||
|
|
@ -825,4 +842,3 @@ runTest();
|
||||||
</pre>
|
</pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
|
/* global async_test, assert_equals */
|
||||||
var t = async_test("Promise callbacks should run immediately after the setTimeout handler that enqueues them");
|
var t = async_test("Promise callbacks should run immediately after the setTimeout handler that enqueues them");
|
||||||
var origPostMessage = window.postMessage;
|
var origPostMessage = window.postMessage;
|
||||||
window.postMessage = function(msg) { origPostMessage.call(window, msg, "*"); };
|
window.postMessage = function(msg) { origPostMessage.call(window, msg, "*"); };
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
|
/* global async_test, assert_equals */
|
||||||
var t = async_test("Promise callbacks in workers should run immediately after the setTimeout handler that enqueues them");
|
var t = async_test("Promise callbacks in workers should run immediately after the setTimeout handler that enqueues them");
|
||||||
var w = new Worker("file_promise_and_timeout_ordering.js");
|
var w = new Worker("file_promise_and_timeout_ordering.js");
|
||||||
w.onmessage = t.step_func_done(function(e) {
|
w.onmessage = t.step_func_done(function(e) {
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1323324
|
||||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||||
<script src="file_promise_argument_tests.js"></script>
|
<script src="file_promise_argument_tests.js"></script>
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
|
/* global TestFunctions */
|
||||||
|
|
||||||
/** Test for Bug 1323324 **/
|
/** Test for Bug 1323324 **/
|
||||||
SimpleTest.waitForExplicitFinish();
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,9 @@ function promiseAllRejectFails() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseAllCastError() {
|
function promiseAllCastError() {
|
||||||
var p = Promise.all([Promise.resolve(2), { then() { foo(); } }]);
|
var p = Promise.all([Promise.resolve(2), { then() {
|
||||||
|
throw new ReferenceError("placeholder for nonexistent function call");
|
||||||
|
} }]);
|
||||||
ok(p instanceof Promise, "Should cast to a Promise.");
|
ok(p instanceof Promise, "Should cast to a Promise.");
|
||||||
p.then(function(v) {
|
p.then(function(v) {
|
||||||
ok(false, "promiseAllCastError: should've rejected.");
|
ok(false, "promiseAllCastError: should've rejected.");
|
||||||
|
|
@ -152,7 +154,7 @@ function promiseAllEnumerable() {
|
||||||
var p = Promise.all([1, new Date(), Promise.resolve("firefox")]);
|
var p = Promise.all([1, new Date(), Promise.resolve("firefox")]);
|
||||||
p.then(function(v) {
|
p.then(function(v) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (key in v) {
|
for (let key in v) {
|
||||||
++count;
|
++count;
|
||||||
ok(v[key] === 1 || v[key] instanceof Date || v[key] === "firefox",
|
ok(v[key] === 1 || v[key] instanceof Date || v[key] === "firefox",
|
||||||
"Enumerated properties don't match.");
|
"Enumerated properties don't match.");
|
||||||
|
|
@ -193,14 +195,6 @@ function promiseRaceValuesArray() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseRacePromiseArray() {
|
function promiseRacePromiseArray() {
|
||||||
function timeoutPromise(n) {
|
|
||||||
return new Promise(function(resolve) {
|
|
||||||
setTimeout(function() {
|
|
||||||
resolve(n);
|
|
||||||
}, n);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var arr = [
|
var arr = [
|
||||||
new Promise(function(resolve) {
|
new Promise(function(resolve) {
|
||||||
resolve("first");
|
resolve("first");
|
||||||
|
|
@ -264,7 +258,7 @@ function promiseRaceReject() {
|
||||||
function promiseRaceThrow() {
|
function promiseRaceThrow() {
|
||||||
var p = Promise.race([
|
var p = Promise.race([
|
||||||
new Promise(function(resolve) {
|
new Promise(function(resolve) {
|
||||||
nonExistent();
|
throw new ReferenceError("placeholder for nonexistent function call");
|
||||||
}),
|
}),
|
||||||
new Promise(function(resolve) {
|
new Promise(function(resolve) {
|
||||||
setTimeout(resolve, 0);
|
setTimeout(resolve, 0);
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ function testRace1() {
|
||||||
|
|
||||||
function testRace2() {
|
function testRace2() {
|
||||||
var p = win.Promise.race(
|
var p = win.Promise.race(
|
||||||
new Array(win.Promise.resolve(1), win.Promise.resolve(2)));
|
[win.Promise.resolve(1), win.Promise.resolve(2)]);
|
||||||
p.then(
|
p.then(
|
||||||
function(arg) {
|
function(arg) {
|
||||||
ok(arg == 1 || arg == 2,
|
ok(arg == 1 || arg == 2,
|
||||||
|
|
@ -140,7 +140,7 @@ function testAll1() {
|
||||||
|
|
||||||
function testAll2() {
|
function testAll2() {
|
||||||
var p = win.Promise.all(
|
var p = win.Promise.all(
|
||||||
new Array(win.Promise.resolve(1), win.Promise.resolve(2)));
|
[win.Promise.resolve(1), win.Promise.resolve(2)]);
|
||||||
p.then(
|
p.then(
|
||||||
function(arg) {
|
function(arg) {
|
||||||
ok(arg instanceof win.Array, "Should get an Array from Promise.all (2)");
|
ok(arg instanceof win.Array, "Should get an Array from Promise.all (2)");
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
test(function() {
|
test(function() {
|
||||||
|
/* global test, assert_not_equals, assert_equals */
|
||||||
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
var desc = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
||||||
assert_not_equals(desc, undefined, "Should have a property");
|
assert_not_equals(desc, undefined, "Should have a property");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<div id="log"></div>
|
<div id="log"></div>
|
||||||
<script>
|
<script>
|
||||||
|
/* global async_test, assert_true, assert_equals */
|
||||||
|
|
||||||
var t = async_test("A promise resolved first (with a thenable) should trigger its callbacks before a promise resolved second (with a promise).");
|
var t = async_test("A promise resolved first (with a thenable) should trigger its callbacks before a promise resolved second (with a promise).");
|
||||||
t.step(function() {
|
t.step(function() {
|
||||||
var customThenCalled = false;
|
var customThenCalled = false;
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,8 @@ function compileManySuccess() {
|
||||||
|
|
||||||
Promise.all(arr).then(ms => {
|
Promise.all(arr).then(ms => {
|
||||||
ok(ms.length === N, "got the right number");
|
ok(ms.length === N, "got the right number");
|
||||||
for (var i = 0; i < N; i++)
|
for (var j = 0; j < N; j++)
|
||||||
checkSampleModule(ms[i]);
|
checkSampleModule(ms[j]);
|
||||||
runTest();
|
runTest();
|
||||||
}).catch(
|
}).catch(
|
||||||
err => { ok(false, String(err)); runTest(); }
|
err => { ok(false, String(err)); runTest(); }
|
||||||
|
|
@ -232,8 +232,8 @@ function compileManyStreamingFetch() {
|
||||||
|
|
||||||
Promise.all(arr).then(ms => {
|
Promise.all(arr).then(ms => {
|
||||||
ok(ms.length === N, "got the right number");
|
ok(ms.length === N, "got the right number");
|
||||||
for (var i = 0; i < N; i++)
|
for (var j = 0; j < N; j++)
|
||||||
checkSampleModule(ms[i]);
|
checkSampleModule(ms[j]);
|
||||||
runTest();
|
runTest();
|
||||||
}).catch(
|
}).catch(
|
||||||
err => { ok(false, String(err)); runTest(); }
|
err => { ok(false, String(err)); runTest(); }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ const sampleURL = "test_webassembly_compile_sample.wasm";
|
||||||
const sampleExportName = "run";
|
const sampleExportName = "run";
|
||||||
const sampleResult = 1275;
|
const sampleResult = 1275;
|
||||||
|
|
||||||
|
/* eslint-disable no-throw-literal */
|
||||||
|
|
||||||
function checkSampleModule(m) {
|
function checkSampleModule(m) {
|
||||||
if (!(m instanceof WebAssembly.Module))
|
if (!(m instanceof WebAssembly.Module))
|
||||||
throw "not a module";
|
throw "not a module";
|
||||||
|
|
@ -25,15 +27,15 @@ onmessage = e => {
|
||||||
WebAssembly.compile(e.data)
|
WebAssembly.compile(e.data)
|
||||||
.then(m => checkSampleModule(m))
|
.then(m => checkSampleModule(m))
|
||||||
.then(() => WebAssembly.instantiate(e.data))
|
.then(() => WebAssembly.instantiate(e.data))
|
||||||
.then(({module, instance}) => { checkSampleModule(module), checkSampleInstance(instance); })
|
.then(({module, instance}) => { checkSampleModule(module); checkSampleInstance(instance); })
|
||||||
.then(() => WebAssembly.compileStreaming(new Response(e.data, initObj)))
|
.then(() => WebAssembly.compileStreaming(new Response(e.data, initObj)))
|
||||||
.then(m => checkSampleModule(m))
|
.then(m => checkSampleModule(m))
|
||||||
.then(() => WebAssembly.instantiateStreaming(new Response(e.data, initObj)))
|
.then(() => WebAssembly.instantiateStreaming(new Response(e.data, initObj)))
|
||||||
.then(({module, instance}) => { checkSampleModule(module), checkSampleInstance(instance); })
|
.then(({module, instance}) => { checkSampleModule(module); checkSampleInstance(instance); })
|
||||||
.then(() => WebAssembly.compileStreaming(fetch(sampleURL)))
|
.then(() => WebAssembly.compileStreaming(fetch(sampleURL)))
|
||||||
.then(m => checkSampleModule(m))
|
.then(m => checkSampleModule(m))
|
||||||
.then(() => WebAssembly.instantiateStreaming(fetch(sampleURL)))
|
.then(() => WebAssembly.instantiateStreaming(fetch(sampleURL)))
|
||||||
.then(({module, instance}) => { checkSampleModule(module), checkSampleInstance(instance); })
|
.then(({module, instance}) => { checkSampleModule(module); checkSampleInstance(instance); })
|
||||||
.then(() => postMessage("ok"))
|
.then(() => postMessage("ok"))
|
||||||
.catch(err => postMessage("fail: " + err));
|
.catch(err => postMessage("fail: " + err));
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -84,9 +84,11 @@ add_task(async function test_observe_uncaught() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let resolveLater = function(delay = 20) {
|
let resolveLater = function(delay = 20) {
|
||||||
|
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||||
return new Promise((resolve, reject) => setTimeout(resolve, delay));
|
return new Promise((resolve, reject) => setTimeout(resolve, delay));
|
||||||
};
|
};
|
||||||
let rejectLater = function(delay = 20) {
|
let rejectLater = function(delay = 20) {
|
||||||
|
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||||
return new Promise((resolve, reject) => setTimeout(reject, delay));
|
return new Promise((resolve, reject) => setTimeout(reject, delay));
|
||||||
};
|
};
|
||||||
let makeSamples = function* () {
|
let makeSamples = function* () {
|
||||||
|
|
@ -119,6 +121,8 @@ add_task(async function test_observe_uncaught() {
|
||||||
|
|
||||||
// Reject a promise now, consume it later.
|
// Reject a promise now, consume it later.
|
||||||
let p = Promise.reject("Reject now, consume later");
|
let p = Promise.reject("Reject now, consume later");
|
||||||
|
|
||||||
|
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||||
setTimeout(() => p.catch(() => {
|
setTimeout(() => p.catch(() => {
|
||||||
info("Consumed promise");
|
info("Consumed promise");
|
||||||
}), 200);
|
}), 200);
|
||||||
|
|
@ -261,6 +265,7 @@ add_task(async function test_uninstall_observer() {
|
||||||
let wait = new Observer();
|
let wait = new Observer();
|
||||||
Promise.reject("I am another uncaught rejection.");
|
Promise.reject("I am another uncaught rejection.");
|
||||||
await wait.blocker;
|
await wait.blocker;
|
||||||
|
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
|
||||||
await new Promise(resolve => setTimeout(resolve, 100));
|
await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
// Normally, `deactivate` should not be notified of the uncaught rejection.
|
// Normally, `deactivate` should not be notified of the uncaught rejection.
|
||||||
wait.active = false;
|
wait.active = false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue