Bug 1290951 - Part 4.1: Add a new wpt test for extended bytecheck. r=bkelly

--HG--
extra : rebase_source : 028522a4ce49c350d3607aa2c3498c2fc2341bf2
This commit is contained in:
Ho-Pang Hsu 2017-05-04 02:05:26 +08:00
Родитель d466693cc4
Коммит 2dd9be8b86
4 изменённых файлов: 202 добавлений и 0 удалений

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

@ -61981,6 +61981,16 @@
{}
]
],
"service-workers/service-worker/resources/bytecheck-worker-imported-script.py": [
[
{}
]
],
"service-workers/service-worker/resources/bytecheck-worker.py": [
[
{}
]
],
"service-workers/service-worker/resources/claim-with-redirect-iframe.html": [
[
{}
@ -122846,6 +122856,12 @@
{}
]
],
"service-workers/service-worker/update-bytecheck.https.html": [
[
"/service-workers/service-worker/update-bytecheck.https.html",
{}
]
],
"service-workers/service-worker/update-recovery.https.html": [
[
"/service-workers/service-worker/update-recovery.https.html",
@ -206409,6 +206425,14 @@
"0ddb4f1cf84729ed673295719ec58a3e5d600a12",
"support"
],
"service-workers/service-worker/resources/bytecheck-worker-imported-script.py": [
"772d029d4efbe22f62f3473d4afe9e501a792571",
"support"
],
"service-workers/service-worker/resources/bytecheck-worker.py": [
"2693790af1dcd812bc3741db7fa355e23eef0e01",
"support"
],
"service-workers/service-worker/resources/claim-with-redirect-iframe.html": [
"fdc472f4e9a591f0b471174b2aa1783107731f49",
"support"
@ -207077,6 +207101,10 @@
"7c8c6c3edca83d54f1838eccf3afb0b1223c7a44",
"testharness"
],
"service-workers/service-worker/update-bytecheck.https.html": [
"6562348b198124822297c6b622c3e63870427672",
"testharness"
],
"service-workers/service-worker/update-recovery.https.html": [
"aac5705d6844e4a33200418504adb57053a45be2",
"testharness"

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

@ -0,0 +1,19 @@
import time
def main(request, response):
headers = [('Content-Type', 'application/javascript'),
('Cache-Control', 'max-age=0')]
imported_content_type = ''
if 'imported' in request.GET:
imported_content_type = request.GET['imported']
imported_content = 'default'
if imported_content_type == 'time':
imported_content = time.time()
body = '''
// %s
''' % (imported_content)
return headers, body

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

@ -0,0 +1,28 @@
import time
def main(request, response):
headers = [('Content-Type', 'application/javascript'),
('Cache-Control', 'max-age=0')]
main_content_type = ''
if 'main' in request.GET:
main_content_type = request.GET['main']
main_content = 'default'
if main_content_type == 'time':
main_content = time.time()
imported_request_type = ''
if 'imported' in request.GET:
imported_request_type = request.GET['imported']
imported_request = ''
if imported_request_type == 'time':
imported_request = '?imported=time';
body = '''
// %s
importScripts('bytecheck-worker-imported-script.py%s');
''' % (main_content, imported_request)
return headers, body

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

@ -0,0 +1,127 @@
<!doctype html>
<meta charset=utf-8>
<title></title>
<script src="/resources/testharness.js"></script>
<script src="resources/testharness-helpers.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<script>
promise_test(function(t) {
var script = 'resources/bytecheck-worker.py' +
'?main=default' +
'&imported=default';
var scope = 'resources/blank.html';
var swr, sw;
return Promise.resolve()
.then(() => service_worker_unregister_and_register(t, script, scope))
.then(registration => swr = registration)
.then(() => wait_for_update(t, swr))
.then(worker => sw = worker)
.then(() => wait_for_state(t, sw, 'activated'))
.then(() => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw,
null,
null]))
.then(() => swr.update())
.then(() => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw,
null,
null]))
.then(() => service_worker_unregister_and_done(t, scope));
}, "Test with (main: same, imported: same)");
promise_test(function(t) {
var script = 'resources/bytecheck-worker.py' +
'?main=default' +
'&imported=time';
var scope = 'resources/blank.html';
var swr, sw;
return Promise.resolve()
.then(() => service_worker_unregister_and_register(t, script, scope))
.then(registration => swr = registration)
.then(() => wait_for_update(t, swr))
.then(worker => sw = worker)
.then(() => wait_for_state(t, sw, 'activated'))
.then(() => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw,
null,
null]))
.then(() => swr.update())
.then(() => wait_for_update(t, swr))
.then(() => service_worker_unregister_and_done(t, scope));
}, "Test with (main: same, imported: different)");
promise_test(function(t) {
var script = 'resources/bytecheck-worker.py' +
'?main=time' +
'&imported=default';
var scope = 'resources/blank.html';
var swr, sw;
return Promise.resolve()
.then(() => service_worker_unregister_and_register(t, script, scope))
.then(registration => swr = registration)
.then(() => wait_for_update(t, swr))
.then(worker => sw = worker)
.then(() => wait_for_state(t, sw, 'activated'))
.then(() => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw,
null,
null]))
.then(() => swr.update())
.then(() => wait_for_update(t, swr))
.then(() => service_worker_unregister_and_done(t, scope));
}, "Test with (main: different, imported: same)");
promise_test(function(t) {
var script = 'resources/bytecheck-worker.py' +
'?main=time' +
'&imported=time';
var scope = 'resources/blank.html';
var swr, sw;
return Promise.resolve()
.then(() => service_worker_unregister_and_register(t, script, scope))
.then(registration => swr = registration)
.then(() => wait_for_update(t, swr))
.then(worker => sw = worker)
.then(() => wait_for_state(t, sw, 'activated'))
.then(() => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw,
null,
null]))
.then(() => swr.update())
.then(() => wait_for_update(t, swr))
.then(() => service_worker_unregister_and_done(t, scope));
}, "Test with (main: different, imported: different)");
</script>