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

Unified Diff: third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html

Issue 2619963002: Improve performance of access-key-for-all-elements.html. (Closed)
Patch Set: Follow review comments 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/fast/forms/access-key-for-all-elements.html
diff --git a/third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html b/third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html
index ffaccd98dacb56e4a7006f772b2a6a63efb36794..a0c94c2cedbcf09c52963b1eb9e75b5c44bb4bc1 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/access-key-for-all-elements.html
@@ -1,43 +1,51 @@
<!DOCTYPE html>
-<html>
-<head>
-<script src="../../resources/js-test.js"></script>
-</head>
<body>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
<script>
-description('This test checks to see if accesskey attributes works on all elements.');
+const modifiers = /\bMac OS X\b/.test(navigator.userAgent) ? ["ctrlKey", "altKey"] : ["altKey"];
-function pressKey(key)
-{
- if (/\bMac OS X\b/.test(navigator.userAgent))
- modifiers = ["ctrlKey", "altKey"];
- else
- modifiers = ["altKey"];
- eventSender.keyDown(key, modifiers);
+function pressKey(key) {
+ eventSender.keyDown(key, modifiers);
}
-var tagNames = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdo","bgsound","big","blockquote",
- "body","br","canvas","caption","center","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt",
- "em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html",
- "i","iframe","img","ins","kbd","keygen","label","layer","li","link","listing","main","map","mark","marquee","menu","meta","meter","nav",
- "nobr","noembed","noframes","nolayer","noscript","object","ol","output","p","param","plaintext","pre","progress","q","rp","rt","ruby","s",
- "samp","script","section","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","tfoot","th","thead",
- "title","tr","track","tt","u","ul","var","video","wbr","xmp"];
+const tagNames = [
+ "a", "abbr", "acronym", "address", "area", "article", "aside", "audio",
+ "b", "base", "basefont", "bdo", "bgsound", "big", "blockquote", "body", "br",
+ "canvas", "caption", "center", "cite", "code", "col", "colgroup", "datalist",
+ "dd", "del", "details", "dfn", "dir", "div", "dl", "dt",
+ "em", "embed", "fieldset", "figcaption", "figure", "font", "footer", "form",
+ "frame", "frameset",
+ "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup","hr","html",
+ "i", "iframe", "img", "ins", "kbd", "label", "layer", "li", "link", "listing",
+ "main", "map", "mark", "marquee", "menu", "meta", "meter",
+ "nav", "nobr", "noembed", "noframes", "nolayer", "noscript",
+ "object", "ol", "output", "p", "param", "plaintext", "pre", "progress", "q",
+ "rp", "rt", "ruby", "s", "samp", "script", "section", "small", "source",
+ "span", "strike", "strong", "style", "sub", "summary", "sup",
+ "table", "tbody", "td", "tfoot", "th", "thead", "title", "tr", "track", "tt",
+ "u", "ul", "var", "video", "wbr", "xmp"];
-for (var i = 0 ; i < tagNames.length; i++) {
- var testElement = document.createElement(tagNames[i]);
+tagNames.forEach((name) => {
+ test(() => {
+ var testElement = document.createElement(name);
document.body.appendChild(testElement);
var clicked = false;
- testElement.onclick = function () { clicked = true; }
+ testElement.onclick = () => { clicked = true; }
var focused = false;
- testElement.onfocus = function () { focused = true; }
- debug('Check for ' + testElement.tagName + ' tag');
- shouldBeDefined('testElement.accessKey');
- shouldBeTrue("testElement.accessKey ='k'; testElement.accessKey == 'k'");
- shouldBe("pressKey(testElement.accessKey);[clicked, focused]", "[true, false]");
- debug('');
-}
+ testElement.onfocus = () => { focused = true; }
+
+ assert_not_equals(testElement.accessKey, undefined);
+
+ testElement.accessKey = "k";
+ assert_equals(testElement.accessKey, "k");
+
+ pressKey(testElement.accessKey);
+ assert_true(clicked, "Pressing access key should trigger click handler.");
+ assert_false(focused, "Pressing access key should not focus on the element.");
+
+ document.body.removeChild(testElement);
+ }, "Check for " + name + " tag");
+});
</script>
-<div id="console"></div>
</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698