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.

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

mercurial