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 ca87083..cc159ec 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 46f2b6e..c3901a4 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 1f9f42b..64e9d3f 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 9b0a3bd..0c237eb 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 a1d8b9e..b422dac 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();