Bug 1318351 - Remove mainContent and related code used by B2G.
MozReview-Commit-ID: 1BZY5VvCMZ9
--- a/testing/marionette/browser.js
+++ b/testing/marionette/browser.js
@@ -62,17 +62,17 @@ browser.getTabBrowser = function (win) {
return null;
}
};
/**
* Creates a browsing context wrapper.
*
* Browsing contexts handle interactions with the browser, according to
- * the current environment (desktop, B2G, Fennec, &c).
+ * the current environment (Firefox, Fennec).
*
* @param {nsIDOMWindow} win
* The window whose browser needs to be accessed.
* @param {GeckoDriver} driver
* Reference to the driver the browser is attached to.
*/
browser.Context = class {
@@ -87,19 +87,16 @@ browser.Context = class {
this.driver = driver;
// In Firefox this is <xul:tabbrowser> (not <xul:browser>!)
// and BrowserApp in Fennec
this.tabBrowser = browser.getTabBrowser(win);
this.knownFrames = [];
- // Used in B2G to identify the homescreen content page
- this.mainContentId = null;
-
// Used to set curFrameId upon new session
this.newSession = true;
this.seenEls = new element.Store();
// A reference to the tab corresponding to the current window handle, if any.
// Specifically, this.tab refers to the last tab that Marionette switched
// to in this browser window. Note that this may not equal the currently
@@ -114,17 +111,16 @@ browser.Context = class {
// can handle modals in each <xul:browser>.
this.frameManager = new frame.Manager(driver);
this.frameRegsPending = 0;
// register all message listeners
this.frameManager.addMessageManagerListeners(driver.mm);
this.getIdForBrowser = driver.getIdForBrowser.bind(driver);
this.updateIdForBrowser = driver.updateIdForBrowser.bind(driver);
- this._curFrameId = null;
this._browserWasRemote = null;
this._hasRemotenessChange = false;
}
/**
* Returns the content browser for the currently selected tab.
* If there is no tab selected, null will be returned.
*/
@@ -138,30 +134,22 @@ browser.Context = class {
/**
* The current frame ID is managed per browser element on desktop in
* case the ID needs to be refreshed. The currently selected window is
* identified by a tab.
*/
get curFrameId() {
let rv = null;
- if (this.driver.appName == "B2G") {
- rv = this._curFrameId;
- } else if (this.tab) {
+ if (this.tab) {
rv = this.getIdForBrowser(this.contentBrowser);
}
return rv;
}
- set curFrameId(id) {
- if (this.driver.appName != "Firefox") {
- this._curFrameId = id;
- }
- }
-
/**
* Retrieves the current tabmodal UI object. According to the browser
* associated with the currently selected tab.
*/
getTabModalUI() {
let br = this.contentBrowser;
if (!br.hasAttribute("tabmodalPromptShowing")) {
return null;
@@ -309,36 +297,32 @@ browser.Context = class {
// If we're setting up a new session on Firefox, we only process the
// registration for this frame if it belongs to the current tab.
if (!this.tab) {
this.switchToTab();
}
if (target === this.contentBrowser) {
this.updateIdForBrowser(this.contentBrowser, uid);
- this.mainContentId = uid;
}
- } else {
- this._curFrameId = uid;
- this.mainContentId = uid;
}
}
// used to delete sessions
this.knownFrames.push(uid);
return remotenessChange;
}
/**
* When navigating between pages results in changing a browser's
* process, we need to take measures not to lose contact with a listener
* script. This function does the necessary bookkeeping.
*/
hasRemotenessChange() {
- // None of these checks are relevant on b2g or if we don't have a tab yet,
+ // None of these checks are relevant if we don't have a tab yet,
// and may not apply on Fennec.
if (this.driver.appName != "Firefox" ||
this.tab === null ||
this.contentBrowser === null) {
return false;
}
if (this._hasRemotenessChange) {
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -88,34 +88,33 @@ this.Context.fromString = function (s) {
* in chrome space and mediates calls to the message listener of the current
* browsing context's content frame message listener via ListenerProxy.
*
* Throughout this prototype, functions with the argument {@code cmd}'s
* documentation refers to the contents of the {@code cmd.parameters}
* object.
*
* @param {string} appName
- * Description of the product, for example "B2G" or "Firefox".
+ * Description of the product, for example "Firefox".
* @param {MarionetteServer} server
* The instance of Marionette server.
*/
this.GeckoDriver = function (appName, server) {
this.appName = appName;
this._server = server;
this.sessionId = null;
this.wins = new browser.Windows();
this.browsers = {};
// points to current browser
this.curBrowser = null;
// topmost chrome frame
this.mainFrame = null;
// chrome iframe that currently has focus
this.curFrame = null;
- this.mainContentFrameId = null;
this.mozBrowserClose = null;
this.currentFrameElement = null;
// frame ID of the current remote frame, used for mozbrowserclose events
this.oopFrameId = null;
this.observing = null;
this._browserIds = new WeakMap();
// The curent context decides if commands should affect chrome- or
@@ -504,48 +503,41 @@ GeckoDriver.prototype.registerBrowser =
// message here.
//
// TODO: Should have a better way of determining that this message
// is from a remote frame.
this.curBrowser.frameManager.currentRemoteFrame.targetFrameId = id;
}
let reg = {};
- // this will be sent to tell the content process if it is the main content
- let mainContent = this.curBrowser.mainContentId === null;
+
// We want to ignore frames that are XUL browsers that aren't in the "main"
// tabbrowser, but accept things on Fennec (which doesn't have a
// xul:tabbrowser), and accept HTML iframes (because tests depend on it),
// as well as XUL frames. Ideally this should be cleaned up and we should
// keep track of browsers a different way.
if (this.appName != "Firefox" || be.namespaceURI != XUL_NS ||
be.nodeName != "browser" || be.getTabBrowser()) {
// curBrowser holds all the registered frames in knownFrames
reg.id = id;
reg.remotenessChange = this.curBrowser.register(id, be);
}
- // set to true if we updated mainContentId
- mainContent = mainContent && this.curBrowser.mainContentId !== null;
- if (mainContent) {
- this.mainContentFrameId = this.curBrowser.curFrameId;
- }
-
this.wins.set(reg.id, listenerWindow);
if (nullPrevious && (this.curBrowser.curFrameId !== null)) {
this.sendAsync(
"newSession",
this.capabilities.toJSON(),
this.newSessionCommandId);
if (this.curBrowser.isNewSession) {
this.newSessionCommandId = null;
}
}
- return [reg, mainContent, this.capabilities.toJSON()];
+ return [reg, this.capabilities.toJSON()];
};
GeckoDriver.prototype.registerPromise = function () {
const li = "Marionette:register";
return new Promise(resolve => {
let cb = msg => {
let wid = msg.json.value;
--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -389,62 +389,29 @@ var loadListener = {
*/
function registerSelf() {
let msg = {value: winUtil.outerWindowID};
// register will have the ID and a boolean describing if this is the main process or not
let register = sendSyncMessage("Marionette:register", msg);
if (register[0]) {
let {id, remotenessChange} = register[0][0];
- capabilities = session.Capabilities.fromJSON(register[0][2]);
+ capabilities = session.Capabilities.fromJSON(register[0][1]);
listenerId = id;
if (typeof id != "undefined") {
- // check if we're the main process
- if (register[0][1]) {
- addMessageListener("MarionetteMainListener:emitTouchEvent", emitTouchEventForIFrame);
- }
startListeners();
let rv = {};
if (remotenessChange) {
rv.listenerId = id;
}
sendAsyncMessage("Marionette:listenersAttached", rv);
}
}
}
-function emitTouchEventForIFrame(message) {
- message = message.json;
- let identifier = legacyactions.nextTouchId;
-
- let domWindowUtils = curContainer.frame.
- QueryInterface(Components.interfaces.nsIInterfaceRequestor).
- getInterface(Components.interfaces.nsIDOMWindowUtils);
- var ratio = domWindowUtils.screenPixelsPerCSSPixel;
-
- var typeForUtils;
- switch (message.type) {
- case 'touchstart':
- typeForUtils = domWindowUtils.TOUCH_CONTACT;
- break;
- case 'touchend':
- typeForUtils = domWindowUtils.TOUCH_REMOVE;
- break;
- case 'touchcancel':
- typeForUtils = domWindowUtils.TOUCH_CANCEL;
- break;
- case 'touchmove':
- typeForUtils = domWindowUtils.TOUCH_CONTACT;
- break;
- }
- domWindowUtils.sendNativeTouchPoint(identifier, typeForUtils,
- Math.round(message.screenX * ratio), Math.round(message.screenY * ratio),
- message.force, 90);
-}
-
// Eventually we will not have a closure for every single command, but
// use a generic dispatch for all listener commands.
//
// Perhaps one could even conceive having a separate instance of
// CommandProcessor for the listener, because the code is mostly the same.
function dispatch(fn) {
if (typeof fn != "function") {
throw new TypeError("Provided dispatch handler is not a function");