michael@0: /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: // Test that the computed view shows the original source link when source maps michael@0: // are enabled michael@0: michael@0: const TESTCASE_URI = TEST_URL_ROOT_SSL + "doc_sourcemaps.html"; michael@0: const PREF = "devtools.styleeditor.source-maps-enabled"; michael@0: const SCSS_LOC = "doc_sourcemaps.scss:4"; michael@0: const CSS_LOC = "doc_sourcemaps.css:1"; michael@0: michael@0: let test = asyncTest(function*() { michael@0: info("Turning the pref " + PREF + " on"); michael@0: Services.prefs.setBoolPref(PREF, true); michael@0: michael@0: yield addTab(TESTCASE_URI); michael@0: let {toolbox, inspector, view} = yield openComputedView(); michael@0: michael@0: info("Select the test node"); michael@0: yield selectNode("div", inspector); michael@0: michael@0: info("Expanding the first property"); michael@0: yield expandComputedViewPropertyByIndex(view, inspector, 0); michael@0: michael@0: info("Verifying the link text"); michael@0: yield verifyLinkText(view, SCSS_LOC); michael@0: michael@0: info("Toggling the pref"); michael@0: Services.prefs.setBoolPref(PREF, false); michael@0: michael@0: info("Verifying that the link text has changed after the pref change"); michael@0: yield verifyLinkText(view, CSS_LOC); michael@0: michael@0: info("Toggling the pref again"); michael@0: Services.prefs.setBoolPref(PREF, true); michael@0: michael@0: info("Testing that clicking on the link works"); michael@0: yield testClickingLink(toolbox, view); michael@0: michael@0: info("Turning the pref " + PREF + " off"); michael@0: Services.prefs.clearUserPref(PREF); michael@0: }); michael@0: michael@0: function* testClickingLink(toolbox, view) { michael@0: let onEditor = waitForStyleEditor(toolbox, "doc_sourcemaps.scss"); michael@0: michael@0: info("Clicking the computedview stylesheet link"); michael@0: let link = getComputedViewLinkByIndex(view, 0); michael@0: link.scrollIntoView(); michael@0: link.click(); michael@0: michael@0: let editor = yield onEditor; michael@0: michael@0: let {line, col} = editor.sourceEditor.getCursor(); michael@0: is(line, 3, "cursor is at correct line number in original source"); michael@0: } michael@0: michael@0: function verifyLinkText(view, text) { michael@0: let link = getComputedViewLinkByIndex(view, 0); michael@0: michael@0: return waitForSuccess( michael@0: () => link.textContent == text, michael@0: "link text changed to display correct location: " + text michael@0: ); michael@0: }