Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/ */
5 "use strict";
7 // Test that the computed view shows the original source link when source maps
8 // are enabled
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";
15 let test = asyncTest(function*() {
16 info("Turning the pref " + PREF + " on");
17 Services.prefs.setBoolPref(PREF, true);
19 yield addTab(TESTCASE_URI);
20 let {toolbox, inspector, view} = yield openComputedView();
22 info("Select the test node");
23 yield selectNode("div", inspector);
25 info("Expanding the first property");
26 yield expandComputedViewPropertyByIndex(view, inspector, 0);
28 info("Verifying the link text");
29 yield verifyLinkText(view, SCSS_LOC);
31 info("Toggling the pref");
32 Services.prefs.setBoolPref(PREF, false);
34 info("Verifying that the link text has changed after the pref change");
35 yield verifyLinkText(view, CSS_LOC);
37 info("Toggling the pref again");
38 Services.prefs.setBoolPref(PREF, true);
40 info("Testing that clicking on the link works");
41 yield testClickingLink(toolbox, view);
43 info("Turning the pref " + PREF + " off");
44 Services.prefs.clearUserPref(PREF);
45 });
47 function* testClickingLink(toolbox, view) {
48 let onEditor = waitForStyleEditor(toolbox, "doc_sourcemaps.scss");
50 info("Clicking the computedview stylesheet link");
51 let link = getComputedViewLinkByIndex(view, 0);
52 link.scrollIntoView();
53 link.click();
55 let editor = yield onEditor;
57 let {line, col} = editor.sourceEditor.getCursor();
58 is(line, 3, "cursor is at correct line number in original source");
59 }
61 function verifyLinkText(view, text) {
62 let link = getComputedViewLinkByIndex(view, 0);
64 return waitForSuccess(
65 () => link.textContent == text,
66 "link text changed to display correct location: " + text
67 );
68 }