Permalink
Browse files

Firefox 17 compat updates (bugs 808795, 776718, 808769, 808758)

  • Loading branch information...
1 parent 8b91609 commit a03e0bb7f936b252dfd7caa9fbb6f7bcdd3e4682 @mattbasta committed Nov 12, 2012
@@ -0,0 +1,42 @@
+from helper import CompatTestCase
+from validator.compat import FX17_DEFINITION
+
+
+class TestFX17Compat(CompatTestCase):
+ """Test that compatibility tests for Gecko 17 are properly executed."""
+
+ VERSION = FX17_DEFINITION
+
+ def test_checkLoadURI(self):
+ """Test that `checkLoadURI` is flagged in Gecko 17."""
+ self.run_script_for_compat("x.checkLoadURI;")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_checkLoadURIStr(self):
+ """Test that `checkLoadURIStr` is flagged in Gecko 17."""
+ self.run_script_for_compat("x.checkLoadURIStr;")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_onuploadprogress(self):
+ """Test that `onuploadprogress` is flagged in Gecko 17."""
+ self.run_script_for_compat("""
+ var x = XMLHttpRequest();
+ x.onuploadprogress = function() {};
+ x.send();
+ """)
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_onuploadprogress(self):
+ """Test that `onuploadprogress` is flagged in Gecko 17."""
+ self.run_script_for_compat("x.nsIChromeFrameMessageManager;")
+ self.assert_silent()
+ self.assert_compat_error()
+
+ def test_eval_function(self):
+ """Test that `eval` and `Function` are flagged in Gecko 17."""
+ self.run_script_for_compat("var foo = eval('asdf');")
+ self.assert_failed(with_warnings=True)
+ self.assert_compat_error(type_="notice")
View
@@ -142,15 +142,19 @@ def test_file_structure():
bundle = ErrorBundle(True) # No color since no output
# Populate the bundle with some test data.
- bundle.error((), "error", "", "file1", 123)
- bundle.error((), "error", "", "file2")
+ bundle.error((), "error", description="",
+ filename="file1", column=123)
+ bundle.error((), "error", description="",
+ filename="file2")
bundle.error((), "error")
# Push a state
bundle.push_state("foo")
- bundle.warning((), "warning", "", "file4", 123)
- bundle.warning((), "warning", "", "file5")
+ bundle.warning((), "warning", description="",
+ filename="file4", column=123)
+ bundle.warning((), "warning", description="",
+ filename="file5")
bundle.warning((), "warning")
bundle.pop_state()
@@ -19,4 +19,3 @@ def test_no_dups():
assert _do_test_raw("""
eval.prototype = true;
""").message_count == 2
-
@@ -27,7 +27,8 @@
"11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2", "13.0",
"13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1", "15.0a2", "15.0",
"15.*", "16.0a1", "16.0a2", "16.0", "16.*", "17.0a1", "17.0a2", "17.0",
- "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1"]
+ "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1", "18.0a2", "18.0", "18.*",
+ "19.0a1"]
},
"2":{"name":"Mozilla",
"guid":"{86c18b42-e466-45a9-ae7a-9b95ba6f5640}",
@@ -55,7 +56,8 @@
"11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2", "13.0",
"13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1", "15.0a2", "15.0",
"15.*", "16.0a1", "16.0a2", "16.0", "16.*", "17.0a1", "17.0a2", "17.0",
- "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1"]
+ "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1", "18.0a2", "18.0", "18.*",
+ "19.0a1"]
},
"4":{"name":"Sunbird",
"guid":"{718e30fb-e89b-41dd-9da7-e25a45638b28}",
@@ -78,7 +80,8 @@
"2.8.*", "2.9a1", "2.9a2", "2.9", "2.9.*", "2.10a1", "2.10a2", "2.10",
"2.10.*", "2.11a1", "2.11a2", "2.11", "2.11.*", "2.12a1", "2.12a2",
"2.12", "2.12.*", "2.13a1", "2.13a2", "2.13", "2.13.*", "2.14a1",
- "2.14a2", "2.14", "2.14.*", "2.15a1"]
+ "2.14a2", "2.14", "2.14.*", "2.15a1", "2.15a2", "2.15", "2.15.*",
+ "2.16a1"]
},
"6":{"name":"Mobile",
"guid":"{a23983c0-fd0e-11dc-95ff-0800200c9a66}",
@@ -95,7 +98,7 @@
"13.0", "13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1",
"15.0a2", "15.0", "15.*", "16.0a1", "16.0a2", "16.0", "16.*",
"17.0a1", "17.0a2", "17.0", "17.0a1", "17.0a2", "17.0", "17.*",
- "18.0a1"]
+ "18.0a1", "18.0a2", "18.0", "18.*", "19.0a1"]
},
"7":{"name":"Android",
"guid":"{aa3c5121-dab2-40e2-81ca-7ea25febc110}",
@@ -104,6 +107,7 @@
"11.*", "12.0a1", "12.0a2", "12.0", "12.*", "13.0a1", "13.0a2",
"13.0", "13.*", "14.0a1", "14.0a2", "14.0", "14.*", "15.0a1", "15.0a2",
"15.0", "15.*", "16.0a1", "16.0a2", "16.0", "16.*", "17.0a1", "17.0a2",
- "17.0", "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1"]
+ "17.0", "17.0a1", "17.0a2", "17.0", "17.*", "18.0a1", "18.0a2", "18.0",
+ "18.*", "19.0a1"]
}
}
View
@@ -2,6 +2,10 @@
import json
import os
+import types
+
+
+DESCRIPTION_TYPES = types.StringTypes + (list, tuple, )
@cvan

cvan Nov 13, 2012

Contributor

you didn't!

# Package type constants.
PACKAGE_ANY = 0
View
@@ -32,14 +32,13 @@ class ErrorBundle(object):
"""
def __init__(self, determined=True, listed=True, instant=False,
- overrides=None, spidermonkey=None, for_appversions=None):
+ overrides=None, spidermonkey=False, for_appversions=None):
self.handler = None
self.errors = []
self.warnings = []
self.notices = []
- self.message_count = 0
self.message_tree = {}
self.compat_summary = {"errors": 0,
@@ -57,7 +56,6 @@ def __init__(self, determined=True, listed=True, instant=False,
# TODO: Break off into resource helper
self.resources = {}
- self.overrides = None
self.pushable_resources = {}
self.final_context = None
@@ -69,13 +67,10 @@ def __init__(self, determined=True, listed=True, instant=False,
self.instant = instant
self.determined = determined
- # TODO: Break off into version helper
self.version_requirements = None
- if overrides:
- self.overrides = overrides
- if spidermonkey:
- self.save_resource("SPIDERMONKEY", spidermonkey)
+ self.overrides = overrides or None
@cvan

cvan Nov 13, 2012

Contributor

are you thinking this might be '' or False?

@mattbasta

mattbasta Nov 13, 2012

Owner

An empty list

+ self.save_resource("SPIDERMONKEY", spidermonkey or False)
self.supported_versions = self.for_appversions = for_appversions
@@ -142,11 +137,13 @@ def set_tier(self, tier):
if tier > self.ending_tier:
self.ending_tier = tier
+ @property
+ def message_count(self):
+ return len(self.errors) + len(self.warnings) + len(self.notices)
+
def _save_message(self, stack, type_, message, context=None):
"Stores a message in the appropriate message stack."
- self.message_count += 1
-
uid = uuid.uuid4().hex
message["uid"] = uid
@@ -435,10 +432,7 @@ def _print_message(self, prefix, message, verbose=True):
"Prints a message and takes care of all sorts of nasty code"
# Load up the standard output.
- output = ["\n",
- prefix,
- message["message"],
- "\n"]
+ output = ["\n", prefix, message["message"]]
# We have some extra stuff for verbose mode.
if verbose:
@@ -511,8 +505,7 @@ def _compare_version(self, requirements, support):
# the provided versions for the GUID are supported.
if (guid in support and
any((detected_version in requirements[guid]) for
- detected_version in
- support[guid])):
+ detected_version in support[guid])):
return True
def discard_unused_messages(self, ending_tier):
@@ -6,8 +6,9 @@
import spidermonkey
import instanceactions
import instanceproperties
-from validator.constants import (BUGZILLA_BUG, FENNEC_GUID, FIREFOX_GUID,
- MAX_STR_SIZE)
+from validator.compat import FX17_DEFINITION
+from validator.constants import (BUGZILLA_BUG, DESCRIPTION_TYPES, FENNEC_GUID,
+ FIREFOX_GUID, MAX_STR_SIZE)
from validator.decorator import version_range
from jstypes import *
@@ -354,6 +355,22 @@ def _define_literal(traverser, node):
traverser=traverser)
+def call_dangerous_function(traverser, member, name):
+ if name in ("eval", "Function", ):
+ traverser.err.notice(
+ err_id=("js", "actions", "_call_expression", "eval_compat"),
+ notice="`toString` for function objects has changed.",
+ description=["The `toString` implementation for function objects "
+ "have changed. If you are using `eval` or `Function` "
+ "to change the behavior of 'native' functions, it is "
+ "probably not working correctly in Firefox 17 and "
+ "above.",
+ "See %s for details." % BUGZILLA_BUG % 761723],
+ for_appversions=FX17_DEFINITION,
+ compatibility_type="error",
+ tier=5)
@cvan

cvan Nov 13, 2012

Contributor

why tier 5?

@mattbasta

mattbasta Nov 13, 2012

Owner

Tier 5 is compatibility

+
+
def _call_expression(traverser, node):
args = node["arguments"]
map(traverser._traverse_node, args)
@@ -377,14 +394,15 @@ def _call_expression(traverser, node):
column=traverser.position,
context=traverser.context)
- if (member.is_global and
- "dangerous" in member.value and
- isinstance(member.value["dangerous"], types.LambdaType)):
+ if member.is_global and callable(member.value.get("dangerous", None)):
+ result = member.value["dangerous"](a=args, t=traverser._traverse_node,
+ e=traverser.err)
+ name = member.value.get("name", "")
+
+ if result:
+ call_dangerous_function(traverser, member, name)
- dangerous = member.value["dangerous"]
- t = traverser._traverse_node
- result = dangerous(a=args, t=t, e=traverser.err)
- if result and "name" in member.value:
+ if result and name:
## Generate a string representation of the params
#params = u", ".join([_get_as_str(t(p).get_literal_value()) for
# p in args])
@@ -393,8 +411,8 @@ def _call_expression(traverser, node):
"called_dangerous_global"),
warning="`%s` called in potentially dangerous manner" %
member.value["name"],
- description=result if isinstance(result, (types.StringTypes,
- list, tuple)) else
+ description=result if isinstance(result,
+ DESCRIPTION_TYPES) else
"The global `%s` function was called using a set "
"of dangerous parameters. Calls of this nature "
"are deprecated." % member.value["name"],
@@ -512,4 +512,3 @@ def set(self, index, value, traverser=None):
def output(self):
return u"[%s]" % self.get_literal_value()
-
@@ -2,6 +2,7 @@
import types
from validator.compat import FX15_DEFINITION
+from validator.constants import DESCRIPTION_TYPES
from . import actions
from .jstypes import *
@@ -190,8 +191,7 @@ def _traverse_node(self, node):
action_debug = (action_result.output() if
isinstance(action_result, JSWrapper) else
action_result)
- self._debug("ACTION>>%s (%s)" % (action_debug,
- node["type"]))
+ self._debug("ACTION>>%s (%s)" % (action_debug, node["type"]))
if action_result is None:
self.debug_level += 1
@@ -306,18 +306,21 @@ def _is_global(self, name):
def _build_global(self, name, entity):
"Builds an object based on an entity from the predefined entity list"
- if (not isinstance(entity.get("dangerous"), types.LambdaType) or
+ if (not callable(entity.get("dangerous")) or
"dangerous_on_read" in entity):
dang = entity.get("dangerous", entity.get("dangerous_on_read"))
- if isinstance(dang, types.LambdaType):
+ if callable(dang):
dang = dang(self._traverse_node, self.err)
+
if dang:
+ actions.call_dangerous_function(self, entity, name)
+
self._debug("DANGEROUS")
self.err.warning(
("js", "traverser", "dangerous_global"),
"Illegal or deprecated access to the `%s` global" % name,
- [dang if isinstance(dang, (types.StringTypes, list, tuple))
+ [dang if isinstance(dang, DESCRIPTION_TYPES)
else "Access to the `%s` property is deprecated "
"for security or other reasons." % name],
filename=self.filename,
@@ -5,6 +5,7 @@
FX7_DEFINITION, FX8_DEFINITION, FX9_DEFINITION,
FX11_DEFINITION, FX12_DEFINITION, FX13_DEFINITION,
FX14_DEFINITION, FX15_DEFINITION, FX16_DEFINITION,
+ FX17_DEFINITION,
TB7_DEFINITION, TB10_DEFINITION, TB11_DEFINITION,
TB12_DEFINITION, TB13_DEFINITION, TB14_DEFINITION,
TB15_DEFINITION, TB16_DEFINITION)
@@ -698,6 +699,39 @@ def js_tests(self):
@register_generator
+class Gecko17RegexTests(CompatRegexTestHelper):
+ """Regex tests for Gecko 17 updates."""
+
+ VERSION = FX17_DEFINITION
+
+ CFMM_URL = ("http://mxr.mozilla.org/mozilla-beta/source/content/base/"
+ "public/nsIMessageManager.idl")
+
+ def js_tests(self):
+
+ yield self.get_test_bug(
+ 776825, "nsIChromeFrameMessageManager",
@cvan

cvan Nov 13, 2012

Contributor

where's the test for this?

@mattbasta

mattbasta Nov 13, 2012

Owner

I'm not interested in testing the efficaciousness of the python re library.

+ "`nsIChromeFrameMessageManager` has been removed.",
+ "The `nsIChromeFrameMessageManager` interface has been "
+ "removed, and the new Message Manager interfaces should be "
+ "used instead. See %s for more information." % self.CFMM_URL,
@cvan

cvan Nov 13, 2012

Contributor

you say "See %s for details" above and the bug says "Read %s". consistency.

@mattbasta

mattbasta Nov 13, 2012

Owner

"See %s for the deets"

+ compat_type="error")
+
+ yield self.get_test_bug(
+ 761278, "onuploadprogress",
+ "`onuploadprogress` has been removed.",
+ "The `onuploadprogress` property has been removed from "
+ "`XMLHttpRequest`.", compat_type="error")
@cvan

cvan Nov 13, 2012

Contributor

you should add "See %s for more information"

@mattbasta

mattbasta Nov 13, 2012

Owner

get_test_bug, bro

+
+ yield self.get_test_bug(
+ 327244, "checkLoadURI(Str)?",
+ "`checkLoadURI` and `checkLoadURIStr` have been removed.",
+ "The `checkLoadURI` and `checkLoadURIStr` interfaces have "
@cvan

cvan Nov 13, 2012

Contributor

don't want to mention nsIScriptSecurityManager?

@mattbasta

mattbasta Nov 13, 2012

Owner

I mention what Jorge tells me to mention

+ "been removed. You should use `checkLoadURIWithPrincipal` "
+ "instead.", compat_type="error")
@cvan

cvan Nov 13, 2012

Contributor

you should add "See %s for more information."

@mattbasta

mattbasta Nov 13, 2012

Owner

get_test_bug does that for you.

+
+
+@register_generator
class Thunderbird7RegexTests(CompatRegexTestHelper):
"""Regex tests for the Thunderbird 7 update."""

1 comment on commit a03e0bb

Contributor

cvan commented on a03e0bb Nov 13, 2012

r+wc

Please sign in to comment.