mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-01 12:03:08 +00:00
Merge m-c to inbound.
This commit is contained in:
commit
5a97bb58af
@ -593,7 +593,7 @@ pref("hal.processPriorityManager.gonk.FOREGROUND.Nice", 1);
|
||||
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.OomScoreAdjust", 200);
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.KillUnderMB", 7);
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.Nice", 10);
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_PERCEIVABLE.Nice", 7);
|
||||
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_HOMESCREEN.OomScoreAdjust", 267);
|
||||
pref("hal.processPriorityManager.gonk.BACKGROUND_HOMESCREEN.KillUnderMB", 8);
|
||||
|
@ -9,6 +9,8 @@ this.EXPORTED_SYMBOLS = [ "DeveloperToolbar", "CommandUtils" ];
|
||||
const NS_XHTML = "http://www.w3.org/1999/xhtml";
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource:///modules/devtools/Commands.jsm");
|
||||
@ -24,7 +26,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "gcli",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CmdCommands",
|
||||
"resource:///modules/devtools/BuiltinCommands.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleServiceListener",
|
||||
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
@ -435,8 +437,8 @@ DeveloperToolbar.prototype._initErrorsCount = function DT__initErrorsCount(aTab)
|
||||
}
|
||||
|
||||
let window = aTab.linkedBrowser.contentWindow;
|
||||
let listener = new PageErrorListener(window, {
|
||||
onPageError: this._onPageError.bind(this, tabId),
|
||||
let listener = new ConsoleServiceListener(window, {
|
||||
onConsoleServiceMessage: this._onPageError.bind(this, tabId),
|
||||
});
|
||||
listener.init();
|
||||
|
||||
@ -593,7 +595,8 @@ DeveloperToolbar.prototype.handleEvent = function DT_handleEvent(aEvent)
|
||||
DeveloperToolbar.prototype._onPageError =
|
||||
function DT__onPageError(aTabId, aPageError)
|
||||
{
|
||||
if (aPageError.category == "CSS Parser" ||
|
||||
if (!(aPageError instanceof Ci.nsIScriptError) ||
|
||||
aPageError.category == "CSS Parser" ||
|
||||
aPageError.category == "CSS Loader") {
|
||||
return;
|
||||
}
|
||||
|
@ -547,6 +547,10 @@ ViewHelpers.create({ constructor: BrowserConsole, proto: WebConsole.prototype },
|
||||
this._bc_init = this.$init().then((aReason) => {
|
||||
let title = this.ui.rootElement.getAttribute("browserConsoleTitle");
|
||||
this.ui.rootElement.setAttribute("title", title);
|
||||
|
||||
let cmd_close = this.ui.document.getElementById("cmd_close");
|
||||
cmd_close.removeAttribute("disabled");
|
||||
|
||||
return aReason;
|
||||
});
|
||||
|
||||
|
@ -129,6 +129,8 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_bug_869003_inspect_cross_domain_object.js \
|
||||
browser_bug_862916_console_dir_and_filter_off.js \
|
||||
browser_console_native_getters.js \
|
||||
browser_bug_871156_ctrlw_close_tab.js \
|
||||
browser_console_nsiconsolemessage.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the
|
||||
// current tab when using the Web Console - bug 871156.
|
||||
|
||||
function test()
|
||||
{
|
||||
const TEST_URI = "data:text/html;charset=utf8,<title>bug871156</title>\n" +
|
||||
"<p>hello world";
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
|
||||
function consoleOpened(hud)
|
||||
{
|
||||
ok(hud, "Web Console opened");
|
||||
|
||||
let tabClosed = false, toolboxDestroyed = false;
|
||||
|
||||
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
|
||||
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
|
||||
|
||||
ok(true, "tab closed");
|
||||
|
||||
tabClosed = true;
|
||||
if (toolboxDestroyed) {
|
||||
testBrowserConsole();
|
||||
}
|
||||
});
|
||||
|
||||
let toolbox = gDevTools.getToolbox(hud.target);
|
||||
toolbox.once("destroyed", () => {
|
||||
ok(true, "toolbox destroyed");
|
||||
|
||||
toolboxDestroyed = true;
|
||||
if (tabClosed) {
|
||||
testBrowserConsole();
|
||||
}
|
||||
});
|
||||
|
||||
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
|
||||
}
|
||||
|
||||
function testBrowserConsole()
|
||||
{
|
||||
info("test the Browser Console");
|
||||
|
||||
HUDConsoleUI.toggleBrowserConsole().then((hud) => {
|
||||
ok(hud, "Browser Console opened");
|
||||
|
||||
Services.obs.addObserver(function onDestroy() {
|
||||
Services.obs.removeObserver(onDestroy, "web-console-destroyed");
|
||||
ok(true, "the Browser Console closed");
|
||||
|
||||
executeSoon(finishTest);
|
||||
}, "web-console-destroyed", false);
|
||||
|
||||
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
// Check that nsIConsoleMessages show in the Browser Console and in the Web
|
||||
// Console. See bug 859756.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf8,<title>bug859756</title>\n" +
|
||||
"<p>hello world\n<p>nsIConsoleMessages ftw!";
|
||||
|
||||
let gWebConsole, gJSTerm, gVariablesView;
|
||||
|
||||
function test()
|
||||
{
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
|
||||
// Test for cached nsIConsoleMessages.
|
||||
sendMessage("test1 for bug859756", "cat2012");
|
||||
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function sendMessage(aMessage, aCategory)
|
||||
{
|
||||
let windowID = WebConsoleUtils.getInnerWindowId(content);
|
||||
let consoleMsg = Cc["@mozilla.org/consolemessage;1"]
|
||||
.createInstance(Ci.nsIConsoleMessage);
|
||||
consoleMsg.initMessage(aMessage, aCategory, windowID);
|
||||
Services.console.logMessage(consoleMsg);
|
||||
}
|
||||
|
||||
function consoleOpened(hud)
|
||||
{
|
||||
gWebConsole = hud;
|
||||
gJSTerm = hud.jsterm;
|
||||
|
||||
// Send a message with no window ID.
|
||||
Services.console.logStringMessage("do-not-show-me");
|
||||
|
||||
sendMessage("test2 for bug859756", "cat2013");
|
||||
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
text: "test1 for bug859756",
|
||||
category: CATEGORY_JS,
|
||||
},
|
||||
{
|
||||
text: "test2 for bug859756",
|
||||
category: CATEGORY_JS,
|
||||
},
|
||||
],
|
||||
}).then(onLogMessages);
|
||||
}
|
||||
|
||||
function onLogMessages()
|
||||
{
|
||||
let text = gWebConsole.outputNode.textContent;
|
||||
is(text.indexOf("do-not-show-me"), -1,
|
||||
"message without window ID is not displayed");
|
||||
closeConsole(null, onWebConsoleClose);
|
||||
}
|
||||
|
||||
function onWebConsoleClose()
|
||||
{
|
||||
HUDConsoleUI.toggleBrowserConsole().then(onBrowserConsoleOpen);
|
||||
}
|
||||
|
||||
function onBrowserConsoleOpen(hud)
|
||||
{
|
||||
waitForMessages({
|
||||
webconsole: hud,
|
||||
messages: [
|
||||
{
|
||||
text: "test1 for bug859756",
|
||||
category: CATEGORY_JS,
|
||||
},
|
||||
{
|
||||
text: "test2 for bug859756",
|
||||
category: CATEGORY_JS,
|
||||
},
|
||||
{
|
||||
text: "do-not-show-me",
|
||||
category: CATEGORY_JS,
|
||||
},
|
||||
],
|
||||
}).then(finishTest);
|
||||
}
|
@ -956,11 +956,14 @@ WebConsoleFrame.prototype = {
|
||||
aRemoteMessages.forEach(function(aMessage) {
|
||||
switch (aMessage._type) {
|
||||
case "PageError": {
|
||||
let category = Utils.categoryForScriptError(aMessage);
|
||||
let category = Utils.categoryForConsoleMessage(aMessage);
|
||||
this.outputMessage(category, this.reportPageError,
|
||||
[category, aMessage]);
|
||||
break;
|
||||
}
|
||||
case "LogMessage":
|
||||
this.handleLogMessage(aMessage);
|
||||
break;
|
||||
case "ConsoleAPI":
|
||||
this.outputMessage(CATEGORY_WEBDEV, this.logConsoleAPIMessage,
|
||||
[aMessage]);
|
||||
@ -1188,10 +1191,26 @@ WebConsoleFrame.prototype = {
|
||||
*/
|
||||
handlePageError: function WCF_handlePageError(aPageError)
|
||||
{
|
||||
let category = Utils.categoryForScriptError(aPageError);
|
||||
let category = Utils.categoryForConsoleMessage(aPageError);
|
||||
this.outputMessage(category, this.reportPageError, [category, aPageError]);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle log messages received from the server. This method outputs the given
|
||||
* message.
|
||||
*
|
||||
* @param object aPacket
|
||||
* The message packet received from the server.
|
||||
*/
|
||||
handleLogMessage: function WCF_handleLogMessage(aPacket)
|
||||
{
|
||||
let category = Utils.categoryForConsoleMessage(aPacket.category);
|
||||
this.outputMessage(category, () => {
|
||||
return this.createMessageNode(category, SEVERITY_LOG, aPacket.message,
|
||||
null, null, null, null, aPacket.timeStamp);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Log network event.
|
||||
*
|
||||
@ -4337,17 +4356,17 @@ var Utils = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine the category of a given nsIScriptError.
|
||||
* Determine the category of a given nsIConsoleMessage.
|
||||
*
|
||||
* @param nsIScriptError aScriptError
|
||||
* The script error you want to determine the category for.
|
||||
* @param nsIConsoleMessage aMessage
|
||||
* The message you want to determine the category for.
|
||||
* @return CATEGORY_JS|CATEGORY_CSS|CATEGORY_SECURITY
|
||||
* Depending on the script error CATEGORY_JS, CATEGORY_CSS, or
|
||||
* Depending on the message kind CATEGORY_JS, CATEGORY_CSS, or
|
||||
* CATEGORY_SECURITY can be returned.
|
||||
*/
|
||||
categoryForScriptError: function Utils_categoryForScriptError(aScriptError)
|
||||
categoryForConsoleMessage: function Utils_categoryForConsoleMessage(aMessage)
|
||||
{
|
||||
switch (aScriptError.category) {
|
||||
switch (aMessage.category) {
|
||||
case "CSS Parser":
|
||||
case "CSS Loader":
|
||||
return CATEGORY_CSS;
|
||||
@ -4508,6 +4527,7 @@ function WebConsoleConnectionProxy(aWebConsole, aTarget)
|
||||
this.target = aTarget;
|
||||
|
||||
this._onPageError = this._onPageError.bind(this);
|
||||
this._onLogMessage = this._onLogMessage.bind(this);
|
||||
this._onConsoleAPICall = this._onConsoleAPICall.bind(this);
|
||||
this._onNetworkEvent = this._onNetworkEvent.bind(this);
|
||||
this._onNetworkEventUpdate = this._onNetworkEventUpdate.bind(this);
|
||||
@ -4611,6 +4631,7 @@ WebConsoleConnectionProxy.prototype = {
|
||||
|
||||
let client = this.client = this.target.client;
|
||||
|
||||
client.addListener("logMessage", this._onLogMessage);
|
||||
client.addListener("pageError", this._onPageError);
|
||||
client.addListener("consoleAPICall", this._onConsoleAPICall);
|
||||
client.addListener("networkEvent", this._onNetworkEvent);
|
||||
@ -4731,6 +4752,23 @@ WebConsoleConnectionProxy.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The "logMessage" message type handler. We redirect any message to the UI
|
||||
* for displaying.
|
||||
*
|
||||
* @private
|
||||
* @param string aType
|
||||
* Message type.
|
||||
* @param object aPacket
|
||||
* The message received from the server.
|
||||
*/
|
||||
_onLogMessage: function WCCP__onLogMessage(aType, aPacket)
|
||||
{
|
||||
if (this.owner && aPacket.from == this._consoleActor) {
|
||||
this.owner.handleLogMessage(aPacket);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The "consoleAPICall" message type handler. We redirect any message to
|
||||
* the UI for displaying.
|
||||
@ -4858,6 +4896,7 @@ WebConsoleConnectionProxy.prototype = {
|
||||
}
|
||||
|
||||
this.client.removeListener("pageError", this._onPageError);
|
||||
this.client.removeListener("logMessage", this._onLogMessage);
|
||||
this.client.removeListener("consoleAPICall", this._onConsoleAPICall);
|
||||
this.client.removeListener("networkEvent", this._onNetworkEvent);
|
||||
this.client.removeListener("networkEventUpdate", this._onNetworkEventUpdate);
|
||||
|
@ -37,7 +37,7 @@
|
||||
<command id="cmd_fullZoomEnlarge" oncommand="goDoCommand('cmd_fontSizeEnlarge');"/>
|
||||
<command id="cmd_fullZoomReduce" oncommand="goDoCommand('cmd_fontSizeReduce');"/>
|
||||
<command id="cmd_fullZoomReset" oncommand="goDoCommand('cmd_fontSizeReset');"/>
|
||||
<command id="cmd_close" oncommand="goDoCommand('cmd_close');"/>
|
||||
<command id="cmd_close" oncommand="goDoCommand('cmd_close');" disabled="true"/>
|
||||
</commandset>
|
||||
<keyset id="consoleKeys">
|
||||
<key id="key_fullZoomReduce" key="&fullZoomReduceCmd.commandkey;" command="cmd_fullZoomReduce" modifiers="accel"/>
|
||||
|
@ -161,6 +161,7 @@
|
||||
background-repeat: no-repeat;
|
||||
background-position: left, right;
|
||||
border-right: 1px solid hsla(206,37%,4%,.45);
|
||||
-moz-box-align: center;
|
||||
}
|
||||
|
||||
.devtools-tab > image {
|
||||
|
@ -1525,29 +1525,32 @@ nsEventStateManager::IsRemoteTarget(nsIContent* target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
nsEventStateManager::MapEventCoordinatesForChildProcess(nsFrameLoader* aFrameLoader,
|
||||
nsEvent* aEvent)
|
||||
/*static*/ nsIntPoint
|
||||
nsEventStateManager::GetChildProcessOffset(nsFrameLoader* aFrameLoader,
|
||||
const nsEvent& aEvent)
|
||||
{
|
||||
// The "toplevel widget" in child processes is always at position
|
||||
// 0,0. Map the event coordinates to match that.
|
||||
nsIFrame* targetFrame = aFrameLoader->GetPrimaryFrameOfOwningContent();
|
||||
if (!targetFrame) {
|
||||
return;
|
||||
return nsIntPoint();
|
||||
}
|
||||
nsPresContext* presContext = targetFrame->PresContext();
|
||||
|
||||
// Find out how far we're offset from the nearest widget.
|
||||
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(&aEvent,
|
||||
targetFrame);
|
||||
return pt.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
nsEventStateManager::MapEventCoordinatesForChildProcess(
|
||||
const nsIntPoint& aOffset, nsEvent* aEvent)
|
||||
{
|
||||
if (aEvent->eventStructType != NS_TOUCH_EVENT) {
|
||||
nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent,
|
||||
targetFrame);
|
||||
aEvent->refPoint = pt.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||
aEvent->refPoint = aOffset;
|
||||
} else {
|
||||
aEvent->refPoint = nsIntPoint();
|
||||
// Find out how far we're offset from the nearest widget.
|
||||
nsPoint offset =
|
||||
nsLayoutUtils::GetEventCoordinatesRelativeTo(aEvent, targetFrame);
|
||||
nsIntPoint intOffset =
|
||||
offset.ToNearestPixels(presContext->AppUnitsPerDevPixel());
|
||||
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
|
||||
// Then offset all the touch points by that distance, to put them
|
||||
// in the space where top-left is 0,0.
|
||||
@ -1555,12 +1558,20 @@ nsEventStateManager::MapEventCoordinatesForChildProcess(nsFrameLoader* aFrameLoa
|
||||
for (uint32_t i = 0; i < touches.Length(); ++i) {
|
||||
nsIDOMTouch* touch = touches[i];
|
||||
if (touch) {
|
||||
touch->mRefPoint += intOffset;
|
||||
touch->mRefPoint += aOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
nsEventStateManager::MapEventCoordinatesForChildProcess(nsFrameLoader* aFrameLoader,
|
||||
nsEvent* aEvent)
|
||||
{
|
||||
nsIntPoint offset = GetChildProcessOffset(aFrameLoader, *aEvent);
|
||||
MapEventCoordinatesForChildProcess(offset, aEvent);
|
||||
}
|
||||
|
||||
bool
|
||||
CrossProcessSafeEvent(const nsEvent& aEvent)
|
||||
{
|
||||
|
@ -192,10 +192,15 @@ public:
|
||||
static void SetFullScreenState(mozilla::dom::Element* aElement, bool aIsFullScreen);
|
||||
|
||||
static bool IsRemoteTarget(nsIContent* aTarget);
|
||||
static nsIntPoint GetChildProcessOffset(nsFrameLoader* aFrameLoader,
|
||||
const nsEvent& aEvent);
|
||||
|
||||
static void MapEventCoordinatesForChildProcess(nsFrameLoader* aFrameLoader,
|
||||
nsEvent* aEvent);
|
||||
|
||||
static void MapEventCoordinatesForChildProcess(const nsIntPoint& aOffset,
|
||||
nsEvent* aEvent);
|
||||
|
||||
// Holds the point in screen coords that a mouse event was dispatched to,
|
||||
// before we went into pointer lock mode. This is constantly updated while
|
||||
// the pointer is not locked, but we don't update it while the pointer is
|
||||
|
@ -31,6 +31,9 @@ public:
|
||||
nsString mRootDir;
|
||||
nsString mPath;
|
||||
bool mEditable;
|
||||
nsString mMimeType;
|
||||
uint64_t mLength;
|
||||
uint64_t mLastModifiedDate;
|
||||
|
||||
// Used when the path will be set later via SetPath.
|
||||
DeviceStorageFile(const nsAString& aStorageType,
|
||||
@ -83,6 +86,10 @@ public:
|
||||
static void GetRootDirectoryForType(const nsAString& aStorageType,
|
||||
const nsAString& aStorageName,
|
||||
nsIFile** aFile);
|
||||
|
||||
nsresult CalculateSizeAndModifiedDate();
|
||||
nsresult CalculateMimeType();
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void NormalizeFilePath();
|
||||
|
@ -487,6 +487,8 @@ DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
|
||||
, mRootDir(aRootDir)
|
||||
, mPath(aPath)
|
||||
, mEditable(false)
|
||||
, mLength(UINT64_MAX)
|
||||
, mLastModifiedDate(UINT64_MAX)
|
||||
{
|
||||
Init();
|
||||
AppendRelativePath(mRootDir);
|
||||
@ -503,6 +505,8 @@ DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
|
||||
, mStorageName(aStorageName)
|
||||
, mPath(aPath)
|
||||
, mEditable(false)
|
||||
, mLength(UINT64_MAX)
|
||||
, mLastModifiedDate(UINT64_MAX)
|
||||
{
|
||||
Init();
|
||||
AppendRelativePath(aPath);
|
||||
@ -514,6 +518,8 @@ DeviceStorageFile::DeviceStorageFile(const nsAString& aStorageType,
|
||||
: mStorageType(aStorageType)
|
||||
, mStorageName(aStorageName)
|
||||
, mEditable(false)
|
||||
, mLength(UINT64_MAX)
|
||||
, mLastModifiedDate(UINT64_MAX)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
@ -958,6 +964,45 @@ DeviceStorageFile::Remove()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DeviceStorageFile::CalculateMimeType()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
nsAutoCString mimeType;
|
||||
nsCOMPtr<nsIMIMEService> mimeService =
|
||||
do_GetService(NS_MIMESERVICE_CONTRACTID);
|
||||
if (mimeService) {
|
||||
nsresult rv = mimeService->GetTypeFromFile(mFile, mimeType);
|
||||
if (NS_FAILED(rv)) {
|
||||
mimeType.Truncate();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
mMimeType = NS_ConvertUTF8toUTF16(mimeType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DeviceStorageFile::CalculateSizeAndModifiedDate()
|
||||
{
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
int64_t fileSize;
|
||||
nsresult rv = mFile->GetFileSize(&fileSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mLength = fileSize;
|
||||
|
||||
PRTime modDate;
|
||||
rv = mFile->GetLastModifiedTime(&modDate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mLastModifiedDate = modDate;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
DeviceStorageFile::CollectFiles(nsTArray<nsRefPtr<DeviceStorageFile> > &aFiles,
|
||||
PRTime aSince)
|
||||
@ -1034,6 +1079,7 @@ DeviceStorageFile::collectFilesInternal(nsTArray<nsRefPtr<DeviceStorageFile> > &
|
||||
} else if (isFile) {
|
||||
nsRefPtr<DeviceStorageFile> dsf =
|
||||
new DeviceStorageFile(mStorageType, mStorageName, mRootDir, newPath);
|
||||
dsf->CalculateSizeAndModifiedDate();
|
||||
aFiles.AppendElement(dsf);
|
||||
}
|
||||
}
|
||||
@ -1344,8 +1390,16 @@ nsIFileToJsval(nsPIDOMWindow* aWindow, DeviceStorageFile* aFile)
|
||||
|
||||
nsString compositePath;
|
||||
aFile->GetCompositePath(compositePath);
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(aFile->mFile, compositePath,
|
||||
EmptyString());
|
||||
|
||||
// This check is useful to know if somewhere the DeviceStorageFile
|
||||
// has not been properly set. Mimetype is not checked because it can be
|
||||
// empty.
|
||||
NS_ASSERTION(aFile->mLength != UINT64_MAX, "Size not set");
|
||||
NS_ASSERTION(aFile->mLastModifiedDate != UINT64_MAX, "LastModifiedDate not set");
|
||||
|
||||
nsCOMPtr<nsIDOMBlob> blob = new nsDOMFileFile(compositePath, aFile->mMimeType,
|
||||
aFile->mLength, aFile->mFile,
|
||||
aFile->mLastModifiedDate);
|
||||
return InterfaceToJsval(aWindow, blob, &NS_GET_IID(nsIDOMBlob));
|
||||
}
|
||||
|
||||
@ -1486,6 +1540,8 @@ ContinueCursorEvent::GetNextFile()
|
||||
if (!typeChecker->Check(cursorStorageType, file->mFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
file->CalculateMimeType();
|
||||
return file.forget();
|
||||
}
|
||||
|
||||
@ -1867,6 +1923,7 @@ public:
|
||||
: mFile(aFile)
|
||||
{
|
||||
mRequest.swap(aRequest);
|
||||
mFile->CalculateMimeType();
|
||||
}
|
||||
|
||||
~ReadFileEvent() {}
|
||||
@ -1884,6 +1941,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (!r) {
|
||||
nsresult rv = mFile->CalculateSizeAndModifiedDate();
|
||||
if (NS_FAILED(rv)) {
|
||||
r = new PostErrorEvent(mRequest, POST_ERROR_EVENT_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
if (!r) {
|
||||
r = new PostResultEvent(mRequest, mFile);
|
||||
}
|
||||
|
@ -476,21 +476,25 @@ var gData = [
|
||||
{
|
||||
type: 'pictures',
|
||||
shouldPass: false,
|
||||
fileExtension: '.png',
|
||||
test: TestEnumerate
|
||||
},
|
||||
{
|
||||
type: 'videos',
|
||||
shouldPass: false,
|
||||
fileExtension: '.ogv',
|
||||
test: TestEnumerate
|
||||
},
|
||||
{
|
||||
type: 'music',
|
||||
shouldPass: false,
|
||||
fileExtension: '.ogg',
|
||||
test: TestEnumerate
|
||||
},
|
||||
{
|
||||
type: 'sdcard',
|
||||
shouldPass: false,
|
||||
fileExtension: '.txt',
|
||||
test: TestEnumerate
|
||||
},
|
||||
|
||||
@ -498,6 +502,7 @@ var gData = [
|
||||
{
|
||||
type: 'pictures',
|
||||
shouldPass: true,
|
||||
fileExtension: '.png',
|
||||
|
||||
permissions: ["device-storage:pictures"],
|
||||
|
||||
@ -506,6 +511,7 @@ var gData = [
|
||||
{
|
||||
type: 'videos',
|
||||
shouldPass: true,
|
||||
fileExtension: '.ogv',
|
||||
|
||||
permissions: ["device-storage:videos"],
|
||||
|
||||
@ -514,6 +520,7 @@ var gData = [
|
||||
{
|
||||
type: 'music',
|
||||
shouldPass: true,
|
||||
fileExtension: '.ogg',
|
||||
|
||||
permissions: ["device-storage:music"],
|
||||
|
||||
@ -522,6 +529,7 @@ var gData = [
|
||||
{
|
||||
type: 'sdcard',
|
||||
shouldPass: true,
|
||||
fileExtension: '.txt',
|
||||
|
||||
permissions: ["device-storage:sdcard"],
|
||||
|
||||
@ -532,6 +540,7 @@ var gData = [
|
||||
{
|
||||
type: 'pictures',
|
||||
shouldPass: true,
|
||||
fileExtension: '.png',
|
||||
|
||||
app: "https://example.com/manifest_cert.webapp",
|
||||
permissions: ["device-storage:pictures"],
|
||||
@ -541,6 +550,7 @@ var gData = [
|
||||
{
|
||||
type: 'videos',
|
||||
shouldPass: true,
|
||||
fileExtension: '.ogv',
|
||||
|
||||
app: "https://example.com/manifest_cert.webapp",
|
||||
permissions: ["device-storage:videos"],
|
||||
@ -550,6 +560,7 @@ var gData = [
|
||||
{
|
||||
type: 'music',
|
||||
shouldPass: true,
|
||||
fileExtension: '.ogg',
|
||||
|
||||
app: "https://example.com/manifest_cert.webapp",
|
||||
permissions: ["device-storage:music"],
|
||||
@ -559,6 +570,7 @@ var gData = [
|
||||
{
|
||||
type: 'sdcard',
|
||||
shouldPass: true,
|
||||
fileExtension: '.txt',
|
||||
|
||||
app: "https://example.com/manifest_cert.webapp",
|
||||
permissions: ["device-storage:sdcard"],
|
||||
|
@ -636,6 +636,18 @@ bool TabParent::SendRealTouchEvent(nsTouchEvent& event)
|
||||
return false;
|
||||
}
|
||||
if (event.message == NS_TOUCH_START) {
|
||||
// Adjust the widget coordinates to be relative to our frame.
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
if (!frameLoader) {
|
||||
// No frame anymore?
|
||||
sEventCapturer = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
mChildProcessOffsetAtTouchStart =
|
||||
nsEventStateManager::GetChildProcessOffset(frameLoader,
|
||||
event);
|
||||
|
||||
MOZ_ASSERT((!sEventCapturer && mEventCaptureDepth == 0) ||
|
||||
(sEventCapturer == this && mEventCaptureDepth > 0));
|
||||
// We want to capture all remaining touch events in this series
|
||||
@ -693,16 +705,8 @@ TabParent::TryCapture(const nsGUIEvent& aEvent)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Adjust the widget coordinates to be relative to our frame.
|
||||
nsRefPtr<nsFrameLoader> frameLoader = GetFrameLoader();
|
||||
|
||||
if (!frameLoader) {
|
||||
// No frame anymore?
|
||||
sEventCapturer = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
nsEventStateManager::MapEventCoordinatesForChildProcess(frameLoader, &event);
|
||||
nsEventStateManager::MapEventCoordinatesForChildProcess(
|
||||
mChildProcessOffsetAtTouchStart, &event);
|
||||
|
||||
SendRealTouchEvent(event);
|
||||
return true;
|
||||
|
@ -313,6 +313,11 @@ private:
|
||||
// dispatch to content.
|
||||
void MaybeForwardEventToRenderFrame(const nsInputEvent& aEvent,
|
||||
nsInputEvent* aOutEvent);
|
||||
// The offset for the child process which is sampled at touch start. This
|
||||
// means that the touch events are relative to where the frame was at the
|
||||
// start of the touch. We need to look for a better solution to this
|
||||
// problem see bug 872911.
|
||||
nsIntPoint mChildProcessOffsetAtTouchStart;
|
||||
// When true, we've initiated normal shutdown and notified our
|
||||
// managing PContent.
|
||||
bool mMarkedDestroying;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIConsoleMessage.idl"
|
||||
|
||||
[scriptable, uuid(ec640482-be5f-49a0-a9cb-c87eacce9291)]
|
||||
[scriptable, uuid(cac9d8e8-0d53-4fa8-9903-bb367e4fa1fe)]
|
||||
interface nsIScriptError : nsIConsoleMessage
|
||||
{
|
||||
/** pseudo-flag for default case */
|
||||
@ -41,33 +41,6 @@ interface nsIScriptError : nsIConsoleMessage
|
||||
readonly attribute uint32_t columnNumber;
|
||||
readonly attribute uint32_t flags;
|
||||
|
||||
/**
|
||||
* Categories I know about -
|
||||
* XUL javascript
|
||||
* content javascript (both of these from nsDocShell, currently)
|
||||
* component javascript (errors in JS components)
|
||||
*/
|
||||
readonly attribute string category;
|
||||
|
||||
/*
|
||||
The time (in milliseconds from the Epoch) that the script error instance
|
||||
was initialised, and thus the time when the error occurred.
|
||||
Currently used to display date and time of the message in Error console.
|
||||
The timestamp is initialized as JS_now/1000 so that it can be
|
||||
compared to Date.now in Javascript.
|
||||
*/
|
||||
readonly attribute long long timeStamp;
|
||||
|
||||
/* Get the window id this was initialized with. Zero will be
|
||||
returned if init() was used instead of initWithWindowID(). */
|
||||
readonly attribute unsigned long long outerWindowID;
|
||||
|
||||
/* Get the inner window id this was initialized with. Zero will be
|
||||
returned if init() was used instead of initWithWindowID(). */
|
||||
readonly attribute unsigned long long innerWindowID;
|
||||
|
||||
readonly attribute boolean isFromPrivateWindow;
|
||||
|
||||
void init(in AString message,
|
||||
in AString sourceName,
|
||||
in AString sourceLine,
|
||||
@ -87,13 +60,11 @@ interface nsIScriptError : nsIConsoleMessage
|
||||
in uint32_t flags,
|
||||
in string category,
|
||||
in unsigned long long innerWindowID);
|
||||
|
||||
AUTF8String toString();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_SCRIPTERROR_CID \
|
||||
{ 0xe38e53b9, 0x5bb0, 0x456a, { 0xb5, 0x53, 0x57, 0x93, 0x70, 0xcb, 0x15, 0x67 }}
|
||||
{ 0x1950539a, 0x90f0, 0x4d22, { 0xb5, 0xaf, 0x71, 0x32, 0x9c, 0x68, 0xfa, 0x35 }}
|
||||
|
||||
#define NS_SCRIPTERROR_CONTRACTID "@mozilla.org/scripterror;1"
|
||||
%}
|
||||
|
@ -93,6 +93,16 @@ nsScriptError::GetCategory(char **result) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIConsoleMessage method
|
||||
NS_IMETHODIMP
|
||||
nsScriptError::InitMessage(const nsAString& message,
|
||||
const char *category,
|
||||
uint64_t innerWindowID)
|
||||
{
|
||||
return InitWithWindowID(message, EmptyString(), EmptyString(), 0, 0, 0,
|
||||
category, innerWindowID);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptError::Init(const nsAString& message,
|
||||
const nsAString& sourceName,
|
||||
|
@ -187,7 +187,9 @@ function log(aThing) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else if (type.match("Error$") || aThing.name == "NS_ERROR_FAILURE") {
|
||||
else if (type.match("Error$") ||
|
||||
(typeof aThing.name == "string" &&
|
||||
aThing.name.match("NS_ERROR_"))) {
|
||||
reply += " Message: " + aThing + "\n";
|
||||
if (aThing.stack) {
|
||||
reply += " Stack:\n";
|
||||
|
@ -174,6 +174,7 @@ const UnsolicitedNotifications = {
|
||||
"consoleAPICall": "consoleAPICall",
|
||||
"eventNotification": "eventNotification",
|
||||
"fileActivity": "fileActivity",
|
||||
"logMessage": "logMessage",
|
||||
"networkEvent": "networkEvent",
|
||||
"networkEventUpdate": "networkEventUpdate",
|
||||
"newGlobal": "newGlobal",
|
||||
|
@ -39,7 +39,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "VariablesView",
|
||||
"resource:///modules/devtools/VariablesView.jsm");
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["WebConsoleUtils", "JSPropertyProvider", "JSTermHelpers",
|
||||
"PageErrorListener", "ConsoleAPIListener",
|
||||
"ConsoleServiceListener", "ConsoleAPIListener",
|
||||
"NetworkResponseListener", "NetworkMonitor",
|
||||
"ConsoleProgressListener"];
|
||||
|
||||
@ -873,25 +873,25 @@ return JSPropertyProvider;
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* The nsIConsoleService listener. This is used to send all the page errors
|
||||
* (JavaScript, CSS and more) to the remote Web Console instance.
|
||||
* The nsIConsoleService listener. This is used to send all of the console
|
||||
* messages (JavaScript, CSS and more) to the remote Web Console instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param nsIDOMWindow [aWindow]
|
||||
* Optional - the window object for which we are created. This is used
|
||||
* for filtering out messages that belong to other windows.
|
||||
* @param object aListener
|
||||
* The listener object must have a method: onPageError. This method is
|
||||
* invoked with one argument, the nsIScriptError, whenever a relevant
|
||||
* page error is received.
|
||||
* The listener object must have one method:
|
||||
* - onConsoleServiceMessage(). This method is invoked with one argument, the
|
||||
* nsIConsoleMessage, whenever a relevant message is received.
|
||||
*/
|
||||
this.PageErrorListener = function PageErrorListener(aWindow, aListener)
|
||||
this.ConsoleServiceListener = function ConsoleServiceListener(aWindow, aListener)
|
||||
{
|
||||
this.window = aWindow;
|
||||
this.listener = aListener;
|
||||
}
|
||||
|
||||
PageErrorListener.prototype =
|
||||
ConsoleServiceListener.prototype =
|
||||
{
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
|
||||
|
||||
@ -902,8 +902,7 @@ PageErrorListener.prototype =
|
||||
window: null,
|
||||
|
||||
/**
|
||||
* The listener object which is notified of page errors. It must have
|
||||
* a onPageError method which is invoked with one argument: the nsIScriptError.
|
||||
* The listener object which is notified of messages from the console service.
|
||||
* @type object
|
||||
*/
|
||||
listener: null,
|
||||
@ -911,7 +910,7 @@ PageErrorListener.prototype =
|
||||
/**
|
||||
* Initialize the nsIConsoleService listener.
|
||||
*/
|
||||
init: function PEL_init()
|
||||
init: function CSL_init()
|
||||
{
|
||||
Services.console.registerListener(this);
|
||||
},
|
||||
@ -921,43 +920,47 @@ PageErrorListener.prototype =
|
||||
* messages belonging to the current window and sends them to the remote Web
|
||||
* Console instance.
|
||||
*
|
||||
* @param nsIScriptError aScriptError
|
||||
* The script error object coming from the nsIConsoleService.
|
||||
* @param nsIConsoleMessage aMessage
|
||||
* The message object coming from the nsIConsoleService.
|
||||
*/
|
||||
observe: function PEL_observe(aScriptError)
|
||||
observe: function CSL_observe(aMessage)
|
||||
{
|
||||
if (!this.listener ||
|
||||
!(aScriptError instanceof Ci.nsIScriptError)) {
|
||||
if (!this.listener) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.window) {
|
||||
if (!aScriptError.outerWindowID ||
|
||||
!this.isCategoryAllowed(aScriptError.category)) {
|
||||
if (!aMessage.outerWindowID ||
|
||||
!this.isCategoryAllowed(aMessage.category)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let errorWindow =
|
||||
Services.wm.getOuterWindowWithId(aScriptError.outerWindowID);
|
||||
let errorWindow = Services.wm.getOuterWindowWithId(aMessage.outerWindowID);
|
||||
if (!errorWindow || errorWindow.top != this.window) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.listener.onPageError(aScriptError);
|
||||
if (aMessage.message) {
|
||||
this.listener.onConsoleServiceMessage(aMessage);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if the given script error category is allowed to be tracked or not.
|
||||
* Check if the given message category is allowed to be tracked or not.
|
||||
* We ignore chrome-originating errors as we only care about content.
|
||||
*
|
||||
* @param string aCategory
|
||||
* The nsIScriptError category you want to check.
|
||||
* The message category you want to check.
|
||||
* @return boolean
|
||||
* True if the category is allowed to be logged, false otherwise.
|
||||
*/
|
||||
isCategoryAllowed: function PEL_isCategoryAllowed(aCategory)
|
||||
isCategoryAllowed: function CSL_isCategoryAllowed(aCategory)
|
||||
{
|
||||
if (!aCategory) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (aCategory) {
|
||||
case "XPConnect JavaScript":
|
||||
case "component javascript":
|
||||
@ -977,28 +980,26 @@ PageErrorListener.prototype =
|
||||
* Get the cached page errors for the current inner window.
|
||||
*
|
||||
* @return array
|
||||
* The array of cached messages. Each element is an nsIScriptError
|
||||
* with an added _type property so the remote Web Console instance can
|
||||
* tell the difference between various types of cached messages.
|
||||
* The array of cached messages. Each element is an nsIScriptError or
|
||||
* an nsIConsoleMessage.
|
||||
*/
|
||||
getCachedMessages: function PEL_getCachedMessages()
|
||||
getCachedMessages: function CSL_getCachedMessages()
|
||||
{
|
||||
let innerWindowId = this.window ?
|
||||
WebConsoleUtils.getInnerWindowId(this.window) : null;
|
||||
let errors = Services.console.getMessageArray() || [];
|
||||
|
||||
return errors.filter(function(aError) {
|
||||
return aError instanceof Ci.nsIScriptError &&
|
||||
(!innerWindowId ||
|
||||
return errors.filter((aError) => {
|
||||
return !innerWindowId ||
|
||||
(aError.innerWindowID == innerWindowId &&
|
||||
this.isCategoryAllowed(aError.category)));
|
||||
}, this);
|
||||
this.isCategoryAllowed(aError.category));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the nsIConsoleService listener.
|
||||
*/
|
||||
destroy: function PEL_destroy()
|
||||
destroy: function CSL_destroy()
|
||||
{
|
||||
Services.console.unregisterListener(this);
|
||||
this.listener = this.window = null;
|
||||
@ -1091,8 +1092,7 @@ ConsoleAPIListener.prototype =
|
||||
* Get the cached messages for the current inner window.
|
||||
*
|
||||
* @return array
|
||||
* The array of cached messages. Each element is a Console API
|
||||
* prepared to be sent to the remote Web Console instance.
|
||||
* The array of cached messages.
|
||||
*/
|
||||
getCachedMessages: function CAL_getCachedMessages()
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "WebConsoleUtils",
|
||||
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PageErrorListener",
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleServiceListener",
|
||||
"resource://gre/modules/devtools/WebConsoleUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIListener",
|
||||
@ -165,10 +165,10 @@ WebConsoleActor.prototype =
|
||||
_window: null,
|
||||
|
||||
/**
|
||||
* The PageErrorListener instance.
|
||||
* The ConsoleServiceListener instance.
|
||||
* @type object
|
||||
*/
|
||||
pageErrorListener: null,
|
||||
consoleServiceListener: null,
|
||||
|
||||
/**
|
||||
* The ConsoleAPIListener instance.
|
||||
@ -211,9 +211,9 @@ WebConsoleActor.prototype =
|
||||
*/
|
||||
disconnect: function WCA_disconnect()
|
||||
{
|
||||
if (this.pageErrorListener) {
|
||||
this.pageErrorListener.destroy();
|
||||
this.pageErrorListener = null;
|
||||
if (this.consoleServiceListener) {
|
||||
this.consoleServiceListener.destroy();
|
||||
this.consoleServiceListener = null;
|
||||
}
|
||||
if (this.consoleAPIListener) {
|
||||
this.consoleAPIListener.destroy();
|
||||
@ -363,10 +363,10 @@ WebConsoleActor.prototype =
|
||||
let listener = aRequest.listeners.shift();
|
||||
switch (listener) {
|
||||
case "PageError":
|
||||
if (!this.pageErrorListener) {
|
||||
this.pageErrorListener =
|
||||
new PageErrorListener(window, this);
|
||||
this.pageErrorListener.init();
|
||||
if (!this.consoleServiceListener) {
|
||||
this.consoleServiceListener =
|
||||
new ConsoleServiceListener(window, this);
|
||||
this.consoleServiceListener.init();
|
||||
}
|
||||
startedListeners.push(listener);
|
||||
break;
|
||||
@ -426,9 +426,9 @@ WebConsoleActor.prototype =
|
||||
let listener = toDetach.shift();
|
||||
switch (listener) {
|
||||
case "PageError":
|
||||
if (this.pageErrorListener) {
|
||||
this.pageErrorListener.destroy();
|
||||
this.pageErrorListener = null;
|
||||
if (this.consoleServiceListener) {
|
||||
this.consoleServiceListener.destroy();
|
||||
this.consoleServiceListener = null;
|
||||
}
|
||||
stoppedListeners.push(listener);
|
||||
break;
|
||||
@ -495,13 +495,24 @@ WebConsoleActor.prototype =
|
||||
}
|
||||
break;
|
||||
case "PageError":
|
||||
if (this.pageErrorListener) {
|
||||
let cache = this.pageErrorListener.getCachedMessages();
|
||||
cache.forEach(function(aMessage) {
|
||||
let message = this.preparePageErrorForRemote(aMessage);
|
||||
message._type = type;
|
||||
if (this.consoleServiceListener) {
|
||||
let cache = this.consoleServiceListener.getCachedMessages();
|
||||
cache.forEach((aMessage) => {
|
||||
let message = null;
|
||||
if (aMessage instanceof Ci.nsIScriptError) {
|
||||
message = this.preparePageErrorForRemote(aMessage);
|
||||
message._type = type;
|
||||
}
|
||||
else {
|
||||
message = {
|
||||
_type: "LogMessage",
|
||||
message: aMessage.message,
|
||||
timeStamp: aMessage.timeStamp,
|
||||
category: aMessage.category,
|
||||
};
|
||||
}
|
||||
messages.push(message);
|
||||
}, this);
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -595,6 +606,10 @@ WebConsoleActor.prototype =
|
||||
let windowId = !this._isGlobalActor ?
|
||||
WebConsoleUtils.getInnerWindowId(this.window) : null;
|
||||
ConsoleAPIStorage.clearEvents(windowId);
|
||||
if (this._isGlobalActor) {
|
||||
Services.console.logStringMessage(null); // for the Error Console
|
||||
Services.console.reset();
|
||||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
@ -852,19 +867,31 @@ WebConsoleActor.prototype =
|
||||
//////////////////
|
||||
|
||||
/**
|
||||
* Handler for page errors received from the PageErrorListener. This method
|
||||
* sends the nsIScriptError to the remote Web Console client.
|
||||
* Handler for messages received from the ConsoleServiceListener. This method
|
||||
* sends the nsIConsoleMessage to the remote Web Console client.
|
||||
*
|
||||
* @param nsIScriptError aPageError
|
||||
* The page error we need to send to the client.
|
||||
* @param nsIConsoleMessage aMessage
|
||||
* The message we need to send to the client.
|
||||
*/
|
||||
onPageError: function WCA_onPageError(aPageError)
|
||||
onConsoleServiceMessage: function WCA_onConsoleServiceMessage(aMessage)
|
||||
{
|
||||
let packet = {
|
||||
from: this.actorID,
|
||||
type: "pageError",
|
||||
pageError: this.preparePageErrorForRemote(aPageError),
|
||||
};
|
||||
let packet;
|
||||
if (aMessage instanceof Ci.nsIScriptError) {
|
||||
packet = {
|
||||
from: this.actorID,
|
||||
type: "pageError",
|
||||
pageError: this.preparePageErrorForRemote(aMessage),
|
||||
};
|
||||
}
|
||||
else {
|
||||
packet = {
|
||||
from: this.actorID,
|
||||
type: "logMessage",
|
||||
message: aMessage.message,
|
||||
timeStamp: aMessage.timeStamp,
|
||||
category: aMessage.category,
|
||||
};
|
||||
}
|
||||
this.conn.send(packet);
|
||||
},
|
||||
|
||||
|
@ -24,6 +24,7 @@ MOCHITEST_CHROME_FILES = \
|
||||
test_bug819670_getter_throws.html \
|
||||
test_object_actor_native_getters.html \
|
||||
test_object_actor_native_getters_lenient_this.html \
|
||||
test_nsiconsolemessage.html \
|
||||
network_requests_iframe.html \
|
||||
data.json \
|
||||
data.json^headers^ \
|
||||
|
@ -106,7 +106,10 @@ function checkObject(aObject, aExpected)
|
||||
|
||||
function checkValue(aName, aValue, aExpected)
|
||||
{
|
||||
if (aValue === undefined) {
|
||||
if (aExpected === null) {
|
||||
ok(!aValue, "'" + aName + "' is null");
|
||||
}
|
||||
else if (aValue === undefined) {
|
||||
ok(false, "'" + aName + "' is undefined");
|
||||
}
|
||||
else if (typeof aExpected == "string" || typeof aExpected == "number" ||
|
||||
|
@ -95,7 +95,7 @@ function doConsoleCalls()
|
||||
<script class="testbody" type="text/javascript;version=1.8">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let consoleAPIListener, pageErrorListener;
|
||||
let consoleAPIListener, consoleServiceListener;
|
||||
let consoleAPICalls = 0;
|
||||
let pageErrors = 0;
|
||||
|
||||
@ -108,7 +108,7 @@ let handlers = {
|
||||
}
|
||||
},
|
||||
|
||||
onPageError: function onPageError()
|
||||
onConsoleServiceMessage: function onConsoleServiceMessage()
|
||||
{
|
||||
pageErrors++;
|
||||
if (pageErrors == expectedPageErrors.length) {
|
||||
@ -153,16 +153,16 @@ function onCachedConsoleAPI(aState, aResponse)
|
||||
});
|
||||
|
||||
closeDebugger(aState, function() {
|
||||
pageErrorListener = new PageErrorListener(null, handlers);
|
||||
pageErrorListener.init();
|
||||
consoleServiceListener = new ConsoleServiceListener(null, handlers);
|
||||
consoleServiceListener.init();
|
||||
doPageErrors();
|
||||
});
|
||||
}
|
||||
|
||||
function testPageErrors()
|
||||
{
|
||||
pageErrorListener.destroy();
|
||||
pageErrorListener = null;
|
||||
consoleServiceListener.destroy();
|
||||
consoleServiceListener = null;
|
||||
attachConsole(["PageError"], onAttach2);
|
||||
}
|
||||
|
||||
|
126
toolkit/devtools/webconsole/test/test_nsiconsolemessage.html
Normal file
126
toolkit/devtools/webconsole/test/test_nsiconsolemessage.html
Normal file
@ -0,0 +1,126 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Test for nsIConsoleMessages</title>
|
||||
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript;version=1.8" src="common.js"></script>
|
||||
<!-- Any copyright is dedicated to the Public Domain.
|
||||
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
||||
</head>
|
||||
<body>
|
||||
<p>Make sure that nsIConsoleMessages are logged. See bug 859756.</p>
|
||||
|
||||
<script class="testbody" type="text/javascript;version=1.8">
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let expectedMessages = [];
|
||||
let testingTabActor = false;
|
||||
|
||||
function sendConsoleMessage(aMessage, aCategory, aWindowId)
|
||||
{
|
||||
let consoleMsg = Cc["@mozilla.org/consolemessage;1"]
|
||||
.createInstance(Ci.nsIConsoleMessage);
|
||||
consoleMsg.initMessage(aMessage, aCategory, aWindowId);
|
||||
Services.console.logMessage(consoleMsg);
|
||||
}
|
||||
|
||||
function sendMessages()
|
||||
{
|
||||
expectedMessages = [
|
||||
{
|
||||
message: "hello world! bug859756",
|
||||
category: null,
|
||||
timeStamp: /^\d+$/,
|
||||
},
|
||||
{
|
||||
message: "foobarz",
|
||||
category: null,
|
||||
timeStamp: /^\d+$/,
|
||||
},
|
||||
{
|
||||
message: "boom",
|
||||
category: "cat7",
|
||||
timeStamp: /^\d+$/,
|
||||
},
|
||||
{
|
||||
message: "windowfun",
|
||||
category: "cat9",
|
||||
timeStamp: /^\d+$/,
|
||||
},
|
||||
];
|
||||
|
||||
Services.console.logStringMessage("hello world! bug859756");
|
||||
sendConsoleMessage("foobarz");
|
||||
sendConsoleMessage("boom", "cat7");
|
||||
sendConsoleMessage("windowfun", "cat9", Date.now());
|
||||
}
|
||||
|
||||
function sendMessagesForTab()
|
||||
{
|
||||
sendMessages();
|
||||
expectedMessages = [
|
||||
{
|
||||
message: "windowfun3",
|
||||
category: "cat10",
|
||||
timeStamp: /^\d+$/,
|
||||
},
|
||||
];
|
||||
|
||||
let windowID = WebConsoleUtils.getInnerWindowId(top);
|
||||
sendConsoleMessage("windowfun3", "cat10", windowID);
|
||||
}
|
||||
|
||||
function startTest()
|
||||
{
|
||||
removeEventListener("load", startTest);
|
||||
attachConsole(["PageError"], onAttach);
|
||||
}
|
||||
|
||||
function onAttach(aState, aResponse)
|
||||
{
|
||||
window.onLogMessage_ = onLogMessage.bind(null, aState);
|
||||
aState.dbgClient.addListener("logMessage", onLogMessage_);
|
||||
|
||||
if (!testingTabActor) {
|
||||
sendMessages();
|
||||
} else {
|
||||
sendMessagesForTab();
|
||||
}
|
||||
|
||||
info("waiting for messages");
|
||||
}
|
||||
|
||||
let receivedMessages = [];
|
||||
|
||||
function onLogMessage(aState, aType, aPacket)
|
||||
{
|
||||
is(aPacket.from, aState.actor, "packet actor");
|
||||
|
||||
receivedMessages.push(aPacket);
|
||||
if (receivedMessages.length != expectedMessages.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
aState.dbgClient.removeListener("logMessage", onLogMessage_);
|
||||
|
||||
checkObject(receivedMessages, expectedMessages);
|
||||
|
||||
receivedMessages = expectedMessages = [];
|
||||
window.onLogMessage_ = null;
|
||||
|
||||
closeDebugger(aState, () => {
|
||||
if (!testingTabActor) {
|
||||
testingTabActor = true;
|
||||
info("start tab actor test");
|
||||
attachConsole(["PageError"], onAttach, true);
|
||||
} else {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addEventListener("load", startTest);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -103,6 +103,7 @@ endif
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../build \
|
||||
-I$(topsrcdir)/xpcom/ds \
|
||||
-I$(topsrcdir)/dom/base \
|
||||
$(NULL)
|
||||
|
||||
# We generate ErrorListCxxDefines.h from ErrorList.h using regex. The -n option
|
||||
|
@ -9,29 +9,115 @@
|
||||
|
||||
#include "nsConsoleMessage.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsILoadContext.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage)
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage()
|
||||
nsConsoleMessage::nsConsoleMessage()
|
||||
: mMessage(),
|
||||
mCategory(),
|
||||
mOuterWindowID(0),
|
||||
mInnerWindowID(0),
|
||||
mTimeStamp(0),
|
||||
mIsFromPrivateWindow(false)
|
||||
{
|
||||
}
|
||||
|
||||
nsConsoleMessage::nsConsoleMessage(const PRUnichar *message)
|
||||
nsConsoleMessage::nsConsoleMessage(const PRUnichar *message)
|
||||
{
|
||||
mMessage.Assign(message);
|
||||
nsString m;
|
||||
m.Assign(message);
|
||||
InitMessage(m, nullptr, 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetMessageMoz(PRUnichar **result) {
|
||||
*result = ToNewUnicode(mMessage);
|
||||
nsConsoleMessage::InitMessage(const nsAString& message,
|
||||
const char *category,
|
||||
uint64_t innerWindowID)
|
||||
{
|
||||
mTimeStamp = JS_Now() / 1000;
|
||||
mMessage.Assign(message);
|
||||
mCategory.Assign(category);
|
||||
mInnerWindowID = innerWindowID;
|
||||
|
||||
return NS_OK;
|
||||
if (innerWindowID) {
|
||||
nsGlobalWindow* window = nsGlobalWindow::GetInnerWindowWithId(innerWindowID);
|
||||
if (window) {
|
||||
nsPIDOMWindow* outer = window->GetOuterWindow();
|
||||
if (outer)
|
||||
mOuterWindowID = outer->WindowID();
|
||||
|
||||
nsIDocShell* docShell = window->GetDocShell();
|
||||
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
|
||||
|
||||
if (loadContext) {
|
||||
// Never mark exceptions from chrome windows as having come from
|
||||
// private windows, since we always want them to be reported.
|
||||
nsIPrincipal* winPrincipal = window->GetPrincipal();
|
||||
mIsFromPrivateWindow = loadContext->UsePrivateBrowsing() &&
|
||||
!nsContentUtils::IsSystemPrincipal(winPrincipal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// NS_IMETHODIMP
|
||||
// nsConsoleMessage::Init(const PRUnichar *message) {
|
||||
// nsAutoString newMessage(message);
|
||||
// mMessage = ToNewUnicode(newMessage);
|
||||
// return NS_OK;
|
||||
// }
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetMessageMoz(PRUnichar **result)
|
||||
{
|
||||
*result = ToNewUnicode(mMessage);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetCategory(char **result)
|
||||
{
|
||||
*result = ToNewCString(mCategory);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetOuterWindowID(uint64_t *aOuterWindowID)
|
||||
{
|
||||
*aOuterWindowID = mOuterWindowID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetInnerWindowID(uint64_t *aInnerWindowID)
|
||||
{
|
||||
*aInnerWindowID = mInnerWindowID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetTimeStamp(int64_t *aTimeStamp)
|
||||
{
|
||||
*aTimeStamp = mTimeStamp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::GetIsFromPrivateWindow(bool *aIsFromPrivateWindow)
|
||||
{
|
||||
*aIsFromPrivateWindow = mIsFromPrivateWindow;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsConsoleMessage::ToString(nsACString& /*UTF8*/ aResult)
|
||||
{
|
||||
if (!mCategory.IsEmpty())
|
||||
aResult.Assign(mCategory + NS_LITERAL_CSTRING(": ") +
|
||||
NS_ConvertUTF16toUTF8(mMessage));
|
||||
else
|
||||
CopyUTF16toUTF8(mMessage, aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ public:
|
||||
private:
|
||||
~nsConsoleMessage() {}
|
||||
|
||||
int64_t mTimeStamp;
|
||||
nsCString mCategory;
|
||||
uint64_t mOuterWindowID;
|
||||
uint64_t mInnerWindowID;
|
||||
bool mIsFromPrivateWindow;
|
||||
nsString mMessage;
|
||||
};
|
||||
|
||||
|
@ -10,13 +10,49 @@
|
||||
* provide an object that can be qi'ed to provide more specific
|
||||
* message information.
|
||||
*/
|
||||
[scriptable, uuid(41bd8784-1dd2-11b2-9553-8606958fffe1)]
|
||||
[scriptable, uuid(c14c151b-5ea4-47ed-8e85-d392cdd3e154)]
|
||||
interface nsIConsoleMessage : nsISupports
|
||||
{
|
||||
void initMessage(in AString message, [optional] in string category, [optional] in unsigned long long innerWindowID);
|
||||
|
||||
/**
|
||||
* The time (in milliseconds from the Epoch) that the message instance
|
||||
* was initialised.
|
||||
* The timestamp is initialized as JS_now/1000 so that it can be
|
||||
* compared to Date.now in Javascript.
|
||||
*/
|
||||
readonly attribute long long timeStamp;
|
||||
|
||||
/**
|
||||
* Categories I know about
|
||||
* - nsIScriptError:
|
||||
* XUL javascript
|
||||
* content javascript (both of these from nsDocShell, currently)
|
||||
* component javascript (errors in JS components)
|
||||
* - nsIConsoleMessage: none yet.
|
||||
*/
|
||||
readonly attribute string category;
|
||||
|
||||
/**
|
||||
* Get the window id this was initialized with.
|
||||
*/
|
||||
readonly attribute unsigned long long outerWindowID;
|
||||
|
||||
/**
|
||||
* Get the inner window id this was initialized with.
|
||||
*/
|
||||
readonly attribute unsigned long long innerWindowID;
|
||||
|
||||
readonly attribute boolean isFromPrivateWindow;
|
||||
|
||||
[binaryname(MessageMoz)] readonly attribute wstring message;
|
||||
|
||||
AUTF8String toString();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_CONSOLEMESSAGE_CID \
|
||||
{ 0x56c9d666, 0x1dd2, 0x11b2, { 0xb4, 0x3c, 0xa8, 0x4b, 0xf3, 0xb3, 0xec, 0xbb }}
|
||||
{ 0x024efc9e, 0x54dc, 0x4844, { 0x80, 0x4b, 0x41, 0xd3, 0xf3, 0x69, 0x90, 0x73 }}
|
||||
|
||||
#define NS_CONSOLEMESSAGE_CONTRACTID "@mozilla.org/consolemessage;1"
|
||||
%}
|
||||
|
@ -21,6 +21,7 @@
|
||||
COMPONENT(ARRAY, nsArray::XPCOMConstructor)
|
||||
COMPONENT(CONSOLESERVICE, nsConsoleServiceConstructor)
|
||||
COMPONENT(EXCEPTIONSERVICE, nsExceptionServiceConstructor)
|
||||
COMPONENT(CONSOLEMESSAGE, nsConsoleMessageConstructor)
|
||||
COMPONENT(ATOMSERVICE, nsAtomServiceConstructor)
|
||||
COMPONENT(OBSERVERSERVICE, nsObserverService::Create)
|
||||
#ifdef MOZ_VISUAL_EVENT_TRACER
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "nsSupportsPrimitives.h"
|
||||
#include "nsConsoleService.h"
|
||||
#include "nsExceptionService.h"
|
||||
#include "nsConsoleMessage.h"
|
||||
|
||||
#include "nsComponentManager.h"
|
||||
#include "nsCategoryManagerUtils.h"
|
||||
@ -178,6 +179,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsVoidImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSupportsInterfacePointerImpl)
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsConsoleService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsConsoleMessage)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAtomService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsExceptionService)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTimerImpl)
|
||||
|
Loading…
x
Reference in New Issue
Block a user