Bug 1402317 - Remove dom.abortController.enabled and dom.abortController.fetch.enabled prefs, r=qdot

This commit is contained in:
Andrea Marchesini 2017-09-27 03:50:46 +02:00
parent afe9dcf6ff
commit 04cd5ddc32
16 changed files with 109 additions and 236 deletions

View File

@ -22,44 +22,6 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AbortController)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
/* static */ bool
AbortController::IsEnabled(JSContext* aCx, JSObject* aGlobal)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.abortController.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
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)
{

View File

@ -26,12 +26,6 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AbortController)
static bool
IsEnabled(JSContext* aCx, JSObject* aGlobal);
static bool
IsEnabledInFetch(JSContext* aCx, JSObject* aGlobal);
static already_AddRefed<AbortController>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);

View File

@ -1,65 +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 testWebIDL() {
ok("AbortController" in self, "We have a AbortController prototype");
ok("AbortSignal" in self, "We have a AbortSignal prototype");
var ac = new AbortController();
ok(!!ac, "AbortController can be created");
ok(ac instanceof AbortController, "AbortController is a AbortController");
ok(!!ac.signal, "AbortController has a signal");
ok(ac.signal instanceof AbortSignal, "abortSignal is a AbortSignal");
is(ac.signal.aborted, false, "By default AbortSignal.aborted is false");
next();
}
function testUpdateData() {
var ac = new AbortController();
is(ac.signal.aborted, false, "By default AbortSignal.aborted is false");
ac.abort();
is(ac.signal.aborted, true, "Signal is aborted");
next();
}
function testAbortEvent() {
var ac = new AbortController();
ac.signal.onabort = function(e) {
is(e.type, "abort", "Abort received");
next();
}
ac.abort();
}
var steps = [
// Simple stuff
testWebIDL,
testUpdateData,
// Event propagation
testAbortEvent,
];
function next() {
if (!steps.length) {
parent.postMessage({ type: "finish" }, "*");
return;
}
var step = steps.shift();
step();
}
next();
</script>

View File

@ -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>

View File

@ -1,7 +1,5 @@
[DEFAULT]
support-files =
file_abort_controller.html
file_abort_controller_fetch.html
worker_abort_controller_fetch.js
slow.sjs

View File

@ -12,27 +12,61 @@
<body>
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({"set": [["dom.abortController.enabled", true ]]}, () => {
let ifr = document.createElement("iframe");
ifr.src = "file_abort_controller.html";
document.body.appendChild(ifr);
function testWebIDL() {
ok("AbortController" in self, "We have a AbortController prototype");
ok("AbortSignal" in self, "We have a AbortSignal prototype");
window.onmessage = function(e) {
if (e.data.type == "finish") {
var ac = new AbortController();
ok(!!ac, "AbortController can be created");
ok(ac instanceof AbortController, "AbortController is a AbortController");
ok(!!ac.signal, "AbortController has a signal");
ok(ac.signal instanceof AbortSignal, "abortSignal is a AbortSignal");
is(ac.signal.aborted, false, "By default AbortSignal.aborted is false");
next();
}
function testUpdateData() {
var ac = new AbortController();
is(ac.signal.aborted, false, "By default AbortSignal.aborted is false");
ac.abort();
is(ac.signal.aborted, true, "Signal is aborted");
next();
}
function testAbortEvent() {
var ac = new AbortController();
ac.signal.onabort = function(e) {
is(e.type, "abort", "Abort received");
next();
}
ac.abort();
}
var steps = [
// Simple stuff
testWebIDL,
testUpdateData,
// Event propagation
testAbortEvent,
];
function next() {
if (!steps.length) {
SimpleTest.finish();
return;
}
if (e.data.type == "check") {
ok(e.data.status, e.data.message);
return;
}
ok(false, "Something when wrong.");
}
});
var step = steps.shift();
step();
}
SimpleTest.waitForExplicitFinish();
next();
</script>
</body>

View File

@ -12,28 +12,68 @@
<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);
function testAbortedFetch() {
var ac = new AbortController();
ac.abort();
window.onmessage = function(e) {
if (e.data.type == "finish") {
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) {
SimpleTest.finish();
return;
}
if (e.data.type == "check") {
ok(e.data.status, e.data.message);
return;
}
ok(false, "Something when wrong.");
}
});
var step = steps.shift();
step();
}
SimpleTest.waitForExplicitFinish();
next();
</script>
</body>

View File

@ -12,9 +12,7 @@
<body>
<script class="testbody" type="text/javascript">
SpecialPowers.pushPrefEnv({"set": [["dom.fetchObserver.enabled", true ],
["dom.abortController.enabled", true ],
["dom.abortController.fetch.enabled", true ]]}, () => {
SpecialPowers.pushPrefEnv({"set": [["dom.fetchObserver.enabled", true ]]}, () => {
let ifr = document.createElement('iframe');
ifr.src = "file_fetch_observer.html";
document.body.appendChild(ifr);

View File

@ -7,8 +7,7 @@
* https://dom.spec.whatwg.org/#abortcontroller
*/
[Constructor(), Exposed=(Window,Worker),
Func="AbortController::IsEnabled"]
[Constructor(), Exposed=(Window,Worker)]
interface AbortController {
readonly attribute AbortSignal signal;

View File

@ -7,8 +7,7 @@
* https://dom.spec.whatwg.org/#abortsignal
*/
[Exposed=(Window,Worker),
Func="AbortController::IsEnabled"]
[Exposed=(Window,Worker)]
interface AbortSignal : EventTarget {
readonly attribute boolean aborted;

View File

@ -27,8 +27,7 @@ interface Request {
readonly attribute RequestRedirect redirect;
readonly attribute DOMString integrity;
[Func="AbortController::IsEnabledInFetch",
BinaryName="getOrCreateSignal"]
[BinaryName="getOrCreateSignal"]
readonly attribute AbortSignal signal;
[Throws,
@ -52,7 +51,6 @@ dictionary RequestInit {
RequestRedirect redirect;
DOMString integrity;
[Func="AbortController::IsEnabledInFetch"]
AbortSignal? signal;
[Func="FetchObserver::IsEnabled"]

View File

@ -42,8 +42,6 @@ WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTC
WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
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_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)

View File

@ -5075,12 +5075,6 @@ pref("dom.battery.enabled", true);
// Streams API
pref("dom.streams.enabled", false);
// Abort API
pref("dom.abortController.enabled", true);
// Fetch + Abort API
pref("dom.abortController.fetch.enabled", true);
// Push
pref("dom.push.enabled", false);

View File

@ -1 +0,0 @@
prefs: [dom.abortController.enabled:true]

View File

@ -1 +0,0 @@
prefs: [dom.abortController.enabled:true]

View File

@ -1,4 +1,2 @@
prefs: [javascript.options.streams:true,
dom.abortController.enabled:true,
dom.abortController.fetch.enabled:true,
dom.streams.enabled:true]