mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
82 lines
2.0 KiB
HTML
82 lines
2.0 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<script type="text/javascript;version=1.8">
|
|
|
|
function init() {
|
|
window.addEventListener("message", function process(e) {doTest(e)}, false);
|
|
// unless we relinquish the eventloop,
|
|
// tests will run before the chrome event handlers are ready
|
|
setTimeout(doTest, 0);
|
|
}
|
|
|
|
function checkStatusValue(payload, expectedValue) {
|
|
return payload.status == expectedValue;
|
|
}
|
|
|
|
let tests = [
|
|
{
|
|
info: "Check account log in",
|
|
event: "login",
|
|
data: {
|
|
email: "foo@example.com",
|
|
uid: "1234@lcip.org",
|
|
assertion: "foobar",
|
|
sessionToken: "dead",
|
|
kA: "beef",
|
|
kB: "cafe",
|
|
verified: true
|
|
},
|
|
payloadType: "message",
|
|
validateResponse: function(payload) {
|
|
return checkStatusValue(payload, "login");
|
|
},
|
|
},
|
|
];
|
|
|
|
let currentTest = -1;
|
|
function doTest(evt) {
|
|
if (evt) {
|
|
if (currentTest < 0 || !evt.data.content)
|
|
return; // not yet testing
|
|
|
|
let test = tests[currentTest];
|
|
if (evt.data.type != test.payloadType)
|
|
return; // skip unrequested events
|
|
|
|
let error = JSON.stringify(evt.data.content);
|
|
let pass = false;
|
|
try {
|
|
pass = test.validateResponse(evt.data.content)
|
|
} catch (e) {}
|
|
reportResult(test.info, pass, error);
|
|
}
|
|
// start the next test if there are any left
|
|
if (tests[++currentTest])
|
|
sendToBrowser(tests[currentTest].event, tests[currentTest].data);
|
|
else
|
|
reportFinished();
|
|
}
|
|
|
|
function reportResult(info, pass, error) {
|
|
let data = {type: "testResult", info: info, pass: pass, error: error};
|
|
window.parent.postMessage(data, "*");
|
|
}
|
|
|
|
function reportFinished(cmd) {
|
|
let data = {type: "testsComplete", count: tests.length};
|
|
window.parent.postMessage(data, "*");
|
|
}
|
|
|
|
function sendToBrowser(type, data) {
|
|
let event = new CustomEvent("FirefoxAccountsCommand", {detail: {command: type, data: data}, bubbles: true});
|
|
document.dispatchEvent(event);
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="init()">
|
|
</body>
|
|
</html>
|