Skip to content

Commit

Permalink
Bug 1832733 - Unexpose sizeToContent() in Nightly. r=emilio
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewhodson committed May 19, 2023
1 parent 656f5b6 commit 67525df
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions browser/components/migration/tests/browser/browser.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ prefs =

[browser_aboutwelcome_behavior.js]
[browser_dialog_cancel_close.js]
prefs = dom.window.sizeToContent.enabled=true
[browser_dialog_open.js]
[browser_dialog_resize.js]
[browser_disabled_migrator.js]
Expand Down
1 change: 1 addition & 0 deletions dom/base/nsDeprecatedOperationList.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ DEPRECATED_OPERATION(OffscreenCanvasToBlob)
DEPRECATED_OPERATION(MozPreservesPitchDeprecatedPrefix)
DEPRECATED_OPERATION(SVGNearestViewportElement)
DEPRECATED_OPERATION(SVGFarthestViewportElement)
DEPRECATED_OPERATION(SizeToContent)
6 changes: 6 additions & 0 deletions dom/base/nsGlobalWindowInner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3338,6 +3338,12 @@ bool nsGlobalWindowInner::CachesEnabled(JSContext* aCx, JSObject*) {
return true;
}

/* static */
bool nsGlobalWindowInner::IsSizeToContentEnabled(JSContext* aCx, JSObject*) {
return StaticPrefs::dom_window_sizeToContent_enabled() ||
nsContentUtils::IsSystemCaller(aCx);
}

nsDOMOfflineResourceList* nsGlobalWindowInner::GetApplicationCache(
ErrorResult& aError) {
if (!mApplicationCache) {
Expand Down
2 changes: 2 additions & 0 deletions dom/base/nsGlobalWindowInner.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,

static bool CachesEnabled(JSContext* aCx, JSObject*);

static bool IsSizeToContentEnabled(JSContext*, JSObject*);

bool DoResolve(
JSContext* aCx, JS::Handle<JSObject*> aObj, JS::Handle<jsid> aId,
JS::MutableHandle<mozilla::Maybe<JS::PropertyDescriptor>> aDesc);
Expand Down
4 changes: 4 additions & 0 deletions dom/locales/en-US/chrome/dom/dom.properties
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ MathML_DeprecatedScriptminsizeAttributeWarning=MathML attribute “scriptminsize
# LOCALIZATION NOTE: Do not translate MathML and scriptsizemultiplier.
MathML_DeprecatedScriptsizemultiplierAttributeWarning=MathML attribute “scriptsizemultiplier” is deprecated and will be removed at a future date.
FormSubmissionUntrustedEventWarning=Form submission via untrusted submit event is deprecated and will be removed at a future date.

# LOCALIZATION NOTE: Do not translate "sizeToContent()".
SizeToContentWarning=sizeToContent() is deprecated and will be removed in the future.

WebShareAPI_Failed=The share operation has failed.
WebShareAPI_Aborted=The share operation was aborted.
# LOCALIZATION NOTE (UnknownProtocolNavigationPrevented): %1$S is the destination URL.
Expand Down
2 changes: 2 additions & 0 deletions dom/tests/mochitest/bugs/mochitest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ skip-if =
[test_onerror_message.html]
[test_protochains.html]
[test_resize_move_windows.html]
prefs = dom.window.sizeToContent.enabled=true
skip-if = toolkit == 'android'
os == 'linux'
os == "mac" # Bug 1781569
Expand All @@ -169,6 +170,7 @@ support-files =
file_resize_move_windows_1.html
file_resize_move_windows_2.html
[test_sizetocontent_clamp.html]
prefs = dom.window.sizeToContent.enabled=true
skip-if = toolkit == 'android' #Windows can't change size on Android
[test_toJSON.html]
[test_window_bar.html]
Expand Down
2 changes: 1 addition & 1 deletion dom/tests/mochitest/general/test_interfaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@ let interfaceNamesInGlobalScope = [
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "setTimeout", insecureContext: true },
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "sizeToContent", insecureContext: true },
{ name: "sizeToContent", insecureContext: true, nightly: false },
// IMPORTANT: Do not change this list without review from a DOM peer!
{ name: "speechSynthesis", insecureContext: true },
// IMPORTANT: Do not change this list without review from a DOM peer!
Expand Down
11 changes: 7 additions & 4 deletions dom/webidl/Window.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,13 @@ partial interface Window {
*/
undefined scrollByPages(long numPages, optional ScrollOptions options = {});

/**
* Method for sizing this window to the content in the window.
*/
[Throws, NeedsCallerType] undefined sizeToContent();
// Gecko specific API that allows a web page to resize the browser window.
// Dropping support in bug 1600400.
[Throws, NeedsCallerType,
Deprecated="SizeToContent",
Func="nsGlobalWindowInner::IsSizeToContentEnabled"]
undefined sizeToContent();

/**
* Chrome-only method for sizing to content with a maximum-size constraint on
* either (or both) directions.
Expand Down
2 changes: 1 addition & 1 deletion layout/printing/crashtests/crashtests.list
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ load 509839-2.html
load 576878.xhtml
asserts-if(Android,0-1) load 793844.html
skip-if(Android) load 1662259.html
skip-if(Android) load 1663722.html
skip-if(Android) pref(dom.window.sizeToContent.enabled,true) load 1663722.html
skip-if(Android) load 1671503.html
load 1748277.html # Bug 1751260
load 1758199-1.html
Expand Down
6 changes: 6 additions & 0 deletions modules/libpref/init/StaticPrefList.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4768,6 +4768,12 @@
value: false
mirror: always

# Whether Window.sizeToContent() is enabled.
- name: dom.window.sizeToContent.enabled
type: bool
value: @IS_NOT_NIGHTLY_BUILD@
mirror: always

- name: dom.worker.canceling.timeoutMilliseconds
type: RelaxedAtomicUint32
value: 30000 # 30 seconds
Expand Down

0 comments on commit 67525df

Please sign in to comment.