[chromium] Add layout test support for autosize code in FrameView.
authorlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Jan 2012 08:06:38 +0000 (08:06 +0000)
committerlevin@chromium.org <levin@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 8 Jan 2012 08:06:38 +0000 (08:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73631

Reviewed by Dmitry Titov.

Tools:

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController): Expose the new autoresize method.
(LayoutTestController::reset): Set the autoresize mode back to false.
(LayoutTestController::enableAutoResizeMode): A way to turn on autoresizing from javascript code in DumpRenderTree.
* DumpRenderTree/chromium/LayoutTestController.h:
* DumpRenderTree/chromium/WebViewHost.cpp:
(WebViewHost::didAutoResize): Handle the autoresize callback so that the outer bounds change appropriately.
* DumpRenderTree/chromium/WebViewHost.h:

LayoutTests:

* fast/autoresize/basic-expected.txt: Added.
* fast/autoresize/basic.html: Added. Simple test to verify that autoresizing happens.
* platform/efl/Skipped: Skipped the new directory since the layout test
  controller on this platform, doesn't support enableAutoResizeMode.
* platform/gtk/Skipped: Ditto.
* platform/mac/Skipped: Ditto.
* platform/qt/Skipped: Ditto.
* platform/win/Skipped: Ditto.
* platform/wincairo/Skipped: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@104398 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/autoresize/basic-expected.txt [new file with mode: 0644]
LayoutTests/fast/autoresize/basic.html [new file with mode: 0644]
LayoutTests/platform/efl/Skipped
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
LayoutTests/platform/wincairo/Skipped
Tools/ChangeLog
Tools/DumpRenderTree/chromium/LayoutTestController.cpp
Tools/DumpRenderTree/chromium/LayoutTestController.h
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index 59f9345..86b9e3c 100644 (file)
@@ -1,3 +1,20 @@
+2012-01-08  David Levin  <levin@chromium.org>
+
+        [chromium] Add layout test support for autosize code in FrameView.
+        https://bugs.webkit.org/show_bug.cgi?id=73631
+
+        Reviewed by Dmitry Titov.
+
+        * fast/autoresize/basic-expected.txt: Added.
+        * fast/autoresize/basic.html: Added. Simple test to verify that autoresizing happens.
+        * platform/efl/Skipped: Skipped the new directory since the layout test
+          controller on this platform, doesn't support enableAutoResizeMode.
+        * platform/gtk/Skipped: Ditto.
+        * platform/mac/Skipped: Ditto.
+        * platform/qt/Skipped: Ditto.
+        * platform/win/Skipped: Ditto.
+        * platform/wincairo/Skipped: Ditto.
+
 2012-01-07  Dmitry Lomov  <dslomov@google.com>
 
         Unreviewed; chromium tests rebaselined after r104240.
diff --git a/LayoutTests/fast/autoresize/basic-expected.txt b/LayoutTests/fast/autoresize/basic-expected.txt
new file mode 100644 (file)
index 0000000..b9d436e
--- /dev/null
@@ -0,0 +1,12 @@
+This test only works in when run in dumprendertree as it relies on having auto-resize enabled its window. 
+
+When it succeeds, there should be a series of PASS messages followed by a DONE message. 
+
+PASS: document.body.clientWidth equaled window.innerWidth
+PASS: document.body.clientHeight equaled window.innerHeight
+PASS: document.body.scrollWidth equaled window.innerWidth
+PASS: document.body.scrollHeight equaled window.innerHeight
+PASS: window.innerWidth equaled window.outerWidth
+PASS: window.innerHeight equaled window.outerHeight
+DONE
+
diff --git a/LayoutTests/fast/autoresize/basic.html b/LayoutTests/fast/autoresize/basic.html
new file mode 100644 (file)
index 0000000..a1afcb7
--- /dev/null
@@ -0,0 +1,44 @@
+<!doctype html>
+<html>
+<script>
+function log(message)
+{
+    document.getElementById("result").innerHTML += message + "<br>";
+}
+
+function shouldBe(a, b)
+{
+  aValue = eval(a);
+  bValue = eval(b);
+  if (aValue == bValue)
+     log('PASS: ' + a + ' equaled ' + b);
+  else
+     log('FAILED: ' + a + '(' + aValue + ') did not equal ' + b + '(' + bValue + ')');
+}
+
+function runTest()
+{
+    if (window.layoutTestController) {
+        layoutTestController.enableAutoResizeMode(10, 10, 1000, 1000);
+        layoutTestController.dumpAsText();
+    }
+    shouldBe('document.body.clientWidth', 'window.innerWidth');
+    shouldBe('document.body.clientHeight', 'window.innerHeight');
+    shouldBe('document.body.scrollWidth', 'window.innerWidth');
+    shouldBe('document.body.scrollHeight', 'window.innerHeight');
+    shouldBe('window.innerWidth', 'window.outerWidth');
+    shouldBe('window.innerHeight', 'window.outerHeight');
+    log('DONE');
+}
+</script>
+<body onload="runTest()" style="margin:0; width:900px">
+This test only works in when run in dumprendertree as it relies on having auto-resize enabled its window.
+<br>
+<br>
+When it succeeds, there should be a series of PASS messages followed by a DONE message.
+<br>
+<br>
+<div id='result'>
+</div>
+</body>
+</html>
index 7fe2763..49ec0f0 100644 (file)
@@ -477,6 +477,9 @@ fast/media/media-query-list-06.html
 fast/media/media-query-list-07.html
 fast/media/view-mode-media-feature.html
 
+# EFL's LayoutTestController does not implement enableAutoResizeMode
+fast/autoresize
+
 # EFL's LayoutTestController does not implement setWindowIsKey
 editing/selection/4975120.html
 editing/selection/caret-and-focus-ring.html
index c37ffcf..830ad09 100644 (file)
@@ -373,6 +373,9 @@ fast/mutation
 # supported.
 fast/text/international/locale-sensitive-fonts.html
 
+# Needs layoutTestController.enableAutoResizeMode()
+fast/autoresize
+
 # The GTK+ build bots don't yet have the muscle to run WebGL tests.
 compositing/webgl
 fast/canvas/webgl
index eefaf48..8534dbd 100644 (file)
@@ -132,6 +132,9 @@ fast/media/media-query-list-05.html
 fast/media/media-query-list-06.html
 fast/media/media-query-list-07.html
 
+# Needs layoutTestController.enableAutoResizeMode()
+fast/autoresize
+
 # Test is flaky and thus not useful until fixed.
 # https://bugs.webkit.org/show_bug.cgi?id=36642
 fast/replaced/border-radius-clip.html
index 676116e..f4d11e2 100644 (file)
@@ -694,6 +694,9 @@ fast/repaint/text-emphasis-h.html
 fast/repaint/text-emphasis-v.html
 fast/repaint/background-clip-text.html
 
+# Needs layoutTestController.enableAutoResizeMode()
+fast/autoresize
+
 # This requires didClearWindowObjectForFrameInIsolatedWorld foo in FrameLoaderClient
 http/tests/security/isolatedWorld/didClearWindowObject.html
 # This needs more investigation
index 78a8410..2bc1d17 100644 (file)
@@ -1074,6 +1074,9 @@ http/tests/misc/prefetch-purpose.html
 # LayoutTestController::pageProperty is not implemented for WIN yet.
 printing/page-rule-selection.html
 
+# Needs layoutTestController.enableAutoResizeMode()
+fast/autoresize
+
 # Hyphenation is not implemented yet.
 fast/text/hyphenate-character.html
 fast/text/hyphens.html
index 4816d11..bb65b30 100644 (file)
@@ -1612,6 +1612,9 @@ http/tests/misc/prefetch-purpose.html
 # LayoutTestController::pageProperty is not implemented for WIN yet.
 printing/page-rule-selection.html
 
+# Needs layoutTestController.enableAutoResizeMode()
+fast/autoresize
+
 # Hyphenation is not implemented yet.
 fast/text/hyphenate-character.html
 fast/text/hyphens.html
index 10964b2..0ea3b28 100644 (file)
@@ -1,3 +1,19 @@
+2012-01-08  David Levin  <levin@chromium.org>
+
+        [chromium] Add layout test support for autosize code in FrameView.
+        https://bugs.webkit.org/show_bug.cgi?id=73631
+
+        Reviewed by Dmitry Titov.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController): Expose the new autoresize method.
+        (LayoutTestController::reset): Set the autoresize mode back to false.
+        (LayoutTestController::enableAutoResizeMode): A way to turn on autoresizing from javascript code in DumpRenderTree.
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::didAutoResize): Handle the autoresize callback so that the outer bounds change appropriately.
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2012-01-07  Zan Dobersek  <zandobersek@gmail.com>
 
         [WK2][GTK] Each test takes roughly half a second to load
index 7fc2136..f68e0d8 100644 (file)
@@ -116,6 +116,7 @@ LayoutTestController::LayoutTestController(TestShell* shell)
     bindMethod("dumpPermissionClientCallbacks", &LayoutTestController::dumpPermissionClientCallbacks);
     bindMethod("dumpCreateView", &LayoutTestController::dumpCreateView);
     bindMethod("elementDoesAutoCompleteForElementWithId", &LayoutTestController::elementDoesAutoCompleteForElementWithId);
+    bindMethod("enableAutoResizeMode", &LayoutTestController::enableAutoResizeMode);
     bindMethod("evaluateInWebInspector", &LayoutTestController::evaluateInWebInspector);
     bindMethod("evaluateScriptInIsolatedWorld", &LayoutTestController::evaluateScriptInIsolatedWorld);
     bindMethod("setIsolatedWorldSecurityOrigin", &LayoutTestController::setIsolatedWorldSecurityOrigin);
@@ -608,6 +609,8 @@ void LayoutTestController::reset()
         m_shell->webView()->setSelectionColors(0xff1e90ff, 0xff000000, 0xffc8c8c8, 0xff323232);
 #endif
         m_shell->webView()->removeAllUserContent();
+        WebKit::WebSize empty;
+        m_shell->webView()->enableAutoResizeMode(false, empty, empty);
     }
     m_dumpAsText = false;
     m_dumpAsAudio = false;
@@ -1098,6 +1101,24 @@ void LayoutTestController::elementDoesAutoCompleteForElementWithId(const CppArgu
     result->set(elementDoesAutoCompleteForElementWithId(elementId));
 }
 
+void LayoutTestController::enableAutoResizeMode(const CppArgumentList& arguments, CppVariant* result)
+{
+    if (arguments.size() != 4) {
+        result->set(false);
+        return;
+    }
+    int minWidth = cppVariantToInt32(arguments[0]);
+    int minHeight = cppVariantToInt32(arguments[1]);
+    WebKit::WebSize minSize(minWidth, minHeight);
+
+    int maxWidth = cppVariantToInt32(arguments[2]);
+    int maxHeight = cppVariantToInt32(arguments[3]);
+    WebKit::WebSize maxSize(maxWidth, maxHeight);
+
+    m_shell->webView()->enableAutoResizeMode(true, minSize, maxSize);
+    result->set(true);
+}
+
 void LayoutTestController::numberOfActiveAnimations(const CppArgumentList&, CppVariant* result)
 {
     result->set(numberOfActiveAnimations());
index 71b1b42..603b3b9 100644 (file)
@@ -243,6 +243,7 @@ public:
     void pauseAnimationAtTimeOnElementWithId(const CppArgumentList&, CppVariant*);
     void pauseTransitionAtTimeOnElementWithId(const CppArgumentList&, CppVariant*);
     void elementDoesAutoCompleteForElementWithId(const CppArgumentList&, CppVariant*);
+    void enableAutoResizeMode(const CppArgumentList&, CppVariant*);
     void numberOfActiveAnimations(const CppArgumentList&, CppVariant*);
     void suspendAnimations(const CppArgumentList&, CppVariant*);
     void resumeAnimations(const CppArgumentList&, CppVariant*);
index 1b0687d..5d378ba 100644 (file)
@@ -709,6 +709,13 @@ void WebViewHost::didScrollRect(int, int, const WebRect& clipRect)
     didInvalidateRect(clipRect);
 }
 
+void WebViewHost::didAutoResize(const WebSize& newSize)
+{
+    // Purposely don't include the virtualWindowBorder in this case so that
+    // window.inner[Width|Height] is the same as window.outer[Width|Height]
+    setWindowRect(WebRect(0, 0, newSize.width, newSize.height));
+}
+
 void WebViewHost::scheduleComposite()
 {
     WebSize widgetSize = webWidget()->size();
index 0bc4c38..8323fd8 100644 (file)
@@ -154,6 +154,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
     // WebKit::WebWidgetClient
     virtual void didInvalidateRect(const WebKit::WebRect&);
     virtual void didScrollRect(int dx, int dy, const WebKit::WebRect&);
+    virtual void didAutoResize(const WebKit::WebSize& newSize);
     virtual void scheduleComposite();
 #if ENABLE(REQUEST_ANIMATION_FRAME)
     virtual void scheduleAnimation();