Bug 1456344 [wpt PR 10295] - [Mojo Blob URLs] Handle more navigation cases., a=testonly
authorMarijn Kruisselbrink <mek@chromium.org>
Wed, 06 Jun 2018 16:19:14 +0000
changeset 422194 ea36fd45cbf269a7f6f1a83b343e1704b7bea302
parent 422193 fdc37f5fdf831bc4065ccd937cc2cf395b7c911d
child 422195 28a4916ff9d5655c7b816da2a9d4c7746f664304
push id34122
push userebalazs@mozilla.com
push dateMon, 11 Jun 2018 09:37:00 +0000
treeherdermozilla-central@9941eb8c3b29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1456344, 10295, 800901, 899508, 561670
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/FileAPI/url/url-in-tags-revoke.window.js
testing/web-platform/tests/FileAPI/url/url-reload.window.js
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -306136,16 +306136,22 @@
     ]
    ],
    "FileAPI/url/url-lifetime.html": [
     [
      "/FileAPI/url/url-lifetime.html",
      {}
     ]
    ],
+   "FileAPI/url/url-reload.window.js": [
+    [
+     "/FileAPI/url/url-reload.window.html",
+     {}
+    ]
+   ],
    "FileAPI/url/url-with-fetch.any.js": [
     [
      "/FileAPI/url/url-with-fetch.any.html",
      {}
     ],
     [
      "/FileAPI/url/url-with-fetch.any.worker.html",
      {}
@@ -402924,27 +402930,31 @@
    "59efa25d03f8765d4848d4b4e6310c7740763342",
    "testharness"
   ],
   "FileAPI/url/url-format.any.js": [
    "b087f507b342f88240efcee2569da96fee469a5b",
    "testharness"
   ],
   "FileAPI/url/url-in-tags-revoke.window.js": [
-   "4d314e8f231158a8a216ecefd6a3ffa20cf31680",
+   "058021aab41c4ace8b6246ac33891f6eddbdd8b3",
    "testharness"
   ],
   "FileAPI/url/url-in-tags.window.js": [
    "cdbb802a1a1b85cba8e5119235d11590d7e2581f",
    "testharness"
   ],
   "FileAPI/url/url-lifetime.html": [
    "3cbda186b6669c24770013d899e96a71ea49a08d",
    "testharness"
   ],
+  "FileAPI/url/url-reload.window.js": [
+   "81c540bce445ccbb97ce5436c337112917b866f6",
+   "testharness"
+  ],
   "FileAPI/url/url-with-fetch.any.js": [
    "b9f82d1ea5d2ef12e87946df37c373805a336fa6",
    "testharness"
   ],
   "FileAPI/url/url-with-xhr.any.js": [
    "883d206ae9ec439874f2a874e6f4566f037c0f42",
    "testharness"
   ],
--- a/testing/web-platform/tests/FileAPI/url/url-in-tags-revoke.window.js
+++ b/testing/web-platform/tests/FileAPI/url/url-in-tags-revoke.window.js
@@ -33,16 +33,61 @@ async_test(t => {
     URL.revokeObjectURL(url);
     frame.onload = t.step_func_done(() => {
       assert_equals(frame.contentWindow.test_result, run_result);
     });
   });
 }, 'Fetching a blob URL immediately before revoking it works in an iframe navigation.');
 
 async_test(t => {
+  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 win = window.open(url);
+  URL.revokeObjectURL(url);
+  add_completion_callback(() => { win.close(); });
+
+  win.onload = t.step_func_done(() => {
+    assert_equals(win.test_result, run_result);
+  });
+}, 'Opening a blob URL in a new window immediately before revoking it works.');
+
+function receive_message_on_channel(t, channel_name) {
+  const channel = new BroadcastChannel(channel_name);
+  return new Promise(resolve => {
+    channel.addEventListener('message', t.step_func(e => {
+      resolve(e.data);
+    }));
+  });
+}
+
+function window_contents_for_channel(channel_name) {
+  return '<!doctype html>\n' +
+    '<script>\n' +
+    'new BroadcastChannel("' + channel_name + '").postMessage("foobar");\n' +
+    'self.close();\n' +
+    '</script>';
+}
+
+async_test(t => {
+  const channel_name = 'noopener-window-test';
+  const blob = new Blob([window_contents_for_channel(channel_name)], {type: 'text/html'});
+  receive_message_on_channel(t, channel_name).then(t.step_func_done(t => {
+    assert_equals(t, 'foobar');
+  }));
+  const url = URL.createObjectURL(blob);
+  const win = window.open();
+  win.opener = null;
+  win.location = url;
+  URL.revokeObjectURL(url);
+}, 'Opening a blob URL in a noopener about:blank window immediately before revoking it works.');
+
+async_test(t => {
   const run_result = 'test_script_OK';
   const blob_contents = 'window.script_test_result = "' + run_result + '";';
   const blob = new Blob([blob_contents]);
   const url = URL.createObjectURL(blob);
 
   const e = document.createElement('script');
   e.setAttribute('src', url);
   e.onload = t.step_func_done(() => {
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/FileAPI/url/url-reload.window.js
@@ -0,0 +1,36 @@
+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.');