tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_reftest.py (3894B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 from marionette_driver.errors import UnsupportedOperationException
      6 from marionette_harness import MarionetteTestCase, skip
      7 
      8 
      9 class TestReftest(MarionetteTestCase):
     10    def setUp(self):
     11        super(TestReftest, self).setUp()
     12 
     13        self.original_window = self.marionette.current_window_handle
     14 
     15        self.marionette.set_pref("marionette.log.truncate", False)
     16        self.marionette.set_pref("dom.send_after_paint_to_content", True)
     17        self.marionette.set_pref("widget.gtk.overlay-scrollbars.enabled", False)
     18 
     19    def tearDown(self):
     20        try:
     21            # make sure we've teared down any reftest context
     22            self.marionette._send_message("reftest:teardown", {})
     23        except UnsupportedOperationException:
     24            # this will throw if we aren't currently in a reftest context
     25            pass
     26 
     27        self.marionette.switch_to_window(self.original_window)
     28 
     29        self.marionette.clear_pref("dom.send_after_paint_to_content")
     30        self.marionette.clear_pref("marionette.log.truncate")
     31        self.marionette.clear_pref("widget.gtk.overlay-scrollbars.enabled")
     32 
     33        super(TestReftest, self).tearDown()
     34 
     35    @skip("Bug 1648444 - Unexpected page unload when refreshing about:blank")
     36    def test_basic(self):
     37        self.marionette._send_message("reftest:setup", {"screenshot": "unexpected"})
     38        rv = self.marionette._send_message(
     39            "reftest:run",
     40            {
     41                "test": "about:blank",
     42                "references": [["about:blank", [], "=="]],
     43                "expected": "PASS",
     44                "timeout": 10 * 1000,
     45            },
     46        )
     47        self.marionette._send_message("reftest:teardown", {})
     48        expected = {
     49            "value": {
     50                "extra": {},
     51                "message": "Testing about:blank == about:blank\n",
     52                "stack": None,
     53                "status": "PASS",
     54            }
     55        }
     56        self.assertEqual(expected, rv)
     57 
     58    def test_url_comparison(self):
     59        test_page = self.fixtures.where_is("test.html")
     60        test_page_2 = self.fixtures.where_is("foo/../test.html")
     61 
     62        self.marionette._send_message("reftest:setup", {"screenshot": "unexpected"})
     63        rv = self.marionette._send_message(
     64            "reftest:run",
     65            {
     66                "test": test_page,
     67                "references": [[test_page_2, [], "=="]],
     68                "expected": "PASS",
     69                "timeout": 10 * 1000,
     70            },
     71        )
     72        self.marionette._send_message("reftest:teardown", {})
     73        self.assertEqual("PASS", rv["value"]["status"])
     74 
     75    def test_cache_multiple_sizes(self):
     76        teal = self.fixtures.where_is("reftest/teal-700x700.html")
     77        mostly_teal = self.fixtures.where_is("reftest/mostly-teal-700x700.html")
     78 
     79        self.marionette._send_message("reftest:setup", {"screenshot": "unexpected"})
     80        rv = self.marionette._send_message(
     81            "reftest:run",
     82            {
     83                "test": teal,
     84                "references": [[mostly_teal, [], "=="]],
     85                "expected": "PASS",
     86                "timeout": 10 * 1000,
     87                "width": 600,
     88                "height": 600,
     89            },
     90        )
     91        self.assertEqual("PASS", rv["value"]["status"])
     92 
     93        rv = self.marionette._send_message(
     94            "reftest:run",
     95            {
     96                "test": teal,
     97                "references": [[mostly_teal, [], "=="]],
     98                "expected": "PASS",
     99                "timeout": 10 * 1000,
    100                "width": 700,
    101                "height": 700,
    102            },
    103        )
    104        self.assertEqual("FAIL", rv["value"]["status"])
    105        self.marionette._send_message("reftest:teardown", {})