|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 function test() { |
|
6 let inspector, doc, toolbox; |
|
7 let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); |
|
8 let {require} = devtools; |
|
9 let {Promise: promise} = Cu.import("resource://gre/modules/Promise.jsm", {}); |
|
10 let {Task} = Cu.import("resource://gre/modules/Task.jsm", {}); |
|
11 |
|
12 waitForExplicitFinish(); |
|
13 |
|
14 gBrowser.selectedTab = gBrowser.addTab(); |
|
15 gBrowser.selectedBrowser.addEventListener("load", function onload() { |
|
16 gBrowser.selectedBrowser.removeEventListener("load", onload, true); |
|
17 doc = content.document; |
|
18 waitForFocus(setupTest, content); |
|
19 }, true); |
|
20 |
|
21 content.location = "data:text/html;charset=utf-8,<h1>foo</h1><span>bar</span>"; |
|
22 |
|
23 function setupTest() { |
|
24 openInspector((aInspector, aToolbox) => { |
|
25 toolbox = aToolbox; |
|
26 inspector = aInspector; |
|
27 inspector.selection.setNode(doc.querySelector("span"), "test"); |
|
28 inspector.toolbox.once("highlighter-ready", runTests); |
|
29 }); |
|
30 } |
|
31 |
|
32 function runTests() { |
|
33 Task.spawn(function() { |
|
34 yield hoverH1InMarkupView(); |
|
35 yield assertH1Highlighted(); |
|
36 |
|
37 finishUp(); |
|
38 }).then(null, Cu.reportError); |
|
39 } |
|
40 |
|
41 function hoverH1InMarkupView() { |
|
42 let deferred = promise.defer(); |
|
43 let container = getContainerForRawNode(inspector.markup, doc.querySelector("h1")); |
|
44 |
|
45 inspector.toolbox.once("highlighter-ready", deferred.resolve); |
|
46 EventUtils.synthesizeMouseAtCenter(container.tagLine, {type: "mousemove"}, |
|
47 inspector.markup.doc.defaultView); |
|
48 |
|
49 return deferred.promise; |
|
50 } |
|
51 |
|
52 function assertH1Highlighted() { |
|
53 ok(isHighlighting(), "The highlighter is shown on a markup container hover"); |
|
54 is(getHighlitNode(), doc.querySelector("h1"), "The highlighter highlights the right node"); |
|
55 } |
|
56 |
|
57 function finishUp() { |
|
58 inspector = doc = toolbox = null; |
|
59 gBrowser.removeCurrentTab(); |
|
60 finish(); |
|
61 } |
|
62 } |