Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php

Issue 2005783005: Re-enable storage for Suborigins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php
index a373506f177da67e3eb3bf1b646f2d7462838c3b..9fe36827f9bc331b40a13753db4f819957d3a00f 100644
--- a/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php
+++ b/third_party/WebKit/LayoutTests/http/tests/security/suborigins/suborigin-storage-dom-access.php
@@ -4,25 +4,65 @@ header("Suborigin: foobar");
<!DOCTYPE html>
<html>
<head>
-<title>Verifies that localStorage and sessionStorage are not accessible from within a suborigin</title>
+<title>Verifies that localStorage and sessionStorage are accessible from within a suborigin and are different from the physical origin's localStorage and sessionStorage</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
-var expectedError = new DOMException("TEST EXCEPTION", "SecurityError");
-var localStorageTest = async_test("localStorage must not be accessible from a suborigin");
-var sessionStorageTest = async_test("sessionStorage must not be accessible from a suborigin");
+var iframeWindow;
+localStorage.clear();
+sessionStorage.clear();
-function mustThrowSecurityException() {
- assert_throws(expectedError, function() {
- window.localStorage;
- });
- this.done();
+function storageAccessibilityTest(storage) {
+ return function(test) {
+ assert_equals(storage.getItem("FOO"), null);
+ storage.setItem("FOO", "BAR");
+ assert_equals(storage.getItem("FOO"), "BAR");
+ storage.removeItem("FOO");
+ assert_equals(storage.getItem("FOO"), null);
+ test.done();
+ }
}
-localStorageTest.step(mustThrowSecurityException);
-sessionStorageTest.step(mustThrowSecurityException);
+async_test(storageAccessibilityTest(localStorage),
+ "localStorage is accessible from a Suborigin");
+async_test(storageAccessibilityTest(sessionStorage),
+ "sessionStorage is accessible from a Suborigin");
+
+var localStorageXOriginTest = async_test(
+ "localStorage is set in a Suborigin is not accessible in the physical origin, or vice versa");
+var sessionStorageXOriginTest = async_test(
+ "sessionStorage is set in a Suborigin is not accessible in the physical origin, or vice versa");
+
+window.onmessage = function(event) {
+ // When the iframe states that it is ready to accept messages, start the
+ // localStorage and sessionStorage tests by setting up the appropriate
+ // store and messaging the iframe that the store is ready.
+ //
+ // When the iframe responds again, this time check that the values in our
+ // storage have not changed and that the iframe's storage values have also
+ // not changed.
+ if (event.data == 'ready') {
+ iframeWindow = document.getElementById('iframe').contentWindow;
+ localStorage.setItem('LOCAL_FOO1', 'BAR');
+ sessionStorage.setItem('SESSION_FOO1', 'BAR');
+ iframeWindow.postMessage({ 'type': 'localStorage' }, '*');
+ iframeWindow.postMessage({ 'type': 'sessionStorage' }, '*');
+ } else if (event.data.type == 'localStorage') {
+ assert_equals(event.data.value, null);
+ assert_equals(localStorage.getItem("LOCAL_FOO2"), null);
+ localStorageXOriginTest.done();
+ } else if (event.data.type == 'sessionStorage') {
+ assert_equals(event.data.value, null);
+ assert_equals(localStorage.getItem("SESSION_FOO2"), null);
+ sessionStorageXOriginTest.done();
+ } else {
+ assert_unreached('Unknown data received');
+ }
+};
+
</script>
+<iframe id="iframe" src="resources/access-storage.php"></iframe>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698