Changeset 116686 in webkit


Ignore:
Timestamp:
May 10, 2012 2:14:12 PM (12 years ago)
Author:
tsepez@chromium.org
Message:

[Chromium] WebFrameTest.ChromePageNoJavascript isn't catching regressions
https://bugs.webkit.org/show_bug.cgi?id=86046

Reviewed by Adam Barth.

Test both cases for registerURLSchemeAsNotAllowingJavascriptURLs. Also add
a call to layout() to ensure the javascript result is seen.

  • tests/WebFrameTest.cpp:

(WebKit::TEST_F):
(WebKit):

Location:
trunk/Source/WebKit/chromium
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/chromium/ChangeLog

    r116671 r116686  
     12012-05-10  Tom Sepez  <tsepez@chromium.org>
     2
     3        [Chromium] WebFrameTest.ChromePageNoJavascript isn't catching regressions
     4        https://bugs.webkit.org/show_bug.cgi?id=86046
     5
     6        Reviewed by Adam Barth.
     7
     8        Test both cases for registerURLSchemeAsNotAllowingJavascriptURLs.  Also add
     9        a call to layout() to ensure the javascript result is seen.
     10       
     11        * tests/WebFrameTest.cpp:
     12        (WebKit::TEST_F):
     13        (WebKit):
     14
    1152012-05-10  Varun Jain  <varunjain@google.com>
    216
  • trunk/Source/WebKit/chromium/tests/WebFrameTest.cpp

    r116608 r116686  
    138138}
    139139
     140TEST_F(WebFrameTest, ChromePageJavascript)
     141{
     142    registerMockedChromeURLLoad("history.html");
     143 
     144    // Pass true to enable JavaScript.
     145    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.html", true);
     146
     147    // Try to run JS against the chrome-style URL.
     148    FrameTestHelpers::loadFrame(webView->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))");
     149
     150    // Required to see any updates in contentAsText.
     151    webView->layout();
     152
     153    // Now retrieve the frame's text and ensure it was modified by running javascript.
     154    std::string content = webView->mainFrame()->contentAsText(1024).utf8();
     155    EXPECT_NE(std::string::npos, content.find("Clobbered"));
     156}
     157
    140158TEST_F(WebFrameTest, ChromePageNoJavascript)
    141159{
    142160    registerMockedChromeURLLoad("history.html");
    143161
     162    /// Pass true to enable JavaScript.
    144163    WebView* webView = FrameTestHelpers::createWebViewAndLoad(m_chromeURL + "history.html", true);
    145164
    146     // Try to run JS against the chrome-style URL.
     165    // Try to run JS against the chrome-style URL after prohibiting it.
    147166    WebSecurityPolicy::registerURLSchemeAsNotAllowingJavascriptURLs("chrome");
    148167    FrameTestHelpers::loadFrame(webView->mainFrame(), "javascript:document.body.appendChild(document.createTextNode('Clobbered'))");
    149168
    150     // Now retrieve the frames text and see if it was clobbered.
     169    // Required to see any updates in contentAsText.
     170    webView->layout();
     171
     172    // Now retrieve the frame's text and ensure it wasn't modified by running javascript.
    151173    std::string content = webView->mainFrame()->contentAsText(1024).utf8();
    152     EXPECT_NE(std::string::npos, content.find("Simulated Chromium History Page"));
    153174    EXPECT_EQ(std::string::npos, content.find("Clobbered"));
    154175}
Note: See TracChangeset for help on using the changeset viewer.