Bug 1623826 - Do not expose outerWidth/outerHeight features of window.open to web content. r=smaug

Depends on D81969

Differential Revision: https://phabricator.services.mozilla.com/D81970
This commit is contained in:
Tooru Fujisawa 2020-07-15 04:40:08 +00:00
Родитель 7c0bb4dbca
Коммит 2477f5a5d5
11 изменённых файлов: 68 добавлений и 174 удалений

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

@ -23,11 +23,8 @@ skip-if = (os == "mac") #Bug 1570812
[browser_roundedWindow_dialogWindow.js]
[browser_roundedWindow_newWindow.js]
[browser_roundedWindow_open_max_inner.js]
[browser_roundedWindow_open_max_outer.js]
[browser_roundedWindow_open_mid_inner.js]
[browser_roundedWindow_open_mid_outer.js]
[browser_roundedWindow_open_min_inner.js]
[browser_roundedWindow_open_min_outer.js]
[browser_roundedWindow_windowSetting_max_inner.js]
[browser_roundedWindow_windowSetting_max_outer.js]
[browser_roundedWindow_windowSetting_mid_inner.js]

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

@ -4,26 +4,23 @@
* maximum values.
*/
OpenTest.run(
[
{
settingWidth: 1025,
settingHeight: 1050,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 9999,
settingHeight: 9999,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 999,
settingHeight: 999,
targetWidth: 1000,
targetHeight: 1000,
},
],
false
);
OpenTest.run([
{
settingWidth: 1025,
settingHeight: 1050,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 9999,
settingHeight: 9999,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 999,
settingHeight: 999,
targetWidth: 1000,
targetHeight: 1000,
},
]);

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

@ -1,29 +0,0 @@
/*
* Bug 1330882 - A test case for opening new windows through window.open() as
* rounded size when fingerprinting resistance is enabled. This test is for
* maximum values.
*/
OpenTest.run(
[
{
settingWidth: 1025,
settingHeight: 1050,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 9999,
settingHeight: 9999,
targetWidth: 1000,
targetHeight: 1000,
},
{
settingWidth: 999,
settingHeight: 999,
targetWidth: 1000,
targetHeight: 1000,
},
],
true
);

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

@ -4,26 +4,23 @@
* middle values.
*/
OpenTest.run(
[
{
settingWidth: 600,
settingHeight: 600,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 599,
settingHeight: 599,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 401,
settingHeight: 501,
targetWidth: 600,
targetHeight: 600,
},
],
false
);
OpenTest.run([
{
settingWidth: 600,
settingHeight: 600,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 599,
settingHeight: 599,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 401,
settingHeight: 501,
targetWidth: 600,
targetHeight: 600,
},
]);

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

@ -1,29 +0,0 @@
/*
* Bug 1330882 - A test case for opening new windows through window.open() as
* rounded size when fingerprinting resistance is enabled. This test is for
* middle values.
*/
OpenTest.run(
[
{
settingWidth: 600,
settingHeight: 600,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 599,
settingHeight: 599,
targetWidth: 600,
targetHeight: 600,
},
{
settingWidth: 401,
settingHeight: 501,
targetWidth: 600,
targetHeight: 600,
},
],
true
);

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

@ -4,20 +4,17 @@
* minimum values.
*/
OpenTest.run(
[
{
settingWidth: 199,
settingHeight: 99,
targetWidth: 200,
targetHeight: 100,
},
{
settingWidth: 10,
settingHeight: 10,
targetWidth: 200,
targetHeight: 100,
},
],
false
);
OpenTest.run([
{
settingWidth: 199,
settingHeight: 99,
targetWidth: 200,
targetHeight: 100,
},
{
settingWidth: 10,
settingHeight: 10,
targetWidth: 200,
targetHeight: 100,
},
]);

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

@ -1,23 +0,0 @@
/*
* Bug 1330882 - A test case for opening new windows through window.open() as
* rounded size when fingerprinting resistance is enabled. This test is for
* minimum values.
*/
OpenTest.run(
[
{
settingWidth: 199,
settingHeight: 99,
targetWidth: 200,
targetHeight: 100,
},
{
settingWidth: 10,
settingHeight: 10,
targetWidth: 200,
targetHeight: 100,
},
],
true
);

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

@ -220,7 +220,6 @@ async function testWindowOpen(
aSettingHeight,
aTargetWidth,
aTargetHeight,
aTestOuter,
aMaxAvailWidth,
aMaxAvailHeight,
aPopupChromeUIWidth,
@ -237,17 +236,7 @@ async function testWindowOpen(
}
// Create the testing window features.
let winFeatures;
if (aTestOuter) {
winFeatures =
"outerWidth=" +
(aSettingWidth + aPopupChromeUIWidth) +
",outerHeight=" +
(aSettingHeight + aPopupChromeUIHeight);
} else {
winFeatures = "width=" + aSettingWidth + ",height=" + aSettingHeight;
}
let winFeatures = "width=" + aSettingWidth + ",height=" + aSettingHeight;
let testParams = {
winFeatures,
@ -492,14 +481,13 @@ class WindowSettingTest extends RoundedWindowTest {
}
class OpenTest extends RoundedWindowTest {
async doTest(test, testOuter) {
async doTest(test) {
await testWindowOpen(
this.tab.linkedBrowser,
test.settingWidth,
test.settingHeight,
test.targetWidth,
test.targetHeight,
testOuter,
this.maxAvailWidth,
this.maxAvailHeight,
this.popupChromeUIWidth,

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

@ -515,7 +515,7 @@ nsWindowWatcher::OpenWindowWithRemoteTab(nsIRemoteTab* aRemoteTab,
features.Tokenize(aFeatures);
SizeSpec sizeSpec;
CalcSizeSpec(features, sizeSpec);
CalcSizeSpec(features, false, sizeSpec);
uint32_t chromeFlags = CalculateChromeFlagsForContent(features, sizeSpec);
@ -686,7 +686,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
bool isCallerChrome = nsContentUtils::LegacyIsCallerChromeOrNativeCode();
SizeSpec sizeSpec;
CalcSizeSpec(features, sizeSpec);
CalcSizeSpec(features, hasChromeParent, sizeSpec);
// Make sure we calculate the chromeFlags *before* we push the
// callee context onto the context stack so that
@ -2009,7 +2009,7 @@ already_AddRefed<BrowsingContext> nsWindowWatcher::GetBrowsingContextByName(
// static
void nsWindowWatcher::CalcSizeSpec(const WindowFeatures& aFeatures,
SizeSpec& aResult) {
bool aHasChromeParent, SizeSpec& aResult) {
// https://drafts.csswg.org/cssom-view/#set-up-browsing-context-features
// To set up browsing context features for a browsing context `target` given
// a map `tokenizedFeatures`:
@ -2067,8 +2067,8 @@ void nsWindowWatcher::CalcSizeSpec(const WindowFeatures& aFeatures,
}
// Non-standard extension.
// See bug 1623826
if (aFeatures.Exists("outerwidth")) {
// Not exposed to web content.
if (aHasChromeParent && aFeatures.Exists("outerwidth")) {
int32_t width = aFeatures.GetInt("outerwidth");
if (width) {
aResult.mOuterWidth = width;
@ -2107,8 +2107,8 @@ void nsWindowWatcher::CalcSizeSpec(const WindowFeatures& aFeatures,
}
// Non-standard extension.
// See bug 1623826
if (aFeatures.Exists("outerheight")) {
// Not exposed to web content.
if (aHasChromeParent && aFeatures.Exists("outerheight")) {
int32_t height = aFeatures.GetInt("outerheight");
if (height) {
aResult.mOuterHeight = height;

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

@ -99,7 +99,7 @@ class nsWindowWatcher : public nsIWindowWatcher,
/* Compute the right SizeSpec based on aFeatures */
static void CalcSizeSpec(const mozilla::dom::WindowFeatures& aFeatures,
SizeSpec& aResult);
bool aHasChromeParent, SizeSpec& aResult);
static void SizeOpenedWindow(
nsIDocShellTreeOwner* aTreeOwner, mozIDOMWindowProxy* aParent,
bool aIsCallerChrome, const SizeSpec& aSizeSpec,

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

@ -19,9 +19,7 @@ add_task(async function test_popup_conditions() {
// * left or screenX
// * top or screenY
// * width or innerWidth
// * outerWidth
// * height or innerHeight
// * outerHeight
{ features: "location,menubar,resizable,scrollbars,status", popup: false },
{ features: "toolbar,menubar,resizable,scrollbars,status", popup: false },
{
@ -85,10 +83,10 @@ add_task(async function test_popup_conditions() {
popup: true,
},
// If outerWidth is specified, popup.
// outerWidth has no effect.
{
features: "location,menubar,scrollbars,status,outerWidth=100",
popup: true,
popup: false,
},
// left or screenX alone doesn't make it a popup.
@ -111,7 +109,7 @@ add_task(async function test_popup_conditions() {
popup: false,
},
// height or innerHeight or outerHeight alone doesn't make it a popup.
// height or innerHeight alone doesn't make it a popup.
{
features: "location,menubar,scrollbars,status,height=100",
popup: false,
@ -120,6 +118,7 @@ add_task(async function test_popup_conditions() {
features: "location,menubar,scrollbars,status,innerHeight=100",
popup: false,
},
// outerHeight has no effect.
{
features: "location,menubar,scrollbars,status,outerHeight=100",
popup: false,