Bug 21752 - REGRESSION: referencing XHR constructor for a not yet loaded frame permanently breaks it
Summary: REGRESSION: referencing XHR constructor for a not yet loaded frame permanentl...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac OS X 10.5
: P1 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords: HasReduction, InRadar, Regression
Depends on:
Blocks:
 
Reported: 2008-10-20 07:47 PDT by Alexey Proskuryakov
Modified: 2009-03-16 00:40 PDT (History)
2 users (show)

See Also:


Attachments
test case (1.55 KB, application/zip)
2008-10-20 07:48 PDT, Alexey Proskuryakov
no flags Details
proposed fix (17.21 KB, patch)
2009-03-02 07:40 PST, Alexey Proskuryakov
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2008-10-20 07:47:51 PDT
To reproduce, see attached test case.

This is a regression caused by r36954, which enabled certain constructors to be cached on the Window, as they should be. Unfortunately, this conflicts with a pre-existing issue in WebCore - the Window object is not properly replaced/cleared when transitioning from a temporary document created before loading to an actual one.

The attached test case checks both the pre-existing issue, and its new manifestation.
Comment 1 Alexey Proskuryakov 2008-10-20 07:48:35 PDT
Created attachment 24523 [details]
test case
Comment 2 Alexey Proskuryakov 2008-10-20 07:50:06 PDT
<rdar://problem/6303355>
Comment 3 Alexey Proskuryakov 2009-03-02 06:06:33 PST
In fact, this "pre-existing issue" is expected behavior, see <http://trac.webkit.org/changeset/25783/trunk/WebCore/loader/FrameLoader.cpp>. The attached test is faulty, as the way logging is done affects its results.

The problem with XMLHttpRequest being broken remains.
Comment 4 Alexey Proskuryakov 2009-03-02 07:40:13 PST
Created attachment 28175 [details]
proposed fix
Comment 5 Adam Barth 2009-03-02 09:30:47 PST
Have you tested whether this creates memory leaks?  It seems like the JSGlobalObject holds on to the JSImageConstructor, which now mark()s the JSGlobalObject...
Comment 6 Adam Barth 2009-03-02 09:43:51 PST
Ignore my previous comment.  I forgot that we use mark-and-sweep.
Comment 7 Sam Weinig 2009-03-13 12:27:12 PDT
In what cases are we replacing the document but not the window object.  Ideally, these should be one-to-one now.
Comment 8 Darin Adler 2009-03-13 12:32:44 PDT
Comment on attachment 28175 [details]
proposed fix

r=me

I'm slightly worried since it would be insecure to re-use these JavaScript objects with a new document with a different security origin. But I guess we have tests to cover that possibility and they are not re-used in that bad way.
Comment 9 Alexey Proskuryakov 2009-03-13 12:38:44 PDT
Sam, one case where we must replace only the document is in r25783.
Comment 10 Alexey Proskuryakov 2009-03-16 00:40:55 PDT
Committed <http://trac.webkit.org/changeset/41732>.

> I'm slightly worried since it would be insecure to re-use these JavaScript
> objects with a new document with a different security origin.

My understanding is that this patch doesn't make security weaker, because the only transition that ever happens is from about:blank.