From e052f8a735425cc786a2c07fc94e3c18f1a6a189 Mon Sep 17 00:00:00 2001 From: Richard Stotz Date: Fri, 23 Apr 2021 10:17:59 +0000 Subject: [PATCH] Bug 1705236 [wpt PR 28492] - NativeIO: Enable 3rd party cookie block on capacity allocation, a=testonly Automatic update from web-platform-tests NativeIO: Enable 3rd party cookie block on capacity allocation This change adds a check to all filesystem-like methods (requestCapacity, releaseCapacity, getRemainingCapacity) that makes them throw when 3rd party cookies are blocked and the call came from a 3rd party context (e.g. from within an iframe). This CL also adds a test that NativeIO does not crash the renderer when accessed from destroyed execution contexts. Bug: 1137788 Change-Id: Ifb0fcdae0dad0fc2eae5e061a6800520dffcef14 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2821323 Reviewed-by: Marijn Kruisselbrink Reviewed-by: Christian Dullweber Commit-Queue: Richard Stotz Cr-Commit-Position: refs/heads/master@{#872768} -- wpt-commits: 1441bb6cc4af8eb81a614873456a7a9c8d885854 wpt-pr: 28492 --- .../native-io/detached_iframe.https.window.js | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 testing/web-platform/tests/native-io/detached_iframe.https.window.js diff --git a/testing/web-platform/tests/native-io/detached_iframe.https.window.js b/testing/web-platform/tests/native-io/detached_iframe.https.window.js new file mode 100644 index 000000000000..e36327a72860 --- /dev/null +++ b/testing/web-platform/tests/native-io/detached_iframe.https.window.js @@ -0,0 +1,37 @@ +// META: title=NativeIO API: Do not crash in detached iframes. +// META: global=window + +function add_iframe(test, src, sandbox) { + const iframe = document.createElement("iframe"); + document.body.appendChild(iframe); + return iframe; +} + +promise_test(async testCase => { + const iframe = add_iframe(); + const iframe_sfa = iframe.contentWindow.storageFoundation; + const frameDOMException = iframe.contentWindow.DOMException; + iframe.remove(); + + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.getAll()); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.open('test_file')); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.rename('test_file', 'test')); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.delete('test')); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.requestCapacity(10)); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.releaseCapacity(10)); + await promise_rejects_dom( + testCase, 'InvalidStateError', frameDOMException, + iframe_sfa.getRemainingCapacity()); +}, 'storageFoundation must return an error when called from detached iframes.');