Permalink
Browse files

Merge pull request #161 from mattbasta/fx14

Firefox 14 Compat Update
  • Loading branch information...
2 parents 683ffb1 + 9180382 commit 86d06cfabca5ede6ca0d5da072a5851bffde65be @mattbasta committed Jun 29, 2012
View
No changes.
View
@@ -0,0 +1,96 @@
+from ..helper import RegexTestCase
+from ..js_helper import TestCase as JSTestCase
+
+
+class CompatTestCase(JSTestCase, RegexTestCase):
+ """
+ A TestCase object which aids in running tests regarding compatibility
+ tests. It is expected that you will supply a static member `VERSION`
+ describing the version(s) of Gecko that these tests apply to.
+ """
+
+ def setUp(self, *args, **kwargs):
+ super(CompatTestCase, self).setUp(*args, **kwargs)
+
+ def run_script_for_compat(self, script, expose_pollution=False):
+ """
+ Test a script with and without version restrictions to determine
+ whether it properly raises JavaScript compatibility messages.
+ """
+ self._run_member_for_compat(lambda: self.run_script(script,
+ expose_pollution))
+
+ def run_xpcom_for_compat(self, interface, methods=None):
+ """
+ Yields after each method has been run as a script. Used to test that
+ XPCOM members are properly flagged for compatibility tests.
+
+ - `interface` should be the name of the XPCOM interface.
+ - `methods` should be the member to test. It may be a simple reference
+ to a member (i.e.: `foo`) or an action upon a member (i.e.:
+ `foo('bar')` or `foo["bar"] = "zap"`).
+ """
+
+ script = """
+ var x = Components.classes[""].createInstance(Components.interfaces.%s);
+ x.%%s;
+ """ % interface
+
+ if not methods:
+ return
+
+ for method in methods:
+ self.run_script_for_compat(script % method)
+ yield
+
+ def run_regex_for_compat(self, input):
+ """
+ Test an input with and without version restrictions to determine
+ whether it properly raises regex compatibility messages.
+ """
+ self._run_member_for_compat(lambda: self.run_regex(input))
+
+ def _run_member_for_compat(self, method):
+ # Run the method without version restrictions.
+ method()
+
+ # Store away that error bundle to prepare for the next error bundle.
+ standard_err = self.err
+ self.err = None
+
+ # Run the method again with version restrictions.
+ self.setup_err(for_appversions=self.VERSION)
+ method()
+
+ self.compat_err = self.err
+ self.err = standard_err
+
+ def assert_compat_silent(self):
+ """Assert that no compatibility messages have been raised."""
+ assert not any(self.compat_err.compat_summary.values()), \
+ "Got %s" % self.compat_err.compat_summary
+
+ def assert_compat_error(self, type_="warning"):
+ """
+ Assert that a compat error was raised as a message of type `type_`.
+ """
+ self._assert_compat_type("error", type_)
+
+ def assert_compat_warning(self, type_="notice"):
+ """
+ Assert that a compat warning was raised as a message of type `type_`.
+ """
+ self._assert_compat_type("warning", type_)
+
+ def _assert_compat_type(self, compat_type, type_):
+ print self.compat_err.print_summary()
+ message_collection = {"error": self.compat_err.errors,
+ "warning": self.compat_err.warnings,
+ "notice": self.compat_err.notices}[type_]
+ assert message_collection, \
+ "No %ss were raised in the compatibility test." % type_
+ assert any(m["compatibility_type"] == compat_type for
+ m in message_collection), \
+ ("No %ss that raise a compatibility %s were found." %
+ (type_, compat_type))
+
@@ -0,0 +1,66 @@
+from helper import CompatTestCase
+from validator.compat import FX10_DEFINITION
+
+
+class TestFX10Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 10 are properly executed."""
+
+ VERSION = FX10_DEFINITION
+
+ def test_isSameNode(self):
+ """Test that `isSameNode` is flagged in Gecko 10."""
+ self.run_script_for_compat('alert(x.isSameNode(foo));')
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_replaceWholeText(self):
+ """Test that `repalceWholeText` is flagged in Gecko 10."""
+ self.run_script_for_compat('alert(x.replaceWholeText());')
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_isElementContentWhitespace(self):
+ """Test that `isElementContentWhitespace` is flagged in Gecko 10."""
+ self.run_script_for_compat('alert(x.isElementContentWhitespace);')
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_xml_docuemnt_properties(self):
+ """
+ Test that the `xmlEncoding`, `xmlVersion`, and `xmlStandalone` objects
+ are dead for the document object in Gecko 10.
+ """
+ patterns = ["document.xmlEncoding", "document.xmlVersion",
+ "document.xmlStandalone", "content.document.xmlEncoding"]
+ for pattern in patterns:
+ self.run_script_for_compat("alert(%s);" % pattern)
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_xml_properties(self):
+ """
+ Test that the `xmlEncoding`, `xmlVersion`, and `xmlStandalone` objects
+ are dead in Gecko 10.
+ """
+ patterns = ["foo.xmlEncoding", "foo.xmlVersion", "foo.xmlStandalone"]
+ for pattern in patterns:
+ self.run_script_for_compat("alert(%s);" % pattern)
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_interfaces(self):
+ interfaces = ["nsIDOMNSHTMLFrameElement", "nsIDOMNSHTMLElement"]
+ for interface in interfaces:
+ self.run_script_for_compat("""
+ var x = Components.classes[""].createInstance(
+ Components.interfaces.%s);
+ """ % interface)
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
+ def test_nsIBrowserHistory(self):
+ for method in self.run_xpcom_for_compat(
+ "nsIBrowserHistory", ["lastPageVisited"]):
+ self.assert_silent()
+ self.assert_compat_error(type_="error")
+
@@ -0,0 +1,27 @@
+from helper import CompatTestCase
+from validator.compat import FX11_DEFINITION
+
+
+class TestFX11Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 11 are properly executed."""
+
+ VERSION = FX11_DEFINITION
+
+ def test_requestAnimationFrame(self):
+ """Test that requestAnimationFrame requires at least one parameter."""
+
+ self.run_script_for_compat('requestAnimationFrame(foo);')
+ self.assert_silent()
+ self.assert_compat_silent()
+
+ self.run_script_for_compat('requestAnimationFrame();')
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_patterns(self):
+ patterns = ["nsICharsetResolver", '"omni.jar"']
+ for pattern in patterns:
+ self.run_regex_for_compat(pattern)
+ self.assert_silent()
+ self.assert_compat_error()
+
@@ -0,0 +1,27 @@
+from helper import CompatTestCase
+from validator.compat import FX12_DEFINITION
+
+
+class TestFX12Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 12 are properly executed."""
+
+ VERSION = FX12_DEFINITION
+
+ def test_chromemargin(self):
+ self.run_regex_for_compat('<foo chromemargin="1">')
+ self.assert_silent()
+ self.assert_compat_error(type_="notice")
+
+ def test_documentCharsetInfo(self):
+ self.run_regex_for_compat('window.documentCharsetInfo;')
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_interfaces(self):
+ interfaces = ["nsIJetpack", "nsIJetpackService",
+ "nsIProxyObjectManager"]
+ for interface in interfaces:
+ self.run_regex_for_compat("Components.interfaces.%s" % interface)
+ self.assert_silent()
+ self.assert_compat_error()
+
@@ -0,0 +1,55 @@
+from helper import CompatTestCase
+from validator.compat import FX13_DEFINITION
+
+
+class TestFX13Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 13 are properly executed."""
+
+ VERSION = FX13_DEFINITION
+
+ def test_startendMarker(self):
+ """Test that _startMarker and _endMarker are flagged in Gecko 13."""
+
+ patterns = ["bar()._startMarker",
+ "bar()._startMarker = 1",
+ "bar()._endMarker",
+ "bar()._endMarker = 1"]
+ for pattern in patterns:
+ self.run_script_for_compat(pattern)
+ self.assert_silent()
+ self.assert_compat_error(type_="notice")
+
+ def test_excludeItemsIfParentHasAnnotation(self):
+ """
+ Test that `excludeItemsIfParentHasAnnotation` is flagged in Gecko 13.
+ """
+ self.run_regex_for_compat("excludeItemsIfParentHasAnnotation")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_globalStorage_flagged(self):
+ """Test that `globalStorage` is flagged in Gecko 13."""
+ self.run_regex_for_compat('globalStorage["foo"]')
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_nsILivemarkService(self):
+ self.run_regex_for_compat("nsILivemarkService")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_nsIPrefBranch2(self):
+ self.run_regex_for_compat("nsIPrefBranch2")
+ self.assert_silent()
+ self.assert_compat_warning(type_="warning")
+
+ def test_nsIScriptableUnescapeHTML(self):
+ self.run_regex_for_compat("nsIScriptableUnescapeHTML")
+ self.assert_silent()
+ self.assert_compat_warning()
+
+ def test_nsIAccessNode(self):
+ self.run_regex_for_compat("nsIAccessNode")
+ self.assert_silent()
+ self.assert_compat_error()
+
@@ -0,0 +1,72 @@
+from helper import CompatTestCase
+from validator.compat import FX14_DEFINITION
+
+
+class TestFX14Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 14 are properly executed."""
+
+ VERSION = FX14_DEFINITION
+
+ def test_nsIPlacesImportExportService(self):
+ """
+ nsIPlacesImportExportService.importHTMLFromFile and .importHTMLFromURI
+ have both been removed from Gecko 14.
+ """
+ for method in self.run_xpcom_for_compat(
+ "nsIPlacesImportExportService",
+ ["importHTMLFromFile", "importHTMLFromURI"]):
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_nsIDOMHTMLDocument(self):
+ """
+ Test that `queryCommandText` and `execCommandShowHelp` have been
+ flagged in Gecko 14.
+ """
+ for method in self.run_xpcom_for_compat(
+ "nsIDOMHTMLDocument",
+ ["queryCommandText()", "execCommandShowHelp()"]):
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_nsINavBookmarksService(self):
+ """Test that GUIDs are removed from `nsINavBookarmsService`."""
+
+ for method in self.run_xpcom_for_compat(
+ "nsINavBookmarksService", ["getItemGUID", "setItemGUID",
+ "getItemIdForGUID"]):
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_nsIHistoryQueryOptions(self):
+ """Test that `redirectsMode` is flagged in Gecko 14."""
+ for method in self.run_xpcom_for_compat(
+ "nsINavHistoryQueryOptions", ["redirectsMode"]):
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_onFaviconDataAvailable(self):
+ """Test that `onFaviconDataAvailable` is flagged in Gecko 14."""
+ self.run_script_for_compat("alert(x.onFaviconDataAvailable());")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_Blob(self):
+ """Test that the (Moz)BlobBuilder objects are deprecated."""
+ self.run_regex_for_compat("MozBlobBuilder")
+ self.assert_silent()
+ self.assert_compat_warning(type_="warning")
+
+ self.run_regex_for_compat("BlobBuilder")
+ self.assert_silent()
+ self.assert_compat_warning(type_="warning")
+
+ def test_nsILocalFile(self):
+ """
+ Test that `nsILocalFile` suggests that `nsIFile` should be used
+ instead.
+ """
+ self.run_regex_for_compat("nsILocalFile")
+ self.assert_silent()
+ self.assert_compat_warning(type_="warning")
+
@@ -0,0 +1,20 @@
+from helper import CompatTestCase
+from validator.compat import FX5_DEFINITION
+
+
+class TestFX5Compat(CompatTestCase):
+ """Test that compatibility tests for Firefox 5 are properly executed."""
+
+ VERSION = FX5_DEFINITION
+
+ def test_navigator_language(self):
+ """
+ Test that `navigator.language is flagged as potentially incompatible
+ with Gecko 5.
+ """
+
+ self.run_script_for_compat('alert(navigator.language);')
+ self.assert_silent()
+
+ self.assert_compat_error(type_="notice")
+
Oops, something went wrong.

0 comments on commit 86d06cf

Please sign in to comment.