Commit 4ddc2ce8 authored by Xiaocheng Hu's avatar Xiaocheng Hu Committed by Commit Bot

Convert some layout tests with W3C testharness

This patch converts some layout tests to use testharness instead of
plain text dump or js-test.js.

It is a preparation for crrev.com/c/1243119. The changed tests have
non-trivial text failures with that patch (due to flakes or non-trivial
dependency on js-test.js), so we convert them in this CL to reduce
noise there, and ensure that there are only newline text diffs in the
other CL.

Bug: 887148
Change-Id: I46d7508ddde62e32ddfa421e9975b39b73cc06df
Reviewed-on: https://chromium-review.googlesource.com/1246902
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594581}
parent 36469737
To manually test, click one of the buttons below. The result should be two 'PASS' events for either button.
Copy Cut
PASS successfullyParsed is true
TEST COMPLETE
PASS document.execCommand('copy') is true
PASS copyEventSeen is true
PASS document.execCommand('cut') is true
PASS cutEventSeen is true
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var copyEventSeen;
var cutEventSeen;
function runTest()
{
if (window.testRunner)
testRunner.setJavaScriptCanAccessClipboard(false);
else
return;
clickButton("copy");
clickButton("cut");
test(() => {
assert_exists(window, 'testRunner');
testRunner.setJavaScriptCanAccessClipboard(false);
clickButton("copy");
}, 'Copy');
test(() => {
assert_exists(window, 'testRunner');
testRunner.setJavaScriptCanAccessClipboard(false);
clickButton("cut");
}, 'Cut');
}
function clickButton(id)
......@@ -25,15 +31,15 @@ function clickButton(id)
function onClickCopy()
{
copyEventSeen = false;
shouldBeTrue("document.execCommand('copy')");
shouldBeTrue("copyEventSeen");
assert_true(document.execCommand('copy'));
assert_true(copyEventSeen);
}
function onClickCut()
{
cutEventSeend = false;
shouldBeTrue("document.execCommand('cut')");
shouldBeTrue("cutEventSeen");
assert_true(document.execCommand('cut'));
assert_true(cutEventSeen);
}
function onCopy()
......@@ -46,11 +52,13 @@ function onCut()
cutEventSeen = true;
}
</script>
<body onload="runTest()" oncopy="onCopy()" oncut="onCut()">
<body oncopy="onCopy()" oncut="onCut()">
<p>To manually test, click one of the buttons below. The result should be two 'PASS' events for either button.
<div>
<button id="copy" onclick="onClickCopy()">Copy</button>
<button id="cut" onclick="onClickCut()">Cut</button>
</div>
<div id="console"></div>
<script>
runTest();
</script>
</body>
This test verifies the order of events fired by drag-and-drop.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
focus src
drop dst
input src
change src
blur src
focus dst
input dst
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body onload="runTest()">
<body>
<input type="text" id="src" value="abc">
<input type="text" id="dst">
<div id="console"></div>
<script>
description("This test verifies the order of events fired by drag-and-drop.");
test(() => {
const expected = [
{name: 'focus', target: 'src'},
{name: 'drop', target: 'dst'},
{name: 'input', target: 'src'},
{name: 'change', target: 'src'},
{name: 'blur', target: 'src'},
{name: 'focus', target: 'dst'},
{name: 'input', target: 'dst'},
];
var fired = 0;
function checkEvent(name, target) {
assert_equals(name, expected[fired].name);
assert_equals(target, expected[fired].target);
++fired;
}
function runTest()
{
var src = document.getElementById('src');
var dst = document.getElementById('dst');
['blur', 'change', 'drop', 'focus', 'input'].forEach(function(event) {
src.addEventListener(event, debug.bind(null, event + ' src'));
dst.addEventListener(event, debug.bind(null, event + ' dst'));
src.addEventListener(event, () => checkEvent(event, 'src'));
dst.addEventListener(event, () => checkEvent(event, 'dst'));
});
src.select();
......@@ -26,7 +40,7 @@ function runTest()
eventSender.leapForward(1000);
eventSender.mouseMoveTo(dst.offsetLeft + dst.offsetWidth / 2, dst.offsetTop + dst.offsetHeight / 2);
eventSender.mouseUp();
}
}, 'Event order by drag-and-drop');
</script>
</body>
</html>
This test checks select attribute of content element is valid.
null
PASS internals.isValidContentSelect(content) is true
PASS internals.isValidContentSelect(content) is true
*|div
PASS internals.isValidContentSelect(content) is true
|div
PASS internals.isValidContentSelect(content) is true
div
PASS internals.isValidContentSelect(content) is true
*|*
PASS internals.isValidContentSelect(content) is true
|*
PASS internals.isValidContentSelect(content) is true
*
PASS internals.isValidContentSelect(content) is true
.elem
PASS internals.isValidContentSelect(content) is true
p.elem
PASS internals.isValidContentSelect(content) is true
foo.elem
PASS internals.isValidContentSelect(content) is true
*.right
PASS internals.isValidContentSelect(content) is true
#elem
PASS internals.isValidContentSelect(content) is true
p#elem
PASS internals.isValidContentSelect(content) is true
foo#elem
PASS internals.isValidContentSelect(content) is true
*#something
PASS internals.isValidContentSelect(content) is true
div[title]
PASS internals.isValidContentSelect(content) is true
div[class="example"]
PASS internals.isValidContentSelect(content) is true
div[hello="Cleveland"][goodbye="Columbus"]
PASS internals.isValidContentSelect(content) is true
div[rel~="copyright"]
PASS internals.isValidContentSelect(content) is true
div[href="http://www.example.com/"]
PASS internals.isValidContentSelect(content) is true
div[hreflang|="en"]
PASS internals.isValidContentSelect(content) is true
div[character=romeo]
PASS internals.isValidContentSelect(content) is true
div, div
PASS internals.isValidContentSelect(content) is true
div, div
PASS internals.isValidContentSelect(content) is true
div:not(div)
PASS internals.isValidContentSelect(content) is true
div div
PASS internals.isValidContentSelect(content) is false
div > div
PASS internals.isValidContentSelect(content) is false
div + div
PASS internals.isValidContentSelect(content) is false
div ~ div
PASS internals.isValidContentSelect(content) is false
ns|div
PASS internals.isValidContentSelect(content) is false
ns|*
PASS internals.isValidContentSelect(content) is false
div:root
PASS internals.isValidContentSelect(content) is false
div:lang(en)
PASS internals.isValidContentSelect(content) is false
div::before
PASS internals.isValidContentSelect(content) is false
div::after
PASS internals.isValidContentSelect(content) is false
div::first-line
PASS internals.isValidContentSelect(content) is false
div::first-letter
PASS internals.isValidContentSelect(content) is false
div:active
PASS internals.isValidContentSelect(content) is false
div:hover
PASS internals.isValidContentSelect(content) is false
div:focus
PASS internals.isValidContentSelect(content) is false
div div:not(div)
PASS internals.isValidContentSelect(content) is false
div:not(div) div
PASS internals.isValidContentSelect(content) is false
div span div
PASS internals.isValidContentSelect(content) is false
div < div
PASS internals.isValidContentSelect(content) is false
div - dvi
PASS internals.isValidContentSelect(content) is false
< div
PASS internals.isValidContentSelect(content) is false
+div
PASS internals.isValidContentSelect(content) is false
~div
PASS internals.isValidContentSelect(content) is false
div:!
PASS internals.isValidContentSelect(content) is false
!:!
PASS internals.isValidContentSelect(content) is false
div::!
PASS internals.isValidContentSelect(content) is false
div::first_of_type
PASS internals.isValidContentSelect(content) is false
pe;ro
PASS internals.isValidContentSelect(content) is false
@screen
PASS internals.isValidContentSelect(content) is false
@import "style.css"
PASS internals.isValidContentSelect(content) is false
div :first-of-type
PASS internals.isValidContentSelect(content) is false
div::first-of-type
PASS internals.isValidContentSelect(content) is false
div, ,div
PASS internals.isValidContentSelect(content) is false
div ''
PASS internals.isValidContentSelect(content) is false
div:link
PASS internals.isValidContentSelect(content) is false
div:visited
PASS internals.isValidContentSelect(content) is false
div:target
PASS internals.isValidContentSelect(content) is false
div:enabled
PASS internals.isValidContentSelect(content) is false
div:checked
PASS internals.isValidContentSelect(content) is false
div:indeterminate
PASS internals.isValidContentSelect(content) is false
div:nth-child(1)
PASS internals.isValidContentSelect(content) is false
div:nth-last-child(1)
PASS internals.isValidContentSelect(content) is false
div:nth-of-type(1)
PASS internals.isValidContentSelect(content) is false
div:nth-last-of-type(1)
PASS internals.isValidContentSelect(content) is false
div:first-child
PASS internals.isValidContentSelect(content) is false
div:last-child
PASS internals.isValidContentSelect(content) is false
div:first-of-type
PASS internals.isValidContentSelect(content) is false
div:last-of-type
PASS internals.isValidContentSelect(content) is false
div:only-of-type
PASS internals.isValidContentSelect(content) is false
div:first-of-type:last-of-type
PASS internals.isValidContentSelect(content) is false
div.elem:visited
PASS internals.isValidContentSelect(content) is false
*:visited
PASS internals.isValidContentSelect(content) is false
div:first-of-type, div
PASS internals.isValidContentSelect(content) is false
div, div:first-of-type
PASS internals.isValidContentSelect(content) is false
div:first-of-type, div:last-of-type
PASS internals.isValidContentSelect(content) is false
div:not(:not(div))
PASS internals.isValidContentSelect(content) is false
div:not(:hover)
PASS internals.isValidContentSelect(content) is false
div:not(div div)
PASS internals.isValidContentSelect(content) is false
div:not(div div:not)
PASS internals.isValidContentSelect(content) is false
div:not(div div:hover)
PASS internals.isValidContentSelect(content) is false
div div:not(:hover)
PASS internals.isValidContentSelect(content) is false
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<p>This test checks select attribute of content element is valid.</p>
......@@ -12,16 +13,16 @@
var container = document.getElementById("container");
var content;
function test(select, valid) {
function runTest(select, valid) {
content = document.createElement('content');
if (select != null)
content.setAttribute('select', select);
debug(select);
if (valid)
shouldBe("internals.isValidContentSelect(content)", "true");
else
shouldBe("internals.isValidContentSelect(content)", "false");
test(() => {
assert_exists(window, 'internals',
'This test requires internals.isValidContentSelect');
assert_equals(internals.isValidContentSelect(content), valid);
}, `${select} ${valid}`);
}
var dataOfValidCases = [
......@@ -53,19 +54,15 @@ var dataOfInvalidCases = [
];
function doTest() {
if (!window.internals)
return;
for (var i = 0; i < dataOfValidCases.length; ++i) {
test(dataOfValidCases[i], true);
runTest(dataOfValidCases[i], true);
}
for (var i = 0; i < dataOfInvalidCases.length; ++i) {
test(dataOfInvalidCases[i], false);
runTest(dataOfInvalidCases[i], false);
}
}
doTest();
var successfullyParsed = true;
</script>
</body>
</html>
This test ensures that if an autoscroll starts from within a scrollable div, it does not propagate to its non-scrollable document body. Furthermore, it tests that if the body has only one of overflowX or overflowY set to hidden, the scrollable axis actually scrolls. Note that this test is pertaining to crbug.com/531525.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS Document didn't scroll.
PASS successfullyParsed is true
TEST COMPLETE
......@@ -14,32 +14,27 @@
width: 100px;
}
</style>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script type="text/javascript">
var scrollTopBefore;
var maxScrollLeft;
setPrintTestResultsLazily();
jsTestIsAsync = true;
description("This test ensures that if an autoscroll starts from within a " +
const testCase = async_test(
"If an autoscroll starts from within a " +
"scrollable div, it does not propagate to its non-scrollable document " +
"body. Furthermore, it tests that if the body has only one of overflowX " +
"or overflowY set to hidden, the scrollable axis actually scrolls. Note " +
"that this test is pertaining to crbug.com/531525.");
function finishTest() {
const finishTest = testCase.step_func_done(() => {
eventSender.mouseUp();
// Because only overflowY:hidden is set, horizontal scroll should happen and
// vertical scroll shouldn't.
if (document.scrollingElement.scrollTop == scrollTopBefore && document.scrollingElement.scrollLeft == maxScrollLeft) {
testPassed("Document didn't scroll.");
} else {
testFailed("Document scrolled although overflow:hidden.");
testFailed(document.scrollingElement.scrollTop + " " + scrollTopBefore + " " + document.scrollingElement.scrollLeft + " " + maxScrollLeft);
}
assert_equals(document.scrollingElement.scrollTop, scrollTopBefore);
assert_equals(document.scrollingElement.scrollLeft, maxScrollLeft);
document.getElementById('text-wrapper').style.display = 'none';
finishJSTest();
}
});
window.onload = function () {
scrollTopBefore = document.scrollingElement.scrollTop;
......
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
}
</script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<button id="testButton" style="text-indent: -99999999px;" onclick="btnClicked()">Move</button>
<p id="output"></p>
<script>
function btnClicked()
{
document.getElementById('output').innerHTML = "Button is clicked.";
}
if (window.eventSender) {
var testEle = document.getElementById('testButton');
eventSender.mouseMoveTo(testEle.offsetLeft + testEle.offsetWidth / 2, testEle.offsetTop + testEle.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseUp();
}
const testCase = async_test('Button is clicked');
const btnClicked = testCase.step_func_done(() => {});
testCase.step(() => {
assert_exists(window, 'eventSender');
var testEle = document.getElementById('testButton');
eventSender.mouseMoveTo(testEle.offsetLeft + testEle.offsetWidth / 2, testEle.offsetTop + testEle.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseUp();
});
</script>
</body>
</html>
This tests that we don't lose data dropped onto an input field that changes its content during a drop event
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS dragTarget.value is elementToDrag.href
PASS Didn't crash.
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
function resetField()
......@@ -10,9 +11,11 @@
function runTest()
{
if (window.testRunner) {
testRunner.dumpAsText();
test(() => {
assert_exists(
window, 'eventSender',
'This test requires eventSender. To test this manually drag the link into the text field.');
elementToDrag = document.getElementById("elementToDrag");
x1 = elementToDrag.offsetLeft + elementToDrag.offsetWidth / 2;
y1 = elementToDrag.offsetTop + elementToDrag.offsetHeight / 2;
......@@ -26,14 +29,12 @@
eventSender.leapForward(400);
eventSender.mouseMoveTo(x2, y2);
eventSender.mouseUp();
shouldBe("dragTarget.value", "elementToDrag.href");
testPassed("Didn't crash.");
assert_equals(dragTarget.value, elementToDrag.href);
//clean up output
elementToDrag.parentNode.removeChild(elementToDrag);
dragTarget.parentNode.removeChild(dragTarget);
} else {
debug('<br>To test this manually drag the link into the text field.')
}
}, "This tests that we don't lose data dropped onto an input field that changes its content during a drop event");
}
</script>
</head>
......@@ -43,8 +44,7 @@
<input id="dragTarget" type="text" value="Original Text" onfocus="resetField()" />
<div id="console"></div>
<script>
description("This tests that we don't lose data dropped onto an input field that changes its content during a drop event");
runTest();
</script>
</body>
</html>
\ No newline at end of file
</html>
Test that wheel and mouse events are dispatched to document and window even if they do not hit any element in the page.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
outside body, inside element
eventType: mousedown
PASS objectsToString(actualReceivers) is "HTMLDivElement,HTMLBodyElement,HTMLDocument,Window"
eventType: mouseup
PASS objectsToString(actualReceivers) is "HTMLDivElement,HTMLBodyElement,HTMLDocument,Window"
eventType: click
PASS objectsToString(actualReceivers) is "HTMLDivElement,HTMLBodyElement,HTMLDocument,Window"
eventType: wheel
PASS objectsToString(actualReceivers) is "HTMLDivElement,HTMLBodyElement,HTMLDocument,Window"
inside body, outside element
eventType: mousedown
PASS objectsToString(actualReceivers) is "HTMLBodyElement,HTMLDocument,Window"
eventType: mouseup
PASS objectsToString(actualReceivers) is "HTMLBodyElement,HTMLDocument,Window"
eventType: click
PASS objectsToString(actualReceivers) is "HTMLBodyElement,HTMLDocument,Window"
eventType: wheel
PASS objectsToString(actualReceivers) is "HTMLBodyElement,HTMLDocument,Window"
outside body, outside element, inside frame
eventType: mousedown
PASS objectsToString(actualReceivers) is "HTMLDocument,Window"
eventType: mouseup
PASS objectsToString(actualReceivers) is "HTMLDocument,Window"
eventType: click
PASS objectsToString(actualReceivers) is "HTMLDocument,Window"
eventType: wheel
PASS objectsToString(actualReceivers) is "HTMLDocument,Window"
PASS successfullyParsed is true
TEST COMPLETE
......@@ -33,18 +33,15 @@ div#child {
<div id='console'></div>
</body>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
jsTestIsAsync = true;
setPrintTestResultsLazily();
description('Test that wheel and mouse events are dispatched to document ' +
'and window even if they do not hit any element in the page.');
onload = function() {
if (!window.eventSender) {
testFailed('window.eventSender is required for this test.');
return;
}
const purpose =
'Test that wheel and mouse events are dispatched to document' +
'and window even if they do not hit any element in the page.';
test(() => {
assert_exists(window, 'eventSender', 'window.eventSender is required for this test.');
window.receivers = new Map();
var eventTypes = ['wheel', 'click', 'mousedown', 'mouseup'];
......@@ -57,20 +54,19 @@ onload = function() {
}
}
debug('outside body, inside element'); // received by element, body, doc, window
generateEventsAndVerify(500, 500, [document.getElementById('child'), document.body, document, window]);
debug('inside body, outside element'); // received by body, doc, window
generateEventsAndVerify(10, 10, [document.body, document, window]);
debug('outside body, outside element, inside frame'); // received by doc, window
generateEventsAndVerify(10, 500, [document, window]);
finishJSTest();
// received by element, body, doc, window
generateEventsAndVerify(500, 500, [document.getElementById('child'), document.body, document, window], 'outside body, inside element.');
// received by body, doc, window
generateEventsAndVerify(10, 10, [document.body, document, window], 'inside body, outside element.');
// received by doc, window
generateEventsAndVerify(10, 500, [document, window], 'outside body, outside element, inside frame.');
function registerEvent(e) {
window.receivers[e.type].push(this);
}
function generateEventsAndVerify(x, y, expectedReceivers) {
function generateEventsAndVerify(x, y, expectedReceivers, title) {
test(() => {
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
verifyReceivers('mousedown', expectedReceivers);
......@@ -81,16 +77,16 @@ onload = function() {
eventSender.mouseScrollBy(10, 10);
verifyReceivers('wheel', expectedReceivers);
}, title + ' ' + purpose);
}
function verifyReceivers(eventType, expectedReceivers) {
debug('eventType: ' + eventType);
window.actualReceivers = window.receivers[eventType];
shouldBeEqualToString('objectsToString(actualReceivers)', objectsToString(expectedReceivers));
assert_equals(objectsToString(actualReceivers), objectsToString(expectedReceivers), eventType);
window.receivers[eventType] = [];
}
}
});
function objectsToString(objects) {
return String(objects.map(function(o) {return o.constructor.name;}));
......
Type something into the first input and press tab. The browser should not crash.
PASSED
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div>Type something into the first input and press tab. The browser should not crash.</div>
<div id="parent">
<input id="a" />
<input id="b" />
</div>
<div id="results"></div>
<script>
document.getElementById("a").addEventListener("change", function(e) {
var parent = document.getElementById("parent");
......@@ -11,17 +12,11 @@ document.getElementById("a").addEventListener("change", function(e) {
document.getElementById("c").select();
}, false);
function runTest()
{
test(() => {
document.getElementById("a").focus();
if (!window.testRunner)
return;
testRunner.dumpAsText();
eventSender.keyDown("x")
eventSender.keyDown("\t");
document.getElementById("results").innerText = "PASSED";
}
runTest();
}, "Typing followed by focus change doesn't crash");
</script>
Click Here Click Here Too
PASS win is non-null.
PASS successfullyParsed is true
TEST COMPLETE
PASS win is non-null.
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<button id="button1" onclick="testButton1()">Click Here</button>
<button id="button2" onclick="testButton2()">Click Here Too</button>
<button id="test" onclick="popup()" style="display:none"></button>
<div id="console"></div>
<script>
setup({explicit_done: true});
var testNum = 0;
var win;
function popup() {
win = window.open("about:blank", "blank");
shouldBeNonNull("win");
assert_not_equals(win, null);
}
function testButton1() {
......@@ -44,28 +46,30 @@
function nextTest() {
if (testNum == 0) {
test(() => {
var button1 = document.getElementById("button1");
eventSender.mouseMoveTo(button1.offsetLeft + button1.offsetWidth / 2, button1.offsetTop + button1.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseUp();
}, 'Click button1');
} else if (testNum == 1) {
test(() => {
var button2 = document.getElementById("button2");
eventSender.mouseMoveTo(button2.offsetLeft + button2.offsetWidth / 2, button2.offsetTop + button2.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseUp();
}, 'Click button2');
} else {
testRunner.notifyDone();
done();
}
++testNum;
closeWindowAndRunNextTest();
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setPopupBlockingEnabled(true);
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.waitUntilDone();
nextTest();
}
......
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<button id="test" onclick="popup()" style="display:none"></button>
......@@ -9,21 +10,16 @@
var win;
function popup() {
win = window.open("about:blank", "blank");
shouldBeNull("win");
assert_equals(win, null);
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setPopupBlockingEnabled(true);
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.waitUntilDone();
}
document.getElementById("test").click();
if (window.testRunner)
testRunner.notifyDone();
test(() => document.getElementById("test").click(), 'Fake button click');
</script>
</body>
</html>
PASS win is null
PASS win is null
PASS successfullyParsed is true
TEST COMPLETE
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<textarea id="test" width="100" onfocus="popup()" onblur="popup()"></textarea>
<div id="console"></div>
<script>
var win;
function popup() {
win = window.open("about:blank", "blank");
shouldBeNull("win");
assert_equals(win, null);
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setPopupBlockingEnabled(true);
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.waitUntilDone();
}
document.getElementById("test").focus();
document.getElementById("test").blur();
if (window.testRunner)
testRunner.notifyDone();
test(() => document.getElementById("test").focus(), 'focus');
test(() => document.getElementById("test").blur(), 'blur');
</script>
</body>
</html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<a id=test href="javascript:popup()">test</a>
......@@ -9,23 +10,18 @@
var win;
function popup() {
win = window.open('about:blank','blank','height=200,width=200');
shouldBeNull("win");
assert_equals(win, null);
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.setCanOpenWindows();
testRunner.setPopupBlockingEnabled(true);
testRunner.setCloseRemainingWindowsWhenComplete(true);
testRunner.waitUntilDone();
}
clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent("click", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById("test").dispatchEvent(clickEvent);
if (window.testRunner)
testRunner.notifyDone();
test(() => document.getElementById("test").dispatchEvent(clickEvent), 'Untrusted click');
</script>
</body>
</html>
Target
Test user gesture behavior during touch events.
During a scroll, no touch events are user gestures
PASS openedPopup is false
PASS openedPopup is false
PASS openedPopup is false
During a drag that isn't a scroll, only touchend is a user gesture
PASS openedPopup is false
PASS openedPopup is false
PASS openedPopup is true
PASS successfullyParsed is true
TEST COMPLETE
<script src="../../../resources/js-test.js"></script>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id="target">Target</div>
<div id="description">Test user gesture behavior during touch events.</div>
<div id="console"></div>
<script>
......@@ -9,7 +9,7 @@ var cancelEvent = false;
var openedPopup = undefined;
function handler(e) {
if (openedPopup !== undefined)
testFailed("Handler invoked multiple times");
assert_unreached("Handler invoked multiple times");
var w = window.open("about:blank", "_blank");
if (w) {
......@@ -31,12 +31,9 @@ function testPopupOnEventDuring(eventType, expectPopup, operation) {
operation();
if (openedPopup===undefined)
testFailed(eventType + ' handler was not invoked');
else if (expectPopup)
shouldBeTrue("openedPopup");
else
shouldBeFalse("openedPopup");
assert_not_equals(openedPopup, undefined,
eventType + ' handler was not invoked');
assert_equals(openedPopup, expectPopup);
target.removeEventListener(eventType, handler);
}
......@@ -52,17 +49,19 @@ var rect = target.getBoundingClientRect();
var targetX = rect.left + rect.width / 2;
var targetY = rect.top + rect.height / 2;
debug("During a scroll, no touch events are user gestures");
cancelEvent = false;
eventSender.addTouchPoint(targetX, targetY);
testPopupOnEventDuring('touchstart', false, function() { eventSender.touchStart(); });
eventSender.updateTouchPoint(0, targetX + 10, targetY);
testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove(); });
eventSender.notifyStartOfTouchScroll();
eventSender.releaseTouchPoint(0);
testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd(); });
test(() => {
cancelEvent = false;
eventSender.addTouchPoint(targetX, targetY);
testPopupOnEventDuring('touchstart', false, function() { eventSender.touchStart(); });
eventSender.updateTouchPoint(0, targetX + 10, targetY);
testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove(); });
eventSender.notifyStartOfTouchScroll();
eventSender.releaseTouchPoint(0);
testPopupOnEventDuring('touchend', false, function() { eventSender.touchEnd(); });
}, "During a scroll, no touch events are user gestures");
debug("During a drag that isn't a scroll, only touchend is a user gesture");
test(() => {
cancelEvent = true;
eventSender.addTouchPoint(targetX, targetY);
testPopupOnEventDuring('touchstart', false, function() { eventSender.touchStart(); });
......@@ -70,5 +69,6 @@ eventSender.updateTouchPoint(0, targetX + 10, targetY);
testPopupOnEventDuring('touchmove', false, function() { eventSender.touchMove(); });
eventSender.releaseTouchPoint(0);
testPopupOnEventDuring('touchend', true, function() { eventSender.touchEnd(); });
}, "During a drag that isn't a scroll, only touchend is a user gesture");
</script>
CONSOLE ERROR: line 248: Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
CONSOLE ERROR: Refused to load the image 'http://127.0.0.1:8000/security/resources/abe.png' because it violates the following Content Security Policy directive: "img-src 'none'".
ALERT: PASS (1/1)
This test ensures that blocking an image via CSP doesn't crash if GC executes before the error event fires.
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
<meta http-equiv="Content-Security-Policy" content="img-src 'none'; script-src 'unsafe-inline'">
<script>
if (window.testRunner)
testRunner.waitUntilDone();
const testCase = async_test(
'Blocking an image via CSP doesn\'t crash if GC executes before the error event fires');
function test() {
(function () {
var img = document.createElement('img');
img.onload = function () {
alert('FAIL (1/1)');
finishTesting();
};
img.onerror = function () {
alert('PASS (1/1)');
finishTesting();
};
img.onload = testCase.step_func_done(() => assert_unreached());
img.onerror = testCase.step_func_done(() => {});
img.src = "../resources/abe.png";
})();
gc();
}
function finishTesting() {
if (window.testRunner)
setTimeout(function () { testRunner.notifyDone(); }, 0);
return true;
}
</script>
</head>
<body onload='test();'>
......
CONSOLE ERROR: line 95: Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-SKwGvORdKBYTYiM4lxIkanDyKH8J0qJ5Ix8LGkKsbhw='), or a nonce ('nonce-...') is required to enable inline execution.
CONSOLE ERROR: line 77: Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self'". Either the 'unsafe-inline' keyword, a hash ('sha256-E8Yv3p3nivzZKSVWxu7y2Pr+w7Nco7lvx8r5nBVoLFA='), or a nonce ('nonce-...') is required to enable inline execution.
PASS successfullyParsed is true
TEST COMPLETE
This test ensures that styles can be set by object.cloneNode()
PASS node1.style.background is "yellow"
PASS node2.style.background is "yellow"
PASS node3.style.background is "blue"
PASS node4.style.background is "blue"
PASS node1.style.color is "red"
PASS node2.style.color is "red"
PASS node3.style.color is "green"
PASS node4.style.color is "green"
PASS window.getComputedStyle(node1).background is window.getComputedStyle(node2).background
PASS window.getComputedStyle(node3).background is window.getComputedStyle(node4).background
PASS window.getComputedStyle(node1).color is window.getComputedStyle(node2).color
PASS window.getComputedStyle(node3).color is window.getComputedStyle(node4).color
PASS ops.style.background is ""
getComputedStyle(clonedOps).background: rgba(0, 0, 0, 0) none repeat scroll 0% 0% / auto padding-box border-box
PASS ops.style.color is "red"
PASS clonedOps.style.background is ""
PASS violetOps.style.background is "rgb(238, 130, 238)"
PASS window.getComputedStyle(clonedOps).background is window.getComputedStyle(ops).background
PASS window.getComputedStyle(clonedOps).color is window.getComputedStyle(ops).color
getComputedStyle(violetOps).background: rgb(238, 130, 238) none repeat scroll 0% 0% / auto padding-box border-box
PASS window.getComputedStyle(ops).background is not window.getComputedStyle(violetOps).background
PASS window.getComputedStyle(clonedOps).background is not window.getComputedStyle(violetOps).background
PASS ops.id is "ops"
PASS ops.id is clonedOps.id
This is a div (nodes)
This is a div. (node 1 or 2)
This is a div. (node 1 or 2)
This is a div. (node 3 or 4)
Node #4
Yet another div.
Yet another div.
Yet another div.
......@@ -2,11 +2,11 @@
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="style-src 'self';">
<script src="/js-test-resources/js-test.js"></script>
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
<script>
window.onload = function () {
debug("This test ensures that styles can be set by object.cloneNode()");
const testCase = async_test('Styles can be set by object.cloneNode()');
window.onload = testCase.step_func_done(() => {
window.nodes = document.getElementById('nodes');
window.node1 = document.getElementById('node1');
window.node1.style.background = "yellow";
......@@ -25,21 +25,21 @@
nodes.appendChild(node3);
nodes.appendChild(node4);
shouldBeEqualToString("node1.style.background", "yellow");
shouldBeEqualToString("node2.style.background", "yellow");
shouldBeEqualToString("node3.style.background", "blue");
shouldBeEqualToString("node4.style.background", "blue");
assert_equals(node1.style.background, "yellow");
assert_equals(node2.style.background, "yellow");
assert_equals(node3.style.background, "blue");
assert_equals(node4.style.background, "blue");
shouldBeEqualToString("node1.style.color", "red");
shouldBeEqualToString("node2.style.color", "red");
shouldBeEqualToString("node3.style.color", "green");
shouldBeEqualToString("node4.style.color", "green");
assert_equals(node1.style.color, "red");
assert_equals(node2.style.color, "red");
assert_equals(node3.style.color, "green");
assert_equals(node4.style.color, "green");
shouldBe("window.getComputedStyle(node1).background", "window.getComputedStyle(node2).background");
shouldBe("window.getComputedStyle(node3).background", "window.getComputedStyle(node4).background");
assert_equals(window.getComputedStyle(node1).background, window.getComputedStyle(node2).background);
assert_equals(window.getComputedStyle(node3).background, window.getComputedStyle(node4).background);
shouldBe("window.getComputedStyle(node1).color", "window.getComputedStyle(node2).color");
shouldBe("window.getComputedStyle(node3).color", "window.getComputedStyle(node4).color");
assert_equals(window.getComputedStyle(node1).color, window.getComputedStyle(node2).color);
assert_equals(window.getComputedStyle(node3).color, window.getComputedStyle(node4).color);
window.ops = document.getElementById('ops');
ops.style.color = 'red';
......@@ -49,21 +49,19 @@
violetOps.style.background = 'rgb(238, 130, 238)';
document.getElementsByTagName('body')[0].appendChild(clonedOps);
shouldBeEqualToString("ops.style.background", "");
debug("getComputedStyle(clonedOps).background: " + window.getComputedStyle(ops).background);
shouldBeEqualToString("ops.style.color", "red");
shouldBeEqualToString("clonedOps.style.background", "");
shouldBeEqualToString("violetOps.style.background", "rgb(238, 130, 238)");
assert_equals(ops.style.background, "");
assert_equals(ops.style.color, "red");
assert_equals(clonedOps.style.background, "");
assert_equals(violetOps.style.background, "rgb(238, 130, 238)");
shouldBe("window.getComputedStyle(clonedOps).background", "window.getComputedStyle(ops).background");
shouldBe("window.getComputedStyle(clonedOps).color", "window.getComputedStyle(ops).color");
debug("getComputedStyle(violetOps).background: " + window.getComputedStyle(violetOps).background);
shouldNotBe("window.getComputedStyle(ops).background", "window.getComputedStyle(violetOps).background");
shouldNotBe("window.getComputedStyle(clonedOps).background", "window.getComputedStyle(violetOps).background");
assert_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(ops).background);
assert_equals(window.getComputedStyle(clonedOps).color, window.getComputedStyle(ops).color);
assert_not_equals(window.getComputedStyle(ops).background, window.getComputedStyle(violetOps).background);
assert_not_equals(window.getComputedStyle(clonedOps).background, window.getComputedStyle(violetOps).background);
shouldBeEqualToString("ops.id", "ops");
shouldBe("ops.id", "clonedOps.id");
};
assert_equals(ops.id, "ops");
assert_equals(ops.id, clonedOps.id);
});
</script>
</head>
<body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment