зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1365371 - change source map test not to require old debugger; r=jryans
MozReview-Commit-ID: 8SckurtKlHZ --HG-- extra : rebase_source : 9488041c361bab69d500dd1a6ed69368bbab321f
This commit is contained in:
Родитель
a48a121ef2
Коммит
ad27509671
|
@ -1,11 +1,7 @@
|
||||||
/* Any copyright is dedicated to the Public Domain.
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
// Whitelisting this test.
|
"use strict";
|
||||||
// As part of bug 1077403, the leaking uncaught rejections should be fixed.
|
|
||||||
thisTestLeaksUncaughtRejectionsAndShouldBeFixed("[object Object]");
|
|
||||||
thisTestLeaksUncaughtRejectionsAndShouldBeFixed(
|
|
||||||
"TypeError: this.transport is null");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the SourceMapService updates generated sources when source maps
|
* Tests the SourceMapService updates generated sources when source maps
|
||||||
|
@ -13,15 +9,8 @@ thisTestLeaksUncaughtRejectionsAndShouldBeFixed(
|
||||||
* when tagging an already source mapped location initially.
|
* when tagging an already source mapped location initially.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Force the old debugger UI since it's directly used (see Bug 1301705)
|
|
||||||
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
|
|
||||||
registerCleanupFunction(function* () {
|
|
||||||
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
|
|
||||||
});
|
|
||||||
|
|
||||||
const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
|
|
||||||
// Empty page
|
// Empty page
|
||||||
const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
|
const PAGE_URL = `${URL_ROOT}doc_empty-tab-01.html`;
|
||||||
const JS_URL = `${URL_ROOT}code_binary_search.js`;
|
const JS_URL = `${URL_ROOT}code_binary_search.js`;
|
||||||
const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`;
|
const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`;
|
||||||
|
|
||||||
|
@ -30,9 +19,9 @@ add_task(function* () {
|
||||||
const service = toolbox.sourceMapURLService;
|
const service = toolbox.sourceMapURLService;
|
||||||
|
|
||||||
// Inject JS script
|
// Inject JS script
|
||||||
let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_binary_search");
|
let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
|
||||||
yield createScript(JS_URL);
|
yield createScript(JS_URL);
|
||||||
yield sourceShown;
|
yield sourceSeen;
|
||||||
|
|
||||||
let loc1 = { url: JS_URL, line: 6 };
|
let loc1 = { url: JS_URL, line: 6 };
|
||||||
let newLoc1 = yield service.originalPositionFor(loc1.url, loc1.line);
|
let newLoc1 = yield service.originalPositionFor(loc1.url, loc1.line);
|
||||||
|
@ -64,33 +53,3 @@ function checkLoc2(oldLoc, newLoc) {
|
||||||
is(newLoc.column, 10, "Correct column for JS:8:3 -> COFFEE");
|
is(newLoc.column, 10, "Correct column for JS:8:3 -> COFFEE");
|
||||||
is(newLoc.sourceUrl, COFFEE_URL, "Correct url for JS:8:3 -> COFFEE");
|
is(newLoc.sourceUrl, COFFEE_URL, "Correct url for JS:8:3 -> COFFEE");
|
||||||
}
|
}
|
||||||
|
|
||||||
function createScript(url) {
|
|
||||||
info(`Creating script: ${url}`);
|
|
||||||
let mm = getFrameScript();
|
|
||||||
let command = `
|
|
||||||
let script = document.createElement("script");
|
|
||||||
script.setAttribute("src", "${url}");
|
|
||||||
document.body.appendChild(script);
|
|
||||||
null;
|
|
||||||
`;
|
|
||||||
return evalInDebuggee(mm, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
function waitForSourceShown(debuggerPanel, url) {
|
|
||||||
let { panelWin } = debuggerPanel;
|
|
||||||
let deferred = defer();
|
|
||||||
|
|
||||||
info(`Waiting for source ${url} to be shown in the debugger...`);
|
|
||||||
panelWin.on(panelWin.EVENTS.SOURCE_SHOWN, function onSourceShown(_, source) {
|
|
||||||
|
|
||||||
let sourceUrl = source.url || source.generatedUrl;
|
|
||||||
if (sourceUrl.includes(url)) {
|
|
||||||
panelWin.off(panelWin.EVENTS.SOURCE_SHOWN, onSourceShown);
|
|
||||||
info(`Source shown for ${url}`);
|
|
||||||
deferred.resolve(source);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return deferred.promise;
|
|
||||||
}
|
|
||||||
|
|
|
@ -146,3 +146,45 @@ function checkHostType(toolbox, hostType, previousHostType) {
|
||||||
previousHostType, "The previous host is correct");
|
previousHostType, "The previous host is correct");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new <script> referencing URL. Return a promise that
|
||||||
|
* resolves when this has happened
|
||||||
|
* @param {String} url
|
||||||
|
* the url
|
||||||
|
* @return {Promise} a promise that resolves when the element has been created
|
||||||
|
*/
|
||||||
|
function createScript(url) {
|
||||||
|
info(`Creating script: ${url}`);
|
||||||
|
let mm = getFrameScript();
|
||||||
|
let command = `
|
||||||
|
let script = document.createElement("script");
|
||||||
|
script.setAttribute("src", "${url}");
|
||||||
|
document.body.appendChild(script);
|
||||||
|
null;
|
||||||
|
`;
|
||||||
|
return evalInDebuggee(mm, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait for the toolbox to notice that a given source is loaded
|
||||||
|
* @param {Toolbox} toolbox
|
||||||
|
* @param {String} url
|
||||||
|
* the url to wait for
|
||||||
|
* @return {Promise} a promise that is resolved when the source is loaded
|
||||||
|
*/
|
||||||
|
function waitForSourceLoad(toolbox, url) {
|
||||||
|
info(`Waiting for source ${url} to be available...`);
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let target = toolbox.target;
|
||||||
|
|
||||||
|
function sourceHandler(_, sourceEvent) {
|
||||||
|
if (sourceEvent && sourceEvent.source && sourceEvent.source.url === url) {
|
||||||
|
resolve();
|
||||||
|
target.off("source-updated", sourceHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target.on("source-updated", sourceHandler);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче