-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for
window.open
position and size features
- Loading branch information
1 parent
603b3b8
commit 650b414
Showing
17 changed files
with
1,133 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-001.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: tokenization -- position features `top` and `left`</title> | ||
<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 width = 'width=401,'; | ||
var height = 'height=402,'; | ||
|
||
[ 'left=141', | ||
' left = 141', | ||
'left==141', | ||
'\nleft= 141', | ||
',left=141,,', | ||
'LEFT=141' | ||
].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, 141); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features); | ||
}, `"${features}" should set left position of opened window`); | ||
}); | ||
|
||
[ 'top=142', | ||
' top = 142', | ||
'top==142', | ||
'\ttop= 142', | ||
',top=142,,', | ||
'TOP=142' | ||
].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, 142); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features); | ||
}, `${format_value(features)} should set top position of opened window`); | ||
}); | ||
|
||
[ 'top=152,left=152', | ||
'top=152,,left=152,', | ||
'top=152==left=152', | ||
',,top= 152, left=152' | ||
].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, 152); | ||
assert_equals(data.left, 152); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features); | ||
}, `${format_value(features)} should set top and left position of opened window`); | ||
}); | ||
|
||
</script> |
70 changes: 70 additions & 0 deletions
70
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-002.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: tokenization -- size features `width` and `height`</title> | ||
<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 width = 'width=401,'; | ||
var height = 'height=402,'; | ||
|
||
[ 'width=401', | ||
' width = 401', | ||
'width==401', | ||
'\nwidth= 401', | ||
',width=401,,', | ||
'WIDTH=401' | ||
].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, 401); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', height + features); | ||
}, `${format_value(features)} should set width of opened window`); | ||
}); | ||
|
||
[ 'height=402', | ||
' height = 402', | ||
'height==402', | ||
'\nheight= 402', | ||
',height=402,,', | ||
'HEIGHT=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), '', width + features); | ||
}, `${format_value(features)} should set height of opened window`); | ||
}); | ||
|
||
[ 'height=402,width=401', | ||
' height = 402 , width = 401 ,', | ||
'height==402 width = 401', | ||
'\nheight= 402,,width=\n401', | ||
',height=402,,width==401', | ||
'HEIGHT=402, WIDTH=401' | ||
].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); | ||
assert_equals(data.width, 401) | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', features); | ||
}, `${format_value(features)} should set height and width of opened window`); | ||
}); | ||
|
||
</script> |
54 changes: 54 additions & 0 deletions
54
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-003.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: tokenization -- legacy position features `screenx`, `screeny`</title> | ||
<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 width = 'width=401,'; | ||
var height = 'height=402,'; | ||
|
||
[ 'screenx=141', | ||
' screenx = 141', | ||
'screenx==141', | ||
'\nscreenx= 141', | ||
',screenx=141,,', | ||
'SCREENX=141', | ||
'screenX=141' | ||
].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, 141); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features); | ||
}, `${format_value(features)} should set left position of opened window`); | ||
}); | ||
|
||
[ 'screeny=142', | ||
' screeny = 142', | ||
'screeny==142', | ||
'\nscreeny= 142', | ||
',screeny=142,,', | ||
'SCREENY=142', | ||
'screenY=142' | ||
].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, 142); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', width + height + features); | ||
}, `${format_value(features)} should set top position of opened window`); | ||
}); | ||
|
||
</script> |
54 changes: 54 additions & 0 deletions
54
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-004.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: tokenization -- legacy size features `innerheight`, `innerwidth`</title> | ||
<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 width = 'width=401,'; | ||
var height = 'height=402,'; | ||
|
||
[ 'innerwidth=401', | ||
' innerwidth = 401', | ||
'innerwidth==401', | ||
'\ninnerwidth= 401', | ||
',innerwidth=401,,', | ||
'INNERWIDTH=401', | ||
'innerWidth=401' | ||
].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, 401); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', height + features); | ||
}, `${format_value(features)} should set width of opened window`); | ||
}); | ||
|
||
[ 'innerheight=402', | ||
' innerheight = 402', | ||
'innerheight==402', | ||
'\ninnerheight= 402', | ||
',innerheight=402,,', | ||
'INNERHEIGHT=402', | ||
'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), '', width + features); | ||
}, `${format_value(features)} should set height of opened window`); | ||
}); | ||
|
||
</script> |
72 changes: 72 additions & 0 deletions
72
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-005.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: non-integer values for feature `top`</title> | ||
<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) { | ||
// When code point in first position is not an ASCII digit, "+" or "-", | ||
// that's an error and the value becomes 0 | ||
[ 'top=/104', | ||
'top=_104', | ||
'top=L104' | ||
].forEach(feature => { | ||
async_test(t => { | ||
var prefixedMessage = new PrefixedMessageTest(); | ||
var featureString = `${featuresPrefix}${feature}`; | ||
prefixedMessage.onMessage(t.step_func_done((data, e) => { | ||
e.source.close(); | ||
assert_equals(data.top, baselineDimensions.top, `"${feature} begins with an invalid character and should be ignored"`); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', featureString); | ||
}, `features "${feature}" should NOT set "top=104"`); | ||
}); | ||
|
||
// Codepoints that are valid ASCII digits should be collected | ||
// Non-ASCII digits and subsequent code points are ignored | ||
[ 'top=105.5', | ||
'top=105.32', | ||
'top=105LLl', | ||
'top=105^4', | ||
'top=105*3', | ||
'top=105/5', | ||
'top=105 ', | ||
'top=105e1', | ||
'top=105e-1' | ||
].forEach(feature => { | ||
async_test(t => { | ||
var featureString = `${featuresPrefix}${feature}`; | ||
var prefixedMessage = new PrefixedMessageTest(); | ||
prefixedMessage.onMessage(t.step_func_done((data, e) => { | ||
e.source.close(); | ||
assert_equals(data.top, 105, `"${feature} value after first non-digit will be ignored"`); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', featureString); | ||
}, `features "${feature}" should set "top=105"`); | ||
}); | ||
} | ||
|
||
</script> |
75 changes: 75 additions & 0 deletions
75
...pis-for-creating-and-navigating-browsing-contexts-by-name/open-features-optional-006.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>HTML: window.open `features`: non-integer values for feature `left`</title> | ||
<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 featuresPrefix = `width=401,height=204,top=0,`; | ||
var windowURL = 'resources/message-opener.html'; | ||
|
||
// https://html.spec.whatwg.org/multipage/infrastructure.html#rules-for-parsing-integers | ||
|
||
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) { | ||
// When code point in first position is not an ASCII digit, "+" or "-", | ||
// that's an error and the value becomes 0 | ||
[ 'left=/104', | ||
'left=_104', | ||
'left=L104' | ||
].forEach(feature => { | ||
async_test(t => { | ||
var featureString = `${featuresPrefix}${feature}`; | ||
var prefixedMessage = new PrefixedMessageTest(); | ||
prefixedMessage.onMessage(t.step_func_done((data, e) => { | ||
e.source.close(); | ||
assert_equals(data.left, baselineDimensions.left, `"${feature} begins with an invalid character and should be ignored"`); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', featureString); | ||
}, `features "${feature}" should NOT set "left=104"`); | ||
}); | ||
|
||
// Codepoints that are valid ASCII digits should be collected | ||
// Non-ASCII digits and subsequent code points are ignored | ||
[ 'left=105.5', | ||
'left=105.32', | ||
'left=105LLl', | ||
'left=105^4', | ||
'left=105*3', | ||
'left=105/5', | ||
'left=105 ', | ||
'left=105e1', | ||
'left=105e-1' | ||
].forEach(feature => { | ||
async_test(t => { | ||
var featureString = `${featuresPrefix}${feature}`; | ||
var prefixedMessage = new PrefixedMessageTest(); | ||
prefixedMessage.onMessage(t.step_func_done((data, e) => { | ||
e.source.close(); | ||
assert_equals(data.left, 105, `"${featureString} value after first non-digit will be ignored"`); | ||
})); | ||
var win = window.open(prefixedMessage.url(windowURL), '', featureString); | ||
}, `features "${feature}" should set "left=105"`); | ||
}); | ||
} | ||
|
||
</script> |
Oops, something went wrong.