1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_keybindings_02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Tests the computed-view keyboard navigation 1.11 + 1.12 +let test = asyncTest(function*() { 1.13 + yield addTab("data:text/html,computed view keyboard nav test"); 1.14 + 1.15 + content.document.body.innerHTML = '<style type="text/css"> ' + 1.16 + 'span { font-variant: small-caps; color: #000000; } ' + 1.17 + '.nomatches {color: #ff0000;}</style> <div id="first" style="margin: 10em; ' + 1.18 + 'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA">\n' + 1.19 + '<h1>Some header text</h1>\n' + 1.20 + '<p id="salutation" style="font-size: 12pt">hi.</p>\n' + 1.21 + '<p id="body" style="font-size: 12pt">I am a test-case. This text exists ' + 1.22 + 'solely to provide some things to <span style="color: yellow">' + 1.23 + 'highlight</span> and <span style="font-weight: bold">count</span> ' + 1.24 + 'style list-items in the box at right. If you are reading this, ' + 1.25 + 'you should go do something else instead. Maybe read a book. Or better ' + 1.26 + 'yet, write some test-cases for another bit of code. ' + 1.27 + '<span style="font-style: italic">some text</span></p>\n' + 1.28 + '<p id="closing">more text</p>\n' + 1.29 + '<p>even more text</p>' + 1.30 + '</div>'; 1.31 + content.document.title = "Computed view keyboard navigation test"; 1.32 + 1.33 + info("Opening the computed-view"); 1.34 + let {toolbox, inspector, view} = yield openComputedView(); 1.35 + 1.36 + info("Selecting the test node"); 1.37 + yield selectNode("span", inspector); 1.38 + 1.39 + info("Selecting the first computed style in the list"); 1.40 + let firstStyle = view.styleDocument.querySelector(".property-view"); 1.41 + ok(firstStyle, "First computed style found in panel"); 1.42 + firstStyle.focus(); 1.43 + 1.44 + info("Tab to select the 2nd style and press return"); 1.45 + let onExpanded = inspector.once("computed-view-property-expanded"); 1.46 + EventUtils.synthesizeKey("VK_TAB", {}); 1.47 + EventUtils.synthesizeKey("VK_RETURN", {}); 1.48 + yield onExpanded; 1.49 + 1.50 + info("Verify the 2nd style has been expanded"); 1.51 + let secondStyleSelectors = view.styleDocument.querySelectorAll( 1.52 + ".property-content .matchedselectors")[1]; 1.53 + ok(secondStyleSelectors.childNodes.length > 0, "Matched selectors expanded"); 1.54 + 1.55 + info("Tab back up and test the same thing, with space"); 1.56 + let onExpanded = inspector.once("computed-view-property-expanded"); 1.57 + EventUtils.synthesizeKey("VK_TAB", {shiftKey: true}); 1.58 + EventUtils.synthesizeKey("VK_SPACE", {}); 1.59 + yield onExpanded; 1.60 + 1.61 + info("Verify the 1st style has been expanded too"); 1.62 + let firstStyleSelectors = view.styleDocument.querySelectorAll( 1.63 + ".property-content .matchedselectors")[0]; 1.64 + ok(firstStyleSelectors.childNodes.length > 0, "Matched selectors expanded"); 1.65 +});