Bug 1395176 - Use scoped remoteFrames instead of global. r?automatedtester
MozReview-Commit-ID: 5Kj78w2gDvx
--- a/testing/marionette/frame.js
+++ b/testing/marionette/frame.js
@@ -11,19 +11,16 @@ Cu.import("resource://gre/modules/XPCOMU
this.EXPORTED_SYMBOLS = ["frame"];
/** @namespace */
this.frame = {};
const FRAME_SCRIPT = "chrome://marionette/content/listener.js";
-// list of OOP frames that has the frame script loaded
-var remoteFrames = [];
-
/**
* An object representing a frame that Marionette has loaded a
* frame script in.
*/
frame.RemoteFrame = function(windowId, frameId) {
// outerWindowId relative to main process
this.windowId = windowId;
// actual frame relative to the windowId's frames list
@@ -146,24 +143,24 @@ frame.Manager = class {
* a list of remote frames.
*/
switchToFrame(winId, frameId) {
let oopFrame = this.getOopFrame(winId, frameId);
let mm = this.getFrameMM(winId, frameId);
// see if this frame already has our frame script loaded in it;
// if so, just wake it up
- for (let i = 0; i < remoteFrames.length; i++) {
- let f = remoteFrames[i];
+ for (let i = 0; i < this.remoteFrames.length; i++) {
+ let f = this.remoteFrames[i];
let fmm = f.messageManager.get();
try {
fmm.sendAsyncMessage("aliveCheck", {});
} catch (e) {
if (e.result == Cr.NS_ERROR_NOT_INITIALIZED) {
- remoteFrames.splice(i--, 1);
+ this.remoteFrames.splice(i--, 1);
continue;
}
}
if (fmm == mm) {
this.currentRemoteFrame = f;
this.addMessageManagerListeners(mm);
@@ -173,17 +170,17 @@ frame.Manager = class {
}
// if we get here, then we need to load the frame script in this frame,
// and set the frame's ChromeMessageSender as the active message manager
// the driver will listen to.
this.addMessageManagerListeners(mm);
let f = new frame.RemoteFrame(winId, frameId);
f.messageManager = Cu.getWeakReference(mm);
- remoteFrames.push(f);
+ this.remoteFrames.push(f);
this.currentRemoteFrame = f;
mm.loadFrameScript(FRAME_SCRIPT, true, true);
return oopFrame.id;
}
/*