From afcb3962b4a14c301b795aeb4ef9d31d5f6450d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 21 Oct 2022 19:00:57 +0000 Subject: [PATCH] Bug 1796819 - Remove OffscreenCanvas origin trial / domain allowlist. r=aosmond We've shipped this, a single pref should be enough. Differential Revision: https://phabricator.services.mozilla.com/D159947 --- dom/canvas/CanvasUtils.cpp | 34 ------------------- dom/canvas/OffscreenCanvas.cpp | 6 +--- dom/origin-trials/OriginTrials.cpp | 2 -- dom/origin-trials/ffi/lib.rs | 4 +-- .../tests/mochitest/test_meta_simple.html | 5 --- dom/webidl/HTMLCanvasElement.webidl | 2 +- dom/webidl/OffscreenCanvas.webidl | 3 +- .../OffscreenCanvasRenderingContext2D.webidl | 3 +- modules/libpref/init/StaticPrefList.yaml | 19 ----------- 9 files changed, 5 insertions(+), 73 deletions(-) diff --git a/dom/canvas/CanvasUtils.cpp b/dom/canvas/CanvasUtils.cpp index 37fef582ecb2..0ded590c0b94 100644 --- a/dom/canvas/CanvasUtils.cpp +++ b/dom/canvas/CanvasUtils.cpp @@ -341,40 +341,6 @@ bool HasDrawWindowPrivilege(JSContext* aCx, JSObject* /* unused */) { nsGkAtoms::all_urlsPermission); } -bool IsOffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj) { - if (StaticPrefs::gfx_offscreencanvas_enabled()) { - return true; - } - - if (OriginTrials::IsEnabled(aCx, aObj, OriginTrial::OffscreenCanvas)) { - return true; - } - - if (!StaticPrefs::gfx_offscreencanvas_domain_enabled()) { - return false; - } - - if (!NS_IsMainThread()) { - dom::WorkerPrivate* workerPrivate = dom::GetWorkerPrivateFromContext(aCx); - if (workerPrivate->UsesSystemPrincipal() || - workerPrivate->OriginNoSuffix() == u"resource://pdf.js"_ns) { - return true; - } - - const auto prefLock = StaticPrefs::gfx_offscreencanvas_domain_allowlist(); - return nsContentUtils::IsURIInList(workerPrivate->GetBaseURI(), *prefLock); - } - - nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx); - if (principal->IsSystemPrincipal() || nsContentUtils::IsPDFJS(principal)) { - return true; - } - - nsCOMPtr uri = principal->GetURI(); - const auto prefLock = StaticPrefs::gfx_offscreencanvas_domain_allowlist(); - return nsContentUtils::IsURIInList(uri, *prefLock); -} - bool CheckWriteOnlySecurity(bool aCORSUsed, nsIPrincipal* aPrincipal, bool aHadCrossOriginRedirects) { if (!aPrincipal) { diff --git a/dom/canvas/OffscreenCanvas.cpp b/dom/canvas/OffscreenCanvas.cpp index 4c1cb538f761..870fd0048ab4 100644 --- a/dom/canvas/OffscreenCanvas.cpp +++ b/dom/canvas/OffscreenCanvas.cpp @@ -446,11 +446,7 @@ already_AddRefed OffscreenCanvas::CreateFromCloneData( /* static */ bool OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj) { - if (NS_IsMainThread()) { - return true; - } - - return CanvasUtils::IsOffscreenCanvasEnabled(aCx, aObj); + return NS_IsMainThread() || StaticPrefs::gfx_offscreencanvas_enabled(); } NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper, diff --git a/dom/origin-trials/OriginTrials.cpp b/dom/origin-trials/OriginTrials.cpp index e9c4eaddcbd8..9f9e6b44fee0 100644 --- a/dom/origin-trials/OriginTrials.cpp +++ b/dom/origin-trials/OriginTrials.cpp @@ -210,8 +210,6 @@ static int32_t PrefState(OriginTrial aTrial) { switch (aTrial) { case OriginTrial::TestTrial: return StaticPrefs::dom_origin_trials_test_trial_state(); - case OriginTrial::OffscreenCanvas: - return StaticPrefs::dom_origin_trials_offscreen_canvas_state(); case OriginTrial::CoepCredentialless: return StaticPrefs::dom_origin_trials_coep_credentialless_state(); case OriginTrial::MAX: diff --git a/dom/origin-trials/ffi/lib.rs b/dom/origin-trials/ffi/lib.rs index f850fe52458d..1745c9e790a6 100644 --- a/dom/origin-trials/ffi/lib.rs +++ b/dom/origin-trials/ffi/lib.rs @@ -9,8 +9,7 @@ use std::ffi::c_void; pub enum OriginTrial { // NOTE(emilio): 0 is reserved for WebIDL usage. TestTrial = 1, - OffscreenCanvas = 2, - CoepCredentialless = 3, + CoepCredentialless = 2, MAX, } @@ -19,7 +18,6 @@ impl OriginTrial { fn from_str(s: &str) -> Option { Some(match s { "TestTrial" => Self::TestTrial, - "OffscreenCanvas" => Self::OffscreenCanvas, "CoepCredentialless" => Self::CoepCredentialless, _ => return None, }) diff --git a/dom/origin-trials/tests/mochitest/test_meta_simple.html b/dom/origin-trials/tests/mochitest/test_meta_simple.html index 9afd4a645c16..8b853a8774f3 100644 --- a/dom/origin-trials/tests/mochitest/test_meta_simple.html +++ b/dom/origin-trials/tests/mochitest/test_meta_simple.html @@ -1,17 +1,12 @@ - -