Bug 1402503: Part 1 - Fix slow script add-on ID detection. r=mixedpuppy
authorKris Maglione <maglione.k@gmail.com>
Mon, 25 Sep 2017 10:52:11 -0700
changeset 434294 71d2e5d65943b2fcd77faf2eebdcf3e1b20741c3
parent 434293 19370d245a119cb5688c57ec5b2b61fd0c763ec5
child 434295 d2fef59cb50727486b4d59125668808a0b2e46e4
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1402503
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1402503: Part 1 - Fix slow script add-on ID detection. r=mixedpuppy MozReview-Commit-ID: EYhOn2TQCq1
js/xpconnect/src/XPCJSContext.cpp
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -40,16 +40,17 @@
 #include "jsapi.h"
 #include "jsprf.h"
 #include "js/MemoryMetrics.h"
 #include "mozilla/dom/GeneratedAtomList.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ScriptLoader.h"
 #include "mozilla/dom/WindowBinding.h"
+#include "mozilla/extensions/WebExtensionPolicy.h"
 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ProcessHangMonitor.h"
 #include "mozilla/Sprintf.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "mozilla/Unused.h"
@@ -554,17 +555,21 @@ XPCJSContext::ActivityCallback(void* arg
 
     XPCJSContext* self = static_cast<XPCJSContext*>(arg);
     self->mWatchdogManager->RecordContextActivity(self, active);
 }
 
 static inline bool
 IsWebExtensionPrincipal(nsIPrincipal* principal, nsAString& addonId)
 {
-    return BasePrincipal::Cast(principal)->AddonPolicy();
+    if (auto policy = BasePrincipal::Cast(principal)->AddonPolicy()) {
+        policy->GetId(addonId);
+        return true;
+    }
+    return false;
 }
 
 static bool
 IsWebExtensionContentScript(BasePrincipal* principal, nsAString& addonId)
 {
     if (!principal->Is<ExpandedPrincipal>()) {
         return false;
     }