Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #195 from kmaglione/bug-833512

Bug 833512 - Flag instances of null passed in place of a privacy context
  • Loading branch information...
commit 9f39efb2c4b5e4d4653744ff004272847253887d 2 parents 8c641e6 + d7aad60
@mattbasta mattbasta authored
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):
+ """
+ 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":
Please sign in to comment.
Something went wrong with that request. Please try again.