mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1107699 - Remove timeout before Console.log() and the dispatching of ConsoleEvents, r=past
This commit is contained in:
parent
de33a28323
commit
e98bebedfa
@ -1268,7 +1268,7 @@ Console::ProcessCallData(ConsoleCallData* aData)
|
||||
innerID.AppendInt(aData->mInnerIDNumber);
|
||||
}
|
||||
|
||||
if (NS_FAILED(mStorage->RecordPendingEvent(innerID, outerID, eventValue))) {
|
||||
if (NS_FAILED(mStorage->RecordEvent(innerID, outerID, eventValue))) {
|
||||
NS_WARNING("Failed to record a console event.");
|
||||
}
|
||||
}
|
||||
|
@ -11,18 +11,12 @@ let Cc = Components.classes;
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// The console API events have to be scheduled when stored using
|
||||
// |recordPendingEvent|.
|
||||
const CALL_DELAY = 15 // milliseconds
|
||||
|
||||
// This constant tells how many messages to process in a single timer execution.
|
||||
const MESSAGES_IN_INTERVAL = 1500
|
||||
|
||||
const STORAGE_MAX_EVENTS = 200;
|
||||
|
||||
var _consoleStorage = new Map();
|
||||
var _consolePendingStorage = new Map();
|
||||
var _timer;
|
||||
|
||||
const CONSOLEAPISTORAGE_CID = Components.ID('{96cf7855-dfa9-4c6d-8276-f9705b4890f2}');
|
||||
|
||||
@ -141,51 +135,6 @@ ConsoleAPIStorageService.prototype = {
|
||||
Services.obs.notifyObservers(aEvent, "console-storage-cache-event", aId);
|
||||
},
|
||||
|
||||
/**
|
||||
* Similar to recordEvent, but these events are scheduled and stored any
|
||||
* CALL_DELAY millisecs.
|
||||
*/
|
||||
recordPendingEvent: function CS_recordPendingEvent(aId, aOuterId, aEvent)
|
||||
{
|
||||
if (!_consolePendingStorage.has(aId)) {
|
||||
_consolePendingStorage.set(aId, []);
|
||||
}
|
||||
|
||||
let storage = _consolePendingStorage.get(aId);
|
||||
storage.push({ outerId: aOuterId, event: aEvent });
|
||||
|
||||
if (!_timer) {
|
||||
_timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
}
|
||||
|
||||
let self = this;
|
||||
_timer.initWithCallback(function() { self.flushPendingEvents(); },
|
||||
CALL_DELAY, Ci.nsITimer.TYPE_REPEATING_SLACK);
|
||||
},
|
||||
|
||||
/**
|
||||
* Processes the pending event queue.
|
||||
*/
|
||||
flushPendingEvents: function CS_flushPendingEvents()
|
||||
{
|
||||
for (let [id, objs] of _consolePendingStorage) {
|
||||
for (let i = 0; i < objs.length && i < MESSAGES_IN_INTERVAL; ++i) {
|
||||
this.recordEvent(id, objs[i].outerId, objs[i].event);
|
||||
}
|
||||
|
||||
if (objs.length <= MESSAGES_IN_INTERVAL) {
|
||||
_consolePendingStorage.delete(id);
|
||||
} else {
|
||||
_consolePendingStorage.set(id, objs.splice(MESSAGES_IN_INTERVAL));
|
||||
}
|
||||
}
|
||||
|
||||
if (_timer && _consolePendingStorage.size == 0) {
|
||||
_timer.cancel();
|
||||
_timer = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear storage data for the given window.
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(cce39123-585e-411b-9edd-2513f7cf7e47)]
|
||||
[scriptable, uuid(9e32a7b6-c4d1-4d9a-87b9-1ef6b75c27a9)]
|
||||
interface nsIConsoleAPIStorage : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -35,22 +35,6 @@ interface nsIConsoleAPIStorage : nsISupports
|
||||
*/
|
||||
void recordEvent(in DOMString aId, in DOMString aOuterId, in jsval aEvent);
|
||||
|
||||
/**
|
||||
* Similar to recordEvent() but these events will be collected
|
||||
* and dispatched with a timer in order to avoid flooding the devtools
|
||||
* webconsole.
|
||||
*
|
||||
* @param string aId
|
||||
* The ID of the inner window for which the event occurred or "jsm" for
|
||||
* messages logged from JavaScript modules..
|
||||
* @param string aOuterId
|
||||
* This ID is used as 3rd parameters for the console-api-log-event
|
||||
* notification.
|
||||
* @param object aEvent
|
||||
* A JavaScript object you want to store.
|
||||
*/
|
||||
void recordPendingEvent(in DOMString aId, in DOMString aOuterId, in jsval aEvent);
|
||||
|
||||
/**
|
||||
* Clear storage data for the given window.
|
||||
*
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
const TEST_URI = "http://example.com/browser/dom/tests/browser/test-console-api.html";
|
||||
|
||||
var gWindow, gLevel, gArgs, gTestDriver, gStyle;
|
||||
var gWindow, gLevel, gArgs, gStyle;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
@ -15,7 +15,7 @@ function test() {
|
||||
var browser = gBrowser.selectedBrowser;
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
gWindow = gLevel = gArgs = gTestDriver = null;
|
||||
gWindow = gLevel = gArgs = null;
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
@ -26,8 +26,7 @@ function test() {
|
||||
executeSoon(function test_executeSoon() {
|
||||
gWindow = browser.contentWindow;
|
||||
consoleAPISanityTest();
|
||||
gTestDriver = observeConsoleTest();
|
||||
gTestDriver.next();
|
||||
observeConsoleTest();
|
||||
});
|
||||
|
||||
}, false);
|
||||
@ -74,8 +73,6 @@ function testConsoleData(aMessageObject) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gTestDriver.next();
|
||||
}
|
||||
|
||||
function testLocationData(aMessageObject) {
|
||||
@ -215,127 +212,100 @@ function observeConsoleTest() {
|
||||
let win = XPCNativeWrapper.unwrap(gWindow);
|
||||
expect("log", "arg");
|
||||
win.console.log("arg");
|
||||
yield undefined;
|
||||
|
||||
expect("info", "arg", "extra arg");
|
||||
win.console.info("arg", "extra arg");
|
||||
yield undefined;
|
||||
|
||||
expect("warn", "Lesson 1: PI is approximately equal to 3");
|
||||
win.console.warn("Lesson %d: %s is approximately equal to %1.0f",
|
||||
1,
|
||||
"PI",
|
||||
3.14159);
|
||||
yield undefined;
|
||||
|
||||
expect("warn", "Lesson 1: PI is approximately equal to 3.14");
|
||||
win.console.warn("Lesson %d: %s is approximately equal to %1.2f",
|
||||
1,
|
||||
"PI",
|
||||
3.14159);
|
||||
yield undefined;
|
||||
|
||||
expect("warn", "Lesson 1: PI is approximately equal to 3.141590");
|
||||
win.console.warn("Lesson %d: %s is approximately equal to %f",
|
||||
1,
|
||||
"PI",
|
||||
3.14159);
|
||||
yield undefined;
|
||||
|
||||
expect("warn", "Lesson 1: PI is approximately equal to 3.1415900");
|
||||
win.console.warn("Lesson %d: %s is approximately equal to %0.7f",
|
||||
1,
|
||||
"PI",
|
||||
3.14159);
|
||||
yield undefined;
|
||||
|
||||
expect("log", "%d, %s, %l");
|
||||
win.console.log("%d, %s, %l");
|
||||
yield undefined;
|
||||
|
||||
expect("log", "%a %b %g");
|
||||
win.console.log("%a %b %g");
|
||||
yield undefined;
|
||||
|
||||
expect("log", "%a %b %g", "a", "b");
|
||||
win.console.log("%a %b %g", "a", "b");
|
||||
yield undefined;
|
||||
|
||||
expect("log", "2, a, %l", 3);
|
||||
win.console.log("%d, %s, %l", 2, "a", 3);
|
||||
yield undefined;
|
||||
|
||||
// Bug #692550 handle null and undefined.
|
||||
expect("log", "null, undefined");
|
||||
win.console.log("%s, %s", null, undefined);
|
||||
yield undefined;
|
||||
|
||||
// Bug #696288 handle object as first argument.
|
||||
let obj = { a: 1 };
|
||||
expect("log", obj, "a");
|
||||
win.console.log(obj, "a");
|
||||
yield undefined;
|
||||
|
||||
expect("dir", win.toString());
|
||||
win.console.dir(win);
|
||||
yield undefined;
|
||||
|
||||
expect("error", "arg");
|
||||
win.console.error("arg");
|
||||
yield undefined;
|
||||
|
||||
expect("exception", "arg");
|
||||
win.console.exception("arg");
|
||||
yield undefined;
|
||||
|
||||
expect("log", "foobar");
|
||||
gStyle = ["color:red;foobar;;"];
|
||||
win.console.log("%cfoobar", gStyle[0]);
|
||||
yield undefined;
|
||||
|
||||
let obj4 = { d: 4 };
|
||||
expect("warn", "foobar", obj4, "test", "bazbazstr", "last");
|
||||
gStyle = [null, null, null, "color:blue;", "color:red"];
|
||||
win.console.warn("foobar%Otest%cbazbaz%s%clast", obj4, gStyle[3], "str", gStyle[4]);
|
||||
yield undefined;
|
||||
|
||||
let obj3 = { c: 3 };
|
||||
expect("info", "foobar", "bazbaz", obj3, "%comg", "color:yellow");
|
||||
gStyle = [null, "color:pink;"];
|
||||
win.console.info("foobar%cbazbaz", gStyle[1], obj3, "%comg", "color:yellow");
|
||||
yield undefined;
|
||||
|
||||
gStyle = null;
|
||||
let obj2 = { b: 2 };
|
||||
expect("log", "omg ", obj, " foo ", 4, obj2);
|
||||
win.console.log("omg %o foo %o", obj, 4, obj2);
|
||||
yield undefined;
|
||||
|
||||
expect("assert", "message");
|
||||
win.console.assert(false, "message");
|
||||
yield undefined;
|
||||
|
||||
expect("count", { label: "label a", count: 1 })
|
||||
win.console.count("label a");
|
||||
yield undefined;
|
||||
|
||||
expect("count", { label: "label b", count: 1 })
|
||||
win.console.count("label b");
|
||||
yield undefined;
|
||||
|
||||
expect("count", { label: "label a", count: 2 })
|
||||
win.console.count("label a");
|
||||
yield undefined;
|
||||
|
||||
expect("count", { label: "label b", count: 2 })
|
||||
win.console.count("label b");
|
||||
yield undefined;
|
||||
|
||||
startTraceTest();
|
||||
yield undefined;
|
||||
|
||||
startLocationTest();
|
||||
yield undefined;
|
||||
}
|
||||
|
||||
function consoleAPISanityTest() {
|
||||
|
Loading…
Reference in New Issue
Block a user