зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1724043 - Port dialog cancel event tests to WPT. r=sefeng
Differential Revision: https://phabricator.services.mozilla.com/D121762
This commit is contained in:
Родитель
3f890fe3ab
Коммит
343df9bbc4
|
@ -1,9 +1,4 @@
|
|||
[DEFAULT]
|
||||
prefs =
|
||||
dom.dialog_element.enabled=true
|
||||
[test_cancelDialogByEscape.html]
|
||||
[test_dialog_cancel_with_select.html]
|
||||
[test_dialog_cancel_events.html]
|
||||
[test_dialog_cancel_preventDefault.html]
|
||||
[test_dialog_keydown_preventDefault.html]
|
||||
[test_bug1648877_dialog_fullscreen_denied.html]
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1322947
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1322947</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="SimpleTest.waitForFocus(runTest)">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947"> Test dialog modal is closed by escape key</a>
|
||||
<p id="display"></p>
|
||||
<dialog id="dialog">
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
|
||||
<dialog id="dialogWithAutofocus">
|
||||
<input autofocus/>
|
||||
</dialog>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/* Make sure we still cancel the dialog even if the input element is focused */
|
||||
function runTestCancelWhenInputFocused() {
|
||||
const dialog = document.getElementById("dialogWithAutofocus");
|
||||
const input = document.querySelector("input");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
ok(dialog.close, "dialog with input autofocused is closed");
|
||||
done();
|
||||
});
|
||||
dialog.showModal();
|
||||
ok(input == document.activeElement, "input element should be focused");
|
||||
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
const dialog = document.getElementById("dialog");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
ok(dialog.close, "dialog closed");
|
||||
setTimeout(function(){
|
||||
runTestCancelWhenInputFocused();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1322947
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1322947</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="runTest()">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">Test cancel event
|
||||
is fired when the dialog is closed by user interaction</a>
|
||||
<p id="display"></p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
var hasCloseEventFired = false;
|
||||
|
||||
function runTest() {
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
ok(true, "cancel event is fired");
|
||||
ok(event.cancelable, "cancel event should be cancelable");
|
||||
ok(!hasCancelEventFired, "cancel event should only be fired once");
|
||||
ok(!hasCloseEventFired, "close event should be fired after cancel event");
|
||||
hasCancelEventFired = true;
|
||||
});
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
ok(true, "close event is fired");
|
||||
ok(!hasCloseEventFired, "close event should only be fired once");
|
||||
ok(hasCancelEventFired, "cancel event should be fired before close event");
|
||||
hasCloseEventFired = true;
|
||||
done();
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1322947
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1322947</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="SimpleTest.waitForFocus(runTest)">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">Test cancel event with preventDefault on cancel event for dialog element</a>
|
||||
<p id="display"></p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
|
||||
function runTest() {
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
const verify = () => {
|
||||
ok(hasCancelEventFired, "cancel is fired");
|
||||
done();
|
||||
}
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
hasCancelEventFired = true;
|
||||
event.preventDefault();
|
||||
setTimeout(function() {
|
||||
verify();
|
||||
}, 0)
|
||||
});
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
ok(false, "close event should not be fired");
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1322947
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1322947</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="SimpleTest.waitForFocus(runTest)">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947"> Test dialog modal is closed by escape key</a>
|
||||
<p id="display"></p>
|
||||
<dialog id="dialog">
|
||||
<select>
|
||||
<option value="one">one</option>
|
||||
<option value="two">two</option>
|
||||
</select>
|
||||
</dialog>
|
||||
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
const dialog = document.getElementById("dialog");
|
||||
const select = document.querySelector("select");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
ok(dialog.close, "dialog with select is closed");
|
||||
done();
|
||||
});
|
||||
dialog.showModal();
|
||||
ok(select == document.activeElement, "select element should be focused");
|
||||
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1322947
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1322947</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body onload="SimpleTest.waitForFocus(runTest)">
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">Test cancel event with preventDefault on keydown event for dialog element</a>
|
||||
<p id="display"></p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
|
||||
function runTest() {
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
const verify = () => {
|
||||
ok(!hasCancelEventFired, "cancel should not be fired");
|
||||
ok(hasKeydownEventFired, "document level keydown event should be fired");
|
||||
done();
|
||||
}
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
hasCancelEventFired = true;
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function(event) {
|
||||
hasKeydownEventFired = true;
|
||||
event.preventDefault();
|
||||
setTimeout(function() {
|
||||
verify();
|
||||
}, 0);
|
||||
});
|
||||
dialog.showModal();
|
||||
synthesizeKey("VK_ESCAPE", {}, window);
|
||||
}
|
||||
|
||||
function done() {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,50 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test cancel event is fired when the dialog is closed by user interaction</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
|
||||
</head>
|
||||
<body>
|
||||
<p>Test cancel event is fired when the dialog is closed by user interaction</p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
var hasCloseEventFired = false;
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
assert_true(true, "cancel event is fired");
|
||||
assert_true(event.cancelable, "cancel event should be cancelable");
|
||||
assert_false(hasCancelEventFired, "cancel event should only be fired once");
|
||||
assert_false(hasCloseEventFired, "close event should be fired after cancel event");
|
||||
hasCancelEventFired = true;
|
||||
});
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
assert_true(true, "close event is fired");
|
||||
assert_false(hasCloseEventFired, "close event should only be fired once");
|
||||
assert_true(hasCancelEventFired, "cancel event should be fired before close event");
|
||||
hasCloseEventFired = true;
|
||||
done();
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
|
||||
const escKey = "\uE00C";
|
||||
new test_driver.Actions()
|
||||
.keyDown(escKey)
|
||||
.keyUp(escKey)
|
||||
.send();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test cancel event with preventDefault on cancel event for dialog element</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
|
||||
</head>
|
||||
<body>
|
||||
<p>Test cancel event with preventDefault on cancel event for dialog element</p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
const verify = () => {
|
||||
assert_true(hasCancelEventFired, "cancel is fired");
|
||||
done();
|
||||
};
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
hasCancelEventFired = true;
|
||||
event.preventDefault();
|
||||
step_timeout(function() {
|
||||
verify();
|
||||
}, 0)
|
||||
});
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
assert_true(false, "close event should not be fired");
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
const escKey = "\uE00C";
|
||||
new test_driver.Actions()
|
||||
.keyDown(escKey)
|
||||
.keyUp(escKey)
|
||||
.send();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,63 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test dialog modal is closed by escape key with input focused</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
|
||||
</head>
|
||||
<body>
|
||||
<p>Test dialog modal is closed by escape key with input focused</p>
|
||||
<dialog id="dialog">
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
|
||||
<dialog id="dialogWithAutofocus">
|
||||
<input autofocus/>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
|
||||
const triggerEscKey = () => {
|
||||
const escKey = "\uE00C";
|
||||
new test_driver.Actions()
|
||||
.keyDown(escKey)
|
||||
.keyUp(escKey)
|
||||
.send();
|
||||
};
|
||||
|
||||
/* Make sure we still cancel the dialog even if the input element is focused */
|
||||
function runTestCancelWhenInputFocused() {
|
||||
const dialog = document.getElementById("dialogWithAutofocus");
|
||||
const input = document.querySelector("input");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
assert_false(dialog.open, "dialog with input autofocused is closed");
|
||||
done();
|
||||
});
|
||||
dialog.showModal();
|
||||
assert_true(input == document.activeElement, "input element should be focused");
|
||||
|
||||
triggerEscKey();
|
||||
}
|
||||
|
||||
const dialog = document.getElementById("dialog");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
assert_false(dialog.open, "dialog closed");
|
||||
step_timeout(function(){
|
||||
runTestCancelWhenInputFocused();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
dialog.showModal();
|
||||
triggerEscKey();
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test dialog modal is closed by escape key with select focused</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
|
||||
</head>
|
||||
<body>
|
||||
<p>Test dialog modal is closed by escape key with select focused</p>
|
||||
<dialog id="dialog">
|
||||
<select>
|
||||
<option value="one">one</option>
|
||||
<option value="two">two</option>
|
||||
</select>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
|
||||
const dialog = document.getElementById("dialog");
|
||||
const select = document.querySelector("select");
|
||||
|
||||
dialog.addEventListener("close", function() {
|
||||
assert_false(dialog.open, "dialog with select is closed");
|
||||
done();
|
||||
});
|
||||
dialog.showModal();
|
||||
assert_true(select == document.activeElement, "select element should be focused");
|
||||
|
||||
const escKey = "\uE00C";
|
||||
new test_driver.Actions()
|
||||
.keyDown(escKey)
|
||||
.keyUp(escKey)
|
||||
.send();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test cancel event with preventDefault on keydown event for dialog element</title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/testdriver.js"></script>
|
||||
<script src="/resources/testdriver-vendor.js"></script>
|
||||
<script src="/resources/testdriver-actions.js"></script>
|
||||
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322947">
|
||||
</head>
|
||||
<body>
|
||||
<p>Test cancel event with preventDefault on keydown event for dialog element</p>
|
||||
<dialog>
|
||||
<p>Hello World</p>
|
||||
</dialog>
|
||||
<script>
|
||||
setup({ single_test: true });
|
||||
|
||||
var hasCancelEventFired = false;
|
||||
|
||||
const dialog = document.querySelector("dialog");
|
||||
|
||||
const verify = () => {
|
||||
assert_false(hasCancelEventFired, "cancel should not be fired");
|
||||
assert_true(hasKeydownEventFired, "document level keydown event should be fired");
|
||||
done();
|
||||
};
|
||||
|
||||
dialog.addEventListener("cancel", function(event) {
|
||||
hasCancelEventFired = true;
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function(event) {
|
||||
hasKeydownEventFired = true;
|
||||
event.preventDefault();
|
||||
step_timeout(function() {
|
||||
verify();
|
||||
}, 0);
|
||||
});
|
||||
dialog.showModal();
|
||||
const escKey = "\uE00C";
|
||||
new test_driver.Actions()
|
||||
.keyDown(escKey)
|
||||
.keyUp(escKey)
|
||||
.send();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче