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

RESOLVED INVALID

Status

defect
RESOLVED INVALID
3 years ago
3 years ago

People

(Reporter: whimboo, Unassigned)

Tracking

(Blocks 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

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')
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.
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"
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
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.