Bug 1050104 - Do not return a new console object every time self.console is called on workers; r=baku

This commit is contained in:
Ehsan Akhgari 2014-08-08 08:34:30 -04:00
parent 368a5b3a15
commit 85c6c5911a
4 changed files with 11 additions and 4 deletions

View File

@ -80,17 +80,16 @@ WorkerGlobalScope::WrapObject(JSContext* aCx)
MOZ_CRASH("We should never get here!");
}
already_AddRefed<Console>
Console*
WorkerGlobalScope::GetConsole()
{
mWorkerPrivate->AssertIsOnWorkerThread();
if (!mConsole) {
mConsole = new Console(nullptr);
MOZ_ASSERT(mConsole);
}
return mConsole.forget();
return mConsole;
}
already_AddRefed<WorkerLocation>

View File

@ -60,7 +60,7 @@ public:
return nsRefPtr<WorkerGlobalScope>(this).forget();
}
already_AddRefed<Console>
Console*
GetConsole();
already_AddRefed<WorkerLocation>

View File

@ -5,6 +5,12 @@
onmessage = function(event) {
postMessage({event: 'console exists', status: !!console, last : false});
var logCalled = false;
console.log = function() {
logCalled = true;
}
console.log("foo");
postMessage({event: 'console.log is replaceable', status: logCalled, last: false});
console = 42;
postMessage({event: 'console is replaceable', status: console === 42, last : true});
}

View File

@ -7,6 +7,8 @@ onmessage = function(event) {
// TEST: does console exist?
postMessage({event: 'console exists', status: !!console, last : false});
postMessage({event: 'console is the same object', status: console === console, last: false});
postMessage({event: 'trace without function', status: true, last : false});
for (var i = 0; i < 10; ++i) {