[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

bweinstein at apple.com bweinstein at apple.com
Wed Dec 22 15:28:54 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 09308a226c65b95f930aaf78508f18096a230367
Author: bweinstein at apple.com <bweinstein at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 4 16:38:20 2010 +0000

    User scripts shouldn't be injected in a frame's empty initial document.
    https://bugs.webkit.org/show_bug.cgi?id=48970
    <rdar://problem/8618164>
    <rdar://problem/8082122>
    
    Reviewed by Brady Eidson.
    
    WebCore:
    
    When a frame loads, it first creates an empty initial document, then navigates to the correct URL. Our
    current policy with user scripts is to inject them into both the initial empty document, and then inject
    them again.
    
    This causes developers to think their scripts have been injected twice into all iframes, and there is a timing
    issue between WebKit1 and WebKit2 that causes start scripts to be injected into the initial empty document
    of the main frame when a new tab or window is created.
    
    The fix for this is to not inject user scripts when the frame is creating its initial empty document before loading
    the correct source.
    
    * page/Frame.cpp:
    (WebCore::Frame::injectUserScripts):
    
    LayoutTests:
    
    Update userscripts tests to reflect the fact that start scripts are not injected
    in the initial load of about:blank in an iframe anymore.
    
    This patch also makes the tests more verbose, and the results clearer to understand
    by printing out the URLs of the documents that ran the content scripts.
    
    * userscripts/script-not-run-for-fragments-expected.txt:
    * userscripts/script-not-run-for-fragments.html:
    * userscripts/script-run-at-start-expected.txt:
    * userscripts/user-script-audio-document-expected.txt:
    * userscripts/user-script-audio-document.html:
    * userscripts/user-script-image-document-expected.txt:
    * userscripts/user-script-image-document.html:
    * userscripts/user-script-plugin-document-expected.txt:
    * userscripts/user-script-plugin-document.html:
    * userscripts/user-script-video-document-expected.txt:
    * userscripts/user-script-video-document.html:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71339 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 4bb65c8..5b33bff 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,30 @@
+2010-11-03  Brian Weinstein  <bweinstein at apple.com>
+
+        Reviewed by Brady Eidson.
+
+        User scripts shouldn't be injected in a frame's empty initial document.
+        https://bugs.webkit.org/show_bug.cgi?id=48970
+        <rdar://problem/8618164>
+        <rdar://problem/8082122>
+        
+        Update userscripts tests to reflect the fact that start scripts are not injected
+        in the initial load of about:blank in an iframe anymore.
+        
+        This patch also makes the tests more verbose, and the results clearer to understand
+        by printing out the URLs of the documents that ran the content scripts.
+
+        * userscripts/script-not-run-for-fragments-expected.txt:
+        * userscripts/script-not-run-for-fragments.html:
+        * userscripts/script-run-at-start-expected.txt:
+        * userscripts/user-script-audio-document-expected.txt:
+        * userscripts/user-script-audio-document.html:
+        * userscripts/user-script-image-document-expected.txt:
+        * userscripts/user-script-image-document.html:
+        * userscripts/user-script-plugin-document-expected.txt:
+        * userscripts/user-script-plugin-document.html:
+        * userscripts/user-script-video-document-expected.txt:
+        * userscripts/user-script-video-document.html:
+
 2010-11-04  Adam Roben  <aroben at apple.com>
 
         Add more failing tests to the Windows Skipped file
diff --git a/LayoutTests/userscripts/script-not-run-for-fragments-expected.txt b/LayoutTests/userscripts/script-not-run-for-fragments-expected.txt
index 0863d2a..ec66dec 100644
--- a/LayoutTests/userscripts/script-not-run-for-fragments-expected.txt
+++ b/LayoutTests/userscripts/script-not-run-for-fragments-expected.txt
@@ -1,3 +1,2 @@
-CONSOLE MESSAGE: line 1: injected
-CONSOLE MESSAGE: line 1: injected
+CONSOLE MESSAGE: line 1: injected: blank.xhtml
 This test should not infinitely inject user scripts. 
diff --git a/LayoutTests/userscripts/script-not-run-for-fragments.html b/LayoutTests/userscripts/script-not-run-for-fragments.html
index c73efc3..cd4e543 100644
--- a/LayoutTests/userscripts/script-not-run-for-fragments.html
+++ b/LayoutTests/userscripts/script-not-run-for-fragments.html
@@ -5,7 +5,7 @@
 if (window.layoutTestController) {
     layoutTestController.dumpAsText();
     layoutTestController.waitUntilDone();
-    layoutTestController.addUserScript("console.log('injected'); var div = document.createElement('div'); div.innerHTML = '<p>hi</p>';", true, true);
+    layoutTestController.addUserScript("console.log('injected: ' + document.location.href); var div = document.createElement('div'); div.innerHTML = '<p>hi</p>';", true, true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/script-run-at-start-expected.txt b/LayoutTests/userscripts/script-run-at-start-expected.txt
index b73913c..dba6ed4 100644
--- a/LayoutTests/userscripts/script-run-at-start-expected.txt
+++ b/LayoutTests/userscripts/script-run-at-start-expected.txt
@@ -1,3 +1,2 @@
 CONSOLE MESSAGE: line 1: SUCCESS
-CONSOLE MESSAGE: line 1: SUCCESS
 This test should log a console message on success. 
diff --git a/LayoutTests/userscripts/user-script-audio-document-expected.txt b/LayoutTests/userscripts/user-script-audio-document-expected.txt
index f1e8cf6..f18c585 100644
--- a/LayoutTests/userscripts/user-script-audio-document-expected.txt
+++ b/LayoutTests/userscripts/user-script-audio-document-expected.txt
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
+CONSOLE MESSAGE: line 1: End Script: user-script-audio-document.html
+CONSOLE MESSAGE: line 1: Start Script: test.wav
+CONSOLE MESSAGE: line 1: End Script: test.wav
 
diff --git a/LayoutTests/userscripts/user-script-audio-document.html b/LayoutTests/userscripts/user-script-audio-document.html
index 97e6818..9f0dc62 100644
--- a/LayoutTests/userscripts/user-script-audio-document.html
+++ b/LayoutTests/userscripts/user-script-audio-document.html
@@ -3,8 +3,8 @@
 <script>
 if (window.layoutTestController) {
     window.layoutTestController.dumpAsText();
-    window.layoutTestController.addUserScript("console.log('Start Script')", true, true);
-    window.layoutTestController.addUserScript("console.log('End Script')", false, true);
+    window.layoutTestController.addUserScript("console.log('Start Script: ' + document.location.href)", true, true);
+    window.layoutTestController.addUserScript("console.log('End Script: ' + document.location.href)", false, true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/user-script-image-document-expected.txt b/LayoutTests/userscripts/user-script-image-document-expected.txt
index f1e8cf6..c37761b 100644
--- a/LayoutTests/userscripts/user-script-image-document-expected.txt
+++ b/LayoutTests/userscripts/user-script-image-document-expected.txt
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
+CONSOLE MESSAGE: line 1: End Script: user-script-image-document.html
+CONSOLE MESSAGE: line 1: Start Script: abe.png
+CONSOLE MESSAGE: line 1: End Script: abe.png
 
diff --git a/LayoutTests/userscripts/user-script-image-document.html b/LayoutTests/userscripts/user-script-image-document.html
index 0137ce6..826032a 100644
--- a/LayoutTests/userscripts/user-script-image-document.html
+++ b/LayoutTests/userscripts/user-script-image-document.html
@@ -3,8 +3,8 @@
 <script>
 if (window.layoutTestController) {
     window.layoutTestController.dumpAsText();
-    window.layoutTestController.addUserScript("console.log('Start Script')", true, true);
-    window.layoutTestController.addUserScript("console.log('End Script')", false, true);
+    window.layoutTestController.addUserScript("console.log('Start Script: ' + document.location.href)", true, true);
+    window.layoutTestController.addUserScript("console.log('End Script: ' + document.location.href)", false, true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/user-script-plugin-document-expected.txt b/LayoutTests/userscripts/user-script-plugin-document-expected.txt
index f1e8cf6..2346786 100644
--- a/LayoutTests/userscripts/user-script-plugin-document-expected.txt
+++ b/LayoutTests/userscripts/user-script-plugin-document-expected.txt
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
+CONSOLE MESSAGE: line 1: End Script: user-script-plugin-document.html
+CONSOLE MESSAGE: line 1: Start Script: data:application/x-webkit-test-netscape,
+CONSOLE MESSAGE: line 1: End Script: data:application/x-webkit-test-netscape,
 
diff --git a/LayoutTests/userscripts/user-script-plugin-document.html b/LayoutTests/userscripts/user-script-plugin-document.html
index d6c36d6..79ce4d9 100644
--- a/LayoutTests/userscripts/user-script-plugin-document.html
+++ b/LayoutTests/userscripts/user-script-plugin-document.html
@@ -3,8 +3,8 @@
 <script>
 if (window.layoutTestController) {
     window.layoutTestController.dumpAsText();
-    window.layoutTestController.addUserScript("console.log('Start Script')", true, true);
-    window.layoutTestController.addUserScript("console.log('End Script')", false, true);
+    window.layoutTestController.addUserScript("console.log('Start Script: ' + document.location.href)", true, true);
+    window.layoutTestController.addUserScript("console.log('End Script: ' + document.location.href)", false, true);
 }
 </script>
 </head>
diff --git a/LayoutTests/userscripts/user-script-video-document-expected.txt b/LayoutTests/userscripts/user-script-video-document-expected.txt
index f1e8cf6..0b25ab0 100644
--- a/LayoutTests/userscripts/user-script-video-document-expected.txt
+++ b/LayoutTests/userscripts/user-script-video-document-expected.txt
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
-CONSOLE MESSAGE: line 1: Start Script
-CONSOLE MESSAGE: line 1: End Script
+CONSOLE MESSAGE: line 1: End Script: user-script-video-document.html
+CONSOLE MESSAGE: line 1: Start Script: counting.mp4
+CONSOLE MESSAGE: line 1: End Script: counting.mp4
 
diff --git a/LayoutTests/userscripts/user-script-video-document.html b/LayoutTests/userscripts/user-script-video-document.html
index 2119fa9..1c4db0a 100644
--- a/LayoutTests/userscripts/user-script-video-document.html
+++ b/LayoutTests/userscripts/user-script-video-document.html
@@ -3,8 +3,8 @@
 <script>
 if (window.layoutTestController) {
     window.layoutTestController.dumpAsText();
-    window.layoutTestController.addUserScript("console.log('Start Script')", true, true);
-    window.layoutTestController.addUserScript("console.log('End Script')", false, true);
+    window.layoutTestController.addUserScript("console.log('Start Script: ' + document.location.href)", true, true);
+    window.layoutTestController.addUserScript("console.log('End Script: ' + document.location.href)", false, true);
 }
 </script>
 </head>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 2de7991..9e6ddc4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-11-03  Brian Weinstein  <bweinstein at apple.com>
+
+        Reviewed by Brady Eidson.
+
+        User scripts shouldn't be injected in a frame's empty initial document.
+        https://bugs.webkit.org/show_bug.cgi?id=48970
+        <rdar://problem/8618164>
+        <rdar://problem/8082122>
+        
+        When a frame loads, it first creates an empty initial document, then navigates to the correct URL. Our
+        current policy with user scripts is to inject them into both the initial empty document, and then inject
+        them again.
+        
+        This causes developers to think their scripts have been injected twice into all iframes, and there is a timing
+        issue between WebKit1 and WebKit2 that causes start scripts to be injected into the initial empty document
+        of the main frame when a new tab or window is created.
+        
+        The fix for this is to not inject user scripts when the frame is creating its initial empty document before loading
+        the correct source.
+
+        * page/Frame.cpp:
+        (WebCore::Frame::injectUserScripts):
+
 2010-11-04  Andreas Kling  <kling at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/page/Frame.cpp b/WebCore/page/Frame.cpp
index 8909755..70499d9 100644
--- a/WebCore/page/Frame.cpp
+++ b/WebCore/page/Frame.cpp
@@ -502,6 +502,9 @@ void Frame::injectUserScripts(UserScriptInjectionTime injectionTime)
 {
     if (!m_page)
         return;
+
+    if (loader()->stateMachine()->creatingInitialEmptyDocument())
+        return;
     
     // Walk the hashtable. Inject by world.
     const UserScriptMap* userScripts = m_page->group().userScripts();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list