File: url-parsing.https.html

package info (click to toggle)
thunderbird 1%3A128.14.0esr-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,334,824 kB
  • sloc: cpp: 7,391,917; javascript: 5,617,271; ansic: 3,833,216; python: 1,230,742; xml: 619,690; asm: 456,022; java: 179,892; sh: 118,796; makefile: 21,908; perl: 14,825; objc: 12,399; yacc: 4,583; pascal: 2,973; lex: 1,720; ruby: 1,190; exp: 762; sql: 674; awk: 580; php: 436; lisp: 430; sed: 70; csh: 10
file content (73 lines) | stat: -rw-r--r-- 3,208 bytes parent folder | download | duplicates (34)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE html>
<title>register()/getRegistration() URL parsing, with multiple globals in play</title>
<link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-register-method">
<link rel="help" href="https://w3c.github.io/ServiceWorker/spec/service_worker/index.html#service-worker-container-getregistration-method">
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<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>

<!-- This is the entry global -->

<iframe src="incumbent/incumbent.https.html"></iframe>

<script>
'use strict';

const loadPromise = new Promise(resolve => {
    window.addEventListener('load', () => resolve());
});

promise_test(t => {
    let registration;

    return loadPromise.then(() => {
        return frames[0].testRegister();
    }).then(r => {
        registration = r;
        return wait_for_state(t, registration.installing, 'activated');
    }).then(_ => {
        assert_equals(registration.active.scriptURL, normalizeURL('relevant/test-sw.js'), 'the script URL should be parsed against the relevant global');
        assert_equals(registration.scope, normalizeURL('relevant/'), 'the default scope URL should be parsed against the parsed script URL');

        return registration.unregister();
    });
}, 'register should use the relevant global of the object it was called on to resolve the script URL and the default scope URL');

promise_test(t => {
    let registration;

    return loadPromise.then(() => {
        return frames[0].testRegister({ scope: 'scope' });
    }).then(r => {
        registration = r;
        return wait_for_state(t, registration.installing, 'activated');
    }).then(_ => {
        assert_equals(registration.active.scriptURL, normalizeURL('relevant/test-sw.js'), 'the script URL should be parsed against the relevant global');
        assert_equals(registration.scope, normalizeURL('relevant/scope'), 'the given scope URL should be parsed against the relevant global');

        return registration.unregister();
    });
}, 'register should use the relevant global of the object it was called on to resolve the script URL and the given scope URL');

promise_test(t => {
    let registration;

    return loadPromise.then(() => {
        return navigator.serviceWorker.register(normalizeURL('relevant/test-sw.js'));
    }).then(r => {
        registration = r;
        return frames[0].testGetRegistration();
    })
    .then(gottenRegistration => {
        assert_not_equals(registration, null, 'the registration should not be null');
        assert_not_equals(gottenRegistration, null, 'the registration from the other frame should not be null');
        assert_equals(gottenRegistration.scope, registration.scope,
            'the retrieved registration\'s scope should be equal to the original\'s scope');

        return registration.unregister();
    });
}, 'getRegistration should use the relevant global of the object it was called on to resolve the script URL');

</script>