mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 949762 - Tracer should respect black boxing. r=fitzgen
This commit is contained in:
parent
7c2d3e4078
commit
8bfef49271
@ -1234,11 +1234,7 @@ SourceScripts.prototype = {
|
||||
_onBlackBoxChange: function (aEvent, { url, isBlackBoxed }) {
|
||||
const item = DebuggerView.Sources.getItemByValue(url);
|
||||
if (item) {
|
||||
if (isBlackBoxed) {
|
||||
item.prebuiltNode.classList.add("black-boxed");
|
||||
} else {
|
||||
item.prebuiltNode.classList.remove("black-boxed");
|
||||
}
|
||||
item.prebuiltNode.classList.toggle("black-boxed", isBlackBoxed);
|
||||
}
|
||||
DebuggerView.Sources.updateToolbarButtonsState();
|
||||
DebuggerView.maybeShowBlackBoxMessage();
|
||||
@ -1555,11 +1551,12 @@ Tracer.prototype = {
|
||||
/**
|
||||
* Callback for handling a new call frame.
|
||||
*/
|
||||
_onCall: function({ name, location, parameterNames, depth, arguments: args }) {
|
||||
_onCall: function({ name, location, blackBoxed, parameterNames, depth, arguments: args }) {
|
||||
const item = {
|
||||
name: name,
|
||||
location: location,
|
||||
id: this._idCounter++
|
||||
id: this._idCounter++,
|
||||
blackBoxed
|
||||
};
|
||||
|
||||
this._stack.push(item);
|
||||
@ -1570,7 +1567,8 @@ Tracer.prototype = {
|
||||
depth: depth,
|
||||
parameterNames: parameterNames,
|
||||
arguments: args,
|
||||
frameId: item.id
|
||||
frameId: item.id,
|
||||
blackBoxed
|
||||
});
|
||||
},
|
||||
|
||||
@ -1582,14 +1580,15 @@ Tracer.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
const { name, id, location } = this._stack.pop();
|
||||
const { name, id, location, blackBoxed } = this._stack.pop();
|
||||
DebuggerView.Tracer.addTrace({
|
||||
type: aPacket.why,
|
||||
name: name,
|
||||
location: location,
|
||||
depth: aPacket.depth,
|
||||
frameId: id,
|
||||
returnVal: aPacket.return || aPacket.throw || aPacket.yield
|
||||
returnVal: aPacket.return || aPacket.throw || aPacket.yield,
|
||||
blackBoxed
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1437,10 +1437,11 @@ TracerView.prototype = Heritage.extend(WidgetMethods, {
|
||||
* The network request view.
|
||||
*/
|
||||
_createView: function(aTrace) {
|
||||
let { type, name, location, depth, frameId } = aTrace;
|
||||
let { type, name, location, blackBoxed, depth, frameId } = aTrace;
|
||||
let { parameterNames, returnVal, arguments: args } = aTrace;
|
||||
let fragment = document.createDocumentFragment();
|
||||
|
||||
this._templateItem.classList.toggle("black-boxed", blackBoxed);
|
||||
this._templateItem.setAttribute("tooltiptext", SourceUtils.trimUrl(location.url));
|
||||
this._templateItem.style.MozPaddingStart = depth + "em";
|
||||
|
||||
|
@ -262,6 +262,7 @@ skip-if = os == "linux" || e10s # Bug 888811 & bug 891176
|
||||
[browser_dbg_tracing-04.js]
|
||||
[browser_dbg_tracing-05.js]
|
||||
[browser_dbg_tracing-06.js]
|
||||
[browser_dbg_tracing-07.js]
|
||||
[browser_dbg_variables-view-01.js]
|
||||
[browser_dbg_variables-view-02.js]
|
||||
[browser_dbg_variables-view-03.js]
|
||||
|
86
browser/devtools/debugger/test/browser_dbg_tracing-07.js
Normal file
86
browser/devtools/debugger/test/browser_dbg_tracing-07.js
Normal file
@ -0,0 +1,86 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Execute code both before and after blackboxing and test that we get
|
||||
* appropriately styled traces.
|
||||
*/
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
|
||||
|
||||
let gTab, gDebuggee, gPanel;
|
||||
|
||||
function test() {
|
||||
Task.async(function*() {
|
||||
yield pushPref();
|
||||
|
||||
[gTab, gDebuggee, gPanel] = yield initDebugger(TAB_URL);
|
||||
|
||||
yield startTracing(gPanel);
|
||||
yield clickButton();
|
||||
yield waitForClientEvents(gPanel, "traces");
|
||||
|
||||
/**
|
||||
* Test that there are some traces which are not blackboxed.
|
||||
*/
|
||||
const firstBbButton = getBlackBoxButton(gPanel);
|
||||
ok(!firstBbButton.checked, "Should not be black boxed by default");
|
||||
|
||||
const blackBoxedTraces =
|
||||
gPanel.panelWin.document.querySelectorAll(".trace-item.black-boxed");
|
||||
ok(blackBoxedTraces.length === 0, "There should no blackboxed traces.");
|
||||
|
||||
const notBlackBoxedTraces =
|
||||
gPanel.panelWin.document.querySelectorAll(".trace-item:not(.black-boxed)");
|
||||
ok(notBlackBoxedTraces.length > 0,
|
||||
"There should be some traces which are not blackboxed.");
|
||||
|
||||
yield toggleBlackBoxing(gPanel);
|
||||
yield clickButton();
|
||||
yield waitForClientEvents(gPanel, "traces");
|
||||
|
||||
/**
|
||||
* Test that there are some traces which are blackboxed.
|
||||
*/
|
||||
const secondBbButton = getBlackBoxButton(gPanel);
|
||||
ok(secondBbButton.checked, "The checkbox should no longer be checked.");
|
||||
const traces =
|
||||
gPanel.panelWin.document.querySelectorAll(".trace-item.black-boxed");
|
||||
ok(traces.length > 0, "There should be some blackboxed traces.");
|
||||
|
||||
yield stopTracing(gPanel);
|
||||
yield popPref();
|
||||
yield closeDebuggerAndFinish(gPanel);
|
||||
|
||||
finish();
|
||||
})().catch(e => {
|
||||
ok(false, "Got an error: " + e.message + "\n" + e.stack);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
function clickButton() {
|
||||
EventUtils.sendMouseEvent({ type: "click" },
|
||||
gDebuggee.document.querySelector("button"),
|
||||
gDebuggee);
|
||||
}
|
||||
|
||||
function pushPref() {
|
||||
let deferred = promise.defer();
|
||||
SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]},
|
||||
deferred.resolve);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function popPref() {
|
||||
let deferred = promise.defer();
|
||||
SpecialPowers.popPrefEnv(deferred.resolve);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
gTab = null;
|
||||
gDebuggee = null;
|
||||
gPanel = null;
|
||||
});
|
||||
|
@ -249,6 +249,10 @@
|
||||
color: #f5f7fa; /* Light foreground text */
|
||||
}
|
||||
|
||||
.theme-dark .trace-item.black-boxed {
|
||||
color: rgba(128,128,128,0.4);
|
||||
}
|
||||
|
||||
.theme-dark .trace-item.selected-matching {
|
||||
background-color: rgba(29,79,115,.4); /* Select highlight blue at 40% alpha */
|
||||
}
|
||||
@ -284,6 +288,10 @@
|
||||
color: #292e33; /* Dark foreground text */
|
||||
}
|
||||
|
||||
.theme-light .trace-item.black-boxed {
|
||||
color: rgba(128,128,128,0.4);
|
||||
}
|
||||
|
||||
.theme-light .trace-item.selected-matching {
|
||||
background-color: rgba(76,158,217,.4); /* Select highlight blue at 40% alpha */
|
||||
}
|
||||
|
@ -284,6 +284,12 @@ TracerActor.prototype = {
|
||||
};
|
||||
}
|
||||
|
||||
if (this._parent.threadActor && aFrame.script) {
|
||||
packet.blackBoxed = this._parent.threadActor.sources.isBlackBoxed(aFrame.script.url);
|
||||
} else {
|
||||
packet.blackBoxed = false;
|
||||
}
|
||||
|
||||
if (this._requestsForTraceType.callsite
|
||||
&& aFrame.older
|
||||
&& aFrame.older.script) {
|
||||
|
@ -175,9 +175,9 @@ function attachTestTab(aClient, aTitle, aCallback) {
|
||||
// TabClient referring to the tab, and a ThreadClient referring to the
|
||||
// thread.
|
||||
function attachTestThread(aClient, aTitle, aCallback) {
|
||||
attachTestTab(aClient, aTitle, function (aResponse, aTabClient) {
|
||||
attachTestTab(aClient, aTitle, function (aTabResponse, aTabClient) {
|
||||
function onAttach(aResponse, aThreadClient) {
|
||||
aCallback(aResponse, aTabClient, aThreadClient);
|
||||
aCallback(aResponse, aTabClient, aThreadClient, aTabResponse);
|
||||
}
|
||||
aTabClient.attachThread({
|
||||
useSourceMaps: true,
|
||||
|
167
toolkit/devtools/server/tests/unit/test_trace_actor-10.js
Normal file
167
toolkit/devtools/server/tests/unit/test_trace_actor-10.js
Normal file
@ -0,0 +1,167 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Create 2 sources, A and B, B is black boxed. When calling functions A->B->A,
|
||||
* verify that only traces from source B are black boxed.
|
||||
*/
|
||||
|
||||
var gDebuggee;
|
||||
var gClient;
|
||||
var gTraceClient;
|
||||
var gThreadClient;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
initTestTracerServer();
|
||||
gDebuggee = addTestGlobal("test-tracer-actor");
|
||||
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient.connect(function() {
|
||||
attachTestThread(gClient, "test-tracer-actor",
|
||||
function(aResponse, aTabClient, aThreadClient, aTabResponse) {
|
||||
gThreadClient = aThreadClient;
|
||||
gThreadClient.resume(function (aResponse) {
|
||||
gClient.attachTracer(aTabResponse.traceActor,
|
||||
function(aResponse, aTraceClient) {
|
||||
gTraceClient = aTraceClient;
|
||||
testTraces();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
const BLACK_BOXED_URL = "http://example.com/blackboxme.js";
|
||||
const SOURCE_URL = "http://example.com/source.js";
|
||||
|
||||
const testTraces = Task.async(function* () {
|
||||
// Read traces
|
||||
const tracesStopped = promise.defer();
|
||||
gClient.addListener("traces", (aEvent, { traces }) => {
|
||||
for (let t of traces) {
|
||||
check_trace(t);
|
||||
}
|
||||
tracesStopped.resolve();
|
||||
});
|
||||
|
||||
yield startTrace();
|
||||
|
||||
evalSetup();
|
||||
|
||||
// Blackbox source
|
||||
const sourcesResponse = yield getSources(gThreadClient);
|
||||
let sourceClient = gThreadClient.source(
|
||||
sourcesResponse.sources.filter(s => s.url == BLACK_BOXED_URL)[0]);
|
||||
do_check_true(!sourceClient.isBlackBoxed,
|
||||
"By default the source is not black boxed.");
|
||||
yield blackBox(sourceClient);
|
||||
do_check_true(sourceClient.isBlackBoxed);
|
||||
|
||||
evalTestCode();
|
||||
|
||||
yield tracesStopped.promise;
|
||||
yield stopTrace();
|
||||
|
||||
finishClient(gClient);
|
||||
});
|
||||
|
||||
function startTrace()
|
||||
{
|
||||
let deferred = promise.defer();
|
||||
gTraceClient.startTrace(["depth", "name", "location"], null,
|
||||
function() { deferred.resolve(); });
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function evalSetup()
|
||||
{
|
||||
Components.utils.evalInSandbox(
|
||||
"" + function fnBlackBoxed(k) {
|
||||
fnInner();
|
||||
},
|
||||
gDebuggee,
|
||||
"1.8",
|
||||
BLACK_BOXED_URL,
|
||||
1
|
||||
);
|
||||
|
||||
Components.utils.evalInSandbox(
|
||||
"" + function fnOuter() {
|
||||
fnBlackBoxed();
|
||||
} + "\n" +
|
||||
"" + function fnInner() {
|
||||
[1].forEach(function noop() {});
|
||||
},
|
||||
gDebuggee,
|
||||
"1.8",
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
function evalTestCode()
|
||||
{
|
||||
Components.utils.evalInSandbox(
|
||||
"fnOuter();",
|
||||
gDebuggee,
|
||||
"1.8",
|
||||
SOURCE_URL,
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
function stopTrace()
|
||||
{
|
||||
let deferred = promise.defer();
|
||||
gTraceClient.stopTrace(null, function() { deferred.resolve(); });
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function check_trace({ type, sequence, depth, name, location, blackBoxed })
|
||||
{
|
||||
switch(sequence) {
|
||||
// First two packets come from evalInSandbox in evalSetup
|
||||
// The third packet comes from evalInSandbox in evalTestCode
|
||||
case 0:
|
||||
case 2:
|
||||
case 4:
|
||||
do_check_eq(name, "(global)");
|
||||
do_check_eq(type, "enteredFrame");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
do_check_eq(blackBoxed, false);
|
||||
do_check_eq(name, "fnOuter");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
do_check_eq(blackBoxed, true);
|
||||
do_check_eq(name, "fnBlackBoxed");
|
||||
break;
|
||||
|
||||
case 7:
|
||||
do_check_eq(blackBoxed, false);
|
||||
do_check_eq(name, "fnInner");
|
||||
break;
|
||||
|
||||
case 8:
|
||||
do_check_eq(blackBoxed, false);
|
||||
do_check_eq(name, "noop");
|
||||
break;
|
||||
|
||||
case 1: // evalInSandbox
|
||||
case 3: // evalInSandbox
|
||||
case 9: // noop
|
||||
case 10: // fnInner
|
||||
case 11: // fnBlackBoxed
|
||||
case 12: // fnOuter
|
||||
case 13: // evalInSandbox
|
||||
do_check_eq(type, "exitedFrame");
|
||||
break;
|
||||
|
||||
default:
|
||||
// Should have covered all sequences.
|
||||
do_check_true(false);
|
||||
}
|
||||
}
|
@ -63,8 +63,8 @@ function TestTabActor(aConnection, aGlobal)
|
||||
this.conn = aConnection;
|
||||
this._global = aGlobal;
|
||||
this._global.wrappedJSObject = aGlobal;
|
||||
this._threadActor = new ThreadActor(this, this._global);
|
||||
this.conn.addActor(this._threadActor);
|
||||
this.threadActor = new ThreadActor(this, this._global);
|
||||
this.conn.addActor(this.threadActor);
|
||||
this._attached = false;
|
||||
this._extraActors = {};
|
||||
this.makeDebugger = makeDebugger.bind(null, {
|
||||
@ -107,7 +107,7 @@ TestTabActor.prototype = {
|
||||
onAttach: function(aRequest) {
|
||||
this._attached = true;
|
||||
|
||||
let response = { type: "tabAttached", threadActor: this._threadActor.actorID };
|
||||
let response = { type: "tabAttached", threadActor: this.threadActor.actorID };
|
||||
this._appendExtraActors(response);
|
||||
|
||||
return response;
|
||||
|
@ -196,6 +196,7 @@ reason = bug 820380
|
||||
[test_trace_actor-07.js]
|
||||
[test_trace_actor-08.js]
|
||||
[test_trace_actor-09.js]
|
||||
[test_trace_actor-10.js]
|
||||
[test_ignore_caught_exceptions.js]
|
||||
[test_requestTypes.js]
|
||||
reason = bug 937197
|
||||
|
Loading…
Reference in New Issue
Block a user