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
This commit is contained in:
Emilio Cobos Álvarez 2022-10-21 19:00:57 +00:00
Родитель 605f03838c
Коммит afcb3962b4
9 изменённых файлов: 5 добавлений и 73 удалений

Просмотреть файл

@ -341,40 +341,6 @@ bool HasDrawWindowPrivilege(JSContext* aCx, JSObject* /* unused */) {
nsGkAtoms::all_urlsPermission); 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<nsIURI> uri = principal->GetURI();
const auto prefLock = StaticPrefs::gfx_offscreencanvas_domain_allowlist();
return nsContentUtils::IsURIInList(uri, *prefLock);
}
bool CheckWriteOnlySecurity(bool aCORSUsed, nsIPrincipal* aPrincipal, bool CheckWriteOnlySecurity(bool aCORSUsed, nsIPrincipal* aPrincipal,
bool aHadCrossOriginRedirects) { bool aHadCrossOriginRedirects) {
if (!aPrincipal) { if (!aPrincipal) {

Просмотреть файл

@ -446,11 +446,7 @@ already_AddRefed<OffscreenCanvas> OffscreenCanvas::CreateFromCloneData(
/* static */ /* static */
bool OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, bool OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx,
JSObject* aObj) { JSObject* aObj) {
if (NS_IsMainThread()) { return NS_IsMainThread() || StaticPrefs::gfx_offscreencanvas_enabled();
return true;
}
return CanvasUtils::IsOffscreenCanvasEnabled(aCx, aObj);
} }
NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper, NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper,

Просмотреть файл

@ -210,8 +210,6 @@ static int32_t PrefState(OriginTrial aTrial) {
switch (aTrial) { switch (aTrial) {
case OriginTrial::TestTrial: case OriginTrial::TestTrial:
return StaticPrefs::dom_origin_trials_test_trial_state(); return StaticPrefs::dom_origin_trials_test_trial_state();
case OriginTrial::OffscreenCanvas:
return StaticPrefs::dom_origin_trials_offscreen_canvas_state();
case OriginTrial::CoepCredentialless: case OriginTrial::CoepCredentialless:
return StaticPrefs::dom_origin_trials_coep_credentialless_state(); return StaticPrefs::dom_origin_trials_coep_credentialless_state();
case OriginTrial::MAX: case OriginTrial::MAX:

Просмотреть файл

@ -9,8 +9,7 @@ use std::ffi::c_void;
pub enum OriginTrial { pub enum OriginTrial {
// NOTE(emilio): 0 is reserved for WebIDL usage. // NOTE(emilio): 0 is reserved for WebIDL usage.
TestTrial = 1, TestTrial = 1,
OffscreenCanvas = 2, CoepCredentialless = 2,
CoepCredentialless = 3,
MAX, MAX,
} }
@ -19,7 +18,6 @@ impl OriginTrial {
fn from_str(s: &str) -> Option<Self> { fn from_str(s: &str) -> Option<Self> {
Some(match s { Some(match s {
"TestTrial" => Self::TestTrial, "TestTrial" => Self::TestTrial,
"OffscreenCanvas" => Self::OffscreenCanvas,
"CoepCredentialless" => Self::CoepCredentialless, "CoepCredentialless" => Self::CoepCredentialless,
_ => return None, _ => return None,
}) })

Просмотреть файл

@ -1,17 +1,12 @@
<!doctype html> <!doctype html>
<!-- Created with: mktoken --origin 'https://example.com' --feature TestTrial --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 --> <!-- Created with: mktoken --origin 'https://example.com' --feature TestTrial --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="AyGdETIKWLLqe+chG57f74gZcjYSfbdYAapEq7DA49E6CmaYaPmaoXh/4tAe5XJJJdwwpFVal7hz/irC+Wvp1HgAAABLeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9"> <meta http-equiv="origin-trial" content="AyGdETIKWLLqe+chG57f74gZcjYSfbdYAapEq7DA49E6CmaYaPmaoXh/4tAe5XJJJdwwpFVal7hz/irC+Wvp1HgAAABLeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IlRlc3RUcmlhbCIsImV4cGlyeSI6MzI1MDM2ODAwMDB9">
<!-- Created with: mktoken --origin 'https://example.com' --feature OffscreenCanvas --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="Ay92n3CdO5VIYbmQB7t7r7e4c34nT1k9zbX5ON2JthrXaOFxLn5NieN7ITlKhPbmPSLA4qoS+TBdshqEUwmVaIwAAABReyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6Ik9mZnNjcmVlbkNhbnZhcyIsImV4cGlyeSI6MzI1MDM2ODAwMDB9">
<!-- Created with: mktoken --origin 'https://example.com' --feature CoepCredentialless --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 --> <!-- Created with: mktoken --origin 'https://example.com' --feature CoepCredentialless --expiry 'Wed, 01 Jan 3000 01:00:00 +0100' --sign test-keys/test-ecdsa.pkcs8 -->
<meta http-equiv="origin-trial" content="Az+DK2Kczk8Xz1cAlD+TkvPZmuM2uJZ2CFefbp2hLuCU9FbUqxWTyQ2tEYr50r0syKELcOZLAPaABw8aYTLHn5YAAABUeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IkNvZXBDcmVkZW50aWFsbGVzcyIsImV4cGlyeSI6MzI1MDM2ODAwMDB9"> <meta http-equiv="origin-trial" content="Az+DK2Kczk8Xz1cAlD+TkvPZmuM2uJZ2CFefbp2hLuCU9FbUqxWTyQ2tEYr50r0syKELcOZLAPaABw8aYTLHn5YAAABUeyJvcmlnaW4iOiJodHRwczovL2V4YW1wbGUuY29tIiwiZmVhdHVyZSI6IkNvZXBDcmVkZW50aWFsbGVzcyIsImV4cGlyeSI6MzI1MDM2ODAwMDB9">
<script src="/tests/SimpleTest/SimpleTest.js"></script> <script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="common.js"></script> <script src="common.js"></script>
<script> <script>
assertTestTrialActive(true); assertTestTrialActive(true);
add_task(function() {
ok(!!self.OffscreenCanvas, "OffscreenCanvas trial works.");
});
add_task(function() { add_task(function() {
ok(!!SpecialPowers.DOMWindowUtils.isCoepCredentialless(), "CoepCredentialless trial works."); ok(!!SpecialPowers.DOMWindowUtils.isCoepCredentialless(), "CoepCredentialless trial works.");
}); });

Просмотреть файл

@ -49,7 +49,7 @@ partial interface HTMLCanvasElement {
// For OffscreenCanvas // For OffscreenCanvas
// Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
partial interface HTMLCanvasElement { partial interface HTMLCanvasElement {
[Func="CanvasUtils::IsOffscreenCanvasEnabled", Throws] [Pref="gfx.offscreencanvas.enabled", Throws]
OffscreenCanvas transferControlToOffscreen(); OffscreenCanvas transferControlToOffscreen();
}; };

Просмотреть файл

@ -16,8 +16,7 @@ dictionary ImageEncodeOptions {
enum OffscreenRenderingContextId { "2d", "bitmaprenderer", "webgl", "webgl2", "webgpu" }; enum OffscreenRenderingContextId { "2d", "bitmaprenderer", "webgl", "webgl2", "webgpu" };
[Exposed=(Window,Worker), [Exposed=(Window,Worker), Pref="gfx.offscreencanvas.enabled"]
Func="CanvasUtils::IsOffscreenCanvasEnabled"]
interface OffscreenCanvas : EventTarget { interface OffscreenCanvas : EventTarget {
constructor([EnforceRange] unsigned long width, [EnforceRange] unsigned long height); constructor([EnforceRange] unsigned long width, [EnforceRange] unsigned long height);

Просмотреть файл

@ -7,8 +7,7 @@
* https://html.spec.whatwg.org/#the-offscreen-2d-rendering-context * https://html.spec.whatwg.org/#the-offscreen-2d-rendering-context
*/ */
[Exposed=(Window,Worker), [Exposed=(Window,Worker), Pref="gfx.offscreencanvas.enabled"]
Func="CanvasUtils::IsOffscreenCanvasEnabled"]
interface OffscreenCanvasRenderingContext2D { interface OffscreenCanvasRenderingContext2D {
[Throws] [Throws]
undefined commit(); undefined commit();

Просмотреть файл

@ -3073,13 +3073,6 @@
value: 0 value: 0
mirror: always mirror: always
# Origin trial state for OffscreenCanvas.
# 0: normal, 1: always-enabled, 2: always-disabled
- name: dom.origin-trials.offscreen-canvas.state
type: RelaxedAtomicInt32
value: 0
mirror: always
# Origin trial state for COEP: Credentialless. # Origin trial state for COEP: Credentialless.
# 0: normal, 1: always-enabled, 2: always-disabled # 0: normal, 1: always-enabled, 2: always-disabled
- name: dom.origin-trials.coep-credentialless.state - name: dom.origin-trials.coep-credentialless.state
@ -5979,18 +5972,6 @@
value: true value: true
mirror: always mirror: always
# Enable OffscreenCanvas based on the domain allowlist.
- name: gfx.offscreencanvas.domain-enabled
type: RelaxedAtomicBool
value: true
mirror: always
# Domains included in the allowlist.
- name: gfx.offscreencanvas.domain-allowlist
type: DataMutexString
value: "*.zoom.us,zoom.us"
mirror: always
- name: gfx.omta.background-color - name: gfx.omta.background-color
type: bool type: bool
value: true value: true