--- a/testing/marionette/listener.js
+++ b/testing/marionette/listener.js
@@ -21,16 +21,17 @@ Cu.import("chrome://marionette/content/e
Cu.import("chrome://marionette/content/error.js");
Cu.import("chrome://marionette/content/evaluate.js");
Cu.import("chrome://marionette/content/event.js");
Cu.import("chrome://marionette/content/interaction.js");
Cu.import("chrome://marionette/content/legacyaction.js");
Cu.import("chrome://marionette/content/logging.js");
Cu.import("chrome://marionette/content/navigate.js");
Cu.import("chrome://marionette/content/proxy.js");
+Cu.import("chrome://marionette/content/session.js");
Cu.import("chrome://marionette/content/simpletest.js");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.importGlobalProperties(["URL"]);
@@ -53,17 +54,17 @@ var SUPPORTED_STRATEGIES = new Set([
element.Strategy.ID,
element.Strategy.Name,
element.Strategy.LinkText,
element.Strategy.PartialLinkText,
element.Strategy.TagName,
element.Strategy.XPath,
]);
-var capabilities = {};
+var capabilities;
var legacyactions = new legacyaction.Chain(checkForInterrupted);
// the unload handler
var onunload;
// Flag to indicate whether an async script is currently running or not.
var asyncTestRunning = false;
@@ -118,17 +119,17 @@ var sandboxName = "default";
*/
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 = register[0][2];
+ capabilities = session.Capabilities.fromJSON(register[0][2]);
listenerId = id;
if (typeof id != "undefined") {
// check if we're the main process
if (register[0][1]) {
addMessageListener("MarionetteMainListener:emitTouchEvent", emitTouchEventForIFrame);
}
startListeners();
let rv = {};
@@ -316,18 +317,18 @@ function waitForReady() {
}
}
/**
* Called when we start a new session. It registers the
* current environment, and resets all values
*/
function newSession(msg) {
- capabilities = msg.json;
- isB2G = capabilities.platformName == "B2G";
+ capabilities = session.Capabilities.fromJSON(msg.json);
+ isB2G = capabilities.get("platformName") === "B2G";
resetValues();
if (isB2G) {
readyStateTimer.initWithCallback(waitForReady, 100, Ci.nsITimer.TYPE_ONE_SHOT);
// We have to set correct mouse event source to MOZ_SOURCE_TOUCH
// to offer a way for event listeners to differentiate
// events being the result of a physical mouse action.
// This is especially important for the touch event shim,
// in order to prevent creating touch event for these fake mouse events.
@@ -641,17 +642,17 @@ function emitTouchEvent(type, touch) {
function singleTap(id, corx, cory) {
let el = seenEls.get(id, curContainer);
// after this block, the element will be scrolled into view
let visible = element.isVisible(el, corx, cory);
if (!visible) {
throw new ElementNotVisibleError("Element is not currently visible and may not be manipulated");
}
- let a11y = accessibility.get(capabilities["moz:accessibilityChecks"]);
+ let a11y = accessibility.get(capabilities.get("moz:accessibilityChecks"));
return a11y.getAccessible(el, true).then(acc => {
a11y.assertVisible(acc, el, visible);
a11y.assertActionable(acc, el);
if (!curContainer.frame.document.createTouch) {
legacyactions.mouseEventsOnly = true;
}
let c = element.coordinates(el, corx, cory);
if (!legacyactions.mouseEventsOnly) {
@@ -1201,18 +1202,18 @@ function getActiveElement() {
*
* @param {WebElement} id
* Reference to the web element to click.
*/
function clickElement(id) {
let el = seenEls.get(id, curContainer);
return interaction.clickElement(
el,
- !!capabilities["moz:accessibilityChecks"],
- capabilities.specificationLevel >= 1);
+ capabilities.get("moz:accessibilityChecks"),
+ capabilities.get("specificationLevel") >= 1);
}
function getElementAttribute(id, name) {
let el = seenEls.get(id, curContainer);
if (element.isBooleanAttribute(el, name)) {
if (el.hasAttribute(name)) {
return "true";
} else {
@@ -1260,17 +1261,17 @@ function getElementTagName(id) {
* Determine the element displayedness of the given web element.
*
* Also performs additional accessibility checks if enabled by session
* capability.
*/
function isElementDisplayed(id) {
let el = seenEls.get(id, curContainer);
return interaction.isElementDisplayed(
- el, capabilities["moz:accessibilityChecks"]);
+ el, capabilities.get("moz:accessibilityChecks"));
}
/**
* Retrieves the computed value of the given CSS property of the given
* web element.
*
* @param {String} id
* Web element reference.
@@ -1313,39 +1314,39 @@ function getElementRect(id) {
* Reference to web element.
*
* @return {boolean}
* True if enabled, false otherwise.
*/
function isElementEnabled(id) {
let el = seenEls.get(id, curContainer);
return interaction.isElementEnabled(
- el, capabilities["moz:accessibilityChecks"]);
+ el, capabilities.get("moz:accessibilityChecks"));
}
/**
* Determines if the referenced element is selected or not.
*
* This operation only makes sense on input elements of the Checkbox-
* and Radio Button states, or option elements.
*/
function isElementSelected(id) {
let el = seenEls.get(id, curContainer);
return interaction.isElementSelected(
- el, capabilities["moz:accessibilityChecks"]);
+ el, capabilities.get("moz:accessibilityChecks"));
}
function* sendKeysToElement(id, val) {
let el = seenEls.get(id, curContainer);
if (el.type == "file") {
let path = val.join("");
yield interaction.uploadFile(el, path);
} else {
yield interaction.sendKeysToElement(
- el, val, false, capabilities["moz:accessibilityChecks"]);
+ el, val, false, capabilities.get("moz:accessibilityChecks"));
}
}
/**
* Clear the text of an element.
*/
function clearElement(id) {
try {