summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/general/resource_timing_nocors.html
blob: 39b34950fceaf238e27a08c5253c4939f5bdde0a (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
<!--
  Any copyright is dedicated to the Public Domain.
  http://creativecommons.org/publicdomain/zero/1.0/
-->

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css"/>
  <link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/dom/tests/mochitest/general/linkA.css"/>
  <link rel="stylesheet" type="text/css" href="http://example.com/tests/dom/tests/mochitest/general/linkB.css"/>
  <link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/linkC.css"/>

<!--

  Resources fetched by a cross-origin stylesheet loaded with a no-cors mode should not be reported.
  Resources marked with a ^ should be reported in performance.getEntries()

  (mochi.test:8888 | linkA.css)^ -> (mochi.test:8888 | cssA.css)^
                                 -> (mochi.test:8888 | cssB.css)^ -> (mochi.test:8888 | cssC.css)^
                                                                  -> (example.org     | cssC.css)^
  (example.com     | linkB.css)^ -> (example.com     | cssA.css)
                                 -> (mochi.test:8888 | cssA.css)
                                 -> (test2.examp.org | cssB.css) -> (test2.examp.org | cssC.css)
                                                                 -> (example.org     | cssC.css)
                                 -> (example.net     | cssC.css)

  (example.net     | linkC.css)^ -> (example.net | cssA.css)
    [WITH Allow-* HEADERS]

-->


  <script type="application/javascript">

function ok(cond, message) {
  window.opener.ok(cond, message)
}

function is(received, expected, message) {
  window.opener.is(received, expected, message);
}

function isnot(received, notExpected, message) {
  window.opener.isnot(received, notExpected, message);
}

var allResources = {
  "http://mochi.test:8888/tests/SimpleTest/test.css" : "link",
  "http://mochi.test:8888/tests/dom/tests/mochitest/general/linkA.css" : "link",
  "http://example.com/tests/dom/tests/mochitest/general/linkB.css" : "link",
  "http://example.net/tests/dom/tests/mochitest/general/linkC.css" : "link",
  "http://mochi.test:8888/tests/dom/tests/mochitest/general/cssA.css" : "css",
  "http://mochi.test:8888/tests/dom/tests/mochitest/general/cssB.css" : "css",
  "http://mochi.test:8888/tests/dom/tests/mochitest/general/cssC.css" : "css",
  "http://example.org/tests/dom/tests/mochitest/general/cssC.css" : "css",
};

window.onload = function() {
  let entries = performance.getEntries();
  for (let entry of entries) {
    let type = allResources[entry.name];
    if (!type) {
      ok(false, "Did not expect to find resource: "+entry.name);
      continue;
    }

    is(entry.initiatorType, type, "Expected initiatorType does not match");
  }

  is(entries.length, Object.keys(allResources).length, "Found wrong number of resources");

  window.opener.finishTests();
}

</script>
</head>
<body>
  <a target="_blank"
     href="https://bugzilla.mozilla.org/show_bug.cgi?id=1180145"
     title="Resource timing NO-CORS CSS">
    Bug #1180145 -  Resource Timing NO-CORS CSS
  </a>
  <p id="display"></p>
  <div id="content">
  </div>
</body>
</html>