Title: [119019] trunk
Revision
119019
Author
[email protected]
Date
2012-05-30 18:54:50 -0700 (Wed, 30 May 2012)

Log Message

Add a LayoutTest for prerender remove after stop.
https://bugs.webkit.org/show_bug.cgi?id=87860

Tools:

These very boring mocks in DumpRenderTree mean that the basic Prerendering API
can be tested by LayoutTests now.

Reviewed by Adam Barth.

* DumpRenderTree/DumpRenderTree.gypi:
* DumpRenderTree/chromium/MockWebPrerenderingSupport.cpp: Added.
(MockWebPrerenderingSupport::MockWebPrerenderingSupport):
(MockWebPrerenderingSupport::~MockWebPrerenderingSupport):
(MockWebPrerenderingSupport::add):
(MockWebPrerenderingSupport::cancel):
(MockWebPrerenderingSupport::abandon):
* DumpRenderTree/chromium/MockWebPrerenderingSupport.h: Added.
(MockWebPrerenderingSupport):
* DumpRenderTree/chromium/TestShell.cpp:
(TestShell::initialize):
* DumpRenderTree/chromium/TestShell.h:
(TestShell):
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::willAddPrerender):
(WebViewHost::setWebWidget):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):

LayoutTests:

Bug 87746 was uploaded without a LayoutTest because I originally thought
it would only be testable in Chrome with a browser test.  However, that was
wrong.

Note that this test doesn't need to be disabled based on if the platform
uses Prerendering, since the test is for a crash, which won't happen on
platforms without prerendering, either.

Reviewed by Adam Barth.

* fast/dom/HTMLLinkElement/prerender-remove-after-stop-expected.txt: Added.
* fast/dom/HTMLLinkElement/prerender-remove-after-stop.html: Added.
* fast/dom/HTMLLinkElement/resources/empty.html: Added.
* fast/dom/HTMLLinkElement/resources/simple-prerender.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (119018 => 119019)


--- trunk/LayoutTests/ChangeLog	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/LayoutTests/ChangeLog	2012-05-31 01:54:50 UTC (rev 119019)
@@ -1,3 +1,23 @@
+2012-05-30  Gavin Peters  <[email protected]>
+
+        Add a LayoutTest for prerender remove after stop.
+        https://bugs.webkit.org/show_bug.cgi?id=87860
+
+        Bug 87746 was uploaded without a LayoutTest because I originally thought
+        it would only be testable in Chrome with a browser test.  However, that was
+        wrong.
+
+        Note that this test doesn't need to be disabled based on if the platform
+        uses Prerendering, since the test is for a crash, which won't happen on
+        platforms without prerendering, either.
+
+        Reviewed by Adam Barth.
+
+        * fast/dom/HTMLLinkElement/prerender-remove-after-stop-expected.txt: Added.
+        * fast/dom/HTMLLinkElement/prerender-remove-after-stop.html: Added.
+        * fast/dom/HTMLLinkElement/resources/empty.html: Added.
+        * fast/dom/HTMLLinkElement/resources/simple-prerender.html: Added.
+
 2012-05-30  Zhenyao Mo  <[email protected]>
 
         WebKit incorrectly clears the alpha channel on readPixels, even for Framebuffers

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop-expected.txt (0 => 119019)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop-expected.txt	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,4 @@
+Test navigation and removal of link prerender elements
+
+
+This test succeeds when it does not crash. The iframe above this text should also not crash, and should show an empty page.

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop.html (0 => 119019)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/prerender-remove-after-stop.html	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,38 @@
+<html>
+<head>
+<script>
+
+function done() {
+   if (window.layoutTestController) {
+       layoutTestController.notifyDone();
+   }
+}
+
+function elementRemover(doc, id) {
+    return function() {
+        var element = doc.getElementById(id);
+        element.parentNode.removeChild(element);
+        setTimeout(done, 0);
+    }
+}
+
+function navigateIFrameThenRemoveLink() {
+    var iframe = document.getElementById('iframe');
+    iframe._onload_ = elementRemover(iframe.contentDocument, 'prerenderLink');
+    iframe.contentWindow.location = "resources/empty.html";
+}
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+}
+</script>
+</head>
+<body>
+<h1>Test navigation and removal of link prerender elements</h1>
+
+<iframe id=iframe _onload_="navigateIFrameThenRemoveLink()" src=""
+This test succeeds when it does not crash.  The iframe above this text should also not crash, and should show an empty page.
+
+</body>
+</html>

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/empty.html (0 => 119019)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/empty.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/empty.html	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,3 @@
+<html>
+An empty page.
+</html>

Added: trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/simple-prerender.html (0 => 119019)


--- trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/simple-prerender.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLLinkElement/resources/simple-prerender.html	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,4 @@
+<html>
+This is a page that contains a prerender link.
+<link id=prerenderLink rel=prerender href=""
+</html>

Modified: trunk/Tools/ChangeLog (119018 => 119019)


--- trunk/Tools/ChangeLog	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/ChangeLog	2012-05-31 01:54:50 UTC (rev 119019)
@@ -1,3 +1,32 @@
+2012-05-30  Gavin Peters  <[email protected]>
+
+        Add a LayoutTest for prerender remove after stop.
+        https://bugs.webkit.org/show_bug.cgi?id=87860
+
+        These very boring mocks in DumpRenderTree mean that the basic Prerendering API
+        can be tested by LayoutTests now.
+
+        Reviewed by Adam Barth.
+
+        * DumpRenderTree/DumpRenderTree.gypi:
+        * DumpRenderTree/chromium/MockWebPrerenderingSupport.cpp: Added.
+        (MockWebPrerenderingSupport::MockWebPrerenderingSupport):
+        (MockWebPrerenderingSupport::~MockWebPrerenderingSupport):
+        (MockWebPrerenderingSupport::add):
+        (MockWebPrerenderingSupport::cancel):
+        (MockWebPrerenderingSupport::abandon):
+        * DumpRenderTree/chromium/MockWebPrerenderingSupport.h: Added.
+        (MockWebPrerenderingSupport):
+        * DumpRenderTree/chromium/TestShell.cpp:
+        (TestShell::initialize):
+        * DumpRenderTree/chromium/TestShell.h:
+        (TestShell):
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::willAddPrerender):
+        (WebViewHost::setWebWidget):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+
 2012-05-30  Stephanie Lewis  <[email protected]>
 
         https://bugs.webkit.org/show_bug.cgi?id=87717

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.gypi (119018 => 119019)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.gypi	2012-05-31 01:54:50 UTC (rev 119019)
@@ -24,6 +24,8 @@
             'chromium/MockGrammarCheck.h',
             'chromium/MockSpellCheck.cpp',
             'chromium/MockSpellCheck.h',
+            'chromium/MockWebPrerenderingSupport.cpp',
+            'chromium/MockWebPrerenderingSupport.h',
             'chromium/MockWebSpeechInputController.cpp',
             'chromium/MockWebSpeechInputController.h',
             'chromium/NotificationPresenter.h',

Added: trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.cpp (0 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.cpp	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.cpp	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockWebPrerenderingSupport.h"
+
+#include <wtf/Assertions.h>
+
+MockWebPrerenderingSupport::MockWebPrerenderingSupport()
+{
+    ASSERT(!current());
+    initialize(this);
+}
+
+MockWebPrerenderingSupport::~MockWebPrerenderingSupport()
+{
+    ASSERT(current() == this);
+    shutdown();
+}
+
+void MockWebPrerenderingSupport::add(const WebKit::WebPrerender&)
+{
+}
+
+void MockWebPrerenderingSupport::cancel(const WebKit::WebPrerender&)
+{
+}
+
+void MockWebPrerenderingSupport::abandon(const WebKit::WebPrerender&)
+{
+}

Added: trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.h (0 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/chromium/MockWebPrerenderingSupport.h	2012-05-31 01:54:50 UTC (rev 119019)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MockWebPrerenderingSupport_h
+#define MockWebPrerenderingSupport_h
+
+#include "third_party/WebKit/Source/Platform/chromium/public/WebPrerenderingSupport.h"
+
+class MockWebPrerenderingSupport : public WebKit::WebPrerenderingSupport {
+public:
+    MockWebPrerenderingSupport();
+    virtual ~MockWebPrerenderingSupport();
+
+private:
+    void add(const WebKit::WebPrerender&) OVERRIDE;
+    void cancel(const WebKit::WebPrerender&) OVERRIDE;
+    void abandon(const WebKit::WebPrerender&) OVERRIDE;
+};
+
+#endif // MockWebPrerenderingSupport_h

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.cpp (119018 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.cpp	2012-05-31 01:54:50 UTC (rev 119019)
@@ -34,6 +34,7 @@
 #include "DRTDevToolsAgent.h"
 #include "DRTDevToolsClient.h"
 #include "LayoutTestController.h"
+#include "MockWebPrerenderingSupport.h"
 #include "platform/WebArrayBufferView.h"
 #include "WebCompositor.h"
 #include "WebDataSource.h"
@@ -66,6 +67,7 @@
 #include <wtf/MD5.h>
 #include <wtf/OwnArrayPtr.h>
 
+
 using namespace WebKit;
 using namespace std;
 
@@ -147,6 +149,7 @@
     m_webPermissions = adoptPtr(new WebPermissions(this));
     m_accessibilityController = adoptPtr(new AccessibilityController(this));
     m_gamepadController = adoptPtr(new GamepadController(this));
+
     m_layoutTestController = adoptPtr(new LayoutTestController(this));
     m_eventSender = adoptPtr(new EventSender(this));
     m_textInputController = adoptPtr(new TextInputController(this));
@@ -154,6 +157,9 @@
     m_notificationPresenter = adoptPtr(new NotificationPresenter(this));
 #endif
     m_printer = m_testShellMode ? TestEventPrinter::createTestShellPrinter() : TestEventPrinter::createDRTPrinter();
+#if ENABLE(LINK_PRERENDER)
+    m_prerenderingSupport = adoptPtr(new MockWebPrerenderingSupport());
+#endif
 
     WTF::initializeThreading();
 

Modified: trunk/Tools/DumpRenderTree/chromium/TestShell.h (119018 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/TestShell.h	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/DumpRenderTree/chromium/TestShell.h	2012-05-31 01:54:50 UTC (rev 119019)
@@ -59,6 +59,7 @@
 class DRTDevToolsAgent;
 class DRTDevToolsCallArgs;
 class DRTDevToolsClient;
+class MockWebPrerenderingSupport;
 class WebPermissions;
 
 struct TestParams {
@@ -224,6 +225,9 @@
 #endif
     OwnPtr<WebViewHost> m_webViewHost;
     OwnPtr<WebKit::WebThread> m_webCompositorThread;
+#if ENABLE(LINK_PRERENDER)
+    OwnPtr<MockWebPrerenderingSupport> m_prerenderingSupport;
+#endif
 
     TestParams m_params;
     int m_timeout; // timeout value in millisecond

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp (119018 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.cpp	2012-05-31 01:54:50 UTC (rev 119019)
@@ -450,6 +450,15 @@
     return frame->executeCommand(WebString::fromUTF8(m_editCommandName), WebString::fromUTF8(m_editCommandValue));
 }
 
+// WebKit::WebPrerendererClient
+
+void WebViewHost::willAddPrerender(WebKit::WebPrerender*)
+{
+}
+
+
+// WebKit::WebSpellCheckClient
+
 void WebViewHost::spellCheck(const WebString& text, int& misspelledOffset, int& misspelledLength, WebVector<WebString>* optionalSuggestions)
 {
     // Check the spelling of the given text.
@@ -1409,6 +1418,7 @@
 {
     m_webWidget = widget;
     webView()->setSpellCheckClient(this);
+    webView()->setPrerendererClient(this);
     webView()->setCompositorSurfaceReady();
 }
 

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (119018 => 119019)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-05-31 01:51:50 UTC (rev 119018)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-05-31 01:54:50 UTC (rev 119019)
@@ -38,6 +38,7 @@
 #include "WebCursorInfo.h"
 #include "WebFrameClient.h"
 #include "WebIntentRequest.h"
+#include "WebPrerendererClient.h"
 #include "WebSpellCheckClient.h"
 #include "WebViewClient.h"
 #include <wtf/HashMap.h>
@@ -74,7 +75,8 @@
 class TestMediaStreamClient;
 }
 
-class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewClient, public WebKit::WebFrameClient, public NavigationHost {
+class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, public NavigationHost,
+                    public WebKit::WebPrerendererClient, public WebKit::WebSpellCheckClient {
  public:
     WebViewHost(TestShell*);
     virtual ~WebViewHost();
@@ -124,6 +126,9 @@
     // NavigationHost
     virtual bool navigate(const TestNavigationEntry&, bool reload);
 
+    // WebKit::WebPrerendererClient
+    virtual void willAddPrerender(WebKit::WebPrerender*) OVERRIDE;
+
     // WebKit::WebSpellCheckClient
     virtual void spellCheck(const WebKit::WebString&, int& offset, int& length, WebKit::WebVector<WebKit::WebString>* optionalSuggestions);
     virtual void requestCheckingOfText(const WebKit::WebString&, WebKit::WebTextCheckingCompletion*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to