Bug 1554354. Fix new u2f tests on Android. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D32555

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-05-25 14:23:37 +00:00
Родитель 32e7d4ed2b
Коммит bbef5f170b
2 изменённых файлов: 27 добавлений и 13 удалений

Просмотреть файл

@ -14,10 +14,15 @@
// failure! Run the actual code we want off something that will report
// errors properly.
SimpleTest.executeSoon(function() {
is(typeof(u2f.register.bind(u2f)), "function",
// Need a new global for the pref to really take effect.
var iframe = document.createElement("iframe");
document.documentElement.appendChild(iframe);
var win = iframe.contentWindow;
is(typeof(win.u2f.register.bind(win.u2f)), "function",
"Should be able to bind u2f.register");
is(typeof(u2f.sign.bind(u2f)), "function",
is(typeof(win.u2f.sign.bind(win.u2f)), "function",
"Should be able to bind u2f.sign");
iframe.remove();
SimpleTest.finish();
});
}

Просмотреть файл

@ -14,21 +14,30 @@
doTest);
function doTest() {
// Need a new global for the pref to really take effect.
var iframe = document.createElement("iframe");
document.documentElement.appendChild(iframe);
var win = iframe.contentWindow;
var s = document.createElement("script");
s.textContent = `
'use strict';
var savedU2f = u2f;
var savedRegister = savedU2f.register;
var savedSign = savedU2f.sign;
var u2f = u2f || {};
u2f.register = function() {};
u2f.sign = function() {};
is(u2f, savedU2f, "Should still have the right object");
is(u2f.register, savedRegister, "Should not allow overriding 'sign'");
is(u2f.sign, savedSign, "Should not allow overriding 'sign'");
SimpleTest.finish();
try {
var savedU2f = u2f;
var savedRegister = savedU2f.register;
var savedSign = savedU2f.sign;
var u2f = u2f || {};
u2f.register = function() {};
u2f.sign = function() {};
parent.is(u2f, savedU2f, "Should still have the right object");
parent.is(u2f.register, savedRegister, "Should not allow overriding 'sign'");
parent.is(u2f.sign, savedSign, "Should not allow overriding 'sign'");
} catch (e) {
parent.ok(false, "Threw an exception: " + e);
} finally {
parent.SimpleTest.finish();
}
`;
document.documentElement.appendChild(s);
win.document.documentElement.appendChild(s);
}
</script>
</head>