Update web-platform-tests to revision 60ad712df2130b21908c4a055abf241d68ba9647

This commit is contained in:
WPT Sync Bot 2019-01-20 21:07:09 -05:00
parent ccc4149b30
commit 03d8b09382
46 changed files with 1257 additions and 139 deletions

View file

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style type="text/css">
#scroller {
overflow: scroll;
width: 500px;
height: 500px;
}
#anchor {
position: relative;
width: 100px;
height: 100px;
margin-top: 100px;
margin-bottom: 1000px;
background-color: blue;
}
#positioned {
position: absolute;
width: 10px;
height: 10px;
top: -200px;
background-color: yellow;
}
</style>
</head>
<body>
<div id="scroller">
<div id="anchor">
<div id="positioned">
</div>
</div>
</div>
<script type="text/javascript">
test(() => {
let scroller = document.querySelector('#scroller');
let positioned = document.querySelector('#positioned');
// Scroll down to select #anchor as an anchor node
scroller.scrollTop = 20;
// Move #positioned downwards, which will move the unclamped scrollable
// overflow rect of #anchor downards as well
positioned.style.top = '-180px';
// To trigger the bug that this regression tests in Gecko, we need
// to not take Gecko's relative positioning fast path. To do
// this, change the 'left' of #positioned from 'auto' to '0px'.
positioned.style.left = '0px';
// The implementation should clamp the scrollable overflow rect
// before the start-edge of the anchor node, and not apply an
// adjustment
assert_equals(scroller.scrollTop, 20);
}, 'scrollable overflow before the start-edge of the anchor node should be clamped');
</script>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body { height: 400vh; margin: 0; }
#sticky, #content { width: 200px; height: 100px; }
#sticky { position: sticky; left: 100px; top: 50px; }
#before { height: 50px; }
#content { margin-top: 100px; }
</style>
<div id="sticky">sticky</div>
<div id="before"></div>
<div id="content">content</div>
<script>
// Tests that the anchor selection algorithm skips sticky-positioned elements.
test(() => {
document.scrollingElement.scrollTop = 150;
document.querySelector("#before").style.height = "100px";
assert_equals(document.scrollingElement.scrollTop, 200);
}, "Sticky-positioned headers shouldn't be chosen as scroll anchors (we should use 'content' instead)");
</script>

View file

@ -0,0 +1,56 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body { margin: 0; }
#scroller {
overflow: scroll;
height: 100px;
}
#multicol {
margin-top: 20px;
height: 200px;
columns: 2;
column-fill: auto;
}
#before {
margin-top: 100px;
height: 100px;
}
#content {
height: 10px;
}
</style>
<div id="scroller">
<div id="multicol">
<div id="fragmented">
<div id="before"></div>
<div id="content">content</div>
</div>
</div>
</div>
<script>
// Tests a scroll anchor inside of a div fragmented across multicol
test(() => {
let scroller = document.querySelector("#scroller");
let before = document.querySelector("#before");
let content = document.querySelector("#content");
// Scroll down so that we select a scroll anchor. We should select #content
// and not #before, as #before is positioned offscreen in the first column
scroller.scrollTop = 10;
// Increase the height of #before so that it fragments into the second
// column and pushes #content down.
before.style.height = "110px";
// We should have anchored to #content and have done an adjustment of 10px
assert_equals(scroller.scrollTop, 20);
}, "An element in a fragmented div should be able to be selected as an anchor node.");
</script>

View file

@ -0,0 +1,47 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#scroller {
height: 200px;
overflow: scroll;
}
#before { height: 50px; }
#table-row {
display: table-row;
overflow-anchor: none;
width: 100px;
height: 100px;
}
#after { margin-bottom: 500px; }
</style>
<div id="scroller">
<div id="before"></div>
<div id="table-row">content</div>
<div id="after"></div>
</div>
<script>
// Tests that the anchor exclusion API works with table parts that generate
// anonymous table box wrappers
test(() => {
let scroller = document.querySelector('#scroller');
let before = document.querySelector('#before');
// Scroll down so that #table-row is the only element in view
scroller.scrollTop = 50;
// Expand #before so that we might perform a scroll adjustment
before.style.height = "100px";
// We shouldn't have selected #table-row as an anchor as it is
// 'overflow-anchor: none'
assert_equals(scroller.scrollTop, 50);
}, "A table with anonymous wrappers and 'overflow-anchor: none' shouldn't generate any scroll anchor candidates.");
</script>

View file

@ -0,0 +1,45 @@
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="help" href="https://drafts.csswg.org/css-scroll-anchoring-1/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#scroller {
height: 200px;
overflow: scroll;
}
#before { height: 50px; }
#table {
display: table;
overflow-anchor: none;
width: 100px;
height: 100px;
margin-bottom: 500px;
}
</style>
<div id="scroller">
<div id="before"></div>
<div id="table">content</div>
</div>
<script>
// Tests that the anchor exclusion API works with tables
test(() => {
let scroller = document.querySelector('#scroller');
let before = document.querySelector('#before');
// Scroll down so that #table is the only element in view
scroller.scrollTop = 50;
// Expand #before so that we might perform a scroll adjustment
before.style.height = "100px";
// We shouldn't have selected #table as an anchor as it is
// 'overflow-anchor: none'
assert_equals(scroller.scrollTop, 50);
}, "A table with 'overflow-anchor: none' shouldn't generate any scroll anchor candidates.");
</script>

View file

@ -0,0 +1,7 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<table style="border-collapse: collapse; border-style: solid;">
<td>Should see a non-solid border</td>
</table>

View file

@ -0,0 +1,10 @@
<!doctype html>
<title>CSS Test: border-collapsed tables don't unconditionally render double borders as solid</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1521066">
<link rel="help" href="https://drafts.csswg.org/css2/tables.html#collapsing-borders">
<link rel="mismatch" href="border-collapse-double-border-notref.html">
<table style="border-collapse: collapse; border-style: double;">
<td>Should see a non-solid border</td>
</table>

View file

@ -0,0 +1,25 @@
<!doctype html>
<title>CSS Test Reference</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<style>
table {
font-size: 2em;
border-collapse: collapse;
border: 5px solid green;
}
</style>
<p>You should see no non-solid borders and no red.</p>
<table>
<tr>
<td colspan="4" style="border: 5px solid purple;">hello</td>
</tr>
<tr>
<td style="border-right: 5px solid blue; border-bottom: 9px hidden red;">one</td>
<td style="border-right: 5px solid blue;">two</td>
<td>three</td>
<td style="border-left: 5px solid blue">four</td>
</tr>
</table>

View file

@ -0,0 +1,28 @@
<!doctype html>
<title>CSS Test: Table border resolution rules</title>
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
<link rel="author" href="https://mozilla.org" title="Mozilla">
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1520138">
<link rel="help" href="https://drafts.csswg.org/css2/tables.html#border-conflict-resolution">
<link rel="match" href="border-conflict-resolution-ref.html">
<style>
table {
font-size: 2em;
border-collapse: collapse;
border: 5px solid green;
}
</style>
<p>You should see no non-solid borders and no red.</p>
<table>
<tr>
<td colspan="4" style="border: 5px solid purple;">hello</td>
</tr>
<tr>
<td style="border-top: 5px solid blue; border-right: 5px solid blue; border-bottom: 9px hidden red; border-left: 9px none;">one</td>
<td style="border-top: 5px dashed blue; border-right: 5px solid blue; border-bottom: 5px outset red;">two</td>
<td style="border-top: 5px ridge blue; border-right: 5px ridge red; border-bottom: 5px inset red;">three</td>
<td style="border-left: 5px solid blue; border-bottom: 5px dotted red;">four</td>
</tr>
</table>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module: getComputedValue().borderCollapse</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-collapse">
<meta name="assert" content="border-collapse computed value is as specified.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("border-collapse", "separate");
test_computed_value("border-collapse", "collapse");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing border-collapse with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-collapse">
<meta name="assert" content="border-collapse supports only the grammar 'separate | collapse'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("border-collapse", "none");
test_invalid_value("border-collapse", "separate collapse");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing border-collapse with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-collapse">
<meta name="assert" content="border-collapse supports the full grammar 'separate | collapse'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("border-collapse", "separate");
test_valid_value("border-collapse", "collapse");
</script>
</body>
</html>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module: getComputedValue().borderSpacing</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-spacing">
<meta name="assert" content="border-spacing computed value is two absolute lengths.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<style>
#target {
font-size: 40px;
}
</style>
<script>
test_computed_value("border-spacing", "10px 20px");
test_computed_value("border-spacing", "0", "0px 0px");
test_computed_value("border-spacing", "calc(10px + 0.5em) calc(10px - 0.5em)", "30px 0px");
test_computed_value("border-spacing", "calc(10px - 0.5em) calc(10px + 0.5em)", "0px 30px");
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing border-spacing with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-spacing">
<meta name="assert" content="border-spacing supports only the grammar '<length>{1,2}'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("border-spacing", "10%");
test_invalid_value("border-spacing", "-20px");
test_invalid_value("border-spacing", "30");
test_invalid_value("border-spacing", "40px 50px 60px");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing border-spacing with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-border-spacing">
<meta name="assert" content="border-spacing supports the full grammar '<length>{1,2}'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("border-spacing", "0px");
test_valid_value("border-spacing", "10px 20px");
test_valid_value("border-spacing", "calc(10px + 0.5em) calc(10px - 0.5em)");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module: getComputedValue().captionSide</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-caption-side">
<meta name="assert" content="caption-side computed value is as specified.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("caption-side", "top");
test_computed_value("caption-side", "bottom");
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing caption-side with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-caption-side">
<meta name="assert" content="caption-side supports only the grammar 'top | bottom'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("caption-side", "auto");
test_invalid_value("caption-side", "left");
test_invalid_value("caption-side", "right");
test_invalid_value("caption-side", "top bottom");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing caption-side with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-caption-side">
<meta name="assert" content="caption-side supports the full grammar 'top | bottom'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("caption-side", "top");
test_valid_value("caption-side", "bottom");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module: getComputedValue().emptyCells</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-empty-cells">
<meta name="assert" content="empty-cells computed value is as specified.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("empty-cells", "show");
test_computed_value("empty-cells", "hide");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing empty-cells with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-empty-cells">
<meta name="assert" content="empty-cells supports only the grammar 'show | hide'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("empty-cells", "auto");
test_invalid_value("empty-cells", "show hide");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing empty-cells with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-empty-cells">
<meta name="assert" content="empty-cells supports the full grammar 'show | hide'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("empty-cells", "show");
test_valid_value("empty-cells", "hide");
</script>
</body>
</html>

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module: getComputedValue().tableLayout</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-table-layout">
<meta name="assert" content="table-layout computed value is as specified.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
</head>
<body>
<div id="target"></div>
<script>
test_computed_value("table-layout", "auto");
test_computed_value("table-layout", "fixed");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing table-layout with invalid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-table-layout">
<meta name="assert" content="table-layout supports only the grammar 'auto | fixed'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_invalid_value("table-layout", "none");
test_invalid_value("table-layout", "auto fixed");
</script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS Table Module Test: parsing table-layout with valid values</title>
<link rel="help" href="https://drafts.csswg.org/css-tables/#propdef-table-layout">
<meta name="assert" content="table-layout supports the full grammar 'auto | fixed'.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
</head>
<body>
<script>
test_valid_value("table-layout", "auto");
test_valid_value("table-layout", "fixed");
</script>
</body>
</html>

View file

@ -12,24 +12,24 @@
width: 200px;
margin-bottom: 2px;
background: lightgray;
height: 20px;
height: 10px;
clear: all;
}
div.a {
width: 10px;
height: 20px;
height: 10px;
background: lightgreen;
float: left;
}
div.b {
width: 30px;
height: 20px;
height: 10px;
background: pink;
float: left;
}
div.c {
width: 40px;
height: 20px;
height: 10px;
background: orange;
float: left;
}
@ -37,7 +37,7 @@
/* Inside of 'b': */
div.fixedSizeChild {
width: 30px;
height: 10px;
height: 5px;
background: purple;
}
</style>

View file

@ -14,7 +14,7 @@
<style>
div.flexbox {
width: 200px;
height: 20px; /* Short, to force us to wrap */
height: 10px; /* Short, to force us to wrap */
display: flex;
flex-direction: column;
flex-wrap: wrap;
@ -23,19 +23,19 @@
}
div.a {
width: 10px;
height: 20px;
height: 10px;
flex: none;
background: lightgreen;
}
div.b {
width: auto; /* width comes from contents */
height: 20px;
height: 10px;
flex: none;
background: pink;
}
div.c {
width: 40px;
height: 20px;
height: 10px;
flex: none;
background: orange;
}
@ -43,7 +43,7 @@
/* Inside of 'b': */
div.fixedSizeChild {
width: 30px;
height: 10px;
height: 5px;
background: purple;
}
</style>

View file

@ -15,7 +15,7 @@
<style>
div.flexbox {
width: 200px;
max-height: 20px; /* Short, to force us to wrap */
max-height: 10px; /* Short, to force us to wrap */
display: flex;
flex-direction: column;
flex-wrap: wrap;
@ -24,19 +24,19 @@
}
div.a {
width: 10px;
height: 20px;
height: 10px;
flex: none;
background: lightgreen;
}
div.b {
width: auto; /* width comes from contents */
height: 20px;
height: 10px;
flex: none;
background: pink;
}
div.c {
width: 40px;
height: 20px;
height: 10px;
flex: none;
background: orange;
}
@ -44,7 +44,7 @@
/* Inside of 'b': */
div.fixedSizeChild {
width: 30px;
height: 10px;
height: 5px;
background: purple;
}
</style>

View file

@ -16,17 +16,17 @@
display: inline-block;
}
div.a {
height: 20px;
height: 10px;
width: 10px;
background: lightgreen;
}
div.b {
height: 20px;
height: 10px;
width: 50px;
background: pink;
}
div.c {
height: 20px;
height: 10px;
width: 100px;
background: orange;
}

View file

@ -18,17 +18,17 @@
margin-bottom: 2px;
}
div.a {
height: 20px;
height: 10px;
flex: 0 10px;
background: lightgreen;
}
div.b {
height: 20px;
height: 10px;
flex: 0 50px;
background: pink;
}
div.c {
height: 20px;
height: 10px;
flex: 0 100px;
background: orange;
}

View file

@ -24,17 +24,17 @@
clear: both;
}
div.a {
height: 20px;
height: 10px;
flex: 0 10px;
background: lightgreen;
}
div.b {
height: 20px;
height: 10px;
flex: 0 50px;
background: pink;
}
div.c {
height: 20px;
height: 10px;
flex: 0 100px;
background: orange;
}

View file

@ -15,17 +15,17 @@
float: left;
}
div.a {
width: 20px;
width: 10px;
height: 35px;
background: lightgreen;
}
div.b {
width: 20px;
width: 10px;
height: 40px;
background: pink;
}
div.c {
width: 20px;
width: 10px;
height: 45px;
background: orange;
}

View file

@ -29,17 +29,17 @@
float: left;
}
div.a {
width: 20px;
width: 10px;
flex: 0 0 35px;
background: lightgreen;
}
div.b {
width: 20px;
width: 10px;
flex: 0 0 40px;
background: pink;
}
div.c {
width: 20px;
width: 10px;
flex: 0 0 45px;
background: orange;
}

View file

@ -0,0 +1,10 @@
def opener(session):
return session.execute_script("""
return window.opener;
""")
def window_name(session):
return session.execute_script("""
return window.name;
""")

View file

@ -0,0 +1,52 @@
import pytest
from webdriver.transport import Response
from tests.support.asserts import assert_error, assert_success
def new_window(session, type_hint=None):
return session.transport.send(
"POST", "session/{session_id}/window/new".format(**vars(session)),
{"type": type_hint})
def test_null_parameter_value(session, http):
path = "/session/{session_id}/window/new".format(**vars(session))
with http.post(path, None) as response:
assert_error(Response.from_http(response), "invalid argument")
def test_no_browsing_context(session, closed_window):
response = new_window(session)
assert_error(response, "no such window")
@pytest.mark.parametrize("type_hint", [True, 42, 4.2, [], {}])
def test_type_with_invalid_type(session, type_hint):
response = new_window(session, type_hint)
assert_error(response, "invalid argument")
def test_type_with_null_value(session):
original_handles = session.handles
response = new_window(session, type_hint=None)
value = assert_success(response)
handles = session.handles
assert len(handles) == len(original_handles) + 1
assert value["handle"] in handles
assert value["handle"] not in original_handles
assert value["type"] in ["tab", "window"]
def test_type_with_unknown_value(session):
original_handles = session.handles
response = new_window(session, type_hint="foo")
value = assert_success(response)
handles = session.handles
assert len(handles) == len(original_handles) + 1
assert value["handle"] in handles
assert value["handle"] not in original_handles
assert value["type"] in ["tab", "window"]

View file

@ -0,0 +1,48 @@
from tests.support.asserts import assert_success
from . import opener, window_name
def new_window(session, type_hint=None):
return session.transport.send(
"POST", "session/{session_id}/window/new".format(**vars(session)),
{"type": type_hint})
def test_new_tab(session):
original_handles = session.handles
response = new_window(session, type_hint="tab")
value = assert_success(response)
handles = session.handles
assert len(handles) == len(original_handles) + 1
assert value["handle"] in handles
assert value["handle"] not in original_handles
assert value["type"] == "tab"
def test_new_tab_opens_about_blank(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
session.handle = value["handle"]
assert session.url == "about:blank"
def test_new_tab_sets_no_window_name(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
session.handle = value["handle"]
assert window_name(session) == ""
def test_new_tab_sets_no_opener(session):
response = new_window(session, type_hint="tab")
value = assert_success(response)
assert value["type"] == "tab"
session.handle = value["handle"]
assert opener(session) is None

View file

@ -0,0 +1,48 @@
from tests.support.asserts import assert_success
from . import opener, window_name
def new_window(session, type_hint=None):
return session.transport.send(
"POST", "session/{session_id}/window/new".format(**vars(session)),
{"type": type_hint})
def test_type_with_window(session):
original_handles = session.handles
response = new_window(session, type_hint="window")
value = assert_success(response)
handles = session.handles
assert len(handles) == len(original_handles) + 1
assert value["handle"] in handles
assert value["handle"] not in original_handles
assert value["type"] == "window"
def test_new_window_opens_about_blank(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
session.handle = value["handle"]
assert session.url == "about:blank"
def test_new_window_sets_no_window_name(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
session.handle = value["handle"]
assert window_name(session) == ""
def test_new_window_sets_no_opener(session):
response = new_window(session, type_hint="window")
value = assert_success(response)
assert value["type"] == "window"
session.handle = value["handle"]
assert opener(session) is None

View file

@ -0,0 +1,121 @@
# META: timeout=long
import pytest
from tests.support.asserts import assert_dialog_handled, assert_error, assert_success
def new_window(session, type_hint=None):
return session.transport.send(
"POST", "session/{session_id}/window/new".format(**vars(session)),
{"type": type_hint})
@pytest.fixture
def check_user_prompt_closed_without_exception(session, create_dialog):
def check_user_prompt_closed_without_exception(dialog_type, retval):
original_handles = session.handles
create_dialog(dialog_type, text=dialog_type)
response = new_window(session)
value = assert_success(response)
handles = session.handles
assert len(handles) == len(original_handles) + 1
assert value["handle"] in handles
assert value["handle"] not in original_handles
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
return check_user_prompt_closed_without_exception
@pytest.fixture
def check_user_prompt_closed_with_exception(session, create_dialog):
def check_user_prompt_closed_with_exception(dialog_type, retval):
original_handles = session.handles
create_dialog(dialog_type, text=dialog_type)
response = new_window(session)
assert_error(response, "unexpected alert open")
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
assert len(session.handles) == len(original_handles)
return check_user_prompt_closed_with_exception
@pytest.fixture
def check_user_prompt_not_closed_but_exception(session, create_dialog):
def check_user_prompt_not_closed_but_exception(dialog_type):
original_handles = session.handles
create_dialog(dialog_type, text=dialog_type)
response = new_window(session)
assert_error(response, "unexpected alert open")
assert session.alert.text == dialog_type
session.alert.dismiss()
assert len(session.handles) == len(original_handles)
return check_user_prompt_not_closed_but_exception
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", True),
("prompt", ""),
])
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
check_user_prompt_closed_without_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
check_user_prompt_not_closed_but_exception(dialog_type)
@pytest.mark.parametrize("dialog_type, retval", [
("alert", None),
("confirm", False),
("prompt", None),
])
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
check_user_prompt_closed_with_exception(dialog_type, retval)