mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-27 18:01:44 -10:00
Backed out changeset 5db908b26d50 (bug 1494796) Backed out changeset c48f00f0df72 (bug 1494796) Backed out changeset 591453b88e8b (bug 1494796) Backed out changeset a14e820311bc (bug 1494796) Backed out changeset 0e214d450b35 (bug 1494796) Backed out changeset 1a4ab8b35a85 (bug 1494796) Backed out changeset fe1559f5f1d4 (bug 1494796) Backed out changeset 35d967de4223 (bug 1494796) Backed out changeset 1d21a55cae15 (bug 1494796) Backed out changeset 33eec873a43e (bug 1494796) Backed out changeset 25e69c21dc2e (bug 1494796) Backed out changeset b900d41c8ae8 (bug 1494796) Backed out changeset c2a034e34fa6 (bug 1494796)
93 lines
2.4 KiB
JavaScript
93 lines
2.4 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
const { sourceSpec } = require("devtools/shared/specs/source");
|
|
const { FrontClassWithSpec, registerFront } = require("devtools/shared/protocol");
|
|
const { ArrayBufferFront } = require("devtools/shared/fronts/array-buffer");
|
|
|
|
/**
|
|
* A SourceFront provides a way to access the source text of a script.
|
|
*
|
|
* @param client DebuggerClient
|
|
* The Debugger Client instance.
|
|
* @param form Object
|
|
* The form sent across the remote debugging protocol.
|
|
*/
|
|
class SourceFront extends FrontClassWithSpec(sourceSpec) {
|
|
constructor(client, form) {
|
|
super(client);
|
|
this._url = form.url;
|
|
// this is here for the time being, until the source front is managed
|
|
// via protocol.js marshalling
|
|
this.actorID = form.actor;
|
|
this.manage(this);
|
|
}
|
|
|
|
get actor() {
|
|
return this.actorID;
|
|
}
|
|
|
|
get url() {
|
|
return this._url;
|
|
}
|
|
|
|
// Alias for source.blackbox to avoid changing protocol.js packets
|
|
blackBox(range) {
|
|
return this.blackbox(range);
|
|
}
|
|
|
|
// Alias for source.unblackbox to avoid changing protocol.js packets
|
|
unblackBox() {
|
|
return this.unblackbox();
|
|
}
|
|
|
|
/**
|
|
* Get a Front for either an ArrayBuffer or LongString
|
|
* for this SourceFront's source.
|
|
*/
|
|
async source() {
|
|
const response = await this.onSource();
|
|
return this._onSourceResponse(response);
|
|
}
|
|
|
|
_onSourceResponse(response) {
|
|
const { contentType, source } = response;
|
|
if (source instanceof ArrayBufferFront) {
|
|
return source.slice(0, source.length).then(function(resp) {
|
|
if (resp.error) {
|
|
return resp;
|
|
}
|
|
// Keeping str as a string, ArrayBuffer/Uint8Array will not survive
|
|
// setIn/mergeIn operations.
|
|
const str = atob(resp.encoded);
|
|
const newResponse = {
|
|
source: {
|
|
binary: str,
|
|
toString: () => "[wasm]",
|
|
},
|
|
contentType,
|
|
};
|
|
return newResponse;
|
|
});
|
|
}
|
|
|
|
return source.substring(0, source.length).then(function(resp) {
|
|
if (resp.error) {
|
|
return resp;
|
|
}
|
|
|
|
const newResponse = {
|
|
source: resp,
|
|
contentType: contentType,
|
|
};
|
|
return newResponse;
|
|
});
|
|
}
|
|
}
|
|
|
|
exports.SourceFront = SourceFront;
|
|
registerFront(SourceFront);
|