Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lint.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ SET TIMEOUT: html/webappapis/dynamic-markup-insertion/opening-the-input-stream/c
SET TIMEOUT: html/webappapis/timers/*
SET TIMEOUT: portals/history/resources/portal-harness.js
SET TIMEOUT: requestidlecallback/deadline-after-expired-timer.html
SET TIMEOUT: resource-timing/tentative/initiator-url/set-timeout.html
SET TIMEOUT: resources/*
SET TIMEOUT: scheduler/tentative/current-task-signal-async-abort.any.js
SET TIMEOUT: scheduler/tentative/current-task-signal-async-priority.any.js
Expand Down
9 changes: 9 additions & 0 deletions resource-timing/resources/iframe-post-message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<script>
window.addEventListener('message', e => {
const port = e.ports?.[0];
port.postMessage("hello from iframe");
});
</script>
</html>
9 changes: 9 additions & 0 deletions resource-timing/resources/loading-resource-lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This js file actually calls fetch to load an image to
// an element.
async function load_image(label, img_element) {
const url = "/images/blue.png?"+label;
const response = await fetch(url);
blob = await response.blob();
const imgURL = URL.createObjectURL(blob);
img_element.src = imgURL;
}
29 changes: 29 additions & 0 deletions resource-timing/resources/loading-resources-in-posted-task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function load_resources() {
//Fetching the Stylesheet
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "resources/empty_style.css?no_cache";
link.id = "link_id";
document.head.appendChild(link);

// Fetching an image
var img = document.createElement("img");
img.src = "/images/blue.png?no_cache";
img.alt = "Sample Image for testing initiator Attribute";
img.id = "img_id"
document.body.appendChild(img);

// Inserting a script element
var script = document.createElement("script");
script.src = "resources/empty.js?no_cache";
script.id = "script_id"
document.body.appendChild(script);

//Inserting a html document in an iframe
var iframe = document.createElement("iframe");
iframe.src = "resources/green.html?no_cache";
iframe.id = "iframe_id";
document.body.appendChild(iframe);
}

scheduler.postTask(load_resources);
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
//Fetching the Stylesheet
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "../resources/empty_style.css";
link.href = "resources/empty_style.css?no_cache";
link.id = "link_id";
document.head.appendChild(link);

// Fetching an image
var img = document.createElement("img");
img.src = "/images/blue.png";
img.src = "/images/blue.png?no_cache";
img.alt = "Sample Image for testing initiator Attribute";
img.id = "img_id"
document.body.appendChild(img);

//Inserting a html document in an iframe
var iframe = document.createElement("iframe");
iframe.src = "../resources/green.html";
document.body.appendChild(iframe);

// Inserting a script element
var script = document.createElement("script");
script.src = "../resources/empty.js";
script.src = "resources/empty.js?no_cache";
script.id = "script_id"
document.body.appendChild(script);

//Inserting a html document in an iframe
var iframe = document.createElement("iframe");
iframe.src = "resources/green.html?no_cache";
iframe.id = "iframe_id";
document.body.appendChild(iframe);
37 changes: 37 additions & 0 deletions resource-timing/tentative/initiator-url/event-handler.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

<script src="../../resources/loading-resource-lib.js"></script>
</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for a resource fetched via event handler,
the initiator_url points to script that sets up the event handler.
</p>
</body>
<script>

var img = document.createElement("img");
document.body.appendChild(img);

const frame = document.createElement("iframe");
frame.addEventListener("load", () => {
load_image(label, img);
});
frame.src = "../resources/green.html";
document.body.appendChild(frame);


const label = "initiator_url_eventhandler";
const resource = "/images/blue.png?"+label;
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/event-handler.html";

initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from event handlers", resource + " timeout");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

</head>
<body>
<script src="../../resources/loading-resources-in-posted-task.js"></script>

<h1>Description</h1>
<p> This test loads a number of resources in the loading-resources.js via scheduler.postTask()
and verifies that `iniatitor_url`s in ResourceTiming are expected.
</p>
</body>
<script>

const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] + "/resource-timing/resources/loading-resources-in-posted-task.js";
const resources = [
"empty_style.css?no_cache",
"blue.png?no_cache",
"empty.js?no_cache",
"green.html?no_cache",
];
for (const resource of resources) {
initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl by scheduler.postTask() from external scripts", resource + " timeout");
}
</script>
31 changes: 31 additions & 0 deletions resource-timing/tentative/initiator-url/external-script.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

</head>
<body>
<script src="../../resources/loading-resources.js"></script>

<h1>Description</h1>
<p> This test loads a number of resources in the loading-resources.js and
verifies that `iniatitor_url`s in ResourceTiming entries are as expected.
</p>
</body>
<script>

const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] + "/resource-timing/resources/loading-resources.js";
const resources = [
"empty_style.css?no_cache",
"blue.png?no_cache",
"empty.js?no_cache",
"green.html?no_cache",
];
for (const resource of resources) {
initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from external scripts", resource + " timeout");
}
</script>
42 changes: 42 additions & 0 deletions resource-timing/tentative/initiator-url/iframe-post-message.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

<script src="../../resources/loading-resource-lib.js"></script>
</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for a resource fetched via message handler,
the initiator_url points to script that sends the message.
</p>
</body>
<script>

const channel = new MessageChannel();
const frame = document.createElement("iframe");
frame.addEventListener("load", () => {
frame.contentWindow.postMessage("port", "*", [channel.port2]);
});
frame.src = "../../resources/iframe-post-message.html";
document.body.appendChild(frame);

var img = document.createElement("img");
document.body.appendChild(img);

const label = "initiator_url_iframe_postmessage";
const resource = "/images/blue.png?"+label;
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/iframe-post-message.html";

channel.port1.onmessage = e => {
load_image(label, img);
}

initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from iframe postMessage()", resource + " timeout");

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
document.write('<link id="css_written" rel="stylesheet" href="../resources/empty_style.css?inline-script-doc-write">');
document.write('<script id="script_written" src="../resources/empty.js?doc-write"><\/script>');

const host_info = get_host_info();
const expectedInitiatorUrl = host_info["ORIGIN"] +
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/inline-document-write.html";

const resources = [
Expand Down
48 changes: 48 additions & 0 deletions resource-timing/tentative/initiator-url/inline-script.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for resources including an
iframe, that are loaded by an inline script, the
initiatorUrl is properly reported.
</p>
</body>
<script>

const label = "no_cache_inline_script";

var ifr = document.createElement("iframe");
document.body.appendChild(ifr);
ifr.src = "resources/blank_page_green.html?" + label;

const link = document.createElement("link");
link.rel = "stylesheet";
link.href = "../../resources/empty_style.css?" + label;
document.head.appendChild(link);

const img = document.createElement("img");
img.src = "/images/blue.png?" + label;
document.body.appendChild(img);

const resources = [
"blank_page_green.html?" + label,
"empty_style.css?" + label,
"blue.png?" + label,
];

const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/inline-script.html";

for (const resource of resources) {
initiator_url_test(resource, expectedInitiatorUrl, resource+
" initiatorUrl from inline-script", resource+" timeout");
}

</script>
31 changes: 31 additions & 0 deletions resource-timing/tentative/initiator-url/post-task.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

<script src="../../resources/loading-resource-lib.js"></script>
</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for a resource fetched with a postTask,
the initiator_url points to the async caller script,
instead of the callee script.
</p>
</body>
<script>
var img = document.createElement("img");
document.body.appendChild(img);

const label = "initiator_url_posttask";
const resource = "/images/blue.png?"+label;
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/post-task.html";
scheduler.postTask(function() {load_image(label, img)});

initiator_url_test(resource, expectedInitiatorUrl, resource+
" initiatorUrl from postTask()", resource + " timeout");

</script>
32 changes: 32 additions & 0 deletions resource-timing/tentative/initiator-url/promise.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

<script src="../../resources/loading-resource-lib.js"></script>
</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for a resource fetched with a Promise,
the initiator_url points to the async caller script,
instead of the callee script.
</p>
</body>
<script>
var img = document.createElement("img");
document.body.appendChild(img);

const label = "initiator_url_promise";
const resource = "/images/blue.png?"+label;
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/promise.html";
const instant_promise = Promise.resolve();
instant_promise.then( function() {load_image(label, img)} );

initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from fullfilled promise", resource + " timeout");

</script>
30 changes: 30 additions & 0 deletions resource-timing/tentative/initiator-url/queue-microtask.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../../resources/test-initiator.js"></script>

<script src="../../resources/loading-resource-lib.js"></script>
</head>
<body>
<h1>Description</h1>
<p> This test verifies that, for a resource fetched with a queueMicrotask,
the initiator_url points to the async caller script,
instead of the callee script.
</p>
</body>
<script>
var img = document.createElement("img");
document.body.appendChild(img);

const label = "initiator_url_queuemicrotask";
const resource = "/images/blue.png?"+label;
const hostInfo = get_host_info();
const expectedInitiatorUrl = hostInfo["ORIGIN"] +
"/resource-timing/tentative/initiator-url/queue-microtask.html";
queueMicrotask( function() {load_image(label, img)} );

initiator_url_test(resource, expectedInitiatorUrl, resource +
" initiatorUrl from queueMicrotask()", resource + " timeout");
</script>
Loading