From c8cb3c645ca85bba3d0a288a7858947a6693ebef Mon Sep 17 00:00:00 2001 From: John Foerch Date: Sun, 6 Nov 2011 12:59:57 -0500 Subject: [PATCH] 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. --- chrome.manifest | 4 ---- components/content-policy.js | 2 +- content-policy.manifest | 4 ++++ modules/content-policy.js | 21 +++++++++++++++++++-- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 content-policy.manifest diff --git a/chrome.manifest b/chrome.manifest index 8cad998..a21c993 100644 --- a/chrome.manifest +++ b/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} diff --git a/components/content-policy.js b/components/content-policy.js index 9ea4f02..79e2484 100644 --- a/components/content-policy.js +++ b/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 diff --git a/content-policy.manifest b/content-policy.manifest new file mode 100644 index 0000000..49ad490 --- /dev/null +++ b/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 diff --git a/modules/content-policy.js b/modules/content-policy.js index 606cec4..b467630 100644 --- a/modules/content-policy.js +++ b/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.", -- 2.11.4.GIT