Steps to reproduce: Open http://rodneyrehm.de/t/css.escape (with cold cache / freshly started browser) and open DevTools and run `CSS.escape` to print the value. Expected behavior: The function's body is printed to the console Actual behavior: `undefined` is printed to the console Additional Notes: The issue cannot be reproduced reliably. Sometimes hitting Command+R will make CSS.escape actually hold the function, sometimes you need Command+Shift+R. Usually cleaning the cache and or restarting the browser before opening this page will make WebKit (or JavaScriptCore, or whatever) exhibit this behavior. Eventually CSS.escape will hold the function, but it may lose it again. It feels like some script optimization routine is (sometimes) killing the function declaration, because it is not used immediately (i.e. dead code removal), or some such. Live Testcase: http://rodneyrehm.de/t/css.escape Related issue on Github: https://github.com/mathiasbynens/CSS.escape/issues/2
Confirmed in r189569.
*** This bug has been marked as a duplicate of bug 126337 ***
(In reply to comment #2) > > *** This bug has been marked as a duplicate of bug 126337 *** Note that this is not really a duplicate of bug 126337. Fixing bug 126337 would work around the issue in this specific case of `CSS.escape` but the underlying JavaScriptCore bug would still be there.
Oh, you're right. Sorry about that. It isn't about WebKit missing CSS.escape. It is about a bizarre WebKit behavior with this particular CSS.escape shim.
We encountered the same issue (with the same polyfill) in Wikipedia/MediaWiki. Issue was tracked: https://phabricator.wikimedia.org/T121991
<rdar://problem/24448680>
You can also reproduce it be delaying the lookup with a setTimeout. The code below alerts('window.CSS.escape missing in event') in Version 9.1 (10601.5.17.4) <html> <script src='css.escape.js'></script> <script type='text/javascript'> if (!window.CSS.escape) { alert('window.CSS.escape not loaded'); } console.log(!!window.CSS.escape); setTimeout(function() { console.log(!!window.CSS.escape); if (!window.CSS.escape) { alert('window.CSS.escape missing in event'); } },5000); </script> </html>
I can't get this to reproduce in WebKit trunk right anymore. Please reopen if you can get it to fail in trunk, nightly, etc.
Created attachment 278255 [details] patch that has the regression test
Comment on attachment 278255 [details] patch that has the regression test rs=me if it bots don't complain.
Confirmed. Still broken in Safari Version 9.1 (11601.5.17.1), but works in STP Version 9.1.1 (11601.6.17, 11602.1.29).