mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
Update web-platform-tests to revision ddfc95cf0493ae147a4f6a4d7be8eff1a0c23098
This commit is contained in:
parent
1f6a864ab5
commit
7e6290451f
832 changed files with 16026 additions and 2649 deletions
|
@ -11,12 +11,12 @@
|
|||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
var iframe;
|
||||
var d;
|
||||
var body;
|
||||
let iframe;
|
||||
let d;
|
||||
let body;
|
||||
|
||||
// explicitly test the namespace before we start testing
|
||||
test_namespace("getEntriesByType");
|
||||
// Explicitly test the namespace before we start testing.
|
||||
test_namespace('getEntriesByType');
|
||||
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
|
@ -30,17 +30,17 @@ function onload_test() {
|
|||
done();
|
||||
return;
|
||||
}
|
||||
var context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
var entries = context.getEntriesByType('resource');
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
// when a persistent connection is used, follow-on resources should be included as PerformanceResourceTiming objects
|
||||
// When a persistent connection is used, follow-on resources should be included as PerformanceResourceTiming objects.
|
||||
test_equals(entries.length, 2, 'There should be 2 PerformanceEntries');
|
||||
|
||||
if (entries.length >= 2) {
|
||||
// when a persistent connection is used, for the resource that reuses the socket, connectStart and connectEnd should have the same value as fetchStart
|
||||
var entry = entries[1];
|
||||
test_equals(entry.fetchStart, entry.connectStart, "connectStart and fetchStart should be the same");
|
||||
test_equals(entry.fetchStart, entry.connectEnd, "connectEnd and fetchStart should be the same");
|
||||
// When a persistent connection is used, for the resource that reuses the socket, connectStart and connectEnd should have the same value as fetchStart.
|
||||
const entry = entries[1];
|
||||
test_equals(entry.fetchStart, entry.connectStart, 'connectStart and fetchStart should be the same');
|
||||
test_equals(entry.fetchStart, entry.connectEnd, 'connectEnd and fetchStart should be the same');
|
||||
}
|
||||
|
||||
done();
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing in dedicated workers</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<link rel="stylesheet" href="resources/resource_timing_test0.css" />
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
const worker = new Worker("resources/worker_with_images.js");
|
||||
worker.onmessage = function(event) {
|
||||
const context = new PerformanceContext(window.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
test_equals(entries.length, 6, "There should be six entries: 4 scripts, 1 stylesheet, and the worker itself");
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that resources requested by dedicated workers don't appear in the main document.</p>
|
||||
</body>
|
||||
</html>
|
|
@ -10,27 +10,27 @@
|
|||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
// explicitly test the namespace before we start testing
|
||||
// Explicitly test the namespace before we start testing.
|
||||
test_namespace("getEntriesByType");
|
||||
|
||||
|
||||
var iframe;
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
var d = iframe.contentWindow.document;
|
||||
var body = d.createElement('body');
|
||||
const d = iframe.contentWindow.document;
|
||||
const body = d.createElement('body');
|
||||
d.getElementsByTagName('html')[0].appendChild(body);
|
||||
|
||||
var style = d.createElement('link');
|
||||
const style = d.createElement('link');
|
||||
style.rel = 'stylesheet';
|
||||
style.href = 'resource_timing_test0.css';
|
||||
body.appendChild(style);
|
||||
|
||||
var image = d.createElement('img');
|
||||
const image = d.createElement('img');
|
||||
image.src = 'resource_timing_test0.png';
|
||||
body.appendChild(image);
|
||||
|
||||
var subframe = d.createElement('iframe');
|
||||
const subframe = d.createElement('iframe');
|
||||
subframe.src = 'inject_resource_test.html';
|
||||
body.appendChild(subframe);
|
||||
}
|
||||
|
@ -39,13 +39,13 @@ function onload_test() {
|
|||
done();
|
||||
return;
|
||||
}
|
||||
var context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
var entries = context.getEntriesByType('resource');
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
var index = window.location.pathname.lastIndexOf('/');
|
||||
var pathname = window.location.pathname.substring(0, index) + '/';
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index) + '/';
|
||||
|
||||
var expected_entries = { };
|
||||
let expected_entries = { };
|
||||
expected_entries[ pathname + 'resources/resource_timing_test0.css' ] = 'link',
|
||||
expected_entries[ pathname + 'resources/resource_timing_test0.png' ] = 'img',
|
||||
expected_entries[ pathname + 'resources/inject_resource_test.html' ] = 'iframe',
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing frame initiator type</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
|
||||
function onload_test() {
|
||||
const iframe = document.getElementById('frameContext');
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index) +
|
||||
'/resources/blank_page_green.htm';
|
||||
const expected_entries = {};
|
||||
expected_entries[pathname] = 'frame';
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
done();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that the frame initiator type is represented.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/green_frame.htm" style="width: 250px; height: 250px;"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing ignores requests for data: URIs</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
const iframe_content = '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAOTm7AAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="></img>';
|
||||
iframe = document.getElementById('frameContext');
|
||||
iframe.contentWindow.document.write(iframe_content);
|
||||
}
|
||||
function onload_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
test_true(entries.length == 0, "entries.length == 0");
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that resources with data: URIs aren't present in the Resource Timing buffer.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing ignores failed resources</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
const iframe_content = '<img src="resources/non-existing-file.png"></img>';
|
||||
iframe = document.getElementById('frameContext');
|
||||
iframe.contentWindow.document.write(iframe_content);
|
||||
}
|
||||
function onload_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
test_true(entries.length == 0, "entries.length == 0");
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that failed resources aren't present in the Resource Timing buffer.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,109 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing initiator types</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true, timeout: 30000});
|
||||
|
||||
let background_loaded = false;
|
||||
let page_loaded = false;
|
||||
let ol_font_loaded = false;
|
||||
let ul_font_loaded = false;
|
||||
let xhr_loaded = false;
|
||||
|
||||
function check_finished() {
|
||||
if (!ul_font_loaded) {
|
||||
ul_font_loaded = check_font_loaded('ul');
|
||||
}
|
||||
if (!ol_font_loaded) {
|
||||
ol_font_loaded = check_font_loaded('ol');
|
||||
}
|
||||
if (page_loaded && ol_font_loaded && ul_font_loaded && background_loaded && xhr_loaded) {
|
||||
perform_test();
|
||||
} else {
|
||||
step_timeout(check_finished, 100);
|
||||
}
|
||||
}
|
||||
|
||||
function check_font_loaded(type) {
|
||||
const width_var_name = 'original_width_' + type;
|
||||
const element_var_name = 'element_' + type;
|
||||
if (!this.hasOwnProperty(width_var_name)) {
|
||||
const d = document.getElementById('frameContext').contentWindow.document;
|
||||
const list = d.createElement(type);
|
||||
const li = d.createElement('li');
|
||||
li.innerHTML = 'width_test';
|
||||
list.appendChild(li);
|
||||
d.getElementsByTagName('body')[0].appendChild(list);
|
||||
this[element_var_name] = list;
|
||||
this[width_var_name] = li.offsetHeight;
|
||||
}
|
||||
return this[width_var_name] != this[element_var_name].offsetHeight;
|
||||
}
|
||||
|
||||
function onload_test() {
|
||||
page_loaded = true;
|
||||
|
||||
const image = document.createElement('img');
|
||||
image.src = 'resources/blue.png?id=n1';
|
||||
background_loaded = image.complete;
|
||||
if (!background_loaded) {
|
||||
image.onload = function() {
|
||||
background_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
step_timeout(check_finished, 100);
|
||||
}
|
||||
|
||||
function perform_test() {
|
||||
const context = new PerformanceContext(document.getElementById('frameContext').contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index) + '/resources/';
|
||||
const font_pathname = window.location.pathname.substring(0, index - 15) + 'fonts/Ahem.ttf';
|
||||
|
||||
let expected_entries = {};
|
||||
expected_entries[font_pathname] = 'css';
|
||||
expected_entries[pathname + 'resource_timing_test0.png'] = 'img';
|
||||
expected_entries[pathname + 'blank_page_green.htm'] = 'iframe';
|
||||
expected_entries[pathname + 'empty_script.js'] = 'script';
|
||||
expected_entries[pathname + 'resource_timing_test0.css?id=embed'] = 'embed';
|
||||
expected_entries[pathname + 'resource_timing_test0.css?id=n1'] = 'css';
|
||||
expected_entries[font_pathname + '?id=n1'] = 'css';
|
||||
expected_entries[pathname + 'blue.png?id=1'] = 'css';
|
||||
expected_entries[pathname + 'blue.png?id=2'] = 'css';
|
||||
expected_entries[pathname + 'blue.png?id=async_xhr'] = 'xmlhttprequest';
|
||||
expected_entries[pathname + 'blue.png?id=body'] = 'body';
|
||||
expected_entries[pathname + 'blue.png?id=input'] = 'input';
|
||||
expected_entries[pathname + 'blue.png?id=n1'] = 'css';
|
||||
expected_entries[pathname + 'blue.png?id=object'] = 'object';
|
||||
expected_entries[pathname + 'blue.png?id=poster'] = 'video';
|
||||
expected_entries[pathname + 'nested.css'] = 'link';
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
done();
|
||||
}
|
||||
|
||||
window.on_test_body_created = check_finished;
|
||||
window.on_async_xhr_done = function() {
|
||||
xhr_loaded = true;
|
||||
check_finished();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that all of the initiator types are represented.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/all_resource_types.htm" style="width: 250px; height: 250px;"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing memory cached resources</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
let d;
|
||||
let iframe;
|
||||
let iframeBody;
|
||||
let count = 0;
|
||||
function onload_prep() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
d = iframe.contentWindow.document;
|
||||
iframeBody = d.body;
|
||||
|
||||
const image = d.createElement('img');
|
||||
image.addEventListener('load', function() {
|
||||
step_timeout(onload_test, 0); });
|
||||
image.src = 'blue.png?id=cached';
|
||||
iframeBody.appendChild(image);
|
||||
|
||||
const image2 = d.createElement('img');
|
||||
image2.addEventListener('load', function() {
|
||||
step_timeout(onload_test, 0); });
|
||||
image2.src = 'blue.png?id=cached';
|
||||
iframeBody.appendChild(image2);
|
||||
}
|
||||
|
||||
function onload_test() {
|
||||
++count;
|
||||
if (count < 2)
|
||||
return;
|
||||
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
test_equals(entries.length, 1, "There should be only one entry");
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index);
|
||||
let expected_entries = {};
|
||||
expected_entries[pathname + '/resources/blue.png?id=cached'] = 'img';
|
||||
test_resource_entries(entries, expected_entries);
|
||||
test_greater_than(entries[0].requestStart, 0, 'requestStart should be non-zero on the same-origin request');
|
||||
test_greater_or_equals(entries[0].responseEnd, entries[0].startTime, 'responseEnd should not be before startTime');
|
||||
test_greater_or_equals(entries[0].duration, 0, 'duration should not be negative');
|
||||
|
||||
context.clearResourceTimings();
|
||||
start_crossorigin_test();
|
||||
}
|
||||
function start_crossorigin_test() {
|
||||
const image3 = d.createElement('img');
|
||||
image3.addEventListener("load", function() { step_timeout(finish_crossorigin_test, 0); });
|
||||
image3.src = 'http://{{domains[www1]}}:{{ports[http][1]}}{{location[path]}}/../resources/blue.png?id=cached';
|
||||
iframeBody.appendChild(image3);
|
||||
}
|
||||
function finish_crossorigin_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
test_equals(entries.length, 1, 'There should be one entry in second test');
|
||||
test_true(entries[0].name.startsWith('http://{{domains[www1]}}:{{ports[http][1]}}'), 'Entry name should start with cross-origin domain');
|
||||
test_true(entries[0].name.endsWith('/resources/blue.png?id=cached'), 'Entry name should end with file name');
|
||||
test_equals(entries[0].requestStart, 0, 'requestStart should be 0 on the cross-origin request');
|
||||
done();
|
||||
}
|
||||
window.setup_iframe = () => {};
|
||||
window.addEventListener('load', onload_prep);
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that a memory cached resource appears in the buffer once.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" src="resources/inject_resource_test.html"></iframe>
|
||||
<img src="resources/blue.png?id=cached"></img>
|
||||
<img src="http://{{domains[www1]}}:{{ports[http][1]}}{{location[path]}}/../resources/blue.png?id=cached"></img>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing redirect names</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#performanceresourcetiming"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
const iframe_content =
|
||||
'<link rel="stylesheet" href="/common/redirect.py?location=/resource-timing/resources/resource_timing_test0.css"></link>' +
|
||||
'<img src="/common/redirect.py?location=/resource-timing/resources/blue.png"></img>' +
|
||||
'<iframe src="/common/redirect.py?location=/resource-timing/resources/blank_page_green.htm"></iframe>' +
|
||||
'<script src="/common/redirect.py?location=/resource-timing/resources/empty_script.js"></scr' + 'ipt>' +
|
||||
'<scr' + 'ipt>' +
|
||||
'const xhr = new XMLHttpRequest;' +
|
||||
'xhr.open("GET", "/common/redirect.py?location=/resource-timing/resources/blank_page_green.htm?id=xhr", false);' +
|
||||
'xhr.send();' +
|
||||
'</scr' + 'ipt>';
|
||||
iframe = document.getElementById('frameContext');
|
||||
iframe.contentWindow.document.write(iframe_content);
|
||||
}
|
||||
function onload_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('resource-timing');
|
||||
const pathname = window.location.pathname.substring(0, index) +
|
||||
'common/redirect.py?location=/resource-timing/resources/';
|
||||
let expected_entries = {};
|
||||
expected_entries[pathname + 'resource_timing_test0.css'] = 'link';
|
||||
expected_entries[pathname + 'blue.png'] = 'img';
|
||||
expected_entries[pathname + 'blank_page_green.htm'] = 'iframe';
|
||||
expected_entries[pathname + 'empty_script.js'] = 'script';
|
||||
expected_entries[pathname + 'blank_page_green.htm?id=xhr'] = 'xmlhttprequest';
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that redirects do not alter the URL.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing reparenting elements</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
iframe = document.getElementById('frameContext');
|
||||
const d = iframe.contentWindow.document;
|
||||
const iframeBody = d.createElement('body');
|
||||
|
||||
const move_to_parent = d.createElement('img');
|
||||
move_to_parent.src = 'blue.png?id=move_to_parent';
|
||||
iframeBody.appendChild(move_to_parent);
|
||||
iframeBody.removeChild(move_to_parent);
|
||||
|
||||
const parentBody = document.getElementsByTagName('body')[0];
|
||||
parentBody.appendChild(move_to_parent);
|
||||
|
||||
const move_to_child = document.createElement('img');
|
||||
move_to_child.src = 'blue.png?id=move_to_child';
|
||||
parentBody.appendChild(move_to_child);
|
||||
parentBody.removeChild(move_to_child);
|
||||
iframeBody.appendChild(move_to_child);
|
||||
}
|
||||
function onload_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index);
|
||||
let expected_entries = {};
|
||||
expected_entries[pathname + '/resources/blue.png?id=move_to_child'] = 'img';
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that reparenting an element doesn't change the initiator document.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,72 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Resource Timing script initiator types</title>
|
||||
<link rel="author" title="Google" href="http://www.google.com/" />
|
||||
<link rel="help" href="http://www.w3.org/TR/resource-timing/#dom-performanceresourcetiming-initiatortype"/>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/webperftestharness.js"></script>
|
||||
<script src="resources/webperftestharnessextension.js"></script>
|
||||
<script>
|
||||
setup({explicit_done: true});
|
||||
let iframe;
|
||||
function setup_iframe() {
|
||||
const iframe_content =
|
||||
'<script src="empty_script.js?id=1"></scr' + 'ipt>' +
|
||||
'<script src="empty_script.js?id=2" async></scr' + 'ipt>' +
|
||||
'<script src="empty_script.js?id=3" async=false></scr' + 'ipt>' +
|
||||
'<script src="empty_script.js?id=4" defer></scr' + 'ipt>' +
|
||||
'<script>' +
|
||||
'document.write("<script src=\\"empty_script.js?id=5\\"></scr" + "ipt>");' +
|
||||
'const s1 = document.createElement("script");' +
|
||||
's1.src = "empty_script.js?id=6";' +
|
||||
'document.getElementsByTagName("head")[0].appendChild(s1);' +
|
||||
'const s2 = document.createElement("script");' +
|
||||
's2.src = "empty_script.js?id=7";' +
|
||||
's2.async = true;' +
|
||||
'document.getElementsByTagName("head")[0].appendChild(s2);' +
|
||||
'const s3 = document.createElement("script");' +
|
||||
's3.src = "empty_script.js?id=8";' +
|
||||
's3.async = false;' +
|
||||
'document.getElementsByTagName("head")[0].appendChild(s3);' +
|
||||
'const s4 = document.createElement("script");' +
|
||||
's4.src = "empty_script.js?id=9";' +
|
||||
's4.defer = true;' +
|
||||
'document.getElementsByTagName("head")[0].appendChild(s4);' +
|
||||
'</scr' + 'ipt>';
|
||||
iframe = document.getElementById('frameContext');
|
||||
iframe.contentWindow.document.write(iframe_content);
|
||||
}
|
||||
function onload_test() {
|
||||
const context = new PerformanceContext(iframe.contentWindow.performance);
|
||||
const entries = context.getEntriesByType('resource');
|
||||
|
||||
const index = window.location.pathname.lastIndexOf('/');
|
||||
const pathname = window.location.pathname.substring(0, index) +
|
||||
'/resources/empty_script.js?id=';
|
||||
let expected_entries = {};
|
||||
expected_entries[pathname + '1'] = 'script';
|
||||
expected_entries[pathname + '2'] = 'script';
|
||||
expected_entries[pathname + '3'] = 'script';
|
||||
expected_entries[pathname + '4'] = 'script';
|
||||
expected_entries[pathname + '5'] = 'script';
|
||||
expected_entries[pathname + '6'] = 'script';
|
||||
expected_entries[pathname + '7'] = 'script';
|
||||
expected_entries[pathname + '8'] = 'script';
|
||||
expected_entries[pathname + '9'] = 'script';
|
||||
|
||||
test_resource_entries(entries, expected_entries);
|
||||
done();
|
||||
}
|
||||
window.setup_iframe = setup_iframe;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Description</h1>
|
||||
<p>This test validates that all of the different types of script loads are reported with the correct initiator.</p>
|
||||
<div id="log"></div>
|
||||
<iframe id="frameContext" onload="onload_test();" src="resources/inject_resource_test.html"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
||||
<title>All Resource Types Test Page</title>
|
||||
</head>
|
||||
<body background='blue.png?id=body'>
|
||||
<script>
|
||||
if (window.parent.hasOwnProperty('on_test_body_created'))
|
||||
window.parent.on_test_body_created();
|
||||
</script>
|
||||
<link rel="stylesheet" href="nested.css"></link>
|
||||
<img src="resource_timing_test0.png"></img>
|
||||
<iframe src="blank_page_green.htm" width="100px" height="100px"></iframe>
|
||||
<script src="empty_script.js"></script>
|
||||
<script>
|
||||
var async_xhr = new XMLHttpRequest;
|
||||
async_xhr.open('GET', 'blue.png?id=async_xhr', true);
|
||||
async_xhr.onreadystatechange = function() {
|
||||
if (async_xhr.readyState == 4 && async_xhr.status == 200 && parent.hasOwnProperty('on_async_xhr_done'))
|
||||
parent.on_async_xhr_done();
|
||||
}
|
||||
async_xhr.send();
|
||||
</script>
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: remoteFontAhem;
|
||||
src: url('/fonts/Ahem.ttf');
|
||||
}
|
||||
iframe {
|
||||
background: url('blue.png?id=1');
|
||||
}
|
||||
ul {
|
||||
font-family: remoteFontAhem;
|
||||
list-style-image: url('blue.png?id=2');
|
||||
}
|
||||
</style>
|
||||
<ul>
|
||||
<li>Test</li>
|
||||
</ul>
|
||||
<ol>
|
||||
<li>Test</li>
|
||||
</ol>
|
||||
<embed src="resource_timing_test0.css?id=embed" type="text/css"></embed>
|
||||
<input type="image" src="blue.png?id=input"></input>
|
||||
<object type="image/png" data="blue.png?id=object"></object>
|
||||
<video poster="blue.png?id=poster"></video>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
|
||||
<title>Green Test Page</title>
|
||||
</head>
|
||||
<body style="background-color:#00FF00;">
|
||||
<h1>Placeholder</h1>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<frameset>
|
||||
<frame src="blank_page_green.htm">
|
||||
</frameset>
|
||||
</head>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
@import "resource_timing_test0.css?id=n1";
|
||||
|
||||
@font-face {
|
||||
font-family: remoteFont;
|
||||
src: url('/fonts/Ahem.ttf?id=n1');
|
||||
}
|
||||
ol {
|
||||
font-family: remoteFont;
|
||||
list-style-image: url('blue.png?id=n1');
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
let numComplete = 0;
|
||||
|
||||
function checkDone() {
|
||||
++numComplete;
|
||||
if (numComplete == 2) {
|
||||
postMessage('');
|
||||
}
|
||||
}
|
||||
|
||||
function makeRequest(request) {
|
||||
var xhr = new XMLHttpRequest;
|
||||
xhr.open('get', request, true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState == 4) {
|
||||
checkDone();
|
||||
}
|
||||
}
|
||||
xhr.send();
|
||||
}
|
||||
makeRequest('blue.png');
|
||||
makeRequest('resource_timing_test0.png');
|
|
@ -183,7 +183,9 @@ function resource_load(expected)
|
|||
});
|
||||
|
||||
t["timing_attrs"].step(function test() {
|
||||
var actual = window.performance.getEntriesByName(expected.name)[0];
|
||||
const entries = window.performance.getEntriesByName(expected.name);
|
||||
assert_equals(entries.length, 1, 'There should be a single matching entry');
|
||||
const actual = entries[0];
|
||||
|
||||
// Debugging bug 1263428
|
||||
// Feel free to remove/overwrite this piece of code
|
||||
|
@ -191,18 +193,18 @@ function resource_load(expected)
|
|||
assert_true(false, "actual: "+JSON.stringify(actual));
|
||||
}
|
||||
|
||||
assert_equals(actual.redirectStart, 0, "redirectStart time");
|
||||
assert_equals(actual.redirectEnd, 0, "redirectEnd time");
|
||||
assert_equals(actual.redirectStart, 0, 'redirectStart should be 0');
|
||||
assert_equals(actual.redirectEnd, 0, 'redirectEnd should be 0');
|
||||
assert_true(actual.secureConnectionStart == undefined ||
|
||||
actual.secureConnectionStart == 0, "secureConnectionStart time");
|
||||
assert_equals(actual.fetchStart, actual.startTime, "fetchStart is equal to startTime");
|
||||
assert_greater_than_equal(actual.domainLookupStart, actual.fetchStart, "domainLookupStart after fetchStart");
|
||||
assert_greater_than_equal(actual.domainLookupEnd, actual.domainLookupStart, "domainLookupEnd after domainLookupStart");
|
||||
assert_greater_than_equal(actual.connectStart, actual.domainLookupEnd, "connectStart after domainLookupEnd");
|
||||
assert_greater_than_equal(actual.connectEnd, actual.connectStart, "connectEnd after connectStart");
|
||||
assert_greater_than_equal(actual.requestStart, actual.connectEnd, "requestStart after connectEnd");
|
||||
assert_greater_than_equal(actual.responseStart, actual.requestStart, "responseStart after requestStart");
|
||||
assert_greater_than_equal(actual.responseEnd, actual.responseStart, "responseEnd after responseStart");
|
||||
actual.secureConnectionStart == 0, 'secureConnectionStart should be 0 or undefined');
|
||||
assert_equals(actual.fetchStart, actual.startTime, 'fetchStart is equal to startTime');
|
||||
assert_greater_than_equal(actual.domainLookupStart, actual.fetchStart, 'domainLookupStart after fetchStart');
|
||||
assert_greater_than_equal(actual.domainLookupEnd, actual.domainLookupStart, 'domainLookupEnd after domainLookupStart');
|
||||
assert_greater_than_equal(actual.connectStart, actual.domainLookupEnd, 'connectStart after domainLookupEnd');
|
||||
assert_greater_than_equal(actual.connectEnd, actual.connectStart, 'connectEnd after connectStart');
|
||||
assert_greater_than_equal(actual.requestStart, actual.connectEnd, 'requestStart after connectEnd');
|
||||
assert_greater_than_equal(actual.responseStart, actual.requestStart, 'responseStart after requestStart');
|
||||
assert_greater_than_equal(actual.responseEnd, actual.responseStart, 'responseEnd after responseStart');
|
||||
this.done();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue