LayoutTests:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2007 22:35:50 +0000 (22:35 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Jul 2007 22:35:50 +0000 (22:35 +0000)
        Reviewed by Oliver.

        - test case for <rdar://problem/5326303> REGRESSION: blur event fires upon navigating away from a page with focused element

        (Test mostly by Alice.)

        * fast/events/no-blur-on-page-leave-expected.txt: Added.
        * fast/events/no-blur-on-page-leave.html: Added.
        * fast/events/resources/no-blur-result.html: Added.

WebCore:

        Reviewed by Oliver.

        <rdar://problem/5326303> REGRESSION: blur event fires upon navigating away from a page with focused element

        The proximate cause was the recent change to keep focus on the
        WebHTMLView when switching views. But the reason this happend was
        that didCommitLoadForFrame got called at a time when the new view
        was in place, but the old document was still there. This was a
        longstanding problem with the delegate, and fixing it cleans it
        up.

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::begin): Don't send dispatchWindowObjectAvailable if
        caller asked not to (this is to allow order of delegates to be the same).
        (WebCore::FrameLoader::transitionToCommitted): Don't emit didCommitLoadForFrame here.
        (WebCore::FrameLoader::receivedFirstData): Instead do it here, after calling begin(),
        so the new document is set up.
        * loader/FrameLoader.h: Add new optional parameter to begin().

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

LayoutTests/ChangeLog
LayoutTests/fast/events/no-blur-on-page-leave-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/no-blur-on-page-leave.html [new file with mode: 0644]
LayoutTests/fast/events/resources/no-blur-result.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/loader/FrameLoader.cpp
WebCore/loader/FrameLoader.h

index ca870839feacf7ae8597e838883acf026b381745..cc159ec41239ba04dad31c3a4a91b893a630b230 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-20  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+
+        - test case for <rdar://problem/5326303> REGRESSION: blur event fires upon navigating away from a page with focused element
+        
+        (Test mostly by Alice.)
+
+        * fast/events/no-blur-on-page-leave-expected.txt: Added.
+        * fast/events/no-blur-on-page-leave.html: Added.
+        * fast/events/resources/no-blur-result.html: Added.
+
 2007-07-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Mitz.
diff --git a/LayoutTests/fast/events/no-blur-on-page-leave-expected.txt b/LayoutTests/fast/events/no-blur-on-page-leave-expected.txt
new file mode 100644 (file)
index 0000000..34379a6
--- /dev/null
@@ -0,0 +1,4 @@
+onblur should not fire if an element has focus when navigating away from the page
+rdar://problem/5326303
+
+
diff --git a/LayoutTests/fast/events/no-blur-on-page-leave.html b/LayoutTests/fast/events/no-blur-on-page-leave.html
new file mode 100644 (file)
index 0000000..5f7515f
--- /dev/null
@@ -0,0 +1,31 @@
+<script>
+function test()
+{
+    if (!window.layoutTestController)
+        return;
+
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntiDone();
+
+    var element = document.getElementById("elem");
+    element.focus();
+    element.onchange();
+}
+function failed()
+{
+    document.getElementById("console").innerHTML = "blur event fired, FAILED!";
+    window.location = 'resources/no-blur-result.html/#FAILED';
+    layoutTestController.notifyDone();
+}
+
+</script>
+<body onload="test();">
+onblur should not fire if an element has focus when navigating away from the page<br>
+<a href="rdar://problem/5326303">rdar://problem/5326303</a><br>
+<select id="elem" onchange="window.location='resources/no-blur-result.html';" onblur="failed()">
+<option>CHANGE ME</option>
+<option>PICK ME</option>
+</select>
+<pre id=console>
+</pre>
+</body>
diff --git a/LayoutTests/fast/events/resources/no-blur-result.html b/LayoutTests/fast/events/resources/no-blur-result.html
new file mode 100644 (file)
index 0000000..c0fc424
--- /dev/null
@@ -0,0 +1,24 @@
+<script>
+function test()
+{
+    if (window.location.hash == "#FAILED")
+        document.getElementById("succeededDiv").setAttribute("style", "display:none;");
+    else
+        document.getElementById("failedDiv").setAttribute("style", "display:none;");
+        
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+}
+</script>
+
+<body onload="test();">
+
+<div id="succeededDiv">
+<span style="color:green;">SUCCESS</span>
+</div>
+
+<div id="failedDiv">
+<a name="FAILED"><span style="color:red;">FAILED</span></a>
+</div>
+
+</body>
index 46f2b6eea05d359b90a3126787a0a4d5cbe6be8d..c3901a4471768ba4f228214feb03b9623d1638e4 100644 (file)
@@ -1,3 +1,26 @@
+2007-07-20  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Oliver.
+
+        <rdar://problem/5326303> REGRESSION: blur event fires upon navigating away from a page with focused element
+
+
+        
+        The proximate cause was the recent change to keep focus on the
+        WebHTMLView when switching views. But the reason this happend was
+        that didCommitLoadForFrame got called at a time when the new view
+        was in place, but the old document was still there. This was a
+        longstanding problem with the delegate, and fixing it cleans it
+        up.
+
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::begin): Don't send dispatchWindowObjectAvailable if
+        caller asked not to (this is to allow order of delegates to be the same).
+        (WebCore::FrameLoader::transitionToCommitted): Don't emit didCommitLoadForFrame here.
+        (WebCore::FrameLoader::receivedFirstData): Instead do it here, after calling begin(),
+        so the new document is set up.
+        * loader/FrameLoader.h: Add new optional parameter to begin().
+
 2007-07-20  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Beth Dakin.
index 1f9f42b2b24731c5d7f0af3a3ef69917f5f769c3..64e9d3f6d6091b1e6bbd13f231399fa66acc19a3 100644 (file)
                0867D690FE84028FC02AAC07 /* Project object */ = {
                        isa = PBXProject;
                        buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
+                       compatibilityVersion = "Xcode 2.4";
                        hasScannedForEncodings = 1;
                        knownRegions = (
                                English,
                        mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
                        productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
                        projectDirPath = "";
+                       projectRoot = "";
                        targets = (
                                93F198A508245E59001E9ABC /* WebCore */,
                                DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
index 9b0a3bdb270966bfe9a7b076a9f77c2a4364f00b..0c237eb296c55253fc56ed6ed3959237737b2484 100644 (file)
@@ -817,7 +817,15 @@ void FrameLoader::clear(bool clearWindowProperties)
 
 void FrameLoader::receivedFirstData()
 {
-    begin(m_workingURL);
+    begin(m_workingURL, false);
+
+    dispatchDidCommitLoad();
+    dispatchWindowObjectAvailable();
+    
+    String ptitle = m_documentLoader->title();
+    // If we have a title let the WebView know about it.
+    if (!ptitle.isNull())
+        m_client->dispatchDidReceiveTitle(ptitle);
 
     m_frame->document()->docLoader()->setCachePolicy(m_cachePolicy);
     m_workingURL = KURL();
@@ -852,10 +860,11 @@ void FrameLoader::begin()
     begin(KURL());
 }
 
-void FrameLoader::begin(const KURL& url)
+void FrameLoader::begin(const KURL& url, bool dispatch)
 {
     clear();
-    dispatchWindowObjectAvailable();
+    if (dispatch)
+        dispatchWindowObjectAvailable();
 
     m_needsClear = true;
     m_shouldClearWindowProperties = true;
@@ -2430,7 +2439,6 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
 
     // Handle adding the URL to the back/forward list.
     DocumentLoader* dl = m_documentLoader.get();
-    String ptitle = dl->title();
 
     switch (m_loadType) {
         case FrameLoadTypeForward:
@@ -2485,12 +2493,6 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage)
         return;
 
     m_committedFirstRealDocumentLoad = true;
-
-    dispatchDidCommitLoad();
-    
-    // If we have a title let the WebView know about it.
-    if (!ptitle.isNull())
-        m_client->dispatchDidReceiveTitle(ptitle);
 }
 
 bool FrameLoader::privateBrowsingEnabled() const
index a1d8b9e5c05b7f74ca66c724c7924cf63c84c980..b422dac99e29478be07e3af0c4c592b9bb160749 100644 (file)
@@ -309,7 +309,8 @@ namespace WebCore {
         KURL historyURL(int distance);
 
         void begin();
-        void begin(const KURL&);
+        void begin(const KURL&, bool dispatchWindowObjectAvailable = true);
+
         void write(const char* str, int len = -1, bool flush = false);
         void write(const String&);
         void end();