1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_no-results-placeholder.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,73 @@ 1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +// Tests that the no results placeholder works properly. 1.11 + 1.12 +let test = asyncTest(function*() { 1.13 + yield addTab("data:text/html,no results placeholder test"); 1.14 + 1.15 + info("Creating the test document"); 1.16 + content.document.body.innerHTML = '<style type="text/css"> ' + 1.17 + '.matches {color: #F00;}</style>' + 1.18 + '<span id="matches" class="matches">Some styled text</span>'; 1.19 + content.document.title = "Tests that the no results placeholder works properly"; 1.20 + 1.21 + info("Opening the computed view"); 1.22 + let {toolbox, inspector, view} = yield openComputedView(); 1.23 + 1.24 + info("Selecting the test node"); 1.25 + yield selectNode("#matches", inspector); 1.26 + 1.27 + yield enterInvalidFilter(inspector, view); 1.28 + checkNoResultsPlaceholderShown(view); 1.29 + 1.30 + yield clearFilterText(inspector, view); 1.31 + checkNoResultsPlaceholderHidden(view); 1.32 +}); 1.33 + 1.34 +function* enterInvalidFilter(inspector, computedView) { 1.35 + let searchbar = computedView.searchField; 1.36 + let searchTerm = "xxxxx"; 1.37 + 1.38 + info("setting filter text to \"" + searchTerm + "\""); 1.39 + 1.40 + let onRefreshed = inspector.once("computed-view-refreshed"); 1.41 + searchbar.focus(); 1.42 + for each (let c in searchTerm) { 1.43 + EventUtils.synthesizeKey(c, {}, computedView.styleWindow); 1.44 + } 1.45 + yield onRefreshed; 1.46 +} 1.47 + 1.48 +function checkNoResultsPlaceholderShown(computedView) { 1.49 + info("Checking that the no results placeholder is shown"); 1.50 + 1.51 + let placeholder = computedView.noResults; 1.52 + let win = computedView.styleWindow; 1.53 + let display = win.getComputedStyle(placeholder).display; 1.54 + is(display, "block", "placeholder is visible"); 1.55 +} 1.56 + 1.57 +function* clearFilterText(inspector, computedView) { 1.58 + info("Clearing the filter text"); 1.59 + 1.60 + let searchbar = computedView.searchField; 1.61 + 1.62 + let onRefreshed = inspector.once("computed-view-refreshed"); 1.63 + searchbar.focus(); 1.64 + searchbar.value = ""; 1.65 + EventUtils.synthesizeKey("c", {}, computedView.styleWindow); 1.66 + yield onRefreshed; 1.67 +} 1.68 + 1.69 +function checkNoResultsPlaceholderHidden(computedView) { 1.70 + info("Checking that the no results placeholder is hidden"); 1.71 + 1.72 + let placeholder = computedView.noResults; 1.73 + let win = computedView.styleWindow; 1.74 + let display = win.getComputedStyle(placeholder).display; 1.75 + is(display, "none", "placeholder is hidden"); 1.76 +}