Bug 1239552 - Disable frame script global scope; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Tue, 26 Jul 2016 13:35:01 +0100
changeset 394970 8b794afe9d29b1a6bf13e86fad305a8c8937cf2e
parent 394969 f8bf93b1c8d547cc62ba405197152129b5736059
child 526917 65fde203523c8a639cd7bde9b42dc100d34ff327
push id24684
push userbmo:ato@mozilla.com
push dateMon, 01 Aug 2016 12:44:30 +0000
reviewersautomatedtester
bugs1239552
milestone50.0a1
Bug 1239552 - Disable frame script global scope; r?automatedtester By default, frame scripts each have their own scope, so they can declare global variables without causing conflicts with any other frame scripts. The current code switches off that behaviour, meaning that the script's scope is shared with any other frame scripts in the same frame. This patch changes it so that each loaded frame script gets its own scope. This works around the problem that on Windows in officially branded builds, IPC message handlers are registered twice causing a race condition in the IPC communication between driver.js and listener.js. This is not a solution for fixing the core of the problem. MozReview-Commit-ID: Fcjmi7tq5eA
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -334,17 +334,20 @@ GeckoDriver.prototype.whenBrowserStarted
       // so send the ack here. Otherwise, make a note of how many child scripts
       // will be loaded so we known when it's safe to return.
       if (mm.childCount !== 0) {
         this.curBrowser.frameRegsPending = mm.childCount;
       }
     }
 
     if (!Preferences.get(CONTENT_LISTENER_PREF) || !isNewSession) {
-      mm.loadFrameScript(FRAME_SCRIPT, true, true);
+      // load listener into the remote frame
+      // and any applicable new frames
+      // opened after this call
+      mm.loadFrameScript(FRAME_SCRIPT, true);
       Preferences.set(CONTENT_LISTENER_PREF, true);
     }
   } else {
     logger.error(
         `Could not load listener into content for page ${win.location.href}`);
   }
 };