summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/service-workers/service-worker/immutable-prototype-serviceworker.https.html
blob: e63f6b348a861345101670b9c3d87aaa4977b0c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
'use strict';

let expected = ['immutable', 'immutable', 'immutable', 'immutable', 'immutable'];

promise_test(t =>
  navigator.serviceWorker.register('resources/immutable-prototype-serviceworker.js', {scope: './resources/'})
      .then(registration => {
    let worker = registration.installing || registration.waiting || registration.active;
    let channel = new MessageChannel()
    worker.postMessage(channel.port2, [channel.port2]);
    let resolve;
    let promise = new Promise(r => resolve = r);
    channel.port1.onmessage = resolve;
    return promise.then(result => assert_array_equals(expected, result.data));
  }),
'worker prototype chain should be immutable');
</script>
</html>