fune/testing/web-platform/tests/FileAPI/url/url-reload.window.js
Marijn Kruisselbrink 3a5b955342 Bug 1456344 [wpt PR 10295] - [Mojo Blob URLs] Handle more navigation cases., a=testonly
Automatic update from web-platform-tests[Mojo Blob URLs] Handle more navigation cases.

This changes two more IPCs to resolve blob URLs in blink before
sending the request to the browser, hopefully covering all cases.

Still only works with the network service enabled (and that's
probably not going to change), but at least fixes ordering issues
the network service had between resolving and revoking blob URLs.

Design doc: https://docs.google.com/document/d/1DqVcTWE9Qb_3KpIRH2bFV-6hWEr8S92c4ppY67YL1KI/edit#heading=h.n4fzuc6mgziv

Bug: 800901
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: Iad88fc87264b248d15b03bdad2c24d2c5a46d9df
Reviewed-on: https://chromium-review.googlesource.com/899508
Reviewed-by: Camille Lamy <clamy@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561670}

--

wpt-commits: 68b2bc73d15159bd98c63807038ed7e6ba011d2f
wpt-pr: 10295
2018-06-10 09:29:15 +01:00

36 lines
1.2 KiB
JavaScript

function blob_url_reload_test(t, revoke_before_reload) {
const run_result = 'test_frame_OK';
const blob_contents = '<!doctype html>\n<meta charset="utf-8">\n' +
'<script>window.test_result = "' + run_result + '";</script>';
const blob = new Blob([blob_contents], {type: 'text/html'});
const url = URL.createObjectURL(blob);
const frame = document.createElement('iframe');
frame.setAttribute('src', url);
frame.setAttribute('style', 'display:none;');
document.body.appendChild(frame);
frame.onload = t.step_func(() => {
if (revoke_before_reload)
URL.revokeObjectURL(url);
assert_equals(frame.contentWindow.test_result, run_result);
frame.contentWindow.test_result = null;
frame.onload = t.step_func_done(() => {
assert_equals(frame.contentWindow.test_result, run_result);
});
// Slight delay before reloading to ensure revoke actually has had a chance
// to be processed.
t.step_timeout(() => {
frame.contentWindow.location.reload();
}, 250);
});
}
async_test(t => {
blob_url_reload_test(t, false);
}, 'Reloading a blob URL succeeds.');
async_test(t => {
blob_url_reload_test(t, true);
}, 'Reloading a blob URL succeeds even if the URL was revoked.');