2009-08-16 Nikolas Zimmermann <nikolas.zimmermann@torchmobile.com>
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2009 00:45:50 +0000 (00:45 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Aug 2009 00:45:50 +0000 (00:45 +0000)
        Reviewed by George Staikos.

        [WML] <option> element & 'onpick' events - history navigation is broken
        https://bugs.webkit.org/show_bug.cgi?id=28371

        After selecting an option element with an 'onpick' event associated with a 'go' task,
        the navigation is executed. When going back in history, the same 'onpick' event is fired
        again. Fix that problem, add wml/option-element-onpick-recursion.html covering the bug.

        Test: wml/option-element-onpick-recursion.html

        * wml/WMLOptionElement.cpp:
        (WebCore::WMLOptionElement::handleIntrinsicEventIfNeeded):
        * wml/WMLSelectElement.cpp:
        (WebCore::WMLSelectElement::WMLSelectElement):
        (WebCore::WMLSelectElement::selectInitialOptions):
        * wml/WMLSelectElement.h:
        (WebCore::WMLSelectElement::initialized):

2009-08-16  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>

        Reviewed by George Staikos.

        [WML] <option> element & 'onpick' events - history navigation is broken
        https://bugs.webkit.org/show_bug.cgi?id=28371

        Add new test covering history navigation & 'onpick' event handling.

        * wml/option-element-onpick-recursion-expected.txt: Added.
        * wml/option-element-onpick-recursion.html: Added.
        * wml/resources/WMLTestCase.js:
        (createStaticWMLTestCase):
        (createDynamicWMLTestCase):
        * wml/resources/option-element-onpick-recursion.js: Added.
        (setupTestDocument):
        (prepareTest):
        (executeTest):
        * wml/resources/option-element-onpick-recursion.wml: Added.
        * wml/resources/option-element-onpick.js:
        (prepareTest):

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

LayoutTests/ChangeLog
LayoutTests/wml/option-element-onpick-recursion-expected.txt [new file with mode: 0644]
LayoutTests/wml/option-element-onpick-recursion.html [new file with mode: 0644]
LayoutTests/wml/resources/WMLTestCase.js
LayoutTests/wml/resources/option-element-onpick-recursion.js [new file with mode: 0644]
LayoutTests/wml/resources/option-element-onpick-recursion.wml [new file with mode: 0644]
LayoutTests/wml/resources/option-element-onpick.js
WebCore/ChangeLog
WebCore/wml/WMLOptionElement.cpp
WebCore/wml/WMLSelectElement.cpp
WebCore/wml/WMLSelectElement.h

index a30acc0..d1feda1 100644 (file)
@@ -1,5 +1,27 @@
 2009-08-16  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
 
+        Reviewed by George Staikos.
+
+        [WML] <option> element & 'onpick' events - history navigation is broken
+        https://bugs.webkit.org/show_bug.cgi?id=28371
+
+        Add new test covering history navigation & 'onpick' event handling.
+
+        * wml/option-element-onpick-recursion-expected.txt: Added.
+        * wml/option-element-onpick-recursion.html: Added.
+        * wml/resources/WMLTestCase.js:
+        (createStaticWMLTestCase):
+        (createDynamicWMLTestCase):
+        * wml/resources/option-element-onpick-recursion.js: Added.
+        (setupTestDocument):
+        (prepareTest):
+        (executeTest):
+        * wml/resources/option-element-onpick-recursion.wml: Added.
+        * wml/resources/option-element-onpick.js:
+        (prepareTest):
+
+2009-08-16  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
         Not reviewed. Add missing WML specific layout test result.
 
         * platform/mac/fast/wml/html-fieldset-crash-expected.txt: Added.
diff --git a/LayoutTests/wml/option-element-onpick-recursion-expected.txt b/LayoutTests/wml/option-element-onpick-recursion-expected.txt
new file mode 100644 (file)
index 0000000..3a51146
--- /dev/null
@@ -0,0 +1,17 @@
+WML layout tests - using XHTML scripting
+
+
+Tests onpick intrinsic event recursion bug
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
+--------
+Frame: '<!--framePath //<!--frame0-->-->'
+--------
+
diff --git a/LayoutTests/wml/option-element-onpick-recursion.html b/LayoutTests/wml/option-element-onpick-recursion.html
new file mode 100644 (file)
index 0000000..d077796
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script>var relativePathToLayoutTests = "..";</script>
+<script src="resources/WMLTestCase.js"></script>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<h1>WML layout tests - using XHTML scripting</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/option-element-onpick-recursion.js"></script>
+</body>
+</html>
index e023ec7..a89748d 100644 (file)
@@ -29,11 +29,14 @@ function onloadHandler(resetupDocument) {
     testDocument.initializeWMLPageState();
 }
 
-function createStaticWMLTestCase(testDescription, testName) {
+function createStaticWMLTestCase(testDescription, testName, resetPageState) {
     if (testName == null)
         return;
 
-    createWMLTestCase(testDescription, false, testName);
+    if (resetPageState == null)
+        resetPageState = true;
+
+    createWMLTestCase(testDescription, false, testName, resetPageState);
 }
 
 function createDynamicWMLTestCase(testDescription, resetupDocument) {
@@ -43,16 +46,17 @@ function createDynamicWMLTestCase(testDescription, resetupDocument) {
 
     // Setup default test name
     var testName = relativePathToLayoutTests + "/wml/resources/test-document.wml";
-    createWMLTestCase(testDescription, resetupDocument, testName);
+    createWMLTestCase(testDescription, resetupDocument, testName, true);
 }
 
-function createWMLTestCase(testDescription, resetupDocument, testName) {
+function createWMLTestCase(testDescription, resetupDocument, testName, resetPageState) {
     // Initialize JS test
     description(testDescription);
     bodyElement = document.getElementsByTagName("body")[0];
 
     // Clear variable state & history
-    document.resetWMLPageState();
+    if (resetPageState)
+        document.resetWMLPageState();
 
     // Setup DRT specific settings
     if (window.layoutTestController) {
diff --git a/LayoutTests/wml/resources/option-element-onpick-recursion.js b/LayoutTests/wml/resources/option-element-onpick-recursion.js
new file mode 100644 (file)
index 0000000..dbd48b1
--- /dev/null
@@ -0,0 +1,22 @@
+// [Name] option-element-onpick-recursion.js
+
+createStaticWMLTestCase("Tests onpick intrinsic event recursion bug", "resources/option-element-onpick-recursion.wml", false);
+
+var resultElement;
+
+function setupTestDocument() {
+    resultElement = testDocument.getElementById("result");
+}
+
+function prepareTest() {
+    if (resultElement.textContent != "finished")
+        window.setTimeout('startTest(25, 15)', 0);
+    else
+        completeTest();
+}
+
+function executeTest() {
+    window.history.back();
+}
+
+var successfullyParsed = true;
diff --git a/LayoutTests/wml/resources/option-element-onpick-recursion.wml b/LayoutTests/wml/resources/option-element-onpick-recursion.wml
new file mode 100644 (file)
index 0000000..f0bf295
--- /dev/null
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
+<wml>
+    <card>
+        <select name="result" multiple="false">
+            <option onpick="#card2" value="finished">Dog</option>
+            <option value="error">Cat</option>
+        </select>
+    </card>
+
+    <card id="card2">
+        <p>Test passes, if this text is not visible in the dumped output</p>
+        <p id="result">$result</p>
+    </card>
+</wml>
index 18adf3f..48651ad 100644 (file)
@@ -23,7 +23,7 @@ function setupTestDocument() {
 }
 
 function prepareTest() {
-    startTest(25, 15);
+    window.setTimeout('startTest(25, 15)', 0);
 }
 
 function executeTest() {
index 604256f..0202da9 100644 (file)
@@ -1,3 +1,24 @@
+2009-08-16  Nikolas Zimmermann  <nikolas.zimmermann@torchmobile.com>
+
+        Reviewed by George Staikos.
+
+        [WML] <option> element & 'onpick' events - history navigation is broken
+        https://bugs.webkit.org/show_bug.cgi?id=28371
+
+        After selecting an option element with an 'onpick' event associated with a 'go' task,
+        the navigation is executed. When going back in history, the same 'onpick' event is fired
+        again. Fix that problem, add wml/option-element-onpick-recursion.html covering the bug.
+
+        Test: wml/option-element-onpick-recursion.html
+
+        * wml/WMLOptionElement.cpp:
+        (WebCore::WMLOptionElement::handleIntrinsicEventIfNeeded):
+        * wml/WMLSelectElement.cpp:
+        (WebCore::WMLSelectElement::WMLSelectElement):
+        (WebCore::WMLSelectElement::selectInitialOptions):
+        * wml/WMLSelectElement.h:
+        (WebCore::WMLSelectElement::initialized):
+
 2009-08-16  Anthony Ricaud  <rik@webkit.org>
 
         Reviewed by Timothy Hatcher.
index 764d3a1..61fa762 100644 (file)
@@ -158,6 +158,10 @@ RenderStyle* WMLOptionElement::nonRendererRenderStyle() const
 
 void WMLOptionElement::handleIntrinsicEventIfNeeded()
 {
+    WMLSelectElement* select = ownerSelectElement(this);
+    if (!select || !select->initialized())
+        return;
+
     WMLIntrinsicEventHandler* eventHandler = this->eventHandler();
     if (!eventHandler)
         return;
index 2d03a3f..03ca05a 100644 (file)
@@ -39,6 +39,7 @@ using namespace WMLNames;
 
 WMLSelectElement::WMLSelectElement(const QualifiedName& tagName, Document* document)
     : WMLFormControlElement(tagName, document)
+    , m_initialized(false)
 {
 }
 
@@ -242,14 +243,17 @@ void WMLSelectElement::selectInitialOptions()
     // Spec: Step 1 - the default option index is determined using iname and ivalue
     calculateDefaultOptionIndices();
 
-    if (m_defaultOptionIndices.isEmpty())
+    if (m_defaultOptionIndices.isEmpty()) {
+        m_initialized = true;
         return;
+    }
 
     // Spec: Step 2 – initialise variables
     initializeVariables();
 
     // Spec: Step 3 – pre-select option(s) specified by the default option index 
     selectDefaultOptions();
+    m_initialized = true;
 }
 
 void WMLSelectElement::insertedIntoTree(bool deep)
index 412a950..5ab7da6 100644 (file)
@@ -85,6 +85,8 @@ public:
     void scrollToSelection();
     void selectInitialOptions();
 
+    bool initialized() const { return m_initialized; }
+
 private:
     virtual void insertedIntoTree(bool);
 
@@ -104,6 +106,7 @@ private:
     String ivalue() const;
 
     SelectElementData m_data;
+    bool m_initialized;
     Vector<unsigned> m_defaultOptionIndices;
 };