Bug 1345284 - Move variable declarations in test_promise_argument.html, and test_promise_callback_retval.html. r?jmaher draft
authorGreg Mierzwinski <gmierz2@outlook.com>
Mon, 05 Jun 2017 12:35:53 -0400
changeset 590307 21d4bf2eec2143e8c208a92756c9e55f51af1219
parent 589150 cad53f061da634a16ea75887558301b77f65745d
child 632181 4fe5d872e3432710df3e1d2a2f592a817cc03f8f
push id62693
push userbmo:gmierz2@outlook.com
push dateWed, 07 Jun 2017 15:40:23 +0000
reviewersjmaher
bugs1345284
milestone55.0a1
Bug 1345284 - Move variable declarations in test_promise_argument.html, and test_promise_callback_retval.html. r?jmaher This patch fixes an intermittent bug with the test "test_webassembly_compile.html". That test calls the garbage collector which destroys the variables declared within the function-level scopes in the tests "test_promise_argument.html", and "test_promise_callback_retval.html". Declaring them outside the function scope prevents the variables from being destroyed. MozReview-Commit-ID: 7dMwavRqnFg
dom/promise/tests/test_promise_argument.html
dom/promise/tests/test_promise_callback_retval.html
--- a/dom/promise/tests/test_promise_argument.html
+++ b/dom/promise/tests/test_promise_argument.html
@@ -8,20 +8,21 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1323324</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script src="file_promise_argument_tests.js"></script>
   <script type="application/javascript">
   /** Test for Bug 1323324 **/
   SimpleTest.waitForExplicitFinish();
 
+  var globalWrapper;
   function verifyPromiseGlobal(p, global, msg) {
     // SpecialPowers.Cu.getGlobalForObject returns a SpecialPowers wrapper for
     // the actual global.  We want to grab the underlying object.
-    var globalWrapper = SpecialPowers.Cu.getGlobalForObject(p);
+    globalWrapper = SpecialPowers.Cu.getGlobalForObject(p);
     is(SpecialPowers.unwrap(globalWrapper), global,
        msg + " should come from " + global.label);
   }
 
   const isXrayArgumentTest = false;
 
   function getPromise(global, arg) {
     return global.TestFunctions.passThroughPromise(arg);
--- a/dom/promise/tests/test_promise_callback_retval.html
+++ b/dom/promise/tests/test_promise_callback_retval.html
@@ -8,28 +8,30 @@ https://bugzilla.mozilla.org/show_bug.cg
   <title>Test for Bug 1323324</title>
   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
   <script src="file_promise_argument_tests.js"></script>
   <script type="application/javascript">
   /** Test for Bug 1323324 **/
   SimpleTest.waitForExplicitFinish();
 
+  var globalWrapper;
   function verifyPromiseGlobal(p, global, msg) {
     // SpecialPowers.Cu.getGlobalForObject returns a SpecialPowers wrapper for
     // the actual global.  We want to grab the underlying object.
-    var globalWrapper = SpecialPowers.Cu.getGlobalForObject(p);
+    globalWrapper = SpecialPowers.Cu.getGlobalForObject(p);
     is(SpecialPowers.unwrap(globalWrapper), global,
        msg + " should come from " + global.label);
   }
 
   const isXrayArgumentTest = false;
 
+  var func;
   function getPromise(global, arg) {
-    var func = new global.Function("x", "return x").bind(undefined, arg);
+    func = new global.Function("x", "return x").bind(undefined, arg);
     return TestFunctions.passThroughCallbackPromise(func);
   }
 
   addLoadEvent(function() {
     frames[0].label = "child";
     SpecialPowers.pushPrefEnv({set: [['dom.expose_test_interfaces', true]]},
                               runPromiseArgumentTests.bind(undefined,
                                                            SimpleTest.finish));