Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / encrypted-media / encrypted-media-unique-origin.html
blob08ddead83288bd259c532e6259205c40c811dd30
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Unique origin is unable to create MediaKeys</title>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <div id="log"></div>
10 <script>
11 // When the sandbox attribute is present on an iframe, it will
12 // treat the content as being from a unique origin. So try to
13 // call createMediaKeys() inside an iframe and it should fail.
15 function load_iframe(src, sandbox) {
16 return new Promise(function(resolve) {
17 var iframe = document.createElement('iframe');
18 iframe.onload = function() { resolve(iframe); };
19 iframe.sandbox = sandbox;
20 iframe.src = src;
21 document.documentElement.appendChild(iframe);
22 });
25 function wait_for_message() {
26 return new Promise(function(resolve) {
27 self.addEventListener('message', function listener(e) {
28 resolve(e.data);
29 self.removeEventListener(listener);
30 });
31 });
34 promise_test(function(test) {
35 var script = 'data:text/html,' +
36 '<script>' +
37 ' window.onmessage = function(e) {' +
38 ' navigator.requestMediaKeySystemAccess(\'org.w3.clearkey\', [{}]).then(function(access) {' +
39 ' return access.createMediaKeys();' +
40 ' }).then(function(mediaKeys) {' +
41 ' window.parent.postMessage({result: \'allowed\'}, \'*\');' +
42 ' }, function(error) {' +
43 ' window.parent.postMessage({result: \'failed\'}, \'*\');' +
44 ' });' +
45 ' };' +
46 '<\/script>';
48 // Verify that this page can create a MediaKeys first.
49 navigator.requestMediaKeySystemAccess('org.w3.clearkey', [{}]).then(function(access) {
50 return access.createMediaKeys();
51 }).then(function(mediaKeys) {
52 // Success, so now create the iframe and try there.
53 return load_iframe(script, 'allow-scripts')
54 }).then(function(iframe) {
55 iframe.contentWindow.postMessage({}, '*');
56 return wait_for_message();
57 }).then(function(message) {
58 assert_equals(message.result, 'failed');
59 });
60 }, 'Unique origin is unable to create MediaKeys');
61 </script>
62 </body>
63 </html>