| OLD | NEW |
| (Empty) |
| 1 importScripts('interfaces.js'); | |
| 2 importScripts('worker-testharness.js'); | |
| 3 | |
| 4 var EVENT_HANDLER = 'object'; | |
| 5 | |
| 6 test(function() { | |
| 7 verify_interface('ServiceWorkerGlobalScope', | |
| 8 self, | |
| 9 { | |
| 10 clients: 'object', | |
| 11 registration: 'object', | |
| 12 skipWaiting: 'function', | |
| 13 | |
| 14 onactivate: EVENT_HANDLER, | |
| 15 onfetch: EVENT_HANDLER, | |
| 16 oninstall: EVENT_HANDLER, | |
| 17 onmessage: EVENT_HANDLER | |
| 18 }); | |
| 19 }, 'ServiceWorkerGlobalScope'); | |
| 20 | |
| 21 test(function() { | |
| 22 verify_interface('Clients', | |
| 23 self.clients, | |
| 24 { | |
| 25 claim: 'function', | |
| 26 matchAll: 'function' | |
| 27 }); | |
| 28 }, 'Clients'); | |
| 29 | |
| 30 test(function() { | |
| 31 verify_interface('Client'); | |
| 32 // FIXME: Get an instance and test it, or ensure property exists on | |
| 33 // prototype. | |
| 34 }, 'Client'); | |
| 35 | |
| 36 test(function() { | |
| 37 verify_interface('WindowClient'); | |
| 38 // FIXME: Get an instance and test it, or ensure property exists on | |
| 39 // prototype. | |
| 40 }, 'WindowClient'); | |
| 41 | |
| 42 test(function() { | |
| 43 verify_interface('CacheStorage', | |
| 44 self.caches, | |
| 45 { | |
| 46 match: 'function', | |
| 47 has: 'function', | |
| 48 open: 'function', | |
| 49 delete: 'function', | |
| 50 keys: 'function' | |
| 51 }); | |
| 52 }, 'CacheStorage'); | |
| 53 | |
| 54 promise_test(function(t) { | |
| 55 return create_temporary_cache(t) | |
| 56 .then(function(cache) { | |
| 57 verify_interface('Cache', | |
| 58 cache, | |
| 59 { | |
| 60 match: 'function', | |
| 61 matchAll: 'function', | |
| 62 add: 'function', | |
| 63 addAll: 'function', | |
| 64 put: 'function', | |
| 65 delete: 'function', | |
| 66 keys: 'function' | |
| 67 }); | |
| 68 }); | |
| 69 }, 'Cache'); | |
| 70 | |
| 71 test(function() { | |
| 72 assert_equals( | |
| 73 new ExtendableEvent('ExtendableEvent').type, | |
| 74 'ExtendableEvent', 'Type of ExtendableEvent should be ExtendableEvent'); | |
| 75 assert_throws(new TypeError, function() { | |
| 76 new FetchEvent('FetchEvent'); | |
| 77 }, 'FetchEvent constructor with one argument throws'); | |
| 78 assert_throws(new TypeError, function() { | |
| 79 new FetchEvent('FetchEvent', {}); | |
| 80 }, 'FetchEvent constructor with empty init dict throws'); | |
| 81 assert_throws(new TypeError, function() { | |
| 82 new FetchEvent('FetchEvent', {request: null}); | |
| 83 }, 'FetchEvent constructor with null request member throws'); | |
| 84 var req = new Request('https://www.example.com/', {method: 'POST'}); | |
| 85 assert_equals( | |
| 86 new FetchEvent('FetchEvent', {request: req}).type, | |
| 87 'FetchEvent', 'Type of FetchEvent should be FetchEvent'); | |
| 88 assert_equals( | |
| 89 new FetchEvent('FetchEvent', {request: req}).cancelable, | |
| 90 false, 'Default FetchEvent.cancelable should be false'); | |
| 91 assert_equals( | |
| 92 new FetchEvent('FetchEvent', {request: req}).bubbles, | |
| 93 false, 'Default FetchEvent.bubbles should be false'); | |
| 94 assert_equals( | |
| 95 new FetchEvent('FetchEvent', {request: req}).clientId, | |
| 96 null, 'Default FetchEvent.clientId should be null'); | |
| 97 assert_equals( | |
| 98 new FetchEvent('FetchEvent', {request: req}).isReload, | |
| 99 false, 'Default FetchEvent.isReload should be false'); | |
| 100 assert_equals( | |
| 101 new FetchEvent( | |
| 102 'FetchEvent', {request: req, cancelable: false}).cancelable, | |
| 103 false, 'FetchEvent.cancelable should be false'); | |
| 104 assert_equals( | |
| 105 new FetchEvent( | |
| 106 'FetchEvent', | |
| 107 {request: req, | |
| 108 clientId: '006e6aae-cfd4-4331-bea8-fbae364703cf'}).clientId, | |
| 109 '006e6aae-cfd4-4331-bea8-fbae364703cf', | |
| 110 'FetchEvent.clientId with option {clientId: string} should be ' + | |
| 111 'the value of string'); | |
| 112 assert_equals( | |
| 113 new FetchEvent( | |
| 114 'FetchEvent', | |
| 115 {request: req, isReload: true}).isReload, | |
| 116 true, | |
| 117 'FetchEvent.isReload with option {isReload: true} should be true'); | |
| 118 assert_equals( | |
| 119 new FetchEvent( | |
| 120 'FetchEvent', | |
| 121 {request: req, isReload: true}).request.url, | |
| 122 'https://www.example.com/', | |
| 123 'FetchEvent.request.url should return the value it was ' + | |
| 124 'initialized to'); | |
| 125 }, 'Event constructors'); | |
| OLD | NEW |