Skip to content

Commit

Permalink
Make screen_enumeration WPT run on Android
Browse files Browse the repository at this point in the history
This fixes the following issues that prevented the screen_enumeration
WPT from passing on Clank and WL (may also apply to other tests):

1) Enable MojoJS when running run_android_wpt.py
  This allows WPT to access mojo interfaces like on Desktop platforms.

2) Implement GetDefaultBrowserContext() on Clank and WL
  This method from content::DevToolsManagerDelegate is called when a WPT
  tries to enable permissions via test_driver.set_permission(). On Clank
  we can use the same implementation than on Desktop via ProfileManager
  but on WL this CL currently just uses the first available Profile via
  ProfileImpl::GetAllProfiles().

Bug: 1180429
Change-Id: I9fb715806661d2be3d532cbd17bf9758d54aec21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2797375
Reviewed-by: Robbie McElrath <rmcelrath@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#869746}
  • Loading branch information
rknoll authored and Chromium LUCI CQ committed Apr 6, 2021
1 parent 4008195 commit 7b9de30
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
6 changes: 6 additions & 0 deletions chrome/browser/android/devtools_manager_delegate_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/grit/browser_resources.h"
Expand Down Expand Up @@ -191,6 +192,11 @@ DevToolsManagerDelegateAndroid::DevToolsManagerDelegateAndroid() = default;

DevToolsManagerDelegateAndroid::~DevToolsManagerDelegateAndroid() = default;

content::BrowserContext*
DevToolsManagerDelegateAndroid::GetDefaultBrowserContext() {
return ProfileManager::GetActiveUserProfile()->GetOriginalProfile();
}

std::string DevToolsManagerDelegateAndroid::GetTargetType(
content::WebContents* web_contents) {
TabAndroid* tab = web_contents ? TabAndroid::FromWebContents(web_contents)
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/android/devtools_manager_delegate_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DevToolsManagerDelegateAndroid : public content::DevToolsManagerDelegate {

private:
// content::DevToolsManagerDelegate implementation.
content::BrowserContext* GetDefaultBrowserContext() override;
std::string GetTargetType(content::WebContents* web_contents) override;
content::DevToolsAgentHost::List RemoteDebuggingTargets() override;
scoped_refptr<content::DevToolsAgentHost> CreateNewTarget(
Expand Down
8 changes: 8 additions & 0 deletions testing/scripts/run_android_wpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, device):
# Arguments from add_extra_argumentsparse were added so
# its safe to parse the arguments and set self._options
self.parse_args()
self.output_directory = os.path.join(SRC_DIR, 'out', self.options.target)
self.mojo_js_directory = os.path.join(self.output_directory, 'gen')

@property
def rest_args(self):
Expand All @@ -136,8 +138,11 @@ def rest_args(self):
"--no-pause-after-test",
"--no-capture-stdio",
"--no-manifest-download",
"--binary-arg=--enable-blink-features=MojoJS,MojoJSTest",
"--binary-arg=--enable-blink-test-features",
"--binary-arg=--disable-field-trial-config",
"--enable-mojojs",
"--mojojs-path=" + self.mojo_js_directory,
])
# if metadata was created then add the metadata directory
# to the list of wpt arguments
Expand Down Expand Up @@ -215,6 +220,9 @@ class WPTPassThroughArgs(PassThroughArgs):

# Add this so that product argument does not go in self._rest_args
# when self.parse_args() is called
parser.add_argument('--target', '-t', default='Release',
help='Specify the target build subdirectory under'
' src/out/.')
parser.add_argument('--product', help=argparse.SUPPRESS)
parser.add_argument('--webdriver-binary', required=True,
help='Path of the webdriver binary. It needs to have'
Expand Down
5 changes: 0 additions & 5 deletions third_party/blink/web_tests/android/ChromiumWPTExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -3890,11 +3890,6 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-screen-type-on-worker.h
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-supported-by-feature-policy.html [ Failure Pass ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.window.html [ Crash Failure ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Crash Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Crash Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/isMultiScreen.tentative.https.window.html [ Crash ]
crbug.com/1050754 external/wpt/screen_enumeration/isMultiScreen.values.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/screen_enumeration_permission.https.window.html [ Crash Failure ]
crbug.com/1050754 external/wpt/scroll-animations/cancel-animation.html [ Failure Pass ]
crbug.com/1050754 external/wpt/scroll-animations/constructor-no-document.html [ Failure Pass ]
crbug.com/1050754 external/wpt/scroll-animations/constructor.html [ Failure Pass ]
Expand Down
5 changes: 0 additions & 5 deletions third_party/blink/web_tests/android/WeblayerWPTExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1910,11 +1910,6 @@ crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-released.https.html [ C
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-request-denied.https.html [ Crash ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelock-type.https.window.html [ Crash ]
crbug.com/1050754 external/wpt/screen-wake-lock/wakelockpermissiondescriptor.https.html [ Crash ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.tentative.https.window.html [ Crash ]
crbug.com/1050754 external/wpt/screen_enumeration/getScreens.values.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/isMultiScreen.tentative.https.window.html [ Crash ]
crbug.com/1050754 external/wpt/screen_enumeration/isMultiScreen.values.https.html [ Failure ]
crbug.com/1050754 external/wpt/screen_enumeration/screen_enumeration_permission.https.window.html [ Failure ]
crbug.com/1050754 external/wpt/scroll-animations/css/at-scroll-timeline-dynamic.tentative.html [ Failure ]
crbug.com/1050754 external/wpt/scroll-animations/css/at-scroll-timeline-start-end.html [ Failure ]
crbug.com/1050754 external/wpt/scroll-animations/current-time-root-scroller.html [ Failure ]
Expand Down
16 changes: 16 additions & 0 deletions weblayer/browser/devtools_manager_delegate_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,28 @@

#include "weblayer/browser/devtools_manager_delegate_android.h"

#include "weblayer/browser/browser_context_impl.h"
#include "weblayer/browser/profile_impl.h"

namespace weblayer {

DevToolsManagerDelegateAndroid::DevToolsManagerDelegateAndroid() = default;

DevToolsManagerDelegateAndroid::~DevToolsManagerDelegateAndroid() = default;

content::BrowserContext*
DevToolsManagerDelegateAndroid::GetDefaultBrowserContext() {
auto profiles = ProfileImpl::GetAllProfiles();
if (profiles.empty())
return nullptr;

// This is called when granting permissions via devtools in browser tests or WPT. We assume that
// there is only a single profile and just pick the first one here. Note that outside of tests
// there might exist multiple profiles for WebLayer and this assumption won't hold.
ProfileImpl* profile = *profiles.begin();
return profile->GetBrowserContext();
}

std::string DevToolsManagerDelegateAndroid::GetDiscoveryPageHTML() {
const char html[] =
"<html>"
Expand Down
1 change: 1 addition & 0 deletions weblayer/browser/devtools_manager_delegate_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class DevToolsManagerDelegateAndroid : public content::DevToolsManagerDelegate {
~DevToolsManagerDelegateAndroid() override;

// content::DevToolsManagerDelegate implementation.
content::BrowserContext* GetDefaultBrowserContext() override;
std::string GetDiscoveryPageHTML() override;
bool IsBrowserTargetDiscoverable() override;

Expand Down

0 comments on commit 7b9de30

Please sign in to comment.