Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Unified Diff: tools/testing/extensions/firefox/ConsoleCollector/chrome/content/console.js

Issue 11043007: Add the ability to get the Javascript console errors in Firefox in the test output when tests fail. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/testing/extensions/firefox/ConsoleCollector/chrome/content/console.js
===================================================================
--- tools/testing/extensions/firefox/ConsoleCollector/chrome/content/console.js (revision 0)
+++ tools/testing/extensions/firefox/ConsoleCollector/chrome/content/console.js (revision 0)
@@ -0,0 +1,79 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
Emily Fortuna 2012/10/02 22:40:49 I'm confused. This is for Chrome? Why is it in the
gram 2012/10/04 18:43:12 No, this is "chrome" in the sense of UI; it is jus
+
+var ConsoleCollector = {};
+
+(function() {
+ var messages = [];
+ this.add = function(message) {
+ messages.push(message);
+ };
+ this.read = function(type) {
+ var rtn = [];
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ rtn.push({ 'time' : message.timeStamp,
+ 'source' : message.sourceName,
+ 'line': message.lineNumber,
+ 'column': message.columnNumber,
+ 'category': message.category,
+ 'message' : message.errorMessage });
+ }
+ messages = [];
+ return rtn;
+ };
+ this.clear = function() {
+ messages = [];
+ };
+}).apply(ConsoleCollector);
+
+(function() {
+
+ var consoleService;
+
+ var consoleListener = {
+ observe: function(e) {
+ try {
+ var message = e.QueryInterface(Components.interfaces.nsIScriptError);
+ ConsoleCollector.add(message);
+ } catch (exception) {
+ ConsoleCollector.add(e);
+ }
+ },
+
+ QueryInterface: function (iid) {
+ if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
+ !iid.equals(Components.interfaces.nsISupports)) {
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ return this;
+ }
+ };
+
+ function initialize(event) {
+ consoleService = Components.classes['@mozilla.org/consoleservice;1']
+ .getService(Components.interfaces.nsIConsoleService);
Emily Fortuna 2012/10/02 22:40:49 80 char
gram 2012/10/04 18:43:12 Dang - my Sublime Text is putting in tabs it seems
+ if (consoleService) {
+ consoleService.registerListener(consoleListener);
+ }
+ }
+
+ function shutdown(event) {
+ consoleService.unregisterListener(consoleListener);
+ }
+
+ var onPageLoad = function(e) {
+ var win = e.originalTarget.defaultView;
+ if (win) {
+ win.wrappedJSObject.ConsoleCollector = ConsoleCollector;
+ }
+ };
+
+ window.getBrowser().addEventListener("load", onPageLoad, true);
+ window.addEventListener('load', initialize, false);
+ window.addEventListener('unload', shutdown, false);
+}());
+
+
+

Powered by Google App Engine
This is Rietveld 408576698