2012-02-07 09:22:30 -08:00
|
|
|
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-04-08 22:15:47 -07:00
|
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2012-02-07 09:22:30 -08:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Mozilla Foundation
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2011
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Victor Porof <vporof@mozilla.com> (original author)
|
2012-03-05 09:56:13 -08:00
|
|
|
* Mihai Sucan <mihai.sucan@gmail.com>
|
2012-02-07 09:22:30 -08:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
2012-04-08 22:15:47 -07:00
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
2012-02-07 09:22:30 -08:00
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2012-02-07 09:22:30 -08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object mediating visual changes and event listeners between the debugger and
|
|
|
|
* the html view.
|
|
|
|
*/
|
|
|
|
let DebuggerView = {
|
|
|
|
|
|
|
|
/**
|
2012-04-08 22:15:47 -07:00
|
|
|
* An instance of SourceEditor.
|
|
|
|
*/
|
|
|
|
editor: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the SourceEditor instance.
|
|
|
|
*/
|
|
|
|
initializeEditor: function DV_initializeEditor() {
|
|
|
|
let placeholder = document.getElementById("editor");
|
|
|
|
|
|
|
|
let config = {
|
|
|
|
mode: SourceEditor.MODES.JAVASCRIPT,
|
|
|
|
showLineNumbers: true,
|
|
|
|
readOnly: true,
|
|
|
|
showAnnotationRuler: true,
|
|
|
|
showOverviewRuler: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.editor = new SourceEditor();
|
|
|
|
this.editor.init(placeholder, config, this._onEditorLoad.bind(this));
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the SourceEditor instance and added breakpoints.
|
|
|
|
*/
|
|
|
|
destroyEditor: function DV_destroyEditor() {
|
|
|
|
DebuggerController.Breakpoints.destroy();
|
|
|
|
this.editor = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The load event handler for the source editor. This method does post-load
|
|
|
|
* editor initialization.
|
|
|
|
*/
|
|
|
|
_onEditorLoad: function DV__onEditorLoad() {
|
|
|
|
DebuggerController.Breakpoints.initialize();
|
2012-05-03 10:36:40 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the close button hidden or visible. It's hidden by default.
|
|
|
|
* @param boolean aVisibleFlag
|
|
|
|
*/
|
|
|
|
showCloseButton: function DV_showCloseButton(aVisibleFlag) {
|
|
|
|
document.getElementById("close").setAttribute("hidden", !aVisibleFlag);
|
2012-04-08 22:15:47 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions handling the scripts UI.
|
|
|
|
*/
|
|
|
|
function ScriptsView() {
|
|
|
|
this._onScriptsChange = this._onScriptsChange.bind(this);
|
2012-04-19 03:44:33 -07:00
|
|
|
this._onScriptsSearch = this._onScriptsSearch.bind(this);
|
2012-04-08 22:15:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
ScriptsView.prototype = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all elements from the scripts container, leaving it empty.
|
|
|
|
*/
|
|
|
|
empty: function DVS_empty() {
|
|
|
|
while (this._scripts.firstChild) {
|
|
|
|
this._scripts.removeChild(this._scripts.firstChild);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-19 03:44:33 -07:00
|
|
|
/**
|
|
|
|
* Removes the input in the searchbox and unhides all the scripts.
|
|
|
|
*/
|
|
|
|
clearSearch: function DVS_clearSearch() {
|
|
|
|
this._searchbox.value = "";
|
|
|
|
this._onScriptsSearch({});
|
|
|
|
},
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
/**
|
|
|
|
* Checks whether the script with the specified URL is among the scripts
|
|
|
|
* known to the debugger and shown in the list.
|
2012-02-07 09:22:30 -08:00
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param string aUrl
|
|
|
|
* The script URL.
|
|
|
|
* @return boolean
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
contains: function DVS_contains(aUrl) {
|
2012-04-17 11:16:57 -07:00
|
|
|
if (this._tmpScripts.some(function(element) {
|
|
|
|
return element.script.url == aUrl;
|
|
|
|
})) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-08 22:15:47 -07:00
|
|
|
if (this._scripts.getElementsByAttribute("value", aUrl).length > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-04-08 22:15:47 -07:00
|
|
|
* Checks whether the script with the specified label is among the scripts
|
|
|
|
* known to the debugger and shown in the list.
|
2012-02-07 09:22:30 -08:00
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param string aLabel
|
|
|
|
* The script label.
|
|
|
|
* @return boolean
|
|
|
|
*/
|
|
|
|
containsLabel: function DVS_containsLabel(aLabel) {
|
2012-04-17 11:16:57 -07:00
|
|
|
if (this._tmpScripts.some(function(element) {
|
|
|
|
return element.label == aLabel;
|
|
|
|
})) {
|
|
|
|
return true;
|
|
|
|
}
|
2012-04-08 22:15:47 -07:00
|
|
|
if (this._scripts.getElementsByAttribute("label", aLabel).length > 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Selects the script with the specified URL from the list.
|
|
|
|
*
|
|
|
|
* @param string aUrl
|
|
|
|
* The script URL.
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
selectScript: function DVS_selectScript(aUrl) {
|
|
|
|
for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
|
|
|
|
if (this._scripts.getItemAtIndex(i).value == aUrl) {
|
|
|
|
this._scripts.selectedIndex = i;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the script with the specified URL is selected in the list.
|
|
|
|
*
|
|
|
|
* @param string aUrl
|
|
|
|
* The script URL.
|
|
|
|
*/
|
|
|
|
isSelected: function DVS_isSelected(aUrl) {
|
|
|
|
if (this._scripts.selectedItem &&
|
|
|
|
this._scripts.selectedItem.value == aUrl) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the URL of the selected script.
|
|
|
|
* @return string | null
|
|
|
|
*/
|
|
|
|
get selected() {
|
|
|
|
return this._scripts.selectedItem ?
|
|
|
|
this._scripts.selectedItem.value : null;
|
|
|
|
},
|
|
|
|
|
2012-04-17 11:16:57 -07:00
|
|
|
/**
|
|
|
|
* Returns the list of labels in the scripts container.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
get scriptLabels() {
|
|
|
|
let labels = [];
|
|
|
|
for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
|
|
|
|
labels.push(this._scripts.getItemAtIndex(i).label);
|
|
|
|
}
|
|
|
|
return labels;
|
|
|
|
},
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
/**
|
|
|
|
* Returns the list of URIs for scripts in the page.
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
get scriptLocations() {
|
|
|
|
let locations = [];
|
|
|
|
for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
|
|
|
|
locations.push(this._scripts.getItemAtIndex(i).value);
|
|
|
|
}
|
|
|
|
return locations;
|
|
|
|
},
|
|
|
|
|
2012-04-19 03:44:33 -07:00
|
|
|
/**
|
|
|
|
* Gets the number of visible (hidden=false) scripts in the container.
|
|
|
|
* @return number
|
|
|
|
*/
|
|
|
|
get visibleItemsCount() {
|
|
|
|
let count = 0;
|
|
|
|
for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
|
|
|
|
count += this._scripts.getItemAtIndex(i).hidden ? 0 : 1;
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
},
|
|
|
|
|
2012-04-19 03:44:33 -07:00
|
|
|
/**
|
2012-04-17 11:16:57 -07:00
|
|
|
* Prepares a script to be added to the scripts container. This allows
|
|
|
|
* for a large number of scripts to be batched up before being
|
|
|
|
* alphabetically sorted and added in the container.
|
|
|
|
* @see ScriptsView.commitScripts
|
|
|
|
*
|
|
|
|
* If aForceFlag is true, the script will be immediately inserted at the
|
|
|
|
* necessary position in the container so that all the scripts remain sorted.
|
|
|
|
* This can be much slower than batching up multiple scripts.
|
2012-04-17 11:16:57 -07:00
|
|
|
*
|
|
|
|
* @param string aLabel
|
|
|
|
* The simplified script location to be shown.
|
|
|
|
* @param string aScript
|
|
|
|
* The source script.
|
2012-04-17 11:16:57 -07:00
|
|
|
* @param boolean aForceFlag
|
|
|
|
* True to force the script to be immediately added.
|
2012-04-17 11:16:57 -07:00
|
|
|
*/
|
2012-04-17 11:16:57 -07:00
|
|
|
addScript: function DVS_addScript(aLabel, aScript, aForceFlag) {
|
|
|
|
// Batch the script to be added later.
|
|
|
|
if (!aForceFlag) {
|
|
|
|
this._tmpScripts.push({ label: aLabel, script: aScript });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the target position in the menulist and insert the script there.
|
|
|
|
for (let i = 0, l = this._scripts.itemCount; i < l; i++) {
|
|
|
|
if (this._scripts.getItemAtIndex(i).label > aLabel) {
|
|
|
|
this._createScriptElement(aLabel, aScript, i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// The script is alphabetically the last one.
|
|
|
|
this._createScriptElement(aLabel, aScript, -1, true);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds all the prepared scripts to the scripts container.
|
|
|
|
* If a script already exists (was previously added), nothing happens.
|
|
|
|
*/
|
|
|
|
commitScripts: function DVS_commitScripts() {
|
|
|
|
let newScripts = this._tmpScripts;
|
|
|
|
this._tmpScripts = [];
|
|
|
|
|
|
|
|
if (!newScripts || !newScripts.length) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
newScripts.sort(function(a, b) {
|
|
|
|
return a.label.toLowerCase() > b.label.toLowerCase();
|
|
|
|
});
|
|
|
|
|
|
|
|
for (let i = 0, l = newScripts.length; i < l; i++) {
|
|
|
|
let item = newScripts[i];
|
|
|
|
this._createScriptElement(item.label, item.script, -1, true);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a custom script element and adds it to the scripts container.
|
|
|
|
* If the script with the specified label already exists, nothing happens.
|
|
|
|
*
|
|
|
|
* @param string aLabel
|
|
|
|
* The simplified script location to be shown.
|
|
|
|
* @param string aScript
|
|
|
|
* The source script.
|
|
|
|
* @param number aIndex
|
|
|
|
* The index where to insert to new script in the container.
|
|
|
|
* Pass -1 to append the script at the end.
|
|
|
|
* @param boolean aSelectIfEmptyFlag
|
|
|
|
* True to set the newly created script as the currently selected item
|
|
|
|
* if there are no other existing scripts in the container.
|
|
|
|
*/
|
|
|
|
_createScriptElement: function DVS__createScriptElement(
|
|
|
|
aLabel, aScript, aIndex, aSelectIfEmptyFlag)
|
|
|
|
{
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure we don't duplicate anything.
|
2012-04-17 11:16:57 -07:00
|
|
|
if (aLabel == "null" || this.containsLabel(aLabel)) {
|
|
|
|
return;
|
2012-04-08 22:15:47 -07:00
|
|
|
}
|
|
|
|
|
2012-04-17 11:16:57 -07:00
|
|
|
let scriptItem =
|
|
|
|
aIndex == -1 ? this._scripts.appendItem(aLabel, aScript.url)
|
|
|
|
: this._scripts.insertItemAt(aIndex, aLabel, aScript.url);
|
2012-04-17 11:16:57 -07:00
|
|
|
|
2012-04-17 11:16:57 -07:00
|
|
|
scriptItem.setAttribute("tooltiptext", aScript.url);
|
|
|
|
scriptItem.setUserData("sourceScript", aScript, null);
|
|
|
|
|
|
|
|
if (this._scripts.itemCount == 1 && aSelectIfEmptyFlag) {
|
|
|
|
this._scripts.selectedItem = scriptItem;
|
|
|
|
}
|
2012-04-08 22:15:47 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-04-19 03:44:33 -07:00
|
|
|
* The click listener for the scripts container.
|
2012-04-08 22:15:47 -07:00
|
|
|
*/
|
|
|
|
_onScriptsChange: function DVS__onScriptsChange() {
|
|
|
|
let script = this._scripts.selectedItem.getUserData("sourceScript");
|
2012-04-19 03:44:33 -07:00
|
|
|
this._preferredScript = script;
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.SourceScripts.showScript(script);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-04-19 03:44:33 -07:00
|
|
|
* The search listener for the scripts search box.
|
|
|
|
*/
|
|
|
|
_onScriptsSearch: function DVS__onScriptsSearch(e) {
|
|
|
|
let editor = DebuggerView.editor;
|
|
|
|
let scripts = this._scripts;
|
|
|
|
let rawValue = this._searchbox.value.toLowerCase();
|
|
|
|
|
|
|
|
let rawLength = rawValue.length;
|
|
|
|
let lastColon = rawValue.lastIndexOf(":");
|
|
|
|
let lastAt = rawValue.lastIndexOf("@");
|
|
|
|
|
|
|
|
let fileEnd = lastColon != -1 ? lastColon : lastAt != -1 ? lastAt : rawLength;
|
|
|
|
let lineEnd = lastAt != -1 ? lastAt : rawLength;
|
|
|
|
|
|
|
|
let file = rawValue.slice(0, fileEnd);
|
|
|
|
let line = window.parseInt(rawValue.slice(fileEnd + 1, lineEnd)) || -1;
|
|
|
|
let token = rawValue.slice(lineEnd + 1);
|
|
|
|
|
|
|
|
// Presume we won't find anything.
|
|
|
|
scripts.selectedItem = this._preferredScript;
|
|
|
|
|
|
|
|
// If we're not searching for a file anymore, unhide all the scripts.
|
|
|
|
if (!file) {
|
|
|
|
for (let i = 0, l = scripts.itemCount; i < l; i++) {
|
|
|
|
scripts.getItemAtIndex(i).hidden = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (let i = 0, l = scripts.itemCount, found = false; i < l; i++) {
|
|
|
|
let item = scripts.getItemAtIndex(i);
|
|
|
|
let target = item.value.toLowerCase();
|
|
|
|
|
|
|
|
// Search is not case sensitive, and is tied to the url not the label.
|
|
|
|
if (target.match(file)) {
|
|
|
|
item.hidden = false;
|
|
|
|
|
|
|
|
if (!found) {
|
|
|
|
found = true;
|
|
|
|
scripts.selectedItem = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Hide what doesn't match our search.
|
|
|
|
else {
|
|
|
|
item.hidden = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (line > -1) {
|
|
|
|
editor.setCaretPosition(line - 1);
|
|
|
|
}
|
|
|
|
if (token) {
|
|
|
|
let offset = editor.find(token, { ignoreCase: true });
|
|
|
|
if (offset > -1) {
|
|
|
|
editor.setCaretPosition(0);
|
|
|
|
editor.setCaretOffset(offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The keyup listener for the scripts search box.
|
|
|
|
*/
|
|
|
|
_onScriptsKeyUp: function DVS__onScriptsKeyUp(e) {
|
|
|
|
if (e.keyCode === e.DOM_VK_ESCAPE) {
|
|
|
|
DebuggerView.editor.focus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (e.keyCode === e.DOM_VK_RETURN || e.keyCode === e.DOM_VK_ENTER) {
|
|
|
|
let editor = DebuggerView.editor;
|
|
|
|
let offset = editor.findNext(true);
|
|
|
|
if (offset > -1) {
|
|
|
|
editor.setCaretPosition(0);
|
|
|
|
editor.setCaretOffset(offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The cached scripts container and search box.
|
2012-04-08 22:15:47 -07:00
|
|
|
*/
|
|
|
|
_scripts: null,
|
2012-04-19 03:44:33 -07:00
|
|
|
_searchbox: null,
|
2012-04-08 22:15:47 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is initialized.
|
|
|
|
*/
|
|
|
|
initialize: function DVS_initialize() {
|
|
|
|
this._scripts = document.getElementById("scripts");
|
2012-04-19 03:44:33 -07:00
|
|
|
this._searchbox = document.getElementById("scripts-search");
|
2012-04-08 22:15:47 -07:00
|
|
|
this._scripts.addEventListener("select", this._onScriptsChange, false);
|
2012-04-19 03:44:33 -07:00
|
|
|
this._searchbox.addEventListener("select", this._onScriptsSearch, false);
|
|
|
|
this._searchbox.addEventListener("input", this._onScriptsSearch, false);
|
|
|
|
this._searchbox.addEventListener("keyup", this._onScriptsKeyUp, false);
|
2012-04-17 11:16:57 -07:00
|
|
|
this.commitScripts();
|
2012-04-08 22:15:47 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is shut down.
|
|
|
|
*/
|
|
|
|
destroy: function DVS_destroy() {
|
|
|
|
this._scripts.removeEventListener("select", this._onScriptsChange, false);
|
2012-04-19 03:44:33 -07:00
|
|
|
this._searchbox.removeEventListener("select", this._onScriptsSearch, false);
|
|
|
|
this._searchbox.removeEventListener("input", this._onScriptsSearch, false);
|
|
|
|
this._searchbox.removeEventListener("keyup", this._onScriptsKeyUp, false);
|
2012-04-08 22:15:47 -07:00
|
|
|
this._scripts = null;
|
2012-04-19 03:44:33 -07:00
|
|
|
this._searchbox = null;
|
2012-02-07 09:22:30 -08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions handling the html stackframes UI.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
function StackFramesView() {
|
|
|
|
this._onFramesScroll = this._onFramesScroll.bind(this);
|
|
|
|
this._onCloseButtonClick = this._onCloseButtonClick.bind(this);
|
|
|
|
this._onResumeButtonClick = this._onResumeButtonClick.bind(this);
|
|
|
|
this._onStepOverClick = this._onStepOverClick.bind(this);
|
|
|
|
this._onStepInClick = this._onStepInClick.bind(this);
|
|
|
|
this._onStepOutClick = this._onStepOutClick.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
StackFramesView.prototype = {
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the current frames state based on the debugger active thread state.
|
|
|
|
*
|
|
|
|
* @param string aState
|
|
|
|
* Either "paused" or "attached".
|
|
|
|
*/
|
|
|
|
updateState: function DVF_updateState(aState) {
|
|
|
|
let resume = document.getElementById("resume");
|
|
|
|
let status = document.getElementById("status");
|
|
|
|
|
2012-02-09 23:46:10 -08:00
|
|
|
// If we're paused, show a pause label and a resume label on the button.
|
2012-04-08 22:15:47 -07:00
|
|
|
if (aState == "paused") {
|
|
|
|
status.textContent = L10N.getStr("pausedState");
|
|
|
|
resume.label = L10N.getStr("resumeLabel");
|
|
|
|
}
|
|
|
|
// If we're attached, do the opposite.
|
|
|
|
else if (aState == "attached") {
|
|
|
|
status.textContent = L10N.getStr("runningState");
|
|
|
|
resume.label = L10N.getStr("pauseLabel");
|
|
|
|
}
|
|
|
|
// No valid state parameter.
|
|
|
|
else {
|
2012-02-07 09:22:30 -08:00
|
|
|
status.textContent = "";
|
|
|
|
}
|
2012-04-19 03:44:33 -07:00
|
|
|
|
|
|
|
DebuggerView.Scripts.clearSearch();
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all elements from the stackframes container, leaving it empty.
|
|
|
|
*/
|
|
|
|
empty: function DVF_empty() {
|
|
|
|
while (this._frames.firstChild) {
|
|
|
|
this._frames.removeChild(this._frames.firstChild);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all elements from the stackframes container, and adds a child node
|
|
|
|
* with an empty text note attached.
|
|
|
|
*/
|
|
|
|
emptyText: function DVF_emptyText() {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the container is empty first.
|
2012-02-07 09:22:30 -08:00
|
|
|
this.empty();
|
|
|
|
|
|
|
|
let item = document.createElement("div");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The empty node should look grayed out to avoid confusion.
|
2012-02-07 09:22:30 -08:00
|
|
|
item.className = "empty list-item";
|
2012-04-23 06:47:00 -07:00
|
|
|
item.appendChild(document.createTextNode(L10N.getStr("emptyStackText")));
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
this._frames.appendChild(item);
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a frame to the stackframes container.
|
|
|
|
* If the frame already exists (was previously added), null is returned.
|
|
|
|
* Otherwise, the newly created element is returned.
|
|
|
|
*
|
|
|
|
* @param number aDepth
|
|
|
|
* The frame depth specified by the debugger.
|
|
|
|
* @param string aFrameNameText
|
|
|
|
* The name to be displayed in the list.
|
2012-02-25 01:04:07 -08:00
|
|
|
* @param string aFrameDetailsText
|
|
|
|
* The details to be displayed in the list.
|
2012-02-07 09:22:30 -08:00
|
|
|
* @return object
|
|
|
|
* The newly created html node representing the added frame.
|
|
|
|
*/
|
2012-02-25 01:04:07 -08:00
|
|
|
addFrame: function DVF_addFrame(aDepth, aFrameNameText, aFrameDetailsText) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure we don't duplicate anything.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (document.getElementById("stackframe-" + aDepth)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let frame = document.createElement("div");
|
|
|
|
let frameName = document.createElement("span");
|
2012-02-25 01:04:07 -08:00
|
|
|
let frameDetails = document.createElement("span");
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Create a list item to be added to the stackframes container.
|
2012-02-07 09:22:30 -08:00
|
|
|
frame.id = "stackframe-" + aDepth;
|
|
|
|
frame.className = "dbg-stackframe list-item";
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// This list should display the name and details for the frame.
|
2012-02-07 09:22:30 -08:00
|
|
|
frameName.className = "dbg-stackframe-name";
|
2012-02-25 01:04:07 -08:00
|
|
|
frameDetails.className = "dbg-stackframe-details";
|
2012-02-07 09:22:30 -08:00
|
|
|
frameName.appendChild(document.createTextNode(aFrameNameText));
|
2012-02-25 01:04:07 -08:00
|
|
|
frameDetails.appendChild(document.createTextNode(aFrameDetailsText));
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
frame.appendChild(frameName);
|
2012-02-25 01:04:07 -08:00
|
|
|
frame.appendChild(frameDetails);
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
this._frames.appendChild(frame);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Return the element for later use if necessary.
|
2012-02-07 09:22:30 -08:00
|
|
|
return frame;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Highlights a frame from the stackframe container as selected/deselected.
|
|
|
|
*
|
|
|
|
* @param number aDepth
|
|
|
|
* The frame depth specified by the debugger.
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param boolean aFlag
|
|
|
|
* True if the frame should be deselected, false otherwise.
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
highlightFrame: function DVF_highlightFrame(aDepth, aFlag) {
|
2012-02-07 09:22:30 -08:00
|
|
|
let frame = document.getElementById("stackframe-" + aDepth);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The list item wasn't found in the stackframe container.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!frame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Add the 'selected' css class if the frame isn't already selected.
|
|
|
|
if (!aFlag && !frame.classList.contains("selected")) {
|
2012-02-07 09:22:30 -08:00
|
|
|
frame.classList.add("selected");
|
2012-04-08 22:15:47 -07:00
|
|
|
}
|
|
|
|
// Remove the 'selected' css class if the frame is already selected.
|
|
|
|
else if (aFlag && frame.classList.contains("selected")) {
|
2012-02-07 09:22:30 -08:00
|
|
|
frame.classList.remove("selected");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
/**
|
|
|
|
* Deselects a frame from the stackframe container.
|
|
|
|
*
|
|
|
|
* @param number aDepth
|
|
|
|
* The frame depth specified by the debugger.
|
|
|
|
*/
|
|
|
|
unhighlightFrame: function DVF_unhighlightFrame(aDepth) {
|
2012-04-17 11:16:57 -07:00
|
|
|
this.highlightFrame(aDepth, true);
|
2012-04-08 22:15:47 -07:00
|
|
|
},
|
|
|
|
|
2012-02-07 09:22:30 -08:00
|
|
|
/**
|
|
|
|
* Gets the current dirty state.
|
|
|
|
*
|
|
|
|
* @return boolean value
|
|
|
|
* True if should load more frames.
|
|
|
|
*/
|
|
|
|
get dirty() {
|
|
|
|
return this._dirty;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets if the active thread has more frames that need to be loaded.
|
|
|
|
*
|
2012-01-23 00:29:15 -08:00
|
|
|
* @param boolean aValue
|
2012-02-07 09:22:30 -08:00
|
|
|
* True if should load more frames.
|
|
|
|
*/
|
2012-01-23 00:29:15 -08:00
|
|
|
set dirty(aValue) {
|
|
|
|
this._dirty = aValue;
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-04-08 22:15:47 -07:00
|
|
|
* Listener handling the stackframes container click event.
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
_onFramesClick: function DVF__onFramesClick(aEvent) {
|
|
|
|
let target = aEvent.target;
|
|
|
|
|
|
|
|
while (target) {
|
|
|
|
if (target.debuggerFrame) {
|
|
|
|
DebuggerController.StackFrames.selectFrame(target.debuggerFrame.depth);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
target = target.parentNode;
|
|
|
|
}
|
|
|
|
},
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the stackframes container scroll event.
|
|
|
|
*/
|
2012-01-23 00:29:15 -08:00
|
|
|
_onFramesScroll: function DVF__onFramesScroll(aEvent) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Update the stackframes container only if we have to.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (this._dirty) {
|
|
|
|
let clientHeight = this._frames.clientHeight;
|
|
|
|
let scrollTop = this._frames.scrollTop;
|
|
|
|
let scrollHeight = this._frames.scrollHeight;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// If the stackframes container was scrolled past 95% of the height,
|
|
|
|
// load more content.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (scrollTop >= (scrollHeight - clientHeight) * 0.95) {
|
|
|
|
this._dirty = false;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.StackFrames.addMoreFrames();
|
2012-02-07 09:22:30 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the close button click event.
|
|
|
|
*/
|
|
|
|
_onCloseButtonClick: function DVF__onCloseButtonClick() {
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.dispatchEvent("Debugger:Close");
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-02-09 23:46:10 -08:00
|
|
|
* Listener handling the pause/resume button click event.
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
|
|
|
_onResumeButtonClick: function DVF__onResumeButtonClick() {
|
2012-04-08 22:15:47 -07:00
|
|
|
if (DebuggerController.activeThread.paused) {
|
|
|
|
DebuggerController.activeThread.resume();
|
2012-02-09 23:46:10 -08:00
|
|
|
} else {
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.activeThread.interrupt();
|
2012-02-09 23:46:10 -08:00
|
|
|
}
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
2012-03-17 23:50:43 -07:00
|
|
|
/**
|
|
|
|
* Listener handling the step over button click event.
|
|
|
|
*/
|
|
|
|
_onStepOverClick: function DVF__onStepOverClick() {
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.activeThread.stepOver();
|
2012-03-17 23:50:43 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the step in button click event.
|
|
|
|
*/
|
|
|
|
_onStepInClick: function DVF__onStepInClick() {
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.activeThread.stepIn();
|
2012-03-17 23:50:43 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Listener handling the step out button click event.
|
|
|
|
*/
|
|
|
|
_onStepOutClick: function DVF__onStepOutClick() {
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerController.activeThread.stepOut();
|
2012-03-17 23:50:43 -07:00
|
|
|
},
|
|
|
|
|
2012-02-07 09:22:30 -08:00
|
|
|
/**
|
|
|
|
* Specifies if the active thread has more frames which need to be loaded.
|
|
|
|
*/
|
|
|
|
_dirty: false,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The cached stackframes container.
|
|
|
|
*/
|
|
|
|
_frames: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is initialized.
|
|
|
|
*/
|
|
|
|
initialize: function DVF_initialize() {
|
|
|
|
let close = document.getElementById("close");
|
|
|
|
let resume = document.getElementById("resume");
|
2012-03-17 23:50:43 -07:00
|
|
|
let stepOver = document.getElementById("step-over");
|
|
|
|
let stepIn = document.getElementById("step-in");
|
|
|
|
let stepOut = document.getElementById("step-out");
|
2012-02-07 09:22:30 -08:00
|
|
|
let frames = document.getElementById("stackframes");
|
|
|
|
|
|
|
|
close.addEventListener("click", this._onCloseButtonClick, false);
|
|
|
|
resume.addEventListener("click", this._onResumeButtonClick, false);
|
2012-03-17 23:50:43 -07:00
|
|
|
stepOver.addEventListener("click", this._onStepOverClick, false);
|
|
|
|
stepIn.addEventListener("click", this._onStepInClick, false);
|
|
|
|
stepOut.addEventListener("click", this._onStepOutClick, false);
|
2012-04-08 22:15:47 -07:00
|
|
|
frames.addEventListener("click", this._onFramesClick, false);
|
2012-02-07 09:22:30 -08:00
|
|
|
frames.addEventListener("scroll", this._onFramesScroll, false);
|
|
|
|
window.addEventListener("resize", this._onFramesScroll, false);
|
|
|
|
|
|
|
|
this._frames = frames;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is shut down.
|
|
|
|
*/
|
|
|
|
destroy: function DVF_destroy() {
|
|
|
|
let close = document.getElementById("close");
|
|
|
|
let resume = document.getElementById("resume");
|
2012-03-17 23:50:43 -07:00
|
|
|
let stepOver = document.getElementById("step-over");
|
|
|
|
let stepIn = document.getElementById("step-in");
|
|
|
|
let stepOut = document.getElementById("step-out");
|
2012-02-07 09:22:30 -08:00
|
|
|
let frames = this._frames;
|
|
|
|
|
|
|
|
close.removeEventListener("click", this._onCloseButtonClick, false);
|
|
|
|
resume.removeEventListener("click", this._onResumeButtonClick, false);
|
2012-03-17 23:50:43 -07:00
|
|
|
stepOver.removeEventListener("click", this._onStepOverClick, false);
|
|
|
|
stepIn.removeEventListener("click", this._onStepInClick, false);
|
|
|
|
stepOut.removeEventListener("click", this._onStepOutClick, false);
|
2012-02-07 09:22:30 -08:00
|
|
|
frames.removeEventListener("click", this._onFramesClick, false);
|
|
|
|
frames.removeEventListener("scroll", this._onFramesScroll, false);
|
|
|
|
window.removeEventListener("resize", this._onFramesScroll, false);
|
|
|
|
|
|
|
|
this._frames = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Functions handling the properties view.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
function PropertiesView() {
|
|
|
|
this._addScope = this._addScope.bind(this);
|
|
|
|
this._addVar = this._addVar.bind(this);
|
|
|
|
this._addProperties = this._addProperties.bind(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertiesView.prototype = {
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a scope to contain any inspected variables.
|
|
|
|
* If the optional id is not specified, the scope html node will have a
|
|
|
|
* default id set as aName-scope.
|
|
|
|
*
|
|
|
|
* @param string aName
|
|
|
|
* The scope name (e.g. "Local", "Global" or "With block").
|
|
|
|
* @param string aId
|
|
|
|
* Optional, an id for the scope html node.
|
|
|
|
* @return object
|
|
|
|
* The newly created html node representing the added scope or null
|
|
|
|
* if a node was not created.
|
|
|
|
*/
|
|
|
|
_addScope: function DVP__addScope(aName, aId) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the parent container exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!this._vars) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Compute the id of the element if not specified.
|
2012-02-24 06:37:40 -08:00
|
|
|
aId = aId || (aName.toLowerCase().trim().replace(" ", "-") + "-scope");
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Contains generic nodes and functionality.
|
2012-02-07 09:22:30 -08:00
|
|
|
let element = this._createPropertyElement(aName, aId, "scope", this._vars);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the element was created successfully.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!element) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see DebuggerView.Properties._addVar
|
|
|
|
*/
|
|
|
|
element.addVar = this._addVar.bind(this, element);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Return the element for later use if necessary.
|
2012-02-07 09:22:30 -08:00
|
|
|
return element;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a variable to a specified scope.
|
|
|
|
* If the optional id is not specified, the variable html node will have a
|
|
|
|
* default id set as aScope.id->aName-variable.
|
|
|
|
*
|
|
|
|
* @param object aScope
|
|
|
|
* The parent scope element.
|
|
|
|
* @param string aName
|
|
|
|
* The variable name.
|
|
|
|
* @param string aId
|
|
|
|
* Optional, an id for the variable html node.
|
|
|
|
* @return object
|
|
|
|
* The newly created html node representing the added var.
|
|
|
|
*/
|
|
|
|
_addVar: function DVP__addVar(aScope, aName, aId) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the scope container exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!aScope) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Compute the id of the element if not specified.
|
2012-02-07 09:22:30 -08:00
|
|
|
aId = aId || (aScope.id + "->" + aName + "-variable");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Contains generic nodes and functionality.
|
2012-02-07 09:22:30 -08:00
|
|
|
let element = this._createPropertyElement(aName, aId, "variable",
|
|
|
|
aScope.querySelector(".details"));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the element was created successfully.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!element) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see DebuggerView.Properties._setGrip
|
|
|
|
*/
|
|
|
|
element.setGrip = this._setGrip.bind(this, element);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see DebuggerView.Properties._addProperties
|
|
|
|
*/
|
|
|
|
element.addProperties = this._addProperties.bind(this, element);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Setup the additional elements specific for a variable node.
|
2012-02-07 09:22:30 -08:00
|
|
|
element.refresh(function() {
|
|
|
|
let separator = document.createElement("span");
|
|
|
|
let info = document.createElement("span");
|
|
|
|
let title = element.querySelector(".title");
|
|
|
|
let arrow = element.querySelector(".arrow");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Separator shouldn't be selectable.
|
2012-02-07 09:22:30 -08:00
|
|
|
separator.className = "unselectable";
|
|
|
|
separator.appendChild(document.createTextNode(": "));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The variable information (type, class and/or value).
|
2012-02-07 09:22:30 -08:00
|
|
|
info.className = "info";
|
|
|
|
|
|
|
|
title.appendChild(separator);
|
|
|
|
title.appendChild(info);
|
|
|
|
|
|
|
|
}.bind(this));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Return the element for later use if necessary.
|
2012-02-07 09:22:30 -08:00
|
|
|
return element;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the specific grip for a variable.
|
|
|
|
* The grip should contain the value or the type & class, as defined in the
|
|
|
|
* remote debugger protocol. For convenience, undefined and null are
|
|
|
|
* both considered types.
|
|
|
|
*
|
|
|
|
* @param object aVar
|
|
|
|
* The parent variable element.
|
|
|
|
* @param object aGrip
|
|
|
|
* The primitive or object defining the grip, specifying
|
|
|
|
* the value and/or type & class of the variable (if the type
|
|
|
|
* is not specified, it will be inferred from the value).
|
|
|
|
* e.g. 42
|
|
|
|
* true
|
|
|
|
* "nasu"
|
2012-04-08 22:15:47 -07:00
|
|
|
* { type: "undefined" }
|
|
|
|
* { type: "null" }
|
|
|
|
* { type: "object", class: "Object" }
|
2012-02-07 09:22:30 -08:00
|
|
|
* @return object
|
|
|
|
* The same variable.
|
|
|
|
*/
|
|
|
|
_setGrip: function DVP__setGrip(aVar, aGrip) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the variable container exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!aVar) {
|
|
|
|
return null;
|
|
|
|
}
|
2012-04-08 22:15:47 -07:00
|
|
|
if (aGrip === undefined) {
|
|
|
|
aGrip = { type: "undefined" };
|
|
|
|
}
|
|
|
|
if (aGrip === null) {
|
|
|
|
aGrip = { type: "null" };
|
|
|
|
}
|
2012-02-07 09:22:30 -08:00
|
|
|
|
|
|
|
let info = aVar.querySelector(".info") || aVar.target.info;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the info node exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!info) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.textContent = this._propertyString(aGrip);
|
|
|
|
info.classList.add(this._propertyColor(aGrip));
|
|
|
|
|
|
|
|
return aVar;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds multiple properties to a specified variable.
|
|
|
|
* This function handles two types of properties: data properties and
|
|
|
|
* accessor properties, as defined in the remote debugger protocol spec.
|
|
|
|
*
|
|
|
|
* @param object aVar
|
|
|
|
* The parent variable element.
|
|
|
|
* @param object aProperties
|
|
|
|
* An object containing the key: descriptor data properties,
|
|
|
|
* specifying the value and/or type & class of the variable,
|
|
|
|
* or 'get' & 'set' accessor properties.
|
|
|
|
* e.g. { "someProp0": { value: 42 },
|
|
|
|
* "someProp1": { value: true },
|
|
|
|
* "someProp2": { value: "nasu" },
|
|
|
|
* "someProp3": { value: { type: "undefined" } },
|
|
|
|
* "someProp4": { value: { type: "null" } },
|
|
|
|
* "someProp5": { value: { type: "object", class: "Object" } },
|
2012-04-08 22:15:47 -07:00
|
|
|
* "someProp6": { get: { type: "object", class: "Function" },
|
|
|
|
* set: { type: "undefined" } }
|
2012-02-07 09:22:30 -08:00
|
|
|
* @return object
|
|
|
|
* The same variable.
|
|
|
|
*/
|
|
|
|
_addProperties: function DVP__addProperties(aVar, aProperties) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// For each property, add it using the passed object key/grip.
|
2012-02-07 09:22:30 -08:00
|
|
|
for (let i in aProperties) {
|
|
|
|
// Can't use aProperties.hasOwnProperty(i), because it may be overridden.
|
|
|
|
if (Object.getOwnPropertyDescriptor(aProperties, i)) {
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Get the specified descriptor for current property.
|
2012-02-07 09:22:30 -08:00
|
|
|
let desc = aProperties[i];
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// As described in the remote debugger protocol, the value grip must be
|
|
|
|
// contained in a 'value' property.
|
2012-02-07 09:22:30 -08:00
|
|
|
let value = desc["value"];
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// For accessor property descriptors, the two grips need to be
|
|
|
|
// contained in 'get' and 'set' properties.
|
2012-02-07 09:22:30 -08:00
|
|
|
let getter = desc["get"];
|
|
|
|
let setter = desc["set"];
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Handle data property and accessor property descriptors.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (value !== undefined) {
|
|
|
|
this._addProperty(aVar, [i, value]);
|
|
|
|
}
|
|
|
|
if (getter !== undefined || setter !== undefined) {
|
|
|
|
let prop = this._addProperty(aVar, [i]).expand();
|
|
|
|
prop.getter = this._addProperty(prop, ["get", getter]);
|
|
|
|
prop.setter = this._addProperty(prop, ["set", setter]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aVar;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a property to a specified variable.
|
|
|
|
* If the optional id is not specified, the property html node will have a
|
|
|
|
* default id set as aVar.id->aKey-property.
|
|
|
|
*
|
|
|
|
* @param object aVar
|
|
|
|
* The parent variable element.
|
|
|
|
* @param {Array} aProperty
|
|
|
|
* An array containing the key and grip properties, specifying
|
|
|
|
* the value and/or type & class of the variable (if the type
|
|
|
|
* is not specified, it will be inferred from the value).
|
2012-02-24 06:37:40 -08:00
|
|
|
* e.g. ["someProp0", 42]
|
|
|
|
* ["someProp1", true]
|
|
|
|
* ["someProp2", "nasu"]
|
|
|
|
* ["someProp3", { type: "undefined" }]
|
|
|
|
* ["someProp4", { type: "null" }]
|
|
|
|
* ["someProp5", { type: "object", class: "Object" }]
|
2012-02-07 09:22:30 -08:00
|
|
|
* @param string aName
|
|
|
|
* Optional, the property name.
|
|
|
|
* @paarm string aId
|
|
|
|
* Optional, an id for the property html node.
|
|
|
|
* @return object
|
|
|
|
* The newly created html node representing the added prop.
|
|
|
|
*/
|
|
|
|
_addProperty: function DVP__addProperty(aVar, aProperty, aName, aId) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the variable container exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!aVar) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Compute the id of the element if not specified.
|
2012-02-07 09:22:30 -08:00
|
|
|
aId = aId || (aVar.id + "->" + aProperty[0] + "-property");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Contains generic nodes and functionality.
|
2012-02-07 09:22:30 -08:00
|
|
|
let element = this._createPropertyElement(aName, aId, "property",
|
|
|
|
aVar.querySelector(".details"));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure the element was created successfully.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (!element) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see DebuggerView.Properties._setGrip
|
|
|
|
*/
|
|
|
|
element.setGrip = this._setGrip.bind(this, element);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see DebuggerView.Properties._addProperties
|
|
|
|
*/
|
|
|
|
element.addProperties = this._addProperties.bind(this, element);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Setup the additional elements specific for a variable node.
|
2012-02-07 09:22:30 -08:00
|
|
|
element.refresh(function(pKey, pGrip) {
|
|
|
|
let propertyString = this._propertyString(pGrip);
|
|
|
|
let propertyColor = this._propertyColor(pGrip);
|
|
|
|
let key = document.createElement("div");
|
|
|
|
let value = document.createElement("div");
|
|
|
|
let separator = document.createElement("span");
|
|
|
|
let title = element.querySelector(".title");
|
|
|
|
let arrow = element.querySelector(".arrow");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Use a key element to specify the property name.
|
2012-02-07 09:22:30 -08:00
|
|
|
key.className = "key";
|
|
|
|
key.appendChild(document.createTextNode(pKey));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Use a value element to specify the property value.
|
2012-02-07 09:22:30 -08:00
|
|
|
value.className = "value";
|
|
|
|
value.appendChild(document.createTextNode(propertyString));
|
|
|
|
value.classList.add(propertyColor);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Separator shouldn't be selected.
|
2012-02-07 09:22:30 -08:00
|
|
|
separator.className = "unselectable";
|
|
|
|
separator.appendChild(document.createTextNode(": "));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
if ("undefined" !== typeof pKey) {
|
2012-02-07 09:22:30 -08:00
|
|
|
title.appendChild(key);
|
|
|
|
}
|
2012-04-08 22:15:47 -07:00
|
|
|
if ("undefined" !== typeof pGrip) {
|
2012-02-07 09:22:30 -08:00
|
|
|
title.appendChild(separator);
|
|
|
|
title.appendChild(value);
|
|
|
|
}
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make the property also behave as a variable, to allow
|
|
|
|
// recursively adding properties to properties.
|
2012-02-07 09:22:30 -08:00
|
|
|
element.target = {
|
|
|
|
info: value
|
|
|
|
};
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Save the property to the variable for easier access.
|
2012-02-07 09:22:30 -08:00
|
|
|
Object.defineProperty(aVar, pKey, { value: element,
|
|
|
|
writable: false,
|
|
|
|
enumerable: true,
|
|
|
|
configurable: true });
|
|
|
|
}.bind(this), aProperty);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Return the element for later use if necessary.
|
2012-02-07 09:22:30 -08:00
|
|
|
return element;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a custom formatted property string for a type and a value.
|
|
|
|
*
|
|
|
|
* @param string | object aGrip
|
|
|
|
* The variable grip.
|
|
|
|
* @return string
|
|
|
|
* The formatted property string.
|
|
|
|
*/
|
|
|
|
_propertyString: function DVP__propertyString(aGrip) {
|
|
|
|
if (aGrip && "object" === typeof aGrip) {
|
2012-04-08 22:15:47 -07:00
|
|
|
switch (aGrip.type) {
|
2012-02-07 09:22:30 -08:00
|
|
|
case "undefined":
|
|
|
|
return "undefined";
|
|
|
|
case "null":
|
|
|
|
return "null";
|
|
|
|
default:
|
2012-04-08 22:15:47 -07:00
|
|
|
return "[" + aGrip.type + " " + aGrip.class + "]";
|
2012-02-07 09:22:30 -08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (typeof aGrip) {
|
|
|
|
case "string":
|
|
|
|
return "\"" + aGrip + "\"";
|
|
|
|
case "boolean":
|
|
|
|
return aGrip ? "true" : "false";
|
|
|
|
default:
|
|
|
|
return aGrip + "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aGrip + "";
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a custom class style for a type and a value.
|
|
|
|
*
|
|
|
|
* @param string | object aGrip
|
|
|
|
* The variable grip.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
* The css class style.
|
|
|
|
*/
|
|
|
|
_propertyColor: function DVP__propertyColor(aGrip) {
|
|
|
|
if (aGrip && "object" === typeof aGrip) {
|
2012-04-08 22:15:47 -07:00
|
|
|
switch (aGrip.type) {
|
2012-02-07 09:22:30 -08:00
|
|
|
case "undefined":
|
|
|
|
return "token-undefined";
|
|
|
|
case "null":
|
|
|
|
return "token-null";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (typeof aGrip) {
|
|
|
|
case "string":
|
|
|
|
return "token-string";
|
|
|
|
case "boolean":
|
|
|
|
return "token-boolean";
|
|
|
|
case "number":
|
|
|
|
return "token-number";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "token-other";
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an element which contains generic nodes and functionality used by
|
|
|
|
* any scope, variable or property added to the tree.
|
|
|
|
*
|
|
|
|
* @param string aName
|
|
|
|
* A generic name used in a title strip.
|
|
|
|
* @param string aId
|
|
|
|
* id used by the created element node.
|
|
|
|
* @param string aClass
|
|
|
|
* Recommended style class used by the created element node.
|
|
|
|
* @param object aParent
|
|
|
|
* The parent node which will contain the element.
|
|
|
|
* @return object
|
|
|
|
* The newly created html node representing the generic elem.
|
|
|
|
*/
|
|
|
|
_createPropertyElement: function DVP__createPropertyElement(aName, aId, aClass, aParent) {
|
2012-04-08 22:15:47 -07:00
|
|
|
// Make sure we don't duplicate anything and the parent exists.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (document.getElementById(aId)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (!aParent) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let element = document.createElement("div");
|
|
|
|
let arrow = document.createElement("span");
|
|
|
|
let name = document.createElement("span");
|
|
|
|
let title = document.createElement("div");
|
|
|
|
let details = document.createElement("div");
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Create a scope node to contain all the elements.
|
2012-02-07 09:22:30 -08:00
|
|
|
element.id = aId;
|
|
|
|
element.className = aClass;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The expand/collapse arrow.
|
2012-02-07 09:22:30 -08:00
|
|
|
arrow.className = "arrow";
|
|
|
|
arrow.style.visibility = "hidden";
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The name element.
|
2012-02-07 09:22:30 -08:00
|
|
|
name.className = "name unselectable";
|
|
|
|
name.appendChild(document.createTextNode(aName || ""));
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The title element, containing the arrow and the name.
|
2012-02-07 09:22:30 -08:00
|
|
|
title.className = "title";
|
|
|
|
title.addEventListener("click", function() { element.toggle(); }, true);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// The node element which will contain any added scope variables.
|
2012-02-07 09:22:30 -08:00
|
|
|
details.className = "details";
|
|
|
|
|
|
|
|
title.appendChild(arrow);
|
|
|
|
title.appendChild(name);
|
|
|
|
|
|
|
|
element.appendChild(title);
|
|
|
|
element.appendChild(details);
|
|
|
|
|
|
|
|
aParent.appendChild(element);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the element, setting the display style to "block".
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.show = function DVP_element_show() {
|
|
|
|
element.style.display = "-moz-box";
|
|
|
|
|
|
|
|
if ("function" === typeof element.onshow) {
|
|
|
|
element.onshow(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the element, setting the display style to "none".
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.hide = function DVP_element_hide() {
|
|
|
|
element.style.display = "none";
|
|
|
|
|
|
|
|
if ("function" === typeof element.onhide) {
|
|
|
|
element.onhide(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expands the element, showing all the added details.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.expand = function DVP_element_expand() {
|
|
|
|
arrow.setAttribute("open", "");
|
|
|
|
details.setAttribute("open", "");
|
|
|
|
|
|
|
|
if ("function" === typeof element.onexpand) {
|
|
|
|
element.onexpand(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collapses the element, hiding all the added details.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.collapse = function DVP_element_collapse() {
|
|
|
|
arrow.removeAttribute("open");
|
|
|
|
details.removeAttribute("open");
|
|
|
|
|
|
|
|
if ("function" === typeof element.oncollapse) {
|
|
|
|
element.oncollapse(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggles between the element collapse/expand state.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.toggle = function DVP_element_toggle() {
|
|
|
|
element.expanded = !element.expanded;
|
|
|
|
|
|
|
|
if ("function" === typeof element.ontoggle) {
|
|
|
|
element.ontoggle(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
/**
|
|
|
|
* Shows the element expand/collapse arrow (only if necessary!).
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.showArrow = function DVP_element_showArrow() {
|
|
|
|
if (details.childNodes.length) {
|
|
|
|
arrow.style.visibility = "visible";
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Forces the element expand/collapse arrow to be visible, even if there
|
|
|
|
* are no child elements.
|
|
|
|
*
|
|
|
|
* @param boolean aPreventHideFlag
|
|
|
|
* Prevents the arrow to be hidden when requested.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.forceShowArrow = function DVP_element_forceShowArrow(aPreventHideFlag) {
|
|
|
|
element._preventHide = aPreventHideFlag;
|
|
|
|
arrow.style.visibility = "visible";
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hides the element expand/collapse arrow.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.hideArrow = function DVP_element_hideArrow() {
|
|
|
|
if (!element._preventHide) {
|
|
|
|
arrow.style.visibility = "hidden";
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
2012-02-07 09:22:30 -08:00
|
|
|
/**
|
|
|
|
* Returns if the element is visible.
|
|
|
|
* @return boolean
|
|
|
|
* True if the element is visible.
|
|
|
|
*/
|
|
|
|
Object.defineProperty(element, "visible", {
|
|
|
|
get: function DVP_element_getVisible() {
|
|
|
|
return element.style.display !== "none";
|
|
|
|
},
|
|
|
|
set: function DVP_element_setVisible(value) {
|
|
|
|
if (value) {
|
|
|
|
element.show();
|
|
|
|
} else {
|
|
|
|
element.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the element is expanded.
|
|
|
|
* @return boolean
|
|
|
|
* True if the element is expanded.
|
|
|
|
*/
|
|
|
|
Object.defineProperty(element, "expanded", {
|
|
|
|
get: function DVP_element_getExpanded() {
|
|
|
|
return arrow.hasAttribute("open");
|
|
|
|
},
|
|
|
|
set: function DVP_element_setExpanded(value) {
|
|
|
|
if (value) {
|
|
|
|
element.expand();
|
|
|
|
} else {
|
|
|
|
element.collapse();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes all added children in the details container tree.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.empty = function DVP_element_empty() {
|
|
|
|
// this details node won't have any elements, so hide the arrow
|
|
|
|
arrow.style.visibility = "hidden";
|
|
|
|
while (details.firstChild) {
|
|
|
|
details.removeChild(details.firstChild);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ("function" === typeof element.onempty) {
|
|
|
|
element.onempty(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes the element from the parent node details container tree.
|
|
|
|
* @return object
|
|
|
|
* The same element.
|
|
|
|
*/
|
|
|
|
element.remove = function DVP_element_remove() {
|
|
|
|
element.parentNode.removeChild(element);
|
|
|
|
|
|
|
|
if ("function" === typeof element.onremove) {
|
|
|
|
element.onremove(element);
|
|
|
|
}
|
|
|
|
return element;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic function refreshing the internal state of the element when
|
|
|
|
* it's modified (e.g. a child detail, variable, property is added).
|
|
|
|
*
|
|
|
|
* @param function aFunction
|
|
|
|
* The function logic used to modify the internal state.
|
|
|
|
* @param array aArguments
|
|
|
|
* Optional arguments array to be applied to aFunction.
|
|
|
|
*/
|
|
|
|
element.refresh = function DVP_element_refresh(aFunction, aArguments) {
|
|
|
|
if ("function" === typeof aFunction) {
|
|
|
|
aFunction.apply(this, aArguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
let node = aParent.parentNode;
|
|
|
|
let arrow = node.querySelector(".arrow");
|
|
|
|
let children = node.querySelector(".details").childNodes.length;
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// If the parent details node has at least one element, set the
|
|
|
|
// expand/collapse arrow visible.
|
2012-02-07 09:22:30 -08:00
|
|
|
if (children) {
|
|
|
|
arrow.style.visibility = "visible";
|
|
|
|
} else {
|
|
|
|
arrow.style.visibility = "hidden";
|
|
|
|
}
|
|
|
|
}.bind(this);
|
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
// Return the element for later use and customization.
|
2012-02-07 09:22:30 -08:00
|
|
|
return element;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the global scope container.
|
|
|
|
*/
|
|
|
|
get globalScope() {
|
|
|
|
return this._globalScope;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display mode for the global scope container.
|
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param boolean aFlag
|
2012-02-07 09:22:30 -08:00
|
|
|
* False to hide the container, true to show.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
set globalScope(aFlag) {
|
|
|
|
if (aFlag) {
|
2012-02-07 09:22:30 -08:00
|
|
|
this._globalScope.show();
|
|
|
|
} else {
|
|
|
|
this._globalScope.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the local scope container.
|
|
|
|
*/
|
|
|
|
get localScope() {
|
|
|
|
return this._localScope;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display mode for the local scope container.
|
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param boolean aFlag
|
2012-02-07 09:22:30 -08:00
|
|
|
* False to hide the container, true to show.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
set localScope(aFlag) {
|
|
|
|
if (aFlag) {
|
2012-02-07 09:22:30 -08:00
|
|
|
this._localScope.show();
|
|
|
|
} else {
|
|
|
|
this._localScope.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the with block scope container.
|
|
|
|
*/
|
|
|
|
get withScope() {
|
|
|
|
return this._withScope;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display mode for the with block scope container.
|
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param boolean aFlag
|
2012-02-07 09:22:30 -08:00
|
|
|
* False to hide the container, true to show.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
set withScope(aFlag) {
|
|
|
|
if (aFlag) {
|
2012-02-07 09:22:30 -08:00
|
|
|
this._withScope.show();
|
|
|
|
} else {
|
|
|
|
this._withScope.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the closure scope container.
|
|
|
|
*/
|
|
|
|
get closureScope() {
|
|
|
|
return this._closureScope;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the display mode for the with block scope container.
|
|
|
|
*
|
2012-04-08 22:15:47 -07:00
|
|
|
* @param boolean aFlag
|
2012-02-07 09:22:30 -08:00
|
|
|
* False to hide the container, true to show.
|
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
set closureScope(aFlag) {
|
|
|
|
if (aFlag) {
|
2012-02-07 09:22:30 -08:00
|
|
|
this._closureScope.show();
|
|
|
|
} else {
|
|
|
|
this._closureScope.hide();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The cached variable properties container.
|
|
|
|
*/
|
|
|
|
_vars: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-created global, local, with block and closure scopes containing vars.
|
|
|
|
*/
|
|
|
|
_globalScope: null,
|
|
|
|
_localScope: null,
|
|
|
|
_withScope: null,
|
|
|
|
_closureScope: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialization function, called when the debugger is initialized.
|
|
|
|
*/
|
|
|
|
initialize: function DVP_initialize() {
|
|
|
|
this._vars = document.getElementById("variables");
|
2012-04-08 22:15:47 -07:00
|
|
|
this._localScope = this._addScope(L10N.getStr("localScope")).expand();
|
|
|
|
this._withScope = this._addScope(L10N.getStr("withScope")).hide();
|
|
|
|
this._closureScope = this._addScope(L10N.getStr("closureScope")).hide();
|
|
|
|
this._globalScope = this._addScope(L10N.getStr("globalScope"));
|
2012-02-07 09:22:30 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Destruction function, called when the debugger is shut down.
|
|
|
|
*/
|
|
|
|
destroy: function DVP_destroy() {
|
|
|
|
this._vars = null;
|
|
|
|
this._globalScope = null;
|
|
|
|
this._localScope = null;
|
|
|
|
this._withScope = null;
|
|
|
|
this._closureScope = null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2012-04-08 22:15:47 -07:00
|
|
|
* Preliminary setup for the DebuggerView object.
|
2012-02-07 09:22:30 -08:00
|
|
|
*/
|
2012-04-08 22:15:47 -07:00
|
|
|
DebuggerView.Scripts = new ScriptsView();
|
|
|
|
DebuggerView.StackFrames = new StackFramesView();
|
|
|
|
DebuggerView.Properties = new PropertiesView();
|
2012-02-07 09:22:30 -08:00
|
|
|
|
2012-04-08 22:15:47 -07:00
|
|
|
/**
|
|
|
|
* Export the source editor to the global scope for easier access in tests.
|
|
|
|
*/
|
|
|
|
Object.defineProperty(window, "editor", {
|
|
|
|
get: function() { return DebuggerView.editor; }
|
|
|
|
});
|