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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/styleinspector/test/browser_computedview_original-source-link.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
     1.5 +/* Any copyright is dedicated to the Public Domain.
     1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Test that the computed view shows the original source link when source maps
    1.11 +// are enabled
    1.12 +
    1.13 +const TESTCASE_URI = TEST_URL_ROOT_SSL + "doc_sourcemaps.html";
    1.14 +const PREF = "devtools.styleeditor.source-maps-enabled";
    1.15 +const SCSS_LOC = "doc_sourcemaps.scss:4";
    1.16 +const CSS_LOC = "doc_sourcemaps.css:1";
    1.17 +
    1.18 +let test = asyncTest(function*() {
    1.19 +  info("Turning the pref " + PREF + " on");
    1.20 +  Services.prefs.setBoolPref(PREF, true);
    1.21 +
    1.22 +  yield addTab(TESTCASE_URI);
    1.23 +  let {toolbox, inspector, view} = yield openComputedView();
    1.24 +
    1.25 +  info("Select the test node");
    1.26 +  yield selectNode("div", inspector);
    1.27 +
    1.28 +  info("Expanding the first property");
    1.29 +  yield expandComputedViewPropertyByIndex(view, inspector, 0);
    1.30 +
    1.31 +  info("Verifying the link text");
    1.32 +  yield verifyLinkText(view, SCSS_LOC);
    1.33 +
    1.34 +  info("Toggling the pref");
    1.35 +  Services.prefs.setBoolPref(PREF, false);
    1.36 +
    1.37 +  info("Verifying that the link text has changed after the pref change");
    1.38 +  yield verifyLinkText(view, CSS_LOC);
    1.39 +
    1.40 +  info("Toggling the pref again");
    1.41 +  Services.prefs.setBoolPref(PREF, true);
    1.42 +
    1.43 +  info("Testing that clicking on the link works");
    1.44 +  yield testClickingLink(toolbox, view);
    1.45 +
    1.46 +  info("Turning the pref " + PREF + " off");
    1.47 +  Services.prefs.clearUserPref(PREF);
    1.48 +});
    1.49 +
    1.50 +function* testClickingLink(toolbox, view) {
    1.51 +  let onEditor = waitForStyleEditor(toolbox, "doc_sourcemaps.scss");
    1.52 +
    1.53 +  info("Clicking the computedview stylesheet link");
    1.54 +  let link = getComputedViewLinkByIndex(view, 0);
    1.55 +  link.scrollIntoView();
    1.56 +  link.click();
    1.57 +
    1.58 +  let editor = yield onEditor;
    1.59 +
    1.60 +  let {line, col} = editor.sourceEditor.getCursor();
    1.61 +  is(line, 3, "cursor is at correct line number in original source");
    1.62 +}
    1.63 +
    1.64 +function verifyLinkText(view, text) {
    1.65 +  let link = getComputedViewLinkByIndex(view, 0);
    1.66 +
    1.67 +  return waitForSuccess(
    1.68 +    () => link.textContent == text,
    1.69 +    "link text changed to display correct location: " + text
    1.70 +  );
    1.71 +}

mercurial