Title: [134180] trunk
Revision
134180
Author
[email protected]
Date
2012-11-11 17:40:04 -0800 (Sun, 11 Nov 2012)

Log Message

Internals: MockPagePopup should not update DOM structure during detach()
https://bugs.webkit.org/show_bug.cgi?id=101710

Reviewed by Hajime Morita.

Source/WebCore:

PickerIndicatorElement::detach calls
MockPagePopupDriver::closePagePopup, MockPagePopup::~MockPagePopup,
which remove the mock iframe from the tree. But updating the tree during
detach() is dangerous.

MockPagePopupDriver::closePagePopup calls MockpagePopup::closeLater, it
requests to call 'close' asynchronously, and 'close' removes the mock
iframe. We need to change MockPagePopup so that it is ref-couted and has
a timer.

No new tests. This is a change for the test harness.

* testing/MockPagePopupDriver.cpp:
(MockPagePopup): Make this ref-counted, add closeLater, add close, and
add m_closeTimer.
(WebCore::MockPagePopup::MockPagePopup): Initialize the timer.
(WebCore::MockPagePopup::create): PassOwnPtr -> PassRefPtr
(WebCore::MockPagePopup::closeLater):
- Add one reference to avoid destruction by m_mockPagePopup.clear() in
  closePagePopup.
- Notify didClosePopup here because the client expects didClosePopup is
  called synchronously.
- Invoke the timer to call 'close'
(WebCore::MockPagePopup::close):
Just remove one reference. This means calling the desructor.
(WebCore::MockPagePopup::~MockPagePopup):
Move didClosePopup call to caloseLater.
(WebCore::MockPagePopupDriver::closePagePopup):
Request to close PagePopup.
Clear PagePopupClient in m_pagePopupController because this object is
necessary until MockPagePopup is closed, but it should not have a
reference to the PagePopupClient.
* testing/MockPagePopupDriver.h:
(MockPagePopupDriver): Make MockPagePopup ref-counted.

LayoutTests:

Update tests because page popup closing becomes asynchronous.

* fast/forms/resources/picker-common.js:
(waitUntilClosing): Added. Helper to wait until a page popup closing.
* platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html:
* platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html:
* platform/chromium/fast/forms/calendar-picker/calendar-picker-pre-100-year.html:
* platform/chromium/fast/forms/calendar-picker/calendar-picker-type-change-onchange.html:
* platform/chromium/fast/forms/calendar-picker/calendar-picker-with-step.html:
* platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html:
* platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-mouse-operations.html:
* platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-reset-value-after-reload.html:
* platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-step-attribute.html:
* platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html:
* platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-mouse-operations.html:
* platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-step-attribute.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (134179 => 134180)


--- trunk/LayoutTests/ChangeLog	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/ChangeLog	2012-11-12 01:40:04 UTC (rev 134180)
@@ -1,3 +1,27 @@
+2012-11-11  Kent Tamura  <[email protected]>
+
+        Internals: MockPagePopup should not update DOM structure during detach()
+        https://bugs.webkit.org/show_bug.cgi?id=101710
+
+        Reviewed by Hajime Morita.
+
+        Update tests because page popup closing becomes asynchronous.
+
+        * fast/forms/resources/picker-common.js:
+        (waitUntilClosing): Added. Helper to wait until a page popup closing.
+        * platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html:
+        * platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html:
+        * platform/chromium/fast/forms/calendar-picker/calendar-picker-pre-100-year.html:
+        * platform/chromium/fast/forms/calendar-picker/calendar-picker-type-change-onchange.html:
+        * platform/chromium/fast/forms/calendar-picker/calendar-picker-with-step.html:
+        * platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html:
+        * platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-mouse-operations.html:
+        * platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-reset-value-after-reload.html:
+        * platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-step-attribute.html:
+        * platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html:
+        * platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-mouse-operations.html:
+        * platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-step-attribute.html:
+
 2012-11-11  Raphael Kubo da Costa  <[email protected]>
 
         [WK2] Mark fast/repaint/body-background-image.html as flaky.

Modified: trunk/LayoutTests/fast/forms/resources/picker-common.js (134179 => 134180)


--- trunk/LayoutTests/fast/forms/resources/picker-common.js	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/fast/forms/resources/picker-common.js	2012-11-12 01:40:04 UTC (rev 134180)
@@ -25,6 +25,10 @@
     popupOpenCallback();
 }
 
+function waitUntilClosing(callback) {
+    setTimeout(callback, 1);
+}
+
 function sendKey(input, keyName, ctrlKey, altKey) {
     var event = document.createEvent('KeyboardEvent');
     event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName, 0, ctrlKey, altKey);

Modified: trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-key-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -85,6 +85,10 @@
     shouldBe('currentMonth()', '"2000-01"');
 
     eventSender.keyDown('\n');
+    waitUntilClosing(test1AfterClosing);
+}
+
+function test1AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"1999-12-26"');
 

Modified: trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-mouse-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -42,9 +42,12 @@
 
     debug('Check that mouse click closes the popup and sets the value.');
     clickElement(popupWindow.document.querySelectorAll(".day:not(.week-column)")[6]);
+    waitUntilClosing(afterClosingCallback);
+}
+
+function afterClosingCallback() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"2000-02-05"');
-
     finishJSTest();
 }
 </script>

Modified: trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-pre-100-year.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-pre-100-year.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-pre-100-year.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -20,7 +20,7 @@
     sendKey(daysContainer, 'Right');
     sendKey(daysContainer, 'Enter');
     shouldBe('document.getElementById("date").value', '"0002-02-03"');
-    finishJSTest();
+    waitUntilClosing(finishJSTest);
 }
 </script>
 <script src=""

Modified: trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-type-change-onchange.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-type-change-onchange.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-type-change-onchange.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -16,7 +16,7 @@
 function changeType(input) {
     input.type = 'text';
     testPassed('unless crash');
-    finishJSTest();
+    waitUntilClosing(finishJSTest);
 }
 </script>
 <script src=""

Modified: trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-with-step.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-with-step.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/calendar-picker/calendar-picker-with-step.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -22,7 +22,10 @@
 
     // Close popup
     eventSender.keyDown('\x1B');
+    waitUntilClosing(test1AfterClose);
+}
 
+function test1AfterClose() {
     document.getElementById('date').min = "2011-05-01";
     
     // Reopen popup

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-key-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -131,6 +131,10 @@
     eventSender.keyDown('upArrow');
     shouldBe('highlightedEntry()', '"2012-03-08"');
     eventSender.keyDown("\n");
+    waitUntilClosing(test1AfterClosing);
+}
+
+function test1AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"2012-03-08"');
 
@@ -170,6 +174,10 @@
 
     debug('Check that escape key closes the popup.');
     eventSender.keyDown('\x1B');
+    waitUntilClosing(test3AfterClosing);
+}
+
+function test3AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"2012-03-08"');
 

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-mouse-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-mouse-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-mouse-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -103,6 +103,10 @@
 
     debug('Check that mouse click closes the popup and sets the value.');
     clickElement(popupWindow.document.querySelector(".suggestion-list-entry:nth-child(3)"));
+    waitUntilClosing(test1AfterClosing);
+}
+
+function test1AfterClosing() {
     shouldBeNull('$("mock-page-popup")');
     shouldBe('document.getElementById("date").value', '"2012-01-03"');
 
@@ -129,6 +133,10 @@
 
     popupWindow.focus();
     eventSender.keyDown('\x1B');
+    waitUntilClosing(test2AfterClosing);
+}
+
+function test2AfterClosing() {
     shouldBeNull('$("mock-page-popup")');
 
     openPicker($('date'), test3);

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-reset-value-after-reload.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-reset-value-after-reload.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-reset-value-after-reload.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -22,6 +22,10 @@
     eventSender.keyDown('downArrow');
     shouldBe('highlightedEntry()', '"2012-01-01"');
     eventSender.keyDown("\n");
+    waitUntilClosing(runOnOpenPopup1AfterClosing);
+}
+
+function runOnOpenPopup1AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('iframe.contentDocument.getElementById("test1").value', '"2012-01-01"');
 
@@ -35,6 +39,10 @@
     eventSender.keyDown('downArrow');
     shouldBe('highlightedEntry()', '"2012-01-01"');
     eventSender.keyDown("\n");
+    waitUntilClosing(runOnOpenPopup2AfterClosing);
+}
+
+function runOnOpenPopup2AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('iframe.contentDocument.getElementById("test2").value', '"2012-01-01"');
 
@@ -49,7 +57,7 @@
     shouldBeEqualToString('testInput1.value', '');
     shouldBeEqualToString('testInput2.value', '2002-02-02');
     iframe.parentNode.removeChild(iframe);
-    finishJSTest();
+    waitUntilClosing(finishJSTest);
 }
 </script>
 <iframe id=iframe _onload_="openPicker(event.target.contentDocument.getElementById('test1'), runOnOpenPopup1);" srcdoc="<input type=date id=test1 list=suggestions><input type=date id=test2 value=2002-02-02 list=suggestions><datalist id=suggestions><option>2012-01-01</option></datalist>"></iframe>

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-step-attribute.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-step-attribute.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/date-suggestion-picker-step-attribute.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -49,7 +49,10 @@
     shouldBeEqualToString('entryValues()[5]', '@openCalendarPicker');
 
     eventSender.keyDown('\x1B'); // Close picker.
+    waitUntilClosing(test1AfterClosing);
+}
 
+function test1AfterClosing() {
     dateElement.step = 5;
     openPicker(dateElement, test2);
 }
@@ -63,7 +66,10 @@
     shouldBeEqualToString('entryValues()[2]', '@openCalendarPicker');
 
     eventSender.keyDown('\x1B'); // Close picker.
+    waitUntilClosing(test2AfterClosing);
+}
 
+function test2AfterClosing() {
     dateElement.step = 30;
     openPicker(dateElement, test3);
 }

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-key-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -128,6 +128,10 @@
     eventSender.keyDown('upArrow');
     shouldBe('highlightedEntry()', '"02:07"');
     eventSender.keyDown("\n");
+    waitUntilClosing(test1AfterClosing);
+}
+
+function test1AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("time").value', '"02:07"');
 
@@ -143,6 +147,10 @@
 
     debug('Check that escape key closes the popup.');
     eventSender.keyDown('\x1B');
+    waitUntilClosing(test2AfterClosing);
+}
+
+function test2AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("time").value', '"02:07"');
 

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-mouse-operations.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-mouse-operations.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-mouse-operations.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -60,6 +60,10 @@
 
     debug('Check that mouse click closes the popup and sets the value.');
     clickElement(popupWindow.document.querySelector(".suggestion-list-entry:nth-child(3)"));
+    waitUntilClosing(test1AfterClosing);
+}
+
+function test1AfterClosing() {
     shouldBeNull('document.getElementById("mock-page-popup")');
     shouldBe('document.getElementById("time").value', '"01:03"');
 
@@ -86,6 +90,10 @@
 
     popupWindow.focus();
     eventSender.keyDown('\x1B');
+    waitUntilClosing(test2AfterClosing);
+}
+
+function test2AfterClosing() {
     shouldBeNull('$("mock-page-popup")');
 
     openPicker($('time'), test3);

Modified: trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-step-attribute.html (134179 => 134180)


--- trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-step-attribute.html	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/LayoutTests/platform/chromium/fast/forms/suggestion-picker/time-suggestion-picker-step-attribute.html	2012-11-12 01:40:04 UTC (rev 134180)
@@ -38,7 +38,10 @@
     shouldBeEqualToString('entryValues()[1]', '02:00');
 
     eventSender.keyDown('\x1B'); // Close picker.
+    waitUntilClosing(test1AfterClosing);
+}
 
+function test1AfterClosing() {
     timeElement.step = 60;
     openPicker(timeElement, test2);
 }
@@ -53,7 +56,10 @@
     shouldBeEqualToString('entryValues()[3]', '02:01');
 
     eventSender.keyDown('\x1B'); // Close picker.
+    waitUntilClosing(test2AfterClosing);
+}
 
+function test2AfterClosing() {
     timeElement.step = 1;
     openPicker(timeElement, test3);
 }
@@ -69,7 +75,10 @@
     shouldBeEqualToString('entryValues()[4]', '02:01');
 
     eventSender.keyDown('\x1B'); // Close picker.
+    waitUntilClosing(test3AfterClosing);
+}
 
+function test3AfterClosing() {
     timeElement.step = 0.001;
     openPicker(timeElement, test4);
 }

Modified: trunk/Source/WebCore/ChangeLog (134179 => 134180)


--- trunk/Source/WebCore/ChangeLog	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/Source/WebCore/ChangeLog	2012-11-12 01:40:04 UTC (rev 134180)
@@ -1,3 +1,45 @@
+2012-11-11  Kent Tamura  <[email protected]>
+
+        Internals: MockPagePopup should not update DOM structure during detach()
+        https://bugs.webkit.org/show_bug.cgi?id=101710
+
+        Reviewed by Hajime Morita.
+
+        PickerIndicatorElement::detach calls
+        MockPagePopupDriver::closePagePopup, MockPagePopup::~MockPagePopup,
+        which remove the mock iframe from the tree. But updating the tree during
+        detach() is dangerous.
+
+        MockPagePopupDriver::closePagePopup calls MockpagePopup::closeLater, it
+        requests to call 'close' asynchronously, and 'close' removes the mock
+        iframe. We need to change MockPagePopup so that it is ref-couted and has
+        a timer.
+
+        No new tests. This is a change for the test harness.
+
+        * testing/MockPagePopupDriver.cpp:
+        (MockPagePopup): Make this ref-counted, add closeLater, add close, and
+        add m_closeTimer.
+        (WebCore::MockPagePopup::MockPagePopup): Initialize the timer.
+        (WebCore::MockPagePopup::create): PassOwnPtr -> PassRefPtr
+        (WebCore::MockPagePopup::closeLater):
+        - Add one reference to avoid destruction by m_mockPagePopup.clear() in
+          closePagePopup.
+        - Notify didClosePopup here because the client expects didClosePopup is
+          called synchronously.
+        - Invoke the timer to call 'close'
+        (WebCore::MockPagePopup::close):
+        Just remove one reference. This means calling the desructor.
+        (WebCore::MockPagePopup::~MockPagePopup):
+        Move didClosePopup call to caloseLater.
+        (WebCore::MockPagePopupDriver::closePagePopup):
+        Request to close PagePopup.
+        Clear PagePopupClient in m_pagePopupController because this object is
+        necessary until MockPagePopup is closed, but it should not have a
+        reference to the PagePopupClient.
+        * testing/MockPagePopupDriver.h:
+        (MockPagePopupDriver): Make MockPagePopup ref-counted.
+
 2012-11-11  Adam Barth  <[email protected]>
 
         axObjectCache code is more complicated than necessary

Modified: trunk/Source/WebCore/testing/MockPagePopupDriver.cpp (134179 => 134180)


--- trunk/Source/WebCore/testing/MockPagePopupDriver.cpp	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/Source/WebCore/testing/MockPagePopupDriver.cpp	2012-11-12 01:40:04 UTC (rev 134180)
@@ -36,24 +36,29 @@
 #include "PagePopup.h"
 #include "PagePopupClient.h"
 #include "PagePopupController.h"
+#include "Timer.h"
 #include "WebCoreTestSupport.h"
 
 namespace WebCore {
 
-class MockPagePopup : public PagePopup {
+class MockPagePopup : public PagePopup, public RefCounted<MockPagePopup> {
 public:
-    static PassOwnPtr<MockPagePopup> create(PagePopupClient*, const IntRect& originBoundsInRootView, Frame*);
+    static PassRefPtr<MockPagePopup> create(PagePopupClient*, const IntRect& originBoundsInRootView, Frame*);
     virtual ~MockPagePopup();
+    void closeLater();
 
 private:
     MockPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView, Frame*);
+    void close(Timer<MockPagePopup>*);
 
     PagePopupClient* m_popupClient;
     RefPtr<HTMLIFrameElement> m_iframe;
+    Timer<MockPagePopup> m_closeTimer;
 };
 
 inline MockPagePopup::MockPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView, Frame* mainFrame)
     : m_popupClient(client)
+    , m_closeTimer(this, &MockPagePopup::close)
 {
     Document* document = mainFrame->document();
     m_iframe = HTMLIFrameElement::create(HTMLNames::iframeTag, document);
@@ -75,16 +80,30 @@
     writer->end();
 }
 
-PassOwnPtr<MockPagePopup> MockPagePopup::create(PagePopupClient* client, const IntRect& originBoundsInRootView, Frame* mainFrame)
+PassRefPtr<MockPagePopup> MockPagePopup::create(PagePopupClient* client, const IntRect& originBoundsInRootView, Frame* mainFrame)
 {
-    return adoptPtr(new MockPagePopup(client, originBoundsInRootView, mainFrame));
+    return adoptRef(new MockPagePopup(client, originBoundsInRootView, mainFrame));
 }
 
+void MockPagePopup::closeLater()
+{
+    ref();
+    m_popupClient->didClosePopup();
+    m_popupClient = 0;
+    // This can be called in detach(), and we should not change DOM structure
+    // during detach().
+    m_closeTimer.startOneShot(0);
+}
+
+void MockPagePopup::close(Timer<MockPagePopup>*)
+{
+    deref();
+}
+
 MockPagePopup::~MockPagePopup()
 {
     if (m_iframe && m_iframe->parentNode())
         m_iframe->parentNode()->removeChild(m_iframe.get());
-    m_popupClient->didClosePopup();
 }
 
 inline MockPagePopupDriver::MockPagePopupDriver(Frame* mainFrame)
@@ -117,7 +136,9 @@
 {
     if (!popup || popup != m_mockPagePopup.get())
         return;
+    m_mockPagePopup->closeLater();
     m_mockPagePopup.clear();
+    m_pagePopupController->clearPagePopupClient();
     m_pagePopupController.clear();
 }
 

Modified: trunk/Source/WebCore/testing/MockPagePopupDriver.h (134179 => 134180)


--- trunk/Source/WebCore/testing/MockPagePopupDriver.h	2012-11-12 01:35:47 UTC (rev 134179)
+++ trunk/Source/WebCore/testing/MockPagePopupDriver.h	2012-11-12 01:40:04 UTC (rev 134180)
@@ -52,7 +52,7 @@
     virtual PagePopup* openPagePopup(PagePopupClient*, const IntRect& originBoundsInRootView) OVERRIDE;
     virtual void closePagePopup(PagePopup*) OVERRIDE;
 
-    OwnPtr<MockPagePopup> m_mockPagePopup;
+    RefPtr<MockPagePopup> m_mockPagePopup;
     Frame* m_mainFrame;
     RefPtr<PagePopupController> m_pagePopupController;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to