gecko/dom/identity/tests/mochitest/file_syntheticEvents.html

62 lines
1.5 KiB
HTML

<!--
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-->
<!DOCTYPE html>
<html>
<!--
Certified and privileged apps can call mozId outside an event handler
Certified apps: https://bugzilla.mozilla.org/show_bug.cgi?id=971379
Privileged apps: https://bugzilla.mozilla.org/show_bug.cgi?id=982460
-->
<head>
<meta charset="utf-8">
<title>Test app for bug 971379</title>
</head>
<body>
<div id='test'>
<script type="application/javascript;version=1.8">
function postResults(message) {
window.realParent.postMessage(JSON.stringify(message), "*");
}
onmessage = function(event) {
navigator.mozId.watch({
wantIssuer: event.data.wantIssuer,
onready: function() {
try {
navigator.mozId.request();
} catch(e) {
postResults({
success: false,
error: e,
appIndex: event.data.appIndex
});
}
},
onlogin: function(backedAssertion) {
postResults({
success: true,
backedAssertion: backedAssertion,
appIndex: event.data.appIndex
});
},
onerror: function(error) {
postResults({
success: false,
error: error,
appIndex: event.data.appIndex
});
},
onlogout: function() {},
});
};
</script>
</div>
</body>
</html>