Bug 1576254 - Add isSystemOrAddonPrincipal to WorkletPrincipal r=baku
authorTom Ritter <tom@mozilla.com>
Fri, 04 Oct 2019 17:36:40 +0000
changeset 496388 59f5758eb829c44389971429ac5d1857dae323b8
parent 496387 b99e1c5e8d228fec6020c011fdb89e080a79c40d
child 496389 2498e68e641cbac86bac59a54ffd8372e2a905ec
push id97215
push usertritter@mozilla.com
push dateFri, 04 Oct 2019 19:40:14 +0000
treeherderautoland@35dfc96baca1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1576254, 1578623
milestone71.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 1576254 - Add isSystemOrAddonPrincipal to WorkletPrincipal r=baku WorkletPrincipal inherits JSPrincipals so we need to add the isSystemOrAddonPrincipal method to it. As of Bug 1578623 rev a83797ed249c - Worklets are always NullPrincipal, so we can just return false. Differential Revision: https://phabricator.services.mozilla.com/D47475
dom/worklet/WorkletPrincipals.cpp
dom/worklet/WorkletPrincipals.h
--- a/dom/worklet/WorkletPrincipals.cpp
+++ b/dom/worklet/WorkletPrincipals.cpp
@@ -22,14 +22,19 @@ bool WorkletPrincipals::write(JSContext*
                               JSStructuredCloneWriter* aWriter) {
   // This is a serialization of the NullPrincipal corresponding to the worklet
   // environment settings object for the WorkletGlobalScope.
   // https://drafts.css-houdini.org/worklets/#set-up-a-worklet-environment-settings-object
   return nsJSPrincipals::WritePrincipalInfo(aWriter,
                                             mWorkletImpl->PrincipalInfo());
 }
 
+bool WorkletPrincipals::isSystemOrAddonPrincipal() {
+  // Per Bug 1578623 rev a83797ed249c - Worklets are always NullPrincipal
+  return false;
+}
+
 void WorkletPrincipals::Destroy(JSPrincipals* aPrincipals) {
   delete static_cast<WorkletPrincipals*>(aPrincipals);
 }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/worklet/WorkletPrincipals.h
+++ b/dom/worklet/WorkletPrincipals.h
@@ -17,16 +17,18 @@ class WorkletImpl;
 namespace dom {
 
 struct MOZ_HEAP_CLASS WorkletPrincipals final : public JSPrincipals {
   // A new WorkletPrincipals has refcount zero.
   explicit WorkletPrincipals(WorkletImpl* aWorkletImpl);
 
   bool write(JSContext* aCx, JSStructuredCloneWriter* aWriter) override;
 
+  bool isSystemOrAddonPrincipal() override;
+
   // Callback for JS_InitDestroyPrincipalsCallback()
   static void Destroy(JSPrincipals* aPrincipals);
 
   static const uint32_t kJSPrincipalsDebugToken = 0x7e2df9f4;
 
  private:
   ~WorkletPrincipals();
   RefPtr<WorkletImpl> mWorkletImpl;