зеркало из https://github.com/mozilla/gecko-dev.git
Bug 595223 - Keep track of file:// url 'loadGroups'; f=ddahl r=dcamp,dolske
This commit is contained in:
Родитель
e897d4adbf
Коммит
3e0e231091
|
@ -1438,7 +1438,8 @@ HUD_SERVICE.prototype =
|
|||
*/
|
||||
deactivateHUDForContext: function HS_deactivateHUDForContext(aContext, aAnimated)
|
||||
{
|
||||
let window = aContext.linkedBrowser.contentWindow;
|
||||
let browser = aContext.linkedBrowser;
|
||||
let window = browser.contentWindow;
|
||||
let nBox = aContext.ownerDocument.defaultView.
|
||||
getNotificationBox(window);
|
||||
let hudId = "hud_" + nBox.id;
|
||||
|
@ -1449,7 +1450,12 @@ HUD_SERVICE.prototype =
|
|||
this.storeHeight(hudId);
|
||||
}
|
||||
|
||||
let hud = this.hudReferences[hudId];
|
||||
browser.webProgress.removeProgressListener(hud.progressListener);
|
||||
delete hud.progressListener;
|
||||
|
||||
this.unregisterDisplay(displayNode);
|
||||
|
||||
window.focus();
|
||||
}
|
||||
},
|
||||
|
@ -2640,27 +2646,6 @@ HUD_SERVICE.prototype =
|
|||
13: "typeWarning", // JSREPORT_STRICT_MODE_ERROR | JSREPORT_WARNING | JSREPORT_ERROR
|
||||
},
|
||||
|
||||
/**
|
||||
* Closes the Console, if any, that resides on the given tab.
|
||||
*
|
||||
* @param nsIDOMNode aTab
|
||||
* The tab on which to close the console.
|
||||
* @returns void
|
||||
*/
|
||||
closeConsoleOnTab: function HS_closeConsoleOnTab(aTab)
|
||||
{
|
||||
let xulDocument = aTab.ownerDocument;
|
||||
let xulWindow = xulDocument.defaultView;
|
||||
let gBrowser = xulWindow.gBrowser;
|
||||
let linkedBrowser = aTab.linkedBrowser;
|
||||
let notificationBox = gBrowser.getNotificationBox(linkedBrowser);
|
||||
let hudId = "hud_" + notificationBox.getAttribute("id");
|
||||
let outputNode = xulDocument.getElementById(hudId);
|
||||
if (outputNode != null) {
|
||||
this.unregisterDisplay(outputNode);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* onTabClose event handler function
|
||||
*
|
||||
|
@ -2669,7 +2654,7 @@ HUD_SERVICE.prototype =
|
|||
*/
|
||||
onTabClose: function HS_onTabClose(aEvent)
|
||||
{
|
||||
this.closeConsoleOnTab(aEvent.target);
|
||||
this.deactivateHUDForContext(aEvent.target, false);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2687,7 +2672,7 @@ HUD_SERVICE.prototype =
|
|||
|
||||
let tab = tabContainer.firstChild;
|
||||
while (tab != null) {
|
||||
this.closeConsoleOnTab(tab);
|
||||
this.deactivateHUDForContext(tab, false);
|
||||
tab = tab.nextSibling;
|
||||
}
|
||||
},
|
||||
|
@ -2759,6 +2744,11 @@ HUD_SERVICE.prototype =
|
|||
HUDService.registerHUDReference(hud);
|
||||
let windowId = this.getWindowId(aContentWindow.top);
|
||||
this.windowIds[windowId] = hudId;
|
||||
|
||||
hud.progressListener = new ConsoleProgressListener(hudId);
|
||||
|
||||
_browser.webProgress.addProgressListener(hud.progressListener,
|
||||
Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
}
|
||||
else {
|
||||
hud = this.hudReferences[hudId];
|
||||
|
@ -6007,6 +5997,87 @@ HUDConsoleObserver = {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A WebProgressListener that listens for location changes, to update HUDService
|
||||
* state information on page navigation.
|
||||
*
|
||||
* @constructor
|
||||
* @param string aHudId
|
||||
* The HeadsUpDisplay ID.
|
||||
*/
|
||||
function ConsoleProgressListener(aHudId)
|
||||
{
|
||||
this.hudId = aHudId;
|
||||
}
|
||||
|
||||
ConsoleProgressListener.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
onStateChange: function CPL_onStateChange(aProgress, aRequest, aState,
|
||||
aStatus)
|
||||
{
|
||||
if (!(aState & Ci.nsIWebProgressListener.STATE_START)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let uri = null;
|
||||
if (aRequest instanceof Ci.imgIRequest) {
|
||||
let imgIRequest = aRequest.QueryInterface(Ci.imgIRequest);
|
||||
uri = imgIRequest.URI;
|
||||
}
|
||||
else if (aRequest instanceof Ci.nsIChannel) {
|
||||
let nsIChannel = aRequest.QueryInterface(Ci.nsIChannel);
|
||||
uri = nsIChannel.URI;
|
||||
}
|
||||
|
||||
if (!uri || !uri.schemeIs("file") && !uri.schemeIs("ftp")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let outputNode = HUDService.hudReferences[this.hudId].outputNode;
|
||||
|
||||
let chromeDocument = outputNode.ownerDocument;
|
||||
let msgNode = chromeDocument.createElementNS(HTML_NS, "html:span");
|
||||
|
||||
// Create the clickable URL part of the message.
|
||||
let linkNode = chromeDocument.createElementNS(HTML_NS, "html:span");
|
||||
linkNode.appendChild(chromeDocument.createTextNode(uri.spec));
|
||||
linkNode.classList.add("hud-clickable");
|
||||
linkNode.classList.add("webconsole-msg-url");
|
||||
|
||||
linkNode.addEventListener("mousedown", function(aEvent) {
|
||||
this._startX = aEvent.clientX;
|
||||
this._startY = aEvent.clientY;
|
||||
}, false);
|
||||
|
||||
linkNode.addEventListener("click", function(aEvent) {
|
||||
if (aEvent.detail == 1 && aEvent.button == 0 &&
|
||||
this._startX == aEvent.clientX && this._startY == aEvent.clientY) {
|
||||
let viewSourceUtils = chromeDocument.defaultView.gViewSourceUtils;
|
||||
viewSourceUtils.viewSource(uri.spec, null, chromeDocument);
|
||||
}
|
||||
}, false);
|
||||
|
||||
msgNode.appendChild(linkNode);
|
||||
|
||||
let messageNode = ConsoleUtils.createMessageNode(chromeDocument,
|
||||
CATEGORY_NETWORK,
|
||||
SEVERITY_LOG,
|
||||
msgNode,
|
||||
null,
|
||||
null,
|
||||
uri.spec);
|
||||
|
||||
ConsoleUtils.outputMessageNode(messageNode, this.hudId);
|
||||
},
|
||||
|
||||
onLocationChange: function() {},
|
||||
onStatusChange: function() {},
|
||||
onProgressChange: function() {},
|
||||
onSecurityChange: function() {},
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// appName
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -131,6 +131,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_bug_632347_iterators_generators.js \
|
||||
browser_webconsole_bug_642108_refForOutputNode.js \
|
||||
browser_webconsole_bug_642108_pruneTest.js \
|
||||
browser_webconsole_bug_595223_file_uri.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Web Console test suite.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* The Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_FILE = "test-network.html";
|
||||
|
||||
function tabLoad(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
hud = HUDService.hudReferences[hudId];
|
||||
|
||||
browser.addEventListener("load", tabReload, true);
|
||||
|
||||
content.location.reload();
|
||||
}
|
||||
|
||||
function tabReload(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
let textContent = hud.outputNode.textContent;
|
||||
isnot(textContent.indexOf("test-network.html"), -1,
|
||||
"found test-network.html");
|
||||
isnot(textContent.indexOf("test-image.png"), -1, "found test-image.png");
|
||||
isnot(textContent.indexOf("testscript.js"), -1, "found testscript.js");
|
||||
isnot(textContent.indexOf("running network console logging tests"), -1,
|
||||
"found the console.log() message from testscript.js");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function test() {
|
||||
let rootDir = getResolvedURI(getRootDirectory(gTestPath));
|
||||
|
||||
addTab(rootDir.spec + TEST_FILE);
|
||||
browser.addEventListener("load", tabLoad, true);
|
||||
}
|
Загрузка…
Ссылка в новой задаче