summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/private-network-access/preflight-cache.https.window.js
blob: 87dbf501f628a25fa299240da5d5856f4366d8cc (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// META: script=/common/utils.js
// META: script=resources/support.sub.js
//
// Spec: https://wicg.github.io/private-network-access/#cors-preflight
//
// These tests verify that PNA preflight responses are cached.
//
// TODO(https://crbug.com/1268312): We cannot currently test that cache
// entries are keyed by target IP address space because that requires
// loading the same URL from different IP address spaces, and the WPT
// framework does not allow that.
promise_test(async t => {
  let uuid = token();
  await fetchTest(t, {
    source: { server: Server.HTTPS_PRIVATE },
    target: {
      server: Server.HTTPS_LOCAL,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
  await fetchTest(t, {
    source: { server: Server.HTTPS_PRIVATE },
    target: {
      server: Server.HTTPS_LOCAL,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
}, "private to local: success.");

promise_test(async t => {
  let uuid = token();
  await fetchTest(t, {
    source: { server: Server.HTTPS_PUBLIC },
    target: {
      server: Server.HTTPS_LOCAL,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
  await fetchTest(t, {
    source: { server: Server.HTTPS_PUBLIC },
    target: {
      server: Server.HTTPS_LOCAL,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
}, "public to local: success.");

promise_test(async t => {
  let uuid = token();
  await fetchTest(t, {
    source: { server: Server.HTTPS_PUBLIC },
    target: {
      server: Server.HTTPS_PRIVATE,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
  await fetchTest(t, {
    source: { server: Server.HTTPS_PUBLIC },
    target: {
      server: Server.HTTPS_PRIVATE,
      behavior: {
        preflight: PreflightBehavior.singlePreflight(uuid),
        response: ResponseBehavior.allowCrossOrigin(),
      },
    },
    expected: FetchTestResult.SUCCESS,
  });
}, "public to private: success.");