browser/devtools/styleinspector/test/browser_computedview_original-source-link.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial