зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 2da5d0c57ecd (bug 1322383)
This commit is contained in:
Родитель
4721df0eef
Коммит
ce42d563b4
|
@ -117,25 +117,6 @@ assert.mobile = function (msg = "") {
|
|||
assert.that(() => isFennec() || isB2G(), msg, UnsupportedOperationError)();
|
||||
};
|
||||
|
||||
/**
|
||||
* Asserts that |win| is open.
|
||||
*
|
||||
* @param {ChromeWindow} win
|
||||
* Chrome window to test.
|
||||
* @param {string=} msg
|
||||
* Custom error message.
|
||||
*
|
||||
* @return {ChromeWindow}
|
||||
* |win| is returned unaltered.
|
||||
*
|
||||
* @throws {NoSuchWindowError}
|
||||
* If |win| has been closed.
|
||||
*/
|
||||
assert.window = function (win, msg = "") {
|
||||
msg = msg || "Unable to locate window";
|
||||
return assert.that(w => w && w.document.defaultView, msg, NoSuchWindowError)(win);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that |obj| is defined.
|
||||
*
|
||||
|
|
|
@ -305,34 +305,22 @@ GeckoDriver.prototype.sendTargettedAsyncMessage_ = function (name, payload) {
|
|||
/**
|
||||
* Gets the current active window.
|
||||
*
|
||||
* @param {Context=} forcedContext
|
||||
* Optional name of the context to use for the checks.
|
||||
* Defaults to the current context.
|
||||
*
|
||||
* @return {nsIDOMWindow}
|
||||
*/
|
||||
GeckoDriver.prototype.getCurrentWindow = function (forcedContext = undefined) {
|
||||
let context = typeof forcedContext == "undefined" ? this.context : forcedContext;
|
||||
let win = null;
|
||||
|
||||
GeckoDriver.prototype.getCurrentWindow = function() {
|
||||
let typ = null;
|
||||
if (this.curFrame === null) {
|
||||
if (this.curBrowser === null) {
|
||||
let typ = (context === Context.CONTENT) ? "navigator:browser" : null;
|
||||
win = Services.wm.getMostRecentWindow(typ);
|
||||
} else {
|
||||
if (context === Context.CHROME) {
|
||||
win = this.curBrowser.window;
|
||||
} else {
|
||||
if (this.curBrowser.tab && browser.getBrowserForTab(this.curBrowser.tab)) {
|
||||
win = this.curBrowser.window;
|
||||
}
|
||||
if (this.context == Context.CONTENT) {
|
||||
typ = "navigator:browser";
|
||||
}
|
||||
return Services.wm.getMostRecentWindow(typ);
|
||||
} else {
|
||||
return this.curBrowser.window;
|
||||
}
|
||||
} else {
|
||||
win = this.curFrame;
|
||||
return this.curFrame;
|
||||
}
|
||||
|
||||
return win;
|
||||
};
|
||||
|
||||
GeckoDriver.prototype.addFrameCloseListener = function (action) {
|
||||
|
@ -759,8 +747,6 @@ GeckoDriver.prototype.getContext = function (cmd, resp) {
|
|||
* If an Error was thrown whilst evaluating the script.
|
||||
*/
|
||||
GeckoDriver.prototype.executeScript = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let {script, args, scriptTimeout} = cmd.parameters;
|
||||
scriptTimeout = scriptTimeout || this.timeouts.script;
|
||||
|
||||
|
@ -834,8 +820,6 @@ GeckoDriver.prototype.executeScript = function*(cmd, resp) {
|
|||
* If an Error was thrown whilst evaluating the script.
|
||||
*/
|
||||
GeckoDriver.prototype.executeAsyncScript = function* (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let {script, args, scriptTimeout} = cmd.parameters;
|
||||
scriptTimeout = scriptTimeout || this.timeouts.script;
|
||||
|
||||
|
@ -886,8 +870,6 @@ GeckoDriver.prototype.execute_ = function (script, args, timeout, opts = {}) {
|
|||
* Scripts are expected to call the {@code finish} global when done.
|
||||
*/
|
||||
GeckoDriver.prototype.executeJSScript = function* (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {script, args, scriptTimeout} = cmd.parameters;
|
||||
scriptTimeout = scriptTimeout || this.timeouts.script;
|
||||
|
||||
|
@ -899,6 +881,7 @@ GeckoDriver.prototype.executeJSScript = function* (cmd, resp) {
|
|||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let wargs = element.fromJson(args, this.curBrowser.seenEls, win);
|
||||
let harness = new simpletest.Harness(
|
||||
win,
|
||||
|
@ -947,7 +930,6 @@ GeckoDriver.prototype.executeJSScript = function* (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.get = function*(cmd, resp) {
|
||||
assert.content(this.context);
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let url = cmd.parameters.url;
|
||||
|
||||
|
@ -983,23 +965,21 @@ GeckoDriver.prototype.get = function*(cmd, resp) {
|
|||
* of the current resource.
|
||||
*/
|
||||
GeckoDriver.prototype.getCurrentUrl = function (cmd) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
return win.location.href;
|
||||
return this.getCurrentWindow().location.href;
|
||||
|
||||
case Context.CONTENT:
|
||||
return this.listener.getCurrentUrl();
|
||||
let isB2G = this.appName == "B2G";
|
||||
return this.listener.getCurrentUrl(isB2G);
|
||||
}
|
||||
};
|
||||
|
||||
/** Gets the current title of the window. */
|
||||
GeckoDriver.prototype.getTitle = function* (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
resp.body.value = win.document.documentElement.getAttribute("title");
|
||||
break;
|
||||
|
||||
|
@ -1011,17 +991,15 @@ GeckoDriver.prototype.getTitle = function* (cmd, resp) {
|
|||
|
||||
/** Gets the current type of the window. */
|
||||
GeckoDriver.prototype.getWindowType = function (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let win = this.getCurrentWindow();
|
||||
resp.body.value = win.document.documentElement.getAttribute("windowtype");
|
||||
};
|
||||
|
||||
/** Gets the page source of the content document. */
|
||||
GeckoDriver.prototype.getPageSource = function* (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let s = new win.XMLSerializer();
|
||||
resp.body.value = s.serializeToString(win.document);
|
||||
break;
|
||||
|
@ -1038,7 +1016,6 @@ GeckoDriver.prototype.getPageSource = function* (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.goBack = function* (cmd, resp) {
|
||||
assert.content(this.context);
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
if (!this.curBrowser.tab) {
|
||||
// Navigation does not work for non-browser windows
|
||||
|
@ -1080,7 +1057,6 @@ GeckoDriver.prototype.goBack = function* (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.goForward = function* (cmd, resp) {
|
||||
assert.content(this.context);
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
if (!this.curBrowser.tab) {
|
||||
// Navigation does not work for non-browser windows
|
||||
|
@ -1119,7 +1095,6 @@ GeckoDriver.prototype.goForward = function* (cmd, resp) {
|
|||
/** Refresh the page. */
|
||||
GeckoDriver.prototype.refresh = function*(cmd, resp) {
|
||||
assert.content(this.context);
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
yield this.listener.refresh();
|
||||
};
|
||||
|
@ -1166,8 +1141,6 @@ GeckoDriver.prototype.getIdForBrowser = function (browser) {
|
|||
* Unique window handle.
|
||||
*/
|
||||
GeckoDriver.prototype.getWindowHandle = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow(Context.CONTENT));
|
||||
|
||||
// curFrameId always holds the current tab.
|
||||
if (this.curBrowser.curFrameId) {
|
||||
resp.body.value = this.curBrowser.curFrameId;
|
||||
|
@ -1209,8 +1182,6 @@ GeckoDriver.prototype.getWindowHandles = function (cmd, resp) {
|
|||
* Unique window handle.
|
||||
*/
|
||||
GeckoDriver.prototype.getChromeWindowHandle = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow(Context.CHROME));
|
||||
|
||||
for (let i in this.browsers) {
|
||||
if (this.curBrowser == this.browsers[i]) {
|
||||
resp.body.value = i;
|
||||
|
@ -1237,8 +1208,7 @@ GeckoDriver.prototype.getChromeWindowHandles = function (cmd, resp) {
|
|||
* Object with |x| and |y| coordinates.
|
||||
*/
|
||||
GeckoDriver.prototype.getWindowPosition = function (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let win = this.getCurrentWindow();
|
||||
return {
|
||||
x: win.screenX,
|
||||
y: win.screenY,
|
||||
|
@ -1364,8 +1334,6 @@ GeckoDriver.prototype.switchToWindow = function* (cmd, resp) {
|
|||
};
|
||||
|
||||
GeckoDriver.prototype.getActiveFrame = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// no frame means top-level
|
||||
|
@ -1389,8 +1357,6 @@ GeckoDriver.prototype.getActiveFrame = function (cmd, resp) {
|
|||
};
|
||||
|
||||
GeckoDriver.prototype.switchToParentFrame = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let res = yield this.listener.switchToParentFrame();
|
||||
};
|
||||
|
||||
|
@ -1404,8 +1370,6 @@ GeckoDriver.prototype.switchToParentFrame = function*(cmd, resp) {
|
|||
* or index of the frame to switch to.
|
||||
*/
|
||||
GeckoDriver.prototype.switchToFrame = function* (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, element, focus} = cmd.parameters;
|
||||
|
||||
const otherErrorsExpr = /about:.+(error)|(blocked)\?/;
|
||||
|
@ -1597,8 +1561,6 @@ GeckoDriver.prototype.setTimeouts = function (cmd, resp) {
|
|||
|
||||
/** Single tap. */
|
||||
GeckoDriver.prototype.singleTap = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, x, y} = cmd.parameters;
|
||||
|
||||
switch (this.context) {
|
||||
|
@ -1623,8 +1585,6 @@ GeckoDriver.prototype.singleTap = function*(cmd, resp) {
|
|||
* If the command is made in chrome context.
|
||||
*/
|
||||
GeckoDriver.prototype.performActions = function(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
throw new UnsupportedOperationError(
|
||||
|
@ -1639,8 +1599,6 @@ GeckoDriver.prototype.performActions = function(cmd, resp) {
|
|||
* Release all the keys and pointer buttons that are currently depressed.
|
||||
*/
|
||||
GeckoDriver.prototype.releaseActions = function(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
throw new UnsupportedOperationError(
|
||||
|
@ -1662,16 +1620,15 @@ GeckoDriver.prototype.releaseActions = function(cmd, resp) {
|
|||
* Last touch ID.
|
||||
*/
|
||||
GeckoDriver.prototype.actionChain = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {chain, nextId} = cmd.parameters;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// be conservative until this has a use case and is established
|
||||
// to work as expected in Fennec
|
||||
assert.firefox();
|
||||
assert.firefox()
|
||||
|
||||
let win = this.getCurrentWindow();
|
||||
resp.body.value = yield this.legacyactions.dispatchActions(
|
||||
chain, nextId, {frame: win}, this.curBrowser.seenEls);
|
||||
break;
|
||||
|
@ -1692,8 +1649,6 @@ GeckoDriver.prototype.actionChain = function*(cmd, resp) {
|
|||
* finger, and the outer array represents all fingers.
|
||||
*/
|
||||
GeckoDriver.prototype.multiAction = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
throw new UnsupportedOperationError(
|
||||
|
@ -1715,8 +1670,6 @@ GeckoDriver.prototype.multiAction = function*(cmd, resp) {
|
|||
* Value the client is looking for.
|
||||
*/
|
||||
GeckoDriver.prototype.findElement = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let strategy = cmd.parameters.using;
|
||||
let expr = cmd.parameters.value;
|
||||
let opts = {
|
||||
|
@ -1731,7 +1684,7 @@ GeckoDriver.prototype.findElement = function*(cmd, resp) {
|
|||
throw new InvalidSelectorError(`Strategy not supported: ${strategy}`);
|
||||
}
|
||||
|
||||
let container = {frame: win};
|
||||
let container = {frame: this.getCurrentWindow()};
|
||||
if (opts.startNode) {
|
||||
opts.startNode = this.curBrowser.seenEls.get(opts.startNode, container);
|
||||
}
|
||||
|
@ -1760,8 +1713,6 @@ GeckoDriver.prototype.findElement = function*(cmd, resp) {
|
|||
* Value the client is looking for.
|
||||
*/
|
||||
GeckoDriver.prototype.findElements = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let strategy = cmd.parameters.using;
|
||||
let expr = cmd.parameters.value;
|
||||
let opts = {
|
||||
|
@ -1776,7 +1727,7 @@ GeckoDriver.prototype.findElements = function*(cmd, resp) {
|
|||
throw new InvalidSelectorError(`Strategy not supported: ${strategy}`);
|
||||
}
|
||||
|
||||
let container = {frame: win};
|
||||
let container = {frame: this.getCurrentWindow()};
|
||||
if (opts.startNode) {
|
||||
opts.startNode = this.curBrowser.seenEls.get(opts.startNode, container);
|
||||
}
|
||||
|
@ -1798,8 +1749,6 @@ GeckoDriver.prototype.findElements = function*(cmd, resp) {
|
|||
|
||||
/** Return the active element on the page. */
|
||||
GeckoDriver.prototype.getActiveElement = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
throw new UnsupportedOperationError(
|
||||
|
@ -1818,12 +1767,11 @@ GeckoDriver.prototype.getActiveElement = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be clicked.
|
||||
*/
|
||||
GeckoDriver.prototype.clickElement = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
yield interaction.clickElement(el, this.a11yChecks);
|
||||
break;
|
||||
|
@ -1851,12 +1799,11 @@ GeckoDriver.prototype.clickElement = function*(cmd, resp) {
|
|||
* Value of the attribute.
|
||||
*/
|
||||
GeckoDriver.prototype.getElementAttribute = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, name} = cmd.parameters;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
|
||||
resp.body.value = el.getAttribute(name);
|
||||
|
@ -1880,12 +1827,11 @@ GeckoDriver.prototype.getElementAttribute = function*(cmd, resp) {
|
|||
* Value of the property.
|
||||
*/
|
||||
GeckoDriver.prototype.getElementProperty = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, name} = cmd.parameters;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
resp.body.value = el[name];
|
||||
break;
|
||||
|
@ -1904,13 +1850,12 @@ GeckoDriver.prototype.getElementProperty = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be inspected.
|
||||
*/
|
||||
GeckoDriver.prototype.getElementText = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// for chrome, we look at text nodes, and any node with a "label" field
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
let lines = [];
|
||||
this.getVisibleText(el, lines);
|
||||
|
@ -1930,12 +1875,11 @@ GeckoDriver.prototype.getElementText = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be inspected.
|
||||
*/
|
||||
GeckoDriver.prototype.getElementTagName = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
resp.body.value = el.tagName.toLowerCase();
|
||||
break;
|
||||
|
@ -1953,12 +1897,11 @@ GeckoDriver.prototype.getElementTagName = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be inspected.
|
||||
*/
|
||||
GeckoDriver.prototype.isElementDisplayed = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
resp.body.value = yield interaction.isElementDisplayed(
|
||||
el, this.a11yChecks);
|
||||
|
@ -1979,12 +1922,11 @@ GeckoDriver.prototype.isElementDisplayed = function*(cmd, resp) {
|
|||
* CSS rule that is being requested.
|
||||
*/
|
||||
GeckoDriver.prototype.getElementValueOfCssProperty = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, propertyName: prop} = cmd.parameters;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
let sty = win.document.defaultView.getComputedStyle(el);
|
||||
resp.body.value = sty.getPropertyValue(prop);
|
||||
|
@ -2003,13 +1945,12 @@ GeckoDriver.prototype.getElementValueOfCssProperty = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be checked.
|
||||
*/
|
||||
GeckoDriver.prototype.isElementEnabled = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// Selenium atom doesn't quite work here
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
resp.body.value = yield interaction.isElementEnabled(
|
||||
el, this.a11yChecks);
|
||||
|
@ -2028,13 +1969,12 @@ GeckoDriver.prototype.isElementEnabled = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be checked.
|
||||
*/
|
||||
GeckoDriver.prototype.isElementSelected = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// Selenium atom doesn't quite work here
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
resp.body.value = yield interaction.isElementSelected(
|
||||
el, this.a11yChecks);
|
||||
|
@ -2047,12 +1987,11 @@ GeckoDriver.prototype.isElementSelected = function*(cmd, resp) {
|
|||
};
|
||||
|
||||
GeckoDriver.prototype.getElementRect = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
let rect = el.getBoundingClientRect();
|
||||
resp.body = {
|
||||
|
@ -2078,13 +2017,12 @@ GeckoDriver.prototype.getElementRect = function*(cmd, resp) {
|
|||
* Value to send to the element.
|
||||
*/
|
||||
GeckoDriver.prototype.sendKeysToElement = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, value} = cmd.parameters;
|
||||
assert.defined(value, `Expected character sequence: ${value}`);
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
yield interaction.sendKeysToElement(
|
||||
el, value, true, this.a11yChecks);
|
||||
|
@ -2098,8 +2036,6 @@ GeckoDriver.prototype.sendKeysToElement = function*(cmd, resp) {
|
|||
|
||||
/** Sets the test name. The test name is used for logging purposes. */
|
||||
GeckoDriver.prototype.setTestName = function*(cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let val = cmd.parameters.value;
|
||||
this.testName = val;
|
||||
yield this.listener.setTestName({value: val});
|
||||
|
@ -2112,13 +2048,12 @@ GeckoDriver.prototype.setTestName = function*(cmd, resp) {
|
|||
* Reference ID to the element that will be cleared.
|
||||
*/
|
||||
GeckoDriver.prototype.clearElement = function*(cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let id = cmd.parameters.id;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
// the selenium atom doesn't work here
|
||||
let win = this.getCurrentWindow();
|
||||
let el = this.curBrowser.seenEls.get(id, {frame: win});
|
||||
if (el.nodeName == "textbox") {
|
||||
el.value = "";
|
||||
|
@ -2140,7 +2075,6 @@ GeckoDriver.prototype.clearElement = function*(cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.switchToShadowRoot = function*(cmd, resp) {
|
||||
assert.content(this.context)
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let id;
|
||||
if (cmd.parameters) { id = cmd.parameters.id; }
|
||||
|
@ -2150,7 +2084,6 @@ GeckoDriver.prototype.switchToShadowRoot = function*(cmd, resp) {
|
|||
/** Add a cookie to the document. */
|
||||
GeckoDriver.prototype.addCookie = function*(cmd, resp) {
|
||||
assert.content(this.context)
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let cb = msg => {
|
||||
this.mm.removeMessageListener("Marionette:addCookie", cb);
|
||||
|
@ -2180,7 +2113,6 @@ GeckoDriver.prototype.addCookie = function*(cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.getCookies = function*(cmd, resp) {
|
||||
assert.content(this.context)
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
resp.body = yield this.listener.getCookies();
|
||||
};
|
||||
|
@ -2188,7 +2120,6 @@ GeckoDriver.prototype.getCookies = function*(cmd, resp) {
|
|||
/** Delete all cookies that are visible to a document. */
|
||||
GeckoDriver.prototype.deleteAllCookies = function*(cmd, resp) {
|
||||
assert.content(this.context)
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let cb = msg => {
|
||||
let cookie = msg.json;
|
||||
|
@ -2209,7 +2140,6 @@ GeckoDriver.prototype.deleteAllCookies = function*(cmd, resp) {
|
|||
/** Delete a cookie by name. */
|
||||
GeckoDriver.prototype.deleteCookie = function*(cmd, resp) {
|
||||
assert.content(this.context)
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let cb = msg => {
|
||||
this.mm.removeMessageListener("Marionette:deleteCookie", cb);
|
||||
|
@ -2239,11 +2169,9 @@ GeckoDriver.prototype.deleteCookie = function*(cmd, resp) {
|
|||
* Unique window handles of remaining windows.
|
||||
*/
|
||||
GeckoDriver.prototype.close = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
let nwins = 0;
|
||||
|
||||
let winEn = Services.wm.getEnumerator(null);
|
||||
|
||||
while (winEn.hasMoreElements()) {
|
||||
let win = winEn.getNext();
|
||||
|
||||
|
@ -2282,11 +2210,11 @@ GeckoDriver.prototype.close = function (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.closeChromeWindow = function (cmd, resp) {
|
||||
assert.firefox();
|
||||
assert.window(this.getCurrentWindow(Context.CHROME));
|
||||
|
||||
// Get the total number of windows
|
||||
let nwins = 0;
|
||||
|
||||
let winEn = Services.wm.getEnumerator(null);
|
||||
|
||||
while (winEn.hasMoreElements()) {
|
||||
nwins++;
|
||||
winEn.getNext();
|
||||
|
@ -2367,8 +2295,6 @@ GeckoDriver.prototype.deleteSession = function (cmd, resp) {
|
|||
|
||||
/** Returns the current status of the Application Cache. */
|
||||
GeckoDriver.prototype.getAppCacheStatus = function* (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
throw new UnsupportedOperationError(
|
||||
|
@ -2441,15 +2367,16 @@ GeckoDriver.prototype.clearImportedScripts = function*(cmd, resp) {
|
|||
* string.
|
||||
*/
|
||||
GeckoDriver.prototype.takeScreenshot = function (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let {id, highlights, full, hash, scroll} = cmd.parameters;
|
||||
highlights = highlights || [];
|
||||
let format = hash ? capture.Format.Hash : capture.Format.Base64;
|
||||
|
||||
switch (this.context) {
|
||||
case Context.CHROME:
|
||||
let container = {frame: win.document.defaultView};
|
||||
let container = {frame: this.getCurrentWindow().document.defaultView};
|
||||
if (!container.frame) {
|
||||
throw new NoSuchWindowError("Unable to locate window");
|
||||
}
|
||||
|
||||
let highlightEls = highlights.map(
|
||||
ref => this.curBrowser.seenEls.get(ref, container));
|
||||
|
@ -2494,9 +2421,8 @@ GeckoDriver.prototype.takeScreenshot = function (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.getScreenOrientation = function (cmd, resp) {
|
||||
assert.fennec();
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
resp.body.value = win.screen.mozOrientation;
|
||||
resp.body.value = this.getCurrentWindow().screen.mozOrientation;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -2512,7 +2438,6 @@ GeckoDriver.prototype.getScreenOrientation = function (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.setScreenOrientation = function (cmd, resp) {
|
||||
assert.fennec();
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
const ors = [
|
||||
"portrait", "landscape",
|
||||
|
@ -2527,6 +2452,7 @@ GeckoDriver.prototype.setScreenOrientation = function (cmd, resp) {
|
|||
throw new InvalidArgumentError(`Unknown screen orientation: ${or}`);
|
||||
}
|
||||
|
||||
let win = this.getCurrentWindow();
|
||||
if (!win.screen.mozLockOrientation(mozOr)) {
|
||||
throw new WebDriverError(`Unable to set screen orientation: ${or}`);
|
||||
}
|
||||
|
@ -2540,7 +2466,7 @@ GeckoDriver.prototype.setScreenOrientation = function (cmd, resp) {
|
|||
* title bars, etc.
|
||||
*/
|
||||
GeckoDriver.prototype.getWindowSize = function (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
let win = this.getCurrentWindow();
|
||||
return {
|
||||
width: win.outerWidth,
|
||||
height: win.outerHeight,
|
||||
|
@ -2564,9 +2490,9 @@ GeckoDriver.prototype.getWindowSize = function (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.setWindowSize = function* (cmd, resp) {
|
||||
assert.firefox()
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
const {width, height} = cmd.parameters;
|
||||
const win = this.getCurrentWindow();
|
||||
|
||||
yield new Promise(resolve => {
|
||||
// When the DOM resize event claims that it fires _after_ the document
|
||||
|
@ -2598,8 +2524,8 @@ GeckoDriver.prototype.setWindowSize = function* (cmd, resp) {
|
|||
*/
|
||||
GeckoDriver.prototype.maximizeWindow = function (cmd, resp) {
|
||||
assert.firefox()
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
|
||||
let win = this.getCurrentWindow();
|
||||
win.maximize()
|
||||
};
|
||||
|
||||
|
@ -2608,7 +2534,6 @@ GeckoDriver.prototype.maximizeWindow = function (cmd, resp) {
|
|||
* no modal is displayed.
|
||||
*/
|
||||
GeckoDriver.prototype.dismissDialog = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
this._checkIfAlertIsPresent();
|
||||
|
||||
let {button0, button1} = this.dialog.ui;
|
||||
|
@ -2621,7 +2546,6 @@ GeckoDriver.prototype.dismissDialog = function (cmd, resp) {
|
|||
* no modal is displayed.
|
||||
*/
|
||||
GeckoDriver.prototype.acceptDialog = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
this._checkIfAlertIsPresent();
|
||||
|
||||
let {button0} = this.dialog.ui;
|
||||
|
@ -2634,7 +2558,6 @@ GeckoDriver.prototype.acceptDialog = function (cmd, resp) {
|
|||
* alert error if no modal is currently displayed.
|
||||
*/
|
||||
GeckoDriver.prototype.getTextFromDialog = function (cmd, resp) {
|
||||
assert.window(this.getCurrentWindow());
|
||||
this._checkIfAlertIsPresent();
|
||||
|
||||
let {infoBody} = this.dialog.ui;
|
||||
|
@ -2648,7 +2571,6 @@ GeckoDriver.prototype.getTextFromDialog = function (cmd, resp) {
|
|||
* an element not visible error is returned.
|
||||
*/
|
||||
GeckoDriver.prototype.sendKeysToDialog = function (cmd, resp) {
|
||||
let win = assert.window(this.getCurrentWindow());
|
||||
this._checkIfAlertIsPresent();
|
||||
|
||||
// see toolkit/components/prompts/content/commonDialog.js
|
||||
|
@ -2657,11 +2579,12 @@ GeckoDriver.prototype.sendKeysToDialog = function (cmd, resp) {
|
|||
throw new ElementNotVisibleError("This prompt does not accept text input");
|
||||
}
|
||||
|
||||
let win = this.dialog.window ? this.dialog.window : this.getCurrentWindow();
|
||||
event.sendKeysToElement(
|
||||
cmd.parameters.value,
|
||||
loginTextbox,
|
||||
{ignoreVisibility: true},
|
||||
this.dialog.window ? this.dialog.window : win);
|
||||
win);
|
||||
};
|
||||
|
||||
GeckoDriver.prototype._checkIfAlertIsPresent = function() {
|
||||
|
|
|
@ -4,31 +4,26 @@
|
|||
|
||||
from marionette_driver.by import By
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
from marionette_harness import MarionetteTestCase
|
||||
|
||||
|
||||
class TestClickChrome(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
class TestClickChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestClickChrome, self).setUp()
|
||||
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.root_window = self.marionette.current_window_handle
|
||||
self.marionette.set_context("chrome")
|
||||
self.marionette.execute_script(
|
||||
"window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen')")
|
||||
self.marionette.switch_to_window("foo")
|
||||
self.assertNotEqual(self.root_window, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestClickChrome, self).tearDown()
|
||||
self.assertNotEqual(self.root_window, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close()")
|
||||
self.marionette.switch_to_window(self.root_window)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_click(self):
|
||||
|
||||
def open_with_js():
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen'); """)
|
||||
|
||||
win = self.open_window(open_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
def checked():
|
||||
return self.marionette.execute_script(
|
||||
"return arguments[0].checked",
|
||||
|
|
|
@ -4,37 +4,23 @@
|
|||
|
||||
from marionette_driver.by import By
|
||||
|
||||
from marionette_harness import MarionetteTestCase, skip, WindowManagerMixin
|
||||
from marionette_harness import MarionetteTestCase, skip
|
||||
|
||||
|
||||
class TestElementState(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
class TestIsElementEnabledChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestElementState, self).setUp()
|
||||
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def open_window_with_js():
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
self.win = self.open_window(open_window_with_js)
|
||||
self.marionette.switch_to_window(self.win)
|
||||
self.win = self.marionette.current_window_handle
|
||||
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
|
||||
self.marionette.switch_to_window('foo')
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestElementState, self).tearDown()
|
||||
|
||||
@skip("Switched off in bug 896043, and to be turned on in bug 896046")
|
||||
def test_is_displayed(self):
|
||||
l = self.marionette.find_element(By.ID, "textInput")
|
||||
self.assertTrue(l.is_displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = true;", [l])
|
||||
self.assertFalse(l.is_displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = false;", [l])
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_enabled(self):
|
||||
l = self.marionette.find_element(By.ID, "textInput")
|
||||
|
@ -49,10 +35,51 @@ class TestElementState(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertTrue(rect['x'] > 0)
|
||||
self.assertTrue(rect['y'] > 0)
|
||||
|
||||
def test_get_attribute(self):
|
||||
|
||||
@skip("Switched off in bug 896043, and to be turned on in bug 896046")
|
||||
class TestIsElementDisplayed(MarionetteTestCase):
|
||||
def test_isDisplayed(self):
|
||||
l = self.marionette.find_element(By.ID, "textInput")
|
||||
self.assertTrue(l.is_displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = true;", [l])
|
||||
self.assertFalse(l.is_displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = false;", [l])
|
||||
|
||||
|
||||
class TestGetElementAttributeChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.current_window_handle
|
||||
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
|
||||
self.marionette.switch_to_window('foo')
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_get(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
|
||||
self.assertEqual(el.get_attribute("id"), "textInput")
|
||||
|
||||
def test_get_property(self):
|
||||
class TestGetElementProperty(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.current_window_handle
|
||||
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
|
||||
self.marionette.switch_to_window('foo')
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_get(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
|
||||
self.assertEqual(el.get_property("id"), "textInput")
|
||||
|
|
|
@ -314,6 +314,25 @@ class TestExecuteChrome(WindowManagerMixin, TestExecuteContent):
|
|||
setTimeout(function() { cb() }, 250);
|
||||
""", script_timeout=100)
|
||||
|
||||
@skip_if_mobile("New windows not supported in Fennec")
|
||||
def test_invalid_chrome_handle(self):
|
||||
try:
|
||||
win = self.open_window()
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
# Close new window and don't switch back to the original one
|
||||
self.marionette.close_chrome_window()
|
||||
self.assertNotEqual(self.start_window, win)
|
||||
|
||||
# Call execute_script on an invalid chrome handle
|
||||
with self.marionette.using_context('chrome'):
|
||||
self.marionette.execute_script("""
|
||||
return true;
|
||||
""")
|
||||
|
||||
finally:
|
||||
self.close_all_windows()
|
||||
|
||||
def test_lasting_side_effects(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -6,29 +6,23 @@ from marionette_driver.by import By
|
|||
from marionette_driver.errors import NoSuchElementException
|
||||
from marionette_driver.marionette import HTMLElement
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
from marionette_harness import MarionetteTestCase
|
||||
|
||||
|
||||
class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
class TestElementsChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestElementsChrome, self).setUp()
|
||||
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def open_window_with_js():
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
self.win = self.marionette.current_window_handle
|
||||
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
|
||||
self.marionette.switch_to_window('foo')
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestElementsChrome, self).tearDown()
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_id(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
|
||||
|
@ -56,16 +50,14 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
|
|||
self.assertTrue(el.id in [found_el.id for found_el in found_els])
|
||||
|
||||
def test_tag_name(self):
|
||||
el = self.marionette.execute_script(
|
||||
"return window.document.getElementsByTagName('vbox')[0];")
|
||||
el = self.marionette.execute_script("return window.document.getElementsByTagName('vbox')[0];")
|
||||
found_el = self.marionette.find_element(By.TAG_NAME, "vbox")
|
||||
self.assertEquals('vbox', found_el.tag_name)
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertEqual(el, found_el)
|
||||
|
||||
def test_class_name(self):
|
||||
el = self.marionette.execute_script(
|
||||
"return window.document.getElementsByClassName('asdf')[0];")
|
||||
el = self.marionette.execute_script("return window.document.getElementsByClassName('asdf')[0];")
|
||||
found_el = self.marionette.find_element(By.CLASS_NAME, "asdf")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertEqual(el, found_el)
|
||||
|
@ -78,22 +70,13 @@ class TestElementsChrome(WindowManagerMixin, MarionetteTestCase):
|
|||
|
||||
def test_not_found(self):
|
||||
self.marionette.timeout.implicit = 1
|
||||
self.assertRaises(NoSuchElementException,
|
||||
self.marionette.find_element, By.ID, "I'm not on the page")
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
|
||||
self.marionette.timeout.implicit = 0
|
||||
self.assertRaises(NoSuchElementException,
|
||||
self.marionette.find_element, By.ID, "I'm not on the page")
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "I'm not on the page")
|
||||
|
||||
def test_timeout(self):
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, By.ID, "myid")
|
||||
self.marionette.timeout.implicit = 4
|
||||
self.marionette.execute_script("""
|
||||
window.setTimeout(function () {
|
||||
var b = window.document.createElement('button');
|
||||
b.id = 'myid';
|
||||
document.getElementById('things').appendChild(b);
|
||||
}, 1000); """)
|
||||
self.marionette.execute_script("window.setTimeout(function() {var b = window.document.createElement('button'); b.id = 'myid'; document.getElementById('things').appendChild(b);}, 1000)")
|
||||
self.assertEqual(HTMLElement, type(self.marionette.find_element(By.ID, "myid")))
|
||||
self.marionette.execute_script("""
|
||||
var elem = window.document.getElementById('things');
|
||||
elem.removeChild(window.document.getElementById('myid')); """)
|
||||
self.marionette.execute_script("window.document.getElementById('things').removeChild(window.document.getElementById('myid'));")
|
||||
|
|
|
@ -1,168 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from marionette_driver import By
|
||||
from marionette_driver.errors import NoSuchWindowException
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin, skip_if_mobile
|
||||
|
||||
|
||||
class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNoSuchWindowContent, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestNoSuchWindowContent, self).tearDown()
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window(self):
|
||||
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(test_page)
|
||||
self.marionette.find_element(By.ID, "new-window").click()
|
||||
|
||||
win = self.open_window(open_with_link)
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
# When closing a browser window both handles are not available
|
||||
for context in ("chrome", "content"):
|
||||
with self.marionette.using_context(context):
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_chrome_window_handle
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window_while_in_frame(self):
|
||||
|
||||
def open_window_with_js():
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(trigger=open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.switch_to_frame("iframe")
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
def test_closed_tab(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.close()
|
||||
|
||||
# Check that only the content window is not available in both contexts
|
||||
for context in ("chrome", "content"):
|
||||
with self.marionette.using_context(context):
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
|
||||
def test_closed_tab_while_in_frame(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab()
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
|
||||
frame = self.marionette.find_element(By.ID, "test_iframe")
|
||||
self.marionette.switch_to_frame(frame)
|
||||
self.marionette.close()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
|
||||
|
||||
class TestNoSuchWindowChrome(TestNoSuchWindowContent):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNoSuchWindowChrome, self).setUp()
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestNoSuchWindowChrome, self).tearDown()
|
||||
|
||||
|
||||
class TestSwitchWindow(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestSwitchWindow, self).setUp()
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestSwitchWindow, self).tearDown()
|
||||
|
||||
def test_windows(self):
|
||||
def open_browser_with_js():
|
||||
self.marionette.execute_script(" window.open(); ")
|
||||
|
||||
new_window = self.open_window(trigger=open_browser_with_js)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# switch to the other window
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertNotEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
|
||||
# switch back and close original window
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, self.start_window)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
self.assertNotIn(self.start_window, self.marionette.chrome_window_handles)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), len(self.start_windows))
|
||||
|
||||
def test_should_load_and_close_a_window(self):
|
||||
def open_window_with_link():
|
||||
test_html = self.marionette.absolute_url("test_windows.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(test_html)
|
||||
self.marionette.find_element(By.LINK_TEXT, "Open new window").click()
|
||||
|
||||
new_window = self.open_window(trigger=open_window_with_link)
|
||||
self.marionette.switch_to_window(new_window)
|
||||
self.assertEqual(self.marionette.current_chrome_window_handle, new_window)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), 2)
|
||||
|
||||
with self.marionette.using_context('content'):
|
||||
self.assertEqual(self.marionette.title, "We Arrive Here")
|
||||
|
||||
# Let's close and check
|
||||
self.marionette.close_chrome_window()
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
self.assertEqual(len(self.marionette.chrome_window_handles), 1)
|
|
@ -1,24 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
# add this directory to the path
|
||||
sys.path.append(os.path.dirname(__file__))
|
||||
|
||||
from test_window_status_content import TestNoSuchWindowContent
|
||||
|
||||
|
||||
class TestNoSuchWindowChrome(TestNoSuchWindowContent):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNoSuchWindowChrome, self).setUp()
|
||||
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestNoSuchWindowChrome, self).tearDown()
|
|
@ -1,115 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from marionette_driver import By
|
||||
from marionette_driver.errors import NoSuchWindowException
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin, skip_if_mobile
|
||||
|
||||
|
||||
class TestNoSuchWindowContent(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestNoSuchWindowContent, self).setUp()
|
||||
|
||||
self.test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
with self.marionette.using_context("content"):
|
||||
self.marionette.navigate(self.test_page)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
super(TestNoSuchWindowContent, self).tearDown()
|
||||
|
||||
def open_tab_in_foreground(self):
|
||||
with self.marionette.using_context("content"):
|
||||
link = self.marionette.find_element(By.ID, "new-tab")
|
||||
link.click()
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window(self):
|
||||
|
||||
def open_with_link():
|
||||
with self.marionette.using_context("content"):
|
||||
test_page = self.marionette.absolute_url("windowHandles.html")
|
||||
self.marionette.navigate(test_page)
|
||||
self.marionette.find_element(By.ID, "new-window").click()
|
||||
|
||||
win = self.open_window(open_with_link)
|
||||
self.marionette.switch_to_window(win)
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
# When closing a browser window both handles are not available
|
||||
for context in ("chrome", "content"):
|
||||
with self.marionette.using_context(context):
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_chrome_window_handle
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
@skip_if_mobile("Fennec doesn't support other chrome windows")
|
||||
def test_closed_chrome_window_while_in_frame(self):
|
||||
|
||||
def open_window_with_js():
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(trigger=open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
with self.marionette.using_context("chrome"):
|
||||
self.marionette.switch_to_frame("iframe")
|
||||
self.marionette.close_chrome_window()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_window)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
def test_closed_tab(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab(self.open_tab_in_foreground)
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.close()
|
||||
|
||||
# Check that only the content window is not available in both contexts
|
||||
for context in ("chrome", "content"):
|
||||
with self.marionette.using_context(context):
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
||||
|
||||
def test_closed_tab_while_in_frame(self):
|
||||
with self.marionette.using_context("content"):
|
||||
tab = self.open_tab(self.open_tab_in_foreground)
|
||||
self.marionette.switch_to_window(tab)
|
||||
self.marionette.navigate(self.marionette.absolute_url("test_iframe.html"))
|
||||
frame = self.marionette.find_element(By.ID, "test_iframe")
|
||||
self.marionette.switch_to_frame(frame)
|
||||
self.marionette.close()
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.current_window_handle
|
||||
self.marionette.current_chrome_window_handle
|
||||
|
||||
self.marionette.switch_to_window(self.start_tab)
|
||||
|
||||
with self.assertRaises(NoSuchWindowException):
|
||||
self.marionette.switch_to_window(tab)
|
|
@ -2,32 +2,25 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
from marionette_harness import MarionetteTestCase
|
||||
|
||||
|
||||
class TestTitleChrome(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
class TestTitleChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
super(TestTitleChrome, self).setUp()
|
||||
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.current_window_handle
|
||||
self.marionette.execute_script("window.open('chrome://marionette/content/test.xul', 'foo', 'chrome,centerscreen');")
|
||||
self.marionette.switch_to_window('foo')
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestTitleChrome, self).tearDown()
|
||||
self.assertNotEqual(self.win, self.marionette.current_window_handle)
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_get_chrome_title(self):
|
||||
|
||||
def open_window_with_js():
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
title = self.marionette.execute_script(
|
||||
"return window.document.documentElement.getAttribute('title');")
|
||||
title = self.marionette.execute_script("return window.document.documentElement.getAttribute('title');")
|
||||
self.assertEqual(title, self.marionette.title)
|
||||
self.assertEqual('Title Test', self.marionette.title)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from marionette_harness import MarionetteTestCase, WindowManagerMixin
|
||||
|
||||
|
||||
class TestWindowTypeChrome(WindowManagerMixin, MarionetteTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWindowTypeChrome, self).setUp()
|
||||
|
||||
self.marionette.set_context("chrome")
|
||||
|
||||
def tearDown(self):
|
||||
self.close_all_windows()
|
||||
|
||||
super(TestWindowTypeChrome, self).tearDown()
|
||||
|
||||
def test_get_window_type(self):
|
||||
|
||||
def open_window_with_js():
|
||||
self.marionette.execute_script("""
|
||||
window.open('chrome://marionette/content/test.xul',
|
||||
'foo', 'chrome,centerscreen');
|
||||
""")
|
||||
|
||||
win = self.open_window(open_window_with_js)
|
||||
self.marionette.switch_to_window(win)
|
||||
|
||||
window_type = self.marionette.execute_script(
|
||||
"return window.document.documentElement.getAttribute('windowtype');")
|
||||
self.assertEqual(window_type, self.marionette.get_window_type())
|
|
@ -76,15 +76,13 @@ skip-if = appname == 'fennec'
|
|||
[test_window_close_content.py]
|
||||
[test_window_position.py]
|
||||
skip-if = appname == 'fennec'
|
||||
[test_window_status_content.py]
|
||||
[test_window_status_chrome.py]
|
||||
|
||||
[test_screenshot.py]
|
||||
[test_cookies.py]
|
||||
[test_window_title.py]
|
||||
[test_window_title_chrome.py]
|
||||
skip-if = appname == 'fennec'
|
||||
[test_window_type_chrome.py]
|
||||
[test_window_type.py]
|
||||
skip-if = appname == 'fennec'
|
||||
[test_implicit_waits.py]
|
||||
[test_wait.py]
|
||||
|
|
Загрузка…
Ссылка в новой задаче