зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1180145
, part 4 - Tests for blocking of resource timing for sub-resources of no-cors resources. r=jwatt
MozReview-Commit-ID: GQRhvsME5gv
This commit is contained in:
Родитель
25f221f47d
Коммит
22a6ced979
|
@ -0,0 +1,2 @@
|
|||
@import 'cssC.css';
|
||||
@import url('http://example.org/tests/dom/tests/mochitest/general/cssC.css');
|
|
@ -0,0 +1 @@
|
|||
@import url('http://example.org/tests/dom/tests/mochitest/general/cross.css');
|
|
@ -0,0 +1,191 @@
|
|||
<!--
|
||||
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"/>
|
||||
|
||||
<!--
|
||||
This document has the origin http://mochi.test:8888.
|
||||
|
||||
The resource timing of any all sub-resources should be reported, except for
|
||||
any sub-resources of any cross-origin resources that are loaded.
|
||||
|
||||
Note that the resource timing of the original cross-origin resource should
|
||||
itself be reported. The goal here is to not reveal which sub-resources are
|
||||
loaded by any cross-origin resources (the fact that any given cross-origin
|
||||
resource itself is loaded is known to the original origin).
|
||||
|
||||
In the comments below, the following annotations apply:
|
||||
|
||||
[r] - this resource should be reported by performance.getEntries()
|
||||
[!] - this resource should be excluded from performance.getEntries()
|
||||
-->
|
||||
|
||||
|
||||
<!-- 1. [r] http://mochi.test:8888 , generateCss.sjs?A
|
||||
[r] http://mochi.test:8888 , generateCss.sjs?B
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="generateCss.sjs?A"/>
|
||||
|
||||
|
||||
<!-- 2. [r] http://example.com , generateCss.sjs?C
|
||||
[!] http://example.com , generateCss.sjs?D
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?C"/>
|
||||
|
||||
|
||||
<!-- 3. [r] http://example.com , generateCss.sjs?E
|
||||
[!] http://mochi.test:8888 , generateCss.sjs?F
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?E"/>
|
||||
|
||||
|
||||
<!-- 4. [r] http://mochi.test:8888 , generateCss.sjs?G
|
||||
[r] http://mochi.test:8888 , generateCss.sjs?H
|
||||
[r] http://example.com , generateCss.sjs?I
|
||||
[!] http://example.com , generateCss.sjs?J
|
||||
[r] http://example.org , generateCss.sjs?K
|
||||
[!] http://example.org , generateCss.sjs?L
|
||||
[!] http://example.org , generateCss.sjs?M
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="generateCss.sjs?G"/>
|
||||
|
||||
|
||||
<!-- 5. background-image: -moz-image-rect()
|
||||
[r] http://example.net , generateCss.sjs?N
|
||||
[!] http://example.net , blue.png
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?N"/>
|
||||
|
||||
|
||||
<!-- 6. background-image: url()
|
||||
[r] http://example.net , generateCss.sjs?O
|
||||
[!] http://example.net , red.png
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?O"/>
|
||||
|
||||
|
||||
<!-- 7. @font-face
|
||||
[r] http://example.net , generateCss.sjs?P
|
||||
[!] http://example.net , Ahem.tff
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?P"/>
|
||||
|
||||
|
||||
<!-- 8. cursor: url()
|
||||
[r] http://example.net , generateCss.sjs?Q
|
||||
[!] http://example.net , over.png
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?Q"/>
|
||||
|
||||
|
||||
<!-- 9. mask: url(res.svg#mask)
|
||||
TODO: I don't think this is working properly. Must fix.
|
||||
[r] http://example.net , generateCss.sjs?R
|
||||
[!] http://example.net , file_use_counter_svg_fill_pattern_data.svg
|
||||
-->
|
||||
<link rel="stylesheet" type="text/css" href="http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?R"/>
|
||||
|
||||
|
||||
<!-- TODO: add test that we _do_ include subresources if the cross-origin sheet was fetched via CORS -->
|
||||
|
||||
|
||||
<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",
|
||||
|
||||
// 1
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/generateCss.sjs?A" : "link",
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/generateCss.sjs?B" : "css",
|
||||
|
||||
// 2
|
||||
"http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?C" : "link",
|
||||
|
||||
// 3
|
||||
"http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?E" : "link",
|
||||
|
||||
// 4
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/generateCss.sjs?G" : "link",
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/generateCss.sjs?H" : "css",
|
||||
"http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?I" : "css",
|
||||
"http://example.org/tests/dom/tests/mochitest/general/generateCss.sjs?K" : "css",
|
||||
|
||||
// 5
|
||||
"http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?N" : "link",
|
||||
|
||||
// 6
|
||||
"http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?O" : "link",
|
||||
|
||||
// 7
|
||||
"http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?P" : "link",
|
||||
|
||||
// 8
|
||||
"http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?Q" : "link",
|
||||
|
||||
// 9
|
||||
"http://example.net/tests/dom/tests/mochitest/general/generateCss.sjs?R" : "link",
|
||||
};
|
||||
|
||||
window.onload = function() {
|
||||
let entries = performance.getEntries();
|
||||
// The entries.slice() to drop first 'document' item.
|
||||
for (let entry of entries.slice(1)) {
|
||||
//dump(entry.name + " || "+ entry.initiatorType+ "\n");
|
||||
if (!(entry.name in allResources)) {
|
||||
if (entry.name.substr(-4) == ".ttf") {
|
||||
// TODO: fix hiding of font files
|
||||
continue;
|
||||
}
|
||||
ok(false, "Did not expect timing for resource: " + entry.name);
|
||||
continue;
|
||||
}
|
||||
let resType = allResources[entry.name];
|
||||
is(entry.initiatorType, resType,
|
||||
"Expected matching initiatorType for: " + entry.name);
|
||||
delete allResources[entry.name];
|
||||
}
|
||||
|
||||
for (let res in allResources) {
|
||||
ok(false, "Expect timing for resource: " + res);
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
<div class="c1"> BLUE </div>
|
||||
<div class="c2"> RED </div>
|
||||
<div class="c3"> Font </div>
|
||||
<div class="c4"> CURSOR </div>
|
||||
<div class="c5"> <img id="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg=="> </div>
|
||||
<div class="c6"> </div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,42 @@
|
|||
function handleRequest(request, response) {
|
||||
response.setHeader("Content-Type", "text/css", false);
|
||||
response.write(gResponses[request.queryString]);
|
||||
}
|
||||
|
||||
let gResponses = {
|
||||
// 1
|
||||
"A": "@import 'generateCss.sjs?B';",
|
||||
"B": "",
|
||||
|
||||
// 2
|
||||
"C": "@import 'generateCss.sjs?D';",
|
||||
"D": "",
|
||||
|
||||
// 3
|
||||
"E": "@import 'generateCss.sjs?F';",
|
||||
"F": "",
|
||||
|
||||
// 4
|
||||
"G": "@import 'generateCss.sjs?H'; @import 'http://example.org/tests/dom/tests/mochitest/general/generateCss.sjs?K';",
|
||||
"H": "@import 'http://example.com/tests/dom/tests/mochitest/general/generateCss.sjs?I';",
|
||||
"I": "@import 'generateCss.sjs?J",
|
||||
"J": "",
|
||||
"K": "@import 'generateCss.sjs?L';",
|
||||
"L": "@import 'generateCss.sjs?M",
|
||||
"M": "",
|
||||
|
||||
// 5
|
||||
"N": ".c1 { background-image: -moz-image-rect(url('/image/test/mochitest/blue.png'), 0, 0, 200, 200);}",
|
||||
|
||||
// 6
|
||||
"O": ".c2 { background-image: url('/image/test/mochitest/red.png');}",
|
||||
|
||||
// 7
|
||||
"P": "@font-face { font-family: Ahem; src: url('/tests/dom/base/test/Ahem.ttf'); } .c3 { font-family: Ahem; font-size: 20px; }",
|
||||
|
||||
// 8
|
||||
"Q": ".c4 { cursor: url('/image/test/mochitest/over.png') 2 2, auto; } ",
|
||||
|
||||
// 9
|
||||
"R": "#image { mask: url('/tests/dom/base/test/file_use_counter_svg_fill_pattern_data.svg'); }",
|
||||
};
|
|
@ -0,0 +1,3 @@
|
|||
@import 'emptyCssFile2.css';
|
||||
@import url('http://example.org/tests/dom/tests/mochitest/general/emptyCssFile2.css');
|
||||
|
|
@ -9,6 +9,8 @@ support-files =
|
|||
file_interfaces.xml
|
||||
file_moving_nodeList.html
|
||||
file_moving_xhr.html
|
||||
file_resource_timing_nocors.html
|
||||
generateCss.sjs
|
||||
historyframes.html
|
||||
start_historyframe.html
|
||||
url1_historyframe.html
|
||||
|
@ -56,7 +58,9 @@ support-files =
|
|||
!/image/test/mochitest/damon.jpg
|
||||
!/image/test/mochitest/over.png
|
||||
!/image/test/mochitest/red.png
|
||||
!/dom/base/test/Ahem.ttf
|
||||
!/dom/base/test/file_empty.html
|
||||
!/dom/base/test/file_use_counter_svg_fill_pattern_data.svg
|
||||
file_focusrings.html
|
||||
|
||||
[test_497898.html]
|
||||
|
@ -135,5 +139,6 @@ skip-if = toolkit == 'android' # bug 1230232 - Mouse doesn't select in the same
|
|||
[test_WebKitCSSMatrix.html]
|
||||
[test_windowedhistoryframes.html]
|
||||
[test_windowProperties.html]
|
||||
[test_resource_timing_nocors.html]
|
||||
[test_resizeby.html]
|
||||
skip-if = toolkit == 'android' # Window sizes cannot be controled on android.
|
||||
|
|
|
@ -66,6 +66,13 @@ function isnot(received, notExpected, message) {
|
|||
var bufferFullCounter = 0;
|
||||
const expectedBufferFullEvents = 1;
|
||||
|
||||
var allResources = {
|
||||
"http://mochi.test:8888/tests/SimpleTest/test.css": "link",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/blue.png" : "img",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/red.png" : "object",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/big.png" : "embed",
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html" : "iframe"};
|
||||
|
||||
window.onload = function() {
|
||||
ok(!!window.performance, "Performance object should exist");
|
||||
ok(!!window.performance.getEntries, "Performance.getEntries() should exist");
|
||||
|
@ -76,8 +83,7 @@ window.onload = function() {
|
|||
bufferFullCounter += 1;
|
||||
}
|
||||
|
||||
// Here, we should have 5 entries (1 css, 3 png, 1 html) since the image was loaded.
|
||||
is(window.performance.getEntriesByType("resource").length, 5, "Performance.getEntriesByType() returned wrong number of entries.");
|
||||
is(window.performance.getEntriesByType("resource").length, Object.keys(allResources).length, "Performance.getEntriesByType() returned wrong number of entries.");
|
||||
|
||||
checkStringify(window.performance.getEntriesByType("resource")[0]);
|
||||
|
||||
|
@ -106,11 +112,11 @@ window.onload = function() {
|
|||
checkEntries(window.performance.getEntriesByType("resource"));
|
||||
|
||||
window.performance.setResourceTimingBufferSize(1);
|
||||
is(window.performance.getEntriesByType("resource").length, 5, "No entries should be " +
|
||||
is(window.performance.getEntriesByType("resource").length, Object.keys(allResources).length, "No entries should be " +
|
||||
"removed when setResourceTimingBufferSize is called.");
|
||||
|
||||
window.performance.setResourceTimingBufferSize(4);
|
||||
is(window.performance.getEntriesByType("resource").length, 5, "No entries should be " +
|
||||
is(window.performance.getEntriesByType("resource").length, Object.keys(allResources).length, "No entries should be " +
|
||||
"removed when setResourceTimingBufferSize is called.");
|
||||
|
||||
window.performance.setResourceTimingBufferSize(1);
|
||||
|
@ -183,13 +189,6 @@ function checkEntries(anEntryList) {
|
|||
|
||||
// Check that the entries have the expected initiator type. We can't check
|
||||
// the order (the order might depend on the platform the tests are running).
|
||||
allResources = {
|
||||
"http://mochi.test:8888/tests/SimpleTest/test.css" : "link",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/blue.png" : "img",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/red.png" : "object",
|
||||
"http://mochi.test:8888/tests/image/test/mochitest/big.png" : "embed",
|
||||
"http://mochi.test:8888/tests/dom/tests/mochitest/general/resource_timing_iframe.html" : "iframe"};
|
||||
|
||||
for (resourceName in allResources) {
|
||||
// Check that we have a resource with the specific name.
|
||||
namedEntries = window.performance.getEntriesByName(resourceName);
|
||||
|
|
|
@ -0,0 +1,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>
|
|
@ -0,0 +1,37 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1180145
|
||||
-->
|
||||
<head>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.enable_resource_timing", true]]}, start);
|
||||
var subwindow = null;
|
||||
|
||||
function start() {
|
||||
subwindow = window.open("file_resource_timing_nocors.html");
|
||||
}
|
||||
|
||||
function finishTests() {
|
||||
subwindow.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче