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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // 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
4
5 var ConsoleCollector = {};
6
7 (function() {
8 var messages = [];
9 this.add = function(message) {
10 messages.push(message);
11 };
12 this.read = function(type) {
13 var rtn = [];
14 for (var i = 0; i < messages.length; i++) {
15 var message = messages[i];
16 rtn.push({ 'time' : message.timeStamp,
17 'source' : message.sourceName,
18 'line': message.lineNumber,
19 'column': message.columnNumber,
20 'category': message.category,
21 'message' : message.errorMessage });
22 }
23 messages = [];
24 return rtn;
25 };
26 this.clear = function() {
27 messages = [];
28 };
29 }).apply(ConsoleCollector);
30
31 (function() {
32
33 var consoleService;
34
35 var consoleListener = {
36 observe: function(e) {
37 try {
38 var message = e.QueryInterface(Components.interfaces.nsIScriptError);
39 ConsoleCollector.add(message);
40 } catch (exception) {
41 ConsoleCollector.add(e);
42 }
43 },
44
45 QueryInterface: function (iid) {
46 if (!iid.equals(Components.interfaces.nsIConsoleListener) &&
47 !iid.equals(Components.interfaces.nsISupports)) {
48 throw Components.results.NS_ERROR_NO_INTERFACE;
49 }
50 return this;
51 }
52 };
53
54 function initialize(event) {
55 consoleService = Components.classes['@mozilla.org/consoleservice;1']
56 .getService(Components.interfaces.nsIConsoleSe rvice);
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
57 if (consoleService) {
58 consoleService.registerListener(consoleListener);
59 }
60 }
61
62 function shutdown(event) {
63 consoleService.unregisterListener(consoleListener);
64 }
65
66 var onPageLoad = function(e) {
67 var win = e.originalTarget.defaultView;
68 if (win) {
69 win.wrappedJSObject.ConsoleCollector = ConsoleCollector;
70 }
71 };
72
73 window.getBrowser().addEventListener("load", onPageLoad, true);
74 window.addEventListener('load', initialize, false);
75 window.addEventListener('unload', shutdown, false);
76 }());
77
78
79
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698