зеркало из https://github.com/mozilla/gecko-dev.git
Bug 614350 - Web console's console object colliding with content breaks sites; f=rcampbell r=gavin.sharp a=blocking2.0
This commit is contained in:
Родитель
87d73ab860
Коммит
18c12ce07a
|
@ -19,6 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* David Dahl <ddahl@mozilla.com> (Original Author)
|
||||
* Ryan Flint <rflint@mozilla.com>
|
||||
* Rob Campbell <rcampbell@mozilla.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
|
||||
|
@ -73,7 +75,10 @@ ConsoleAPI.prototype = {
|
|||
},
|
||||
error: function CA_error() {
|
||||
self.notifyObservers(id, "error", arguments);
|
||||
}
|
||||
},
|
||||
// many flavors of console objects exist on the web, so calling
|
||||
// unimplemented methods shouldn't be fatal. See bug 614350
|
||||
__noSuchMethod__: function CA_nsm() {}
|
||||
};
|
||||
},
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* David Dahl <ddahl@mozilla.com>
|
||||
* Rob Campbell <rcampbell@mozilla.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
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<script type="text/javascript">
|
||||
function test() {
|
||||
var str = "Test Message."
|
||||
console.foobar(str); // if this throws, we don't execute following funcs
|
||||
console.log(str);
|
||||
console.info(str);
|
||||
console.warn(str);
|
||||
|
|
|
@ -109,6 +109,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_bug_601177_log_levels.js \
|
||||
browser_webconsole_bug_587615_lastTimestamp.js \
|
||||
browser_webconsole_bug_597460_filter_scroll.js \
|
||||
browser_webconsole_console_extras.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -147,6 +148,7 @@ _BROWSER_TEST_PAGES = \
|
|||
test-bug-600183-charset.html^headers^ \
|
||||
test-bug-601177-log-levels.html \
|
||||
test-bug-601177-log-levels.js \
|
||||
test-console-extras.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_BROWSER_TEST_FILES)
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* 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 DevTools test code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Rob Campbell <rcampbell@mozilla.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 ***** */
|
||||
|
||||
// Tests that the basic console.log()-style APIs and filtering work.
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console-extras.html";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("DOMContentLoaded", onLoad, false);
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
browser.removeEventListener("DOMContentLoaded", onLoad, false);
|
||||
let doc = content.document;
|
||||
openConsole();
|
||||
let button = doc.querySelector("button");
|
||||
ok(button, "we have the button");
|
||||
EventUtils.sendMouseEvent({ type: "click" }, button, content);
|
||||
executeSoon(testButtonClicked);
|
||||
}
|
||||
|
||||
function testButtonClicked()
|
||||
{
|
||||
let hudId = HUDService.displaysIndex()[0];
|
||||
let console = browser.contentWindow.wrappedJSObject.console;
|
||||
let hudBox = HUDService.getHeadsUpDisplay(hudId);
|
||||
let outputNode = hudBox.querySelector(".hud-output-node");
|
||||
let nodes = outputNode.querySelectorAll(".hud-msg-node");
|
||||
is(nodes.length, 2, "two nodes");
|
||||
ok(/start/.test(nodes[0].textContent), "start found");
|
||||
ok(/end/.test(nodes[1].textContent), "end found - complete!");
|
||||
finishTest();
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html dir="ltr" xml:lang="en-US" lang="en-US"><head>
|
||||
<title>Console extended API test</title>
|
||||
<script type="text/javascript">
|
||||
function test() {
|
||||
console.log("start");
|
||||
console.time();
|
||||
console.timeEnd()
|
||||
console.exception()
|
||||
console.assert()
|
||||
console.clear()
|
||||
console.dir()
|
||||
console.dirxml()
|
||||
console.trace()
|
||||
console.group()
|
||||
console.groupCollapsed()
|
||||
console.groupEnd()
|
||||
console.profile()
|
||||
console.profileEnd()
|
||||
console.count()
|
||||
console.table()
|
||||
console.log("end");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="header">Heads Up Display Demo</h1>
|
||||
<button onclick="test();">Test Extended API</button>
|
||||
<div id="myDiv"></div>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче