Bug 1547073 - Handle the case where the offscreen canvas has been disconnected from its owner global properly; r=baku
authorEhsan Akhgari <ehsan@mozilla.com>
Sat, 27 Apr 2019 00:11:55 +0000
changeset 530426 749bc2ac924298a5649697f2c759e8e6bc7e9e93
parent 530425 52b13dded51f032b89df622d31afa5e63bf24552
child 530427 c792b992164dad77f1df06c6bf8bbc9a7b4fb3e6
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1547073
milestone68.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 1547073 - Handle the case where the offscreen canvas has been disconnected from its owner global properly; r=baku Differential Revision: https://phabricator.services.mozilla.com/D29075
dom/canvas/WebGLContextExtensions.cpp
dom/canvas/WebGLContextValidate.cpp
--- a/dom/canvas/WebGLContextExtensions.cpp
+++ b/dom/canvas/WebGLContextExtensions.cpp
@@ -108,18 +108,22 @@ bool WebGLContext::IsExtensionSupported(
   if (mDisableExtensions) return false;
 
   bool shouldResistFingerprinting =
       mCanvasElement ?
                      // If we're constructed from a canvas element
           nsContentUtils::ShouldResistFingerprinting(GetOwnerDoc())
                      :
                      // If we're constructed from an offscreen canvas
-          nsContentUtils::ShouldResistFingerprinting(
-              mOffscreenCanvas->GetOwnerGlobal()->PrincipalOrNull());
+          (mOffscreenCanvas->GetOwnerGlobal()
+               ? nsContentUtils::ShouldResistFingerprinting(
+                     mOffscreenCanvas->GetOwnerGlobal()->PrincipalOrNull())
+               :
+               // Last resort, just check the global preference
+               nsContentUtils::ShouldResistFingerprinting());
 
   switch (ext) {
     // In alphabetical order
     // ANGLE_
     case WebGLExtensionID::ANGLE_instanced_arrays:
       return WebGLExtensionInstancedArrays::IsSupported(this);
 
     // EXT_
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -472,18 +472,22 @@ bool WebGLContext::InitAndValidateGL(Fai
 
   ////////////////
   bool shouldResistFingerprinting =
       mCanvasElement ?
                      // If we're constructed from a canvas element
           nsContentUtils::ShouldResistFingerprinting(GetOwnerDoc())
                      :
                      // If we're constructed from an offscreen canvas
-          nsContentUtils::ShouldResistFingerprinting(
-              mOffscreenCanvas->GetOwnerGlobal()->PrincipalOrNull());
+          (mOffscreenCanvas->GetOwnerGlobal()
+               ? nsContentUtils::ShouldResistFingerprinting(
+                     mOffscreenCanvas->GetOwnerGlobal()->PrincipalOrNull())
+               :
+               // Last resort, just check the global preference
+               nsContentUtils::ShouldResistFingerprinting());
 
   if (gfxPrefs::WebGLMinCapabilityMode()) {
     bool ok = true;
 
     ok &= RestrictCap(&mGLMaxVertexTextureImageUnits,
                       kMinMaxVertexTextureImageUnits);
     ok &= RestrictCap(&mGLMaxFragmentTextureImageUnits,
                       kMinMaxFragmentTextureImageUnits);