зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1255734 - DevTools: Inspecting a primitive value in console throws a TypeError. r=vporof
--HG-- extra : rebase_source : c10241573f3ca5f5ecbbb040a24f551d0a848f0d
This commit is contained in:
Родитель
967430b3e2
Коммит
65e076156d
|
@ -675,12 +675,12 @@ VariablesViewController.prototype = {
|
|||
*
|
||||
* This function will empty the variables view.
|
||||
*
|
||||
* @param object aOptions
|
||||
* @param object options
|
||||
* Options for the contents of the view:
|
||||
* - objectActor: the grip of the new ObjectActor to show.
|
||||
* - rawObject: the raw object to show.
|
||||
* - label: the label for the inspected object.
|
||||
* @param object aConfiguration
|
||||
* @param object configuration
|
||||
* Additional options for the controller:
|
||||
* - overrideValueEvalMacro: @see _setEvaluationMacros
|
||||
* - getterOrSetterEvalMacro: @see _setEvaluationMacros
|
||||
|
@ -689,24 +689,28 @@ VariablesViewController.prototype = {
|
|||
* - variable: the created Variable.
|
||||
* - expanded: the Promise that resolves when the variable expands.
|
||||
*/
|
||||
setSingleVariable: function(aOptions, aConfiguration = {}) {
|
||||
this._setEvaluationMacros(aConfiguration);
|
||||
setSingleVariable: function(options, configuration = {}) {
|
||||
this._setEvaluationMacros(configuration);
|
||||
this.view.empty();
|
||||
|
||||
let scope = this.view.addScope(aOptions.label);
|
||||
let scope = this.view.addScope(options.label);
|
||||
scope.expanded = true; // Expand the scope by default.
|
||||
scope.locked = true; // Prevent collapsing the scope.
|
||||
|
||||
let variable = scope.addItem("", { enumerable: true });
|
||||
let populated;
|
||||
|
||||
if (aOptions.objectActor) {
|
||||
if (options.objectActor) {
|
||||
// Save objectActor for properties filtering
|
||||
this.objectActor = aOptions.objectActor;
|
||||
populated = this.populate(variable, aOptions.objectActor);
|
||||
variable.expand();
|
||||
} else if (aOptions.rawObject) {
|
||||
variable.populate(aOptions.rawObject, { expanded: true });
|
||||
this.objectActor = options.objectActor;
|
||||
if (VariablesView.isPrimitive({ value: this.objectActor })) {
|
||||
populated = promise.resolve();
|
||||
} else {
|
||||
populated = this.populate(variable, options.objectActor);
|
||||
variable.expand();
|
||||
}
|
||||
} else if (options.rawObject) {
|
||||
variable.populate(options.rawObject, { expanded: true });
|
||||
populated = promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,16 +15,33 @@ add_task(function* () {
|
|||
let hud = yield openConsole();
|
||||
let jsterm = hud.jsterm;
|
||||
|
||||
/* Check that the window object is inspected */
|
||||
jsterm.execute("testProp = 'testValue'");
|
||||
|
||||
let fetched = jsterm.once("variablesview-fetched");
|
||||
let updated = jsterm.once("variablesview-updated");
|
||||
jsterm.execute("inspect(window)");
|
||||
let variable = yield fetched;
|
||||
let view = yield updated;
|
||||
ok(view, "variables view object");
|
||||
|
||||
ok(variable._variablesView, "variables view object");
|
||||
// The single variable view contains a scope with the variable name
|
||||
// and unnamed subitem that contains the properties
|
||||
let variable = view.getScopeAtIndex(0).get("");
|
||||
ok(variable, "variable object");
|
||||
|
||||
yield findVariableViewProperties(variable, [
|
||||
{ name: "testProp", value: "testValue" },
|
||||
{ name: "document", value: /HTMLDocument \u2192 data:/ },
|
||||
], { webconsole: hud });
|
||||
|
||||
/* Check that a primitive value can be inspected, too */
|
||||
let updated2 = jsterm.once("variablesview-updated");
|
||||
jsterm.execute("inspect(1)");
|
||||
let view2 = yield updated2;
|
||||
ok(view2, "variables view object");
|
||||
|
||||
// Check the label of the scope - it should contain the value
|
||||
let scope = view.getScopeAtIndex(0);
|
||||
ok(scope, "variable object");
|
||||
|
||||
is(scope.name, "1", "The value of the primitive var is correct");
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче