зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset bded779447b2 (bug 1378342)
--HG-- rename : dom/abort/tests/worker_abort_controller_fetch.js => dom/abort/tests/worker_abort_controller.js
This commit is contained in:
Родитель
debdc61170
Коммит
12299a2c87
|
@ -40,26 +40,6 @@ AbortController::IsEnabled(JSContext* aCx, JSObject* aGlobal)
|
|||
return workerPrivate->AbortControllerEnabled();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
AbortController::IsEnabledInFetch(JSContext* aCx, JSObject* aGlobal)
|
||||
{
|
||||
if (NS_IsMainThread()) {
|
||||
return IsEnabled(aCx, aGlobal) &&
|
||||
Preferences::GetBool("dom.abortController.fetch.enabled", false);
|
||||
}
|
||||
|
||||
using namespace workers;
|
||||
|
||||
// Otherwise, check the pref via the WorkerPrivate
|
||||
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
|
||||
if (!workerPrivate) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return workerPrivate->AbortControllerEnabled() &&
|
||||
workerPrivate->AbortControllerEnabledInFetch();
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<AbortController>
|
||||
AbortController::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
|
||||
{
|
||||
|
|
|
@ -29,9 +29,6 @@ public:
|
|||
static bool
|
||||
IsEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static bool
|
||||
IsEnabledInFetch(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static already_AddRefed<AbortController>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
|
||||
|
|
|
@ -41,6 +41,48 @@ function testAbortEvent() {
|
|||
ac.abort();
|
||||
}
|
||||
|
||||
function testAbortedFetch() {
|
||||
var ac = new AbortController();
|
||||
ac.abort();
|
||||
|
||||
fetch('slow.sjs', { signal: ac.signal }).then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testFetchAndAbort() {
|
||||
var ac = new AbortController();
|
||||
|
||||
var p = fetch('slow.sjs', { signal: ac.signal });
|
||||
ac.abort();
|
||||
|
||||
p.then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testWorkerAbortedFetch() {
|
||||
var w = new Worker('worker_abort_controller.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerAbortedFetch');
|
||||
}
|
||||
|
||||
function testWorkerFetchAndAbort() {
|
||||
var w = new Worker('worker_abort_controller.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerFetchAndAbort');
|
||||
}
|
||||
|
||||
var steps = [
|
||||
// Simple stuff
|
||||
testWebIDL,
|
||||
|
@ -48,6 +90,12 @@ var steps = [
|
|||
|
||||
// Event propagation
|
||||
testAbortEvent,
|
||||
|
||||
// fetch + signaling
|
||||
testAbortedFetch,
|
||||
testFetchAndAbort,
|
||||
testWorkerAbortedFetch,
|
||||
testWorkerFetchAndAbort,
|
||||
];
|
||||
|
||||
function next() {
|
||||
|
|
|
@ -1,72 +0,0 @@
|
|||
<script>
|
||||
function ok(a, msg) {
|
||||
parent.postMessage({ type: "check", status: !!a, message: msg }, "*");
|
||||
}
|
||||
|
||||
function is(a, b, msg) {
|
||||
ok(a === b, msg);
|
||||
}
|
||||
|
||||
function testAbortedFetch() {
|
||||
var ac = new AbortController();
|
||||
ac.abort();
|
||||
|
||||
fetch('slow.sjs', { signal: ac.signal }).then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testFetchAndAbort() {
|
||||
var ac = new AbortController();
|
||||
|
||||
var p = fetch('slow.sjs', { signal: ac.signal });
|
||||
ac.abort();
|
||||
|
||||
p.then(() => {
|
||||
ok(false, "Fetch should not return a resolved promise");
|
||||
}, e => {
|
||||
is(e.name, "AbortError", "We have an abort error");
|
||||
}).then(next);
|
||||
}
|
||||
|
||||
function testWorkerAbortedFetch() {
|
||||
var w = new Worker('worker_abort_controller_fetch.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerAbortedFetch');
|
||||
}
|
||||
|
||||
function testWorkerFetchAndAbort() {
|
||||
var w = new Worker('worker_abort_controller_fetch.js');
|
||||
w.onmessage = function(e) {
|
||||
ok(e.data, "Abort + Fetch works in workers");
|
||||
next();
|
||||
}
|
||||
w.postMessage('testWorkerFetchAndAbort');
|
||||
}
|
||||
|
||||
var steps = [
|
||||
// fetch + signaling
|
||||
testAbortedFetch,
|
||||
testFetchAndAbort,
|
||||
testWorkerAbortedFetch,
|
||||
testWorkerFetchAndAbort,
|
||||
];
|
||||
|
||||
function next() {
|
||||
if (!steps.length) {
|
||||
parent.postMessage({ type: "finish" }, "*");
|
||||
return;
|
||||
}
|
||||
|
||||
var step = steps.shift();
|
||||
step();
|
||||
}
|
||||
|
||||
next();
|
||||
|
||||
</script>
|
|
@ -1,8 +1,6 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
file_abort_controller.html
|
||||
file_abort_controller_fetch.html
|
||||
worker_abort_controller_fetch.js
|
||||
worker_abort_controller.js
|
||||
|
||||
[test_abort_controller.html]
|
||||
[test_abort_controller_fetch.html]
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test AbortController in Fetch API</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.abortController.enabled", true ],
|
||||
["dom.abortController.fetch.enabled", true]]}, () => {
|
||||
let ifr = document.createElement('iframe');
|
||||
ifr.src = "file_abort_controller_fetch.html";
|
||||
document.body.appendChild(ifr);
|
||||
|
||||
onmessage = function(e) {
|
||||
if (e.data.type == "finish") {
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.data.type == "check") {
|
||||
ok(e.data.status, e.data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Something when wrong.");
|
||||
}
|
||||
});
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -48,7 +48,7 @@ dictionary RequestInit {
|
|||
RequestRedirect redirect;
|
||||
DOMString integrity;
|
||||
|
||||
[Func="AbortController::IsEnabledInFetch"]
|
||||
[Func="AbortController::IsEnabled"]
|
||||
AbortSignal signal;
|
||||
|
||||
[Func="FetchObserver::IsEnabled"]
|
||||
|
|
|
@ -43,7 +43,6 @@ WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCR
|
|||
WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
|
||||
WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.abortController.enabled", AbortControllerEnabled, ABORTCONTROLLER_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.abortController.fetch.enabled", AbortControllerEnabledInFetch, ABORTCONTROLLER_FETCH_ENABLED)
|
||||
WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
|
||||
WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
|
||||
WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
|
||||
|
|
Загрузка…
Ссылка в новой задаче