зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917745 - Cleanup sizeToContent r=webidl,reusable-components-reviewers,emilio,migration-reviewers,tgiles,mconley
- Remove the pref for enabling sizeToContent in unprivileged web content - Merge sizeToContentConstrained into sizeToContent - Remove tests that are not necessary now that sizeToContent is ChromeOnly Differential Revision: https://phabricator.services.mozilla.com/D221575
This commit is contained in:
Родитель
a07ef88380
Коммит
deaf2f58b1
|
@ -2,7 +2,6 @@
|
|||
head = "head.js"
|
||||
prefs = [
|
||||
"browser.migrate.internal-testing.enabled=true",
|
||||
"dom.window.sizeToContent.enabled=true",
|
||||
]
|
||||
support-files = ["../head-common.js"]
|
||||
tags = "os_integration"
|
||||
|
|
|
@ -64,5 +64,4 @@ DEPRECATED_OPERATION(OffscreenCanvasToBlob)
|
|||
DEPRECATED_OPERATION(SVGDeselectAll)
|
||||
DEPRECATED_OPERATION(SVGNearestViewportElement)
|
||||
DEPRECATED_OPERATION(SVGFarthestViewportElement)
|
||||
DEPRECATED_OPERATION(SizeToContent)
|
||||
DEPRECATED_OPERATION(IDBObjectStoreCreateIndexLocale)
|
||||
|
|
|
@ -3316,12 +3316,6 @@ bool nsGlobalWindowInner::CachesEnabled(JSContext* aCx, JSObject* aObj) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsGlobalWindowInner::IsSizeToContentEnabled(JSContext* aCx, JSObject*) {
|
||||
return StaticPrefs::dom_window_sizeToContent_enabled() ||
|
||||
nsContentUtils::IsSystemCaller(aCx);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsGlobalWindowInner::IsGleanNeeded(JSContext* aCx, JSObject* aObj) {
|
||||
// Glean is needed in ChromeOnly contexts and also in privileged about pages.
|
||||
|
@ -3784,16 +3778,10 @@ void nsGlobalWindowInner::ResizeBy(int32_t aWidthDif, int32_t aHeightDif,
|
|||
ResizeByOuter, (aWidthDif, aHeightDif, aCallerType, aError), aError, );
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::SizeToContent(CallerType aCallerType,
|
||||
ErrorResult& aError) {
|
||||
FORWARD_TO_OUTER_OR_THROW(SizeToContentOuter, (aCallerType, {}, aError),
|
||||
aError, );
|
||||
}
|
||||
|
||||
void nsGlobalWindowInner::SizeToContentConstrained(
|
||||
void nsGlobalWindowInner::SizeToContent(
|
||||
const SizeToContentConstraints& aConstraints, ErrorResult& aError) {
|
||||
FORWARD_TO_OUTER_OR_THROW(
|
||||
SizeToContentOuter, (CallerType::System, aConstraints, aError), aError, );
|
||||
FORWARD_TO_OUTER_OR_THROW(SizeToContentOuter, (aConstraints, aError),
|
||||
aError, );
|
||||
}
|
||||
|
||||
already_AddRefed<nsPIWindowRoot> nsGlobalWindowInner::GetTopWindowRoot() {
|
||||
|
|
|
@ -408,8 +408,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
|
||||
static bool CachesEnabled(JSContext* aCx, JSObject*);
|
||||
|
||||
static bool IsSizeToContentEnabled(JSContext*, JSObject*);
|
||||
|
||||
// WebIDL permission Func for whether Glean APIs are permitted.
|
||||
static bool IsGleanNeeded(JSContext*, JSObject*);
|
||||
|
||||
|
@ -846,10 +844,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
|
|||
already_AddRefed<nsICSSDeclaration> GetDefaultComputedStyle(
|
||||
mozilla::dom::Element& aElt, const nsAString& aPseudoElt,
|
||||
mozilla::ErrorResult& aError);
|
||||
void SizeToContent(mozilla::dom::CallerType aCallerType,
|
||||
mozilla::ErrorResult& aError);
|
||||
void SizeToContentConstrained(const mozilla::dom::SizeToContentConstraints&,
|
||||
mozilla::ErrorResult&);
|
||||
void SizeToContent(const mozilla::dom::SizeToContentConstraints&,
|
||||
mozilla::ErrorResult&);
|
||||
mozilla::dom::Crypto* GetCrypto(mozilla::ErrorResult& aError);
|
||||
nsIControllers* GetControllers(mozilla::ErrorResult& aError);
|
||||
nsresult GetControllers(nsIControllers** aControllers) override;
|
||||
|
|
|
@ -5414,18 +5414,12 @@ void nsGlobalWindowOuter::ResizeByOuter(int32_t aWidthDif, int32_t aHeightDif,
|
|||
}
|
||||
|
||||
void nsGlobalWindowOuter::SizeToContentOuter(
|
||||
CallerType aCallerType, const SizeToContentConstraints& aConstraints,
|
||||
ErrorResult& aError) {
|
||||
const SizeToContentConstraints& aConstraints, ErrorResult& aError) {
|
||||
if (!mDocShell) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* If caller is not chrome and the user has not explicitly exempted the site,
|
||||
* prevent window.sizeToContent() by exiting early
|
||||
*/
|
||||
|
||||
if (!CanMoveResizeWindows(aCallerType) || mBrowsingContext->IsSubframe()) {
|
||||
if (mBrowsingContext->IsSubframe()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -5443,8 +5437,6 @@ void nsGlobalWindowOuter::SizeToContentOuter(
|
|||
return aError.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
// Make sure the new size is following the CheckSecurityWidthAndHeight
|
||||
// rules.
|
||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
|
||||
if (!treeOwner) {
|
||||
return aError.Throw(NS_ERROR_FAILURE);
|
||||
|
@ -5459,7 +5451,6 @@ void nsGlobalWindowOuter::SizeToContentOuter(
|
|||
presContext,
|
||||
"Should be non-nullptr if nsIDocumentViewer::GetContentSize() succeeded");
|
||||
CSSIntSize cssSize = *contentSize;
|
||||
CheckSecurityWidthAndHeight(&cssSize.width, &cssSize.height, aCallerType);
|
||||
|
||||
LayoutDeviceIntSize newDevSize(
|
||||
presContext->CSSPixelsToDevPixels(cssSize.width),
|
||||
|
|
|
@ -606,8 +606,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
|
|||
double GetScrollYOuter();
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
||||
void SizeToContentOuter(mozilla::dom::CallerType,
|
||||
const mozilla::dom::SizeToContentConstraints&,
|
||||
void SizeToContentOuter(const mozilla::dom::SizeToContentConstraints&,
|
||||
mozilla::ErrorResult&);
|
||||
nsIControllers* GetControllersOuter(mozilla::ErrorResult& aError);
|
||||
nsresult GetControllers(nsIControllers** aControllers) override;
|
||||
|
|
|
@ -15097,23 +15097,6 @@ use.counter.deprecated_ops.page:
|
|||
send_in_pings:
|
||||
- use-counters
|
||||
|
||||
size_to_content:
|
||||
type: counter
|
||||
description: >
|
||||
Whether a page used SizeToContent.
|
||||
Compare against `use.counter.top_level_content_documents_destroyed`
|
||||
to calculate the rate.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
|
||||
notification_emails:
|
||||
- dom-core@mozilla.com
|
||||
- emilio@mozilla.com
|
||||
expires: never
|
||||
send_in_pings:
|
||||
- use-counters
|
||||
|
||||
idbobject_store_create_index_locale:
|
||||
type: counter
|
||||
description: >
|
||||
|
@ -16051,23 +16034,6 @@ use.counter.deprecated_ops.doc:
|
|||
send_in_pings:
|
||||
- use-counters
|
||||
|
||||
size_to_content:
|
||||
type: counter
|
||||
description: >
|
||||
Whether a document used SizeToContent.
|
||||
Compare against `use.counter.content_documents_destroyed`
|
||||
to calculate the rate.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1852098
|
||||
notification_emails:
|
||||
- dom-core@mozilla.com
|
||||
- emilio@mozilla.com
|
||||
expires: never
|
||||
send_in_pings:
|
||||
- use-counters
|
||||
|
||||
idbobject_store_create_index_locale:
|
||||
type: counter
|
||||
description: >
|
||||
|
|
|
@ -417,9 +417,6 @@ MathML_DeprecatedMathVariantWarning=“mathvariant='%S'” on MathML elements is
|
|||
MathML_DeprecatedStixgeneralOperatorStretchingWarning=Support for rendering stretched MathML operators with STIXGeneral fonts is deprecated and may be removed at a future date. For details about newer fonts that will continue to be supported, see %S
|
||||
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.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
[DEFAULT]
|
||||
tags = "condprof"
|
||||
prefs = ["dom.window.sizeToContent.enabled=true"]
|
||||
support-files = [
|
||||
"bug289714.sjs",
|
||||
"bug346659-echoer.html",
|
||||
|
@ -315,11 +314,6 @@ support-files = [
|
|||
"file_resize_move_windows_2.html",
|
||||
]
|
||||
|
||||
["test_sizetocontent_clamp.html"]
|
||||
skip-if = [
|
||||
"os == 'android'", #Windows can't change size on Android
|
||||
]
|
||||
|
||||
["test_toJSON.html"]
|
||||
|
||||
["test_window_bar.html"]
|
||||
|
|
|
@ -140,8 +140,6 @@ function checkChangeIsDisabled(aWindow) {
|
|||
aWindow.resizeBy(newWidth - aWindow.innerWidth,
|
||||
newHeight - aWindow.innerHeight);
|
||||
|
||||
aWindow.sizeToContent();
|
||||
|
||||
/**
|
||||
* Position checks.
|
||||
*/
|
||||
|
@ -250,7 +248,7 @@ function checkChangeIsEnabled(aWindow, aNext)
|
|||
return hitEventLoop(sizeChangeCondition, sizeChangeTest, hits);
|
||||
})
|
||||
.then(function() {
|
||||
aWindow.sizeToContent();
|
||||
aWindow.resizeTo(500, 500);
|
||||
return hitEventLoop(sizeChangeCondition, sizeChangeTest, hits);
|
||||
})
|
||||
.then(function() {
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=764240
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 764240</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=764240">Mozilla Bug 764240</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<button onclick="test();">run test</button>
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 764240 **/
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
// Error margin allowed for the window's size. Windows has varying minimum
|
||||
// sizes depending on the os due to outer window chrome. Unix is given 5
|
||||
// pixels to protect against minor variances.
|
||||
var epsilon = !navigator.platform.includes("Win") ? 5 : 20;
|
||||
|
||||
// Windows 8 has a minimum 122 pixel inner window width due to
|
||||
// outer window chrome.
|
||||
var isWin8 = (navigator.userAgent.includes("Windows NT 6.2"));
|
||||
|
||||
var innerWidthMin = (isWin8 ? 120 : 100);
|
||||
var innerWidthMax = (isWin8 ? 125 : 100);
|
||||
|
||||
// Window size with CSD decorations is 180 pixels
|
||||
if (navigator.platform.includes("Linux")) {
|
||||
innerWidthMax = 180;
|
||||
}
|
||||
|
||||
var isExecuted = false;
|
||||
|
||||
function test() {
|
||||
var w = window.open('file_empty.html', null, 'width=300,height=300');
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
w.onresize = function() {
|
||||
info(`got resize: ${w.innerWidth} ${w.innerHeight}`);
|
||||
|
||||
if (w.innerWidth > 300 - epsilon || isExecuted) {
|
||||
return;
|
||||
}
|
||||
|
||||
isExecuted = true;
|
||||
|
||||
ok(w.innerWidth + epsilon >= innerWidthMin && w.innerWidth - epsilon <= innerWidthMax,
|
||||
"innerWidth should be between " + innerWidthMin + " and " + innerWidthMax + " but it was: " + w.innerWidth);
|
||||
ok(w.innerHeight + epsilon >= 100 && w.innerHeight - epsilon <= 100,
|
||||
"innerHeight should be around 100" + " but it was: " + w.innerHeight);
|
||||
|
||||
w.close();
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
SimpleTest.finish();
|
||||
});
|
||||
};
|
||||
w.sizeToContent();
|
||||
}, w);
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
synthesizeMouseAtCenter(document.getElementsByTagName('button')[0], {});
|
||||
});
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -405,18 +405,12 @@ partial interface Window {
|
|||
*/
|
||||
undefined scrollByPages(long numPages, optional ScrollOptions options = {});
|
||||
|
||||
// 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.
|
||||
* Chrome-only method for sizing to content with an optional
|
||||
* maximum-size constraint on either (or both) directions.
|
||||
*/
|
||||
[Throws, ChromeOnly] undefined sizeToContentConstrained(optional SizeToContentConstraints constraints = {});
|
||||
[Throws, ChromeOnly] undefined sizeToContent(optional SizeToContentConstraints constraints = {});
|
||||
|
||||
[ChromeOnly, Replaceable, Throws] readonly attribute XULControllers controllers;
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
[DEFAULT]
|
||||
prefs = [
|
||||
"dom.window.sizeToContent.enabled=true",
|
||||
]
|
||||
skip-if = ["os == 'android'"]
|
||||
support-files = [
|
||||
"animated.gif",
|
||||
|
|
|
@ -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) pref(dom.window.sizeToContent.enabled,true) load 1663722.html
|
||||
skip-if(Android) load 1663722.html
|
||||
skip-if(Android) load 1671503.html
|
||||
load 1748277.html # Bug 1751260
|
||||
# load 1758199-1.html # this test is run at the very end in testing/crashtest/final/crashtests.list
|
||||
|
|
|
@ -4925,12 +4925,6 @@
|
|||
value: true
|
||||
mirror: always
|
||||
|
||||
# Whether Window.sizeToContent() is enabled.
|
||||
- name: dom.window.sizeToContent.enabled
|
||||
type: bool
|
||||
value: false
|
||||
mirror: always
|
||||
|
||||
- name: dom.worker.canceling.timeoutMilliseconds
|
||||
type: RelaxedAtomicUint32
|
||||
value: 30000 # 30 seconds
|
||||
|
|
|
@ -213,7 +213,7 @@
|
|||
}
|
||||
return 0;
|
||||
})();
|
||||
window.sizeToContentConstrained({ prefWidth });
|
||||
window.sizeToContent({ prefWidth });
|
||||
}
|
||||
|
||||
moveToAlertPosition() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче