Skip to content

Commit

Permalink
Backed out 4 changesets (bug 1676671) for telemetry failures. CLOSED …
Browse files Browse the repository at this point in the history
…TREE

Backed out changeset e8d3e51c0440 (bug 1676671)
Backed out changeset 94f71a0d5ee5 (bug 1676671)
Backed out changeset 68192555c760 (bug 1676671)
Backed out changeset efa50f96f8ac (bug 1676671)
  • Loading branch information
Butkovits Atila committed Dec 10, 2020
1 parent 2014a39 commit 51cbbd9
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 73 deletions.
36 changes: 17 additions & 19 deletions testing/marionette/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ class MobileTabBrowser {
});
this.window.document.dispatchEvent(event);
}

get selectedBrowser() {
return this.selectedTab.linkedBrowser;
}
}

/**
Expand Down Expand Up @@ -162,6 +158,8 @@ browser.Context = class {
// and MobileTabBrowser in GeckoView.
this.tabBrowser = browser.getTabBrowser(this.window);

this.knownFrames = [];

// Used to set curFrameId upon new session
this.newSession = true;

Expand Down Expand Up @@ -464,26 +462,26 @@ browser.Context = class {
* if it is not already assigned, and if a) we already have a session
* or b) we're starting a new session and it is the right start frame.
*
* @param {string} uid
* Frame uid for use by Marionette.
* @param {xul:browser} target
* The <xul:browser> that was the target of the originating message.
*/
register(target) {
if (!this.tabBrowser) {
return;
register(uid, target) {
if (this.tabBrowser) {
// 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);
}
}

// 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) {
// Note that browsing contexts can be swapped during navigation in which
// case this id would no longer match the target. See Bug 1680479.
const uid = target.browsingContext.id;
this.updateIdForBrowser(this.contentBrowser, uid);
}
// used to delete sessions
this.knownFrames.push(uid);
}
};

Expand Down
77 changes: 23 additions & 54 deletions testing/marionette/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,6 @@ GeckoDriver.prototype.QueryInterface = ChromeUtils.generateQI([
]);

GeckoDriver.prototype.init = function() {
if (MarionettePrefs.useActors) {
// When using JSWindowActors, we should not rely on framescript events
return;
}

this.mm.addMessageListener("Marionette:ListenersAttached", this);
this.mm.addMessageListener("Marionette:Register", this);
this.mm.addMessageListener("Marionette:switchedToFrame", this);
Expand All @@ -288,10 +283,6 @@ GeckoDriver.prototype.init = function() {
};

GeckoDriver.prototype.uninit = function() {
if (MarionettePrefs.useActors) {
return;
}

this.mm.removeMessageListener("Marionette:ListenersAttached", this);
this.mm.removeMessageListener("Marionette:Register", this);
this.mm.removeMessageListener("Marionette:switchedToFrame", this);
Expand Down Expand Up @@ -612,34 +603,35 @@ GeckoDriver.prototype.getVisibleText = function(el, lines) {
/**
* Handles registration of new content listener browsers. Depending on
* their type they are either accepted or ignored.
*
* @param {xul:browser} browserElement
*/
GeckoDriver.prototype.registerBrowser = function(browserElement) {
GeckoDriver.prototype.registerBrowser = function(id, be) {
// 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.appId != APP_ID_FIREFOX ||
browserElement.namespaceURI != XUL_NS ||
browserElement.nodeName != "browser" ||
browserElement.getTabBrowser()
be.namespaceURI != XUL_NS ||
be.nodeName != "browser" ||
be.getTabBrowser()
) {
this.curBrowser.register(browserElement);
// curBrowser holds all the registered frames in knownFrames
this.curBrowser.register(id, be);
}

const browsingContext = browserElement.browsingContext;
this.wins.set(browsingContext.id, browsingContext.currentWindowGlobal);
this.wins.set(id, BrowsingContext.get(id).currentWindowGlobal);

return id;
};

GeckoDriver.prototype.registerPromise = function() {
const li = "Marionette:Register";

return new Promise(resolve => {
let cb = ({ json, target }) => {
this.registerBrowser(target);
let { frameId } = json;
this.registerBrowser(frameId, target);

if (this.curBrowser.frameRegsPending > 0) {
this.curBrowser.frameRegsPending--;
Expand All @@ -650,7 +642,7 @@ GeckoDriver.prototype.registerPromise = function() {
resolve();
}

return { frameId: json.frameId };
return { frameId };
};
this.mm.addMessageListener(li, cb);
});
Expand Down Expand Up @@ -809,11 +801,8 @@ GeckoDriver.prototype.newSession = async function(cmd) {
logger.info("Preemptively starting accessibility service in Chrome");
}

let registerBrowsers, browserListening;
if (!MarionettePrefs.useActors) {
registerBrowsers = this.registerPromise();
browserListening = this.listeningPromise();
}
let registerBrowsers = this.registerPromise();
let browserListening = this.listeningPromise();

let waitForWindow = function() {
let windowTypes;
Expand Down Expand Up @@ -877,18 +866,8 @@ GeckoDriver.prototype.newSession = async function(cmd) {
throw new error.WebDriverError("Session already running");
}

if (MarionettePrefs.useActors) {
for (let win of this.windows) {
const tabBrowser = browser.getTabBrowser(win);
for (const tab of tabBrowser.tabs) {
const contentBrowser = browser.getBrowserForTab(tab);
this.registerBrowser(contentBrowser);
}
}
} else {
await registerBrowsers;
await browserListening;
}
await registerBrowsers;
await browserListening;

if (MarionettePrefs.useActors) {
registerCommandsActor();
Expand Down Expand Up @@ -1734,7 +1713,7 @@ GeckoDriver.prototype.setWindowHandle = async function(
// Initialise Marionette if the current chrome window has not been seen
// before. Also register the initial tab, if one exists.
let registerBrowsers, browserListening;
if (!MarionettePrefs.useActors && winProperties.hasTabBrowser) {
if (winProperties.hasTabBrowser) {
registerBrowsers = this.registerPromise();
browserListening = this.listeningPromise();
}
Expand All @@ -1743,23 +1722,12 @@ GeckoDriver.prototype.setWindowHandle = async function(

this.chromeBrowsingContext = this.mainFrame.browsingContext;

if (!winProperties.hasTabBrowser) {
this.contentBrowsingContext = null;
} else if (MarionettePrefs.useActors) {
const tabBrowser = browser.getTabBrowser(winProperties.win);

// For chrome windows such as a reftest window, `getTabBrowser` is not
// a tabbrowser, it is the content browser which should be used here.
const contentBrowser = tabBrowser.tabs
? tabBrowser.selectedBrowser
: tabBrowser;

this.contentBrowsingContext = contentBrowser.browsingContext;
this.registerBrowser(contentBrowser);
} else {
if (registerBrowsers && browserListening) {
await registerBrowsers;
const id = await browserListening;
this.contentBrowsingContext = BrowsingContext.get(id);
} else {
this.contentBrowsingContext = null;
}
} else {
// Otherwise switch to the known chrome window
Expand Down Expand Up @@ -3696,8 +3664,9 @@ GeckoDriver.prototype.receiveMessage = function(message) {
break;

case "Marionette:Register":
this.registerBrowser(message.target);
return { frameId: message.json.frameId };
let { frameId } = message.json;
this.registerBrowser(frameId, message.target);
return { frameId };

case "Marionette:ListenersAttached":
if (MarionettePrefs.useActors) {
Expand Down

0 comments on commit 51cbbd9

Please sign in to comment.