LayoutTests:
authorggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 21:52:17 +0000 (21:52 +0000)
committerggaren <ggaren@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Jun 2006 21:52:17 +0000 (21:52 +0000)
        - Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9113
        REGRESSION (14581): XMLHttpRequest never calls onreadystatechange with
        a readystate == 4

        * http/tests/xmlhttprequest/event-listener-gc.html: Added.
        * http/tests/xmlhttprequest/event-listener-gc-expected.txt: Added.

WebCore:

        Fix by Mitz. Reviewed, tweaked, tested, landed by me.

        - Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=9113
        REGRESSION (14581): XMLHttpRequest never calls onreadystatechange with
        a readystate == 4

        An XMLHttpRequest must be added to the DOMObject cache so that its
        DOM implementation object can protect it, and by extension, its event
        listeners.

        This design seems slightly backwards to me -- the bindings should know
        about the DOM, not the other way around -- but I'm restoring it for
        now to fix the regression.

        * bindings/js/JSXMLHttpRequest.cpp:
        (KJS::JSXMLHttpRequest::JSXMLHttpRequest):
        (KJS::JSXMLHttpRequest::~JSXMLHttpRequest):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/xmlhttprequest/event-listener-gc-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/xmlhttprequest/event-listener-gc.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/bindings/js/JSXMLHttpRequest.cpp

index 1fc3f0be16be73a8f40eb1c2ca86667b7f6598be..bd07e9142711040bd69260c6d6b6c5d7f46a800c 100644 (file)
@@ -1,3 +1,12 @@
+2006-06-01  Geoffrey Garen  <ggaren@apple.com>
+
+        - Test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9113
+        REGRESSION (14581): XMLHttpRequest never calls onreadystatechange with 
+        a readystate == 4
+
+        * http/tests/xmlhttprequest/event-listener-gc.html: Added.
+        * http/tests/xmlhttprequest/event-listener-gc-expected.txt: Added.
+
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin.
diff --git a/LayoutTests/http/tests/xmlhttprequest/event-listener-gc-expected.txt b/LayoutTests/http/tests/xmlhttprequest/event-listener-gc-expected.txt
new file mode 100644 (file)
index 0000000..46f7c82
--- /dev/null
@@ -0,0 +1,10 @@
+This test checks whether event handlers for outstanding XMLHttpRequests survive garbage collection.
+
+See http://bugzilla.opendarwin.org/show_bug.cgi?id=9113 REGRESSION (14581): XMLHttpRequest never calls onreadystatechange with a readystate == 4
+
+If the test passes, you'll see a series of 'PASS' messages below.
+
+PASS: event handler fired after garbage collection.
+PASS: event handler fired after garbage collection.
+PASS: event handler fired after garbage collection.
+
diff --git a/LayoutTests/http/tests/xmlhttprequest/event-listener-gc.html b/LayoutTests/http/tests/xmlhttprequest/event-listener-gc.html
new file mode 100644 (file)
index 0000000..678d9d5
--- /dev/null
@@ -0,0 +1,51 @@
+<html>
+<head>
+<script>
+function write(s)
+{
+    document.getElementById('pre').appendChild(document.createTextNode(s));
+}
+
+var didCollect = false;
+function collect()
+{
+    didCollect = true;
+    if (window.GCController)
+        GCController.collect();
+    else
+        for (var i = 0; i < 10000; i++) // >
+            new String("");
+}
+
+function processStateChange()
+{
+    if (didCollect)
+        write("PASS: event handler fired after garbage collection.\n");
+}
+
+function test() 
+{
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+        
+    var request = new XMLHttpRequest();
+    request.onreadystatechange = processStateChange;
+    request.open("GET", "print-content-type.cgi", true);
+    request.send(null);
+    
+    setTimeout('collect();', 0); // timeout ensures stack references to request are cleared when we collect
+}
+</script>
+</head>
+
+<body onload="test();">
+<p>This test checks whether event handlers for outstanding XMLHttpRequests survive garbage collection.</p>
+<p>See http://bugzilla.opendarwin.org/show_bug.cgi?id=9113 REGRESSION (14581): 
+XMLHttpRequest never calls onreadystatechange with a readystate == 4</p>
+<p>If the test passes, you'll see a series of 'PASS' messages below.</p>
+<hr>
+
+<pre id='pre'></pre>
+
+</body>
+</html>
index 4b38a133ec7f8ae97062869c5502cd0439544864..a3875cd3f4dfdced12e4a94af8ae72a22819cd67 100644 (file)
@@ -1,3 +1,23 @@
+2006-06-01  Geoffrey Garen  <ggaren@apple.com>
+
+        Fix by Mitz. Reviewed, tweaked, tested, landed by me.
+
+        - Fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=9113
+        REGRESSION (14581): XMLHttpRequest never calls onreadystatechange with 
+        a readystate == 4
+        
+        An XMLHttpRequest must be added to the DOMObject cache so that its
+        DOM implementation object can protect it, and by extension, its event
+        listeners.
+        
+        This design seems slightly backwards to me -- the bindings should know
+        about the DOM, not the other way around -- but I'm restoring it for
+        now to fix the regression.
+        
+        * bindings/js/JSXMLHttpRequest.cpp:
+        (KJS::JSXMLHttpRequest::JSXMLHttpRequest):
+        (KJS::JSXMLHttpRequest::~JSXMLHttpRequest):
+
 2006-06-01  Anders Carlsson  <acarlsson@apple.com>
 
         * platform/KURL.cpp:
index c59c35c3f88640dd58288620dcd812ae54fa611b..c71023aab7cd0560ebe1b669ff97f53bac70b496 100644 (file)
@@ -154,12 +154,14 @@ JSXMLHttpRequest::JSXMLHttpRequest(ExecState *exec, Document *d)
   : m_impl(new XMLHttpRequest(d))
 {
   setPrototype(JSXMLHttpRequestProto::self(exec));
+  ScriptInterpreter::putDOMObject(m_impl.get(), this);
 }
 
 JSXMLHttpRequest::~JSXMLHttpRequest()
 {
   m_impl->setOnReadyStateChangeListener(0);
   m_impl->setOnLoadListener(0);
+  ScriptInterpreter::forgetDOMObject(m_impl.get());
 }
 
 JSValue* JSXMLHttpRequestProtoFunc::callAsFunction(ExecState *exec, JSObject* thisObj, const List& args)