• bweinstein@apple.com's avatar
    User scripts shouldn't be injected in a frame's empty initial document. · 09308a22
    bweinstein@apple.com authored
    Reviewed by Brady Eidson.
    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:
    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
user-script-plugin-document-expected.txt 229 Bytes