Skip to content

Commit

Permalink
HTML: Test interaction of alias features in window.open
Browse files Browse the repository at this point in the history
Followup to #5390

#5390 (review)

> Would also be good to test interaction of width and innerwidth
> features (which one is used if both are present, if they are
> repeated...)
  • Loading branch information
zcorpan committed Jun 21, 2017
1 parent 9fa3615 commit 823f6f4
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 0 deletions.
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML: window.open `features`: tokenization -- size features `height` vs `innerheight`</title>
<meta name=timeout content=long>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">

<!-- user agents are not required to support open features other than `noopener`
and on some platforms position and size features don't make sense -->
<meta name="flags" content="may" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var windowURL = 'resources/message-opener.html';
var featuresPrefix = `top=0,left=0,width=401,`;

setup (() => {
// Before running tests, open a window using features that mimic
// what would happen if the feature tested here were set to 0
// for comparison later.
var featureString = `${featuresPrefix}height=0`;
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage((data, e) => {
e.source.close();
runWindowTests(data);
});
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
});

function runWindowTests (baselineDimensions) {

// The last specified feature is used
[ 'height=401,height=402',
'height=401,innerheight=402',
'innerheight=401,height=402',
'innerheight=401,innerheight=402',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.height, 402);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated height/innerheight features`);
});

// The last specified feature is used even if the value is 0 or error
[ 'height=401,height=0',
'height=401,innerheight=0',
'innerheight=401,height=0',
'innerheight=401,innerheight=0',
'height=401,height=error',
'height=401,innerheight=error',
'innerheight=401,height=error',
'innerheight=401,innerheight=error',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.height, baselineDimensions.height);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated height/innerheight features where the last one is 0 or error`);
});
}

</script>
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML: window.open `features`: tokenization -- position features `left` vs `screenx`</title>
<meta name=timeout content=long>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">

<!-- user agents are not required to support open features other than `noopener`
and on some platforms position and size features don't make sense -->
<meta name="flags" content="may" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var windowURL = 'resources/message-opener.html';
var featuresPrefix = `width=401,height=204,top=0,`;

setup (() => {
// Before running tests, open a window using features that mimic
// what would happen if the feature tested here were set to 0
// for comparison later.
var featureString = `${featuresPrefix}left=0`;
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage((data, e) => {
e.source.close();
runWindowTests(data);
});
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
});

function runWindowTests (baselineDimensions) {

// The last specified feature is used
[ 'left=101,left=102',
'left=101,screenx=102',
'screenx=101,left=102',
'screenx=101,screenx=102',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.left, 102);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated left/screenx features`);
});

// The last specified feature is used even if the value is 0 or error
[ 'left=101,left=0',
'left=101,screenx=0',
'screenx=101,left=0',
'screenx=101,screenx=0',
'left=101,left=error',
'left=101,screenx=error',
'screenx=101,left=error',
'screenx=101,screenx=error',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.left, baselineDimensions.left);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated left/screenx features where the last one is 0 or error`);
});
}

</script>
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML: window.open `features`: tokenization -- position features `top` vs `screeny`</title>
<meta name=timeout content=long>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">

<!-- user agents are not required to support open features other than `noopener`
and on some platforms position and size features don't make sense -->
<meta name="flags" content="may" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var windowURL = 'resources/message-opener.html';
var featuresPrefix = `width=401,height=204,left=0,`;

setup (() => {
// Before running tests, open a window using features that mimic
// what would happen if the feature tested here were set to 0
// for comparison later.
var featureString = `${featuresPrefix}top=0`;
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage((data, e) => {
e.source.close();
runWindowTests(data);
});
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
});

function runWindowTests (baselineDimensions) {

// The last specified feature is used
[ 'top=101,top=102',
'top=101,screeny=102',
'screeny=101,top=102',
'screeny=101,screeny=102',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.top, 102);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated top/screeny features`);
});

// The last specified feature is used even if the value is 0 or error
[ 'top=101,top=0',
'top=101,screeny=0',
'screeny=101,top=0',
'screeny=101,screeny=0',
'top=101,top=error',
'top=101,screeny=error',
'screeny=101,top=error',
'screeny=101,screeny=error',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.top, baselineDimensions.top);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated top/screeny features where the last one is 0 or error`);
});
}

</script>
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML: window.open `features`: tokenization -- size features `width` vs `innerwidth`</title>
<meta name=timeout content=long>
<link rel="help" href="https://html.spec.whatwg.org/multipage/#apis-for-creating-and-navigating-browsing-contexts-by-name">

<!-- user agents are not required to support open features other than `noopener`
and on some platforms position and size features don't make sense -->
<meta name="flags" content="may" />

<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/PrefixedPostMessage.js"></script>
<script>
var windowURL = 'resources/message-opener.html';
var featuresPrefix = `top=0,left=0,height=401,`;

setup (() => {
// Before running tests, open a window using features that mimic
// what would happen if the feature tested here were set to 0
// for comparison later.
var featureString = `${featuresPrefix}width=0`;
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage((data, e) => {
e.source.close();
runWindowTests(data);
});
var win = window.open(prefixedMessage.url(windowURL), '', featureString);
});

function runWindowTests (baselineDimensions) {

// The last specified feature is used
[ 'width=401,width=402',
'width=401,innerwidth=402',
'innerwidth=401,width=402',
'innerwidth=401,innerwidth=402',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.width, 402);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated width/innerwidth features`);
});

// The last specified feature is used even if the value is 0 or error
[ 'width=401,width=0',
'width=401,innerwidth=0',
'innerwidth=401,width=0',
'innerwidth=401,innerwidth=0',
'width=401,width=error',
'width=401,innerwidth=error',
'innerwidth=401,width=error',
'innerwidth=401,innerwidth=error',
].forEach((features, idx, arr) => {
async_test(t => {
var prefixedMessage = new PrefixedMessageTest();
prefixedMessage.onMessage(t.step_func_done((data, e) => {
e.source.close();
assert_equals(data.width, baselineDimensions.width);
}));
var win = window.open(prefixedMessage.url(windowURL), '', featuresPrefix + features);
}, `${format_value(features)} repeated width/innerwidth features where the last one is 0 or error`);
});
}

</script>

0 comments on commit 823f6f4

Please sign in to comment.