browser/devtools/styleinspector/test/browser_computedview_no-results-placeholder.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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