browser/devtools/styleinspector/test/browser_computedview_keybindings_02.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 ft=javascript 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 // Tests the computed-view keyboard navigation
michael@0 8
michael@0 9 let test = asyncTest(function*() {
michael@0 10 yield addTab("data:text/html,computed view keyboard nav test");
michael@0 11
michael@0 12 content.document.body.innerHTML = '<style type="text/css"> ' +
michael@0 13 'span { font-variant: small-caps; color: #000000; } ' +
michael@0 14 '.nomatches {color: #ff0000;}</style> <div id="first" style="margin: 10em; ' +
michael@0 15 'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA">\n' +
michael@0 16 '<h1>Some header text</h1>\n' +
michael@0 17 '<p id="salutation" style="font-size: 12pt">hi.</p>\n' +
michael@0 18 '<p id="body" style="font-size: 12pt">I am a test-case. This text exists ' +
michael@0 19 'solely to provide some things to <span style="color: yellow">' +
michael@0 20 'highlight</span> and <span style="font-weight: bold">count</span> ' +
michael@0 21 'style list-items in the box at right. If you are reading this, ' +
michael@0 22 'you should go do something else instead. Maybe read a book. Or better ' +
michael@0 23 'yet, write some test-cases for another bit of code. ' +
michael@0 24 '<span style="font-style: italic">some text</span></p>\n' +
michael@0 25 '<p id="closing">more text</p>\n' +
michael@0 26 '<p>even more text</p>' +
michael@0 27 '</div>';
michael@0 28 content.document.title = "Computed view keyboard navigation test";
michael@0 29
michael@0 30 info("Opening the computed-view");
michael@0 31 let {toolbox, inspector, view} = yield openComputedView();
michael@0 32
michael@0 33 info("Selecting the test node");
michael@0 34 yield selectNode("span", inspector);
michael@0 35
michael@0 36 info("Selecting the first computed style in the list");
michael@0 37 let firstStyle = view.styleDocument.querySelector(".property-view");
michael@0 38 ok(firstStyle, "First computed style found in panel");
michael@0 39 firstStyle.focus();
michael@0 40
michael@0 41 info("Tab to select the 2nd style and press return");
michael@0 42 let onExpanded = inspector.once("computed-view-property-expanded");
michael@0 43 EventUtils.synthesizeKey("VK_TAB", {});
michael@0 44 EventUtils.synthesizeKey("VK_RETURN", {});
michael@0 45 yield onExpanded;
michael@0 46
michael@0 47 info("Verify the 2nd style has been expanded");
michael@0 48 let secondStyleSelectors = view.styleDocument.querySelectorAll(
michael@0 49 ".property-content .matchedselectors")[1];
michael@0 50 ok(secondStyleSelectors.childNodes.length > 0, "Matched selectors expanded");
michael@0 51
michael@0 52 info("Tab back up and test the same thing, with space");
michael@0 53 let onExpanded = inspector.once("computed-view-property-expanded");
michael@0 54 EventUtils.synthesizeKey("VK_TAB", {shiftKey: true});
michael@0 55 EventUtils.synthesizeKey("VK_SPACE", {});
michael@0 56 yield onExpanded;
michael@0 57
michael@0 58 info("Verify the 1st style has been expanded too");
michael@0 59 let firstStyleSelectors = view.styleDocument.querySelectorAll(
michael@0 60 ".property-content .matchedselectors")[0];
michael@0 61 ok(firstStyleSelectors.childNodes.length > 0, "Matched selectors expanded");
michael@0 62 });

mercurial