Bug 1413427 - Part5 - Fix cross origin test failure. r=bz,jgraham
authorJames Cheng <jacheng@mozilla.com>
Fri, 03 Nov 2017 17:57:52 +0800
changeset 390891 8a306a5bc1da4a6c1ff7d3cd695b95bdfdccc0f4
parent 390890 6039726995022771be1e7a853fcc238f9fbac829
child 390892 05002ad2b8f98d392a10811ce12f332ce2258210
push id55042
push userjacheng@mozilla.com
push dateThu, 09 Nov 2017 04:28:39 +0000
treeherderautoland@8a306a5bc1da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jgraham
bugs1413427, 1322517
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1413427 - Part5 - Fix cross origin test failure. r=bz,jgraham Bug 1322517 will make the EME APIs only run on secure context. This bug will try to make WPT test run with https. According to the spec https://www.w3.org/TR/secure-contexts/#is-url-trustworthy I got "TypeError: navigator.requestMediaKeySystemAccess is not a function" by the original code. So I need this patch to make the test work as expected. MozReview-Commit-ID: Gp23IcscXHE
testing/web-platform/tests/encrypted-media/scripts/unique-origin.js
--- a/testing/web-platform/tests/encrypted-media/scripts/unique-origin.js
+++ b/testing/web-platform/tests/encrypted-media/scripts/unique-origin.js
@@ -5,32 +5,32 @@ function runTest(config) {
 
     function load_iframe(src, sandbox) {
         return new Promise(function (resolve) {
             var iframe = document.createElement('iframe');
             iframe.onload = function () {
                 resolve(iframe);
             };
             iframe.sandbox = sandbox;
-            iframe.src = src;
+            iframe.srcdoc = src;
             document.documentElement.appendChild(iframe);
         });
     }
 
     function wait_for_message() {
         return new Promise(function (resolve) {
             self.addEventListener('message', function listener(e) {
                 resolve(e.data);
                 self.removeEventListener('message', listener);
             });
         });
     }
 
     promise_test(function (test) {
-        var script = 'data:text/html,' +
+        var script =
           '<script>' +
           '    window.onmessage = function(e) {' +
           '        navigator.requestMediaKeySystemAccess("' + config.keysystem + '", [{' +
           '           initDataTypes: [\"' + config.initDataType + '\"],' +
           '           audioCapabilities: [' +
           '               { contentType:\'' + config.audioType + '\'},' +
           '           ]' +
           '       }]).then(function(access) {' +
@@ -48,17 +48,17 @@ function runTest(config) {
             initDataTypes: [config.initDataType],
             audioCapabilities: [
                 {contentType: config.audioType},
             ]
         }]).then(function (access) {
             return access.createMediaKeys();
         }).then(function (mediaKeys) {
             // Success, so now create the iframe and try there.
-            return load_iframe(script, 'allow-scripts');
+            return load_iframe(script, 'allow-scripts allow-secure-context');
         }).then(function (iframe) {
             iframe.contentWindow.postMessage({}, '*');
             return wait_for_message();
         }).then(function (message) {
             assert_equals(message.result, 'failed');
         });
     }, 'Unique origin is unable to create MediaKeys');
 }