Skip to content

Loading…

Bug 833512 - Flag instances of null passed in place of a privacy context #195

Merged
merged 1 commit into from

2 participants

@kmaglione

No description provided.

@mattbasta mattbasta commented on an outdated diff
validator/testcases/javascript/call_definitions.py
@@ -167,6 +167,29 @@ def spellcheck_updatecurrentdictionary(wrapper, arguments, traverser):
tier=5)
+def webbrowserpersist_saveuri(wrapper, arguments, traverser):
+ """
+ nsIWebBrowserPersist.saveURI requires a valid privacy context as of Firefox 19

83 chars

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mattbasta mattbasta commented on the diff
validator/testcases/javascript/call_definitions.py
@@ -167,6 +167,29 @@ def spellcheck_updatecurrentdictionary(wrapper, arguments, traverser):
tier=5)
+def webbrowserpersist_saveuri(wrapper, arguments, traverser):

How is this function called? It's not referenced anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mattbasta

Looks fine to me. For future reference, I'm using the entity() construct to put in XPCOM stuff going forward. call_definitions is too crowded and entities are more flexible.

@mattbasta mattbasta merged commit 9f39efb into mozilla:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
23 tests/test_js_xpcom.py
@@ -282,6 +282,29 @@ def test_nsidnsservice_resolve():
""").failed()
+def test_xpcom_nsiwebbrowserpersist():
+ """
+ Test that nsIWebBrowserPersist.saveURI is flagged when called
+ with a null load context.
+ """
+
+ assert _do_test_raw("""
+ var foo = Cc["foo"].getService(Components.interfaces.nsIWebBrowserPersist);
+ foo.saveURI(null, null, null, null, null, null, null);
+ """).failed()
+
+ assert _do_test_raw("""
+ var foo = Cc["foo"].getService(Components.interfaces.nsIWebBrowserPersist);
+ var thing = null;
+ foo.saveURI(null, null, null, null, null, null, thing);
+ """).failed()
+
+ assert not _do_test_raw("""
+ var foo = Cc["foo"].getService(Components.interfaces.nsIWebBrowserPersist);
+ foo.saveURI(null, null, null, null, null, null, thing);
+ """).failed()
+
+
class TestnsIWindowWatcher(TestCase):
def _run_against_foo(self, script):
View
24 validator/testcases/javascript/call_definitions.py
@@ -167,6 +167,30 @@ def spellcheck_updatecurrentdictionary(wrapper, arguments, traverser):
tier=5)
+def webbrowserpersist_saveuri(wrapper, arguments, traverser):

How is this function called? It's not referenced anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ """
+ nsIWebBrowserPersist.saveURI requires a valid privacy context as
+ of Firefox 19
+ """
+ if len(arguments) >= 7:
+ load_context = traverser._traverse_node(arguments[6])
+ if load_context.get_literal_value() is None:
+ traverser.err.warning(
+ err_id=("testcases_javascript_call_definititions",
+ "webbrowserpersist_saveuri"),
+ warning=("saveURI should not be called with a null load "
+ "context"),
+ description=("While nsIWebBrowserPersist.saveURI accepts null "
+ "in place of a privacy context, this usage is "
+ "acceptable only when no appropriate load "
+ "context exists."),
+ filename=traverser.filename,
+ line=traverser.line,
+ column=traverser.position,
+ context=traverser.context,
+ tier=4)
+
+
def xpcom_constructor(method, extend=False, mutate=False, pretraversed=False):
"""Returns a function which wraps an XPCOM class instantiation function."""
View
5 validator/testcases/javascript/predefinedentities.py
@@ -342,6 +342,11 @@
{"value":
{u"queryCommandText": entity("nsIDOMHTMLDocument"),
u"execCommandShowHelp": entity("nsIDOMHTMLDocument")}},
+ u"nsIWebBrowserPersist":
+ {"value":
+ {u"saveURI":
+ {"return":
+ call_definitions.webbrowserpersist_saveuri}}},
}
INTERFACE_ENTITIES = {u"nsIXMLHttpRequest":
Something went wrong with that request. Please try again.