Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/resources/interfaces-worker.sub.js

Issue 2933913002: Upstream service worker prototype test to WPT
Patch Set: Migrate test for immutable prototype Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 importScripts('interfaces.js'); 1 'use strict';
2
3 importScripts('interfaces-idls.js');
2 importScripts('worker-testharness.js'); 4 importScripts('worker-testharness.js');
3 importScripts('../resources/testharness-helpers.js'); 5 importScripts('/resources/WebIDLParser.js');
6 importScripts('/resources/idlharness.js');
4 7
5 var EVENT_HANDLER = 'object'; 8 var idlArray = new IdlArray();
6 9 idlArray.add_untested_idls(idls.untested);
7 test(function() { 10 idlArray.add_idls(idls.tested);
8 verify_interface('ServiceWorkerGlobalScope', 11 idlArray.add_objects({
9 self, 12 ServiceWorkerGlobalScope: ['self'],
10 { 13 Clients: ['self.clients'],
11 clients: 'object', 14 ServiceWorkerRegistration: ['self.registration'],
12 registration: 'object', 15 CacheStorage: ['self.caches']
13 skipWaiting: 'function', 16 // TODO: Test instances of Client and WindowClient, e.g.
14 17 // Client: ['self.clientInstance'],
15 onactivate: EVENT_HANDLER, 18 // WindowClient: ['self.windowClientInstance']
16 onfetch: EVENT_HANDLER, 19 });
17 oninstall: EVENT_HANDLER,
18 onmessage: EVENT_HANDLER,
19 onmessageerror: EVENT_HANDLER
20 });
21 }, 'ServiceWorkerGlobalScope');
22
23 test(function() {
24 verify_interface('Clients',
25 self.clients,
26 {
27 claim: 'function',
28 matchAll: 'function'
29 });
30 }, 'Clients');
31
32 test(function() {
33 verify_interface('Client');
34 // FIXME: Get an instance and test it, or ensure property exists on
35 // prototype.
36 }, 'Client');
37
38 test(function() {
39 verify_interface('WindowClient');
40 // FIXME: Get an instance and test it, or ensure property exists on
41 // prototype.
42 }, 'WindowClient');
43
44 test(function() {
45 verify_interface('CacheStorage',
46 self.caches,
47 {
48 match: 'function',
49 has: 'function',
50 open: 'function',
51 delete: 'function',
52 keys: 'function'
53 });
54 }, 'CacheStorage');
55 20
56 promise_test(function(t) { 21 promise_test(function(t) {
57 return create_temporary_cache(t) 22 return create_temporary_cache(t)
58 .then(function(cache) { 23 .then(function(cache) {
59 verify_interface('Cache', 24 self.cacheInstance = cache;
60 cache, 25
61 { 26 idlArray.add_objects({ Cache: ['self.cacheInstance'] });
62 match: 'function', 27 idlArray.test();
63 matchAll: 'function',
64 add: 'function',
65 addAll: 'function',
66 put: 'function',
67 delete: 'function',
68 keys: 'function'
69 });
70 }); 28 });
71 }, 'Cache'); 29 }, 'test setup (cache creation)');
72 30
73 test(function() { 31 test(function() {
74 var req = new Request('http://{{host}}/', 32 var req = new Request('http://{{host}}/',
75 {method: 'POST', 33 {method: 'POST',
76 headers: [['Content-Type', 'Text/Html']]}); 34 headers: [['Content-Type', 'Text/Html']]});
77 assert_equals( 35 assert_equals(
78 new ExtendableEvent('ExtendableEvent').type, 36 new ExtendableEvent('ExtendableEvent').type,
79 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent'); 37 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent');
80 assert_throws(new TypeError, function() { 38 assert_throws(new TypeError, function() {
81 new FetchEvent('FetchEvent'); 39 new FetchEvent('FetchEvent');
(...skipping 26 matching lines...) Expand all
108 new FetchEvent('FetchEvent', {request: req, clientId : 'test-client-id'}). clientId, 'test-client-id', 66 new FetchEvent('FetchEvent', {request: req, clientId : 'test-client-id'}). clientId, 'test-client-id',
109 'FetchEvent.clientId with option {clientId : "test-client-id"} should be " test-client-id"'); 67 'FetchEvent.clientId with option {clientId : "test-client-id"} should be " test-client-id"');
110 assert_equals( 68 assert_equals(
111 new FetchEvent('FetchEvent', {request: req, isReload : true}).isReload, tr ue, 69 new FetchEvent('FetchEvent', {request: req, isReload : true}).isReload, tr ue,
112 'FetchEvent.isReload with option {isReload : true} should be true'); 70 'FetchEvent.isReload with option {isReload : true} should be true');
113 assert_equals( 71 assert_equals(
114 new FetchEvent('FetchEvent', {request : req, isReload : true}).request.url , 72 new FetchEvent('FetchEvent', {request : req, isReload : true}).request.url ,
115 'http://{{host}}/', 73 'http://{{host}}/',
116 'FetchEvent.request.url should return the value it was initialized to'); 74 'FetchEvent.request.url should return the value it was initialized to');
117 }, 'Event constructors'); 75 }, 'Event constructors');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698