mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 798764 - Global console: add support for a global ConsoleProgressListener; r=past
This commit is contained in:
parent
101c6d3fe1
commit
44f1fefdae
@ -212,10 +212,9 @@ var NetworkHelper =
|
|||||||
*/
|
*/
|
||||||
getWindowForRequest: function NH_getWindowForRequest(aRequest)
|
getWindowForRequest: function NH_getWindowForRequest(aRequest)
|
||||||
{
|
{
|
||||||
let loadContext = this.getRequestLoadContext(aRequest);
|
try {
|
||||||
if (loadContext) {
|
return this.getRequestLoadContext(aRequest).associatedWindow;
|
||||||
return loadContext.associatedWindow;
|
} catch (ex) { }
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -227,18 +226,13 @@ var NetworkHelper =
|
|||||||
*/
|
*/
|
||||||
getRequestLoadContext: function NH_getRequestLoadContext(aRequest)
|
getRequestLoadContext: function NH_getRequestLoadContext(aRequest)
|
||||||
{
|
{
|
||||||
if (aRequest && aRequest.notificationCallbacks) {
|
try {
|
||||||
try {
|
return aRequest.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
||||||
return aRequest.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
} catch (ex) { }
|
||||||
} catch (ex) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aRequest && aRequest.loadGroup
|
try {
|
||||||
&& aRequest.loadGroup.notificationCallbacks) {
|
return aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
||||||
try {
|
} catch (ex) { }
|
||||||
return aRequest.loadGroup.notificationCallbacks.getInterface(Ci.nsILoadContext);
|
|
||||||
} catch (ex) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
@ -2590,16 +2590,16 @@ _global.NetworkResponseListener = NetworkResponseListener;
|
|||||||
* location changes.
|
* location changes.
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param object aBrowser
|
* @param object aWindow
|
||||||
* The xul:browser for which we need to track location changes.
|
* The window for which we need to track location changes.
|
||||||
* @param object aOwner
|
* @param object aOwner
|
||||||
* The listener owner which needs to implement two methods:
|
* The listener owner which needs to implement two methods:
|
||||||
* - onFileActivity(aFileURI)
|
* - onFileActivity(aFileURI)
|
||||||
* - onLocationChange(aState, aTabURI, aPageTitle)
|
* - onLocationChange(aState, aTabURI, aPageTitle)
|
||||||
*/
|
*/
|
||||||
function ConsoleProgressListener(aBrowser, aOwner)
|
function ConsoleProgressListener(aWindow, aOwner)
|
||||||
{
|
{
|
||||||
this.browser = aBrowser;
|
this.window = aWindow;
|
||||||
this.owner = aOwner;
|
this.owner = aOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2637,6 +2637,8 @@ ConsoleProgressListener.prototype = {
|
|||||||
*/
|
*/
|
||||||
_initialized: false,
|
_initialized: false,
|
||||||
|
|
||||||
|
_webProgress: null,
|
||||||
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||||
Ci.nsISupportsWeakReference]),
|
Ci.nsISupportsWeakReference]),
|
||||||
|
|
||||||
@ -2650,8 +2652,13 @@ ConsoleProgressListener.prototype = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._webProgress = this.window.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
|
.getInterface(Ci.nsIWebNavigation)
|
||||||
|
.QueryInterface(Ci.nsIWebProgress);
|
||||||
|
this._webProgress.addProgressListener(this,
|
||||||
|
Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||||
|
|
||||||
this._initialized = true;
|
this._initialized = true;
|
||||||
this.browser.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2768,8 +2775,7 @@ ConsoleProgressListener.prototype = {
|
|||||||
let isWindow = aState & Ci.nsIWebProgressListener.STATE_IS_WINDOW;
|
let isWindow = aState & Ci.nsIWebProgressListener.STATE_IS_WINDOW;
|
||||||
|
|
||||||
// Skip non-interesting states.
|
// Skip non-interesting states.
|
||||||
if (!isNetwork || !isWindow ||
|
if (!isNetwork || !isWindow || aProgress.DOMWindow != this.window) {
|
||||||
aProgress.DOMWindow != this.browser.contentWindow) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2777,9 +2783,8 @@ ConsoleProgressListener.prototype = {
|
|||||||
this.owner.onLocationChange("start", aRequest.URI.spec, "");
|
this.owner.onLocationChange("start", aRequest.URI.spec, "");
|
||||||
}
|
}
|
||||||
else if (isStop) {
|
else if (isStop) {
|
||||||
let window = this.browser.contentWindow;
|
this.owner.onLocationChange("stop", this.window.location.href,
|
||||||
this.owner.onLocationChange("stop", window.location.href,
|
this.window.document.title);
|
||||||
window.document.title);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2801,11 +2806,15 @@ ConsoleProgressListener.prototype = {
|
|||||||
this._fileActivity = false;
|
this._fileActivity = false;
|
||||||
this._locationChange = false;
|
this._locationChange = false;
|
||||||
|
|
||||||
if (this.browser.removeProgressListener) {
|
try {
|
||||||
this.browser.removeProgressListener(this);
|
this._webProgress.removeProgressListener(this);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
// This can throw during browser shutdown.
|
||||||
}
|
}
|
||||||
|
|
||||||
this.browser = null;
|
this._webProgress = null;
|
||||||
|
this.window = null;
|
||||||
this.owner = null;
|
this.owner = null;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -47,15 +47,20 @@ XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPIStorage",
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @param object aConnection
|
* @param object aConnection
|
||||||
* The connection to the client, DebuggerServerConnection.
|
* The connection to the client, DebuggerServerConnection.
|
||||||
* @param object [aTabActor]
|
* @param object [aParentActor]
|
||||||
* Optional, the parent tab actor. This must be an instance of
|
* Optional, the parent actor.
|
||||||
* BrowserTabActor.
|
|
||||||
*/
|
*/
|
||||||
function WebConsoleActor(aConnection, aTabActor)
|
function WebConsoleActor(aConnection, aParentActor)
|
||||||
{
|
{
|
||||||
this.conn = aConnection;
|
this.conn = aConnection;
|
||||||
if (aTabActor instanceof BrowserTabActor) {
|
|
||||||
this._browser = aTabActor.browser;
|
if (aParentActor instanceof BrowserTabActor &&
|
||||||
|
aParentActor.browser instanceof Ci.nsIDOMWindow) {
|
||||||
|
this._window = aParentActor.browser;
|
||||||
|
}
|
||||||
|
else if (aParentActor instanceof BrowserTabActor &&
|
||||||
|
aParentActor.browser instanceof Ci.nsIDOMElement) {
|
||||||
|
this._window = aParentActor.browser.contentWindow;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this._window = Services.wm.getMostRecentWindow("navigator:browser");
|
this._window = Services.wm.getMostRecentWindow("navigator:browser");
|
||||||
@ -73,14 +78,6 @@ function WebConsoleActor(aConnection, aTabActor)
|
|||||||
|
|
||||||
WebConsoleActor.prototype =
|
WebConsoleActor.prototype =
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The xul:browser we work with. This is only available when the Web Console
|
|
||||||
* actor is a tab actor.
|
|
||||||
* @private
|
|
||||||
* @type nsIDOMElement
|
|
||||||
*/
|
|
||||||
_browser: null,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells if this Web Console actor is a global actor or not.
|
* Tells if this Web Console actor is a global actor or not.
|
||||||
* @private
|
* @private
|
||||||
@ -137,7 +134,7 @@ WebConsoleActor.prototype =
|
|||||||
* The content window we work with.
|
* The content window we work with.
|
||||||
* @type nsIDOMWindow
|
* @type nsIDOMWindow
|
||||||
*/
|
*/
|
||||||
get window() this._browser ? this._browser.contentWindow : this._window,
|
get window() this._window,
|
||||||
|
|
||||||
_window: null,
|
_window: null,
|
||||||
|
|
||||||
@ -220,7 +217,7 @@ WebConsoleActor.prototype =
|
|||||||
this._objectActorsPool = null;
|
this._objectActorsPool = null;
|
||||||
this._networkEventActorsPool = null;
|
this._networkEventActorsPool = null;
|
||||||
this._sandboxLocation = this.sandbox = null;
|
this._sandboxLocation = this.sandbox = null;
|
||||||
this.conn = this._browser = this._window = null;
|
this.conn = this._window = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,26 +329,18 @@ WebConsoleActor.prototype =
|
|||||||
startedListeners.push(listener);
|
startedListeners.push(listener);
|
||||||
break;
|
break;
|
||||||
case "FileActivity":
|
case "FileActivity":
|
||||||
if (this._isGlobalActor) {
|
|
||||||
// The ConsoleProgressListener cannot listen for global events.
|
|
||||||
// See bug 798764.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!this.consoleProgressListener) {
|
if (!this.consoleProgressListener) {
|
||||||
this.consoleProgressListener =
|
this.consoleProgressListener =
|
||||||
new ConsoleProgressListener(this._browser, this);
|
new ConsoleProgressListener(this.window, this);
|
||||||
}
|
}
|
||||||
this.consoleProgressListener.startMonitor(this.consoleProgressListener.
|
this.consoleProgressListener.startMonitor(this.consoleProgressListener.
|
||||||
MONITOR_FILE_ACTIVITY);
|
MONITOR_FILE_ACTIVITY);
|
||||||
startedListeners.push(listener);
|
startedListeners.push(listener);
|
||||||
break;
|
break;
|
||||||
case "LocationChange":
|
case "LocationChange":
|
||||||
if (this._isGlobalActor) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!this.consoleProgressListener) {
|
if (!this.consoleProgressListener) {
|
||||||
this.consoleProgressListener =
|
this.consoleProgressListener =
|
||||||
new ConsoleProgressListener(this._browser, this);
|
new ConsoleProgressListener(this.window, this);
|
||||||
}
|
}
|
||||||
this.consoleProgressListener.startMonitor(this.consoleProgressListener.
|
this.consoleProgressListener.startMonitor(this.consoleProgressListener.
|
||||||
MONITOR_LOCATION_CHANGE);
|
MONITOR_LOCATION_CHANGE);
|
||||||
|
@ -19,6 +19,7 @@ MOCHITEST_CHROME_FILES = \
|
|||||||
test_object_actor.html \
|
test_object_actor.html \
|
||||||
test_network_get.html \
|
test_network_get.html \
|
||||||
test_network_post.html \
|
test_network_post.html \
|
||||||
|
test_file_uri.html \
|
||||||
network_requests_iframe.html \
|
network_requests_iframe.html \
|
||||||
data.json \
|
data.json \
|
||||||
common.js \
|
common.js \
|
||||||
|
97
toolkit/devtools/webconsole/test/test_file_uri.html
Normal file
97
toolkit/devtools/webconsole/test/test_file_uri.html
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf8">
|
||||||
|
<title>Test for file activity tracking</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>Test for file activity tracking</p>
|
||||||
|
|
||||||
|
<script class="testbody" type="text/javascript;version=1.8">
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
Cu.import("resource://gre/modules/FileUtils.jsm");
|
||||||
|
|
||||||
|
let gState;
|
||||||
|
let gTmpFile;
|
||||||
|
|
||||||
|
function doFileActivity()
|
||||||
|
{
|
||||||
|
info("doFileActivity");
|
||||||
|
let fileContent = "<p>hello world from bug 798764";
|
||||||
|
|
||||||
|
gTmpFile = FileUtils.getFile("TmpD", ["bug798764.html"]);
|
||||||
|
gTmpFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
|
||||||
|
|
||||||
|
let fout = FileUtils.openSafeFileOutputStream(gTmpFile,
|
||||||
|
FileUtils.MODE_WRONLY | FileUtils.MODE_CREATE | FileUtils.MODE_TRUNCATE);
|
||||||
|
|
||||||
|
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].
|
||||||
|
createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||||
|
converter.charset = "UTF-8";
|
||||||
|
let fileContentStream = converter.convertToInputStream(fileContent);
|
||||||
|
|
||||||
|
NetUtil.asyncCopy(fileContentStream, fout, addIframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addIframe(aStatus)
|
||||||
|
{
|
||||||
|
ok(Components.isSuccessCode(aStatus),
|
||||||
|
"the temporary file was saved successfully");
|
||||||
|
|
||||||
|
let iframe = document.createElement("iframe");
|
||||||
|
iframe.src = NetUtil.newURI(gTmpFile).spec;
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startTest()
|
||||||
|
{
|
||||||
|
removeEventListener("load", startTest);
|
||||||
|
|
||||||
|
attachConsole(["FileActivity"], onAttach);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onAttach(aState, aResponse)
|
||||||
|
{
|
||||||
|
gState = aState;
|
||||||
|
gState.dbgClient.addListener("fileActivity", onFileActivity);
|
||||||
|
doFileActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
function onFileActivity(aType, aPacket)
|
||||||
|
{
|
||||||
|
is(aPacket.from, gState.actor, "fileActivity actor");
|
||||||
|
|
||||||
|
gState.dbgClient.removeListener("fileActivity", onFileActivity);
|
||||||
|
|
||||||
|
ok(/bug798764\.html$/.test(aPacket.uri), "file URI match");
|
||||||
|
|
||||||
|
testEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
function testEnd()
|
||||||
|
{
|
||||||
|
if (gTmpFile) {
|
||||||
|
gTmpFile.remove(false);
|
||||||
|
gTmpFile = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gState) {
|
||||||
|
closeDebugger(gState, function() {
|
||||||
|
gState = null;
|
||||||
|
SimpleTest.finish();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
SimpleTest.finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addEventListener("load", startTest);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user