
google-caja - issue #1688
Firefox 20 issue: cannot use the given object as a weak map key
On Firefox version 20.0 (Windows 8), triggered event handlers such as onclick cause "cannot use the given object as a weak map key" error to be thrown at a point before control is handed over to the function which should be called. This behavior can be seen at on the Google Caja Playground (when using Firefox 20) with any of the example applications which make use of such event handlers (the Unboxed Game for example).
What steps will reproduce the problem? 1. Load Firefox 20.0. 2. Go to the Google Caja Playground and load the "Unboxed Game". 3. Click any of the boxes or the restart button. 4. "Uncaught script error: 'cannot use the given object as a weak map key' in source: 'unknown' at line: 0" should be displayed in the Runtime Messages.
What is the expected output? What do you see instead? The expected result is the event being handed over to the function the event called. The actual result is the error is displayed and nothing else happens.
Please provide any additional information below.
Comment #1
Posted on Apr 3, 2013 by Helpful HorseConfirmed.
Comment #2
Posted on Apr 9, 2013 by Swift CamelI don't see the issue in Firefox Aurora 22. It has probably been fixed somewhere between Firefox 20 and now. I would have bet https://bugzilla.mozilla.org/show_bug.cgi?id=777385 , but this bug says the fix has been applied to Firefox 20. Anyway, it seems that it works in Firefox 22
Comment #3
Posted on Apr 10, 2013 by Helpful HorseDiagnosis: This happens because, in FF20, we detect and use a native WeakMap implementation, but that WeakMap cannot accept native Event objects as keys.
Comment #4
Posted on Apr 11, 2013 by Swift CamelNote: This bug is still a problem in FF 21.0b2.
Comment #5
Posted on Apr 11, 2013 by Swift HippoIf necessary, we could add a test and repair to repairES5 that wraps WeakMap.prototype.* to detect Event objects and keep them in a separate inefficient side table. Or we could just add a test that causes us to fall back all the way to our WeakMap emulation.
Comment #6
Posted on Apr 11, 2013 by Swift HippoDuplicate of https://code.google.com/p/google-caja/issues/detail?id=1567 ?
Comment #7
Posted on Apr 11, 2013 by Happy HorseYes, this is the same issue as 1567. It is being tracked as https://bugzilla.mozilla.org/show_bug.cgi?id=803844 It should be mostly fixed now in Firefox 22. I made weak maps work with "new DOM bindings", which landed in Firefox 20 with https://bugzilla.mozilla.org/show_bug.cgi?id=777385 and then in Firefox 22, Olli Pettay has converted most of the events over to the "new DOM bindings", so the combination of the two fixes this particular problem. Sorry it has taken so long to properly fix.
Comment #8
Posted on Apr 17, 2013 by Helpful HorseFixed in r5353, see https://codereview.appspot.com/8612048/.
Comment #9
Posted on Apr 24, 2013 by Grumpy RhinoNot fixed. The problem still exists on Mac and with Google Apps Script.
Comment #10
Posted on Apr 24, 2013 by Helpful HorseThanks for the report. However, at the moment, Google Apps Script is running r5346, which does not include the fix.
Comment #11
Posted on Apr 24, 2013 by Grumpy RhinoThank you for quick answer. Is there any known workaround for the problem? All my web apps are unusable in Firefox and I need to ask users to use different browser. Thank you.
Comment #12
Posted on Apr 26, 2013 by Swift BearSame error using HtmlService.createHtmlOutput() method to render a piece of html. When clicked in a button in the page, firefox 20.0.1 throws this error. All javascript event handlers are not called.
Status: Fixed
Labels:
Type-Defect
Priority-Medium