Upstream version 9.37.193.0 16/26316/1
authorEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Wed, 20 Aug 2014 12:23:42 +0000 (12:23 +0000)
committerEurogiciel-BOT <eurogiciel.tizen@gmail.com>
Wed, 20 Aug 2014 12:23:42 +0000 (12:23 +0000)
Upstream commit-id 868397f443d0425f38abb88487798e7949d0f138

Change-Id: Ic80a08c8e53d59a5b15c17b490203e8940d55a99
Signed-off-by: Eurogiciel-BOT <eurogiciel.tizen@gmail.com>
33 files changed:
packaging/crosswalk.spec
src/xwalk/VERSION
src/xwalk/app/android/app_template/res/values-v14/theme.xml [moved from src/xwalk/app/android/app_template/res/values-v17/theme.xml with 100% similarity]
src/xwalk/app/tools/android/customize.py
src/xwalk/app/tools/android/make_apk.py
src/xwalk/app/tools/android/make_apk_test.py
src/xwalk/application/common/installer/signature_data.cc [new file with mode: 0644]
src/xwalk/application/common/installer/signature_data.h
src/xwalk/application/common/xwalk_application_common.gypi
src/xwalk/packaging/crosswalk.spec
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkLaunchScreenManager.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkUIClientInternal.java
src/xwalk/runtime/android/core_internal/src/org/xwalk/core/internal/XWalkViewInternal.java
src/xwalk/runtime/browser/android/renderer_host/xwalk_render_view_host_ext.cc
src/xwalk/runtime/browser/android/renderer_host/xwalk_render_view_host_ext.h
src/xwalk/runtime/browser/android/xwalk_dev_tools_server.cc
src/xwalk/runtime/browser/runtime_resource_dispatcher_host_delegate_android.cc
src/xwalk/runtime/browser/runtime_resource_dispatcher_host_delegate_android.h
src/xwalk/runtime/browser/ui/native_app_window.cc
src/xwalk/runtime/browser/ui/native_app_window.h
src/xwalk/runtime/renderer/android/xwalk_permission_client.cc
src/xwalk/runtime/renderer/android/xwalk_permission_client.h
src/xwalk/runtime/renderer/android/xwalk_render_view_ext.cc
src/xwalk/runtime/renderer/android/xwalk_render_view_ext.h
src/xwalk/runtime/renderer/isolated_file_system.cc
src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/ShouldOverrideUrlLoadingTest.java [new file with mode: 0644]
src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/TestHelperBridge.java
src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/XWalkViewTestBase.java
src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/util/CommonResources.java
src/xwalk/test/android/runtime_client/javatests/src/org/xwalk/runtime/client/test/NativeFileSystemTest.java
src/xwalk/test/android/runtime_client_embedded/javatests/src/org/xwalk/runtime/client/embedded/test/NativeFileSystemTest.java
src/xwalk/tools/lint.py
src/xwalk/tools/utils.py

index 83c35df..1df546f 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        9.37.190.0
+Version:        9.37.193.0
 Release:        0
 Summary:        Crosswalk is an app runtime based on Chromium
 License:        (BSD-3-Clause and LGPL-2.1+)
index cf0da9d..44cd943 100644 (file)
@@ -1,4 +1,4 @@
 MAJOR=9
 MINOR=37
-BUILD=190
+BUILD=193
 PATCH=0
index 510dd63..2259cea 100755 (executable)
@@ -155,7 +155,7 @@ def CustomizeStringXML(name, description):
 
 
 def CustomizeThemeXML(name, fullscreen, manifest):
-  theme_path = os.path.join(name, 'res', 'values-v17', 'theme.xml')
+  theme_path = os.path.join(name, 'res', 'values-v14', 'theme.xml')
   if not os.path.isfile(theme_path):
     print('Error: theme.xml is missing in the build tool.')
     sys.exit(6)
index ebed389..aed683a 100755 (executable)
@@ -63,7 +63,7 @@ def RunCommand(command, verbose=False, shell=False):
       print ('Command "%s" exited with non-zero exit code %d'
              % (' '.join(command), result))
       sys.exit(result)
-    return output
+    return output.decode("utf-8")
 
 
 def Which(name):
@@ -84,7 +84,7 @@ def GetAndroidApiLevel():
   """
   target_output = RunCommand(['android', 'list', 'target', '-c'])
   target_regex = re.compile(r'android-(\d+)')
-  targets = map(int, target_regex.findall(target_output))
+  targets = [int(i) for i in target_regex.findall(target_output)]
   targets.extend([-1])
   return max(targets)
 
index 3f6c97c..934ce04 100755 (executable)
@@ -468,7 +468,7 @@ class TestMakeApk(unittest.TestCase):
            '-f', self._mode]
     RunCommand(cmd)
     self.addCleanup(Clean, 'Example', '1.0.0')
-    theme = 'Example/res/values-v17/theme.xml'
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -541,7 +541,7 @@ class TestMakeApk(unittest.TestCase):
     self.assertTrue(content.find('android.permission.SEND_SMS') != -1)
     self.assertTrue(content.find('android.permission.WRITE_SMS') != -1)
     self.assertTrue(content.find('landscape') != -1)
-    theme = 'Example/res/values-v17/theme.xml'
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -837,7 +837,7 @@ class TestMakeApk(unittest.TestCase):
     # Test orientation option.
     self.assertTrue(content.find('landscape') != -1)
     # Test fullscreen option
-    theme = 'Example/res/values-v17/theme.xml'
+    theme = 'Example/res/values-v14/theme.xml'
     with open(theme, 'r') as content_file:
       content = content_file.read()
     self.assertTrue(os.path.exists(theme))
@@ -903,7 +903,7 @@ class TestMakeApk(unittest.TestCase):
            '--manifest=%s' % manifest_path, self._mode]
     RunCommand(cmd)
     # Check theme.xml.
-    theme_path = os.path.join('Example', 'res', 'values-v17', 'theme.xml')
+    theme_path = os.path.join('Example', 'res', 'values-v14', 'theme.xml')
     self.assertTrue(os.path.exists(theme_path))
     with open(theme_path, 'r') as content_file:
       content = content_file.read()
diff --git a/src/xwalk/application/common/installer/signature_data.cc b/src/xwalk/application/common/installer/signature_data.cc
new file mode 100644 (file)
index 0000000..740749b
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "xwalk/application/common/installer/signature_data.h"
+
+namespace xwalk {
+namespace application {
+
+SignatureData::SignatureData(const std::string& signature_file_name,
+    int signature_number)
+    : signature_file_name_(signature_file_name),
+      signature_number_(signature_number) {
+}
+
+SignatureData::~SignatureData() {
+}
+
+}  // namespace application
+}  // namespace xwalk
index 5f7f60a..4e623d3 100644 (file)
@@ -19,10 +19,8 @@ namespace application {
 
 class SignatureData {
  public:
-  SignatureData(const std::string& signature_file_name, int signature_number)
-    : signature_file_name_(signature_file_name),
-      signature_number_(signature_number) {
-  }
+  SignatureData(const std::string& signature_file_name, int signature_number);
+  ~SignatureData();
 
   std::string signature_file_name() const {
     return signature_file_name_;
index cb7eca1..77121b9 100644 (file)
@@ -55,6 +55,7 @@
         'installer/package_installer.cc',
         'installer/package_installer.h',
         'installer/signature_data.h',
+        'installer/signature_data.cc',
         'installer/signature_parser.h',
         'installer/signature_parser.cc',
         'installer/wgt_package.h',
index 83c35df..1df546f 100644 (file)
@@ -16,7 +16,7 @@
 %endif
 
 Name:           crosswalk
-Version:        9.37.190.0
+Version:        9.37.193.0
 Release:        0
 Summary:        Crosswalk is an app runtime based on Chromium
 License:        (BSD-3-Clause and LGPL-2.1+)
index 4467121..61cf68b 100644 (file)
@@ -105,12 +105,12 @@ public class XWalkLaunchScreenManager
 
                 mLaunchScreenDialog = new Dialog(mLibContext,
                                                  android.R.style.Theme_Holo_Light_NoActionBar);
-                if ((mActivity.getWindow().getAttributes().flags &
-                     WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) {
-                    mLaunchScreenDialog.getWindow().setFlags(
-                            WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                            WindowManager.LayoutParams.FLAG_FULLSCREEN);
-                }
+
+                int parentVisibility = mActivity.getWindow().getDecorView().getSystemUiVisibility();
+                WindowManager.LayoutParams parentParams = mActivity.getWindow().getAttributes();
+                mLaunchScreenDialog.getWindow().getDecorView().setSystemUiVisibility(parentVisibility);
+                mLaunchScreenDialog.getWindow().setAttributes(parentParams);
+
                 mLaunchScreenDialog.setOnKeyListener(new Dialog.OnKeyListener() {
                     @Override
                     public boolean onKey(DialogInterface arg0, int keyCode,
index 9b48d8d..be57e6f 100644 (file)
@@ -136,6 +136,14 @@ public class XWalkUIClientInternal {
     public void onFullscreenToggled(XWalkViewInternal view, boolean enterFullscreen) {
         Activity activity = view.getActivity();
         if (enterFullscreen) {
+            if ((activity.getWindow().getAttributes().flags &
+                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0) {
+                mOriginalForceNotFullscreen = true;
+                activity.getWindow().clearFlags(
+                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+            } else {
+                mOriginalForceNotFullscreen = false;
+            }
             if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
                 mSystemUiFlag = mDecorView.getSystemUiVisibility();
                 mDecorView.setSystemUiVisibility(
@@ -145,14 +153,6 @@ public class XWalkUIClientInternal {
                         View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
                         View.SYSTEM_UI_FLAG_FULLSCREEN |
                         View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
-                if ((activity.getWindow().getAttributes().flags &
-                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN) != 0) {
-                    mOriginalForceNotFullscreen = true;
-                    activity.getWindow().clearFlags(
-                            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
-                } else {
-                    mOriginalForceNotFullscreen = false;
-                }
             } else {
                 if ((activity.getWindow().getAttributes().flags &
                         WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0) {
@@ -163,12 +163,12 @@ public class XWalkUIClientInternal {
                 }
             }
         } else {
+            if (mOriginalForceNotFullscreen) {
+                activity.getWindow().addFlags(
+                        WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+            }
             if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
                 mDecorView.setSystemUiVisibility(mSystemUiFlag);
-                if (mOriginalForceNotFullscreen) {
-                    activity.getWindow().addFlags(
-                            WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
-                }
             } else {
                 // Clear the activity fullscreen flag.
                 if (!mOriginalFullscreen) {
index ad93b27..ddc6e7c 100644 (file)
@@ -881,7 +881,7 @@ public class XWalkViewInternal extends android.widget.FrameLayout {
     private void onActivityStateChange(Activity activity, int newState) {
         assert(getActivity() == activity);
         switch (newState) {
-           case ActivityState.STARTED:
+            case ActivityState.STARTED:
                 onShow();
                 break;
             case ActivityState.PAUSED:
@@ -893,7 +893,7 @@ public class XWalkViewInternal extends android.widget.FrameLayout {
             case ActivityState.DESTROYED:
                 onDestroy();
                 break;
-           case ActivityState.STOPPED:
+            case ActivityState.STOPPED:
                 onHide();
                 break;
             default:
index e983880..7877ade 100644 (file)
@@ -95,7 +95,7 @@ void XWalkRenderViewHostExt::SetJsOnlineProperty(bool network_up) {
   Send(new XWalkViewMsg_SetJsOnlineProperty(network_up));
 }
 
-void XWalkRenderViewHostExt::RenderViewGone(base::TerminationStatus status) {
+void XWalkRenderViewHostExt::RenderProcessGone(base::TerminationStatus status) {
   DCHECK(CalledOnValidThread());
   for (std::map<int, DocumentHasImagesResult>::iterator pending_req =
            pending_document_has_images_requests_.begin();
index 2b110ee..73be9a6 100644 (file)
@@ -71,7 +71,7 @@ class XWalkRenderViewHostExt : public content::WebContentsObserver,
   // content::WebContentsObserver implementation.
   virtual void RenderViewCreated(
       content::RenderViewHost* render_view_host) OVERRIDE;
-  virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
+  virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
   virtual void DidNavigateAnyFrame(
       const content::LoadCommittedDetails& details,
       const content::FrameNavigateParams& params) OVERRIDE;
index 0e2bf81..a592db3 100644 (file)
@@ -26,6 +26,7 @@
 #include "content/public/browser/navigation_entry.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_delegate.h"
 #include "content/public/common/user_agent.h"
 #include "grit/xwalk_resources.h"
 #include "jni/XWalkDevToolsServer_jni.h"
@@ -66,7 +67,18 @@ class Target : public content::DevToolsTarget {
   virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const OVERRIDE {
     return agent_host_;
   }
-  virtual bool Activate() const OVERRIDE { return false; }
+
+  virtual bool Activate() const OVERRIDE {
+    RenderViewHost* rvh = agent_host_->GetRenderViewHost();
+    if (!rvh)
+      return false;
+    WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
+    if (!web_contents)
+      return false;
+    web_contents->GetDelegate()->ActivateContents(web_contents);
+    return true;
+  }
+
   virtual bool Close() const OVERRIDE { return false; }
 
  private:
index 8a572be..b385f6c 100644 (file)
@@ -302,7 +302,8 @@ content::ResourceDispatcherHostLoginDelegate*
 bool RuntimeResourceDispatcherHostDelegateAndroid::HandleExternalProtocol(
     const GURL& url,
     int child_id,
-    int route_id) {
+    int route_id,
+    bool initiated_by_user_gesture) {
   // On Android, there are many Uris need to be handled differently.
   // e.g: sms:, tel:, mailto: and etc.
   // So here return false to let embedders to decide which protocol
index 559b8df..2c20fbe 100644 (file)
@@ -56,7 +56,8 @@ class RuntimeResourceDispatcherHostDelegateAndroid
   virtual bool HandleExternalProtocol(
       const GURL& url,
       int child_id,
-      int route_id) OVERRIDE;
+      int route_id,
+      bool initiated_by_user_gesture) OVERRIDE;
   virtual void OnResponseStarted(
       net::URLRequest* request,
       content::ResourceContext* resource_context,
index 3f6e0e5..f782ea1 100644 (file)
@@ -15,5 +15,8 @@ NativeAppWindow::CreateParams::CreateParams()
     parent(NULL) {
 }
 
+NativeAppWindow::CreateParams::~CreateParams() {
+}
+
 }  // namespace xwalk
 
index 1ef0b44..7fe49f4 100644 (file)
@@ -34,6 +34,7 @@ class NativeAppWindow {
  public:
   struct CreateParams {
     CreateParams();
+    ~CreateParams();
     // Delegate for this window.
     NativeAppWindowDelegate* delegate;
     // WebContents which the content will be displayed in this window.
index 41221b9..82d61a6 100644 (file)
@@ -12,7 +12,6 @@
 
 namespace xwalk {
 
-
 XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
     : content::RenderFrameObserver(render_frame) {
   render_frame->GetWebFrame()->setPermissionClient(this);
@@ -21,9 +20,8 @@ XWalkPermissionClient::XWalkPermissionClient(content::RenderFrame* render_frame)
 XWalkPermissionClient::~XWalkPermissionClient() {
 }
 
-bool XWalkPermissionClient::allowImage(blink::WebFrame* frame,
-                                 bool enabled_per_settings,
-                                 const blink::WebURL& image_url) {
+bool XWalkPermissionClient::allowImage(bool enabled_per_settings,
+                                       const blink::WebURL& image_url) {
   // Implementing setBlockNetworkImages, so allow local scheme images to be
   // loaded.
   if (enabled_per_settings)
index d0b896c..cb6d972 100644 (file)
@@ -12,7 +12,7 @@ namespace xwalk {
 
 // XWalk implementation of blink::WebPermissionClient.
 class XWalkPermissionClient : public content::RenderFrameObserver,
-                           public blink::WebPermissionClient {
+                              public blink::WebPermissionClient {
  public:
   explicit XWalkPermissionClient(content::RenderFrame* render_view);
 
@@ -20,9 +20,8 @@ class XWalkPermissionClient : public content::RenderFrameObserver,
   virtual ~XWalkPermissionClient();
 
   // blink::WebPermissionClient implementation.
-  virtual bool allowImage(blink::WebFrame* frame,
-                        bool enabledPerSettings,
-                        const blink::WebURL& imageURL) OVERRIDE;
+  virtual bool allowImage(bool enabledPerSettings,
+                          const blink::WebURL& imageURL) OVERRIDE;
 
   DISALLOW_COPY_AND_ASSIGN(XWalkPermissionClient);
 };
index a14ca4e..6372c57 100644 (file)
@@ -20,8 +20,8 @@
 #include "third_party/WebKit/public/web/WebDocument.h"
 #include "third_party/WebKit/public/web/WebElement.h"
 #include "third_party/WebKit/public/web/WebElementCollection.h"
-#include "third_party/WebKit/public/web/WebFrame.h"
 #include "third_party/WebKit/public/web/WebHitTestResult.h"
+#include "third_party/WebKit/public/web/WebLocalFrame.h"
 #include "third_party/WebKit/public/web/WebNode.h"
 #include "third_party/WebKit/public/web/WebNodeList.h"
 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
@@ -168,8 +168,8 @@ void XWalkRenderViewExt::OnDocumentHasImagesRequest(int id) {
                                                    hasImages));
 }
 
-void XWalkRenderViewExt::DidCommitProvisionalLoad(blink::WebFrame* frame,
-                                               bool is_new_navigation) {
+void XWalkRenderViewExt::DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
+                                                  bool is_new_navigation) {
   content::DocumentState* document_state =
       content::DocumentState::FromDataSource(frame->dataSource());
   if (document_state->can_load_local_resources()) {
index 7374481..44ae82d 100644 (file)
@@ -32,7 +32,7 @@ class XWalkRenderViewExt : public content::RenderViewObserver {
 
   // RenderView::Observer:
   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
-  virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
+  virtual void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
                                         bool is_new_navigation) OVERRIDE;
   virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE;
   virtual void DidCommitCompositorFrame() OVERRIDE;
index 5ecda18..4a840c5 100644 (file)
@@ -52,15 +52,22 @@ void IsolatedFileSystem::GetIsolatedFileSystem(
   CHECK(data_source);
   GURL context_url(data_source->request().url());
 
-  std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(),
-                                                      file_system_id));
+  // In instrument test, context_url.GetOrigin() returns emtpy string.
+  // That causes app crash. So assign "file:///" as default value to
+  // origin to avoid this.
+  GURL origin("file:///");
+  if (!context_url.SchemeIs(url::kDataScheme) &&
+      !context_url.GetOrigin().is_empty()) {
+    origin = context_url.GetOrigin();
+  }
+  std::string name(fileapi::GetIsolatedFileSystemName(origin, file_system_id));
 
   // The optional second argument is the subfolder within the isolated file
   // system at which to root the DOMFileSystem we're returning to the caller.
   std::string optional_root_name = "";
 
   blink::WebURL root(GURL(fileapi::GetIsolatedFileSystemRootURIString(
-      context_url.GetOrigin(),
+      origin,
       file_system_id,
       optional_root_name)));
   v8::Isolate* isolate = v8::Isolate::GetCurrent();
diff --git a/src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/ShouldOverrideUrlLoadingTest.java b/src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/ShouldOverrideUrlLoadingTest.java
new file mode 100644 (file)
index 0000000..683a59c
--- /dev/null
@@ -0,0 +1,573 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2014 Intel Corporation. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.xwalk.core.xwview.test;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.util.Pair;
+
+import java.util.ArrayList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import java.util.List;
+
+import org.chromium.base.test.util.DisabledTest;
+import org.chromium.base.test.util.Feature;
+import org.chromium.content.browser.LoadUrlParams;
+import org.chromium.content.browser.test.util.CallbackHelper;
+import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageStartedHelper;
+import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnReceivedErrorHelper;
+import org.chromium.net.test.util.TestWebServer;
+
+import org.xwalk.core.xwview.test.util.CommonResources;
+
+/**
+ * Tests for the shouldOverrideUrlLoading() method.
+ */
+public class ShouldOverrideUrlLoadingTest extends XWalkViewTestBase {
+    private static final String ABOUT_BLANK_URL = "about:blank";
+    private static final String DATA_URL = "data:text/html,<div/>";
+    private static final String REDIRECT_TARGET_PATH = "/redirect_target.html";
+    private static final String TITLE = "TITLE";
+    private TestHelperBridge.ShouldOverrideUrlLoadingHelper mShouldOverrideUrlLoadingHelper;
+    private TestWebServer mWebServer;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mShouldOverrideUrlLoadingHelper = mTestHelperBridge.getShouldOverrideUrlLoadingHelper();
+        mWebServer = new TestWebServer(false);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mWebServer.shutdown();
+        super.tearDown();
+    }
+
+    // Since this value is read on the UI thread, it's simpler to set it there too.
+    void setShouldOverrideUrlLoadingReturnValueOnUiThread(
+            final boolean value) throws Throwable {
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                mShouldOverrideUrlLoadingHelper.setShouldOverrideUrlLoadingReturnValue(value);
+            }
+        });
+    }
+
+    private String getTestPageCommonHeaders() {
+        return "<title>" + TITLE + "</title> ";
+    }
+
+    private String makeHtmlPageFrom(String headers, String body) {
+        return CommonResources.makeHtmlPageFrom(getTestPageCommonHeaders() + headers, body);
+    }
+
+    private String getHtmlForPageWithJsAssignLinkTo(String url) {
+        return makeHtmlPageFrom("",
+                "<img onclick=\"location.href='" + url + "'\" class=\"big\" id=\"link\" />");
+    }
+
+    private String getHtmlForPageWithJsReplaceLinkTo(String url) {
+        return makeHtmlPageFrom("",
+                "<img onclick=\"location.replace('" + url + "');\" class=\"big\" id=\"link\" />");
+    }
+
+    private String getHtmlForPageWithMetaRefreshRedirectTo(String url) {
+        return makeHtmlPageFrom("<meta http-equiv=\"refresh\" content=\"0;url=" + url + "\" />",
+                "<div>Meta refresh redirect</div>");
+    }
+
+    private String getHtmlForPageWithJsRedirectTo(String url, String method, int timeout) {
+        return makeHtmlPageFrom(
+                "<script>" +
+                  "function doRedirectAssign() {" +
+                    "location.href = '" + url + "';" +
+                  "} " +
+                  "function doRedirectReplace() {" +
+                    "location.replace('" + url + "');" +
+                  "} " +
+                "</script>",
+                String.format("<iframe onLoad=\"setTimeout('doRedirect%s()', %d);\" />",
+                    method, timeout));
+    }
+
+    private String addPageToTestServer(TestWebServer webServer, String httpPath, String html) {
+        List<Pair<String, String>> headers = new ArrayList<Pair<String, String>>();
+        headers.add(Pair.create("Content-Type", "text/html"));
+        headers.add(Pair.create("Cache-Control", "no-store"));
+        return webServer.setResponse(httpPath, html, headers);
+    }
+
+    private String createRedirectTargetPage(TestWebServer webServer) {
+        return addPageToTestServer(webServer, REDIRECT_TARGET_PATH,
+                makeHtmlPageFrom("", "<div>This is the end of the redirect chain</div>"));
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testNotCalledOnLoadData() throws Throwable {
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
+
+        assertEquals(0, mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+
+    private void waitForNavigationRunnableAndAssertTitleChanged(
+            CallbackHelper onPageFinishedHelper,
+            Runnable navigationRunnable) throws Exception {
+        final int callCount = onPageFinishedHelper.getCallCount();
+        final String oldTitle = getTitleOnUiThread();
+        getInstrumentation().runOnMainSync(navigationRunnable);
+        onPageFinishedHelper.waitForCallback(callCount);
+        assertFalse(oldTitle.equals(getTitleOnUiThread()));
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnBackForwardNavigation() throws Throwable {
+        final String url = "file:///android_asset/www/index.html";
+        final String httpPath = "/test.html";
+        final String httpPathOnServer = mWebServer.getResponseUrl(httpPath);
+        addPageToTestServer(mWebServer, httpPath,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(httpPathOnServer));
+
+        loadUrlSync(httpPathOnServer);
+        loadUrlSync(url);
+        assertEquals(2, mShouldOverrideUrlLoadingHelper.getCallCount());
+        String oldTitle = getTitleOnUiThread();
+        goBackSync();
+        assertFalse(oldTitle.equals(getTitleOnUiThread()));
+        assertEquals(3, mShouldOverrideUrlLoadingHelper.getCallCount());
+
+        oldTitle = getTitleOnUiThread();
+        goForwardSync();
+        assertFalse(oldTitle.equals(getTitleOnUiThread()));
+        assertEquals(4, mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCantBlockLoads() throws Throwable {
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(true);
+
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(getTestPageCommonHeaders(),
+                        DATA_URL), "text/html", false);
+
+        assertEquals(TITLE, getTitleOnUiThread());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledBeforeOnPageStarted() throws Throwable {
+        OnPageStartedHelper onPageStartedHelper = mTestHelperBridge.getOnPageStartedHelper();
+
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
+
+        final int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        final int onPageStartedCallCount = onPageStartedHelper.getCallCount();
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(true);
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
+        assertEquals(onPageStartedCallCount, onPageStartedHelper.getCallCount());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testDoesNotCauseOnReceivedError() throws Throwable {
+        OnReceivedErrorHelper onReceivedErrorHelper = mTestHelperBridge.getOnReceivedErrorHelper();
+        final int onReceivedErrorCallCount = onReceivedErrorHelper.getCallCount();
+
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
+
+        final int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(true);
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
+
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(false);
+
+        // After we load this URL we're certain that any in-flight callbacks for the previous
+        // navigation have been delivered.
+        loadUrlSync(ABOUT_BLANK_URL);
+
+        assertEquals(onReceivedErrorCallCount, onReceivedErrorHelper.getCallCount());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testNotCalledForAnchorNavigations() throws Throwable {
+        doTestNotCalledForAnchorNavigations(false);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testNotCalledForAnchorNavigationsWithNonHierarchicalScheme() throws Throwable {
+        doTestNotCalledForAnchorNavigations(true);
+    }
+
+    private void doTestNotCalledForAnchorNavigations(boolean useLoadData) throws Throwable {
+        final String anchorLinkPath = "/anchor_link.html";
+        final String anchorLinkUrl = mWebServer.getResponseUrl(anchorLinkPath);
+        addPageToTestServer(mWebServer, anchorLinkPath,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(anchorLinkUrl + "#anchor"));
+
+        if (useLoadData) {
+            loadDataSync(null,
+                    CommonResources.makeHtmlPageWithSimpleLinkTo("#anchor"), "text/html", false);
+        } else {
+            loadUrlSync(anchorLinkUrl);
+        }
+
+        final int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        clickOnElementId("link");
+
+        // After we load this URL we're certain that any in-flight callbacks for the previous
+        // navigation have been delivered.
+        loadUrlSync(ABOUT_BLANK_URL);
+
+        assertEquals(shouldOverrideUrlLoadingCallCount,
+                mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledWhenLinkClicked() throws Throwable {
+        // We can't go to about:blank from here because we'd get a cross-origin error.
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledWhenSelfLinkClicked() throws Throwable {
+        final String httpPath = "/page_with_link_to_self.html";
+        final String httpPathOnServer = mWebServer.getResponseUrl(httpPath);
+        addPageToTestServer(mWebServer, httpPath,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(httpPathOnServer));
+
+        loadUrlSync(httpPathOnServer);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+        assertEquals(httpPathOnServer,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledWhenNavigatingFromJavaScriptUsingAssign()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        loadDataSync(null,
+                getHtmlForPageWithJsAssignLinkTo(redirectTargetUrl), "text/html", false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledWhenNavigatingFromJavaScriptUsingReplace()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        loadDataSync(null,
+                getHtmlForPageWithJsReplaceLinkTo(redirectTargetUrl), "text/html", false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        clickOnElementId("link");
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testPassesCorrectUrl() throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl), "text/html", false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        clickOnElementId("link");
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+        assertEquals(redirectTargetUrl,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+    }
+
+    // This test case is not stable, disable it temporarily.
+    // @SmallTest
+    // @Feature({"XWalkView", "Navigation"})
+    @DisabledTest
+    public void testCanIgnoreLoading() throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String pageWithLinkToIgnorePath = "/page_with_link_to_ignore.html";
+        final String pageWithLinkToIgnoreUrl = addPageToTestServer(mWebServer,
+                pageWithLinkToIgnorePath, CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl));
+        final String synchronizationPath = "/sync.html";
+        final String synchronizationUrl = addPageToTestServer(mWebServer, synchronizationPath,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(redirectTargetUrl));
+
+        loadUrlSync(pageWithLinkToIgnoreUrl);
+
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(true);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        clickOnElementId("link");
+        // Some time around here true should be returned from the shouldOverrideUrlLoading
+        // callback causing the navigation caused by calling clickOnElementId to be ignored.
+        // We validate this by checking which pages were loaded on the server.
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+
+        setShouldOverrideUrlLoadingReturnValueOnUiThread(false);
+
+        loadUrlSync(synchronizationUrl);
+
+        assertEquals(1, mWebServer.getRequestCount(pageWithLinkToIgnorePath));
+        assertEquals(1, mWebServer.getRequestCount(synchronizationPath));
+        assertEquals(0, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledForDataUrl() throws Throwable {
+        final String dataUrl =
+                "data:text/html;base64," +
+                "PGh0bWw+PGhlYWQ+PHRpdGxlPmRhdGFVcmxUZXN0QmFzZTY0PC90aXRsZT48" +
+                "L2hlYWQ+PC9odG1sPg==";
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(dataUrl), "text/html", false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+        assertTrue("Expected URL that starts with 'data:' but got: <" +
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl() + "> instead.",
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl().startsWith(
+                        "data:"));
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledForUnsupportedSchemes() throws Throwable {
+        final String unsupportedSchemeUrl = "foobar://resource/1";
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(unsupportedSchemeUrl), "text/html",
+                        false);
+
+        int callCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(callCount);
+        assertEquals(unsupportedSchemeUrl,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledForPostNavigations() throws Throwable {
+        // The reason POST requests are excluded is BUG 155250.
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String postLinkUrl = addPageToTestServer(mWebServer, "/page_with_post_link.html",
+                CommonResources.makeHtmlPageWithSimplePostFormTo(redirectTargetUrl));
+
+        loadUrlSync(postLinkUrl);
+
+        final int shouldOverrideUrlLoadingCallCount =
+            mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        assertEquals(0, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
+        clickOnElementId("link");
+
+        // Wait for the target URL to be fetched from the server.
+        pollOnUiThread(new Callable<Boolean>() {
+            @Override
+            public Boolean call() throws Exception {
+                return mWebServer.getRequestCount(REDIRECT_TARGET_PATH) == 1;
+            }
+        });
+
+        // Since the targetURL was loaded from the test server it means all processing related
+        // to dispatching a shouldOverrideUrlLoading callback had finished and checking the call
+        // is stable.
+        assertEquals(shouldOverrideUrlLoadingCallCount + 1,
+                mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledFor302AfterPostNavigations() throws Throwable {
+        // The reason POST requests are excluded is BUG 155250.
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String postToGetRedirectUrl = mWebServer.setRedirect("/302.html", redirectTargetUrl);
+        final String postLinkUrl = addPageToTestServer(mWebServer, "/page_with_post_link.html",
+                CommonResources.makeHtmlPageWithSimplePostFormTo(postToGetRedirectUrl));
+
+        loadUrlSync(postLinkUrl);
+
+        final int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
+
+        // Wait for the target URL to be fetched from the server.
+        pollOnUiThread(new Callable<Boolean>() {
+            @Override
+            public Boolean call() throws Exception {
+                return mWebServer.getRequestCount(REDIRECT_TARGET_PATH) == 1;
+            }
+        });
+
+        assertEquals(redirectTargetUrl,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledForIframeHttpNavigations() throws Throwable {
+        final String iframeRedirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String iframeRedirectUrl = mWebServer.setRedirect("/302.html", iframeRedirectTargetUrl);
+        final String pageWithIframeUrl = addPageToTestServer(mWebServer, "/iframe_intercept.html",
+                makeHtmlPageFrom("", "<iframe src=\"" + iframeRedirectUrl + "\" />"));
+
+        assertEquals(0, mWebServer.getRequestCount(REDIRECT_TARGET_PATH));
+        loadUrlSync(pageWithIframeUrl);
+
+        // Wait for the redirect target URL to be fetched from the server.
+        pollOnUiThread(new Callable<Boolean>() {
+            @Override
+            public Boolean call() throws Exception {
+                return mWebServer.getRequestCount(REDIRECT_TARGET_PATH) == 1;
+            }
+        });
+
+        assertEquals(1, mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+
+    /**
+     * Worker method for the various redirect tests.
+     *
+     * Calling this will first load the redirect URL built from redirectFilePath, query and
+     * locationFilePath and assert that we get a override callback for the destination.
+     * The second part of the test loads a page that contains a link which points at the redirect
+     * URL. We expect two callbacks - one for the redirect link and another for the destination.
+     */
+    private void doTestCalledOnRedirect(TestWebServer webServer,
+            String redirectUrl, String redirectTarget) throws Throwable {
+        final String pageWithLinkToRedirectUrl = addPageToTestServer(webServer,
+                "/page_with_link_to_redirect.html",
+                         CommonResources.makeHtmlPageWithSimpleLinkTo(redirectUrl));
+        int directLoadCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        loadUrlSync(redirectUrl);
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(directLoadCallCount, 2);
+        assertEquals(redirectTarget,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+
+        int indirectLoadCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
+        loadUrlSync(pageWithLinkToRedirectUrl);
+
+        clickOnElementId("link");
+
+        mShouldOverrideUrlLoadingHelper.waitForCallback(indirectLoadCallCount, 3);
+        assertEquals(redirectTarget,
+                mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingUrl());
+        assertEquals(redirectUrl,
+                mShouldOverrideUrlLoadingHelper.getPreviousShouldOverrideUrlLoadingUrl());
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOn302Redirect() throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = mWebServer.setRedirect("/302.html", redirectTargetUrl);
+
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnMetaRefreshRedirect() throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = addPageToTestServer(mWebServer, "/meta_refresh.html",
+                getHtmlForPageWithMetaRefreshRedirectTo(redirectTargetUrl));
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnJavaScriptLocationImmediateAssignRedirect()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = addPageToTestServer(mWebServer, "/js_immediate_assign.html",
+                getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Assign", 0));
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnJavaScriptLocationImmediateReplaceRedirect()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = addPageToTestServer(mWebServer, "/js_immediate_replace.html",
+                getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Replace", 0));
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnJavaScriptLocationDelayedAssignRedirect()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = addPageToTestServer(mWebServer, "/js_delayed_assign.html",
+                getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Assign", 100));
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testCalledOnJavaScriptLocationDelayedReplaceRedirect()
+            throws Throwable {
+        final String redirectTargetUrl = createRedirectTargetPage(mWebServer);
+        final String redirectUrl = addPageToTestServer(mWebServer, "/js_delayed_replace.html",
+                getHtmlForPageWithJsRedirectTo(redirectTargetUrl, "Replace", 100));
+        doTestCalledOnRedirect(mWebServer, redirectUrl, redirectTargetUrl);
+    }
+
+    @SmallTest
+    @Feature({"XWalkView", "Navigation"})
+    public void testDoubleNavigateDoesNotSuppressInitialNavigate() throws Throwable {
+        final String jsUrl = "javascript:try{console.log('processed js loadUrl');}catch(e){};";
+
+        // Do a double navigagtion, the second being an effective no-op, in quick succession (i.e.
+        // without yielding the main thread inbetween).
+        loadDataSync(null,
+                CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
+        loadJavaScriptUrl(jsUrl);
+        assertEquals(0, mShouldOverrideUrlLoadingHelper.getCallCount());
+    }
+}
index ec10821..0409d73 100644 (file)
@@ -154,6 +154,44 @@ class TestHelperBridge {
         }
     }
 
+    public class ShouldOverrideUrlLoadingHelper extends CallbackHelper {
+        private String mShouldOverrideUrlLoadingUrl;
+        private String mPreviousShouldOverrideUrlLoadingUrl;
+        private boolean mShouldOverrideUrlLoadingReturnValue = false;
+
+        void setShouldOverrideUrlLoadingUrl(String url) {
+            mShouldOverrideUrlLoadingUrl = url;
+        }
+
+        void setPreviousShouldOverrideUrlLoadingUrl(String url) {
+            mPreviousShouldOverrideUrlLoadingUrl = url;
+        }
+
+        void setShouldOverrideUrlLoadingReturnValue(boolean value) {
+            mShouldOverrideUrlLoadingReturnValue = value;
+        }
+
+        public String getShouldOverrideUrlLoadingUrl() {
+            assert getCallCount() > 0;
+            return mShouldOverrideUrlLoadingUrl;
+        }
+
+        public String getPreviousShouldOverrideUrlLoadingUrl() {
+            assert getCallCount() > 1;
+            return mPreviousShouldOverrideUrlLoadingUrl;
+        }
+
+        public boolean getShouldOverrideUrlLoadingReturnValue() {
+            return mShouldOverrideUrlLoadingReturnValue;
+        }
+
+        public void notifyCalled(String url) {
+            mPreviousShouldOverrideUrlLoadingUrl = mShouldOverrideUrlLoadingUrl;
+            mShouldOverrideUrlLoadingUrl = url;
+            notifyCalled();
+        }
+    }
+
     private String mChangedTitle;
     private final OnPageStartedHelper mOnPageStartedHelper;
     private final OnPageFinishedHelper mOnPageFinishedHelper;
@@ -166,6 +204,7 @@ class TestHelperBridge {
     private final OnLoadStartedHelper mOnLoadStartedHelper;
     private final OnJavascriptCloseWindowHelper mOnJavascriptCloseWindowHelper;
     private final OnProgressChangedHelper mOnProgressChangedHelper;
+    private final ShouldOverrideUrlLoadingHelper mShouldOverrideUrlLoadingHelper;
 
     public TestHelperBridge() {
         mOnPageStartedHelper = new OnPageStartedHelper();
@@ -177,6 +216,7 @@ class TestHelperBridge {
         mOnLoadStartedHelper = new OnLoadStartedHelper();
         mOnJavascriptCloseWindowHelper = new OnJavascriptCloseWindowHelper();
         mOnProgressChangedHelper = new OnProgressChangedHelper();
+        mShouldOverrideUrlLoadingHelper = new ShouldOverrideUrlLoadingHelper();
     }
 
     public OnPageStartedHelper getOnPageStartedHelper() {
@@ -215,6 +255,10 @@ class TestHelperBridge {
         return mOnProgressChangedHelper;
     }
 
+    public ShouldOverrideUrlLoadingHelper getShouldOverrideUrlLoadingHelper() {
+        return mShouldOverrideUrlLoadingHelper;
+    }
+
     public void onTitleChanged(String title) {
         mChangedTitle = title;
         mOnTitleUpdatedHelper.notifyCalled(title);
@@ -253,4 +297,11 @@ class TestHelperBridge {
     public void onProgressChanged(int progress) {
         mOnProgressChangedHelper.notifyCalled(progress);
     }
+
+    public boolean shouldOverrideUrlLoading(String url) {
+        boolean returnValue =
+            mShouldOverrideUrlLoadingHelper.getShouldOverrideUrlLoadingReturnValue();
+        mShouldOverrideUrlLoadingHelper.notifyCalled(url);
+        return returnValue;
+    }
 }
index 5ad26a0..c7f996d 100644 (file)
@@ -34,6 +34,8 @@ import org.xwalk.core.XWalkView;
 public class XWalkViewTestBase
        extends ActivityInstrumentationTestCase2<XWalkViewTestRunnerActivity> {
     protected final static int WAIT_TIMEOUT_SECONDS = 15;
+    protected final static long WAIT_TIMEOUT_MS = 2000;
+    private final static int CHECK_INTERVAL = 100;
     private final static String TAG = "XWalkViewTestBase";
     private XWalkView mXWalkView;
     final TestHelperBridge mTestHelperBridge = new TestHelperBridge();
@@ -99,6 +101,11 @@ public class XWalkViewTestBase
         public void onProgressChanged(XWalkView view, int progressInPercent) {
             mTestHelperBridge.onProgressChanged(progressInPercent);
         }
+
+        @Override
+        public boolean shouldOverrideUrlLoading(XWalkView view, String url) {
+            return mTestHelperBridge.shouldOverrideUrlLoading(url);
+        }
     }
 
     class TestXWalkResourceClient extends TestXWalkResourceClientBase {
@@ -473,4 +480,31 @@ public class XWalkViewTestBase
             }
         });
     }
+
+    public void clickOnElementId(final String id) throws Exception {
+        Assert.assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+            @Override
+            public boolean isSatisfied() {
+                try {
+                    String idIsNotNull = executeJavaScriptAndWaitForResult(
+                        "document.getElementById('" + id + "') != null");
+                    return idIsNotNull.equals("true");
+                } catch (Throwable t) {
+                    t.printStackTrace();
+                    Assert.fail("Failed to check if DOM is loaded: " + t.toString());
+                    return false;
+                }
+            }
+        }, WAIT_TIMEOUT_MS, CHECK_INTERVAL));
+
+        try {
+            String result = executeJavaScriptAndWaitForResult(
+                "var evObj = document.createEvent('Events'); " +
+                "evObj.initEvent('click', true, false); " +
+                "document.getElementById('" + id + "').dispatchEvent(evObj);" +
+                "console.log('element with id [" + id + "] clicked');");
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
 }
index 9e9fbc8..f201b6d 100644 (file)
@@ -102,4 +102,22 @@ public class CommonResources {
                  "</body>" +
              "</html>";
     }
+
+    public static String makeHtmlPageWithSimpleLinkTo(String headers, String destination) {
+        return makeHtmlPageFrom(headers,
+                        "<a href=\"" + destination + "\" id=\"link\">" +
+                          "<img class=\"big\" />" +
+                        "</a>");
+    }
+
+    public static String makeHtmlPageWithSimpleLinkTo(String destination) {
+        return makeHtmlPageWithSimpleLinkTo("", destination);
+    }
+
+    public static String makeHtmlPageWithSimplePostFormTo(String destination) {
+        return makeHtmlPageFrom("",
+                "<form action=\"" + destination + "\" method=\"post\">" +
+                  "<input type=\"submit\" value=\"post\" id=\"link\">" +
+                "</form>");
+    }
 }
index af797a9..ec63542 100644 (file)
@@ -16,7 +16,6 @@ import org.xwalk.test.util.RuntimeClientApiTestBase;
 public class NativeFileSystemTest extends XWalkRuntimeClientTestBase {
     // @SmallTest
     // @Feature({"NativeFileSystem"})
-    @DisabledTest
     public void testNativeFileSystem() throws Throwable {
         RuntimeClientApiTestBase<XWalkRuntimeClientShellActivity> helper =
                 new RuntimeClientApiTestBase<XWalkRuntimeClientShellActivity>(
index 37a2bd0..a40c414 100644 (file)
@@ -16,7 +16,6 @@ import org.xwalk.test.util.RuntimeClientApiTestBase;
 public class NativeFileSystemTest extends XWalkRuntimeClientTestBase {
     // @SmallTest
     // @Feature({"NativeFileSystem"})
-    @DisabledTest
     public void testNativeFileSystem() throws Throwable {
         RuntimeClientApiTestBase<XWalkRuntimeClientEmbeddedShellActivity> helper =
                 new RuntimeClientApiTestBase<XWalkRuntimeClientEmbeddedShellActivity>(
index f8d96b1..b3eb3cb 100755 (executable)
@@ -1,5 +1,9 @@
 #!/usr/bin/env python
 
+# Copyright (c) 2013 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
 ''' This script is used to lint changeset before code checkin
     It get the changeset from the repo and base specified by
     command line arguments. And run cpplint over the changeset.
index 4e671ce..04df3bd 100644 (file)
@@ -1,5 +1,10 @@
 #!/usr/bin/env python
 
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Copyright (c) 2013 Intel Corporation. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
 ''' This script provides utils for python scripts in crosswalk.
 '''