Bug 1426979 P2 Make about-blank-replacement.https.html check simple about:blank and about:srcdoc cases. r=asuth

This commit is contained in:
Ben Kelly 2018-01-10 13:59:30 -05:00
Родитель 7310720f04
Коммит bb09ab9729
5 изменённых файлов: 141 добавлений и 18 удалений

Просмотреть файл

@ -285061,6 +285061,16 @@
{} {}
] ]
], ],
"service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html": [
[
{}
]
],
"service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html": [
[
{}
]
],
"service-workers/service-worker/resources/about-blank-replacement-frame.py": [ "service-workers/service-worker/resources/about-blank-replacement-frame.py": [
[ [
{} {}
@ -285076,6 +285086,11 @@
{} {}
] ]
], ],
"service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html": [
[
{}
]
],
"service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [ "service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [
[ [
{} {}
@ -529185,7 +529200,7 @@
"testharness" "testharness"
], ],
"custom-elements/Document-createElement.html": [ "custom-elements/Document-createElement.html": [
"fb10e851deb193aed700c8ab6790c216766cc362", "14960ee9498f6ff23c1c94d3351a8ef383e60067",
"testharness" "testharness"
], ],
"custom-elements/HTMLElement-constructor.html": [ "custom-elements/HTMLElement-constructor.html": [
@ -529245,7 +529260,7 @@
"testharness" "testharness"
], ],
"custom-elements/parser/parser-constructs-custom-elements-with-is.html": [ "custom-elements/parser/parser-constructs-custom-elements-with-is.html": [
"7a7df7aab092906b5a753c0d122b971aff01517a", "17145d44113ea88688060c6cfd10d162cd97e28b",
"testharness" "testharness"
], ],
"custom-elements/parser/parser-constructs-custom-elements.html": [ "custom-elements/parser/parser-constructs-custom-elements.html": [
@ -536697,7 +536712,7 @@
"testharness" "testharness"
], ],
"html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html": [ "html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-anchor-name.html": [
"8de758988400b4b1acad6bb4c94069b4d0167c20", "9bc91bc9bb368e8bf42810ed8aed936a6c9d581a",
"testharness" "testharness"
], ],
"html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html": [ "html/browsers/browsing-the-web/scroll-to-fragid/scroll-to-id-top.html": [
@ -574233,7 +574248,7 @@
"testharness" "testharness"
], ],
"service-workers/service-worker/about-blank-replacement.https.html": [ "service-workers/service-worker/about-blank-replacement.https.html": [
"345259908d040e4f5d810ae7089dab8a8c909b0a", "0eee8e63450cff5a2f67b6d71d565b99baddbb69",
"testharness" "testharness"
], ],
"service-workers/service-worker/activate-event-after-install-state-change.https.html": [ "service-workers/service-worker/activate-event-after-install-state-change.https.html": [
@ -574485,7 +574500,7 @@
"testharness" "testharness"
], ],
"service-workers/service-worker/fetch-response-taint.https.html": [ "service-workers/service-worker/fetch-response-taint.https.html": [
"217383b4dddcc6f984c4cc7cd5f99e1f9b86cdd1", "154a52255d0aae9a99879389afba6214b803b08d",
"testharness" "testharness"
], ],
"service-workers/service-worker/fetch-response-xhr.https.html": [ "service-workers/service-worker/fetch-response-xhr.https.html": [
@ -574836,6 +574851,14 @@
"567d0a7de3ef54adaa8339bb04632a2ecfcc57a5", "567d0a7de3ef54adaa8339bb04632a2ecfcc57a5",
"support" "support"
], ],
"service-workers/service-worker/resources/about-blank-replacement-blank-dynamic-nested-frame.html": [
"bfd2c8e7acb010cd7b5a0076a9138d8584e5efab",
"support"
],
"service-workers/service-worker/resources/about-blank-replacement-blank-nested-frame.html": [
"79cb319dbdbae7efb9abf3405c2bc76ad9f0bc0f",
"support"
],
"service-workers/service-worker/resources/about-blank-replacement-frame.py": [ "service-workers/service-worker/resources/about-blank-replacement-frame.py": [
"2f22a4c92cfb7c7e8cfbe6f168872c2f5875867d", "2f22a4c92cfb7c7e8cfbe6f168872c2f5875867d",
"support" "support"
@ -574848,6 +574871,10 @@
"498a08b652ec0d867e8d2e173be954f69354a208", "498a08b652ec0d867e8d2e173be954f69354a208",
"support" "support"
], ],
"service-workers/service-worker/resources/about-blank-replacement-srcdoc-nested-frame.html": [
"6a0d88da977057eb365dfc8bfb531558d7a1bd4a",
"support"
],
"service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [ "service-workers/service-worker/resources/about-blank-replacement-uncontrolled-nested-frame.html": [
"ab2ce3693bbc40943b7390c8d76f3601f52410ca", "ab2ce3693bbc40943b7390c8d76f3601f52410ca",
"support" "support"
@ -575829,7 +575856,7 @@
"testharness" "testharness"
], ],
"service-workers/service-worker/worker-interception.https.html": [ "service-workers/service-worker/worker-interception.https.html": [
"2c5e8cb2b7be6d394aaa1400158d3f14895909f3", "41f7e5e8da2c305370fddad83518cd0fa57547eb",
"testharness" "testharness"
], ],
"service-workers/specgen.json": [ "service-workers/specgen.json": [

Просмотреть файл

@ -58,7 +58,7 @@ function getClientIdByURL(worker, url) {
}); });
} }
async function doAsyncTest(t, scope, extraSearchParams) { async function doAsyncTest(t, scope) {
let reg = await service_worker_unregister_and_register(t, worker, scope); let reg = await service_worker_unregister_and_register(t, worker, scope);
await wait_for_state(t, reg.installing, 'activated'); await wait_for_state(t, reg.installing, 'activated');
@ -70,20 +70,30 @@ async function doAsyncTest(t, scope, extraSearchParams) {
let initialResult = frame.contentWindow.nested().document.body.textContent; let initialResult = frame.contentWindow.nested().document.body.textContent;
assert_false(initialResult.startsWith('failure:'), `result: ${initialResult}`); assert_false(initialResult.startsWith('failure:'), `result: ${initialResult}`);
assert_equals(frame.contentWindow.navigator.serviceWorker.controller.scriptURL,
frame.contentWindow.nested().navigator.serviceWorker.controller.scriptURL,
'nested about:blank should have same controlling service worker');
// Next, ask the service worker to find the final client ID for the fully // Next, ask the service worker to find the final client ID for the fully
// loaded nested frame. // loaded nested frame.
let nestedURL = new URL(scope, window.location); let nestedURL = new URL(frame.contentWindow.nested().location);
nestedURL.searchParams.set('nested', true);
extraSearchParams = extraSearchParams || {};
for (let p in extraSearchParams) {
nestedURL.searchParams.set(p, extraSearchParams[p]);
}
let finalResult = await getClientIdByURL(reg.active, nestedURL); let finalResult = await getClientIdByURL(reg.active, nestedURL);
assert_false(finalResult.startsWith('failure:'), `result: ${finalResult}`); assert_false(finalResult.startsWith('failure:'), `result: ${finalResult}`);
// The initial about:blank client and the final loaded client should have // If the nested frame doesn't have a URL to load, then there is no fetch
// the same ID value. // event and the body should be empty. We can't verify the final client ID
assert_equals(initialResult, finalResult, 'client ID values should match'); // against anything.
if (nestedURL.href === 'about:blank' ||
nestedURL.href === 'about:srcdoc') {
assert_equals('', initialResult, 'about:blank text content should be blank');
}
// If the nested URL is not about:blank, though, then the fetch event handler
// should have populated the body with the client id of the initial about:blank.
// Verify the final client id matches.
else {
assert_equals(initialResult, finalResult, 'client ID values should match');
}
frame.remove(); frame.remove();
await service_worker_unregister_and_done(t, scope); await service_worker_unregister_and_done(t, scope);
@ -101,8 +111,7 @@ promise_test(async function(t) {
// worker can ping the client to verify its existence. This ping-pong // worker can ping the client to verify its existence. This ping-pong
// check is performed during the initial load and when verifying the // check is performed during the initial load and when verifying the
// final loaded client. // final loaded client.
await doAsyncTest(t, 'resources/about-blank-replacement-ping-frame.py', await doAsyncTest(t, 'resources/about-blank-replacement-ping-frame.py');
{ 'ping': true });
}, 'Initial about:blank modified by parent is controlled, exposed to ' + }, 'Initial about:blank modified by parent is controlled, exposed to ' +
'clients.matchAll(), and matches final Client.'); 'clients.matchAll(), and matches final Client.');
@ -142,5 +151,27 @@ promise_test(async function(t) {
}, 'Initial about:blank is controlled, exposed to clients.matchAll(), and ' + }, 'Initial about:blank is controlled, exposed to clients.matchAll(), and ' +
'final Client is not controlled by a service worker.'); 'final Client is not controlled by a service worker.');
promise_test(async function(t) {
// Execute a test where the nested frame is an iframe without a src
// attribute. This simple nested about:blank should still inherit the
// controller and be visible to clients.matchAll().
await doAsyncTest(t, 'resources/about-blank-replacement-blank-nested-frame.html');
}, 'Simple about:blank is controlled and is exposed to clients.matchAll().');
promise_test(async function(t) {
// Execute a test where the nested frame is an iframe using a non-empty
// srcdoc containing only a tag pair so its textContent is still empty.
// This nested iframe should still inherit the controller and be visible
// to clients.matchAll().
await doAsyncTest(t, 'resources/about-blank-replacement-srcdoc-nested-frame.html');
}, 'Nested about:srcdoc is controlled and is exposed to clients.matchAll().');
promise_test(async function(t) {
// Execute a test where the nested frame is dynamically added without a src
// attribute. This simple nested about:blank should still inherit the
// controller and be visible to clients.matchAll().
await doAsyncTest(t, 'resources/about-blank-replacement-blank-dynamic-nested-frame.html');
}, 'Dynamic about:blank is controlled and is exposed to clients.matchAll().');
</script> </script>
</body> </body>

Просмотреть файл

@ -0,0 +1,21 @@
<!doctype html>
<html>
<body>
<script>
function nestedLoaded() {
parent.postMessage({ type: 'NESTED_LOADED' }, '*');
}
// dynamically add an about:blank iframe
var f = document.createElement('iframe');
f.onload = nestedLoaded;
document.body.appendChild(f);
// Helper routine to make it slightly easier for our parent to find
// the nested frame.
function nested() {
return f.contentWindow;
}
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,22 @@
<!doctype html>
<html>
<body>
<script>
function nestedLoaded() {
parent.postMessage({ type: 'NESTED_LOADED' }, '*');
}
</script>
<iframe id="nested" onload="nestedLoaded()"></iframe>
<script>
// Helper routine to make it slightly easier for our parent to find
// the nested frame.
function nested() {
return document.getElementById('nested').contentWindow;
}
// NOTE: Make sure not to touch the iframe directly here. We want to
// test the case where the initial about:blank document is not
// directly accessed before load.
</script>
</body>
</html>

Просмотреть файл

@ -0,0 +1,22 @@
<!doctype html>
<html>
<body>
<script>
function nestedLoaded() {
parent.postMessage({ type: 'NESTED_LOADED' }, '*');
}
</script>
<iframe id="nested" srcdoc="<div></div>" onload="nestedLoaded()"></iframe>
<script>
// Helper routine to make it slightly easier for our parent to find
// the nested frame.
function nested() {
return document.getElementById('nested').contentWindow;
}
// NOTE: Make sure not to touch the iframe directly here. We want to
// test the case where the initial about:blank document is not
// directly accessed before load.
</script>
</body>
</html>