Backed out changeset c6a1177a17e4 (bug 670002) because it should have been backed out with the other patch from this bug CLOSED TREE

--HG--
rename : devtools/client/framework/test/browser_source_map-01.js => devtools/client/framework/test/browser_source-location-01.js
rename : devtools/client/framework/test/browser_source_map-02.js => devtools/client/framework/test/browser_source-location-02.js
This commit is contained in:
Wes Kocher 2016-07-20 15:15:33 -07:00
Родитель 1fe6a5300c
Коммит 2f6e5ed95c
7 изменённых файлов: 39 добавлений и 122 удалений

Просмотреть файл

@ -8,12 +8,8 @@ support-files =
browser_toolbox_sidebar_tool.xul
browser_toolbox_window_title_changes_page.html
browser_toolbox_window_title_frame_select_page.html
code_binary_search.coffee
code_binary_search.js
code_binary_search.map
code_math.js
code_ugly.js
doc_empty-tab-01.html
head.js
shared-head.js
shared-redux-head.js
@ -35,8 +31,8 @@ support-files =
[browser_keybindings_03.js]
[browser_menu_api.js]
[browser_new_activation_workflow.js]
[browser_source_map-01.js]
[browser_source_map-02.js]
[browser_source-location-01.js]
[browser_source-location-02.js]
[browser_target_from_url.js]
[browser_target_events.js]
[browser_target_remote.js]

Просмотреть файл

@ -1,5 +1,5 @@
/* 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.
// As part of bug 1077403, the leaking uncaught rejections should be fixed.
@ -8,7 +8,7 @@ thisTestLeaksUncaughtRejectionsAndShouldBeFixed(
"TypeError: this.transport is null");
/**
* Tests the SourceMapService updates generated sources when source maps
* Tests the SourceMapController updates generated sources when source maps
* are subsequently found. Also checks when no column is provided, and
* when tagging an already source mapped location initially.
*/
@ -16,18 +16,18 @@ thisTestLeaksUncaughtRejectionsAndShouldBeFixed(
const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
// Empty page
const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
const JS_URL = `${URL_ROOT}code_binary_search.js`;
const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`;
const { SourceMapService } = require("devtools/client/framework/source-map-service");
const JS_URL = `${DEBUGGER_ROOT}code_binary_search.js`;
const COFFEE_URL = `${DEBUGGER_ROOT}code_binary_search.coffee`;
const { SourceLocationController } = require("devtools/client/framework/source-location");
add_task(function* () {
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
let toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const service = new SourceMapService(toolbox.target);
let controller = new SourceLocationController(toolbox.target);
const aggregator = [];
let aggregator = [];
function onUpdate(e, oldLoc, newLoc) {
function onUpdate(oldLoc, newLoc) {
if (oldLoc.line === 6) {
checkLoc1(oldLoc, newLoc);
} else if (oldLoc.line === 8) {
@ -42,19 +42,20 @@ add_task(function* () {
let loc1 = { url: JS_URL, line: 6 };
let loc2 = { url: JS_URL, line: 8, column: 3 };
let loc3 = { url: COFFEE_URL, line: 2, column: 0 };
service.subscribe(loc1, onUpdate);
service.subscribe(loc2, onUpdate);
controller.bindLocation(loc1, onUpdate);
controller.bindLocation(loc2, onUpdate);
controller.bindLocation(loc3, onUpdate);
// Inject JS script
let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_binary_search");
yield createScript(JS_URL);
yield sourceShown;
yield waitUntil(() => aggregator.length === 2);
yield waitUntil(() => aggregator.length === 3);
ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 4), "found first updated location");
ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 6), "found second updated location");
ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 2), "found third updated location");
yield toolbox.destroy();
gBrowser.removeCurrentTab();
@ -79,6 +80,15 @@ function checkLoc2(oldLoc, newLoc) {
is(newLoc.url, COFFEE_URL, "Correct url for JS:8:3 -> COFFEE");
}
function checkLoc3(oldLoc, newLoc) {
is(oldLoc.line, 2, "Correct line for COFFEE:2:0");
is(oldLoc.column, 0, "Correct column for COFFEE:2:0");
is(oldLoc.url, COFFEE_URL, "Correct url for COFFEE:2:0");
is(newLoc.line, 2, "Correct line for COFFEE:2:0 -> COFFEE");
is(newLoc.column, 0, "Correct column for COFFEE:2:0 -> COFFEE");
is(newLoc.url, COFFEE_URL, "Correct url for COFFEE:2:0 -> COFFEE");
}
function createScript(url) {
info(`Creating script: ${url}`);
let mm = getFrameScript();
@ -90,21 +100,3 @@ function createScript(url) {
`;
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;
}

Просмотреть файл

@ -1,9 +1,9 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests the SourceMapService updates generated sources when pretty printing
* Tests the SourceLocationController updates generated sources when pretty printing
* and un pretty printing.
*/
@ -11,17 +11,17 @@ const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/
// Empty page
const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
const JS_URL = `${URL_ROOT}code_ugly.js`;
const { SourceMapService } = require("devtools/client/framework/source-map-service");
const { SourceLocationController } = require("devtools/client/framework/source-location");
add_task(function* () {
let toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
let service = new SourceMapService(toolbox.target);
let controller = new SourceLocationController(toolbox.target);
let checkedPretty = false;
let checkedUnpretty = false;
function onUpdate(e, oldLoc, newLoc) {
function onUpdate(oldLoc, newLoc) {
if (oldLoc.line === 3) {
checkPrettified(oldLoc, newLoc);
checkedPretty = true;
@ -32,8 +32,8 @@ add_task(function* () {
throw new Error(`Unexpected location update: ${JSON.stringify(oldLoc)}`);
}
}
const loc1 = { url: JS_URL, line: 3 };
service.subscribe(loc1, onUpdate);
controller.bindLocation({ url: JS_URL, line: 3 }, onUpdate);
// Inject JS script
let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
@ -47,12 +47,12 @@ add_task(function* () {
yield waitUntil(() => checkedPretty);
// TODO check unprettified change once bug 1177446 fixed
// info("Testing un-pretty printing.");
// sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
// ppButton.click();
// yield sourceShown;
// yield waitUntil(() => checkedUnpretty);
/*
sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
ppButton.click();
yield sourceShown;
yield waitUntil(() => checkedUnpretty);
*/
yield toolbox.destroy();
gBrowser.removeCurrentTab();

Просмотреть файл

@ -1,18 +0,0 @@
# Uses a binary search algorithm to locate a value in the specified array.
window.binary_search = (items, value) ->
start = 0
stop = items.length - 1
pivot = Math.floor (start + stop) / 2
while items[pivot] isnt value and start < stop
# Adjust the search area.
stop = pivot - 1 if value < items[pivot]
start = pivot + 1 if value > items[pivot]
# Recalculate the pivot.
pivot = Math.floor (stop + start) / 2
# Make sure we've found the correct value.
if items[pivot] is value then pivot else -1

Просмотреть файл

@ -1,29 +0,0 @@
// Generated by CoffeeScript 1.6.1
(function() {
window.binary_search = function(items, value) {
var pivot, start, stop;
start = 0;
stop = items.length - 1;
pivot = Math.floor((start + stop) / 2);
while (items[pivot] !== value && start < stop) {
if (value < items[pivot]) {
stop = pivot - 1;
}
if (value > items[pivot]) {
start = pivot + 1;
}
pivot = Math.floor((stop + start) / 2);
}
if (items[pivot] === value) {
return pivot;
} else {
return -1;
}
};
}).call(this);
/*
//# sourceMappingURL=code_binary_search.map
*/

Просмотреть файл

@ -1,10 +0,0 @@
{
"version": 3,
"file": "code_binary_search.js",
"sourceRoot": "",
"sources": [
"code_binary_search.coffee"
],
"names": [],
"mappings": ";AACA;CAAA;CAAA,CAAA,CAAuB,EAAA,CAAjB,GAAkB,IAAxB;CAEE,OAAA,UAAA;CAAA,EAAQ,CAAR,CAAA;CAAA,EACQ,CAAR,CAAa,CAAL;CADR,EAEQ,CAAR,CAAA;CAEA,EAA0C,CAAR,CAAtB,MAAN;CAGJ,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,CAAR,CAAQ,GAAR;QAAA;CACA,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,EAAR,GAAA;QADA;CAAA,EAIQ,CAAI,CAAZ,CAAA;CAXF,IAIA;CAUA,GAAA,CAAS;CAAT,YAA8B;MAA9B;AAA0C,CAAD,YAAA;MAhBpB;CAAvB,EAAuB;CAAvB"
}

Просмотреть файл

@ -1,14 +0,0 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Empty test page 1</title>
</head>
<body>
</body>
</html>