Bug 1168281 - Instantiate SpecialPowers only if it is not existed when Marionette executes script in sandbox. r=dburns, a=jocheng
authorTing-Yu Chou <janus926@gmail.com>
Fri, 29 May 2015 16:47:24 +0800
changeset 238566 066d969aebac34baaa655d96b35dca031b95cbfd
parent 238565 08da212f538c3dd8f2928496a1c3121d16d9b2ce
child 238567 ae1282b33319c76bede150fd2a42dac871aeede8
push id672
push userryanvm@gmail.com
push dateTue, 02 Jun 2015 17:36:08 +0000
treeherdermozilla-b2g37_v2_2@5b3f1796ddf6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdburns, jocheng
bugs1168281
milestone37.0
Bug 1168281 - Instantiate SpecialPowers only if it is not existed when Marionette executes script in sandbox. r=dburns, a=jocheng
testing/marionette/marionette-listener.js
--- a/testing/marionette/marionette-listener.js
+++ b/testing/marionette/marionette-listener.js
@@ -418,26 +418,22 @@ function createExecuteContentSandbox(aWi
     try {
       sandbox[fn] = marionette[fn].bind(marionette);
     }
     catch(e) {
       sandbox[fn] = marionette[fn];
     }
   });
 
-  if (aWindow.wrappedJSObject.SpecialPowers != undefined) {
-    XPCOMUtils.defineLazyGetter(sandbox, 'SpecialPowers', function() {
-      return aWindow.wrappedJSObject.SpecialPowers;
-    });
-  }
-  else {
-    XPCOMUtils.defineLazyGetter(sandbox, 'SpecialPowers', function() {
-      return new SpecialPowers(aWindow);
-    });
-  }
+  XPCOMUtils.defineLazyGetter(sandbox, 'SpecialPowers', function() {
+    if (!aWindow.wrappedJSObject.SpecialPowers) {
+      aWindow.wrappedJSObject.SpecialPowers = new SpecialPowers(aWindow);
+    }
+    return aWindow.wrappedJSObject.SpecialPowers;
+  });
 
   sandbox.asyncComplete = function sandbox_asyncComplete(value, status, stack, commandId) {
     if (commandId == asyncTestCommandId) {
       curFrame.removeEventListener("unload", onunload, false);
       curFrame.clearTimeout(asyncTestTimeoutId);
 
       if (inactivityTimeoutId != null) {
         curFrame.clearTimeout(inactivityTimeoutId);