Title: [109236] trunk
Revision
109236
Author
commit-qu...@webkit.org
Date
2012-02-29 11:51:11 -0800 (Wed, 29 Feb 2012)

Log Message

Add more tests for web intents
https://bugs.webkit.org/show_bug.cgi?id=79527

Patch by Greg Billock <gbill...@google.com> on 2012-02-29
Reviewed by Adam Barth.

Tools:

* DumpRenderTree/chromium/LayoutTestController.cpp:
(LayoutTestController::LayoutTestController):
(LayoutTestController::sendWebIntentResponse):
* DumpRenderTree/chromium/LayoutTestController.h:
(LayoutTestController):
* DumpRenderTree/chromium/WebViewHost.h:
(WebViewHost):
(WebViewHost::currentIntentRequest):

LayoutTests:

* webintents/resources/web-intents-testing.js: Added.
(onSuccess):
(onFailure):
(startIntentWithCallbacks):
(simulateButtonPress):
* webintents/web-intents-failure-expected.txt: Added.
* webintents/web-intents-failure.html: Added.
* webintents/web-intents-invoke-expected.txt: Added.
* webintents/web-intents-invoke.html: Added.
* webintents/web-intents-reload.html:
* webintents/web-intents-reply-expected.txt: Added.
* webintents/web-intents-reply.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (109235 => 109236)


--- trunk/LayoutTests/ChangeLog	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/LayoutTests/ChangeLog	2012-02-29 19:51:11 UTC (rev 109236)
@@ -1,3 +1,23 @@
+2012-02-29  Greg Billock  <gbill...@google.com>
+
+        Add more tests for web intents
+        https://bugs.webkit.org/show_bug.cgi?id=79527
+
+        Reviewed by Adam Barth.
+
+        * webintents/resources/web-intents-testing.js: Added.
+        (onSuccess):
+        (onFailure):
+        (startIntentWithCallbacks):
+        (simulateButtonPress):
+        * webintents/web-intents-failure-expected.txt: Added.
+        * webintents/web-intents-failure.html: Added.
+        * webintents/web-intents-invoke-expected.txt: Added.
+        * webintents/web-intents-invoke.html: Added.
+        * webintents/web-intents-reload.html:
+        * webintents/web-intents-reply-expected.txt: Added.
+        * webintents/web-intents-reply.html: Added.
+
 2012-02-29  Dmitry Lomov  <dslo...@google.com>
 
         Unreviewed: updating expectations for chrmium (error messages)

Added: trunk/LayoutTests/webintents/resources/web-intents-testing.js (0 => 109236)


--- trunk/LayoutTests/webintents/resources/web-intents-testing.js	                        (rev 0)
+++ trunk/LayoutTests/webintents/resources/web-intents-testing.js	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,40 @@
+// Callback function to be used for a successful web intent call.
+function onSuccess(data) {
+  debug("* got reply: " + data);
+
+  if (window.layoutTestController) {
+    window.layoutTestController.notifyDone();
+  }
+}
+
+// Callback function to be used for a failed web intent call.
+function onFailure(data) {
+  debug("* got failure: " + data);
+
+  if (window.layoutTestController) {
+    window.layoutTestController.notifyDone();
+  }
+}
+
+// Launch a web intent call with callbacks.
+function startIntentWithCallbacks() {
+  navigator.startActivity(new Intent("action1", "mime/type1", "test"), onSuccess, onFailure);
+  debug("* sent intent");
+
+  if (window.layoutTestController) {
+    window.layoutTestController.waitUntilDone();
+  } else {
+    alert('This test needs to run in DRT');
+  }
+}
+
+// This button press simulator sets the user gesture indicator that an intent
+// requires to start.
+function simulateButtonPress() {
+  var button = document.getElementById("button");
+  if (eventSender) {
+    eventSender.mouseMoveTo(button.getBoundingClientRect().left + 2, button.getBoundingClientRect().top + 12);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+  }
+}

Added: trunk/LayoutTests/webintents/web-intents-failure-expected.txt (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-failure-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-failure-expected.txt	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,7 @@
+Received Web Intent: action="" type=mime/type1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+* sent intent
+* got failure: ERROR
+

Added: trunk/LayoutTests/webintents/web-intents-failure.html (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-failure.html	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-failure.html	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,20 @@
+<html>
+  <head>
+    <script src=""
+    <script src=""
+    <script>
+      function buttonClicked() {
+        startIntentWithCallbacks();
+
+        if (window.layoutTestController) {
+          // Empty args will send failure message.
+          window.layoutTestController.sendWebIntentResponse();
+        }
+      }
+    </script>
+  </head>
+<body _onload_="simulateButtonPress()">
+<input type="button" id="button" value="Start Web Intent" _onmouseup_="buttonClicked()">
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/webintents/web-intents-invoke-expected.txt (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-invoke-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-invoke-expected.txt	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,6 @@
+Received Web Intent: action="" type=mime/type1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+* sent intent
+

Added: trunk/LayoutTests/webintents/web-intents-invoke.html (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-invoke.html	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-invoke.html	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,16 @@
+<html>
+  <head>
+    <script src=""
+    <script src=""
+    <script>
+      function buttonClicked() {
+        navigator.startActivity(new Intent("action1", "mime/type1", "test"));
+          debug("* sent intent");
+      }
+    </script>
+  </head>
+<body _onload_="simulateButtonPress()">
+<input type="button" id="button" value="Start Web Intent" _onmouseup_="buttonClicked()">
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/webintents/web-intents-reload.html (109235 => 109236)


--- trunk/LayoutTests/webintents/web-intents-reload.html	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/LayoutTests/webintents/web-intents-reload.html	2012-02-29 19:51:11 UTC (rev 109236)
@@ -1,6 +1,7 @@
 <html>
   <head>
     <script src=""
+    <script src=""
     <script>
       var latch = true;
 
@@ -26,19 +27,14 @@
         if (window.layoutTestController) {
           window.layoutTestController.waitUntilDone();
           window.layoutTestController.dumpChildFramesAsText();
+        } else {
+          alert('This test needs to run in DRT');
         }
 
         debug("* loaded");
 
-        // We must simulate a button press with eventSender because intents
-        // require a user gesture.
-        var button = document.getElementById("button");
-        if (eventSender) {
-          eventSender.mouseMoveTo(button.getBoundingClientRect().left + 2, button.getBoundingClientRect().top + 12);
-          eventSender.mouseDown();
-          eventSender.mouseUp();
-          debug("* sent mouseup");
-        }
+        simulateButtonPress();
+        debug("* sent mouseup");
       }
     </script>
   </head>

Added: trunk/LayoutTests/webintents/web-intents-reply-expected.txt (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-reply-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-reply-expected.txt	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,7 @@
+Received Web Intent: action="" type=mime/type1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+* sent intent
+* got reply: reply
+

Added: trunk/LayoutTests/webintents/web-intents-reply.html (0 => 109236)


--- trunk/LayoutTests/webintents/web-intents-reply.html	                        (rev 0)
+++ trunk/LayoutTests/webintents/web-intents-reply.html	2012-02-29 19:51:11 UTC (rev 109236)
@@ -0,0 +1,19 @@
+<html>
+  <head>
+    <script src=""
+    <script src=""
+    <script>
+      function buttonClicked() {
+        startIntentWithCallbacks();
+
+        if (window.layoutTestController) {
+          window.layoutTestController.sendWebIntentResponse("reply");
+        }
+      }
+    </script>
+  </head>
+<body _onload_="simulateButtonPress()">
+<input type="button" id="button" value="Start Web Intent" _onmouseup_="buttonClicked()">
+<script src=""
+</body>
+</html>

Modified: trunk/Tools/ChangeLog (109235 => 109236)


--- trunk/Tools/ChangeLog	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/Tools/ChangeLog	2012-02-29 19:51:11 UTC (rev 109236)
@@ -1,3 +1,19 @@
+2012-02-29  Greg Billock  <gbill...@google.com>
+
+        Add more tests for web intents
+        https://bugs.webkit.org/show_bug.cgi?id=79527
+
+        Reviewed by Adam Barth.
+
+        * DumpRenderTree/chromium/LayoutTestController.cpp:
+        (LayoutTestController::LayoutTestController):
+        (LayoutTestController::sendWebIntentResponse):
+        * DumpRenderTree/chromium/LayoutTestController.h:
+        (LayoutTestController):
+        * DumpRenderTree/chromium/WebViewHost.h:
+        (WebViewHost):
+        (WebViewHost::currentIntentRequest):
+
 2012-02-29  Dirk Pranke  <dpra...@chromium.org>
 
         perftestsrunner can call printer.write() after printer.cleanup()

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp (109235 => 109236)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp	2012-02-29 19:51:11 UTC (rev 109236)
@@ -49,16 +49,19 @@
 #include "WebGeolocationClientMock.h"
 #include "WebIDBFactory.h"
 #include "WebInputElement.h"
+#include "WebIntentRequest.h"
 #include "WebKit.h"
 #include "WebNotificationPresenter.h"
 #include "WebPermissions.h"
 #include "WebScriptSource.h"
 #include "WebSecurityPolicy.h"
+#include "platform/WebSerializedScriptValue.h"
 #include "WebSettings.h"
 #include "platform/WebSize.h"
 #include "platform/WebURL.h"
 #include "WebView.h"
 #include "WebViewHost.h"
+#include "v8/include/v8.h"
 #include "webkit/support/webkit_support.h"
 #include <algorithm>
 #include <cctype>
@@ -262,6 +265,7 @@
     bindProperty("platformName", &m_platformName);
     bindProperty("interceptPostMessage", &m_interceptPostMessage);
     bindProperty("workerThreadCount", &LayoutTestController::workerThreadCount);
+    bindMethod("sendWebIntentResponse", &LayoutTestController::sendWebIntentResponse);
 }
 
 LayoutTestController::~LayoutTestController()
@@ -2126,6 +2130,28 @@
     result->set(static_cast<int>(WebWorkerInfo::dedicatedWorkerCount()));
 }
 
+void LayoutTestController::sendWebIntentResponse(const CppArgumentList& arguments, CppVariant* result)
+{
+    v8::HandleScope scope;
+    v8::Local<v8::Context> ctx = m_shell->webView()->mainFrame()->mainWorldScriptContext();
+    result->set(m_shell->webView()->mainFrame()->selectionAsMarkup().utf8());
+    v8::Context::Scope cscope(ctx);
+
+    WebKit::WebIntentRequest* request = m_shell->webViewHost()->currentIntentRequest();
+    if (request->isNull())
+        return;
+
+    if (arguments.size() == 1) {
+        WebKit::WebCString reply = cppVariantToWebString(arguments[0]).utf8();
+        v8::Handle<v8::Value> v8value = v8::String::New(reply.data(), reply.length());
+        request->postResult(WebKit::WebSerializedScriptValue::serialize(v8value));
+    } else {
+        v8::Handle<v8::Value> v8value = v8::String::New("ERROR");
+        request->postFailure(WebKit::WebSerializedScriptValue::serialize(v8value));
+    }
+    result->setNull();
+}
+
 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result)
 {
     if (arguments.size() > 0 && arguments[0].isBool()) {

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h (109235 => 109236)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h	2012-02-29 19:51:11 UTC (rev 109236)
@@ -437,6 +437,10 @@
 
     void workerThreadCount(CppVariant*);
 
+    // Expects one string argument for sending successful result, zero
+    // for sending a failure result.
+    void sendWebIntentResponse(const CppArgumentList&, CppVariant*);
+
 public:
     // The following methods are not exposed to _javascript_.
     void setWorkQueueFrozen(bool frozen) { m_workQueue.setFrozen(frozen); }

Modified: trunk/Tools/DumpRenderTree/chromium/WebViewHost.h (109235 => 109236)


--- trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-02-29 19:48:43 UTC (rev 109235)
+++ trunk/Tools/DumpRenderTree/chromium/WebViewHost.h	2012-02-29 19:51:11 UTC (rev 109236)
@@ -252,6 +252,9 @@
     // Pending task list, Note taht the method is referred from MethodTask class.
     TaskList* taskList() { return &m_taskList; }
 
+    // The current web intents request.
+    WebKit::WebIntentRequest* currentIntentRequest() { return &m_currentRequest; }
+
 private:
 
     class HostMethodTask : public MethodTask<WebViewHost> {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to