mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-14 05:45:37 +00:00
Bug 1046512 - Modification to marionette to support running tests with e10s enabled. r=jgriffin
This commit is contained in:
parent
5dda658275
commit
24d17c3c3a
@ -21,7 +21,12 @@ class GeckoInstance(object):
|
||||
"browser.shell.checkDefaultBrowser": False,
|
||||
"browser.startup.page": 0,
|
||||
"browser.sessionstore.resume_from_crash": False,
|
||||
"browser.warnOnQuit": False}
|
||||
"browser.warnOnQuit": False,
|
||||
"browser.displayedE10SPrompt": 5,
|
||||
"browser.displayedE10SPrompt.1": 5,
|
||||
"browser.displayedE10SPrompt.2": 5,
|
||||
"browser.displayedE10SPrompt.3": 5,
|
||||
"browser.displayedE10SPrompt.4": 5}
|
||||
|
||||
def __init__(self, host, port, bin, profile, app_args=None, symbols_path=None,
|
||||
gecko_log=None, prefs=None):
|
||||
|
@ -71,6 +71,7 @@ if (win != null)
|
||||
self.fail("There were no windows that appeared when we clicked earlier")
|
||||
else:
|
||||
time.sleep(1)
|
||||
count += 1
|
||||
|
||||
self.marionette.switch_to_window(window_handles[0])
|
||||
self.assertEqual(self.marionette.title, "We Arrive Here")
|
||||
|
@ -140,13 +140,14 @@ FrameManager.prototype = {
|
||||
// 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 server will listen to
|
||||
this.addMessageManagerListeners(mm);
|
||||
logger.info("frame-manager load script: " + mm.toString());
|
||||
mm.loadFrameScript(FRAME_SCRIPT, true, true);
|
||||
let aFrame = new MarionetteRemoteFrame(message.json.win, message.json.frame);
|
||||
aFrame.messageManager = Cu.getWeakReference(mm);
|
||||
remoteFrames.push(aFrame);
|
||||
this.currentRemoteFrame = aFrame;
|
||||
|
||||
logger.info("frame-manager load script: " + mm.toString());
|
||||
mm.loadFrameScript(FRAME_SCRIPT, true, true);
|
||||
|
||||
aFrame.specialPowersObserver = new specialpowers.SpecialPowersObserver();
|
||||
aFrame.specialPowersObserver.init(mm);
|
||||
return oopFrame.id;
|
||||
|
@ -102,13 +102,15 @@ function registerSelf() {
|
||||
|
||||
if (register[0]) {
|
||||
listenerId = register[0][0].id;
|
||||
// check if we're the main process
|
||||
if (register[0][1] == true) {
|
||||
addMessageListener("MarionetteMainListener:emitTouchEvent", emitTouchEventForIFrame);
|
||||
if (typeof listenerId != "undefined") {
|
||||
// check if we're the main process
|
||||
if (register[0][1] == true) {
|
||||
addMessageListener("MarionetteMainListener:emitTouchEvent", emitTouchEventForIFrame);
|
||||
}
|
||||
importedScripts = FileUtils.getDir('TmpD', [], false);
|
||||
importedScripts.append('marionetteContentScripts');
|
||||
startListeners();
|
||||
}
|
||||
importedScripts = FileUtils.getDir('TmpD', [], false);
|
||||
importedScripts.append('marionetteContentScripts');
|
||||
startListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,6 +266,7 @@ function deleteSession(msg) {
|
||||
removeMessageListenerId("Marionette:getActiveElement", getActiveElement);
|
||||
removeMessageListenerId("Marionette:clickElement", clickElement);
|
||||
removeMessageListenerId("Marionette:getElementAttribute", getElementAttribute);
|
||||
removeMessageListenerId("Marionette:getElementText", getElementText);
|
||||
removeMessageListenerId("Marionette:getElementTagName", getElementTagName);
|
||||
removeMessageListenerId("Marionette:isElementDisplayed", isElementDisplayed);
|
||||
removeMessageListenerId("Marionette:getElementValueOfCssProperty", getElementValueOfCssProperty);
|
||||
@ -1827,8 +1830,15 @@ function addCookie(msg) {
|
||||
if (!document || !document.contentType.match(/html/i)) {
|
||||
sendError('You may only set cookies on html documents', 25, null, msg.json.command_id);
|
||||
}
|
||||
var cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager2);
|
||||
let cookieManager;
|
||||
try {
|
||||
// Retrieving the cookie manager fails with e10s enabled.
|
||||
cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager2);
|
||||
} catch (ex) {
|
||||
sendError("Error retrieving cookie manager: " + ex, 13, null, msg.json.command_id);
|
||||
return;
|
||||
}
|
||||
cookieManager.add(cookie.domain, cookie.path, cookie.name, cookie.value,
|
||||
cookie.secure, false, false, cookie.expiry);
|
||||
sendOk(msg.json.command_id);
|
||||
@ -1840,6 +1850,10 @@ function addCookie(msg) {
|
||||
function getCookies(msg) {
|
||||
var toReturn = [];
|
||||
var cookies = getVisibleCookies(curFrame.location);
|
||||
if (typeof cookies == "undefined") {
|
||||
sendError("Error retrieving cookie manager", 13, null, msg.json.command_id);
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i];
|
||||
var expires = cookie.expires;
|
||||
@ -1866,8 +1880,16 @@ function getCookies(msg) {
|
||||
*/
|
||||
function deleteCookie(msg) {
|
||||
var toDelete = msg.json.name;
|
||||
var cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
|
||||
let cookieManager;
|
||||
try {
|
||||
// Retrieving the cookie manager fails with e10s enabled.
|
||||
cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
} catch (ex) {
|
||||
sendError("Error retrieving cookie manager: " + ex, 13, null, msg.json.command_id);
|
||||
return;
|
||||
}
|
||||
|
||||
var cookies = getVisibleCookies(curFrame.location);
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
@ -1884,8 +1906,15 @@ function deleteCookie(msg) {
|
||||
* Delete all the visibile cookies on a page
|
||||
*/
|
||||
function deleteAllCookies(msg) {
|
||||
let cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
let cookieManager;
|
||||
try {
|
||||
// Retrieving the cookie manager fails with e10s enabled.
|
||||
cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
} catch (ex) {
|
||||
sendError("Error retrieving cookie manager: " + ex, 13, null, msg.json.command_id);
|
||||
return;
|
||||
}
|
||||
let cookies = getVisibleCookies(curFrame.location);
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
let cookie = cookies[i];
|
||||
@ -1905,8 +1934,15 @@ function getVisibleCookies(location) {
|
||||
return currentPath.indexOf(aPath) != -1;
|
||||
}
|
||||
|
||||
let cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
let cookieManager;
|
||||
try {
|
||||
// Retrieving the cookie manager fails with e10s enabled.
|
||||
cookieManager = Cc['@mozilla.org/cookiemanager;1'].
|
||||
getService(Ci.nsICookieManager);
|
||||
} catch (ex) {
|
||||
return;
|
||||
}
|
||||
|
||||
let enumerator = cookieManager.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let cookie = enumerator.getNext().QueryInterface(Ci['nsICookie']);
|
||||
|
@ -439,8 +439,7 @@ MarionetteServerConnection.prototype = {
|
||||
* Start a new session in a new browser.
|
||||
*
|
||||
* If newSession is true, we will switch focus to the start frame
|
||||
* when it registers. Also, if it is in desktop, then a new tab
|
||||
* with the start page uri (about:blank) will be opened.
|
||||
* when it registers.
|
||||
*
|
||||
* @param nsIDOMWindow win
|
||||
* Window whose browser we need to access
|
||||
@ -533,9 +532,6 @@ MarionetteServerConnection.prototype = {
|
||||
/**
|
||||
* Create a new session. This creates a new BrowserObj.
|
||||
*
|
||||
* In a desktop environment, this opens a new browser with
|
||||
* "about:blank" which subsequent commands will be sent to.
|
||||
*
|
||||
* This will send a hash map of supported capabilities to the client
|
||||
* as part of the Marionette:register IPC command in the
|
||||
* receiveMessage callback when a new browser is created.
|
||||
@ -1180,7 +1176,7 @@ MarionetteServerConnection.prototype = {
|
||||
this.sendResponse(this.curBrowser
|
||||
.tab
|
||||
.linkedBrowser
|
||||
.contentWindow.location.href, this.command_id);
|
||||
.contentWindowAsCPOW.location.href, this.command_id);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -2223,7 +2219,7 @@ MarionetteServerConnection.prototype = {
|
||||
/**
|
||||
* Deletes the session.
|
||||
*
|
||||
* If it is a desktop environment, it will close the session's tab and close all listeners
|
||||
* If it is a desktop environment, it will close all listeners
|
||||
*
|
||||
* If it is a B2G environment, it will make the main content listener sleep, and close
|
||||
* all other listeners. The main content listener persists after disconnect (it's the homescreen),
|
||||
@ -2241,7 +2237,6 @@ MarionetteServerConnection.prototype = {
|
||||
//don't set this pref for B2G since the framescript can be safely reused
|
||||
Services.prefs.setBoolPref("marionette.contentListener", false);
|
||||
}
|
||||
this.curBrowser.closeTab();
|
||||
//delete session in each frame in each browser
|
||||
for (let win in this.browsers) {
|
||||
for (let i in this.browsers[win].knownFrames) {
|
||||
@ -2660,9 +2655,9 @@ MarionetteServerConnection.prototype = {
|
||||
Services.wm.getOuterWindowWithId(message.json.value);
|
||||
|
||||
//go in here if we're already in a remote frame.
|
||||
if ((!listenerWindow || (listenerWindow.location &&
|
||||
listenerWindow.location.href != message.json.href)) &&
|
||||
(this.curBrowser.frameManager.currentRemoteFrame !== null)) {
|
||||
if (this.curBrowser.frameManager.currentRemoteFrame !== null &&
|
||||
(!listenerWindow ||
|
||||
this.messageManager == this.curBrowser.frameManager.currentRemoteFrame.messageManager.get())) {
|
||||
// The outerWindowID from an OOP frame will not be meaningful to
|
||||
// the parent process here, since each process maintains its own
|
||||
// independent window list. So, it will either be null (!listenerWindow)
|
||||
@ -2688,8 +2683,8 @@ MarionetteServerConnection.prototype = {
|
||||
let mainContent = (this.curBrowser.mainContentId == null);
|
||||
if (!browserType || browserType != "content") {
|
||||
//curBrowser holds all the registered frames in knownFrames
|
||||
reg.id = this.curBrowser.register(this.generateFrameId(message.json.value),
|
||||
listenerWindow);
|
||||
let listenerId = message.json.value;
|
||||
reg.id = this.curBrowser.register(this.generateFrameId(listenerId), listenerId);
|
||||
}
|
||||
// set to true if we updated mainContentId
|
||||
mainContent = ((mainContent == true) && (this.curBrowser.mainContentId != null));
|
||||
@ -2852,37 +2847,15 @@ BrowserObj.prototype = {
|
||||
},
|
||||
/**
|
||||
* Called when we start a session with this browser.
|
||||
*
|
||||
* In a desktop environment, if newTab is true, it will start
|
||||
* a new 'about:blank' tab and change focus to this tab.
|
||||
*
|
||||
* This will also set the active messagemanager for this object
|
||||
*
|
||||
* @param boolean newTab
|
||||
* If true, create new tab
|
||||
*/
|
||||
startSession: function BO_startSession(newTab, win, callback) {
|
||||
if (appName != "Firefox") {
|
||||
callback(win, newTab);
|
||||
}
|
||||
else if (newTab) {
|
||||
this.tab = this.addTab(this.startPage);
|
||||
//if we have a new tab, make it the selected tab
|
||||
this.browser.selectedTab = this.tab;
|
||||
let newTabBrowser = this.browser.getBrowserForTab(this.tab);
|
||||
// wait for tab to be loaded
|
||||
newTabBrowser.addEventListener("load", function onLoad() {
|
||||
newTabBrowser.removeEventListener("load", onLoad, true);
|
||||
callback(win, newTab);
|
||||
}, true);
|
||||
}
|
||||
else {
|
||||
startSession: function BO_startSession(newSession, win, callback) {
|
||||
if (appName == "Firefox") {
|
||||
//set this.tab to the currently focused tab
|
||||
if (this.browser != undefined && this.browser.selectedTab != undefined) {
|
||||
this.tab = this.browser.selectedTab;
|
||||
}
|
||||
callback(win, newTab);
|
||||
}
|
||||
callback(win, newSession);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -2926,19 +2899,26 @@ BrowserObj.prototype = {
|
||||
* or b) we're starting a new session and it is the right start frame.
|
||||
*
|
||||
* @param string uid
|
||||
* frame uid
|
||||
* @param object frameWindow
|
||||
* the DOMWindow object of the frame that's being registered
|
||||
* frame uid for use by marionette
|
||||
* @param number id
|
||||
* incoming window id assigned by gecko
|
||||
*/
|
||||
register: function BO_register(uid, frameWindow) {
|
||||
register: function BO_register(uid, id) {
|
||||
if (this.curFrameId == null) {
|
||||
// If we're setting up a new session on Firefox, we only process the
|
||||
// registration for this frame if it belongs to the tab we've just
|
||||
// created.
|
||||
let currWinId = null;
|
||||
if (this.browser) {
|
||||
// If we're setting up a new session on Firefox, we only process the
|
||||
// registration for this frame if it belongs to the tab we've just
|
||||
// created.
|
||||
let winAsCPOW = this.browser.getBrowserForTab(this.tab).contentWindowAsCPOW;
|
||||
currWinId = winAsCPOW.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsIDOMWindowUtils)
|
||||
.outerWindowID;
|
||||
}
|
||||
if ((!this.newSession) ||
|
||||
(this.newSession &&
|
||||
((appName != "Firefox") ||
|
||||
frameWindow == this.browser.getBrowserForTab(this.tab).contentWindow))) {
|
||||
id === currWinId))) {
|
||||
this.curFrameId = uid;
|
||||
this.mainContentId = uid;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user