diff options
author | Moonchild <moonchild@palemoon.org> | 2020-06-11 12:43:17 +0000 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-06-13 11:52:17 +0200 |
commit | 29bca891d5ca243774a7355fc3a6a68903f0d596 (patch) | |
tree | ec5a36a57a179b811642c0ee5636ffd3005adc67 /dom/tests | |
parent | bb7060582934f087b71702d1e83f762d5fd6f0af (diff) | |
download | UXP-29bca891d5ca243774a7355fc3a6a68903f0d596.tar UXP-29bca891d5ca243774a7355fc3a6a68903f0d596.tar.gz UXP-29bca891d5ca243774a7355fc3a6a68903f0d596.tar.lz UXP-29bca891d5ca243774a7355fc3a6a68903f0d596.tar.xz UXP-29bca891d5ca243774a7355fc3a6a68903f0d596.zip |
Issue #1587 - Part 6: Move FetchController/Signal to its own dir
Since it is specced separately from fetch.
Diffstat (limited to 'dom/tests')
-rw-r--r-- | dom/tests/mochitest/fetch/file_fetch_controller.html | 161 | ||||
-rw-r--r-- | dom/tests/mochitest/fetch/mochitest.ini | 3 | ||||
-rw-r--r-- | dom/tests/mochitest/fetch/test_fetch_controller.html | 40 | ||||
-rw-r--r-- | dom/tests/mochitest/fetch/worker_fetch_controller.js | 27 |
4 files changed, 0 insertions, 231 deletions
diff --git a/dom/tests/mochitest/fetch/file_fetch_controller.html b/dom/tests/mochitest/fetch/file_fetch_controller.html deleted file mode 100644 index e4137aac9..000000000 --- a/dom/tests/mochitest/fetch/file_fetch_controller.html +++ /dev/null @@ -1,161 +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("FetchController" in self, "We have a FetchController prototype"); - ok("FetchSignal" in self, "We have a FetchSignal prototype"); - - var fc = new FetchController(); - ok(!!fc, "FetchController can be created"); - ok(fc instanceof FetchController, "FetchController is a FetchController"); - - ok(!!fc.signal, "FetchController has a signal"); - ok(fc.signal instanceof FetchSignal, "fetchSignal is a FetchSignal"); - is(fc.signal.aborted, false, "By default FetchSignal.aborted is false"); - next(); -} - -function testUpdateData() { - var fc = new FetchController(); - - is(fc.signal.aborted, false, "By default FetchSignal.aborted is false"); - - fc.abort(); - is(fc.signal.aborted, true, "Signal is aborted"); - - next(); -} - -function testFollowingOurself() { - // Let's follow ourself - var fc = new FetchController(); - fc.follow(fc.signal); - - fc.abort(); - is(fc.signal.aborted, true, "Signal is aborted"); - - next(); -} - -function testFollowingOther() { - // Let's follow another one - var fc1 = new FetchController(); - var fc2 = new FetchController(); - fc1.follow(fc2.signal); - - fc2.abort(); - - is(fc1.signal.aborted, true, "Signal is aborted"); - is(fc2.signal.aborted, true, "Signal is aborted"); - - next(); -} - -function testFollowingLoop() { - // fc1 -> fc2 -> fc3 -> fc1 - var fc1 = new FetchController(); - var fc2 = new FetchController(); - var fc3 = new FetchController(); - fc1.follow(fc2.signal); - fc2.follow(fc3.signal); - fc3.follow(fc1.signal); - - fc3.abort(); - - is(fc1.signal.aborted, true, "Signal is aborted"); - is(fc2.signal.aborted, true, "Signal is aborted"); - is(fc3.signal.aborted, true, "Signal is aborted"); - - next(); -} - -function testAbortEvent() { - var fc = new FetchController(); - fc.signal.onabort = function(e) { - is(e.type, "abort", "Abort received"); - next(); - } - fc.abort(); -} - -function testAbortedFetch() { - var fc = new FetchController(); - fc.abort(); - - fetch('slow.sjs', { signal: fc.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 fc = new FetchController(); - - var p = fetch('slow.sjs', { signal: fc.signal }); - fc.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_fetch_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_fetch_controller.js'); - w.onmessage = function(e) { - ok(e.data, "Abort + Fetch works in workers"); - next(); - } - w.postMessage('testWorkerFetchAndAbort'); -} - -var steps = [ - // Simple stuff - testWebIDL, - testUpdateData, - - // Following algorithm - testFollowingOurself, - testFollowingOther, - testFollowingLoop, - - // Event propagation - testAbortEvent, - - // fetch + signaling - testAbortedFetch, - testFetchAndAbort, - testWorkerAbortedFetch, - testWorkerFetchAndAbort, -]; - -function next() { - if (!steps.length) { - parent.postMessage({ type: "finish" }, "*"); - return; - } - - var step = steps.shift(); - step(); -} - -next(); - -</script> diff --git a/dom/tests/mochitest/fetch/mochitest.ini b/dom/tests/mochitest/fetch/mochitest.ini index 7493ede50..a9447d0d9 100644 --- a/dom/tests/mochitest/fetch/mochitest.ini +++ b/dom/tests/mochitest/fetch/mochitest.ini @@ -1,7 +1,6 @@ [DEFAULT] support-files = fetch_test_framework.js - file_fetch_controller.html test_fetch_basic.js test_fetch_basic_http.js test_fetch_cors.js @@ -23,7 +22,6 @@ support-files = empty.js^headers^ worker_temporaryFileBlob.js common_temporaryFileBlob.js - worker_fetch_controller.js !/dom/xhr/tests/file_XHR_binary1.bin !/dom/xhr/tests/file_XHR_binary1.bin^headers^ !/dom/xhr/tests/file_XHR_binary2.bin @@ -45,7 +43,6 @@ support-files = [test_fetch_basic_http.html] [test_fetch_basic_http_sw_reroute.html] [test_fetch_basic_http_sw_empty_reroute.html] -[test_fetch_controller.html] [test_fetch_cors.html] skip-if = toolkit == 'android' # Bug 1210282 [test_fetch_cors_sw_reroute.html] diff --git a/dom/tests/mochitest/fetch/test_fetch_controller.html b/dom/tests/mochitest/fetch/test_fetch_controller.html deleted file mode 100644 index 812fb9161..000000000 --- a/dom/tests/mochitest/fetch/test_fetch_controller.html +++ /dev/null @@ -1,40 +0,0 @@ -<!-- - Any copyright is dedicated to the Public Domain. - http://creativecommons.org/publicdomain/zero/1.0/ ---> -<!DOCTYPE HTML> -<html> -<head> - <title>Test FetchController</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.fetchController.enabled", true ]]}, () => { - let ifr = document.createElement('iframe'); - ifr.src = "file_fetch_controller.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> - diff --git a/dom/tests/mochitest/fetch/worker_fetch_controller.js b/dom/tests/mochitest/fetch/worker_fetch_controller.js deleted file mode 100644 index 6b008fea8..000000000 --- a/dom/tests/mochitest/fetch/worker_fetch_controller.js +++ /dev/null @@ -1,27 +0,0 @@ -function testWorkerAbortedFetch() { - var fc = new FetchController(); - fc.abort(); - - fetch('slow.sjs', { signal: fc.signal }).then(() => { - postMessage(false); - }, e => { - postMessage(e.name == "AbortError"); - }); -} - -function testWorkerFetchAndAbort() { - var fc = new FetchController(); - - var p = fetch('slow.sjs', { signal: fc.signal }); - fc.abort(); - - p.then(() => { - postMessage(false); - }, e => { - postMessage(e.name == "AbortError"); - }); -} - -onmessage = function(e) { - self[e.data](); -} |