|
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 // Test that the computed view shows the original source link when source maps |
|
8 // are enabled |
|
9 |
|
10 const TESTCASE_URI = TEST_URL_ROOT_SSL + "doc_sourcemaps.html"; |
|
11 const PREF = "devtools.styleeditor.source-maps-enabled"; |
|
12 const SCSS_LOC = "doc_sourcemaps.scss:4"; |
|
13 const CSS_LOC = "doc_sourcemaps.css:1"; |
|
14 |
|
15 let test = asyncTest(function*() { |
|
16 info("Turning the pref " + PREF + " on"); |
|
17 Services.prefs.setBoolPref(PREF, true); |
|
18 |
|
19 yield addTab(TESTCASE_URI); |
|
20 let {toolbox, inspector, view} = yield openComputedView(); |
|
21 |
|
22 info("Select the test node"); |
|
23 yield selectNode("div", inspector); |
|
24 |
|
25 info("Expanding the first property"); |
|
26 yield expandComputedViewPropertyByIndex(view, inspector, 0); |
|
27 |
|
28 info("Verifying the link text"); |
|
29 yield verifyLinkText(view, SCSS_LOC); |
|
30 |
|
31 info("Toggling the pref"); |
|
32 Services.prefs.setBoolPref(PREF, false); |
|
33 |
|
34 info("Verifying that the link text has changed after the pref change"); |
|
35 yield verifyLinkText(view, CSS_LOC); |
|
36 |
|
37 info("Toggling the pref again"); |
|
38 Services.prefs.setBoolPref(PREF, true); |
|
39 |
|
40 info("Testing that clicking on the link works"); |
|
41 yield testClickingLink(toolbox, view); |
|
42 |
|
43 info("Turning the pref " + PREF + " off"); |
|
44 Services.prefs.clearUserPref(PREF); |
|
45 }); |
|
46 |
|
47 function* testClickingLink(toolbox, view) { |
|
48 let onEditor = waitForStyleEditor(toolbox, "doc_sourcemaps.scss"); |
|
49 |
|
50 info("Clicking the computedview stylesheet link"); |
|
51 let link = getComputedViewLinkByIndex(view, 0); |
|
52 link.scrollIntoView(); |
|
53 link.click(); |
|
54 |
|
55 let editor = yield onEditor; |
|
56 |
|
57 let {line, col} = editor.sourceEditor.getCursor(); |
|
58 is(line, 3, "cursor is at correct line number in original source"); |
|
59 } |
|
60 |
|
61 function verifyLinkText(view, text) { |
|
62 let link = getComputedViewLinkByIndex(view, 0); |
|
63 |
|
64 return waitForSuccess( |
|
65 () => link.textContent == text, |
|
66 "link text changed to display correct location: " + text |
|
67 ); |
|
68 } |