Bug 1243415 - Check for a valid DOMWindow for screenshot in chrome scope.
By the webdriver spec the code has to fail with a NoSuchWindowError if the
active window is no longer present.
MozReview-Commit-ID: HFl7yO5ErRn
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2407,19 +2407,24 @@ GeckoDriver.prototype.clearImportedScrip
*/
GeckoDriver.prototype.takeScreenshot = function (cmd, resp) {
let {id, highlights, full, hash} = cmd.parameters;
highlights = highlights || [];
switch (this.context) {
case Context.CHROME:
let canvas;
- let container = {frame: this.getCurrentWindow()};
let highlightEls = [];
+ let container = {frame: this.getCurrentWindow().document.defaultView};
+
+ if (!container.frame) {
+ throw new NoSuchWindowError('Unable to locate window');
+ }
+
for (let h of highlights) {
let el = this.curBrowser.seenEls.get(h, container);
highlightEls.push(el);
}
// viewport
if (!id && !full) {
canvas = capture.viewport(container.frame, highlightEls);