mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 982597 - Remove backwards compatibility for the "sources" packet. r=fitzgen
This commit is contained in:
parent
bfd07a820b
commit
a55f0158dd
@ -246,9 +246,7 @@ this.DebuggerClient = function (aTransport)
|
||||
this._activeRequests = new Map;
|
||||
this._eventsEnabled = true;
|
||||
|
||||
this.compat = new ProtocolCompatibility(this, [
|
||||
new SourcesShim(),
|
||||
]);
|
||||
this.compat = new ProtocolCompatibility(this, []);
|
||||
this.traits = {};
|
||||
|
||||
this.request = this.request.bind(this);
|
||||
@ -932,41 +930,6 @@ const FeatureCompatibilityShim = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A shim to support the "sources" and "newSource" packets for older servers
|
||||
* which don't support them.
|
||||
*/
|
||||
function SourcesShim() {
|
||||
this._sourcesSeen = new Set();
|
||||
}
|
||||
|
||||
SourcesShim.prototype = Object.create(FeatureCompatibilityShim);
|
||||
let SSProto = SourcesShim.prototype;
|
||||
|
||||
SSProto.name = "sources";
|
||||
|
||||
SSProto.onPacketTest = function (aPacket) {
|
||||
if (aPacket.traits) {
|
||||
return aPacket.traits.sources
|
||||
? SUPPORTED
|
||||
: NOT_SUPPORTED;
|
||||
}
|
||||
return SKIP;
|
||||
};
|
||||
|
||||
SSProto.translatePacket = function (aPacket, aReplacePacket, aExtraPacket,
|
||||
aKeepPacket) {
|
||||
if (aPacket.type !== "newScript" || this._sourcesSeen.has(aPacket.url)) {
|
||||
return aKeepPacket();
|
||||
}
|
||||
this._sourcesSeen.add(aPacket.url);
|
||||
return aExtraPacket({
|
||||
from: aPacket.from,
|
||||
type: "newSource",
|
||||
source: aPacket.source
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a tab client for the remote debugging protocol server. This client
|
||||
* is a front to the tab actor created in the server side, hiding the protocol
|
||||
@ -1526,52 +1489,11 @@ ThreadClient.prototype = {
|
||||
* @param aOnResponse Function
|
||||
* Called with the thread's response.
|
||||
*/
|
||||
getSources: function (aOnResponse) {
|
||||
// This is how we should get sources if the server supports "sources"
|
||||
// requests.
|
||||
let getSources = DebuggerClient.requester({
|
||||
type: "sources"
|
||||
}, {
|
||||
telemetry: "SOURCES"
|
||||
});
|
||||
|
||||
// This is how we should deduct what sources exist from the existing scripts
|
||||
// when the server does not support "sources" requests.
|
||||
let getSourcesBackwardsCompat = DebuggerClient.requester({
|
||||
type: "scripts"
|
||||
}, {
|
||||
after: function (aResponse) {
|
||||
if (aResponse.error) {
|
||||
return aResponse;
|
||||
}
|
||||
|
||||
let sourceActorsByURL = aResponse.scripts
|
||||
.reduce(function (aSourceActorsByURL, aScript) {
|
||||
aSourceActorsByURL[aScript.url] = aScript.source;
|
||||
return aSourceActorsByURL;
|
||||
}, {});
|
||||
|
||||
return {
|
||||
sources: [
|
||||
{ url: url, actor: sourceActorsByURL[url] }
|
||||
for (url of Object.keys(sourceActorsByURL))
|
||||
]
|
||||
}
|
||||
},
|
||||
telemetry: "SOURCES"
|
||||
});
|
||||
|
||||
// On the first time `getSources` is called, patch the thread client with
|
||||
// the best method for the server's capabilities.
|
||||
let threadClient = this;
|
||||
this.compat.supportsFeature("sources").then(function () {
|
||||
threadClient.getSources = getSources;
|
||||
}, function () {
|
||||
threadClient.getSources = getSourcesBackwardsCompat;
|
||||
}).then(function () {
|
||||
threadClient.getSources(aOnResponse);
|
||||
});
|
||||
},
|
||||
getSources: DebuggerClient.requester({
|
||||
type: "sources"
|
||||
}, {
|
||||
telemetry: "SOURCES"
|
||||
}),
|
||||
|
||||
_doInterrupted: function (aAction, aError) {
|
||||
if (this.paused) {
|
||||
|
@ -195,15 +195,6 @@ function initTestTracerServer()
|
||||
DebuggerServer.init(function () { return true; });
|
||||
}
|
||||
|
||||
function initSourcesBackwardsCompatDebuggerServer()
|
||||
{
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/root.js");
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/webbrowser.js");
|
||||
DebuggerServer.addActors("resource://gre/modules/devtools/server/actors/script.js");
|
||||
DebuggerServer.addActors("resource://test/testcompatactors.js");
|
||||
DebuggerServer.init(function () { return true; });
|
||||
}
|
||||
|
||||
function finishClient(aClient)
|
||||
{
|
||||
aClient.close(function() {
|
||||
|
@ -44,9 +44,6 @@ function test_source()
|
||||
gThreadClient.getSources(function (aResponse) {
|
||||
do_check_true(!!aResponse);
|
||||
do_check_true(!!aResponse.sources);
|
||||
gClient.compat.supportsFeature("sources").then(function (supported) {
|
||||
do_check_true(supported);
|
||||
});
|
||||
|
||||
let source = aResponse.sources.filter(function (s) {
|
||||
return s.url === SOURCE_URL;
|
||||
|
@ -1,77 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Check that "sources" and "newSource" packets are handled in a backwards
|
||||
* compatible way.
|
||||
*/
|
||||
|
||||
var gDebuggee;
|
||||
var gClient;
|
||||
var gTabClient;
|
||||
var gThreadClient;
|
||||
|
||||
var gNumTimesSourcesSent = 0;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
initSourcesBackwardsCompatDebuggerServer();
|
||||
gDebuggee = addTestGlobal("test-sources-compat");
|
||||
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient.request = (function (request) {
|
||||
return function (aRequest, aOnResponse) {
|
||||
if (aRequest.type === "sources") {
|
||||
++gNumTimesSourcesSent;
|
||||
}
|
||||
return request.call(this, aRequest, aOnResponse);
|
||||
};
|
||||
}(gClient.request));
|
||||
gClient.connect(function() {
|
||||
attachTestTabAndResume(gClient, "test-sources-compat", function (aResponse,
|
||||
aTabClient,
|
||||
aThreadClient) {
|
||||
gTabClient = aTabClient;
|
||||
gThreadClient = aThreadClient;
|
||||
test_new_source_compatibility();
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function test_new_source_compatibility()
|
||||
{
|
||||
gClient.addOneTimeListener("newSource", function (aEvent, aPacket) {
|
||||
do_check_eq(aEvent, "newSource");
|
||||
do_check_eq(aPacket.type, "newSource");
|
||||
do_check_true(!!aPacket.source);
|
||||
do_check_true(
|
||||
!!aPacket.source.url.match(/test_sources_backwards_compat-01.js$/));
|
||||
|
||||
gClient.compat.supportsFeature("sources").then(function () {
|
||||
do_check_true(
|
||||
false,
|
||||
"The server shouldn't support sources since we mocked it not to.");
|
||||
}, test_sources_compatibility);
|
||||
});
|
||||
|
||||
gDebuggee.eval(function inc(n) {
|
||||
return n+1;
|
||||
}.toString());
|
||||
}
|
||||
|
||||
function test_sources_compatibility()
|
||||
{
|
||||
gThreadClient.getSources(function (aResponse) {
|
||||
do_check_true(!aResponse.error);
|
||||
|
||||
do_check_true(aResponse.sources.some(function (s) {
|
||||
return s.url.match(/test_sources_backwards_compat-01.js$/);
|
||||
}));
|
||||
|
||||
do_check_true(gNumTimesSourcesSent <= 1,
|
||||
"Should only send one sources request at most, even though we"
|
||||
+ " might have had to send one to determine feature support.");
|
||||
|
||||
finishClient(gClient);
|
||||
});
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/**
|
||||
* Check getting sources before there are any, in backwards compatibility mode.
|
||||
*/
|
||||
|
||||
var gDebuggee;
|
||||
var gClient;
|
||||
var gTabClient;
|
||||
var gThreadClient;
|
||||
|
||||
var gNumTimesSourcesSent = 0;
|
||||
|
||||
function run_test()
|
||||
{
|
||||
initSourcesBackwardsCompatDebuggerServer();
|
||||
gDebuggee = addTestGlobal("test-sources-compat");
|
||||
gClient = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
gClient.request = (function (request) {
|
||||
return function (aRequest, aOnResponse) {
|
||||
if (aRequest.type === "sources") {
|
||||
++gNumTimesSourcesSent;
|
||||
}
|
||||
return request.call(this, aRequest, aOnResponse);
|
||||
};
|
||||
}(gClient.request));
|
||||
gClient.connect(function() {
|
||||
attachTestTabAndResume(gClient, "test-sources-compat", function (aResponse,
|
||||
aTabClient,
|
||||
aThreadClient) {
|
||||
gTabClient = aTabClient;
|
||||
gThreadClient = aThreadClient;
|
||||
test_listing_zero_sources_compat();
|
||||
});
|
||||
});
|
||||
do_test_pending();
|
||||
}
|
||||
|
||||
function test_listing_zero_sources_compat()
|
||||
{
|
||||
gThreadClient.getSources(function (aPacket) {
|
||||
do_check_true(!aPacket.error);
|
||||
do_check_true(!!aPacket.sources);
|
||||
do_check_eq(aPacket.sources.length, 0);
|
||||
do_check_true(gNumTimesSourcesSent <= 1,
|
||||
"Should only send one sources request, even though we might "
|
||||
+ "have had to send one to determine feature support.");
|
||||
finishClient(gClient);
|
||||
});
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
var gTestGlobals = [];
|
||||
|
||||
function createRootActor()
|
||||
{
|
||||
let actor = {
|
||||
sayHello: function() {
|
||||
this._tabActors = [];
|
||||
for each (let g in gTestGlobals) {
|
||||
let actor = new BrowserTabActor(this.conn);
|
||||
actor.thread = new ThreadActor({}, g);
|
||||
|
||||
actor.json = function() {
|
||||
return { actor: actor.actorID,
|
||||
url: "http://www.example.com/",
|
||||
title: actor.thread.global.__name };
|
||||
};
|
||||
|
||||
actor.requestTypes["attach"] = function (aRequest) {
|
||||
dump("actor.thread.actorID = " + actor.thread.actorID + "\n");
|
||||
return {
|
||||
from: actor.actorID,
|
||||
type: "tabAttached",
|
||||
threadActor: actor.thread.actorID
|
||||
};
|
||||
};
|
||||
|
||||
actor.thread.requestTypes["scripts"] = function (aRequest) {
|
||||
return this._discoverSources().then(function () {
|
||||
let scripts = [];
|
||||
for (let s of this.dbg.findScripts()) {
|
||||
if (!s.url) {
|
||||
continue;
|
||||
}
|
||||
let script = {
|
||||
url: s.url,
|
||||
startLine: s.startLine,
|
||||
lineCount: s.lineCount,
|
||||
source: this.sources.source({ url: s.url }).form()
|
||||
};
|
||||
scripts.push(script);
|
||||
}
|
||||
|
||||
return {
|
||||
from: this.actorID,
|
||||
scripts: scripts
|
||||
};
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
// Pretend that we do not know about the "sources" packet to force the
|
||||
// client to go into its backwards compatibility mode.
|
||||
actor.thread.requestTypes["sources"] = function () {
|
||||
return {
|
||||
error: "unrecognizedPacketType"
|
||||
};
|
||||
};
|
||||
|
||||
let { conn } = this;
|
||||
actor.thread.onNewScript = (function (oldOnNewScript) {
|
||||
return function (aScript) {
|
||||
oldOnNewScript.call(this, aScript);
|
||||
conn.send({
|
||||
from: actor.thread.actorID,
|
||||
type: "newScript",
|
||||
url: aScript.url,
|
||||
startLine: aScript.startLine,
|
||||
lineCount: aScript.lineCount,
|
||||
source: actor.thread.sources.source({ url: aScript.url }).form()
|
||||
});
|
||||
};
|
||||
}(actor.thread.onNewScript));
|
||||
|
||||
this.conn.addActor(actor);
|
||||
this.conn.addActor(actor.thread);
|
||||
this._tabActors.push(actor);
|
||||
}
|
||||
|
||||
this.conn.send = (function (aOldSend) {
|
||||
return function (aPacket) {
|
||||
if (aPacket.type === "newSource") {
|
||||
// Don't send newSource Packets b/c we are an old version of the
|
||||
// RDP!
|
||||
return undefined;
|
||||
} else {
|
||||
return aOldSend.call(this, aPacket);
|
||||
}
|
||||
};
|
||||
}(this.conn.send));
|
||||
|
||||
return { from: "root",
|
||||
applicationType: "xpcshell-tests",
|
||||
traits: {} };
|
||||
},
|
||||
|
||||
listTabs: function(aRequest) {
|
||||
return {
|
||||
from: "root",
|
||||
selected: 0,
|
||||
tabs: [ actor.json() for (actor of this._tabActors) ]
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
actor.requestTypes = {
|
||||
"listTabs": actor.listTabs,
|
||||
"echo": function(aRequest) { return aRequest; },
|
||||
};
|
||||
return actor;
|
||||
}
|
||||
|
||||
DebuggerServer.addTestGlobal = function addTestGlobal(aGlobal)
|
||||
{
|
||||
aGlobal.wrappedJSObject = aGlobal;
|
||||
gTestGlobals.push(aGlobal);
|
||||
}
|
@ -13,7 +13,6 @@ support-files =
|
||||
registertestactors-02.js
|
||||
sourcemapped.js
|
||||
testactors.js
|
||||
testcompatactors.js
|
||||
tracerlocations.js
|
||||
|
||||
[test_nesting-01.js]
|
||||
@ -119,8 +118,6 @@ run-if = toolkit == "gonk"
|
||||
[test_listsources-02.js]
|
||||
[test_listsources-03.js]
|
||||
[test_new_source-01.js]
|
||||
[test_sources_backwards_compat-01.js]
|
||||
[test_sources_backwards_compat-02.js]
|
||||
[test_sourcemaps-01.js]
|
||||
[test_sourcemaps-02.js]
|
||||
[test_sourcemaps-03.js]
|
||||
|
Loading…
Reference in New Issue
Block a user