Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 4 | |
michael@0 | 5 | "use strict"; |
michael@0 | 6 | |
michael@0 | 7 | // Test that the markup-view nodes can be navigated to with the keyboard |
michael@0 | 8 | |
michael@0 | 9 | const TEST_URL = TEST_URL_ROOT + "doc_markup_navigation.html"; |
michael@0 | 10 | const TEST_DATA = [ |
michael@0 | 11 | ["pageup", "*doctype*"], |
michael@0 | 12 | ["down", "html"], |
michael@0 | 13 | ["down", "head"], |
michael@0 | 14 | ["down", "body"], |
michael@0 | 15 | ["down", "node0"], |
michael@0 | 16 | ["right", "node0"], |
michael@0 | 17 | ["down", "node1"], |
michael@0 | 18 | ["down", "node2"], |
michael@0 | 19 | ["down", "node3"], |
michael@0 | 20 | ["down", "*comment*"], |
michael@0 | 21 | ["down", "node4"], |
michael@0 | 22 | ["right", "node4"], |
michael@0 | 23 | ["down", "*text*"], |
michael@0 | 24 | ["down", "node5"], |
michael@0 | 25 | ["down", "node6"], |
michael@0 | 26 | ["down", "*comment*"], |
michael@0 | 27 | ["down" , "node7"], |
michael@0 | 28 | ["right", "node7"], |
michael@0 | 29 | ["down", "*text*"], |
michael@0 | 30 | ["down", "node8"], |
michael@0 | 31 | ["left", "node7"], |
michael@0 | 32 | ["left", "node7"], |
michael@0 | 33 | ["right", "node7"], |
michael@0 | 34 | ["right", "*text*"], |
michael@0 | 35 | ["down", "node8"], |
michael@0 | 36 | ["right", "node8"], |
michael@0 | 37 | ["left", "node8"], |
michael@0 | 38 | ["down", "node9"], |
michael@0 | 39 | ["down", "node10"], |
michael@0 | 40 | ["down", "node11"], |
michael@0 | 41 | ["down", "node12"], |
michael@0 | 42 | ["right", "node12"], |
michael@0 | 43 | ["down", "*text*"], |
michael@0 | 44 | ["down", "node13"], |
michael@0 | 45 | ["down", "node14"], |
michael@0 | 46 | ["down", "node15"], |
michael@0 | 47 | ["down", "node15"], |
michael@0 | 48 | ["down", "node15"], |
michael@0 | 49 | ["up", "node14"], |
michael@0 | 50 | ["up", "node13"], |
michael@0 | 51 | ["up", "*text*"], |
michael@0 | 52 | ["up", "node12"], |
michael@0 | 53 | ["left", "node12"], |
michael@0 | 54 | ["down", "node14"], |
michael@0 | 55 | ["home", "*doctype*"], |
michael@0 | 56 | ["pagedown", "*text*"], |
michael@0 | 57 | ["down", "node5"], |
michael@0 | 58 | ["down", "node6"], |
michael@0 | 59 | ["down", "*comment*"], |
michael@0 | 60 | ["down", "node7"], |
michael@0 | 61 | ["left", "node7"], |
michael@0 | 62 | ["down", "node9"], |
michael@0 | 63 | ["down", "node10"], |
michael@0 | 64 | ["pageup", "node2"], |
michael@0 | 65 | ["pageup", "*doctype*"], |
michael@0 | 66 | ["down", "html"], |
michael@0 | 67 | ["left", "html"], |
michael@0 | 68 | ["down", "html"] |
michael@0 | 69 | ]; |
michael@0 | 70 | |
michael@0 | 71 | let test = asyncTest(function*() { |
michael@0 | 72 | let {inspector} = yield addTab(TEST_URL).then(openInspector); |
michael@0 | 73 | |
michael@0 | 74 | info("Making sure the markup-view frame is focused"); |
michael@0 | 75 | inspector.markup._frame.focus(); |
michael@0 | 76 | |
michael@0 | 77 | info("Starting to iterate through the test data"); |
michael@0 | 78 | for (let [key, className] of TEST_DATA) { |
michael@0 | 79 | info("Testing step: " + key + " to navigate to " + className); |
michael@0 | 80 | pressKey(key); |
michael@0 | 81 | |
michael@0 | 82 | info("Making sure markup-view children get updated"); |
michael@0 | 83 | yield waitForChildrenUpdated(inspector); |
michael@0 | 84 | |
michael@0 | 85 | info("Checking the right node is selected"); |
michael@0 | 86 | checkSelectedNode(key, className, inspector); |
michael@0 | 87 | } |
michael@0 | 88 | }); |
michael@0 | 89 | |
michael@0 | 90 | function pressKey(key) { |
michael@0 | 91 | switch(key) { |
michael@0 | 92 | case "right": |
michael@0 | 93 | EventUtils.synthesizeKey("VK_RIGHT", {}); |
michael@0 | 94 | break; |
michael@0 | 95 | case "down": |
michael@0 | 96 | EventUtils.synthesizeKey("VK_DOWN", {}); |
michael@0 | 97 | break; |
michael@0 | 98 | case "left": |
michael@0 | 99 | EventUtils.synthesizeKey("VK_LEFT", {}); |
michael@0 | 100 | break; |
michael@0 | 101 | case "up": |
michael@0 | 102 | EventUtils.synthesizeKey("VK_UP", {}); |
michael@0 | 103 | break; |
michael@0 | 104 | case "pageup": |
michael@0 | 105 | EventUtils.synthesizeKey("VK_PAGE_UP", {}); |
michael@0 | 106 | break; |
michael@0 | 107 | case "pagedown": |
michael@0 | 108 | EventUtils.synthesizeKey("VK_PAGE_DOWN", {}); |
michael@0 | 109 | break; |
michael@0 | 110 | case "home": |
michael@0 | 111 | EventUtils.synthesizeKey("VK_HOME", {}); |
michael@0 | 112 | break; |
michael@0 | 113 | } |
michael@0 | 114 | } |
michael@0 | 115 | |
michael@0 | 116 | function checkSelectedNode(key, className, inspector) { |
michael@0 | 117 | let node = inspector.selection.node; |
michael@0 | 118 | |
michael@0 | 119 | if (className == "*comment*") { |
michael@0 | 120 | is(node.nodeType, Node.COMMENT_NODE, "Found a comment after pressing " + key); |
michael@0 | 121 | } else if (className == "*text*") { |
michael@0 | 122 | is(node.nodeType, Node.TEXT_NODE, "Found text after pressing " + key); |
michael@0 | 123 | } else if (className == "*doctype*") { |
michael@0 | 124 | is(node.nodeType, Node.DOCUMENT_TYPE_NODE, "Found the doctype after pressing " + key); |
michael@0 | 125 | } else { |
michael@0 | 126 | is(node.className, className, "Found node: " + className + " after pressing " + key); |
michael@0 | 127 | } |
michael@0 | 128 | } |