|
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/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 // Tests that the no results placeholder works properly. |
|
8 |
|
9 let test = asyncTest(function*() { |
|
10 yield addTab("data:text/html,no results placeholder test"); |
|
11 |
|
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"; |
|
17 |
|
18 info("Opening the computed view"); |
|
19 let {toolbox, inspector, view} = yield openComputedView(); |
|
20 |
|
21 info("Selecting the test node"); |
|
22 yield selectNode("#matches", inspector); |
|
23 |
|
24 yield enterInvalidFilter(inspector, view); |
|
25 checkNoResultsPlaceholderShown(view); |
|
26 |
|
27 yield clearFilterText(inspector, view); |
|
28 checkNoResultsPlaceholderHidden(view); |
|
29 }); |
|
30 |
|
31 function* enterInvalidFilter(inspector, computedView) { |
|
32 let searchbar = computedView.searchField; |
|
33 let searchTerm = "xxxxx"; |
|
34 |
|
35 info("setting filter text to \"" + searchTerm + "\""); |
|
36 |
|
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 } |
|
44 |
|
45 function checkNoResultsPlaceholderShown(computedView) { |
|
46 info("Checking that the no results placeholder is shown"); |
|
47 |
|
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 } |
|
53 |
|
54 function* clearFilterText(inspector, computedView) { |
|
55 info("Clearing the filter text"); |
|
56 |
|
57 let searchbar = computedView.searchField; |
|
58 |
|
59 let onRefreshed = inspector.once("computed-view-refreshed"); |
|
60 searchbar.focus(); |
|
61 searchbar.value = ""; |
|
62 EventUtils.synthesizeKey("c", {}, computedView.styleWindow); |
|
63 yield onRefreshed; |
|
64 } |
|
65 |
|
66 function checkNoResultsPlaceholderHidden(computedView) { |
|
67 info("Checking that the no results placeholder is hidden"); |
|
68 |
|
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 } |