Bug 1243415 - Check for a valid DOMWindow for screenshot in chrome scope. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 07 Dec 2016 21:47:44 +0100
changeset 454207 de2ba48480b1cab955a908cd51b3ddcd748bece5
parent 454206 543e603b1cecc1f94753de08f9e6cc38e9f33663
child 454208 519615c70c4c55a9498aec313f1646c188ebec03
push id39865
push userbmo:hskupin@gmail.com
push dateWed, 28 Dec 2016 14:56:14 +0000
bugs1243415
milestone53.0a1
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
testing/marionette/driver.js
--- 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);