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.

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

mercurial