Bug 1237455 P3 Add a version of test_fetch_cors that reroutes through an empty service worker. r=ehsan

--HG--
rename : dom/tests/mochitest/fetch/reroute.js^headers^ => dom/tests/mochitest/fetch/empty.js^headers^
rename : dom/tests/mochitest/fetch/test_fetch_basic_http_sw_reroute.html => dom/tests/mochitest/fetch/test_fetch_basic_http_sw_empty_reroute.html
rename : dom/tests/mochitest/fetch/test_fetch_basic_sw_reroute.html => dom/tests/mochitest/fetch/test_fetch_basic_sw_empty_reroute.html
rename : dom/tests/mochitest/fetch/test_fetch_cors_sw_reroute.html => dom/tests/mochitest/fetch/test_fetch_cors_sw_empty_reroute.html
This commit is contained in:
Ben Kelly 2016-01-19 13:54:15 -08:00
Родитель 4ac9b8ce06
Коммит 5612e2c75b
8 изменённых файлов: 86 добавлений и 2 удалений

Просмотреть файл

Просмотреть файл

@ -0,0 +1 @@
Service-Worker-Allowed: /

Просмотреть файл

@ -16,6 +16,8 @@ support-files =
reroute.js
reroute.js^headers^
sw_reroute.js
empty.js
empty.js^headers^
[test_headers.html]
[test_headers_sw_reroute.html]
@ -28,14 +30,20 @@ skip-if = (e10s && debug && os == 'win')
skip-if = (e10s && debug && os == 'win')
[test_fetch_basic_sw_reroute.html]
skip-if = buildapp == 'b2g' || (e10s && debug && os == 'win') # Bug 1137683
[test_fetch_basic_sw_empty_reroute.html]
skip-if = buildapp == 'b2g'
[test_fetch_basic_http.html]
skip-if = (e10s && debug && os == 'win')
[test_fetch_basic_http_sw_reroute.html]
skip-if = buildapp == 'b2g' || (e10s && debug && os == 'win') # Bug 1137683
[test_fetch_basic_http_sw_empty_reroute.html]
skip-if = buildapp == 'b2g'
[test_fetch_cors.html]
skip-if = buildapp == 'b2g' || (toolkit == 'android' && debug) || (e10s && debug && os == 'win') # Bug 1210552 && 1210282
[test_fetch_cors_sw_reroute.html]
skip-if = buildapp == 'b2g' || (toolkit == 'android' && debug) || (e10s && debug && os == 'win') # Bug 1137683 && 1210282
[test_fetch_cors_sw_empty_reroute.html]
skip-if = buildapp == 'b2g'
[test_formdataparsing.html]
skip-if = (e10s && debug && os == 'win')
[test_formdataparsing_sw_reroute.html]

Просмотреть файл

@ -6,6 +6,13 @@
<script type="text/javascript" src="utils.js"> </script>
<script type="text/javascript" src="fetch_test_framework.js"> </script>
<script>
window.isSWPresent = true;
// If we are using the empty service worker then requests won't actually
// get intercepted and response URLs will reflect redirects. This means
// all our checks should use the "no sw" logic. Otherwise we need to
// note that interceptions are taking place so we can adjust our
// response URL expectations.
if (!navigator.serviceWorker.controller.scriptURL.endsWith('empty.js')) {
window.isSWPresent = true;
}
testScript(location.search.substring(1) + ".js");
</script>

Просмотреть файл

@ -17,7 +17,9 @@ function testScript(script) {
["dom.serviceWorkers.exemptFromPerDomainMax", true]]
}, function() {
navigator.serviceWorker.ready.then(setupSW);
navigator.serviceWorker.register("reroute.js", {scope: "/"});
var scriptURL = location.href.includes("sw_empty_reroute.html")
? "empty.js" : "reroute.js";
navigator.serviceWorker.register(scriptURL, {scope: "/"});
});
}

Просмотреть файл

@ -0,0 +1,22 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1039846 - Test fetch() http fetching in worker</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<script type="text/javascript" src="sw_reroute.js"> </script>
<script class="testbody" type="text/javascript">
testScript("test_fetch_basic_http.js");
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,22 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1039846 - Test fetch() function in worker</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<script type="text/javascript" src="sw_reroute.js"> </script>
<script class="testbody" type="text/javascript">
testScript("test_fetch_basic.js");
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,22 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1039846 - Test fetch() CORS mode</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
<script type="text/javascript" src="sw_reroute.js"> </script>
<script class="testbody" type="text/javascript">
testScript("test_fetch_cors.js");
</script>
</body>
</html>