Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

content-policy: do not auto-load the content-policy component

Have the content-policy module load the content-policy component.  This
should resolve a sporadically occurring bug whereby the program would fail
to start with the error, "get_caller_source_code_reference is not defined"
in recent version of XULRunner (7 and 8 for certain).  The stack trace
points back to the content-policy component's use of add_hook, and since
source-code.js is loaded after hook.js, it suggests that the problem was a
race condition due to asynchronous loading of components.

See http://bugs.conkeror.org/issue376

This patch also has the beneficial effect that the content-policy
component will only be loaded for people who use it.
  • Loading branch information...
commit c8cb3c645ca85bba3d0a288a7858947a6693ebef 1 parent 238d3e8
@retroj authored
View
4 chrome.manifest
@@ -7,10 +7,6 @@ component {0f4dd758-b55a-4386-a79c-8698642eac51} components/command-line.js
contract @mozilla.org/commandlinehandler/general-startup;1?type=conkeror {0f4dd758-b55a-4386-a79c-8698642eac51}
category command-line-handler y-conkeror @mozilla.org/commandlinehandler/general-startup;1?type=conkeror
-component {2926dd11-4d76-4965-bcdc-4aaad70ada04} components/content-policy.js
-contract @conkeror.org/content-policy-listener;1 {2926dd11-4d76-4965-bcdc-4aaad70ada04}
-category content-policy content-policy @conkeror.org/content-policy-listener;1
-
component {74FCB100-B972-11DC-95FF-0800200C9A66} components/download_helper.js
contract @mozilla.org/helperapplauncherdialog;1 {74FCB100-B972-11DC-95FF-0800200C9A66}
View
2  components/content-policy.js
@@ -40,7 +40,7 @@ content_policy.prototype = {
},
_xpcom_categories: [{category: "content-policy"}],
- enabled: false,
+ enabled: true,
shouldLoad: function (content_type, //unsigned long
content_location, //nsIURI
request_origin, //nsIURI
View
4 content-policy.manifest
@@ -0,0 +1,4 @@
+
+component {2926dd11-4d76-4965-bcdc-4aaad70ada04} components/content-policy.js
+contract @conkeror.org/content-policy-listener;1 {2926dd11-4d76-4965-bcdc-4aaad70ada04}
+category content-policy content-policy @conkeror.org/content-policy-listener;1
View
21 modules/content-policy.js
@@ -1,5 +1,5 @@
/**
- * (C) Copyright 2010 John J. Foerch
+ * (C) Copyright 2010-2011 John J. Foerch
*
* Use, modification, and distribution are subject to the terms specified in the
* COPYING file.
@@ -7,7 +7,24 @@
in_module(null);
-content_policy_listener.enabled = true;
+function content_policy_init () {
+ var xulrunner_version = Cc['@mozilla.org/xre/app-info;1']
+ .getService(Ci.nsIXULAppInfo)
+ .platformVersion;
+ var vc = Cc["@mozilla.org/xpcom/version-comparator;1"]
+ .getService(Ci.nsIVersionComparator);
+ var reg = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
+ var file = file_locator_service.get("CurProcD", Ci.nsIFile);
+ if (vc.compare(xulrunner_version, "2.0") >= 0) {
+ file.append("content-policy.manifest");
+ } else {
+ file.append("components");
+ file.append("content-policy.js");
+ }
+ reg.autoRegister(file);
+}
+
+content_policy_init();
interactive("content-policy-enable",
"Enable content-policy processing.",

0 comments on commit c8cb3c6

Please sign in to comment.
Something went wrong with that request. Please try again.