Merge m-c to birch.

This commit is contained in:
Ryan VanderMeulen 2013-04-29 21:22:24 -04:00
commit 9950026482
277 changed files with 5269 additions and 2284 deletions

View File

@ -34,6 +34,7 @@ enum AccType {
eHTMLSelectListType,
eHTMLMediaType,
eHTMLRadioButtonType,
eHTMLRangeType,
eHTMLTableType,
eHTMLTableCellType,
eHTMLTableRowType,

View File

@ -425,6 +425,20 @@ nsAccessibilityService::TreeViewChanged(nsIPresShell* aPresShell,
}
}
void
nsAccessibilityService::RangeValueChanged(nsIPresShell* aPresShell,
nsIContent* aContent)
{
DocAccessible* document = GetDocAccessible(aPresShell);
if (document) {
Accessible* accessible = document->GetAccessible(aContent);
if (accessible) {
document->FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
accessible);
}
}
}
void
nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
nsIContent* aHTMLListItemContent,
@ -1509,6 +1523,9 @@ nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
case eHTMLRadioButtonType:
newAcc = new HTMLRadioButtonAccessible(aContent, document);
break;
case eHTMLRangeType:
newAcc = new HTMLRangeAccessible(aContent, document);
break;
case eHTMLTableType:
newAcc = new HTMLTableAccessibleWrap(aContent, document);
break;

View File

@ -99,6 +99,11 @@ public:
void TreeViewChanged(nsIPresShell* aPresShell, nsIContent* aContent,
nsITreeView* aView);
/**
* Notify of input@type="element" value change.
*/
void RangeValueChanged(nsIPresShell* aPresShell, nsIContent* aContent);
/**
* Update list bullet accessible.
*/

View File

@ -543,6 +543,91 @@ HTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// HTMLRangeAccessible
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS_INHERITED1(HTMLRangeAccessible, LeafAccessible,
nsIAccessibleValue)
role
HTMLRangeAccessible::NativeRole()
{
return roles::SLIDER;
}
bool
HTMLRangeAccessible::IsWidget() const
{
return true;
}
void
HTMLRangeAccessible::Value(nsString& aValue)
{
LeafAccessible::Value(aValue);
if (!aValue.IsEmpty())
return;
HTMLInputElement::FromContent(mContent)->GetValue(aValue);
}
NS_IMETHODIMP
HTMLRangeAccessible::GetMaximumValue(double* aMaximumValue)
{
nsresult rv = LeafAccessible::GetMaximumValue(aMaximumValue);
if (rv != NS_OK_NO_ARIA_VALUE)
return rv;
*aMaximumValue = HTMLInputElement::FromContent(mContent)->GetMaximum();
return NS_OK;
}
NS_IMETHODIMP
HTMLRangeAccessible::GetMinimumValue(double* aMinimumValue)
{
nsresult rv = LeafAccessible::GetMinimumValue(aMinimumValue);
if (rv != NS_OK_NO_ARIA_VALUE)
return rv;
*aMinimumValue = HTMLInputElement::FromContent(mContent)->GetMinimum();
return NS_OK;
}
NS_IMETHODIMP
HTMLRangeAccessible::GetMinimumIncrement(double* aMinimumIncrement)
{
nsresult rv = LeafAccessible::GetMinimumIncrement(aMinimumIncrement);
if (rv != NS_OK_NO_ARIA_VALUE)
return rv;
*aMinimumIncrement = HTMLInputElement::FromContent(mContent)->GetStep();
return NS_OK;
}
NS_IMETHODIMP
HTMLRangeAccessible::GetCurrentValue(double* aCurrentValue)
{
nsresult rv = LeafAccessible::GetCurrentValue(aCurrentValue);
if (rv != NS_OK_NO_ARIA_VALUE)
return rv;
*aCurrentValue = HTMLInputElement::FromContent(mContent)->GetValueAsDouble();
return NS_OK;
}
NS_IMETHODIMP
HTMLRangeAccessible::SetCurrentValue(double aValue)
{
ErrorResult er;
HTMLInputElement::FromContent(mContent)->SetValueAsNumber(aValue, er);
return er.ErrorCode();
}
////////////////////////////////////////////////////////////////////////////////
// HTMLGroupboxAccessible
////////////////////////////////////////////////////////////////////////////////

View File

@ -145,6 +145,31 @@ public:
virtual nsresult HandleAccEvent(AccEvent* aAccEvent);
};
/**
* Used for input@type="range" element.
*/
class HTMLRangeAccessible : public LeafAccessible
{
public:
HTMLRangeAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc)
{
mStateFlags |= eHasNumericValue;
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIACCESSIBLEVALUE
// Accessible
virtual void Value(nsString& aValue);
virtual mozilla::a11y::role NativeRole();
// Widgets
virtual bool IsWidget() const;
};
/**
* Accessible for HTML fieldset element.
*/

View File

@ -8,6 +8,8 @@
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript"
src="../common.js"></script>
@ -79,21 +81,46 @@
}
}
function changeProcessValue(aID, aValue) {
this.DOMNode = getNode(aID);
function changeProgressValue(aID, aValue)
{
this.DOMNode = getNode(aID);
this.invoke = function changeProcessValue_invoke() {
this.DOMNode.value = aValue;
}
this.invoke = function changeProgressValue_invoke()
{
this.DOMNode.value = aValue;
}
this.check = function changeProcessValue_check() {
var acc = getAccessible(this.DOMNode);
is(acc.value, aValue+"%", "Wrong value for " + prettyName(aID));
}
this.check = function changeProgressValue_check()
{
var acc = getAccessible(this.DOMNode);
is(acc.value, aValue+"%", "Wrong value for " + prettyName(aID));
}
this.getID = function changeProcessValue_getID() {
return prettyName(aID) + " value changed";
}
this.getID = function changeProgressValue_getID()
{
return prettyName(aID) + " value changed";
}
}
function changeRangeValue(aID)
{
this.DOMNode = getNode(aID);
this.invoke = function changeRangeValue_invoke()
{
synthesizeMouse(getNode(aID), 5, 5, { });
}
this.finalCheck = function changeRangeValue_finalCheck()
{
var acc = getAccessible(this.DOMNode);
is(acc.value, "0", "Wrong value for " + prettyName(aID));
}
this.getID = function changeRangeValue_getID()
{
return prettyName(aID) + " range value changed";
}
}
function doTests()
@ -104,6 +131,7 @@
testValue("slider_vt", "hi", 0, 0, 3, 0);
testValue("scrollbar", "5", 5, 0, 1000, 0);
testValue("progress", "22%", 22, 0, 100, 0);
testValue("range", "6", 6, 0, 10, 1);
// Test value change events
gQueue = new eventQueue(nsIAccessibleEvent.EVENT_VALUE_CHANGE);
@ -115,7 +143,8 @@
gQueue.push(new changeValue("combobox", "hello"));
gQueue.push(new changeProcessValue("progress", "50"));
gQueue.push(new changeProgressValue("progress", "50"));
gQueue.push(new changeRangeValue("range"));
gQueue.invoke(); // Will call SimpleTest.finish();
}
@ -137,6 +166,11 @@
title="We dont expose new aria role 'scrollbar' and property aria-orientation">
Mozilla Bug 529289
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=559764"
title="Make HTML5 input@type=range element accessible">
Mozilla Bug 559764
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=703202"
title="ARIA comboboxes don't fire value change events">
@ -175,5 +209,8 @@
<!-- progress bar -->
<progress id="progress" value="22" max="100"></progress>
<!-- input@type="range" -->
<input type="range" id="range" min="0" max="10" value="6">
</body>
</html>

View File

@ -59,6 +59,11 @@
};
testAccessibleTree("image_submit", accTree);
// input@type="range"
accTree = { SLIDER: [ ] };
testAccessibleTree("range", accTree);
// output
accTree = {
role: ROLE_SECTION,
children: [
@ -81,17 +86,22 @@
<a target="_blank"
title="Fix O(n^2) access to all the children of a container"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=342045">
Mozilla Bug 342045
Bug 342045
</a>
<a target="_blank"
title="add test for role of input type='image'"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=524521">
Mozilla Bug 524521
Bug 524521
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
title="make HTML <output> accessible">
Mozilla Bug 558036
Bug 558036
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=559764"
title="make HTML5 input@type=range element accessible">
Bug 559764
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>
@ -105,6 +115,8 @@
<input type="submit" id="submit">
<input type="image" id="image_submit">
<input type="range" id="range">
<output id="output">1337</output>
</body>
</html>

View File

@ -15,6 +15,7 @@ MOCHITEST_A11Y_FILES =\
test_general.html \
test_progress.html \
test_progress.xul \
test_range.html \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,59 @@
<html>
<head>
<title>nsIAccessible value testing for input@type=range element</title>
<link rel="stylesheet" type="text/css"
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript"
src="../common.js"></script>
<script type="application/javascript"
src="../value.js"></script>
<script type="application/javascript"
src="chrome://mochikit/content/chrome-harness.js"></script>
<script type="application/javascript">
function doTest()
{
// HTML5 progress element tests
testValue("range", "50", 50, 0, 100, 1);
testValue("range_value", "1", 1, 0, 100, 1);
testValue("range_step", "50", 50, 0, 100, 1);
testValue("range_min42", "71", 71, 42, 100, 1);
testValue("range_max42", "21", 21, 0, 42, 1);
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addA11yLoadEvent(doTest);
</script>
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=559764"
title="make HTML5 input@type=range element accessible">
Bug 559764
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<!-- HTML5 input@type=range element -->
<input type="range" id="range">
<input type="range" id="range_value" value="1">
<input type="range" id="range_step" step="1">
<input type="range" id="range_min42" min="42">
<input type="range" id="range_max42" max="42">
</body>
</html>

View File

@ -5630,11 +5630,11 @@ var OfflineApps = {
return;
}
var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
var browser = this._getBrowserForContentWindow(browserWindow,
let browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
let browser = this._getBrowserForContentWindow(browserWindow,
aContentWindow);
var currentURI = aContentWindow.document.documentURIObject;
let currentURI = aContentWindow.document.documentURIObject;
// don't bother showing UI if the user has already made a decision
if (Services.perms.testExactPermission(currentURI, "offline-app") != Services.perms.UNKNOWN_ACTION)
@ -5649,44 +5649,40 @@ var OfflineApps = {
// this pref isn't set by default, ignore failures
}
var host = currentURI.asciiHost;
var notificationBox = gBrowser.getNotificationBox(browser);
var notificationID = "offline-app-requested-" + host;
var notification = notificationBox.getNotificationWithValue(notificationID);
let host = currentURI.asciiHost;
let notificationID = "offline-app-requested-" + host;
let notification = PopupNotifications.getNotification(notificationID, browser);
if (notification) {
notification.documents.push(aContentWindow.document);
notification.options.documents.push(aContentWindow.document);
} else {
var buttons = [{
let mainAction = {
label: gNavigatorBundle.getString("offlineApps.allow"),
accessKey: gNavigatorBundle.getString("offlineApps.allowAccessKey"),
callback: function() {
for (let document of notification.documents) {
for (let document of notification.options.documents) {
OfflineApps.allowSite(document);
}
}
},{
};
let secondaryActions = [{
label: gNavigatorBundle.getString("offlineApps.never"),
accessKey: gNavigatorBundle.getString("offlineApps.neverAccessKey"),
callback: function() {
for (let document of notification.documents) {
for (let document of notification.options.documents) {
OfflineApps.disallowSite(document);
}
}
},{
label: gNavigatorBundle.getString("offlineApps.notNow"),
accessKey: gNavigatorBundle.getString("offlineApps.notNowAccessKey"),
callback: function() { /* noop */ }
}];
const priority = notificationBox.PRIORITY_INFO_LOW;
var message = gNavigatorBundle.getFormattedString("offlineApps.available",
let message = gNavigatorBundle.getFormattedString("offlineApps.available",
[ host ]);
notification =
notificationBox.appendNotification(message, notificationID,
"chrome://browser/skin/Info.png",
priority, buttons);
notification.documents = [ aContentWindow.document ];
let anchorID = "indexedDB-notification-icon";
let options= {
documents : [ aContentWindow.document ]
};
notification = PopupNotifications.show(browser, notificationID, message,
anchorID, mainAction,
secondaryActions, options);
}
},

View File

@ -437,10 +437,9 @@ nsContextMenu.prototype = {
},
inspectNode: function CM_inspectNode() {
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let gBrowser = this.browser.ownerDocument.defaultView.gBrowser;
let imported = {};
Cu.import("resource:///modules/devtools/Target.jsm", imported);
let tt = imported.TargetFactory.forTab(gBrowser.selectedTab);
let tt = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(tt, "inspector").then(function(toolbox) {
let inspector = toolbox.getCurrentPanel();
inspector.selection.setNode(this.target, "browser-context-menu");

View File

@ -28,7 +28,10 @@
<xul:notificationbox flex="1">
<xul:hbox flex="1" class="browserSidebarContainer">
<xul:vbox flex="1" class="browserContainer">
<xul:stack flex="1" class="browserStack" anonid="browserStack"/>
<xul:stack flex="1" class="browserStack">
<xul:browser anonid="initialBrowser" type="content-primary" message="true" disablehistory="true"
xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup"/>
</xul:stack>
</xul:vbox>
</xul:hbox>
</xul:notificationbox>
@ -1322,14 +1325,26 @@
if (aOwner)
t.owner = aOwner;
var b = this._createBrowserElement();
var b = document.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"browser");
b.setAttribute("type", "content-targetable");
b.setAttribute("message", "true");
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
if (Services.prefs.getPrefType("browser.tabs.remote") == Services.prefs.PREF_BOOL &&
Services.prefs.getBoolPref("browser.tabs.remote")) {
b.setAttribute("remote", "true");
}
if (window.gShowPageResizers && document.getElementById("addon-bar").collapsed &&
window.windowState == window.STATE_NORMAL) {
b.setAttribute("showresizer", "true");
}
if (this.hasAttribute("autocompletepopup"))
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
// Create the browserStack container
@ -1391,6 +1406,7 @@
this.mTabFilters[position] = filter;
b._fastFind = this.fastFind;
b.droppedLinkHandler = handleDroppedLink;
// Dispatch a new tab notification. We do this once we're
// entirely done, so that things are in a consistent state
@ -2691,37 +2707,9 @@
]]></body>
</method>
<method name="_createBrowserElement">
<body><![CDATA[
var b = document.createElementNS(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"browser");
b.setAttribute("message", "true");
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
if (this.hasAttribute("autocompletepopup"))
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
if (Services.prefs.getBoolPref("browser.tabs.remote"))
b.setAttribute("remote", "true");
b.droppedLinkHandler = handleDroppedLink;
return b;
]]></body>
</method>
<constructor>
<![CDATA[
let browser = this._createBrowserElement();
this.mCurrentBrowser = browser;
browser.setAttribute("type", "content-primary");
browser.setAttribute("disablehistory", "true");
let stack = document.getAnonymousElementByAttribute(this, "anonid", "browserStack");
stack.appendChild(browser);
this.mCurrentBrowser = document.getAnonymousElementByAttribute(this, "anonid", "initialBrowser");
this.mCurrentTab = this.tabContainer.firstChild;
document.addEventListener("keypress", this, false);
window.addEventListener("sizemodechange", this, false);
@ -2738,6 +2726,7 @@
this._autoScrollPopup.id = "autoscroller";
this.appendChild(this._autoScrollPopup);
this.mCurrentBrowser.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
this.mCurrentBrowser.droppedLinkHandler = handleDroppedLink;
this.updateWindowResizers();
// Hook up the event listeners to the first browser

View File

@ -105,23 +105,22 @@ function testEventHandling() {
function loaded() {
testEventHandling();
// Click the notification bar's "Allow" button. This should kick
// Click the notification panel's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from
// the children.
var wm = SpecialPowers.Cc["@mozilla.org/appshell/window-mediator;1"].
getService(SpecialPowers.Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox();
var panel = win.PopupNotifications.panel;
is(panel.childElementCount, 2, "2 notifications being displayed");
panel.firstElementChild.button.click();
var notification = notificationBox.getNotificationWithValue("offline-app-requested-mochi.test");
notification.childNodes[0].click();
notification = SpecialPowers.wrap(notificationBox).getNotificationWithValue("offline-app-requested-example.com");
notification.childNodes[0].click();
// should have dismissed one of the notifications.
is(panel.childElementCount, 1, "1 notification now being displayed");
panel.firstElementChild.button.click();
}
</script>
</pre>
</body>
</html>

View File

@ -96,21 +96,17 @@ function handleMessageEvents(event) {
}
function loaded() {
// Click the notification bar's "Allow" button. This should kick
// Click the notification panel's "Allow" button. This should kick
// off updates, which will eventually lead to getting messages from
// the iframe.
var wm = SpecialPowers.Cc["@mozilla.org/appshell/window-mediator;1"].
getService(SpecialPowers.Ci.nsIWindowMediator);
var win = wm.getMostRecentWindow("navigator:browser");
var notificationBox = win.gBrowser.getNotificationBox();
var notification = notificationBox
.getNotificationWithValue("offline-app-requested-mochi.test");
notification.childNodes[0].click();
var panel = win.PopupNotifications.panel;
panel.firstElementChild.button.click();
}
</script>
</pre>
</body>
</html>

View File

@ -15,6 +15,9 @@ function test() {
* session store service the first history entry must be selected.
*/
const URL = "data:text/html,<h1>first</h1>";
const URL2 = "data:text/html,<h1>second</h1>";
function runTests() {
// Create a dummy window that is regarded as active. We need to do this
// because we always collect data for tabs of active windows no matter if
@ -24,8 +27,8 @@ function runTests() {
// Create a tab with two history entries.
let tab = gBrowser.selectedTab = gBrowser.addTab("about:blank");
yield loadURI("about:robots");
yield loadURI("about:mozilla");
yield loadURI(URL);
yield loadURI(URL2);
// All windows currently marked as dirty will be written to disk
// and thus marked clean afterwards.
@ -35,7 +38,7 @@ function runTests() {
// will not fire a 'load' event but a 'pageshow' event with persisted=true.
waitForPageShow();
yield gBrowser.selectedBrowser.goBack();
is(tab.linkedBrowser.currentURI.spec, "about:robots", "url is about:robots");
is(tab.linkedBrowser.currentURI.spec, URL, "correct url after going back");
// If by receiving the 'pageshow' event the first window has correctly
// been marked as dirty, getBrowserState() should return the tab we created

View File

@ -0,0 +1,15 @@
# 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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(topsrcdir)/config/config.mk
include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/main.js $(FINAL_TARGET)/modules/devtools

View File

@ -14,13 +14,13 @@ this.EXPORTED_SYMBOLS = [ "CmdAddonFlags", "CmdCommands" ];
Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/osfile.jsm")
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
"resource:///modules/devtools/Target.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource:///modules/devtools/gDevTools.jsm");
/* CmdAddon ---------------------------------------------------------------- */
@ -405,9 +405,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
return global.Debugger;
});
XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
"resource:///modules/devtools/Target.jsm");
let debuggers = [];
/**
@ -437,7 +434,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
debuggers.push(dbg);
let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
gDevTools.showToolbox(target, "webconsole");
return gcli.lookup("calllogStartReply");
@ -589,7 +586,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
}.bind(this);
let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
gDevTools.showToolbox(target, "webconsole");
return gcli.lookup("calllogChromeStartReply");
@ -835,7 +832,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
description: gcli.lookup("consolecloseDesc"),
exec: function Command_consoleClose(args, context) {
let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.closeToolbox(target);
}
});
@ -848,7 +845,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
description: gcli.lookup("consoleopenDesc"),
exec: function Command_consoleOpen(args, context) {
let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(target, "webconsole");
}
});
@ -1599,6 +1596,75 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
}
}(this));
/* CmdTools -------------------------------------------------------------- */
(function(module) {
gcli.addCommand({
name: "tools",
description: gcli.lookup("toolsDesc"),
manual: gcli.lookup("toolsManual"),
get hidden() gcli.hiddenByChromePref(),
});
gcli.addCommand({
name: "tools srcdir",
description: gcli.lookup("toolsSrcdirDesc"),
manual: gcli.lookup("toolsSrcdirManual"),
get hidden() gcli.hiddenByChromePref(),
params: [
{
name: "srcdir",
type: "string",
description: gcli.lookup("toolsSrcdirDir")
}
],
returnType: "string",
exec: function(args, context) {
let promise = context.createPromise();
let existsPromise = OS.File.exists(args.srcdir + "/CLOBBER");
existsPromise.then(function(exists) {
if (exists) {
var str = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
str.data = args.srcdir;
Services.prefs.setComplexValue("devtools.loader.srcdir",
Components.interfaces.nsISupportsString, str);
devtools.reload();
promise.resolve(gcli.lookupFormat("toolsSrcdirReloaded", [args.srcdir]));
return;
}
promise.reject(gcli.lookupFormat("toolsSrcdirNotFound", [args.srcdir]));
});
return promise;
}
});
gcli.addCommand({
name: "tools builtin",
description: gcli.lookup("toolsBuiltinDesc"),
manual: gcli.lookup("toolsBuiltinManual"),
get hidden() gcli.hiddenByChromePref(),
returnType: "string",
exec: function(args, context) {
Services.prefs.clearUserPref("devtools.loader.srcdir");
devtools.reload();
return gcli.lookup("toolsBuiltinReloaded");
}
});
gcli.addCommand({
name: "tools reload",
description: gcli.lookup("toolsReloadDesc"),
get hidden() gcli.hiddenByChromePref() || !Services.prefs.prefHasUserValue("devtools.loader.srcdir"),
returnType: "string",
exec: function(args, context) {
devtools.reload();
return gcli.lookup("toolsReloaded");
}
});
}(this));
/* CmdRestart -------------------------------------------------------------- */
(function(module) {
@ -1993,7 +2059,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
function fireChange() {
eventEmitter.emit("changed", tab);
}
var target = TargetFactory.forTab(tab);
var target = devtools.TargetFactory.forTab(tab);
target.off("navigate", fireChange);
target.once("navigate", fireChange);
}

View File

@ -24,7 +24,8 @@ let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).req
Components.utils.import("resource:///modules/devtools/gcli.jsm", {});
let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console;
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let devtools = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools;
let TargetFactory = devtools.TargetFactory;
let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise;
let assert = { ok: ok, is: is, log: info };

View File

@ -10,7 +10,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
this.EXPORTED_SYMBOLS = ["DebuggerPanel"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/sdk/core/promise.js");

View File

@ -12,14 +12,14 @@ Cu.import("resource://gre/modules/devtools/dbg-server.jsm", tempScope);
Cu.import("resource://gre/modules/devtools/dbg-client.jsm", tempScope);
Cu.import("resource:///modules/source-editor.jsm", tempScope);
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let Services = tempScope.Services;
let SourceEditor = tempScope.SourceEditor;
let DebuggerServer = tempScope.DebuggerServer;
let DebuggerTransport = tempScope.DebuggerTransport;
let DebuggerClient = tempScope.DebuggerClient;
let gDevTools = tempScope.gDevTools;
let TargetFactory = tempScope.TargetFactory;
let devtools = tempScope.devtools;
let TargetFactory = devtools.TargetFactory;
// Import the GCLI test helper
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));

View File

@ -24,7 +24,8 @@ let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).req
Components.utils.import("resource:///modules/devtools/gcli.jsm", {});
let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console;
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let devtools = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools;
let TargetFactory = devtools.TargetFactory;
let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise;
let assert = { ok: ok, is: is, log: info };

View File

@ -2,8 +2,8 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let {devtools, gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);

View File

@ -13,3 +13,4 @@ include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/framework

View File

@ -9,10 +9,10 @@
const Cu = Components.utils;
Cu.import("resource:///modules/devtools/Target.jsm");
Cu.import("resource:///modules/devtools/Toolbox.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/devtools/dbg-client.jsm");
let {devtools, gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let gClient;
let gConnectionTimeout;
@ -169,8 +169,8 @@ function openToolbox(form, chrome=false) {
client: gClient,
chrome: chrome
};
TargetFactory.forRemoteTab(options).then((target) => {
gDevTools.showToolbox(target, "webconsole", Toolbox.HostType.WINDOW);
devtools.TargetFactory.forRemoteTab(options).then((target) => {
gDevTools.showToolbox(target, "webconsole", devtools.Toolbox.HostType.WINDOW);
window.close();
});
}

View File

@ -4,19 +4,192 @@
"use strict";
this.EXPORTED_SYMBOLS = [ "gDevTools", "DevTools", "gDevToolsBrowser" ];
this.EXPORTED_SYMBOLS = [ "gDevTools", "DevTools", "gDevToolsBrowser", "devtools" ];
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/ToolDefinitions.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Toolbox",
"resource:///modules/devtools/Toolbox.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
"resource:///modules/devtools/Target.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
let loader = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}).Loader;
// Used when the tools should be loaded from the Firefox package itself (the default)
var BuiltinProvider = {
load: function(done) {
this.loader = new loader.Loader({
paths: {
"": "resource://gre/modules/commonjs/",
"main" : "resource:///modules/devtools/main",
"devtools": "resource:///modules/devtools",
"devtools/toolkit": "resource://gre/modules/devtools"
},
globals: {},
});
this.main = loader.main(this.loader, "main");
return Promise.resolve(undefined);
},
unload: function(reason) {
loader.unload(this.loader, reason);
delete this.loader;
},
};
var SrcdirProvider = {
load: function(done) {
let srcdir = Services.prefs.getComplexValue("devtools.loader.srcdir",
Ci.nsISupportsString);
srcdir = OS.Path.normalize(srcdir.data.trim());
let devtoolsDir = OS.Path.join(srcdir, "browser/devtools");
let toolkitDir = OS.Path.join(srcdir, "toolkit/devtools");
this.loader = new loader.Loader({
paths: {
"": "resource://gre/modules/commonjs/",
"devtools/toolkit": "file://" + toolkitDir,
"devtools": "file://" + devtoolsDir,
"main": "file://" + devtoolsDir + "/main.js"
},
globals: {}
});
this.main = loader.main(this.loader, "main");
return this._writeManifest(devtoolsDir).then((data) => {
this._writeManifest(toolkitDir);
}).then(null, Cu.reportError);
},
unload: function(reason) {
loader.unload(this.loader, reason);
delete this.loader;
},
_readFile: function(filename) {
let deferred = Promise.defer();
let file = new FileUtils.File(filename);
NetUtil.asyncFetch(file, (inputStream, status) => {
if (!Components.isSuccessCode(status)) {
deferred.reject(new Error("Couldn't load manifest: " + filename + "\n"));
return;
}
var data = NetUtil.readInputStreamToString(inputStream, inputStream.available());
deferred.resolve(data);
});
return deferred.promise;
},
_writeFile: function(filename, data) {
let deferred = Promise.defer();
let file = new FileUtils.File(filename);
var ostream = FileUtils.openSafeFileOutputStream(file)
var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = "UTF-8";
var istream = converter.convertToInputStream(data);
NetUtil.asyncCopy(istream, ostream, (status) => {
if (!Components.isSuccessCode(status)) {
deferred.reject(new Error("Couldn't write manifest: " + filename + "\n"));
return;
}
deferred.resolve(null);
});
return deferred.promise;
},
_writeManifest: function(dir) {
return this._readFile(dir + "/jar.mn").then((data) => {
// The file data is contained within inputStream.
// You can read it into a string with
let entries = [];
let lines = data.split(/\n/);
let preprocessed = /^\s*\*/;
let contentEntry = new RegExp("^\\s+content/(\\w+)/(\\S+)\\s+\\((\\S+)\\)");
for (let line of lines) {
if (preprocessed.test(line)) {
dump("Unable to override preprocessed file: " + line + "\n");
continue;
}
let match = contentEntry.exec(line);
if (match) {
let entry = "override chrome://" + match[1] + "/content/" + match[2] + "\tfile://" + dir + "/" + match[3];
entries.push(entry);
}
}
return this._writeFile(dir + "/chrome.manifest", entries.join("\n"));
}).then(() => {
Components.manager.addBootstrappedManifestLocation(new FileUtils.File(dir));
});
}
};
this.devtools = {
_provider: null,
get main() this._provider.main,
// This is a gross gross hack. In one place (computed-view.js) we use
// Iterator, but the addon-sdk loader takes Iterator off the global.
// Give computed-view.js a way to get back to the Iterator until we have
// a chance to fix that crap.
_Iterator: Iterator,
setProvider: function(provider) {
if (provider === this._provider) {
return;
}
if (this._provider) {
delete this.require;
this._provider.unload("newprovider");
gDevTools._teardown();
}
this._provider = provider;
this._provider.load();
this.require = loader.Require(this._provider.loader, { id: "devtools" })
let exports = this._provider.main;
// Let clients find exports on this object.
Object.getOwnPropertyNames(exports).forEach(key => {
XPCOMUtils.defineLazyGetter(this, key, () => exports[key]);
});
},
/**
* Choose a default tools provider based on the preferences.
*/
_chooseProvider: function() {
if (Services.prefs.prefHasUserValue("devtools.loader.srcdir")) {
this.setProvider(SrcdirProvider);
} else {
this.setProvider(BuiltinProvider);
}
},
/**
* Reload the current provider.
*/
reload: function() {
var events = devtools.require("sdk/system/events");
events.emit("startupcache-invalidate", {});
this._provider.unload("reload");
delete this._provider;
gDevTools._teardown();
this._chooseProvider();
},
};
const FORBIDDEN_IDS = new Set(["toolbox", ""]);
@ -34,11 +207,6 @@ this.DevTools = function DevTools() {
EventEmitter.decorate(this);
Services.obs.addObserver(this.destroy, "quit-application", false);
// Register the set of default tools
for (let definition of defaultTools) {
this.registerTool(definition);
}
}
DevTools.prototype = {
@ -107,13 +275,13 @@ DevTools.prototype = {
},
getDefaultTools: function DT_getDefaultTools() {
return defaultTools;
return devtools.defaultTools;
},
getAdditionalTools: function DT_getAdditionalTools() {
let tools = [];
for (let [key, value] of this._tools) {
if (defaultTools.indexOf(value) == -1) {
if (devtools.defaultTools.indexOf(value) == -1) {
tools.push(value);
}
}
@ -216,7 +384,7 @@ DevTools.prototype = {
}
else {
// No toolbox for target, create one
toolbox = new Toolbox(target, toolId, hostType);
toolbox = new devtools.Toolbox(target, toolId, hostType);
this._toolboxes.set(target, toolbox);
@ -269,6 +437,15 @@ DevTools.prototype = {
return toolbox.destroy();
},
/**
* Called to tear down a tools provider.
*/
_teardown: function DT_teardown() {
for (let [target, toolbox] of this._toolboxes) {
toolbox.destroy();
}
},
/**
* All browser windows have been closed, tidy up remaining objects.
*/
@ -311,12 +488,20 @@ let gDevToolsBrowser = {
* of there
*/
toggleToolboxCommand: function(gBrowser) {
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = gDevTools.getToolbox(target);
toolbox ? toolbox.destroy() : gDevTools.showToolbox(target);
},
toggleBrowserToolboxCommand: function(gBrowser) {
let target = devtools.TargetFactory.forWindow(gBrowser.ownerDocument.defaultView);
let toolbox = gDevTools.getToolbox(target);
toolbox ? toolbox.destroy()
: gDevTools.showToolbox(target, "inspector", Toolbox.HostType.WINDOW);
},
/**
* This function is for the benefit of Tools:{toolId} commands,
* triggered from the WebDeveloper menu and keyboard shortcuts.
@ -332,11 +517,11 @@ let gDevToolsBrowser = {
* and the host is a window, we raise the toolbox window
*/
selectToolCommand: function(gBrowser, toolId) {
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = gDevTools.getToolbox(target);
if (toolbox && toolbox.currentToolId == toolId) {
if (toolbox.hostType == Toolbox.HostType.WINDOW) {
if (toolbox.hostType == devtools.Toolbox.HostType.WINDOW) {
toolbox.raise();
} else {
toolbox.destroy();
@ -563,8 +748,8 @@ let gDevToolsBrowser = {
for (let win of gDevToolsBrowser._trackedBrowserWindows) {
let hasToolbox = false;
if (TargetFactory.isKnownTab(win.gBrowser.selectedTab)) {
let target = TargetFactory.forTab(win.gBrowser.selectedTab);
if (devtools.TargetFactory.isKnownTab(win.gBrowser.selectedTab)) {
let target = devtools.TargetFactory.forTab(win.gBrowser.selectedTab);
if (gDevTools._toolboxes.has(target)) {
hasToolbox = true;
}
@ -682,3 +867,6 @@ gDevTools.on("toolbox-ready", gDevToolsBrowser._updateMenuCheckbox);
gDevTools.on("toolbox-destroyed", gDevToolsBrowser._updateMenuCheckbox);
Services.obs.addObserver(gDevToolsBrowser.destroy, "quit-application", false);
// Now load the tools.
devtools._chooseProvider();

View File

@ -4,12 +4,8 @@
* 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/. */
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
this.EXPORTED_SYMBOLS = ["ToolSidebar"];
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
var Promise = require("sdk/core/promise");
var EventEmitter = require("devtools/shared/event-emitter");
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -24,7 +20,7 @@ const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
* @param {Boolean} showTabstripe
* Show the tabs.
*/
this.ToolSidebar = function ToolSidebar(tabbox, panel, showTabstripe=true)
function ToolSidebar(tabbox, panel, showTabstripe=true)
{
EventEmitter.decorate(this);
@ -41,6 +37,8 @@ this.ToolSidebar = function ToolSidebar(tabbox, panel, showTabstripe=true)
}
}
exports.ToolSidebar = ToolSidebar;
ToolSidebar.prototype = {
/**
* Register a tab. A tab is a document.

View File

@ -4,17 +4,14 @@
"use strict";
this.EXPORTED_SYMBOLS = [ "TargetFactory" ];
const {Cc, Ci, Cu} = require("chrome");
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
var Promise = require("sdk/core/promise");
var EventEmitter = require("devtools/shared/event-emitter");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerServer",
"resource://gre/modules/devtools/dbg-server.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerClient",
"resource://gre/modules/devtools/dbg-client.jsm");
@ -24,7 +21,7 @@ const promiseTargets = new WeakMap();
/**
* Functions for creating Targets
*/
this.TargetFactory = {
exports.TargetFactory = {
/**
* Construct a Target
* @param {XULTab} tab
@ -95,8 +92,8 @@ this.TargetFactory = {
*/
allTargets: function TF_allTargets() {
let windows = [];
let wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let en = wm.getXULWindowEnumerator(null);
while (en.hasMoreElements()) {
windows.push(en.getNext());

View File

@ -7,10 +7,8 @@ const Cu = Components.utils;
const toolId = "test-tool";
let tempScope = {};
Cu.import("resource:///modules/devtools/EventEmitter.jsm", tempScope);
Cu.import("resource:///modules/devtools/shared/event-emitter.js", tempScope);
let EventEmitter = tempScope.EventEmitter;
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
function test() {
addTab("about:blank", function(aBrowser, aTab) {

View File

@ -8,8 +8,6 @@ const Cu = Components.utils;
let toolbox, target;
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
function test() {
addTab("about:blank", function(aBrowser, aTab) {

View File

@ -2,10 +2,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
var TargetFactory = tempScope.TargetFactory;
var target;
function test()

View File

@ -4,10 +4,6 @@
let toolbox;
let temp = {};
Cu.import("resource:///modules/devtools/Target.jsm", temp);
let TargetFactory = temp.TargetFactory;
function test()
{
waitForExplicitFinish();

View File

@ -6,11 +6,7 @@ let temp = {}
Cu.import("resource:///modules/devtools/gDevTools.jsm", temp);
let DevTools = temp.DevTools;
Cu.import("resource:///modules/devtools/Toolbox.jsm", temp);
let Toolbox = temp.Toolbox;
Cu.import("resource:///modules/devtools/Target.jsm", temp);
let TargetFactory = temp.TargetFactory;
let Toolbox = devtools.Toolbox;
let toolbox, target;

View File

@ -1,9 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let doc = null, toolbox = null, panelWin = null, index = 0, prefValues = [], prefNodes = [];
function test() {

View File

@ -2,10 +2,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
function test()
{
waitForExplicitFinish();

View File

@ -3,11 +3,7 @@
function test() {
const Cu = Components.utils;
let tempScope = {};
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
Cu.import("resource:///modules/devtools/Sidebar.jsm", tempScope);
let {TargetFactory: TargetFactory, gDevTools: gDevTools, ToolSidebar: ToolSidebar} = tempScope;
let {ToolSidebar} = devtools.require("devtools/framework/sidebar");
const toolURL = "data:text/xml;charset=utf8,<?xml version='1.0'?>" +
"<?xml-stylesheet href='chrome://browser/skin/devtools/common.css' type='text/css'?>" +

View File

@ -1,10 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let temp = {};
Cu.import("resource:///modules/devtools/Toolbox.jsm", temp);
let Toolbox = temp.Toolbox;
temp = null;
let Toolbox = devtools.Toolbox;
let toolbox, toolIDs, idIndex;

View File

@ -1,16 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let Toolbox = devtools.Toolbox;
let temp = {};
Cu.import("resource:///modules/devtools/Toolbox.jsm", temp);
let Toolbox = temp.Toolbox;
temp = {};
Cu.import("resource:///modules/devtools/Target.jsm", temp);
let TargetFactory = temp.TargetFactory;
temp = {};
Cu.import("resource:///modules/devtools/gDevTools.jsm", temp);
let gDevTools = temp.gDevTools;
temp = {};
Cu.import("resource://gre/modules/Services.jsm", temp);
let Services = temp.Services;
temp = null;

View File

@ -2,14 +2,17 @@
* 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/. */
let TargetFactory = gDevTools.TargetFactory;
let tempScope = {};
Components.utils.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope);
let console = tempScope.console;
Components.utils.import("resource://gre/modules/commonjs/sdk/core/promise.js", tempScope);
let Promise = tempScope.Promise;
let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
/**
* Open a new tab at a URL and call a callback on load
*/

View File

@ -4,13 +4,12 @@
"use strict";
const Cu = Components.utils;
const {Cu} = require("chrome");
let Promise = require("sdk/core/promise");
let EventEmitter = require("devtools/shared/event-emitter");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
this.EXPORTED_SYMBOLS = [ "Hosts" ];
/**
* A toolbox host represents an object that contains a toolbox (e.g. the
@ -21,7 +20,7 @@ this.EXPORTED_SYMBOLS = [ "Hosts" ];
* destroy() - destroy the host's UI
*/
this.Hosts = {
exports.Hosts = {
"bottom": BottomHost,
"side": SidebarHost,
"window": WindowHost

View File

@ -4,16 +4,17 @@
"use strict";
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const {Cc, Ci, Cu} = require("chrome");
let Promise = require("sdk/core/promise");
let EventEmitter = require("devtools/shared/event-emitter");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Hosts",
"resource:///modules/devtools/ToolboxHosts.jsm");
loader.lazyGetter(this, "Hosts", () => require("devtools/framework/toolbox-hosts").Hosts);
XPCOMUtils.defineLazyModuleGetter(this, "CommandUtils",
"resource:///modules/devtools/DeveloperToolbar.jsm");
@ -34,78 +35,14 @@ XPCOMUtils.defineLazyGetter(this, "toolboxStrings", function() {
});
XPCOMUtils.defineLazyGetter(this, "Requisition", function() {
Cu.import("resource://gre/modules/devtools/Require.jsm");
Cu.import("resource:///modules/devtools/gcli.jsm");
let scope = {};
Cu.import("resource://gre/modules/devtools/Require.jsm", scope);
Cu.import("resource:///modules/devtools/gcli.jsm", scope);
return require('gcli/cli').Requisition;
let req = scope.require;
return req('gcli/cli').Requisition;
});
this.EXPORTED_SYMBOLS = [ "Toolbox" ];
// This isn't the best place for this, but I don't know what is right now
/**
* Implementation of 'promised', while we wait for bug 790195 to be fixed.
* @see Consuming promises in https://addons.mozilla.org/en-US/developers/docs/sdk/latest/packages/api-utils/promise.html
* @see https://bugzilla.mozilla.org/show_bug.cgi?id=790195
* @see https://github.com/mozilla/addon-sdk/blob/master/packages/api-utils/lib/promise.js#L179
*/
Promise.promised = (function() {
// Note: Define shortcuts and utility functions here in order to avoid
// slower property accesses and unnecessary closure creations on each
// call of this popular function.
var call = Function.call;
var concat = Array.prototype.concat;
// Utility function that does following:
// execute([ f, self, args...]) => f.apply(self, args)
function execute(args) { return call.apply(call, args); }
// Utility function that takes promise of `a` array and maybe promise `b`
// as arguments and returns promise for `a.concat(b)`.
function promisedConcat(promises, unknown) {
return promises.then(function(values) {
return Promise.resolve(unknown).then(function(value) {
return values.concat([ value ]);
});
});
}
return function promised(f, prototype) {
/**
Returns a wrapped `f`, which when called returns a promise that resolves to
`f(...)` passing all the given arguments to it, which by the way may be
promises. Optionally second `prototype` argument may be provided to be used
a prototype for a returned promise.
## Example
var promise = promised(Array)(1, promise(2), promise(3))
promise.then(console.log) // => [ 1, 2, 3 ]
**/
return function promised() {
// create array of [ f, this, args... ]
return concat.apply([ f, this ], arguments).
// reduce it via `promisedConcat` to get promised array of fulfillments
reduce(promisedConcat, Promise.resolve([], prototype)).
// finally map that to promise of `f.apply(this, args...)`
then(execute);
};
};
})();
/**
* Convert an array of promises to a single promise, which is resolved (with an
* array containing resolved values) only when all the component promises are
* resolved.
*/
Promise.all = Promise.promised(Array);
/**
* A "Toolbox" is the component that holds all the tools for one specific
* target. Visually, it's a document that includes the tools tabs and all
@ -118,7 +55,7 @@ Promise.all = Promise.promised(Array);
* @param {Toolbox.HostType} hostType
* Type of host that will host the toolbox (e.g. sidebar, window)
*/
this.Toolbox = function Toolbox(target, selectedTool, hostType) {
function Toolbox(target, selectedTool, hostType) {
this._target = target;
this._toolPanels = new Map();
@ -152,6 +89,7 @@ this.Toolbox = function Toolbox(target, selectedTool, hostType) {
gDevTools.on("tool-registered", this._toolRegistered);
gDevTools.on("tool-unregistered", this._toolUnregistered);
}
exports.Toolbox = Toolbox;
/**
* The toolbox can be 'hosted' either embedded in a browser window

View File

@ -10,8 +10,8 @@ Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
"resource:///modules/devtools/Target.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource:///modules/devtools/gDevTools.jsm");
/**
* 'inspect' command
@ -30,7 +30,7 @@ gcli.addCommand({
],
exec: function Command_inspect(args, context) {
let gBrowser = context.environment.chromeDocument.defaultView.gBrowser;
let target = TargetFactory.forTab(gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(gBrowser.selectedTab);
return gDevTools.showToolbox(target, "inspector").then(function(toolbox) {
toolbox.getCurrentPanel().selection.setNode(args.selector, "gcli");

View File

@ -13,3 +13,4 @@ include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools/
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/inspector

View File

@ -4,15 +4,11 @@
* 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/. */
const Cc = Components.classes;
const Cu = Components.utils;
const Ci = Components.interfaces;
const {Cc, Cu, Ci} = require("chrome");
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
const ENSURE_SELECTION_VISIBLE_DELAY = 50; // ms
this.EXPORTED_SYMBOLS = ["HTMLBreadcrumbs"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/DOMHelpers.jsm");
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
@ -44,7 +40,7 @@ const LOW_PRIORITY_ELEMENTS = {
* else select the node;
* . If the selected node is the last node displayed, append its first (if any).
*/
this.HTMLBreadcrumbs = function HTMLBreadcrumbs(aInspector)
function HTMLBreadcrumbs(aInspector)
{
this.inspector = aInspector;
this.selection = this.inspector.selection;
@ -54,6 +50,8 @@ this.HTMLBreadcrumbs = function HTMLBreadcrumbs(aInspector)
this._init();
}
exports.HTMLBreadcrumbs = HTMLBreadcrumbs;
HTMLBreadcrumbs.prototype = {
_init: function BC__init()
{

View File

@ -4,16 +4,13 @@
* 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/. */
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
const {Cu, Cc, Ci} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
this.EXPORTED_SYMBOLS = ["Highlighter"];
let EventEmitter = require("devtools/shared/event-emitter");
const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
// add ":visited" and ":link" after bug 713106 is fixed
@ -74,7 +71,7 @@ const PSEUDO_CLASSES = [":hover", ":active", ":focus"];
* @param aInspector Inspector panel.
* @param aToolbox The toolbox holding the inspector.
*/
this.Highlighter = function Highlighter(aTarget, aInspector, aToolbox)
function Highlighter(aTarget, aInspector, aToolbox)
{
this.target = aTarget;
this.tab = aTarget.tab;
@ -89,6 +86,8 @@ this.Highlighter = function Highlighter(aTarget, aInspector, aToolbox)
this._init();
}
exports.Highlighter = Highlighter;
Highlighter.prototype = {
get selection() {
return this.inspector.selection;

View File

@ -4,28 +4,20 @@
* 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/. */
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
const {Cc, Ci, Cu, Cr} = require("chrome");
this.EXPORTED_SYMBOLS = ["InspectorPanel"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/CssLogic.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "MarkupView",
"resource:///modules/devtools/MarkupView.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Selection",
"resource:///modules/devtools/Selection.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "HTMLBreadcrumbs",
"resource:///modules/devtools/Breadcrumbs.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Highlighter",
"resource:///modules/devtools/Highlighter.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ToolSidebar",
"resource:///modules/devtools/Sidebar.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SelectorSearch",
"resource:///modules/devtools/SelectorSearch.jsm");
let Promise = require("sdk/core/promise");
let EventEmitter = require("devtools/shared/event-emitter");
let {CssLogic} = require("devtools/styleinspector/css-logic");
loader.lazyGetter(this, "MarkupView", () => require("devtools/markupview/markup-view").MarkupView);
loader.lazyGetter(this, "Selection", () => require ("devtools/inspector/selection").Selection);
loader.lazyGetter(this, "HTMLBreadcrumbs", () => require("devtools/inspector/breadcrumbs").HTMLBreadcrumbs);
loader.lazyGetter(this, "Highlighter", () => require("devtools/inspector/highlighter").Highlighter);
loader.lazyGetter(this, "ToolSidebar", () => require("devtools/framework/sidebar").ToolSidebar);
loader.lazyGetter(this, "SelectorSearch", () => require("devtools/inspector/selector-search").SelectorSearch);
const LAYOUT_CHANGE_TIMER = 250;
@ -35,7 +27,7 @@ const LAYOUT_CHANGE_TIMER = 250;
* the markup view, and the sidebar (computed view, rule view
* and layout view).
*/
this.InspectorPanel = function InspectorPanel(iframeWindow, toolbox) {
function InspectorPanel(iframeWindow, toolbox) {
this._toolbox = toolbox;
this._target = toolbox._target;
this.panelDoc = iframeWindow.document;
@ -45,6 +37,8 @@ this.InspectorPanel = function InspectorPanel(iframeWindow, toolbox) {
EventEmitter.decorate(this);
}
exports.InspectorPanel = InspectorPanel;
InspectorPanel.prototype = {
/**
* open is effectively an asynchronous constructor
@ -623,18 +617,18 @@ InspectorPanel.prototype = {
/////////////////////////////////////////////////////////////////////////
//// Initializers
XPCOMUtils.defineLazyGetter(InspectorPanel.prototype, "strings",
loader.lazyGetter(InspectorPanel.prototype, "strings",
function () {
return Services.strings.createBundle(
"chrome://browser/locale/devtools/inspector.properties");
});
XPCOMUtils.defineLazyGetter(this, "clipboardHelper", function() {
loader.lazyGetter(this, "clipboardHelper", function() {
return Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
});
XPCOMUtils.defineLazyGetter(this, "DOMUtils", function () {
loader.lazyGetter(this, "DOMUtils", function () {
return Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
});

View File

@ -4,10 +4,8 @@
* 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/. */
const Cu = Components.utils;
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
this.EXPORTED_SYMBOLS = ["Selection"];
const {Cu} = require("chrome");
let EventEmitter = require("devtools/shared/event-emitter");
/**
* API
@ -58,13 +56,15 @@ this.EXPORTED_SYMBOLS = ["Selection"];
* the ndoe change.
*
*/
this.Selection = function Selection(node=null, track={attributes:true,detached:true}) {
function Selection(node=null, track={attributes:true,detached:true}) {
EventEmitter.decorate(this);
this._onMutations = this._onMutations.bind(this);
this.track = track;
this.setNode(node);
}
exports.Selection = Selection;
Selection.prototype = {
_node: null,
@ -162,7 +162,7 @@ Selection.prototype = {
isNode: function SN_isNode() {
return (this.node &&
!Components.utils.isDeadWrapper(this.node) &&
!Cu.isDeadWrapper(this.node) &&
this.node.ownerDocument &&
this.node.ownerDocument.defaultView &&
this.node instanceof this.node.ownerDocument.defaultView.Node);

View File

@ -4,13 +4,11 @@
"use strict";
const Cu = Components.utils;
const {Cu} = require("chrome");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AutocompletePopup",
"resource:///modules/devtools/AutocompletePopup.jsm");
this.EXPORTED_SYMBOLS = ["SelectorSearch"];
loader.lazyGetter(this, "AutocompletePopup", () => {
return Cu.import("resource:///modules/devtools/AutocompletePopup.jsm", {}).AutocompletePopup;
});
// Maximum number of selector suggestions shown in the panel.
const MAX_SUGGESTIONS = 15;
@ -28,7 +26,7 @@ const MAX_SUGGESTIONS = 15;
* The method to callback when a search is available.
* This method is called with the matched node as the first argument.
*/
this.SelectorSearch = function(aContentDocument, aInputNode, aCallback) {
function SelectorSearch(aContentDocument, aInputNode, aCallback) {
this.doc = aContentDocument;
this.callback = aCallback;
this.searchBox = aInputNode;
@ -66,7 +64,9 @@ this.SelectorSearch = function(aContentDocument, aInputNode, aCallback) {
this.searchBox.addEventListener("keypress", this._onSearchKeypress, true);
}
this.SelectorSearch.prototype = {
exports.SelectorSearch = SelectorSearch;
SelectorSearch.prototype = {
// The possible states of the query.
States: {

View File

@ -1,16 +1,9 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
let temp = {};
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", temp);
let Promise = temp.Promise;
temp = {};
Cu.import("resource:///modules/devtools/Toolbox.jsm", temp);
let Toolbox = temp.Toolbox;
temp = {};
Cu.import("resource:///modules/devtools/Target.jsm", temp);
let TargetFactory = temp.TargetFactory;
temp = null;
let Promise = devtools.require("sdk/core/promise");
let Toolbox = devtools.Toolbox;
let TargetFactory = devtools.TargetFactory;
function test() {
waitForExplicitFinish();

View File

@ -6,10 +6,6 @@
let doc;
let salutation;
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
function createDocument()
{
doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' +

View File

@ -1,10 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"].getService(Ci.inIDOMUtils);
let doc;

View File

@ -1,10 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let doc;
let inspector;

View File

@ -8,8 +8,10 @@ const Cc = Components.classes;
let tempScope = {};
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm", tempScope);
let LayoutHelpers = tempScope.LayoutHelpers;
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
let TargetFactory = devtools.TargetFactory;
Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope);
let console = tempScope.console;
@ -146,3 +148,4 @@ function focusSearchBoxUsingShortcut(panelWin, callback) {
}, false);
EventUtils.synthesizeKey(name, modifiers);
}

View File

@ -24,7 +24,8 @@ let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).req
Components.utils.import("resource:///modules/devtools/gcli.jsm", {});
let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console;
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise;
let assert = { ok: ok, is: is, log: info };

View File

@ -1,9 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
function test() {
waitForExplicitFinish();

View File

@ -9,9 +9,10 @@
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource:///modules/devtools/CssLogic.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
let {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
function LayoutView(aInspector, aWindow)
{
this.inspector = aInspector;

View File

@ -4,71 +4,57 @@
"use strict";
this.EXPORTED_SYMBOLS = [
"defaultTools",
"webConsoleDefinition",
"debuggerDefinition",
"inspectorDefinition",
"styleEditorDefinition",
"netMonitorDefinition"
];
const {Cc, Ci, Cu} = require("chrome");
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
// Add a couple of globals that we use all over this package.
let loaderOptions = require("@loader/options")
loaderOptions.globals.loader = {
lazyGetter: XPCOMUtils.defineLazyGetter.bind(XPCOMUtils),
lazyImporter: XPCOMUtils.defineLazyModuleGetter.bind(XPCOMUtils)
};
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
Object.defineProperty(exports, "Toolbox", {
get: () => require("devtools/framework/toolbox").Toolbox
});
Object.defineProperty(exports, "TargetFactory", {
get: () => require("devtools/framework/target").TargetFactory
});
loader.lazyGetter(this, "osString", () => Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS);
// Panels
loader.lazyGetter(this, "InspectorPanel", function() require("devtools/inspector/inspector-panel").InspectorPanel);
loader.lazyImporter(this, "WebConsolePanel", "resource:///modules/WebConsolePanel.jsm");
loader.lazyImporter(this, "DebuggerPanel", "resource:///modules/devtools/DebuggerPanel.jsm");
loader.lazyImporter(this, "StyleEditorPanel", "resource:///modules/devtools/StyleEditorPanel.jsm");
loader.lazyImporter(this, "ProfilerPanel", "resource:///modules/devtools/ProfilerPanel.jsm");
loader.lazyImporter(this, "NetMonitorPanel", "resource:///modules/devtools/NetMonitorPanel.jsm");
// Strings
const inspectorProps = "chrome://browser/locale/devtools/inspector.properties";
const debuggerProps = "chrome://browser/locale/devtools/debugger.properties";
const styleEditorProps = "chrome://browser/locale/devtools/styleeditor.properties";
const webConsoleProps = "chrome://browser/locale/devtools/webconsole.properties";
const profilerProps = "chrome://browser/locale/devtools/profiler.properties";
const netMonitorProps = "chrome://browser/locale/devtools/netmonitor.properties";
loader.lazyGetter(this, "webConsoleStrings", () => Services.strings.createBundle(webConsoleProps));
loader.lazyGetter(this, "debuggerStrings", () => Services.strings.createBundle(debuggerProps));
loader.lazyGetter(this, "styleEditorStrings", () => Services.strings.createBundle(styleEditorProps));
loader.lazyGetter(this, "inspectorStrings", () => Services.strings.createBundle(inspectorProps));
loader.lazyGetter(this, "profilerStrings",() => Services.strings.createBundle(profilerProps));
loader.lazyGetter(this, "netMonitorStrings", () => Services.strings.createBundle(netMonitorProps));
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
XPCOMUtils.defineLazyGetter(this, "osString",
function() Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).OS);
// Panels
XPCOMUtils.defineLazyModuleGetter(this, "WebConsolePanel",
"resource:///modules/WebConsolePanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DebuggerPanel",
"resource:///modules/devtools/DebuggerPanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "StyleEditorPanel",
"resource:///modules/devtools/StyleEditorPanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "InspectorPanel",
"resource:///modules/devtools/InspectorPanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ProfilerPanel",
"resource:///modules/devtools/ProfilerPanel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetMonitorPanel",
"resource:///modules/devtools/NetMonitorPanel.jsm");
// Strings
XPCOMUtils.defineLazyGetter(this, "webConsoleStrings",
function() Services.strings.createBundle(webConsoleProps));
XPCOMUtils.defineLazyGetter(this, "debuggerStrings",
function() Services.strings.createBundle(debuggerProps));
XPCOMUtils.defineLazyGetter(this, "styleEditorStrings",
function() Services.strings.createBundle(styleEditorProps));
XPCOMUtils.defineLazyGetter(this, "inspectorStrings",
function() Services.strings.createBundle(inspectorProps));
XPCOMUtils.defineLazyGetter(this, "profilerStrings",
function() Services.strings.createBundle(profilerProps));
XPCOMUtils.defineLazyGetter(this, "netMonitorStrings",
function() Services.strings.createBundle(netMonitorProps));
let Tools = {};
exports.Tools = Tools;
// Definitions
let webConsoleDefinition = {
Tools.webConsole = {
id: "webconsole",
key: l10n("cmd.commandkey", webConsoleStrings),
accesskey: l10n("webConsoleCmd.accesskey", webConsoleStrings),
@ -88,7 +74,7 @@ let webConsoleDefinition = {
}
};
let debuggerDefinition = {
Tools.jsdebugger = {
id: "jsdebugger",
key: l10n("open.commandkey", debuggerStrings),
accesskey: l10n("debuggerMenu.accesskey", debuggerStrings),
@ -110,7 +96,7 @@ let debuggerDefinition = {
}
};
let inspectorDefinition = {
Tools.inspector = {
id: "inspector",
accesskey: l10n("inspector.accesskey", inspectorStrings),
key: l10n("inspector.commandkey", inspectorStrings),
@ -131,7 +117,7 @@ let inspectorDefinition = {
}
};
let styleEditorDefinition = {
Tools.styleEditor = {
id: "styleeditor",
key: l10n("open.commandkey", styleEditorStrings),
ordinal: 3,
@ -152,7 +138,7 @@ let styleEditorDefinition = {
}
};
let profilerDefinition = {
Tools.jsprofiler = {
id: "jsprofiler",
accesskey: l10n("profiler.accesskey", profilerStrings),
key: l10n("profiler2.commandkey", profilerStrings),
@ -174,7 +160,7 @@ let profilerDefinition = {
}
};
let netMonitorDefinition = {
Tools.netMonitor = {
id: "netmonitor",
accesskey: l10n("netmonitor.accesskey", netMonitorStrings),
key: l10n("netmonitor.commandkey", netMonitorStrings),
@ -196,15 +182,33 @@ let netMonitorDefinition = {
}
};
this.defaultTools = [
styleEditorDefinition,
webConsoleDefinition,
debuggerDefinition,
inspectorDefinition,
profilerDefinition,
netMonitorDefinition
let defaultTools = [
Tools.styleEditor,
Tools.webConsole,
Tools.jsdebugger,
Tools.inspector,
Tools.jsprofiler,
Tools.netMonitor
];
exports.defaultTools = defaultTools;
for (let definition of defaultTools) {
gDevTools.registerTool(definition);
}
var unloadObserver = {
observe: function(subject, topic, data) {
if (subject.wrappedJSObject === require("@loader/unload")) {
Services.obs.removeObserver(unloadObserver, "sdk:loader:destroy");
for (let definition of defaultTools) {
gDevTools.unregisterTool(definition.id);
}
}
}
};
Services.obs.addObserver(unloadObserver, "sdk:loader:destroy", false);
/**
* Lookup l10n string from a string bundle.
*

View File

@ -11,6 +11,6 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
libs::
$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/markupview
include $(topsrcdir)/config/rules.mk

View File

@ -4,9 +4,7 @@
* 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/. */
const Cc = Components.classes;
const Cu = Components.utils;
const Ci = Components.interfaces;
const {Cc, Cu, Ci} = require("chrome");
// Page size for pageup/pagedown
const PAGE_SIZE = 10;
@ -14,15 +12,13 @@ const PAGE_SIZE = 10;
const PREVIEW_AREA = 700;
const DEFAULT_MAX_CHILDREN = 100;
this.EXPORTED_SYMBOLS = ["MarkupView"];
let {UndoStack} = require("devtools/shared/undo");
let EventEmitter = require("devtools/shared/event-emitter");
let {editableField, InplaceEditor} = require("devtools/shared/inplace-editor");
Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
Cu.import("resource:///modules/devtools/InplaceEditor.jsm");
Cu.import("resource:///modules/devtools/Templater.jsm");
Cu.import("resource:///modules/devtools/Undo.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
/**
* Vocabulary for the purposes of this file:
@ -42,7 +38,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
* @param iframe aFrame
* An iframe in which the caller has kindly loaded markup-view.xhtml.
*/
this.MarkupView = function MarkupView(aInspector, aFrame, aControllerWindow)
function MarkupView(aInspector, aFrame, aControllerWindow)
{
this._inspector = aInspector;
this._frame = aFrame;
@ -75,6 +71,8 @@ this.MarkupView = function MarkupView(aInspector, aFrame, aControllerWindow)
this._initPreview();
}
exports.MarkupView = MarkupView;
MarkupView.prototype = {
_selectedContainer: null,
@ -1526,7 +1524,6 @@ function whitespaceTextFilter(aNode)
}
}
XPCOMUtils.defineLazyGetter(MarkupView.prototype, "strings", function () {
return Services.strings.createBundle(
"chrome://browser/locale/devtools/inspector.properties");
});
loader.lazyGetter(MarkupView.prototype, "strings", () => Services.strings.createBundle(
"chrome://browser/locale/devtools/inspector.properties"
));

View File

@ -20,7 +20,7 @@ function test() {
let inspector;
let {
getInplaceEditorForSpan: inplaceEditor
} = Cu.import("resource:///modules/devtools/InplaceEditor.jsm", {});
} = devtools.require("devtools/shared/inplace-editor");
waitForExplicitFinish();

View File

@ -4,11 +4,8 @@
const Cu = Components.utils;
let TargetFactory = (function() {
let tempScope = {};
Components.utils.import("resource:///modules/devtools/Target.jsm", tempScope);
return tempScope.TargetFactory;
})();
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
// Clear preferences that may be set during the course of tests.
function clearUserPrefs()

View File

@ -24,4 +24,3 @@ DIRS += [
'fontinspector',
]

View File

@ -10,7 +10,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
this.EXPORTED_SYMBOLS = ["NetMonitorPanel"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/sdk/core/promise.js");

View File

@ -13,7 +13,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/source-editor.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource:///modules/devtools/SideMenuWidget.jsm");
Cu.import("resource:///modules/devtools/VariablesView.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");

View File

@ -6,9 +6,9 @@ const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
let { Promise } = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {});
let { TargetFactory } = Cu.import("resource:///modules/devtools/Target.jsm", {});
let { Toolbox } = Cu.import("resource:///modules/devtools/Toolbox.jsm", {});
let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let { gDevTools, devtools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
let Toolbox = devtools.Toolbox;
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/netmonitor/test/";

View File

@ -9,7 +9,7 @@ const Cu = Components.utils;
Cu.import("resource:///modules/devtools/gDevTools.jsm");
Cu.import("resource:///modules/devtools/ProfilerController.jsm");
Cu.import("resource:///modules/devtools/ProfilerHelpers.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
this.EXPORTED_SYMBOLS = ["ProfilerPanel"];

View File

@ -5,11 +5,9 @@ let temp = {};
const PROFILER_ENABLED = "devtools.profiler.enabled";
const REMOTE_ENABLED = "devtools.debugger.remote-enabled";
Cu.import("resource:///modules/devtools/Target.jsm", temp);
let TargetFactory = temp.TargetFactory;
Cu.import("resource:///modules/devtools/gDevTools.jsm", temp);
let gDevTools = temp.gDevTools;
let TargetFactory = temp.devtools.TargetFactory;
Cu.import("resource://gre/modules/devtools/dbg-server.jsm", temp);
let DebuggerServer = temp.DebuggerServer;

View File

@ -11,8 +11,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
Cu.import("resource:///modules/devtools/FloatingScrollbars.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/Target.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
this.EXPORTED_SYMBOLS = ["ResponsiveUIManager"];

View File

@ -79,6 +79,9 @@ function test() {
info("waiting for responsive mode to turn off");
mgr.once("off", restart);
// Force document reflow to avoid intermittent failures.
info("document height " + document.height);
// We're still in the loop of initializing the responsive mode.
// Let's wait next loop to stop it.
executeSoon(function() {

View File

@ -3,9 +3,8 @@
"use strict";
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
// Import the GCLI test helper
let testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));

View File

@ -24,7 +24,8 @@ let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).req
Components.utils.import("resource:///modules/devtools/gcli.jsm", {});
let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console;
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let devtools = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools;
let TargetFactory = devtools.TargetFactory;
let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise;
let assert = { ok: ok, is: is, log: info };

View File

@ -27,7 +27,6 @@ Cu.import("resource:///modules/devtools/LayoutHelpers.jsm");
Cu.import("resource:///modules/devtools/scratchpad-manager.jsm");
Cu.import("resource://gre/modules/jsdebugger.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
Cu.import("resource:///modules/devtools/Target.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
@ -1095,7 +1094,7 @@ var Scratchpad = {
*/
openWebConsole: function SP_openWebConsole()
{
let target = TargetFactory.forTab(this.gBrowser.selectedTab);
let target = devtools.TargetFactory.forTab(this.gBrowser.selectedTab);
gDevTools.showToolbox(target, "webconsole");
this.browserWindow.focus();
},

View File

@ -30,8 +30,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener",
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "TargetFactory",
"resource:///modules/devtools/Target.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "devtools",
"resource:///modules/devtools/gDevTools.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "require",
"resource://gre/modules/devtools/Require.jsm");
@ -162,7 +162,7 @@ let CommandUtils = {
Object.defineProperty(environment, "target", {
get: function() {
let tab = chromeDocument.defaultView.getBrowser().selectedTab;
return TargetFactory.forTab(tab);
return devtools.TargetFactory.forTab(tab);
},
enumerable: true
});

View File

@ -15,3 +15,4 @@ include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
$(NSINSTALL) $(srcdir)/widgets/*.jsm $(FINAL_TARGET)/modules/devtools
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/shared

View File

@ -2,13 +2,20 @@
* 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/. */
this.EXPORTED_SYMBOLS = ["EventEmitter"];
/**
* EventEmitter.
*/
this.EventEmitter = function EventEmitter() {};
if (typeof(require) === "function") {
module.exports = EventEmitter;
var {Cu} = require("chrome");
} else {
var EXPORTED_SYMBOLS = ["EventEmitter"];
var Cu = this["Components"].utils;
}
/**
* Decorate an object with event emitter functionality.
*
@ -102,7 +109,7 @@ EventEmitter.prototype = {
catch (ex) {
// Prevent a bad listener from interfering with the others.
let msg = ex + ": " + ex.stack;
Components.utils.reportError(msg);
Cu.reportError(msg);
dump(msg + "\n");
}
}

View File

@ -24,8 +24,7 @@
"use strict";
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Ci, Cu} = require("chrome");
const HTML_NS = "http://www.w3.org/1999/xhtml";
@ -35,11 +34,6 @@ const FOCUS_BACKWARD = Ci.nsIFocusManager.MOVEFOCUS_BACKWARD;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
this.EXPORTED_SYMBOLS = ["editableItem",
"editableField",
"getInplaceEditorForSpan",
"InplaceEditor"];
/**
* Mark a span editable. |editableField| will listen for the span to
* be focused and create an InlineEditor to handle text input.
@ -81,6 +75,8 @@ function editableField(aOptions)
});
}
exports.editableField = editableField;
/**
* Handle events for an element that should respond to
* clicks and sit in the editing tab order, and call
@ -94,7 +90,7 @@ function editableField(aOptions)
* @param {function} aCallback
* Called when the editor is activated.
*/
this.editableItem = function editableItem(aOptions, aCallback)
function editableItem(aOptions, aCallback)
{
let trigger = aOptions.trigger || "click"
let element = aOptions.element;
@ -136,16 +132,20 @@ this.editableItem = function editableItem(aOptions, aCallback)
element._editable = true;
}
exports.editableItem = this.editableItem;
/*
* Various API consumers (especially tests) sometimes want to grab the
* inplaceEditor expando off span elements. However, when each global has its
* own compartment, those expandos live on Xray wrappers that are only visible
* within this JSM. So we provide a little workaround here.
*/
this.getInplaceEditorForSpan = function getInplaceEditorForSpan(aSpan)
function getInplaceEditorForSpan(aSpan)
{
return aSpan.inplaceEditor;
};
exports.getInplaceEditorForSpan = getInplaceEditorForSpan;
function InplaceEditor(aOptions, aEvent)
{
@ -206,6 +206,8 @@ function InplaceEditor(aOptions, aEvent)
}
}
exports.InplaceEditor = InplaceEditor;
InplaceEditor.prototype = {
_createInput: function InplaceEditor_createEditor()
{

View File

@ -8,7 +8,7 @@ function test() {
function testEmitter(aObject) {
Cu.import("resource:///modules/devtools/EventEmitter.jsm", this);
Cu.import("resource:///modules/devtools/shared/event-emitter.js", this);
let emitter;

View File

@ -2,7 +2,8 @@
* 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/. */
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let {devtools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let TargetFactory = devtools.TargetFactory;
/**
* Open a new tab at a URL and call a callback on load

View File

@ -4,7 +4,18 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
const Cu = Components.utils;
Cu.import("resource:///modules/devtools/Undo.jsm")
let {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {});
let loader = new Loader.Loader({
paths: {
"": "resource://gre/modules/commonjs/",
"devtools": "resource:///modules/devtools",
},
globals: {},
});
let require = Loader.Require(loader, { id: "undo-test" })
let {UndoStack} = require("devtools/shared/undo");
const MAX_SIZE = 5;

View File

@ -3,9 +3,6 @@
/* 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/. */
const Cu = Components.utils;
this.EXPORTED_SYMBOLS = ["UndoStack"];
/**
* A simple undo stack manager.
@ -19,12 +16,14 @@ this.EXPORTED_SYMBOLS = ["UndoStack"];
* @param integer aMaxUndo Maximum number of undo steps.
* defaults to 50.
*/
this.UndoStack = function UndoStack(aMaxUndo)
function UndoStack(aMaxUndo)
{
this.maxUndo = aMaxUndo || 50;
this._stack = [];
}
exports.UndoStack = UndoStack;
UndoStack.prototype = {
// Current index into the undo stack. Is positioned after the last
// currently-applied change.

View File

@ -12,7 +12,7 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
"resource://gre/modules/commonjs/sdk/core/promise.js");

View File

@ -11,7 +11,7 @@ this.EXPORTED_SYMBOLS = ["StyleEditorPanel"];
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource:///modules/devtools/StyleEditorDebuggee.jsm");
Cu.import("resource:///modules/devtools/StyleEditorUI.jsm");
Cu.import("resource:///modules/devtools/StyleEditorUtil.jsm");

View File

@ -15,7 +15,7 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PluralForm.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource:///modules/devtools/StyleEditorUtil.jsm");
Cu.import("resource:///modules/devtools/SplitView.jsm");
Cu.import("resource:///modules/devtools/StyleSheetEditor.jsm");

View File

@ -15,7 +15,7 @@ Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/FileUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
Cu.import("resource:///modules/devtools/EventEmitter.jsm");
Cu.import("resource:///modules/devtools/shared/event-emitter.js");
Cu.import("resource:///modules/source-editor.jsm");
Cu.import("resource:///modules/devtools/StyleEditorUtil.jsm");

View File

@ -7,8 +7,8 @@ const TEST_BASE_HTTPS = "https://example.com/browser/browser/devtools/styleedito
const TEST_HOST = 'mochi.test:8888';
let tempScope = {};
Cu.import("resource:///modules/devtools/Target.jsm", tempScope);
let TargetFactory = tempScope.TargetFactory;
Cu.import("resource:///modules/devtools/gDevTools.jsm", tempScope);
let TargetFactory = tempScope.devtools.TargetFactory;
Components.utils.import("resource://gre/modules/devtools/Console.jsm", tempScope);
let console = tempScope.console;

View File

@ -24,7 +24,8 @@ let require = (Cu.import("resource://gre/modules/devtools/Require.jsm", {})).req
Components.utils.import("resource:///modules/devtools/gcli.jsm", {});
let console = (Cu.import("resource://gre/modules/devtools/Console.jsm", {})).console;
let TargetFactory = (Cu.import("resource:///modules/devtools/Target.jsm", {})).TargetFactory;
let devtools = (Cu.import("resource:///modules/devtools/gDevTools.jsm", {})).devtools;
let TargetFactory = devtools.TargetFactory;
let Promise = (Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {})).Promise;
let assert = { ok: ok, is: is, log: info };

View File

@ -13,4 +13,4 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
libs::
$(NSINSTALL) $(srcdir)/*.jsm $(FINAL_TARGET)/modules/devtools
$(NSINSTALL) $(srcdir)/*.js $(FINAL_TARGET)/modules/devtools/styleinspector

View File

@ -4,25 +4,22 @@
* 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/. */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
const FILTER_CHANGED_TIMEOUT = 300;
const {Cc, Ci, Cu} = require("chrome");
const HTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
let ToolDefinitions = require("main").Tools;
let {CssLogic} = require("devtools/styleinspector/css-logic");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/PluralForm.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/CssLogic.jsm");
Cu.import("resource:///modules/devtools/Templater.jsm");
Cu.import("resource:///modules/devtools/ToolDefinitions.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
this.EXPORTED_SYMBOLS = ["CssHtmlTree", "PropertyView"];
const FILTER_CHANGED_TIMEOUT = 300;
const HTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
/**
* Helper for long-running processes that should yield occasionally to
@ -46,7 +43,7 @@ this.EXPORTED_SYMBOLS = ["CssHtmlTree", "PropertyView"];
function UpdateProcess(aWin, aGenerator, aOptions)
{
this.win = aWin;
this.iter = Iterator(aGenerator);
this.iter = devtools._Iterator(aGenerator);
this.onItem = aOptions.onItem || function() {};
this.onBatch = aOptions.onBatch || function () {};
this.onDone = aOptions.onDone || function() {};
@ -120,7 +117,7 @@ UpdateProcess.prototype = {
* @params {StyleInspector} aStyleInspector The owner of this CssHtmlTree
* @constructor
*/
this.CssHtmlTree = function CssHtmlTree(aStyleInspector)
function CssHtmlTree(aStyleInspector)
{
this.styleWindow = aStyleInspector.window;
this.styleDocument = aStyleInspector.window.document;
@ -533,7 +530,7 @@ CssHtmlTree.prototype = {
* @param {string} aName the CSS property name for which this PropertyView
* instance will render the rules.
*/
this.PropertyView = function PropertyView(aTree, aName)
function PropertyView(aTree, aName)
{
this.tree = aTree;
this.name = aName;
@ -826,7 +823,7 @@ SelectorView.prototype = {
*
* These statuses are localized inside the styleinspector.properties string
* bundle.
* @see CssLogic.jsm - the CssLogic.STATUS array.
* @see css-logic.js - the CssLogic.STATUS array.
*
* @return {void}
*/
@ -935,7 +932,7 @@ SelectorView.prototype = {
if (contentSheet) {
let target = inspector.target;
if (styleEditorDefinition.isTargetSupported(target)) {
if (ToolDefinitions.styleEditor.isTargetSupported(target)) {
gDevTools.showToolbox(target, "styleeditor").then(function(toolbox) {
toolbox.getCurrentPanel().selectStyleSheet(styleSheet, line);
});
@ -951,3 +948,6 @@ SelectorView.prototype = {
}
},
};
exports.CssHtmlTree = CssHtmlTree;
exports.PropertyView = PropertyView;

View File

@ -35,8 +35,9 @@
<script type="application/javascript;version=1.8">
window.setPanel = function(panel, iframe) {
Components.utils.import("resource:///modules/devtools/StyleInspector.jsm");
this.computedview = new ComputedViewTool(panel, window, iframe);
let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {});
let inspector = devtools.require("devtools/styleinspector/style-inspector");
this.computedview = new inspector.ComputedViewTool(panel, window, iframe);
}
window.onunload = function() {
if (this.computedview) {

View File

@ -37,9 +37,8 @@
* - how browsers process CSS
* @constructor
*/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
const RX_UNIVERSAL_SELECTOR = /\s*\*\s*/g;
const RX_NOT = /:not\((.*?)\)/g;
@ -52,14 +51,14 @@ const RX_PSEUDO = /\s*:?:([\w-]+)(\(?\)?)\s*/g;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
this.EXPORTED_SYMBOLS = ["CssLogic", "CssSelector"];
this.CssLogic = function CssLogic()
function CssLogic()
{
// The cache of examined CSS properties.
_propertyInfos: {};
}
exports.CssLogic = CssLogic;
/**
* Special values for filter, in addition to an href these values can be used
*/
@ -1261,7 +1260,7 @@ CssRule.prototype = {
* @param {string} aSelector The selector that we wish to investigate.
* @param {Number} aIndex The index of the selector within it's rule.
*/
this.CssSelector = function CssSelector(aCssRule, aSelector, aIndex)
function CssSelector(aCssRule, aSelector, aIndex)
{
this._cssRule = aCssRule;
this.text = aSelector;
@ -1270,6 +1269,8 @@ this.CssSelector = function CssSelector(aCssRule, aSelector, aIndex)
this.selectorIndex = aIndex;
}
exports.CssSelector = CssSelector;
CssSelector.prototype = {
_matchId: null,

View File

@ -24,8 +24,9 @@
<script type="application/javascript;version=1.8">
window.setPanel = function(panel, iframe) {
Components.utils.import("resource:///modules/devtools/StyleInspector.jsm");
this.ruleview = new RuleViewTool(panel, window, iframe);
let {devtools} = Components.utils.import("resource:///modules/devtools/gDevTools.jsm", {});
let inspector = devtools.require("devtools/styleinspector/style-inspector");
this.ruleview = new inspector.RuleViewTool(panel, window, iframe);
}
window.onunload = function() {
if (this.ruleview) {

View File

@ -6,9 +6,13 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const {Cc, Ci, Cu} = require("chrome");
let {CssLogic} = require("devtools/styleinspector/css-logic");
let {InplaceEditor, editableField, editableItem} = require("devtools/shared/inplace-editor");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const HTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -27,16 +31,8 @@ const CSS_PROP_RE = /\s*([^:\s]*)\s*:\s*(.*?)\s*(?:! (important))?;?$/;
// Used to parse an external resource from a property value
const CSS_RESOURCE_RE = /url\([\'\"]?(.*?)[\'\"]?\)/;
const IOService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource:///modules/devtools/CssLogic.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/InplaceEditor.jsm");
this.EXPORTED_SYMBOLS = ["CssRuleView",
"_ElementStyle"];
const IOService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
/**
* Our model looks like this:
@ -94,7 +90,7 @@ function ElementStyle(aElement, aStore)
this.populate();
}
// We're exporting _ElementStyle for unit tests.
this._ElementStyle = ElementStyle;
exports._ElementStyle = ElementStyle;
ElementStyle.prototype = {
@ -869,7 +865,7 @@ TextProperty.prototype = {
* The iframe containing the ruleview.
* @constructor
*/
this.CssRuleView = function CssRuleView(aDoc, aStore)
function CssRuleView(aDoc, aStore)
{
this.doc = aDoc;
this.store = aStore;
@ -883,6 +879,8 @@ this.CssRuleView = function CssRuleView(aDoc, aStore)
this._showEmpty();
}
exports.CssRuleView = CssRuleView;
CssRuleView.prototype = {
// The element that we're inspecting.
_viewedElement: null,

View File

@ -4,29 +4,29 @@
* 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/. */
const Cc = Components.classes;
const Cu = Components.utils;
const Ci = Components.interfaces;
const {Cc, Cu, Ci} = require("chrome");
let ToolDefinitions = require("main").Tools;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/CssRuleView.jsm");
Cu.import("resource:///modules/devtools/ToolDefinitions.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "gDevTools",
"resource:///modules/devtools/gDevTools.jsm");
loader.lazyGetter(this, "gDevTools", () => Cu.import("resource:///modules/devtools/gDevTools.jsm", {}).gDevTools);
loader.lazyGetter(this, "RuleView", () => require("devtools/styleinspector/rule-view"));
loader.lazyGetter(this, "ComputedView", () => require("devtools/styleinspector/computed-view"));
loader.lazyGetter(this, "_strings", () => Services.strings
.createBundle("chrome://browser/locale/devtools/styleinspector.properties"));
loader.lazyGetter(this, "CssLogic", () => require("devtools/styleinspector/css-logic").CssLogic);
// This module doesn't currently export any symbols directly, it only
// registers inspector tools.
this.EXPORTED_SYMBOLS = ["RuleViewTool", "ComputedViewTool"];
this.RuleViewTool = function RVT_RuleViewTool(aInspector, aWindow, aIFrame)
function RuleViewTool(aInspector, aWindow, aIFrame)
{
this.inspector = aInspector;
this.doc = aWindow.document;
this.outerIFrame = aIFrame;
this.view = new CssRuleView(this.doc, null);
this.view = new RuleView.CssRuleView(this.doc, null);
this.doc.documentElement.appendChild(this.view.element);
this._changeHandler = function() {
@ -61,7 +61,7 @@ this.RuleViewTool = function RVT_RuleViewTool(aInspector, aWindow, aIFrame)
if (contentSheet) {
let target = this.inspector.target;
if (styleEditorDefinition.isTargetSupported(target)) {
if (ToolDefinitions.styleEditor.isTargetSupported(target)) {
gDevTools.showToolbox(target, "styleeditor").then(function(toolbox) {
toolbox.getCurrentPanel().selectStyleSheet(styleSheet, line);
});
@ -93,6 +93,8 @@ this.RuleViewTool = function RVT_RuleViewTool(aInspector, aWindow, aIFrame)
this.onSelect();
}
exports.RuleViewTool = RuleViewTool;
RuleViewTool.prototype = {
onSelect: function RVT_onSelect(aEvent) {
if (!this.inspector.selection.isConnected() ||
@ -150,14 +152,14 @@ RuleViewTool.prototype = {
}
}
this.ComputedViewTool = function CVT_ComputedViewTool(aInspector, aWindow, aIFrame)
function ComputedViewTool(aInspector, aWindow, aIFrame)
{
this.inspector = aInspector;
this.window = aWindow;
this.document = aWindow.document;
this.outerIFrame = aIFrame;
this.cssLogic = new CssLogic();
this.view = new CssHtmlTree(this);
this.view = new ComputedView.CssHtmlTree(this);
this._onSelect = this.onSelect.bind(this);
this.inspector.selection.on("detached", this._onSelect);
@ -176,6 +178,8 @@ this.ComputedViewTool = function CVT_ComputedViewTool(aInspector, aWindow, aIFra
this.onSelect();
}
exports.ComputedViewTool = ComputedViewTool;
ComputedViewTool.prototype = {
onSelect: function CVT_onSelect(aEvent)
{
@ -232,18 +236,3 @@ ComputedViewTool.prototype = {
delete this.inspector;
}
}
XPCOMUtils.defineLazyGetter(this, "_strings", function() Services.strings
.createBundle("chrome://browser/locale/devtools/styleinspector.properties"));
XPCOMUtils.defineLazyGetter(this, "CssLogic", function() {
let tmp = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tmp);
return tmp.CssLogic;
});
XPCOMUtils.defineLazyGetter(this, "CssHtmlTree", function() {
let tmp = {};
Cu.import("resource:///modules/devtools/CssHtmlTree.jsm", tmp);
return tmp.CssHtmlTree;
});

View File

@ -12,9 +12,7 @@ let computedView;
const TEST_URI = "http://example.com/browser/browser/devtools/styleinspector/test/browser_bug683672.html";
let tempScope = {};
Cu.import("resource:///modules/devtools/CssHtmlTree.jsm", tempScope);
let CssHtmlTree = tempScope.CssHtmlTree;
let PropertyView = tempScope.PropertyView;
let {CssHtmlTree, PropertyView} = devtools.require("devtools/styleinspector/computed-view");
function test()
{

View File

@ -18,9 +18,8 @@ const XUL_PRINCIPAL = Components.classes["@mozilla.org/scriptsecuritymanager;1"
.getService(Ci.nsIScriptSecurityManager)
.getNoAppCodebasePrincipal(XUL_URI);
let tempScope = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tempScope);
let CssLogic = tempScope.CssLogic;
let {CssLogic} = devtools.require("devtools/styleinspector/css-logic");
function test()
{

View File

@ -5,9 +5,6 @@
// Tests that we correctly display appropriate media query titles in the
// rule view.
let tempScope = {};
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let _ElementStyle = tempScope._ElementStyle;
let doc;
const TEST_URI = "http://example.com/browser/browser/devtools/styleinspector/" +

View File

@ -5,11 +5,6 @@
// Test that increasing/decreasing values in rule view using
// arrow keys works correctly.
let tempScope = {};
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let doc;
let ruleDialog;
let ruleView;

View File

@ -4,12 +4,8 @@
// Tests that CSS specificity is properly calculated.
let tempScope = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tempScope);
const DOMUtils = Cc["@mozilla.org/inspector/dom-utils;1"]
.getService(Ci.inIDOMUtils);
let CssLogic = tempScope.CssLogic;
let CssSelector = tempScope.CssSelector;
function createDocument()
{

View File

@ -4,10 +4,6 @@
// Test that inherited properties are treated correctly.
let tempScope = {};
Cu.import("resource:///modules/devtools/CssLogic.jsm", tempScope);
let CssLogic = tempScope.CssLogic;
let doc;
function createDocument()

View File

@ -2,11 +2,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {}
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let doc = content.document;
function expectDone(aValue, aCommit, aNext)

View File

@ -2,11 +2,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
let tempScope = {};
Cu.import("resource:///modules/devtools/CssRuleView.jsm", tempScope);
let CssRuleView = tempScope.CssRuleView;
let _ElementStyle = tempScope._ElementStyle;
let doc;
let ruleDialog;
let ruleView;

Some files were not shown because too many files have changed in this diff Show More