Bug 12720

Summary: Re-defining window.location.toString function keeps re-loading forever
Product: WebKit Reporter: Feng Qian <ian.eng.webkit>
Component: DOMAssignee: Feng Qian <ian.eng.webkit>
Status: RESOLVED FIXED    
Severity: Normal CC: ap
Priority: P2 Keywords: HasReduction
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
Test case
none
patch
none
a better test with expected output mjs: review+

Feng Qian
Reported 2007-02-09 15:37:45 PST
Create a page with a statement: window.location.toString = function() { return "www.cnn.com"; } Open it in a new window, it keeps re-loading the page.
Attachments
Test case (83 bytes, text/html)
2007-02-09 15:58 PST, David Kilzer (:ddkilzer)
no flags
patch (1.53 KB, patch)
2007-02-27 18:41 PST, Feng Qian
no flags
a better test with expected output (1.86 KB, patch)
2007-02-27 18:45 PST, Feng Qian
mjs: review+
David Kilzer (:ddkilzer)
Comment 1 2007-02-09 15:57:34 PST
Behavior confirmed in shipping Safari 2.0.4 (419.3) on Mac OS X 10.4.8 (8N1037) and a local debug build of WebKit r19537 with the same software. Both Firefox 2.0.0.1 and Opera 9.10 don't appear to log any errors when the test case is loaded--they just silently refuse to change the built-in function.
David Kilzer (:ddkilzer)
Comment 2 2007-02-09 15:58:14 PST
Created attachment 13098 [details] Test case
Feng Qian
Comment 3 2007-02-27 18:41:01 PST
Created attachment 13417 [details] patch The bug is caused by Location::put if the property name is a function name in the LocationTable. It does not change URL, but put() will think the URL was changed and reload the file again, and into an infinite loop. The fix just returns early when it founds the property name is in the LocationTable, but not changing URL.
Feng Qian
Comment 4 2007-02-27 18:45:16 PST
Created attachment 13418 [details] a better test with expected output
Maciej Stachowiak
Comment 5 2007-02-27 18:50:23 PST
This looks ok, but it might be better to mark the functions that should not be replaceable as read-only.
Maciej Stachowiak
Comment 6 2007-02-27 22:53:35 PST
Comment on attachment 13418 [details] a better test with expected output After further consideration this fix seems ok.
Feng Qian
Comment 7 2007-03-01 12:04:51 PST
(In reply to comment #5) > This looks ok, but it might be better to mark the functions that should not be > replaceable as read-only. > How does ReadOnly attribute work? Will the call be returned before calling Location::put ?
Mark Rowe (bdash)
Comment 8 2007-03-06 19:30:41 PST
Landed in r19995. Thanks for the patch Ian. Can you please ensure that you use spaces rather than tabs in your ChangeLog entries, and that they are consistent in formatting with other entries. I'm specifically thinking of new lines between description and file list, and the presence of the "Reviewed by NOBODY" line. The latter will ensure that the patch cannot be landed unless the reviewer is added.
Mark Rowe (bdash)
Comment 9 2007-03-06 19:44:32 PST
I also just noticed that you forgot to include a changelog for the LayoutTests portion of your patch.
Mark Rowe (bdash)
Comment 10 2007-03-06 20:30:07 PST
Not to keep going on... but the expected results you provided didn't match the test. I updated the test in r20002 to make things pass.
Feng Qian
Comment 11 2007-03-07 12:47:44 PST
(In reply to comment #8) > Landed in r19995. > > Thanks for the patch Ian. Can you please ensure that you use spaces rather > than tabs in your ChangeLog entries, and that they are consistent in formatting > with other entries. I'm specifically thinking of new lines between description > and file list, and the presence of the "Reviewed by NOBODY" line. The latter > will ensure that the patch cannot be landed unless the reviewer is added. Thanks Mike. I will try my best to remember these style rules. >
Note You need to log in before you can comment on or make changes to this bug.