tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_promise_argument_xrays.html (2437B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1233324
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1233324</title>
      9  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
     11  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1233324">Mozilla Bug 1233324</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17 <iframe id="t" src="http://example.org/chrome/dom/promise/tests/file_promise_xrays.html"></iframe>
     18 </div>
     19 
     20 <pre id="test">
     21 <script src="file_promise_argument_tests.js"></script>
     22 <script type="application/javascript">
     23 
     24 var win = $("t").contentWindow;
     25 
     26 /** Test for Bug 1233324 */
     27 SimpleTest.waitForExplicitFinish();
     28 
     29 function testLoadComplete() {
     30  is(win.location.href, $("t").src, "Should have loaded the right thing");
     31  nextTest();
     32 }
     33 
     34 function testHaveXray() {
     35  is(typeof win.Promise.race, "function", "Should see a race() function");
     36  var exception;
     37  try {
     38    win.Promise.wrappedJSObject.race;
     39  } catch (e) {
     40    exception = e;
     41  }
     42  is(exception, "Getting race", "Should have thrown the right exception");
     43  is(win.wrappedJSObject.setupThrew, false, "Setup should not have thrown");
     44  nextTest();
     45 }
     46 
     47 function verifyPromiseGlobal(p, _, msg) {
     48  // SpecialPowers.Cu.getGlobalForObject returns a SpecialPowers wrapper for
     49  // the actual global.  We want to grab the underlying object.
     50  var global = SpecialPowers.unwrap(SpecialPowers.Cu.getGlobalForObject(p));
     51 
     52  // We expect our global to always be "window" here, because we're working over
     53  // Xrays.
     54  is(global, window, msg + " should come from " + window.label);
     55 }
     56 
     57 const isXrayArgumentTest = true;
     58 
     59 function getPromise(global, arg) {
     60  return global.TestFunctions.passThroughPromise(arg);
     61 }
     62 
     63 function testPromiseArgumentConversions() {
     64  runPromiseArgumentTests(nextTest);
     65 }
     66 
     67 var tests = [
     68  testLoadComplete,
     69  testHaveXray,
     70  testPromiseArgumentConversions,
     71 ];
     72 
     73 function nextTest() {
     74  if (!tests.length) {
     75    SimpleTest.finish();
     76    return;
     77  }
     78  tests.shift()();
     79 }
     80 
     81 addLoadEvent(function() {
     82  frames[0].label = "child";
     83  SpecialPowers.pushPrefEnv({set: [["dom.expose_test_interfaces", true]]},
     84                            nextTest);
     85 });
     86 
     87 </script>
     88 </pre>
     89 </body>
     90 </html>