commit ab71188e49358619bfe06a2b618200b2f5e5b68f Author: Alex Catarineu acat@torproject.org Date: Mon Aug 3 12:18:15 2020 +0200
Fix dom objects enumeration tests for 80 --- marionette/tor_browser_tests/lib/testsuite.py | 7 +++++++ .../test_dom-objects-enumeration-worker.py | 15 +++++++++++---- .../tor_browser_tests/test_dom-objects-enumeration.py | 16 ++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/marionette/tor_browser_tests/lib/testsuite.py b/marionette/tor_browser_tests/lib/testsuite.py index 78713c8..88b1953 100644 --- a/marionette/tor_browser_tests/lib/testsuite.py +++ b/marionette/tor_browser_tests/lib/testsuite.py @@ -1,5 +1,6 @@ import os import json +from marionette_harness import MarionetteTestCase
class TestSuite(object): def __init__(self): @@ -24,3 +25,9 @@ class TestSuite(object): output = open(screenshot_file, 'w') output.write(png_data) output.close() + + +class TorBrowserTest(MarionetteTestCase): + def get_version(self): + with self.marionette.using_context("chrome"): + return self.marionette.execute_script("return parseFloat(AppConstants.MOZ_APP_VERSION);") diff --git a/marionette/tor_browser_tests/test_dom-objects-enumeration-worker.py b/marionette/tor_browser_tests/test_dom-objects-enumeration-worker.py index 59d771b..88f5792 100644 --- a/marionette/tor_browser_tests/test_dom-objects-enumeration-worker.py +++ b/marionette/tor_browser_tests/test_dom-objects-enumeration-worker.py @@ -1,9 +1,10 @@ from marionette_harness import MarionetteTestCase +import testsuite
-class Test(MarionetteTestCase): +class Test(testsuite.TorBrowserTest):
def setUp(self): - MarionetteTestCase.setUp(self) + testsuite.TorBrowserTest.setUp(self)
self.marionette.set_pref("network.proxy.allow_hijacking_localhost", False) self.test_page_file_url = self.marionette.absolute_url("dom-objects-enumeration.html?testType=worker") @@ -196,8 +197,14 @@ class Test(MarionetteTestCase): "XMLHttpRequestEventTarget", "XMLHttpRequestUpload", ] + self.expectedObjects80 = self.expectedObjects + ["AggregateError", "FinalizationRegistry", "WeakRef"] + self.expectedObjects80.sort()
def test_dom_objects_enumeration_workers(self): + expectedObjects = self.expectedObjects + if self.get_version() >= 80: + expectedObjects = self.expectedObjects80 + with self.marionette.using_context('content'): self.marionette.navigate(self.test_page_file_url) self.marionette.timeout.implicit = 5 @@ -206,7 +213,7 @@ class Test(MarionetteTestCase): err = False unknown_objects = '' for l in r: - if l in self.expectedObjects: + if l in expectedObjects: continue err = True unknown_objects += l + "\n" @@ -214,7 +221,7 @@ class Test(MarionetteTestCase): err_msg = "Unknown objects:\n%s" % unknown_objects self.assertFalse(err, msg=err_msg)
- for l in self.expectedObjects: + for l in expectedObjects: if l in r: continue err = True diff --git a/marionette/tor_browser_tests/test_dom-objects-enumeration.py b/marionette/tor_browser_tests/test_dom-objects-enumeration.py index be2ae65..3db4366 100644 --- a/marionette/tor_browser_tests/test_dom-objects-enumeration.py +++ b/marionette/tor_browser_tests/test_dom-objects-enumeration.py @@ -8,10 +8,11 @@ from marionette_driver import By from marionette_driver.errors import MarionetteException
from marionette_harness import MarionetteTestCase +import testsuite
-class Test(MarionetteTestCase): +class Test(testsuite.TorBrowserTest): def setUp(self): - MarionetteTestCase.setUp(self) + testsuite.TorBrowserTest.setUp(self) self.marionette.set_pref("network.proxy.allow_hijacking_localhost", False) self.test_page_file_url = self.marionette.absolute_url("dom-objects-enumeration.html?testType=window") # The list of expected DOM objects @@ -753,8 +754,15 @@ class Test(MarionetteTestCase): "XPathResult", "XSLTProcessor", ] + self.expectedObjects80 = self.expectedObjects + ["AggregateError", "FinalizationRegistry", "WeakRef"] + self.expectedObjects80.remove("content") + self.expectedObjects80.sort()
def test_dom_objects_enumeration(self): + expectedObjects = self.expectedObjects + if self.get_version() >= 80: + expectedObjects = self.expectedObjects80 + with self.marionette.using_context('content'): self.marionette.navigate(self.test_page_file_url) self.marionette.timeout.implicit = 5 @@ -763,7 +771,7 @@ class Test(MarionetteTestCase): err = False unknown_objects = '' for l in r: - if l in self.expectedObjects: + if l in expectedObjects: continue err = True unknown_objects += l + "\n" @@ -771,7 +779,7 @@ class Test(MarionetteTestCase): err_msg = "Unknown objects:\n%s" % unknown_objects self.assertFalse(err, msg=err_msg)
- for l in self.expectedObjects: + for l in expectedObjects: if l in r: continue err = True
tor-commits@lists.torproject.org