Bug 12471 - XPathResult not invalidated for documents retrieved via XMLHttpRequest
Summary: XPathResult not invalidated for documents retrieved via XMLHttpRequest
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: XML (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks: 12450
  Show dependency treegraph
 
Reported: 2007-01-30 01:11 PST by Alexey Proskuryakov
Modified: 2009-06-01 01:28 PDT (History)
0 users

See Also:


Attachments
work in progress (5.66 KB, patch)
2007-01-31 12:34 PST, Alexey Proskuryakov
no flags Details | Formatted Diff | Diff
proposed fix (13.53 KB, patch)
2009-06-01 00:57 PDT, 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 2007-01-30 01:11:58 PST
XPathResult relies on DOM Mutation events for invalidation, but these don't work for documents retrieved via XMLHttpRequest (addEventListener() checks for document()->attached(), and bails out if it's not).

This causes several layout test failures:
dom/svg/level3/xpath/XPathResult_invalidIteratorState_ORDERED_NODE_ITERATOR_TYPE.svg
dom/svg/level3/xpath/XPathResult_invalidIteratorState_UNORDERED_NODE_ITERATOR_TYPE.svg
dom/svg/level3/xpath/XPathResult_invalidIteratorState_ANY_TYPE.svg
dom/svg/level3/xpath/XPathResult_iterateNext_INVALID_STATE_ERR.svg
Comment 1 Alexey Proskuryakov 2007-01-30 22:15:28 PST
This check for document()->attached() was added in r8557 <http://trac.webkit.org/projects/webkit/changeset/8557> as a part of a fix to memory leaks on eBay.
Comment 2 Alexey Proskuryakov 2007-01-31 12:34:46 PST
Created attachment 12832 [details]
work in progress

It seems that DOM events don't work for createDocument() and XMLHttpRequest-based documents in Firefox and Opera, too.

I've tried rewriting XPathResult to use domTreeVersion for invalidation - but that also doesn't work in such documents (the DOM version is mostly updated from attach()/detach()).
Comment 3 Alexey Proskuryakov 2009-06-01 00:57:18 PDT
Created attachment 30828 [details]
proposed fix

DOM tree version magically works in ToT.
Comment 4 Darin Adler 2009-06-01 01:20:25 PDT
Comment on attachment 30828 [details]
proposed fix

> + * Copyright (C) 2006, 2009 Apple Computer, Inc.

The preferred form is "<year> Apple Inc. All rights reserved."

I sometimes worry that the single document-wide tree version number is too blunt a tool; glad it works better here than what we were doing before!

r=me
Comment 5 Alexey Proskuryakov 2009-06-01 01:28:05 PDT
Committed r44317.