dom/identity/tests/mochitest/test_rpHasValidCallbacks.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 <!--
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 -->
michael@0 6 <!DOCTYPE html>
michael@0 7 <html>
michael@0 8 <!--
michael@0 9 https://bugzilla.mozilla.org/show_bug.cgi?id=945363
michael@0 10 -->
michael@0 11 <head>
michael@0 12 <meta charset="utf-8">
michael@0 13 <title>BrowserID and Firefox Accounts RPs provide requried callbacks - Bug 945363</title>
michael@0 14 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 15 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
michael@0 16 </head>
michael@0 17
michael@0 18 <body>
michael@0 19 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=945363">Mozilla Bug 945363</a>
michael@0 20 <p id="display"></p>
michael@0 21 <div id="content">
michael@0 22
michael@0 23 </div>
michael@0 24 <pre id="test">
michael@0 25 <script type="application/javascript;version=1.7">
michael@0 26
michael@0 27 /** Test for Bug 945363 **/
michael@0 28
michael@0 29 const BASE_URL = "http://mochi.test:8888/chrome/dom/identity/tests/mochitest/";
michael@0 30
michael@0 31 SimpleTest.waitForExplicitFinish();
michael@0 32
michael@0 33 // Candidate RPs, and whether we expect them to experience an error.
michael@0 34 // Will will load each of these in turn into an iframe. The candiates
michael@0 35 // will invoke navigator.mozId.watch(). If they do not provide the
michael@0 36 // correct arguments to watch(), nsDOMIdentity will throw an exception.
michael@0 37 let candidates = [
michael@0 38 [BASE_URL + "file_browserid_rp_ok.html", false],
michael@0 39 [BASE_URL + "file_browserid_rp_noOnlogin.html", true ],
michael@0 40 [BASE_URL + "file_fxa_rp_ok.html", false],
michael@0 41 [BASE_URL + "file_fxa_rp_noOnlogin.html", true ],
michael@0 42 [BASE_URL + "file_fxa_rp_noOnlogout.html", true ],
michael@0 43 [BASE_URL + "file_fxa_rp_noOnready.html", true ],
michael@0 44 ];
michael@0 45
michael@0 46 let checkedCount = 0;
michael@0 47 let checksTodo = candidates.length;
michael@0 48
michael@0 49 // Each iframe will postMessage to us, telling us whether they caught
michael@0 50 // an exception or not when calling watch().
michael@0 51 window.addEventListener('message', function onMessage(event) {
michael@0 52 let message = JSON.parse(event.data);
michael@0 53 let [uri, expectedError] = candidates[checkedCount];
michael@0 54
michael@0 55 is(message.error, expectedError, "Unexpected error result from " + uri);
michael@0 56
michael@0 57 if (++checkedCount < checksTodo) {
michael@0 58 testRunner.next();
michael@0 59 } else {
michael@0 60 window.removeEventListener('message', onMessage);
michael@0 61 SimpleTest.finish();
michael@0 62 }
michael@0 63 }, false);
michael@0 64
michael@0 65 let content = document.getElementById('content');
michael@0 66 function runTest() {
michael@0 67 for (let [uri, _] of candidates) {
michael@0 68
michael@0 69 let iframe = document.createElement('iframe');
michael@0 70 iframe.setAttribute('mozbrowser', 'true');
michael@0 71 iframe.src = uri;
michael@0 72
michael@0 73 content.appendChild(iframe);
michael@0 74
michael@0 75 yield undefined;
michael@0 76 }
michael@0 77 }
michael@0 78
michael@0 79 let testRunner = runTest();
michael@0 80
michael@0 81 // Enable the identity systems and use verbose logging
michael@0 82 SpecialPowers.pushPrefEnv({'set': [
michael@0 83 ['dom.identity.enabled', true], // navigator.mozId
michael@0 84 ['identity.fxaccounts.enabled', true], // fx accounts
michael@0 85 ['dom.identity.syntheticEventsOk', true], // so we can call request()
michael@0 86 ['toolkit.identity.debug', true], // verbose identity logging
michael@0 87 ['browser.dom.window.dump.enabled', true],
michael@0 88 ]},
michael@0 89 function () { testRunner.next(); }
michael@0 90 );
michael@0 91
michael@0 92 </script>
michael@0 93 </pre>
michael@0 94 </body>
michael@0 95 </html>

mercurial