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

This commit is contained in:
Ho-Pang Hsu 2017-06-07 14:06:52 +08:00
parent 1851f6f815
commit d76ced1949
4 changed files with 151 additions and 0 deletions

View File

@ -64843,6 +64843,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": [
[
{}
@ -127676,6 +127686,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",
@ -213561,6 +213577,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"
@ -214353,6 +214377,10 @@
"7c8c6c3edca83d54f1838eccf3afb0b1223c7a44",
"testharness"
],
"service-workers/service-worker/update-bytecheck.https.html": [
"6562348b198124822297c6b622c3e63870427672",
"testharness"
],
"service-workers/service-worker/update-recovery.https.html": [
"aac5705d6844e4a33200418504adb57053a45be2",
"testharness"

View File

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

View File

@ -0,0 +1,32 @@
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_path = ''
if 'path' in request.GET:
imported_request_path = request.GET['path']
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('%sbytecheck-worker-imported-script.py%s');
''' % (main_content, imported_request_path, imported_request)
return headers, body

View File

@ -0,0 +1,72 @@
<!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>
/*
* @param bolean cors
* Determine wether the imported script should be a cross origin script.
* @param string main
* Decide the content of the main script, where 'default' is for constant
* content while 'time' is for time-variant content.
* @param string imported
* Decide the content of the imported script, where 'default' is for constant
* content while 'time' is for time-variant content.
*/
const settings = [{cors: false, main: 'default', imported: 'default'},
{cors: false, main: 'default', imported: 'time' },
{cors: false, main: 'time', imported: 'default'},
{cors: false, main: 'time', imported: 'time' },
{cors: true, main: 'default', imported: 'default'},
{cors: true, main: 'default', imported: 'time' },
{cors: true, main: 'time', imported: 'default'},
{cors: true, main: 'time', imported: 'time' }];
settings.reduce((p, s) => {
return p.then(promise_test(function(t) {
var path = !s.cors ? ''
: 'https://www1.web-platform.test:8443/' +
'service-workers/service-worker/resources/';
var script = 'resources/bytecheck-worker.py' +
'?main=' + s.main +
'&imported=' + s.imported +
'&path=' + path;
var scope = 'resources/blank.html';
var swr, sw;
return Promise.resolve()
// Register a service worker.
.then(_ => service_worker_unregister_and_register(t, script, scope))
.then(r => swr = r)
.then(_ => wait_for_update(t, swr))
.then(w => sw = w)
.then(_ => wait_for_state(t, sw, 'activated'))
.then(_ => assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw, null, null]))
// Update the service worker registration.
.then(_ => swr.update())
.then(_ => {
// If there should be a new service worker.
if (s.main === 'time' || s.imported === 'time') {
return wait_for_update(t, swr);
}
// Otherwise, make sure there is no newly created service worker.
assert_array_equals([swr.active,
swr.waiting,
swr.installing],
[sw, null, null]);
})
// Unregister the service worker.
.then(_ => service_worker_unregister_and_done(t, scope));
}, `Test(cors: ${s.cors}, main: ${s.main}, imported: ${s.imported})`));
}, Promise.resolve());
</script>