If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

switch_to_window() fails for dialogs when name specified: "NoSuchWindowException: Unable to locate window: foo"

RESOLVED INVALID

Status

Testing
Marionette
RESOLVED INVALID
a year ago
9 months ago

People

(Reporter: whimboo, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

a year ago
from marionette import MarionetteTestCase


class SwitchWindow(MarionetteTestCase):

    def test_dialog(self):
        self.marionette.set_context("chrome")
        self.marionette.execute_async_script("""
            win = window.open('chrome://marionette/content/test2.xul', 'foo',
                              'dialog,height=200,width=300');

            // Bug 1288339 - We don't wait for readyState to be complete yet
            waitForWindow = function() {
              if (win.document.readyState != 'complete') {
                win.setTimeout(this, 100);
              }

              marionetteScriptFinished(true);
            }()
            """)
        print self.marionette.chrome_window_handles
        self.marionette.switch_to_window(self.marionette.chrome_window_handles[1])
        self.marionette.switch_to_window('foo')
(Reporter)

Comment 1

a year ago
The above code snippet works if you select the newly opened dialog via the outer window id, but it fails when you try to access it via its name.
Blocks: 1288336
Summary: switch_to_window() fails for dialogs when name specified: "NoSuchWindowException: Unable to locate window: foo → switch_to_window() fails for dialogs when name specified: "NoSuchWindowException: Unable to locate window: foo"
(Reporter)

Comment 2

9 months ago
The above testcase is incorrect because it doesn't specify the `chrome` flag for the window.open() method. As such the chrome URL will be opened in a new tab instead of a new window.

The following code which uses the WindowManagerMixin class works:

    def test_dialog(self):
        self.marionette.set_context("chrome")

        def open_with_js():
            self.marionette.execute_script("""
                window.open('chrome://marionette/content/test2.xul', 'foo', 'chrome,dialog');
                """)

        self.open_window(trigger=open_with_js)
        self.marionette.switch_to_window('foo')

As such the bug is invalid.
Status: NEW → RESOLVED
Last Resolved: 9 months ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.