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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/FileAPI/url/blob-url-in-sandboxed-iframe.html

Issue 2678223002: WPT test for reading Blob URLs minted in iframes w/ and w/o sandboxing. (Closed)
Patch Set: Removed assert that relied on implementation-defined behavior. 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset="utf-8">
3 <title>FileAPI Test: Creating Blob URL with Blob</title>
4 <link rel="author" title="Victor Costan" href="mailto:pwnall@chromium.org">
5 <link rel="help" href="https://w3c.github.io/FileAPI/#originOfBlobURL">
6 <link rel="help" href="https://html.spec.whatwg.org/multipage/browsers.html#conc ept-origin">
7 <link rel="help" href="https://url.spec.whatwg.org/#url-parsing">
8 <link rel="help" href="https://fetch.spec.whatwg.org/#main-fetch">
9 <script src="/resources/testharness.js"></script>
10 <script src="/resources/testharnessreport.js"></script>
11
12 <style>
13 iframe { width: 10px; height: 10px; }
14 </style>
15
16 <iframe id="unconstrained-iframe"></iframe>
17 <iframe id="sandboxed-iframe" sandbox="allow-scripts"></iframe>
18
19 <script id="iframe-srcdoc" language="text/html">
20 <!doctype html>
21 <script>
22 'use strict';
23
24 window.onload = () => {
25 const blob = new Blob(['Hello world!']);
26 const blobUrl = URL.createObjectURL(blob);
27
28 fetch(blobUrl).then(response => response.text()).then(text => {
29 window.parent.postMessage({ blobUrl, text }, '*');
30 });
31 };
32 // The script tag is closed in readBlobFromUrl().
33 </script>
34
35 <script>
36
37 // Carries out the test of minting a Blob URL in an iframe, and reading it back.
38 //
39 // Returns a promise resolved with an object with properties blobUrl and text
40 // (the text read back from the Blob URL).
41 function readBlobFromUrl(t, iframeSelector) {
42 return new Promise((resolve, reject) => {
43 window.onmessage = t.step_func((message) => { resolve(message.data); });
44
45 const frame = document.querySelector(iframeSelector);
46 const html = document.querySelector('#iframe-srcdoc').textContent +
47 '<' + '/script>';
48 frame.setAttribute('srcdoc', html);
49 });
50 }
51
52 promise_test(t => readBlobFromUrl(t, '#unconstrained-iframe').then(data => {
53 assert_true(data.blobUrl.startsWith('blob:'),
54 "The Blob's URL should use the blob: scheme");
55 assert_equals(data.text, 'Hello world!',
56 "The result of reading the Blob's URL should be the Blob's contents");
57 }), 'reading a Blob URL in an unconstrained iframe');
58
59 promise_test(t => readBlobFromUrl(t, '#sandboxed-iframe').then(data => {
60 assert_true(data.blobUrl.startsWith('blob:'),
61 "The Blob's URL should use the blob: scheme");
62 assert_equals(data.text, 'Hello world!',
63 "The result of reading the Blob's URL should be the Blob's contents");
64 }), 'reading a Blob URL in a sandboxed iframe without the same-origin flag');
65
66 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/external/wpt/MANIFEST.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698