File: claim-with-redirect.https.html

package info (click to toggle)
firefox-esr 115.14.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,659,200 kB
  • sloc: cpp: 6,676,648; javascript: 5,690,850; ansic: 3,328,545; python: 1,120,605; asm: 397,163; xml: 180,531; java: 178,838; sh: 68,930; makefile: 20,999; perl: 12,595; objc: 12,561; yacc: 4,583; cs: 3,846; pascal: 2,840; lex: 1,720; ruby: 1,079; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10
file content (59 lines) | stat: -rw-r--r-- 2,344 bytes parent folder | download | duplicates (26)
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
<!DOCTYPE html>
<title>Service Worker: Claim() when update happens after redirect</title>
<script src="/common/get-host-info.sub.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/test-helpers.sub.js"></script>
<body>
<script>
var host_info = get_host_info();
var BASE_URL = host_info['HTTPS_ORIGIN'] + base_path();
var OTHER_BASE_URL = host_info['HTTPS_REMOTE_ORIGIN'] + base_path();

var WORKER_URL = OTHER_BASE_URL + 'resources/update-claim-worker.py'
var SCOPE_URL = OTHER_BASE_URL + 'resources/redirect.py'
var OTHER_IFRAME_URL = OTHER_BASE_URL +
                       'resources/claim-with-redirect-iframe.html';

// Different origin from the registration
var REDIRECT_TO_URL = BASE_URL +
                      'resources/claim-with-redirect-iframe.html?redirected';

var REGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?register=' +
                          encodeURIComponent(WORKER_URL) + '&' +
                          'scope=' + encodeURIComponent(SCOPE_URL);
var REDIRECT_IFRAME_URL = SCOPE_URL + '?Redirect=' +
                          encodeURIComponent(REDIRECT_TO_URL);
var UPDATE_IFRAME_URL = OTHER_IFRAME_URL + '?update=' +
                        encodeURIComponent(SCOPE_URL);
var UNREGISTER_IFRAME_URL = OTHER_IFRAME_URL + '?unregister=' +
                            encodeURIComponent(SCOPE_URL);

var waiting_resolver = undefined;

addEventListener('message', e => {
    if (waiting_resolver !== undefined) {
      waiting_resolver(e.data);
    }
  });

function assert_with_iframe(url, expected_message) {
  return new Promise(resolve => {
        waiting_resolver = resolve;
        with_iframe(url);
      })
    .then(data => assert_equals(data.message, expected_message));
}

// This test checks behavior when browser got a redirect header from in-scope
// page and navigated to out-of-scope page which has a different origin from any
// registrations.
promise_test(t => {
  return assert_with_iframe(REGISTER_IFRAME_URL, 'registered')
    .then(() => assert_with_iframe(REDIRECT_IFRAME_URL, 'redirected'))
    .then(() => assert_with_iframe(UPDATE_IFRAME_URL, 'updated'))
    .then(() => assert_with_iframe(UNREGISTER_IFRAME_URL, 'unregistered'));
  }, 'Claim works after redirection to another origin');

</script>
</body>