browser/devtools/styleinspector/test/browser_computedview_no-results-placeholder.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 that the no results placeholder works properly.
     9 let test = asyncTest(function*() {
    10   yield addTab("data:text/html,no results placeholder test");
    12   info("Creating the test document");
    13   content.document.body.innerHTML = '<style type="text/css"> ' +
    14     '.matches {color: #F00;}</style>' +
    15     '<span id="matches" class="matches">Some styled text</span>';
    16   content.document.title = "Tests that the no results placeholder works properly";
    18   info("Opening the computed view");
    19   let {toolbox, inspector, view} = yield openComputedView();
    21   info("Selecting the test node");
    22   yield selectNode("#matches", inspector);
    24   yield enterInvalidFilter(inspector, view);
    25   checkNoResultsPlaceholderShown(view);
    27   yield clearFilterText(inspector, view);
    28   checkNoResultsPlaceholderHidden(view);
    29 });
    31 function* enterInvalidFilter(inspector, computedView) {
    32   let searchbar = computedView.searchField;
    33   let searchTerm = "xxxxx";
    35   info("setting filter text to \"" + searchTerm + "\"");
    37   let onRefreshed = inspector.once("computed-view-refreshed");
    38   searchbar.focus();
    39   for each (let c in searchTerm) {
    40     EventUtils.synthesizeKey(c, {}, computedView.styleWindow);
    41   }
    42   yield onRefreshed;
    43 }
    45 function checkNoResultsPlaceholderShown(computedView) {
    46   info("Checking that the no results placeholder is shown");
    48   let placeholder = computedView.noResults;
    49   let win = computedView.styleWindow;
    50   let display = win.getComputedStyle(placeholder).display;
    51   is(display, "block", "placeholder is visible");
    52 }
    54 function* clearFilterText(inspector, computedView) {
    55   info("Clearing the filter text");
    57   let searchbar = computedView.searchField;
    59   let onRefreshed = inspector.once("computed-view-refreshed");
    60   searchbar.focus();
    61   searchbar.value = "";
    62   EventUtils.synthesizeKey("c", {}, computedView.styleWindow);
    63   yield onRefreshed;
    64 }
    66 function checkNoResultsPlaceholderHidden(computedView) {
    67   info("Checking that the no results placeholder is hidden");
    69   let placeholder = computedView.noResults;
    70   let win = computedView.styleWindow;
    71   let display = win.getComputedStyle(placeholder).display;
    72   is(display, "none", "placeholder is hidden");
    73 }

mercurial