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

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/storage/opaque-origin.https.html

Issue 2711183003: Import wpt@a7e9c2abcf65b78fcf1c246fec6681c74e1bc352 (Closed)
Patch Set: Update test expectations and baselines. Created 3 years, 10 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/external/wpt/storage/opaque-origin.https.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/storage/opaque-origin.https.html b/third_party/WebKit/LayoutTests/external/wpt/storage/opaque-origin.https.html
new file mode 100644
index 0000000000000000000000000000000000000000..563f2fea3c51627d919451cde1664703e4e87fe4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/storage/opaque-origin.https.html
@@ -0,0 +1,79 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>StorageManager API and opaque origins</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+
+function load_iframe(src, sandbox) {
+ return new Promise(resolve => {
+ const iframe = document.createElement('iframe');
+ iframe.onload = () => { resolve(iframe); };
+ if (sandbox)
+ iframe.sandbox = sandbox;
+ iframe.srcdoc = src;
+ iframe.style.display = 'none';
+ document.documentElement.appendChild(iframe);
+ });
+}
+
+function wait_for_message(iframe) {
+ return new Promise(resolve => {
+ self.addEventListener('message', function listener(e) {
+ if (e.source === iframe.contentWindow) {
+ resolve(e.data);
+ self.removeEventListener('message', listener);
+ }
+ });
+ });
+}
+
+function make_script(snippet) {
+ return '<script>' +
+ ' window.onmessage = () => {' +
+ ' try {' +
+ ' (' + snippet + ')' +
+ ' .then(' +
+ ' result => {' +
+ ' window.parent.postMessage({result: "no rejection"}, "*");' +
+ ' }, ' +
+ ' error => {' +
+ ' window.parent.postMessage({result: error.name}, "*");' +
+ ' });' +
+ ' } catch (ex) {' +
+ // Report if not implemented/exposed, rather than time out.
+ ' window.parent.postMessage({result: ex.message}, "*");' +
+ ' }' +
+ ' };' +
+ '<\/script>';
+}
+
+['navigator.storage.persist()',
+ 'navigator.storage.persisted()',
+ 'navigator.storage.estimate()'
+].forEach(snippet => {
+ promise_test(t => {
+ return load_iframe(make_script(snippet))
+ .then(iframe => {
+ iframe.contentWindow.postMessage({}, '*');
+ return wait_for_message(iframe);
+ })
+ .then(message => {
+ assert_equals(message.result, 'no rejection',
+ `${snippet} should not reject`);
+ });
+ }, `${snippet} in non-sandboxed iframe should not reject`);
+
+ promise_test(t => {
+ return load_iframe(make_script(snippet), 'allow-scripts')
+ .then(iframe => {
+ iframe.contentWindow.postMessage({}, '*');
+ return wait_for_message(iframe);
+ })
+ .then(message => {
+ assert_equals(message.result, 'TypeError',
+ `${snippet} should reject with TypeError`);
+ });
+ }, `${snippet} in sandboxed iframe should reject with TypeError`);
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698