michael@0: /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
michael@0: /* Any copyright is dedicated to the Public Domain.
michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0:
michael@0: "use strict";
michael@0:
michael@0: // Tests that the no results placeholder works properly.
michael@0:
michael@0: let test = asyncTest(function*() {
michael@0: yield addTab("data:text/html,no results placeholder test");
michael@0:
michael@0: info("Creating the test document");
michael@0: content.document.body.innerHTML = '' +
michael@0: 'Some styled text';
michael@0: content.document.title = "Tests that the no results placeholder works properly";
michael@0:
michael@0: info("Opening the computed view");
michael@0: let {toolbox, inspector, view} = yield openComputedView();
michael@0:
michael@0: info("Selecting the test node");
michael@0: yield selectNode("#matches", inspector);
michael@0:
michael@0: yield enterInvalidFilter(inspector, view);
michael@0: checkNoResultsPlaceholderShown(view);
michael@0:
michael@0: yield clearFilterText(inspector, view);
michael@0: checkNoResultsPlaceholderHidden(view);
michael@0: });
michael@0:
michael@0: function* enterInvalidFilter(inspector, computedView) {
michael@0: let searchbar = computedView.searchField;
michael@0: let searchTerm = "xxxxx";
michael@0:
michael@0: info("setting filter text to \"" + searchTerm + "\"");
michael@0:
michael@0: let onRefreshed = inspector.once("computed-view-refreshed");
michael@0: searchbar.focus();
michael@0: for each (let c in searchTerm) {
michael@0: EventUtils.synthesizeKey(c, {}, computedView.styleWindow);
michael@0: }
michael@0: yield onRefreshed;
michael@0: }
michael@0:
michael@0: function checkNoResultsPlaceholderShown(computedView) {
michael@0: info("Checking that the no results placeholder is shown");
michael@0:
michael@0: let placeholder = computedView.noResults;
michael@0: let win = computedView.styleWindow;
michael@0: let display = win.getComputedStyle(placeholder).display;
michael@0: is(display, "block", "placeholder is visible");
michael@0: }
michael@0:
michael@0: function* clearFilterText(inspector, computedView) {
michael@0: info("Clearing the filter text");
michael@0:
michael@0: let searchbar = computedView.searchField;
michael@0:
michael@0: let onRefreshed = inspector.once("computed-view-refreshed");
michael@0: searchbar.focus();
michael@0: searchbar.value = "";
michael@0: EventUtils.synthesizeKey("c", {}, computedView.styleWindow);
michael@0: yield onRefreshed;
michael@0: }
michael@0:
michael@0: function checkNoResultsPlaceholderHidden(computedView) {
michael@0: info("Checking that the no results placeholder is hidden");
michael@0:
michael@0: let placeholder = computedView.noResults;
michael@0: let win = computedView.styleWindow;
michael@0: let display = win.getComputedStyle(placeholder).display;
michael@0: is(display, "none", "placeholder is hidden");
michael@0: }