Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: third_party/WebKit/LayoutTests/external/wpt/test_keys_wdspec.html

Issue 2665073003: Import wpt@cd5cce9780f84cee679919679b8199084ea96d54 (Closed)
Patch Set: Update test expectations and baselines. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/external/wpt/test_keys_wdspec.html
diff --git a/third_party/WebKit/LayoutTests/external/wpt/test_keys_wdspec.html b/third_party/WebKit/LayoutTests/external/wpt/test_keys_wdspec.html
new file mode 100644
index 0000000000000000000000000000000000000000..0c1ae3628540dde272feb1e4907052fc42b856e2
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/external/wpt/test_keys_wdspec.html
@@ -0,0 +1,69 @@
+<!doctype html>
+<meta charset=utf-8>
+<head>
+ <title>Test Keys</title>
+ <script>
+ var allEvents = {events: []};
+ function displayMessage(message) {
+ document.getElementById("events").innerHTML = "<p>" + message + "</p>";
+ }
+
+ function appendMessage(message) {
+ document.getElementById("events").innerHTML += "<p>" + message + "</p>";
+ }
+
+ /**
+ * Escape |key| if it's in a surrogate-half character range.
+ *
+ * Example: given "\ud83d" return "U+d83d".
+ *
+ * Otherwise JSON.stringify will convert it to U+FFFD (REPLACEMENT CHARACTER)
+ * when returning a value from executeScript, for example.
+ */
+ function escapeSurrogateHalf(key) {
+ if (typeof key !== "undefined" && key.length === 1) {
+ var charCode = key.charCodeAt(0);
+ var highSurrogate = charCode >= 0xD800 && charCode <= 0xDBFF;
+ var surrogate = highSurrogate || (charCode >= 0xDC00 && charCode <= 0xDFFF);
+ if (surrogate) {
+ key = "U+" + charCode.toString(16);
+ }
+ }
+ return key;
+ }
+
+ function recordEvent(event) {
+ var key = escapeSurrogateHalf(event.key);
+ allEvents.events.push({
+ "code": event.code,
+ "key": key,
+ "which": event.which,
+ "location": event.location,
+ "ctrl": event.ctrlKey,
+ "meta": event.metaKey,
+ "shift": event.shiftKey,
+ "repeat": event.repeat,
+ "type": event.type
+ });
+ appendMessage(`${event.type}(code:${event.code}, key:${key}, which:${event.which})`);
+ }
+
+ function resetEvents() {
+ allEvents.events.length = 0;
+ displayMessage("");
+ }
+ </script>
+</head>
+<body>
+ <div>
+ <h2>KeyReporter</h2>
+ <input type="text" id="keys" size="80"
+ onkeyup="recordEvent(event)"
+ onkeypress="recordEvent(event)"
+ onkeydown="recordEvent(event)">
+ </div>
+ <div id="resultContainer" style="width:300;height:60">
+ <h2>Events</h2>
+ <div id="events"></div>
+ </div>
+</body>

Powered by Google App Engine
This is Rietveld 408576698