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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/IndexedDB/idbfactory-open-opaque-origin.html

Issue 2711183003: Import wpt@a7e9c2abcf65b78fcf1c246fec6681c74e1bc352 (Closed)
Patch Set: Update test expectations and baselines. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <meta charset=utf-8>
3 <title>IDBFactory.open() and opaque origins</title>
4 <script src=/resources/testharness.js></script>
5 <script src=/resources/testharnessreport.js></script>
6 <script>
7
8 function load_iframe(src, sandbox) {
9 return new Promise(resolve => {
10 const iframe = document.createElement('iframe');
11 iframe.onload = () => { resolve(iframe); };
12 if (sandbox)
13 iframe.sandbox = sandbox;
14 iframe.srcdoc = src;
15 iframe.style.display = 'none';
16 document.documentElement.appendChild(iframe);
17 });
18 }
19
20 function wait_for_message(iframe) {
21 return new Promise(resolve => {
22 self.addEventListener('message', function listener(e) {
23 if (e.source === iframe.contentWindow) {
24 resolve(e.data);
25 self.removeEventListener('message', listener);
26 }
27 });
28 });
29 }
30
31 const script =
32 '<script>' +
33 ' window.onmessage = () => {' +
34 ' try {' +
35 ' indexedDB.deleteDatabase("opaque-origin-test");' +
36 ' const r = indexedDB.open("opaque-origin-test");' +
37 ' r.onupgradeneeded = () => { r.transaction.abort(); };' +
38 ' window.parent.postMessage({result: "no exception"}, "*");' +
39 ' } catch (ex) {' +
40 ' window.parent.postMessage({result: ex.name}, "*");' +
41 ' };' +
42 ' };' +
43 '<\/script>';
44
45 promise_test(t => {
46 return load_iframe(script)
47 .then(iframe => {
48 iframe.contentWindow.postMessage({}, '*');
49 return wait_for_message(iframe);
50 })
51 .then(message => {
52 assert_equals(message.result, 'no exception',
53 'IDBFactory.open() should not throw');
54 });
55 }, 'IDBFactory.open() in non-sandboxed iframe should not throw');
56
57 promise_test(t => {
58 return load_iframe(script, 'allow-scripts')
59 .then(iframe => {
60 iframe.contentWindow.postMessage({}, '*');
61 return wait_for_message(iframe);
62 })
63 .then(message => {
64 assert_equals(message.result, 'SecurityError',
65 'Exception should be SecurityError');
66 });
67 }, 'IDBFactory.open() in sandboxed iframe should throw SecurityError');
68 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698