<commit_before># 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 import By
from marionette.errors import NoSuchWindowException

import firefox_puppeteer.errors as errors

from firefox_ui_harness.testcase import FirefoxTestCase
from firefox_puppeteer.ui.windows import BaseWindow


class TestWindows(FirefoxTestCase):

    def test_windows(self):
        url = self.marionette.absolute_url('layout/mozilla')

        # Open two more windows
        for index in range(0, 2):
            self.marionette.execute_script(""" window.open(); """)

        windows = self.windows.all
        self.assertEquals(len(windows), 3)

        # Switch to the 2nd window
        self.windows.switch_to(windows[1].handle)
        self.assertEquals(windows[1].handle, self.marionette.current_chrome_window_handle)

        # TODO: Needs updated tabs module for improved navigation
        with self.marionette.using_context('content'):
            self.marionette.navigate(url)
<commit_msg>Bug 1131223 - Add teardown to Firefox Puppeteer's test_windows. r=whimboo<commit_after># 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 import By
from marionette.errors import NoSuchWindowException

import firefox_puppeteer.errors as errors

from firefox_ui_harness.testcase import FirefoxTestCase
from firefox_puppeteer.ui.windows import BaseWindow


class TestWindows(FirefoxTestCase):

    def tearDown(self):
        try:
            self.windows.close_all([self.browser])
        finally:
            FirefoxTestCase.tearDown(self)

    def test_windows(self):
        url = self.marionette.absolute_url('layout/mozilla')

        # Open two more windows
        for index in range(0, 2):
            self.marionette.execute_script(""" window.open(); """)

        windows = self.windows.all
        self.assertEquals(len(windows), 3)

        # Switch to the 2nd window
        self.windows.switch_to(windows[1].handle)
        self.assertEquals(windows[1].handle, self.marionette.current_chrome_window_handle)

        # TODO: Needs updated tabs module for improved navigation
        with self.marionette.using_context('content'):
            self.marionette.navigate(url)

{'fraction_non_alphanumeric': 0.0856453558504222, 'fraction_numerical': 0.010856453558504222, 'mean_word_length': 3.2822719449225475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4540471', 'n_tokens_mistral': 747, 'n_tokens_neox': 700, 'n_words': 204}