Opened 9 years ago

Closed 7 years ago

#12059 closed defect (wontfix)

firebug.js: replacements for console logging functions break if defined more than once

Reported by: steve.pemberton Owned by: Mike Wilcox
Priority: high Milestone: tbd
Component: Core Version: 1.4.3
Keywords: Cc: steve.pemberton@…
Blocked By: Blocking:

Description

firebug.js contains its own versions of the various console logging functions (log, info, debug, warn and error) for use in Internet Explorer. These begin on line 76 in my copy of this file, with the statement:

var isNewIE = (/Trident/.test(window.navigator.userAgent));

If a page includes firebug.js more than once (that is, redefining the logging functions more than once, not using them more than once), they break, causing the Javascript stack to overflow when the page attempts to write something to the console.

For each function, firebug.js saves the original definition by renaming it to have an underscore in front, and then redefines the function to call the original, but with the arguments separated by spaces. According to the comments, this is because if you call console.log("A", "B", "C") in Internet Explorer, it prints "ABC", whereas we want "A B C".

If your page calls firebug.js more than once, it will overwrite its backup of the original functions, so that console._log is no longer the real function, but just points to the previous redefinition of console.log. This causes unlimited recursion, which the browser stops when it runs out of stack space.

A suitable fix would be to check whether the backup of the function already exists, and only assign it if it doesn't.

This could be considered to be operator error, because you shouldn't call code twice if it's only meant to be called once... but it shouldn't break so badly if you do call it twice.

As for why I don't just take out the second include of firebug.js... it happens inside a large framework that I have no control over, and the people who maintain the framework seem to think it's a Dojo bug.

I've recorded this bug as affecting 1.4.3, since that's what we're using, but I assume it affects 1.5 as well, since firebug.js is identical in the two versions.

I have attached a small file that should reproduce the problem.

Attachments (1)

index.html (556 bytes) - added by steve.pemberton 9 years ago.
Test case to break console logging functions

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by steve.pemberton

Attachment: index.html added

Test case to break console logging functions

comment:1 Changed 9 years ago by Chris Mitchell

Owner: anonymous deleted

comment:2 Changed 8 years ago by bill

Component: GeneralCore
Owner: set to Mike Wilcox
Status: newassigned

comment:3 Changed 7 years ago by Mike Wilcox

Resolution: wontfix
Status: assignedclosed

If anything, steps should be made to remove this module or make it opt-in only.

Note: See TracTickets for help on using tickets.