Bug 1413427 - Part5 - Fix cross origin test failure.
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
--- 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');
}