diff --git a/BUILD.gn b/BUILD.gn index 6dbe100..096ef65 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -416,15 +416,6 @@ } } - # NOTE: The following should really be 'is_android', but the fuzzing build - # seems currently broken for this platform at the moment, and the - # corresponding code build and works on Linux unmodified. - # See instructions in the corresponding BUILD.gn. - if (is_linux || is_chromeos) { - deps += - [ "//third_party/android_crazy_linker:android_crazy_linker_zip_fuzzer" ] - } - if (is_linux || is_chromeos) { # This is only used by ChromeOS, but we want maximal fuzzer coverage, so # run it under linux too.
diff --git a/DEPS b/DEPS index 63eae10d..41c7e3e 100644 --- a/DEPS +++ b/DEPS
@@ -272,7 +272,7 @@ 'dawn_standalone': False, # reclient CIPD package version - 'reclient_version': 're_client_version:0.86.0.25feac0-gomaip', + 'reclient_version': 're_client_version:0.87.0.b6908b3-gomaip', # Fetch Rust-related packages. 'use_rust': False, @@ -374,7 +374,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling devtools-frontend # and whatever else without interference from each other. - 'devtools_frontend_revision': '1cf71ef9056c038a8be0f72af432a181ab6ef3f9', + 'devtools_frontend_revision': '8133bad9be36b33c363592e3691ea6da1bb1e79e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libprotobuf-mutator # and whatever else without interference from each other. @@ -446,7 +446,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'cros_components_revision': 'cf9a27ca0df01cd834a0886aa57f797dc9a11004', + 'cros_components_revision': '87ba3d06628a114996d00ca0e70b077d235700fd', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -782,7 +782,7 @@ 'src/clank': { 'url': 'https://chrome-internal.googlesource.com/clank/internal/apps.git' + '@' + - '773541ef7b875aad33ec4ffd613cfa4825d0932b', + '3c00a49877f14713eedc1c67dd463df919764048', 'condition': 'checkout_android and checkout_src_internal', }, @@ -1220,7 +1220,7 @@ Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), 'src/third_party/devtools-frontend-internal': { - 'url': 'https://chrome-internal.googlesource.com/devtools/devtools-internal.git' + '@' + 'b2439e0d3e106a8181c9418712ff799cd08723d6', + 'url': 'https://chrome-internal.googlesource.com/devtools/devtools-internal.git' + '@' + '143261f0cb6616bd8e8e1523d859f30b61f8cb94', 'condition': 'checkout_src_internal', }, @@ -1635,7 +1635,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + 'c194bc190ded8849d9d6be943220c5f8f72cc022', + Var('android_git') + '/platform/external/perfetto.git' + '@' + 'be5960bcdfae8925d83807b3ec5df72c25f98939', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1817,10 +1817,10 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'd1b65aa5a88f6efd900604dfcda840154e9f16e2', 'src/third_party/webgpu-cts/src': - Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '82ec26d039e19c70f6fa979bbff03b82d4b6ff7f', + Var('chromium_git') + '/external/github.com/gpuweb/cts.git' + '@' + '09447faf1a22821f35ca4a3fc9c06e3bf1125756', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '7216b27406d094834d8644a525370069a70d2f93', + Var('webrtc_git') + '/src.git' + '@' + '5c4509a604f7559571699d272a9f3bd85ca385bb', # Wuffs' canonical repository is at github.com/google/wuffs, but we use # Skia's mirror of Wuffs, the same as in upstream Skia's DEPS file. @@ -1890,7 +1890,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@bce42f5b87a7d1e3b9ab2a312bb435b3e696d704', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@f9b0e25a2d3d8beb689ed941a80b19c2e7b11c2f', 'condition': 'checkout_src_internal', },
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index bea3482..791ec56 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -1134,14 +1134,6 @@ (), ), BanRule( - 'RunThisRunLoop', - ( - 'RunThisRunLoop is deprecated, use RunLoop directly instead.', - ), - False, - (), - ), - BanRule( 'RunAllPendingInMessageLoop()', ( "Prefer RunLoop over RunAllPendingInMessageLoop, please contact gab@",
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/services/JsSandboxServiceTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/services/JsSandboxServiceTest.java index 039be11..704a5f50 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/services/JsSandboxServiceTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/services/JsSandboxServiceTest.java
@@ -15,6 +15,7 @@ import androidx.javascriptengine.JavaScriptSandbox; import androidx.javascriptengine.MemoryLimitExceededException; import androidx.javascriptengine.SandboxDeadException; +import androidx.test.filters.LargeTest; import androidx.test.filters.MediumTest; import com.google.common.util.concurrent.ListenableFuture; @@ -577,7 +578,7 @@ } @Test - @MediumTest + @LargeTest public void testHeapSizeEnforced() throws Throwable { final long maxHeapSize = REASONABLE_HEAP_SIZE; // We need to beat the v8 optimizer to ensure it really allocates the required memory. Note @@ -614,7 +615,9 @@ // Check that the heap limit is enforced and that it reports this was the evaluation // that exceeded the limit. try { - oomResultFuture.get(5, TimeUnit.SECONDS); + // Use a generous timeout for OOM, as it may involve multiple rounds of garbage + // collection. + oomResultFuture.get(60, TimeUnit.SECONDS); Assert.fail("Should have thrown."); } catch (ExecutionException e) { if (!(e.getCause() instanceof MemoryLimitExceededException)) { @@ -661,7 +664,7 @@ } @Test - @MediumTest + @LargeTest public void testIsolateCreationAfterCrash() throws Throwable { final long maxHeapSize = REASONABLE_HEAP_SIZE; // We need to beat the v8 optimizer to ensure it really allocates the required memory. Note @@ -689,7 +692,9 @@ // Check that the heap limit is enforced and that it reports this was the evaluation // that exceeded the limit. try { - oomResultFuture.get(5, TimeUnit.SECONDS); + // Use a generous timeout for OOM, as it may involve multiple rounds of garbage + // collection. + oomResultFuture.get(60, TimeUnit.SECONDS); Assert.fail("Should have thrown."); } catch (ExecutionException e) { if (!(e.getCause() instanceof MemoryLimitExceededException)) {
diff --git a/android_webview/js_sandbox/javatests/src/androidx/javascriptengine/WebViewJavaScriptSandboxTest.java b/android_webview/js_sandbox/javatests/src/androidx/javascriptengine/WebViewJavaScriptSandboxTest.java index e74d3df8..b9215a80 100644 --- a/android_webview/js_sandbox/javatests/src/androidx/javascriptengine/WebViewJavaScriptSandboxTest.java +++ b/android_webview/js_sandbox/javatests/src/androidx/javascriptengine/WebViewJavaScriptSandboxTest.java
@@ -8,6 +8,7 @@ import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.filters.LargeTest; import androidx.test.filters.MediumTest; import com.google.common.util.concurrent.ListenableFuture; @@ -553,7 +554,7 @@ } @Test - @MediumTest + @LargeTest public void testHeapSizeEnforced() throws Throwable { final long maxHeapSize = REASONABLE_HEAP_SIZE; // We need to beat the v8 optimizer to ensure it really allocates the required memory. Note @@ -590,7 +591,9 @@ // Check that the heap limit is enforced and that it reports this was the evaluation // that exceeded the limit. try { - oomResultFuture.get(5, TimeUnit.SECONDS); + // Use a generous timeout for OOM, as it may involve multiple rounds of garbage + // collection. + oomResultFuture.get(60, TimeUnit.SECONDS); Assert.fail("Should have thrown."); } catch (ExecutionException e) { if (!(e.getCause() instanceof MemoryLimitExceededException)) { @@ -637,7 +640,7 @@ } @Test - @MediumTest + @LargeTest public void testIsolateCreationAfterCrash() throws Throwable { final long maxHeapSize = REASONABLE_HEAP_SIZE; // We need to beat the v8 optimizer to ensure it really allocates the required memory. Note @@ -665,7 +668,9 @@ // Check that the heap limit is enforced and that it reports this was the evaluation // that exceeded the limit. try { - oomResultFuture.get(5, TimeUnit.SECONDS); + // Use a generous timeout for OOM, as it may involve multiple rounds of garbage + // collection. + oomResultFuture.get(60, TimeUnit.SECONDS); Assert.fail("Should have thrown."); } catch (ExecutionException e) { if (!(e.getCause() instanceof MemoryLimitExceededException)) {
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index fdde973..bcd758354 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -3449,6 +3449,9 @@ "system/accessibility/accessibility_detailed_view_pixeltest.cc", "system/bluetooth/bluetooth_detailed_view_legacy_pixeltest.cc", "system/message_center/ash_notification_view_pixeltest.cc", + "system/time/calendar_unittest_utils.cc", + "system/time/calendar_unittest_utils.h", + "system/time/calendar_up_next_pixeltest.cc", "test/pixel/demo_ash_pixel_diff_test.cc", ]
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index a4585be..4e21486 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd
@@ -4513,10 +4513,10 @@ Turn on camera access to allow apps and webpages with the camera permission to use the camera(s) connected to this device. </message> <message name="IDS_PRIVACY_HUB_TURN_OFF_CAMERA_ACTION_BUTTON" desc="Label for an action button that disables the camera."> - Turn off camera access. + Turn off camera access </message> <message name="IDS_PRIVACY_HUB_TURN_ON_CAMERA_ACTION_BUTTON" desc="Label for an action button that enables the camera."> - Turn on camera access. + Turn on camera access </message> <!-- Strings for microphone mute switch notification -->
diff --git a/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_OFF_CAMERA_ACTION_BUTTON.png.sha1 b/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_OFF_CAMERA_ACTION_BUTTON.png.sha1 index b2f55d7..779f742 100644 --- a/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_OFF_CAMERA_ACTION_BUTTON.png.sha1 +++ b/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_OFF_CAMERA_ACTION_BUTTON.png.sha1
@@ -1 +1 @@ -6cee0333e8cfbb50d113cac4fe6624d51eeaa17f \ No newline at end of file +6a32a22fb50d6ddec414a9a70c4e9455110cc54d \ No newline at end of file
diff --git a/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_ON_CAMERA_ACTION_BUTTON.png.sha1 b/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_ON_CAMERA_ACTION_BUTTON.png.sha1 index a28a3d8e..502bbb7 100644 --- a/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_ON_CAMERA_ACTION_BUTTON.png.sha1 +++ b/ash/ash_strings_grd/IDS_PRIVACY_HUB_TURN_ON_CAMERA_ACTION_BUTTON.png.sha1
@@ -1 +1 @@ -fec376b7f80d5acb18aa84cedc2165e2cdf3afe3 \ No newline at end of file +c2c80e68656904a49c4cfbd41ca4badc741b2ed8 \ No newline at end of file
diff --git a/ash/components/arc/mojom/net.mojom b/ash/components/arc/mojom/net.mojom index 2c32826..e3b85bd 100644 --- a/ash/components/arc/mojom/net.mojom +++ b/ash/components/arc/mojom/net.mojom
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Next MinVersion: 24 +// Next MinVersion: 25 // This file defines the mojo interface between the ARC networking stack and // Chrome OS. There are three different groups of interactions: @@ -655,6 +655,19 @@ int64 duration_ms; }; +// Chrome flags that should be passed into ARC via NetInstance::SetUpFlag(). +[Extensible] +enum Flag { + [Default] UNKNOWN = 0, + + // Chrome Finch flag kEnableArcHostVpn. If true, ARC should start the + // ArcHostVpn service when a builtin VPN client is started. This flag value + // can be toggled at any time, but ARC will only use the latest value when a + // builtin VPN network is detected and sent to ARC as part of an + // ActiveNetworksChanged call. + ENABLE_ARC_HOST_VPN = 1, +}; + // Next Method ID: 18 // IDs 3 and 9 are missing as they belonged to deprecated methods. // Mojo interface exposed by the Chrome browser process for @@ -736,7 +749,7 @@ [MinVersion=18] DisconnectHostVpn@17(); }; -// Next Method ID: 11 +// Next Method ID: 12 // IDs 0 and 2 are missing as they belonged to deprecated method. // Mojo interface exposed by ARC for networking/WiFi/VPN, the Chrome // browser process is the client. @@ -785,4 +798,7 @@ // name |transport_name|. [MinVersion=15] PingTest@10(string transport_name, string ip_address) => (ArcPingTestResult result); + + // Pass a Chrome flag value into ARC. + [MinVersion=22] SetUpFlag@11(Flag flag, bool value); };
diff --git a/ash/components/arc/net/arc_net_host_impl.cc b/ash/components/arc/net/arc_net_host_impl.cc index 780f8c6a..d0e49ad 100644 --- a/ash/components/arc/net/arc_net_host_impl.cc +++ b/ash/components/arc/net/arc_net_host_impl.cc
@@ -9,6 +9,7 @@ #include <utility> #include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h" +#include "ash/components/arc/arc_features.h" #include "ash/components/arc/arc_prefs.h" #include "ash/components/arc/net/cert_manager.h" #include "ash/components/arc/session/arc_bridge_service.h" @@ -621,6 +622,18 @@ // Listen on network configuration changes. ash::PatchPanelClient::Get()->AddObserver(this); + + SetUpFlags(); +} + +void ArcNetHostImpl::SetUpFlags() { + auto* net_instance = + ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service_->net(), SetUpFlag); + if (!net_instance) + return; + + net_instance->SetUpFlag(arc::mojom::Flag::ENABLE_ARC_HOST_VPN, + base::FeatureList::IsEnabled(arc::kEnableArcHostVpn)); } void ArcNetHostImpl::OnConnectionClosed() {
diff --git a/ash/components/arc/net/arc_net_host_impl.h b/ash/components/arc/net/arc_net_host_impl.h index 52fefb5..40f6f25 100644 --- a/ash/components/arc/net/arc_net_host_impl.h +++ b/ash/components/arc/net/arc_net_host_impl.h
@@ -192,6 +192,9 @@ // the properties values translated taken from mojo. void AddPasspointCredentialsWithProperties(base::Value properties); + // Pass any Chrome flags into ARC. + void SetUpFlags(); + void CreateNetworkSuccessCallback( base::OnceCallback<void(const std::string&)> callback, const std::string& service_path,
diff --git a/ash/components/arc/session/arc_vm_client_adapter.cc b/ash/components/arc/session/arc_vm_client_adapter.cc index 150c093..49618af 100644 --- a/ash/components/arc/session/arc_vm_client_adapter.cc +++ b/ash/components/arc/session/arc_vm_client_adapter.cc
@@ -86,10 +86,6 @@ constexpr const char kArcVmBootNotificationServerSocketPath[] = "/run/arcvm_boot_notification_server/host.socket"; -constexpr int kLogdConfigSizeSmall = 256; // kBytes -constexpr int kLogdConfigSizeMed = 512; // kBytes -constexpr int kLogdConfigSizeLarge = 1024; // kBytes - constexpr int64_t kInvalidCid = -1; constexpr base::TimeDelta kConnectTimeoutLimit = base::Seconds(20); @@ -171,161 +167,6 @@ return result; } -std::vector<std::string> GenerateKernelCmdline(const StartParams& start_params, - bool is_host_on_vm) { - std::string native_bridge; - switch (IdentifyBinaryTranslationType(start_params)) { - case ArcBinaryTranslationType::NONE: - native_bridge = "0"; - break; - case ArcBinaryTranslationType::HOUDINI: - native_bridge = "libhoudini.so"; - break; - case ArcBinaryTranslationType::NDK_TRANSLATION: - native_bridge = "libndk_translation.so"; - break; - } - - const int guest_zram_size = kGuestZramSize.Get(); - VLOG(1) << "Setting ARCVM guest's zram size to " << guest_zram_size; - - std::vector<std::string> result = { - base::StringPrintf("androidboot.native_bridge=%s", native_bridge.c_str()), - base::StringPrintf("androidboot.host_is_in_vm=%d", is_host_on_vm), - base::StringPrintf("androidboot.lcd_density=%d", - start_params.lcd_density), - base::StringPrintf("androidboot.arc_file_picker=%d", - start_params.arc_file_picker_experiment), - base::StringPrintf("androidboot.arc_custom_tabs=%d", - start_params.arc_custom_tabs_experiment), - base::StringPrintf( - "androidboot.keyboard_shortcut_helper_integration=%d", - start_params.enable_keyboard_shortcut_helper_integration), - base::StringPrintf("androidboot.enable_notifications_refresh=%d", - start_params.enable_notifications_refresh), - base::StringPrintf("androidboot.zram_size=%d", guest_zram_size), - }; - - const ArcVmUreadaheadMode mode = GetArcVmUreadaheadMode(); - switch (mode) { - case ArcVmUreadaheadMode::READAHEAD: - result.push_back("androidboot.arcvm_ureadahead_mode=readahead"); - break; - case ArcVmUreadaheadMode::GENERATE: - result.push_back("androidboot.arcvm_ureadahead_mode=generate"); - break; - case ArcVmUreadaheadMode::DISABLED: - break; - } - - // Only add boot property if flag to disable media store maintenance is set. - if (start_params.disable_media_store_maintenance) - result.push_back("androidboot.disable_media_store_maintenance=1"); - - if (start_params.arc_generate_play_auto_install) - result.push_back("androidboot.arc_generate_pai=1"); - - if (start_params.use_virtio_blk_data) - result.push_back("androidboot.arcvm_virtio_blk_data=1"); - else - result.push_back("androidboot.arcvm_virtio_blk_data=0"); - - // Conditionally sets some properties based on |start_params|. - switch (start_params.play_store_auto_update) { - case StartParams::PlayStoreAutoUpdate::AUTO_UPDATE_DEFAULT: - break; - case StartParams::PlayStoreAutoUpdate::AUTO_UPDATE_ON: - result.push_back("androidboot.play_store_auto_update=1"); - break; - case StartParams::PlayStoreAutoUpdate::AUTO_UPDATE_OFF: - result.push_back("androidboot.play_store_auto_update=0"); - break; - } - - // Set logcat size, only if configured to one of the few supported sizes. - if (base::FeatureList::IsEnabled(kLogdConfig)) { - auto logd_config_size = kLogdConfigSize.Get(); - switch (logd_config_size) { - case kLogdConfigSizeSmall: - result.push_back("androidboot.arcvm.logd.size=256K"); - break; - case kLogdConfigSizeMed: - result.push_back("androidboot.arcvm.logd.size=512K"); - break; - case kLogdConfigSizeLarge: - result.push_back("androidboot.arcvm.logd.size=1M"); - break; - default: - VLOG(1) << "WARNING: Invalid logd size ignored: [" << logd_config_size - << "]"; - break; - } - } - - if (base::FeatureList::IsEnabled(kVmMemoryPSIReports)) { - auto period = kVmMemoryPSIReportsPeriod.Get(); - // Since Android performs parameter validation, not doing it here. - result.push_back(base::StringPrintf( - "androidboot.arcvm_metrics_mem_psi_period=%d", period)); - } - - if (base::FeatureList::IsEnabled(arc::kUseDalvikMemoryProfile)) { - switch (start_params.dalvik_memory_profile) { - case StartParams::DalvikMemoryProfile::DEFAULT: - case StartParams::DalvikMemoryProfile::M4G: - // Use the 4G profile for devices with 4GB RAM or less. - result.push_back("androidboot.arc_dalvik_memory_profile=4G"); - break; - case StartParams::DalvikMemoryProfile::M8G: - result.push_back("androidboot.arc_dalvik_memory_profile=8G"); - break; - case StartParams::DalvikMemoryProfile::M16G: - result.push_back("androidboot.arc_dalvik_memory_profile=16G"); - break; - } - } else { - VLOG(1) << "Dalvik memory profile is not enabled, the default setting is " - << "used."; - } - - std::string log_profile_name; - switch (start_params.usap_profile) { - case StartParams::UsapProfile::DEFAULT: - log_profile_name = "default low-memory"; - break; - case StartParams::UsapProfile::M4G: - result.push_back("androidboot.usap_profile=4G"); - log_profile_name = "high-memory 4G"; - break; - case StartParams::UsapProfile::M8G: - result.push_back("androidboot.usap_profile=8G"); - log_profile_name = "high-memory 8G"; - break; - case StartParams::UsapProfile::M16G: - result.push_back("androidboot.usap_profile=16G"); - log_profile_name = "high-memory 16G"; - break; - } - VLOG(1) << "Applied " << log_profile_name << " USAP profile"; - - if (start_params.disable_download_provider) - result.push_back("androidboot.disable_download_provider=1"); - - if (base::FeatureList::IsEnabled(arc::kVmGmsCoreLowMemoryKillerProtection)) - result.push_back("androidboot.arc_enable_gmscore_lmk_protection=1"); - - if (start_params.enable_tts_caching) - result.push_back("androidboot.arc.tts.caching=1"); - - if (base::FeatureList::IsEnabled(arc::kVmBroadcastPreNotifyANR)) - result.push_back("androidboot.arc.broadcast_anr_prenotify=1"); - - if (base::FeatureList::IsEnabled(arc::kEnableLazyWebViewInit)) - result.push_back("androidboot.arc.web_view_zygote.lazy_init=1"); - - return result; -} - void AppendParamsFromStartParams( vm_tools::concierge::StartArcVmRequest& request, const StartParams& start_params) { @@ -395,14 +236,6 @@ request.set_owner_id(user_id_hash); request.set_use_per_vm_core_scheduling(use_per_vm_core_scheduling); - if (file_system_status.is_host_rootfs_writable() && - file_system_status.is_system_image_ext_format()) { - request.add_params("rw"); - } - - for (auto& entry : GenerateKernelCmdline(start_params, is_host_on_vm)) - request.add_params(std::move(entry)); - const bool should_set_blocksize = !base::FeatureList::IsEnabled(arc::kUseDefaultBlockSize); constexpr uint32_t kBlockSize = 4096;
diff --git a/ash/components/arc/session/arc_vm_client_adapter_unittest.cc b/ash/components/arc/session/arc_vm_client_adapter_unittest.cc index 755e720..42c41ed 100644 --- a/ash/components/arc/session/arc_vm_client_adapter_unittest.cc +++ b/ash/components/arc/session/arc_vm_client_adapter_unittest.cc
@@ -120,20 +120,6 @@ base::GUID::GenerateRandomV4().AsLowercaseString()); } -// Determines whether the list of parameters in the given request contains -// at least one parameter that starts with the prefix provided -bool HasParameterWithPrefix( - const vm_tools::concierge::StartArcVmRequest& request, - const base::StringPiece& prefix) { - const auto& results = request.params(); - bool prefix_found = false; - for (auto i = results.begin(); i != results.end() && !prefix_found; ++i) { - if (base::StartsWith(*i, prefix)) - prefix_found = true; - } - return prefix_found; -} - bool HasDiskImage(const vm_tools::concierge::StartArcVmRequest& request, const std::string& disk_path) { for (const auto& disk : request.disks()) { @@ -1335,9 +1321,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.disable_media_store_maintenance=1")); - EXPECT_TRUE( request.mini_instance_request().disable_media_store_maintenance()); } @@ -1350,8 +1333,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(base::Contains(request.params(), - "androidboot.arcvm_ureadahead_mode=generate")); EXPECT_EQ(request.ureadahead_mode(), vm_tools::concierge::StartArcVmRequest::UREADAHEAD_MODE_READAHEAD); } @@ -1361,8 +1342,6 @@ start_params.arc_generate_play_auto_install = true; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(request.params(), "androidboot.arc_generate_pai=1")); EXPECT_TRUE(request.mini_instance_request().arc_generate_pai()); } @@ -1370,10 +1349,6 @@ StartMiniArcWithParams(true, GetPopulatedStartParams()); // No androidboot property should be generated. const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE( - base::Contains(request.params(), "androidboot.arc_generate_pai=1")); - EXPECT_FALSE( - base::Contains(request.params(), "androidboot.arc_generate_pai=0")); EXPECT_FALSE(request.mini_instance_request().arc_generate_pai()); } @@ -1388,7 +1363,6 @@ EXPECT_LT(0u, params.cpus()); // Make sure vendor.raw.img is passed. EXPECT_LE(1, params.disks_size()); - EXPECT_LT(0, params.params_size()); } // Tests that crosvm crash is handled properly. @@ -1514,7 +1488,6 @@ // Check "rw" is not in |params|. const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(base::Contains(request.params(), "rw")); EXPECT_FALSE(request.enable_rw()); } @@ -1528,7 +1501,6 @@ // Check "rw" is in |params|. const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), "rw")); EXPECT_TRUE(request.enable_rw()); } @@ -1570,8 +1542,6 @@ // StartArcVmRequest should NOT contain a disk created by CreateDiskImage(). const auto& req = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_FALSE(HasDiskImage(req, kCreatedDiskImagePath)); - EXPECT_TRUE( - base::Contains(req.params(), "androidboot.arcvm_virtio_blk_data=0")); EXPECT_FALSE(req.enable_virtio_blk_data()); } @@ -1616,8 +1586,6 @@ // StartArcVmRequest should contain a disk path created by CreateDiskImage(). const auto& req = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_TRUE(HasDiskImage(req, kCreatedDiskImagePath)); - EXPECT_TRUE( - base::Contains(req.params(), "androidboot.arcvm_virtio_blk_data=1")); EXPECT_TRUE(req.enable_virtio_blk_data()); } @@ -1635,8 +1603,6 @@ // StartArcVmRequest should contain a disk path created by CreateDiskImage(). const auto& req = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_TRUE(HasDiskImage(req, kCreatedDiskImagePath)); - EXPECT_TRUE( - base::Contains(req.params(), "androidboot.arcvm_virtio_blk_data=1")); EXPECT_TRUE(req.enable_virtio_blk_data()); } @@ -1658,8 +1624,6 @@ std::string(kUserIdHash).substr(0, 8).c_str()); const auto& req = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_TRUE(HasDiskImage(req, expected_lvm_disk_path)); - EXPECT_TRUE( - base::Contains(req.params(), "androidboot.arcvm_virtio_blk_data=1")); } TEST_F(ArcVmClientAdapterTest, VirtioBlkForData_OverrideUseLvm) { @@ -1685,42 +1649,15 @@ std::string(kUserIdHash).substr(0, 8).c_str()); const auto& req = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_TRUE(HasDiskImage(req, expected_lvm_disk_path)); - EXPECT_TRUE( - base::Contains(req.params(), "androidboot.arcvm_virtio_blk_data=1")); EXPECT_TRUE(req.enable_virtio_blk_data()); } -TEST_F(ArcVmClientAdapterTest, VshdForRelease) { - base::test::ScopedChromeOSVersionInfo info( - "CHROMEOS_RELEASE_TRACK=stable-channel", base::Time::Now()); - - StartParams start_params(GetPopulatedStartParams()); - StartMiniArcWithParams(true, std::move(start_params)); - UpgradeArc(true); - EXPECT_FALSE( - base::Contains(GetTestConciergeClient()->start_arc_vm_request().params(), - "androidboot.vshd_service_override=vshd_for_test")); -} - -TEST_F(ArcVmClientAdapterTest, VshdForUnknownChannel) { - base::test::ScopedChromeOSVersionInfo info("CHROMEOS_RELEASE_TRACK=unknown", - base::Time::Now()); - - StartParams start_params(GetPopulatedStartParams()); - StartMiniArcWithParams(true, std::move(start_params)); - UpgradeArc(true); - EXPECT_FALSE( - base::Contains(GetTestConciergeClient()->start_arc_vm_request().params(), - "androidboot.vshd_service_override=vshd_for_test")); -} - // Tests that the binary translation type is set to None when no library is // enabled by USE flags. TEST_F(ArcVmClientAdapterTest, BintaryTranslationTypeNone) { StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), "androidboot.native_bridge=0")); EXPECT_EQ( request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest::BINARY_TRANSLATION_TYPE_NONE); @@ -1734,8 +1671,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.native_bridge=libhoudini.so")); EXPECT_EQ( request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest::BINARY_TRANSLATION_TYPE_HOUDINI); @@ -1749,8 +1684,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.native_bridge=libhoudini.so")); EXPECT_EQ( request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest::BINARY_TRANSLATION_TYPE_HOUDINI); @@ -1764,8 +1697,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains( - request.params(), "androidboot.native_bridge=libndk_translation.so")); EXPECT_EQ(request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest:: BINARY_TRANSLATION_TYPE_NDK_TRANSLATION); @@ -1779,8 +1710,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains( - request.params(), "androidboot.native_bridge=libndk_translation.so")); EXPECT_EQ(request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest:: BINARY_TRANSLATION_TYPE_NDK_TRANSLATION); @@ -1796,8 +1725,6 @@ start_params.native_bridge_experiment = true; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains( - request.params(), "androidboot.native_bridge=libndk_translation.so")); EXPECT_EQ(request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest:: BINARY_TRANSLATION_TYPE_NDK_TRANSLATION); @@ -1813,8 +1740,6 @@ start_params.native_bridge_experiment = false; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.native_bridge=libhoudini.so")); EXPECT_EQ( request.native_bridge_experiment(), vm_tools::concierge::StartArcVmRequest::BINARY_TRANSLATION_TYPE_HOUDINI); @@ -1827,10 +1752,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(base::Contains(request.params(), - "androidboot.arcvm_ureadahead_mode=readahead")); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.arcvm_ureadahead_mode=generate")); EXPECT_EQ(request.ureadahead_mode(), vm_tools::concierge::StartArcVmRequest::UREADAHEAD_MODE_GENERATE); } @@ -1842,10 +1763,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(base::Contains(request.params(), - "androidboot.arcvm_ureadahead_mode=readahead")); - EXPECT_FALSE(base::Contains(request.params(), - "androidboot.arcvm_ureadahead_mode=generate")); EXPECT_EQ(request.ureadahead_mode(), vm_tools::concierge::StartArcVmRequest::UREADAHEAD_MODE_DISABLED); } @@ -1913,8 +1830,6 @@ StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); // Not expected arc_disable_download_provider in properties. - for (const auto& param : request.params()) - EXPECT_EQ(std::string::npos, param.find("disable_download_provider")); EXPECT_FALSE(request.mini_instance_request().disable_download_provider()); } @@ -1923,9 +1838,6 @@ start_params.disable_download_provider = true; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(GetTestConciergeClient()->start_arc_vm_request().params(), - "androidboot.disable_download_provider=1")); EXPECT_TRUE(request.mini_instance_request().disable_download_provider()); } @@ -1935,10 +1847,6 @@ false); StartMiniArc(); const auto& req = GetTestConciergeClient()->start_arc_vm_request(); - for (const auto& param : req.params()) { - EXPECT_EQ(std::string::npos, - param.find("arc_enable_gmscore_lmk_protection")); - } EXPECT_FALSE(req.enable_gmscore_lmk_protection()); } @@ -1948,24 +1856,18 @@ true); StartMiniArc(); const auto& req = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains( - req.params(), "androidboot.arc_enable_gmscore_lmk_protection=1")); EXPECT_TRUE(req.enable_gmscore_lmk_protection()); } TEST_F(ArcVmClientAdapterTest, GmsCoreLowMemoryKillerProtection_Default) { StartMiniArc(); const auto& req = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains( - req.params(), "androidboot.arc_enable_gmscore_lmk_protection=1")); EXPECT_TRUE(req.enable_gmscore_lmk_protection()); } TEST_F(ArcVmClientAdapterTest, BroadcastPreANRDefault) { StartMiniArc(); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - for (const auto& param : request.params()) - EXPECT_EQ(std::string::npos, param.find("arc.broadcast_anr_prenotify")); EXPECT_FALSE(request.enable_broadcast_anr_prenotify()); } @@ -1975,9 +1877,6 @@ StartMiniArc(); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(GetTestConciergeClient()->start_arc_vm_request().params(), - "androidboot.arc.broadcast_anr_prenotify=1")); EXPECT_TRUE(request.enable_broadcast_anr_prenotify()); } @@ -2451,7 +2350,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(HasParameterWithPrefix(request, "androidboot.arcvm.logd.size=")); EXPECT_EQ(request.logd_config_size(), -1); } @@ -2467,7 +2365,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(HasParameterWithPrefix(request, "androidboot.arcvm.logd.size=")); EXPECT_EQ(request.logd_config_size(), 333); } @@ -2483,8 +2380,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(request.params(), "androidboot.arcvm.logd.size=256K")); EXPECT_EQ(request.logd_config_size(), 256); } @@ -2500,8 +2395,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(request.params(), "androidboot.arcvm.logd.size=512K")); EXPECT_EQ(request.logd_config_size(), 512); } @@ -2517,8 +2410,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(request.params(), "androidboot.arcvm.logd.size=1M")); EXPECT_EQ(request.logd_config_size(), 1024); } @@ -2561,8 +2452,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(HasParameterWithPrefix( - request, "androidboot.arcvm_metrics_mem_psi_period=")); EXPECT_EQ(request.vm_memory_psi_period(), -1); } @@ -2578,8 +2467,6 @@ EXPECT_GE(GetTestConciergeClient()->start_arc_vm_call_count(), 1); EXPECT_FALSE(is_system_shutdown().has_value()); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.arcvm_metrics_mem_psi_period=300")); EXPECT_EQ(request.vm_memory_psi_period(), 300); } @@ -2619,16 +2506,6 @@ start_params.dalvik_memory_profile = test_param.profile; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - if (test_param.profile_name) { - EXPECT_TRUE( - base::Contains(request.params(), - std::string("androidboot.arc_dalvik_memory_profile=") + - test_param.profile_name)); - } else { - // Not expected any arc_dalvik_memory_profile. - for (const auto& param : request.params()) - EXPECT_EQ(std::string::npos, param.find("arc_dalvik_memory_profile")); - } EXPECT_EQ(request.mini_instance_request().dalvik_memory_profile(), test_param.arc_profile); } @@ -2665,15 +2542,6 @@ start_params.usap_profile = test_param.profile; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - if (test_param.profile_name) { - EXPECT_TRUE(base::Contains( - request.params(), - std::string("androidboot.usap_profile=") + test_param.profile_name)); - } else { - // Not expected any arc_dalvik_memory_profile. - for (const auto& param : request.params()) - EXPECT_EQ(std::string::npos, param.find("usap_profile")); - } EXPECT_EQ(request.usap_profile(), test_param.memory); } @@ -2681,7 +2549,6 @@ StartParams start_params(GetPopulatedStartParams()); StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_FALSE(HasParameterWithPrefix(request, "androidboot.arc.tts.caching=")); EXPECT_FALSE(request.mini_instance_request().enable_tts_caching()); } @@ -2690,8 +2557,6 @@ start_params.enable_tts_caching = true; StartMiniArcWithParams(true, std::move(start_params)); const auto& request = GetTestConciergeClient()->start_arc_vm_request(); - EXPECT_TRUE( - base::Contains(request.params(), "androidboot.arc.tts.caching=1")); EXPECT_TRUE(request.mini_instance_request().enable_tts_caching()); } @@ -2801,8 +2666,6 @@ const auto& request = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_TRUE(request.enable_web_view_zygote_lazy_init()); - EXPECT_TRUE(base::Contains(request.params(), - "androidboot.arc.web_view_zygote.lazy_init=1")); } TEST_F(ArcVmClientAdapterTest, LazyWebViewInitDisabled) { @@ -2814,8 +2677,6 @@ const auto& request = GetTestConciergeClient()->start_arc_vm_request(); EXPECT_FALSE(request.enable_web_view_zygote_lazy_init()); - EXPECT_FALSE(HasParameterWithPrefix( - request, "androidboot.arc.web_view_zygote.lazy_init=")); } TEST_F(ArcVmClientAdapterTest, ArcKeyboardShortcutHelperIntegrationEnabled) {
diff --git a/ash/components/arc/test/fake_net_instance.cc b/ash/components/arc/test/fake_net_instance.cc index fc023fb..9b98586 100644 --- a/ash/components/arc/test/fake_net_instance.cc +++ b/ash/components/arc/test/fake_net_instance.cc
@@ -54,4 +54,6 @@ std::move(callback).Run(std::move(result_ptr)); } +void FakeNetInstance::SetUpFlag(mojom::Flag flag, bool value) {} + } // namespace arc
diff --git a/ash/components/arc/test/fake_net_instance.h b/ash/components/arc/test/fake_net_instance.h index 0d34626e..5c1c12b 100644 --- a/ash/components/arc/test/fake_net_instance.h +++ b/ash/components/arc/test/fake_net_instance.h
@@ -43,6 +43,8 @@ const std::string& ip_address, PingTestCallback callback) override; + void SetUpFlag(mojom::Flag flag, bool value) override; + void set_http_test_result(mojom::ArcHttpTestResult http_test_result) { http_test_result_ = http_test_result; }
diff --git a/ash/system/time/calendar_model.h b/ash/system/time/calendar_model.h index f661d0d..d7fe8bc 100644 --- a/ash/system/time/calendar_model.h +++ b/ash/system/time/calendar_model.h
@@ -145,6 +145,7 @@ friend class CalendarViewEventListViewTest; friend class CalendarViewTest; friend class CalendarViewWithJellyEnabledTest; + friend class CalendarUpNextViewPixelTest; friend class CalendarUpNextViewTest; friend class GlanceablesTest;
diff --git a/ash/system/time/calendar_unittest_utils.cc b/ash/system/time/calendar_unittest_utils.cc index cf761fc1..0a07dac 100644 --- a/ash/system/time/calendar_unittest_utils.cc +++ b/ash/system/time/calendar_unittest_utils.cc
@@ -73,6 +73,17 @@ return event; } +std::unique_ptr<google_apis::calendar::EventList> CreateMockEventList( + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events) { + auto event_list = std::make_unique<google_apis::calendar::EventList>(); + event_list->set_time_zone("Greenwich Mean Time"); + + for (auto& event : events) + event_list->InjectItemForTesting(std::move(event)); + + return event_list; +} + ASH_EXPORT bool IsTheSameMonth(const base::Time& date_a, const base::Time& date_b) { return base::TimeFormatWithPattern(date_a, "MM YYYY") ==
diff --git a/ash/system/time/calendar_unittest_utils.h b/ash/system/time/calendar_unittest_utils.h index 95d2b91..4fc1e827 100644 --- a/ash/system/time/calendar_unittest_utils.h +++ b/ash/system/time/calendar_unittest_utils.h
@@ -5,6 +5,8 @@ #ifndef ASH_SYSTEM_TIME_CALENDAR_UNITTEST_UTILS_H_ #define ASH_SYSTEM_TIME_CALENDAR_UNITTEST_UTILS_H_ +#include <list> +#include <memory> #include <set> #include <string> @@ -252,6 +254,9 @@ google_apis::calendar::CalendarEvent::ResponseStatus::kAccepted, const bool all_day_event = false); +std::unique_ptr<google_apis::calendar::EventList> CreateMockEventList( + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events); + // Checks if the two exploded are in the same month. bool IsTheSameMonth(const base::Time& date_a, const base::Time& date_b);
diff --git a/ash/system/time/calendar_up_next_pixeltest.cc b/ash/system/time/calendar_up_next_pixeltest.cc new file mode 100644 index 0000000..77ff157 --- /dev/null +++ b/ash/system/time/calendar_up_next_pixeltest.cc
@@ -0,0 +1,128 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/shell.h" +#include "ash/system/model/system_tray_model.h" +#include "ash/system/time/calendar_unittest_utils.h" +#include "ash/system/time/calendar_up_next_view.h" +#include "ash/system/time/calendar_utils.h" +#include "ash/system/time/calendar_view_controller.h" +#include "ash/system/tray/tray_constants.h" +#include "ash/test/ash_test_base.h" +#include "ash/test/pixel/ash_pixel_differ.h" +#include "ash/test/pixel/ash_pixel_test_init_params.h" +#include "base/time/time.h" +#include "google_apis/calendar/calendar_api_response_types.h" + +namespace ash { +namespace { + +std::unique_ptr<google_apis::calendar::CalendarEvent> CreateEvent( + const base::Time start_time, + const base::Time end_time, + bool all_day_event = false) { + return calendar_test_utils::CreateEvent( + "id_0", "Event with long name that should ellipsis", start_time, end_time, + google_apis::calendar::CalendarEvent::EventStatus::kConfirmed, + google_apis::calendar::CalendarEvent::ResponseStatus::kAccepted, + all_day_event); +} + +} // namespace + +class CalendarUpNextViewPixelTest : public AshTestBase { + public: + CalendarUpNextViewPixelTest() = default; + + // AshTestBase: + void SetUp() override { + AshTestBase::SetUp(); + + controller_ = std::make_unique<CalendarViewController>(); + widget_ = CreateFramelessTestWidget(); + } + + void TearDown() override { + widget_.reset(); + controller_.reset(); + + AshTestBase::TearDown(); + } + + // AshTestBase: + absl::optional<pixel_test::InitParams> CreatePixelTestInitParams() + const override { + return pixel_test::InitParams(); + } + + void CreateCalendarUpNextView( + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events) { + // Mock events fetch + Shell::Get()->system_tray_model()->calendar_model()->OnEventsFetched( + calendar_utils::GetStartOfMonthUTC( + base::subtle::TimeNowIgnoringOverride().LocalMidnight()), + google_apis::ApiErrorCode::HTTP_SUCCESS, + calendar_test_utils::CreateMockEventList(std::move(events)).get()); + + up_next_view_ = widget_->SetContentsView( + std::make_unique<CalendarUpNextView>(controller_.get())); + widget_->SetSize( + gfx::Size(kTrayMenuWidth, up_next_view_->GetPreferredSize().height())); + } + + views::Widget* Widget() { return widget_.get(); } + + private: + std::unique_ptr<views::Widget> widget_; + CalendarUpNextView* up_next_view_ = nullptr; + std::unique_ptr<CalendarViewController> controller_; +}; + +TEST_F( + CalendarUpNextViewPixelTest, + GivenASingleUpcomingEvent_WhenUpNextViewIsCreated_ThenShouldDisplaySingleUpcomingEvent) { + // Set time override. + base::subtle::ScopedTimeClockOverrides time_override( + []() { return base::subtle::TimeNowIgnoringOverride().LocalMidnight(); }, + nullptr, nullptr); + + // Add single event starting in 10 mins. + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events; + auto start_time = base::subtle::TimeNowIgnoringOverride().LocalMidnight() + + base::Minutes(10); + auto end_time = + base::subtle::TimeNowIgnoringOverride().LocalMidnight() + base::Hours(1); + events.push_back(CreateEvent(start_time, end_time)); + + CreateCalendarUpNextView(std::move(events)); + + EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( + "calendar_up_next_single_upcoming_event.rev_0", Widget())); +} + +TEST_F( + CalendarUpNextViewPixelTest, + GivenThreeUpcomingEvents_WhenUpNextViewIsCreated_ThenShouldDisplayMultipleEventsInScrollView) { + // Set time override. + base::subtle::ScopedTimeClockOverrides time_override( + []() { return base::subtle::TimeNowIgnoringOverride().LocalMidnight(); }, + nullptr, nullptr); + + // Add 3 events starting in 10 mins. + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events; + auto start_time = base::subtle::TimeNowIgnoringOverride().LocalMidnight() + + base::Minutes(10); + auto end_time = + base::subtle::TimeNowIgnoringOverride().LocalMidnight() + base::Hours(1); + events.push_back(CreateEvent(start_time, end_time)); + events.push_back(CreateEvent(start_time, end_time)); + events.push_back(CreateEvent(start_time, end_time)); + + CreateCalendarUpNextView(std::move(events)); + + EXPECT_TRUE(GetPixelDiffer()->CompareUiComponentsOnPrimaryScreen( + "calendar_up_next_multiple_upcoming_events.rev_0", Widget())); +} + +} // namespace ash
diff --git a/ash/system/time/calendar_up_next_view_unittest.cc b/ash/system/time/calendar_up_next_view_unittest.cc index 9fd77f12..acfa67c 100644 --- a/ash/system/time/calendar_up_next_view_unittest.cc +++ b/ash/system/time/calendar_up_next_view_unittest.cc
@@ -28,17 +28,6 @@ all_day_event); } -std::unique_ptr<google_apis::calendar::EventList> CreateMockEventList( - std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>>& events) { - auto event_list = std::make_unique<google_apis::calendar::EventList>(); - event_list->set_time_zone("Greenwich Mean Time"); - - for (auto& event : events) - event_list->InjectItemForTesting(std::move(event)); - - return event_list; -} - } // namespace class CalendarUpNextViewTest : public AshTestBase { @@ -61,13 +50,12 @@ void CreateUpNextView( base::Time date, - std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>>& - events) { + std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events) { up_next_view_.reset(); Shell::Get()->system_tray_model()->calendar_model()->OnEventsFetched( calendar_utils::GetStartOfMonthUTC(date), google_apis::ApiErrorCode::HTTP_SUCCESS, - CreateMockEventList(events).get()); + calendar_test_utils::CreateMockEventList(std::move(events)).get()); up_next_view_ = std::make_unique<CalendarUpNextView>(controller_.get()); } @@ -115,12 +103,12 @@ const char* event_in_progress_end_time_string = "22 Nov 2021 09:30 GMT"; std::list<std::unique_ptr<google_apis::calendar::CalendarEvent>> events; - events.emplace_back(CreateEvent(event_in_ten_mins_start_time_string, - event_in_ten_mins_end_time_string)); - events.emplace_back(CreateEvent(event_in_progress_start_time_string, - event_in_progress_end_time_string)); + events.push_back(CreateEvent(event_in_ten_mins_start_time_string, + event_in_ten_mins_end_time_string)); + events.push_back(CreateEvent(event_in_progress_start_time_string, + event_in_progress_end_time_string)); - CreateUpNextView(date, events); + CreateUpNextView(date, std::move(events)); EXPECT_EQ(GetHeaderLabel()->GetText(), u"Up next"); EXPECT_EQ(GetContentsView()->children().size(), size_t(2));
diff --git a/base/android/linker/BUILD.gn b/base/android/linker/BUILD.gn index 1aedad5..42d9a7a 100644 --- a/base/android/linker/BUILD.gn +++ b/base/android/linker/BUILD.gn
@@ -9,8 +9,6 @@ shared_library("chromium_android_linker") { sources = [ - "legacy_linker_jni.cc", - "legacy_linker_jni.h", "linker_jni.cc", "linker_jni.h", "linker_jni_onload.cc", @@ -21,10 +19,7 @@ # The NDK contains the crazy_linker here: # '<(android_ndk_root)/crazy_linker.gyp:crazy_linker' # However, we use our own fork. See bug 384700. - deps = [ - "//build:buildflag_header_h", - "//third_party/android_crazy_linker", - ] + deps = [ "//build:buildflag_header_h" ] # Export JNI symbols. configs -= [ "//build/config/android:hide_all_but_jni_onload" ] @@ -51,5 +46,8 @@ # format is always supported). It would be nice to also remove the GNU version # tables, for the same reason, but a linker flag to disable them doesn't seem # to exist. This saves 52 bytes on ARM. - ldflags = [ "-Wl,--hash-style=sysv" ] + ldflags = [ + "-Wl,--hash-style=sysv", + "-llog", + ] }
diff --git a/base/android/linker/legacy_linker_jni.cc b/base/android/linker/legacy_linker_jni.cc deleted file mode 100644 index 5c52513..0000000 --- a/base/android/linker/legacy_linker_jni.cc +++ /dev/null
@@ -1,226 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This is a part of the Android-specific Chromium dynamic linker. -// -// See linker_jni.h for more details and the dependency rules. - -#include "base/android/linker/legacy_linker_jni.h" - -#include <crazy_linker.h> -#include <fcntl.h> -#include <jni.h> -#include <limits.h> -#include <stddef.h> -#include <stdlib.h> -#include <unistd.h> - -#include "base/android/linker/linker_jni.h" - -namespace chromium_android_linker { -namespace { - -// The linker uses a single crazy_context_t object created on demand. -// There is no need to protect this against concurrent access, locking -// is already handled on the Java side. -crazy_context_t* GetCrazyContext() { - static crazy_context_t* s_crazy_context = nullptr; - - if (!s_crazy_context) { - // Create new context. - s_crazy_context = crazy_context_create(); - - // Ensure libraries located in the same directory as the linker - // can be loaded before system ones. - crazy_add_search_path_for_address( - reinterpret_cast<void*>(&GetCrazyContext)); - } - - return s_crazy_context; -} - -// A scoped crazy_library_t that automatically closes the handle -// on scope exit, unless Release() has been called. -class ScopedLibrary { - public: - ScopedLibrary() : lib_(nullptr) {} - - ~ScopedLibrary() { - if (lib_) - crazy_library_close_with_context(lib_, GetCrazyContext()); - } - - crazy_library_t* Get() { return lib_; } - - crazy_library_t** GetPtr() { return &lib_; } - - crazy_library_t* Release() { - crazy_library_t* ret = lib_; - lib_ = nullptr; - return ret; - } - - private: - crazy_library_t* lib_; -}; - -// Add a zip archive file path to the context's current search path -// list. Making it possible to load libraries directly from it. -JNI_GENERATOR_EXPORT bool -Java_org_chromium_base_library_1loader_LegacyLinker_nativeAddZipArchivePath( - JNIEnv* env, - jclass clazz, - jstring apk_path_obj) { - String apk_path(env, apk_path_obj); - - char search_path[512]; - snprintf(search_path, sizeof(search_path), "%s!lib/" CURRENT_ABI "/", - apk_path.c_str()); - - crazy_add_search_path(search_path); - return true; -} - -// Load a library with the chromium linker. This will also call its -// JNI_OnLoad() method, which shall register its methods. Note that -// lazy native method resolution will _not_ work after this, because -// Dalvik uses the system's dlsym() which won't see the new library, -// so explicit registration is mandatory. -// -// |env| is the current JNI environment handle. -// |clazz| is the static class handle for org.chromium.base.Linker, -// and is ignored here. -// |library_name| is the library name (e.g. libfoo.so). -// |load_address| is an explicit load address. -// |lib_info_obj| is a LibInfo handle used to communicate information -// with the Java side. -// Return true on success. -JNI_GENERATOR_EXPORT bool -Java_org_chromium_base_library_1loader_LegacyLinker_nativeLoadLibrary( - JNIEnv* env, - jclass clazz, - jstring lib_name_obj, - jlong load_address, - jobject lib_info_obj) { - String library_name(env, lib_name_obj); - LOG_INFO("Called for %s, at address 0x%llx", library_name.c_str(), - static_cast<unsigned long long>(load_address)); - crazy_context_t* context = GetCrazyContext(); - - if (!IsValidAddress(load_address)) - return false; - - // Set the desired load address (0 means randomize it). - crazy_context_set_load_address(context, static_cast<size_t>(load_address)); - - ScopedLibrary library; - if (!crazy_library_open(library.GetPtr(), library_name.c_str(), context)) { - return false; - } - - crazy_library_info_t info; - if (!crazy_library_get_info(library.Get(), context, &info)) { - LOG_ERROR("Could not get library information for %s: %s", - library_name.c_str(), crazy_context_get_error(context)); - return false; - } - - // Release library object to keep it alive after the function returns. - library.Release(); - - s_lib_info_fields.SetLoadInfo(env, lib_info_obj, info.load_address, - info.load_size); - LOG_INFO("Success loading library %s", library_name.c_str()); - return true; -} - -JNI_GENERATOR_EXPORT jboolean -Java_org_chromium_base_library_1loader_LegacyLinker_nativeCreateSharedRelro( - JNIEnv* env, - jclass clazz, - jstring library_name, - jlong load_address, - jobject lib_info_obj) { - String lib_name(env, library_name); - - LOG_INFO("Called for %s", lib_name.c_str()); - - if (!IsValidAddress(load_address)) - return false; - - ScopedLibrary library; - if (!crazy_library_find_by_name(lib_name.c_str(), library.GetPtr())) { - LOG_ERROR("Could not find %s", lib_name.c_str()); - return false; - } - - crazy_context_t* context = GetCrazyContext(); - size_t relro_start = 0; - size_t relro_size = 0; - int relro_fd = -1; - - if (!crazy_library_create_shared_relro( - library.Get(), context, static_cast<size_t>(load_address), - &relro_start, &relro_size, &relro_fd)) { - LOG_ERROR("Could not create shared RELRO sharing for %s: %s\n", - lib_name.c_str(), crazy_context_get_error(context)); - return false; - } - - s_lib_info_fields.SetRelroInfo(env, lib_info_obj, relro_start, relro_size, - relro_fd); - return true; -} - -JNI_GENERATOR_EXPORT jboolean -Java_org_chromium_base_library_1loader_LegacyLinker_nativeUseSharedRelro( - JNIEnv* env, - jclass clazz, - jstring library_name, - jobject lib_info_obj) { - String lib_name(env, library_name); - - LOG_INFO("Called for %s, lib_info_ref=%p", lib_name.c_str(), lib_info_obj); - - ScopedLibrary library; - if (!crazy_library_find_by_name(lib_name.c_str(), library.GetPtr())) { - LOG_ERROR("Could not find %s", lib_name.c_str()); - return false; - } - - crazy_context_t* context = GetCrazyContext(); - size_t relro_start = 0; - size_t relro_size = 0; - int relro_fd = -1; - s_lib_info_fields.GetRelroInfo(env, lib_info_obj, &relro_start, &relro_size, - &relro_fd); - - LOG_INFO("library=%s relro start=%p size=%p fd=%d", lib_name.c_str(), - (void*)relro_start, (void*)relro_size, relro_fd); - - if (!crazy_library_use_shared_relro(library.Get(), context, relro_start, - relro_size, relro_fd)) { - LOG_ERROR("Could not use shared RELRO for %s: %s", lib_name.c_str(), - crazy_context_get_error(context)); - return false; - } - - LOG_INFO("Library %s using shared RELRO section!", lib_name.c_str()); - - return true; -} - -} // namespace - -bool LegacyLinkerJNIInit(JavaVM* vm, JNIEnv* env) { - LOG_INFO("Entering"); - - // Save JavaVM* handle into linker, so that it can call JNI_OnLoad() - // automatically when loading libraries containing JNI entry points. - crazy_set_java_vm(vm, JNI_VERSION_1_4); - - return true; -} - -} // namespace chromium_android_linker
diff --git a/base/android/linker/legacy_linker_jni.h b/base/android/linker/legacy_linker_jni.h deleted file mode 100644 index 43c53292..0000000 --- a/base/android/linker/legacy_linker_jni.h +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2015 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef BASE_ANDROID_LINKER_LEGACY_LINKER_JNI_H_ -#define BASE_ANDROID_LINKER_LEGACY_LINKER_JNI_H_ - -#include <jni.h> - -namespace chromium_android_linker { - -// JNI_OnLoad() initialization hook for the legacy linker. -// Sets up JNI and other initializations for native linker code. -// |vm| is the Java VM handle passed to JNI_OnLoad(). -// |env| is the current JNI environment handle. -// On success, returns true. -extern bool LegacyLinkerJNIInit(JavaVM* vm, JNIEnv* env); - -} // namespace chromium_android_linker - -#endif // BASE_ANDROID_LINKER_LEGACY_LINKER_JNI_H_
diff --git a/base/android/linker/linker_jni_onload.cc b/base/android/linker/linker_jni_onload.cc index c38425d..94da7292 100644 --- a/base/android/linker/linker_jni_onload.cc +++ b/base/android/linker/linker_jni_onload.cc
@@ -6,13 +6,9 @@ // conflict with JNI_Onload() defined by the test library. The linker tests // together with the linker internals are smashed into (=linked with) the test // library. -// -// This file also helps avoiding LegacyLinkerJNIInit() and its dependencies in -// base_unittests. There are no plans to unittest LegacyLinker. #include <jni.h> -#include "base/android/linker/legacy_linker_jni.h" #include "base/android/linker/linker_jni.h" #include "base/android/linker/modern_linker_jni.h" @@ -41,8 +37,7 @@ LOG_ERROR("Could not create JNIEnv"); return -1; } - if (!LinkerJNIInit(vm, env) || !LegacyLinkerJNIInit(vm, env) || - !ModernLinkerJNIInit(vm, env)) { + if (!LinkerJNIInit(vm, env) || !ModernLinkerJNIInit(vm, env)) { return -1; } LOG_INFO("Done");
diff --git a/base/android/linker/modern_linker_jni.cc b/base/android/linker/modern_linker_jni.cc index a50b7a9e..c0f7e94 100644 --- a/base/android/linker/modern_linker_jni.cc +++ b/base/android/linker/modern_linker_jni.cc
@@ -642,3 +642,79 @@ } } // namespace chromium_android_linker + +// Custom implementation of new and delete, this prevents dragging +// the libc++ implementation, which drags exception-related machine +// code that is not needed here. This helps reduce the size of the +// final binary considerably. + +// Avoid these definitions in unittests because they link against the C++ +// library causing symbol duplication. +#if !defined(UNIT_TEST) + +// These symbols are not exported, thus this does not affect the libraries that +// it will load, only the linker binary itself. +void* operator new(size_t size) { + void* ptr = ::malloc(size); + if (ptr != nullptr) + return ptr; + + // Don't assume it is possible to call any C library function like + // snprintf() here, since it might allocate heap memory and crash at + // runtime. Hence our fatal message does not contain the number of + // bytes requested by the allocation. + static const char kFatalMessage[] = "Out of memory!"; +#ifdef __ANDROID__ + __android_log_write(ANDROID_LOG_FATAL, "linker", kFatalMessage); +#else + ::write(STDERR_FILENO, kFatalMessage, sizeof(kFatalMessage) - 1); +#endif + _exit(1); +#if defined(__GNUC__) + __builtin_unreachable(); +#endif + + // Adding a 'return nullptr' here will make the compiler error with a message + // stating that 'operator new(size_t)' is not allowed to return nullptr. + // + // Indeed, an new expression like 'new T' shall never return nullptr, + // according to the C++ specification, and an optimizing compiler will gladly + // remove any null-checks after them (something the Fuschsia team had to + // learn the hard way when writing their kernel in C++). What is meant here + // is something like: + // + // Foo* foo = new Foo(10); + // if (!foo) { <-- entire check and branch + // ... Handle out-of-memory condition. <-- removed by an optimizing + // } <-- compiler. + // + // Note that some C++ library implementations (e.g. recent libc++) recognize + // when they are compiled with -fno-exceptions and provide a simpler version + // of operator new that can return nullptr. However, it is very hard to + // guarantee at build time that this code is linked against such a version + // of the runtime. Moreoever, technically disabling exceptions is completely + // out-of-spec regarding the C++ language, and what the compiler is allowed + // to do in this case is mostly implementation-defined, so better be safe + // than sorry here. + // + // C++ provides a non-throwing new expression that can return a nullptr + // value, but it must be written as 'new (std::nothrow) T' instead of + // 'new T', and thus nobody uses this. This ends up calling + // 'operator new(size_t, const std::nothrow_t&)' which is not implemented + // here. +} + +void* operator new[](size_t size) { + return operator new(size); +} + +void operator delete(void* ptr) { + // The compiler-generated code already checked that |ptr != nullptr| + // so don't to it a second time. + ::free(ptr); +} + +void operator delete[](void* ptr) { + ::free(ptr); +} +#endif // UNIT_TEST
diff --git a/base/trace_event/builtin_categories.h b/base/trace_event/builtin_categories.h index 8113c0d..1c33c33 100644 --- a/base/trace_event/builtin_categories.h +++ b/base/trace_event/builtin_categories.h
@@ -349,6 +349,7 @@ X("shutdown,viz") \ X("startup,benchmark,rail") \ X("startup,rail") \ + X("toplevel,Java") \ X("toplevel,viz") \ X("ui,input") \ X("ui,latency") \
diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index 958f33a..efba847 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn
@@ -615,8 +615,13 @@ # # As remote execution requires inputs to be made more explicit than is normally # expected with gn, you may find that setting allow_remote to true will result -# in many missing file errors. This should be resolved by explicitly declaring -# these inputs/sources. +# in many missing file errors. In most cases, this should be resolved by +# explicitly declaring these inputs/sources. +# +# However, it may be impractical to determine these inputs in gn. For such +# cases, the invoker can specify a custom input processor, which are currently +# defined and implemented in //build/util/action_remote.py. The appropriate +# value should be set using the custom_processor arg. # Variables needed by rbe.gni aren't available at the top of this file. import("//build/toolchain/rbe.gni")
diff --git a/build/fuchsia/linux_internal.sdk.sha1 b/build/fuchsia/linux_internal.sdk.sha1 index ef17b542..ac3acfa6 100644 --- a/build/fuchsia/linux_internal.sdk.sha1 +++ b/build/fuchsia/linux_internal.sdk.sha1
@@ -1 +1 @@ -10.20221123.2.1 +10.20221125.1.1
diff --git a/build/util/action_remote.py b/build/util/action_remote.py index 021c871..1e9517d 100755 --- a/build/util/action_remote.py +++ b/build/util/action_remote.py
@@ -2,16 +2,129 @@ # Copyright 2022 The Chromium Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""Wrapper script to run action remotely through rewrapper with gn.""" +"""Wrapper script to run action remotely through rewrapper with gn. +Also includes Chromium-specific input processors which don't make sense to +be reclient inbuilt input processors.""" + +import argparse +import json +import os import subprocess import sys +from enum import Enum + + +class CustomProcessor(Enum): + mojom_parser = 'mojom_parser' + + def __str__(self): + return self.value + + +def _process_build_metadata_json(bm_file, exec_root, working_dir, output_root, + re_outputs, processed_inputs): + """Recursively find mojom_parser inputs from a build_metadata file.""" + if bm_file in processed_inputs: + return + + processed_inputs.add(bm_file) + + bm_dir = os.path.dirname(bm_file) + wd_rel = os.path.relpath(working_dir, exec_root) + + with open(bm_file) as f: + bm = json.load(f) + + # All sources and corresponding module files are inputs. + for s in bm["sources"]: + src = os.path.normpath(os.path.join(bm_dir, s)) + if src not in processed_inputs and os.path.exists(src): + processed_inputs.add(src) + src_module = os.path.normpath( + os.path.join(output_root, os.path.join(wd_rel, src + "-module"))) + if src_module in re_outputs: + continue + if src_module not in processed_inputs and os.path.exists(src_module): + processed_inputs.add(src_module) + + # Recurse into build_metadata deps. + for d in bm["deps"]: + dep = os.path.normpath(os.path.join(bm_dir, d)) + _process_build_metadata_json(dep, exec_root, working_dir, output_root, + re_outputs, processed_inputs) + + +def _get_mojom_parser_inputs(exec_root, output_files, extra_args): + """Get mojom inputs by walking generated build_metadata files. + + This is less complexity and disk I/O compared to parsing mojom files for + imports and finding all imports. + + Start from the root build_metadata file passed to mojom_parser's + --check-imports flag. + """ + argparser = argparse.ArgumentParser() + argparser.add_argument('--check-imports', dest='check_imports', required=True) + argparser.add_argument('--output-root', dest='output_root', required=True) + mojom_parser_args, _ = argparser.parse_known_args(args=extra_args) + + processed_inputs = set() + _process_build_metadata_json(mojom_parser_args.check_imports, exec_root, + os.getcwd(), mojom_parser_args.output_root, + output_files, processed_inputs) + + # Rebase paths onto rewrapper exec root. + return map(lambda dep: os.path.normpath(os.path.relpath(dep, exec_root)), + processed_inputs) def main(): - # Pass through all args. Use check=True to ensure failure is raised. - args = sys.argv[1:] - proc = subprocess.run(args, check=True) + # Set up argparser with some rewrapper flags. + argparser = argparse.ArgumentParser(description='rewrapper executor for gn', + allow_abbrev=False) + argparser.add_argument('--custom_processor', + type=CustomProcessor, + choices=list(CustomProcessor)) + argparser.add_argument('rewrapper_path') + argparser.add_argument('--input_list_paths') + argparser.add_argument('--output_list_paths') + argparser.add_argument('--exec_root') + parsed_args, extra_args = argparser.parse_known_args() + + # This script expects to be calling rewrapper. + args = [parsed_args.rewrapper_path] + + # Get the output files list. + output_files = set() + with open(parsed_args.output_list_paths, 'r') as file: + for line in file: + output_files.add(line.rstrip('\n')) + + # Scan for and add explicit inputs for rewrapper if necessary. + # These should be in a new input list paths file, as using --inputs can fail + # if the list is extremely large. + if parsed_args.custom_processor == CustomProcessor.mojom_parser: + root, ext = os.path.splitext(parsed_args.input_list_paths) + extra_inputs = _get_mojom_parser_inputs(parsed_args.exec_root, output_files, + extra_args) + extra_input_list_path = '%s__extra%s' % (root, ext) + with open(extra_input_list_path, 'w') as file: + with open(parsed_args.input_list_paths, 'r') as inputs: + file.write(inputs.read()) + file.write("\n".join(extra_inputs)) + args += ["--input_list_paths=%s" % extra_input_list_path] + else: + args += ["--input_list_paths=%s" % parsed_args.input_list_paths] + + # Filter out --custom_processor= which is a flag for this script, + # and filter out --input_list_paths= because we replace it above. + # Pass on the rest of the args to rewrapper. + args_rest = filter(lambda arg: '--custom_processor=' not in arg, sys.argv[2:]) + args += filter(lambda arg: '--input_list_paths=' not in arg, args_rest) + + # Run rewrapper. + proc = subprocess.run(args) return proc.returncode
diff --git a/chrome/VERSION b/chrome/VERSION index 35dc66a..9a96d870 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=110 MINOR=0 -BUILD=5439 +BUILD=5440 PATCH=0
diff --git a/chrome/android/features/autofill_assistant/BUILD.gn b/chrome/android/features/autofill_assistant/BUILD.gn index fe9a487..88be8fbc 100644 --- a/chrome/android/features/autofill_assistant/BUILD.gn +++ b/chrome/android/features/autofill_assistant/BUILD.gn
@@ -108,7 +108,6 @@ "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantProgressBarIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantPromptNavigationIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantQrCodeIntegrationTest.java", - "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantSemanticPredictionIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelperCustomTabTest.java", "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTabHelperRegularTabTest.java", "javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantTestRule.java",
diff --git a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantInputActionIntegrationTest.java b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantInputActionIntegrationTest.java index 1a37058a..3a19d2b 100644 --- a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantInputActionIntegrationTest.java +++ b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantInputActionIntegrationTest.java
@@ -14,7 +14,6 @@ import static org.hamcrest.Matchers.is; import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.checkElementExists; -import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.getElementChecked; import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.getElementValue; import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.startAutofillAssistant; import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.waitUntil; @@ -28,7 +27,6 @@ import static org.chromium.chrome.browser.autofill_assistant.MiniActionTestUtil.addTapSteps; import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toClientId; import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toCssSelector; -import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toIFrameCssSelector; import androidx.test.filters.MediumTest; @@ -415,120 +413,6 @@ assertThat(getElementValue(mTestRule.getWebContents(), "select"), is("three")); } - @Test - @MediumTest - public void fillTextFieldWithNativeMethod() throws Exception { - ArrayList<ActionProto> list = new ArrayList<>(); - - SelectorProto inputInIFrame = toIFrameCssSelector("#iframe", "#input"); - SelectorProto input = toCssSelector("#input2"); - - MiniActionTestUtil.addSetNativeValueSteps(inputInIFrame, "Value 2", list); - MiniActionTestUtil.addSetNativeValueSteps(input, "Value 1", list); - list.add(createWaitForValuePrompt("#input2", "Value 1", "script done")); - - assertThat(getElementValue(mTestRule.getWebContents(), "iframe", "input"), is("")); - assertThat(getElementValue(mTestRule.getWebContents(), "input2"), is("helloworld2")); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript(TEST_SCRIPT, list); - runScript(script); - - waitUntilViewMatchesCondition(withText("script done"), isCompletelyDisplayed()); - assertThat(getElementValue(mTestRule.getWebContents(), "iframe", "input"), is("Value 2")); - assertThat(getElementValue(mTestRule.getWebContents(), "input2"), is("Value 1")); - } - - @Test - @MediumTest - public void fillTextareaWithNativeMethod() throws Exception { - ArrayList<ActionProto> list = new ArrayList<>(); - SelectorProto selector = toCssSelector("#textarea1"); - - MiniActionTestUtil.addSetNativeValueSteps(selector, "new value", list); - list.add(createWaitForValuePrompt("#textarea1", "new value", "script done")); - - assertThat(getElementValue(mTestRule.getWebContents(), "textarea1"), - is("Initial textarea value.")); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript(TEST_SCRIPT, list); - runScript(script); - - waitUntilViewMatchesCondition(withText("script done"), isCompletelyDisplayed()); - assertThat(getElementValue(mTestRule.getWebContents(), "textarea1"), is("new value")); - } - - @Test - @MediumTest - public void fillDropdownWithNativeMethod() throws Exception { - ArrayList<ActionProto> list = new ArrayList<>(); - - SelectorProto selector = toCssSelector("#select"); - MiniActionTestUtil.addSetNativeValueSteps(selector, "three", list); - list.add(createWaitForValuePrompt("#select", "three", "script done")); - - assertThat(getElementValue(mTestRule.getWebContents(), "select"), is("one")); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript(TEST_SCRIPT, list); - runScript(script); - - waitUntilViewMatchesCondition(withText("script done"), isCompletelyDisplayed()); - assertThat(getElementValue(mTestRule.getWebContents(), "select"), is("three")); - } - - @Test - @MediumTest - public void fillCheckboxWithNativeMethod() throws Exception { - ArrayList<ActionProto> list = new ArrayList<>(); - - SelectorProto selectorOption2 = toCssSelector("#option2"); - SelectorProto selectorOption3 = toCssSelector("#option3"); - - MiniActionTestUtil.addSetNativeCheckedSteps(selectorOption2, true, list); - MiniActionTestUtil.addSetNativeCheckedSteps(selectorOption3, false, list); - list.add(createWaitForSelectorPrompt( - SelectorProto.newBuilder() - .addFilters(SelectorProto.Filter.newBuilder().setCssSelector( - "#option3:not(:checked)")) - .build(), - "script done")); - - assertThat(getElementChecked(mTestRule.getWebContents(), "option2"), is(false)); - assertThat(getElementChecked(mTestRule.getWebContents(), "option3"), is(true)); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript(TEST_SCRIPT, list); - runScript(script); - waitUntilViewMatchesCondition(withText("script done"), isCompletelyDisplayed()); - - assertThat(getElementChecked(mTestRule.getWebContents(), "option2"), is(true)); - assertThat(getElementChecked(mTestRule.getWebContents(), "option3"), is(false)); - } - - @Test - @MediumTest - public void fillRadioButtonWithNativeMethod() throws Exception { - ArrayList<ActionProto> list = new ArrayList<>(); - - SelectorProto selectorRed = toCssSelector("#radio_red"); - - MiniActionTestUtil.addSetNativeCheckedSteps(selectorRed, true, list); - list.add(createWaitForSelectorPrompt( - SelectorProto.newBuilder() - .addFilters(SelectorProto.Filter.newBuilder().setCssSelector( - "#radio_red:checked")) - .build(), - "script done")); - - assertThat(getElementChecked(mTestRule.getWebContents(), "radio_red"), is(false)); - assertThat(getElementChecked(mTestRule.getWebContents(), "radio_blue"), is(false)); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript(TEST_SCRIPT, list); - runScript(script); - waitUntilViewMatchesCondition(withText("script done"), isCompletelyDisplayed()); - - assertThat(getElementChecked(mTestRule.getWebContents(), "radio_red"), is(true)); - assertThat(getElementChecked(mTestRule.getWebContents(), "radio_blue"), is(false)); - } - private void runScript(AutofillAssistantTestScript script) { AutofillAssistantTestService testService = new AutofillAssistantTestService(Collections.singletonList(script));
diff --git a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantSemanticPredictionIntegrationTest.java b/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantSemanticPredictionIntegrationTest.java deleted file mode 100644 index 327b086..0000000 --- a/chrome/android/features/autofill_assistant/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantSemanticPredictionIntegrationTest.java +++ /dev/null
@@ -1,146 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.chrome.browser.autofill_assistant; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast; -import static androidx.test.espresso.matcher.ViewMatchers.withText; - -import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.startAutofillAssistant; -import static org.chromium.chrome.browser.autofill_assistant.AutofillAssistantUiTestUtil.waitUntilViewMatchesCondition; -import static org.chromium.chrome.browser.autofill_assistant.ProtoTestUtil.toCssSelector; - -import androidx.test.filters.MediumTest; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.RuleChain; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; - -import org.chromium.base.test.util.Batch; -import org.chromium.base.test.util.CommandLineFlags; -import org.chromium.base.test.util.DisabledTest; -import org.chromium.chrome.browser.autofill_assistant.proto.ActionProto; -import org.chromium.chrome.browser.autofill_assistant.proto.ChipProto; -import org.chromium.chrome.browser.autofill_assistant.proto.ElementConditionProto; -import org.chromium.chrome.browser.autofill_assistant.proto.PromptProto; -import org.chromium.chrome.browser.autofill_assistant.proto.PromptProto.Choice; -import org.chromium.chrome.browser.autofill_assistant.proto.SelectorProto; -import org.chromium.chrome.browser.autofill_assistant.proto.SelectorProto.Filter; -import org.chromium.chrome.browser.autofill_assistant.proto.SelectorProto.SemanticFilter; -import org.chromium.chrome.browser.autofill_assistant.proto.SupportedScriptProto; -import org.chromium.chrome.browser.autofill_assistant.proto.SupportedScriptProto.PresentationProto; -import org.chromium.chrome.browser.autofill_assistant.proto.TellProto; -import org.chromium.chrome.browser.autofill_assistant.proto.WaitForDomProto; -import org.chromium.chrome.browser.customtabs.CustomTabActivityTestRule; -import org.chromium.chrome.browser.flags.ChromeSwitches; -import org.chromium.chrome.test.ChromeJUnit4ClassRunner; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Tests for the Autofill Assistant semantic prediction model. - * - * The Semantic Prediction model is overridden via a command line flag. This - * is done so because otherwise the model would have to be downloaded at Chrome - * startup, which adds latency and flakiness to the tests (network call). - * - * The model file is located in |Environment.getExternalStorageDirectory()|, - * however that directory is hardcoded in @CommandLineFlags because method - * invocations are not allowed in annotations. Since this is an Android test, - * this external storage directory is /storage/emulated/0/chromium_tests_root. - */ -@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, - "enable-features=OptimizationTargetPrediction:fetch_startup_delay_ms/50", - "optimization-guide-model-override=OPTIMIZATION_TARGET_AUTOFILL_ASSISTANT:" - + "/storage/emulated/0/chromium_tests_root/components/test/data/autofill_assistant/model/model.tflite"}) -@RunWith(ChromeJUnit4ClassRunner.class) -@Batch(Batch.PER_CLASS) -public class AutofillAssistantSemanticPredictionIntegrationTest { - private static final String TEST_PAGE = "model/happy_path.html"; - - private final CustomTabActivityTestRule mTestRule = new CustomTabActivityTestRule(); - - @Rule - public final TestRule mRulesChain = RuleChain.outerRule(mTestRule).around( - new AutofillAssistantCustomTabTestRule(mTestRule, TEST_PAGE)); - - @Test - @MediumTest - @DisabledTest(message = "crbug.com/1379094") - public void happyPath() throws Exception { - ArrayList<ActionProto> actions = new ArrayList<>(); - - showMessage(actions, "Begin ..."); - waitForDom(actions, "#foot"); - choice(actions, "Find city"); - waitForDom(actions, "#city", 49, 7); - showMessage(actions, "Element found"); - - AutofillAssistantTestScript script = new AutofillAssistantTestScript( - SupportedScriptProto.newBuilder() - .setPath("happy_path.html") - .setPresentation(PresentationProto.newBuilder().setAutostart(true)) - .build(), - actions); - - AutofillAssistantTestService testService = - new AutofillAssistantTestService(Collections.singletonList(script)); - startAutofillAssistant(mTestRule.getActivity(), testService); - - waitUntilViewMatchesCondition(withText("Begin ..."), isCompletelyDisplayed()); - waitUntilViewMatchesCondition(withText("Find city"), isDisplayingAtLeast(90)); - onView(withText("Find city")).perform(click()); - waitUntilViewMatchesCondition(withText("Element found"), isCompletelyDisplayed(), 5_000); - } - - private void waitForDom(List<ActionProto> actions, String cssSelector) { - actions.add( - ActionProto.newBuilder() - .setWaitForDom( - WaitForDomProto.newBuilder().setTimeoutMs(3_000).setWaitCondition( - ElementConditionProto.newBuilder().setMatch( - toCssSelector(cssSelector)))) - .build()); - } - - private void waitForDom( - List<ActionProto> actions, String cssSelector, int role, int objective) { - SelectorProto moonracerSelector = - SelectorProto.newBuilder() - .addFilters(Filter.newBuilder() - .setCssSelector(cssSelector) - .setSemantic(SemanticFilter.newBuilder() - .setRole(role) - .setObjective(objective))) - .build(); - actions.add( - ActionProto.newBuilder() - .setWaitForDom( - WaitForDomProto.newBuilder().setTimeoutMs(3_000).setWaitCondition( - ElementConditionProto.newBuilder().setMatch( - moonracerSelector))) - .build()); - } - - private void choice(List<ActionProto> actions, String text) { - actions.add( - ActionProto.newBuilder() - .setPrompt(PromptProto.newBuilder().addChoices( - Choice.newBuilder().setChip(ChipProto.newBuilder().setText(text)))) - .build()); - } - - private void showMessage(List<ActionProto> actions, String message) { - actions.add(ActionProto.newBuilder() - .setTell(TellProto.newBuilder().setMessage(message)) - .build()); - } -}
diff --git a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/bar_component/KeyboardAccessoryModernView.java b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/bar_component/KeyboardAccessoryModernView.java index ab2a1a6..77e0954 100644 --- a/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/bar_component/KeyboardAccessoryModernView.java +++ b/chrome/android/features/keyboard_accessory/internal/java/src/org/chromium/chrome/browser/keyboard_accessory/bar_component/KeyboardAccessoryModernView.java
@@ -36,6 +36,8 @@ private ImageView mKeyboardToggle; private TextView mSheetTitle; private Callback<Integer> mObfuscatedLastChildAt; + private ObjectAnimator mAnimator; + private float mLastBarItemsViewPosition; // Records the first time a user scrolled to suppress an IPH explaining how scrolling works. private final RecyclerView.OnScrollListener mScrollingIphCallback = @@ -228,15 +230,20 @@ private void animateSuggestionArrival() { if (areAnimationsDisabled()) return; int bounceDirection = getLayoutDirection() == LAYOUT_DIRECTION_RTL ? 1 : -1; - float basePosition = mBarItemsView.getX(); - float start = basePosition + if (mAnimator != null && mAnimator.isRunning()) { + mAnimator.cancel(); + } else { + mLastBarItemsViewPosition = mBarItemsView.getX(); + } + + float start = mLastBarItemsViewPosition - bounceDirection * ARRIVAL_ANIMATION_BOUNCE_LENGTH_DIP * getContext().getResources().getDisplayMetrics().density; mBarItemsView.setTranslationX(start); - ObjectAnimator animator = - ObjectAnimator.ofFloat(mBarItemsView, "translationX", start, basePosition); - animator.setDuration(ARRIVAL_ANIMATION_DURATION_MS); - animator.setInterpolator(new OvershootInterpolator(ARRIVAL_ANIMATION_TENSION)); - animator.start(); + mAnimator = ObjectAnimator.ofFloat( + mBarItemsView, "translationX", start, mLastBarItemsViewPosition); + mAnimator.setDuration(ARRIVAL_ANIMATION_DURATION_MS); + mAnimator.setInterpolator(new OvershootInterpolator(ARRIVAL_ANIMATION_TENSION)); + mAnimator.start(); } }
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java index a1ea0f4..d614c88 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/site_settings/SiteSettingsTest.java
@@ -6,10 +6,12 @@ import static androidx.test.espresso.Espresso.onData; import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.action.ViewActions.swipeUp; import static androidx.test.espresso.assertion.ViewAssertions.matches; import static androidx.test.espresso.matcher.PreferenceMatchers.withKey; import static androidx.test.espresso.matcher.RootMatchers.withDecorView; +import static androidx.test.espresso.matcher.ViewMatchers.assertThat; import static androidx.test.espresso.matcher.ViewMatchers.hasSibling; import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription; @@ -17,6 +19,8 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText; import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.emptyIterable; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -28,6 +32,7 @@ import static org.chromium.components.content_settings.PrefNames.COOKIE_CONTROLS_MODE; import static org.chromium.components.content_settings.PrefNames.DESKTOP_SITE_DISPLAY_SETTING_ENABLED; import static org.chromium.components.content_settings.PrefNames.DESKTOP_SITE_PERIPHERAL_SETTING_ENABLED; +import static org.chromium.ui.test.util.ViewUtils.onViewWaiting; import android.content.Context; import android.content.Intent; @@ -132,7 +137,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -169,6 +173,8 @@ private static final String[] NULL_ARRAY = new String[0]; private static final String[] BINARY_TOGGLE = new String[] {"binary_toggle"}; + private static final String[] BINARY_TOGGLE_WITH_EXCEPTION_AND_INFO_TEXT = + new String[] {"info_text", "binary_toggle", "add_exception"}; private static final String[] BINARY_TOGGLE_WITH_EXCEPTION = new String[] {"binary_toggle", "add_exception"}; private static final String[] BINARY_TOGGLE_WITH_OS_WARNING_EXTRA = @@ -441,6 +447,10 @@ preferences.onPreferenceChange(toggle, enabled); } }); + if (type == SiteSettingsCategory.Type.SITE_DATA && !enabled) { + int id = R.string.website_settings_site_data_page_block_confirm_dialog_confirm_button; + onViewWaiting(withText(id)).perform(click()); + } settingsActivity.finish(); } @@ -506,9 +516,8 @@ if (key != null) actualKeys.add(key); } - Assert.assertTrue( - actualKeys.toString() + " should match " + Arrays.toString(expectedKeys), - Arrays.equals(actualKeys.toArray(), expectedKeys)); + assertThat(actualKeys, + expectedKeys.length == 0 ? emptyIterable() : contains(expectedKeys)); }); settingsActivity.finish(); } @@ -1352,8 +1361,9 @@ @Feature({"Preferences"}) @EnableFeatures(ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_4) public void testOnlyExpectedPreferencesSiteData() { - testExpectedPreferences(SiteSettingsCategory.Type.SITE_DATA, BINARY_TOGGLE_WITH_EXCEPTION, - BINARY_TOGGLE_WITH_EXCEPTION); + testExpectedPreferences(SiteSettingsCategory.Type.SITE_DATA, + BINARY_TOGGLE_WITH_EXCEPTION_AND_INFO_TEXT, + BINARY_TOGGLE_WITH_EXCEPTION_AND_INFO_TEXT); } @Test
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 269ba5c..7789e6e 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -177,8 +177,6 @@ "autocomplete/shortcuts_backend_factory.h", "autocomplete/zero_suggest_cache_service_factory.cc", "autocomplete/zero_suggest_cache_service_factory.h", - "autofill_assistant/annotate_dom_model_service_factory.cc", - "autofill_assistant/annotate_dom_model_service_factory.h", "autofill_assistant/assistant_field_trial_util_chrome.cc", "autofill_assistant/assistant_field_trial_util_chrome.h", "autofill_assistant/common_dependencies_chrome.cc", @@ -2062,8 +2060,6 @@ "//components/autofill_assistant/browser/", "//components/autofill_assistant/browser/public:password_change", "//components/autofill_assistant/browser/public:public", - "//components/autofill_assistant/content/browser", - "//components/autofill_assistant/content/common:mojo_interfaces", "//components/back_forward_cache", "//components/background_fetch", "//components/background_sync", @@ -3354,7 +3350,6 @@ "//components/autofill_assistant/browser/android:dependencies_android", "//components/autofill_assistant/browser/public:proto", "//components/autofill_assistant/browser/public/fast_checkout/proto:proto", - "//components/autofill_assistant/content/browser", "//components/background_sync", "//components/bookmarks/common/android", "//components/browser_ui/accessibility/android", @@ -6402,6 +6397,7 @@ if (is_win) { deps += [ + "//chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win", "//components/device_signals/core/browser/win", "//components/device_signals/core/common/win", ]
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index f7008576..c59c29f5 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc
@@ -3282,6 +3282,17 @@ std::size(kGalleryAppPdfEditNotificationOpenWithGalleryApp), nullptr}}; #endif +constexpr FeatureEntry::FeatureParam + kPasswordStrengthIndicatorMinimizedVariation[] = { + {password_manager::features:: + kPasswordStrengthIndicatorWithMinimizedState.name, + "true"}}; + +constexpr FeatureEntry::FeatureVariation + kPasswordStrengthIndicatorVariations[] = { + {" with minimized state", kPasswordStrengthIndicatorMinimizedVariation, + std::size(kPasswordStrengthIndicatorMinimizedVariation), nullptr}}; + // RECORDING USER METRICS FOR FLAGS: // ----------------------------------------------------------------------------- // The first line of the entry is the internal name. @@ -8250,8 +8261,10 @@ {"password-strength-indicator", flag_descriptions::kPasswordStrengthIndicatorName, flag_descriptions::kPasswordStrengthIndicatorDescription, kOsDesktop, - FEATURE_VALUE_TYPE( - password_manager::features::kPasswordStrengthIndicator)}, + FEATURE_WITH_PARAMS_VALUE_TYPE( + password_manager::features::kPasswordStrengthIndicator, + kPasswordStrengthIndicatorVariations, + "PasswordStrengthIndicator")}, #if BUILDFLAG(IS_CHROMEOS_ASH) {"partial-split", flag_descriptions::kPartialSplit,
diff --git a/chrome/browser/ash/crosapi/crosapi_util.cc b/chrome/browser/ash/crosapi/crosapi_util.cc index 6956603..076e664 100644 --- a/chrome/browser/ash/crosapi/crosapi_util.cc +++ b/chrome/browser/ash/crosapi/crosapi_util.cc
@@ -225,8 +225,10 @@ policy::BrowserPolicyConnectorAsh* policy_connector = g_browser_process->platform_part()->browser_policy_connector_ash(); result->directory_device_id = policy_connector->GetDirectoryApiID(); - result->serial_number = chromeos::system::StatisticsProvider::GetInstance() - ->GetEnterpriseMachineID(); + result->serial_number = + std::string(chromeos::system::StatisticsProvider::GetInstance() + ->GetMachineID() + .value_or("")); result->annotated_asset_id = policy_connector->GetDeviceAssetID(); result->annotated_location = policy_connector->GetDeviceAnnotatedLocation(); auto* device_name_policy_handler =
diff --git a/chrome/browser/ash/crosapi/echo_private_ash.cc b/chrome/browser/ash/crosapi/echo_private_ash.cc index 6d389bf..4d79362 100644 --- a/chrome/browser/ash/crosapi/echo_private_ash.cc +++ b/chrome/browser/ash/crosapi/echo_private_ash.cc
@@ -95,12 +95,18 @@ std::string result; switch (type) { case mojom::RegistrationCodeType::kCoupon: - provider->GetMachineStatistic(chromeos::system::kOffersCouponCodeKey, - &result); + if (const absl::optional<base::StringPiece> offers_code = + provider->GetMachineStatistic( + chromeos::system::kOffersCouponCodeKey)) { + result = std::string(offers_code.value()); + } break; case mojom::RegistrationCodeType::kGroup: - provider->GetMachineStatistic(chromeos::system::kOffersGroupCodeKey, - &result); + if (const absl::optional<base::StringPiece> offers_code = + provider->GetMachineStatistic( + chromeos::system::kOffersGroupCodeKey)) { + result = std::string(offers_code.value()); + } break; }
diff --git a/chrome/browser/ash/crosapi/extension_info_private_ash.cc b/chrome/browser/ash/crosapi/extension_info_private_ash.cc index 032dfd6..208d018b 100644 --- a/chrome/browser/ash/crosapi/extension_info_private_ash.cc +++ b/chrome/browser/ash/crosapi/extension_info_private_ash.cc
@@ -256,29 +256,28 @@ std::unique_ptr<base::Value> GetValue(const std::string& property_name) { if (property_name == kPropertyHWID) { - std::string hwid; chromeos::system::StatisticsProvider* provider = chromeos::system::StatisticsProvider::GetInstance(); - provider->GetMachineStatistic(chromeos::system::kHardwareClassKey, &hwid); - return std::make_unique<base::Value>(hwid); + const absl::optional<base::StringPiece> hwid = + provider->GetMachineStatistic(chromeos::system::kHardwareClassKey); + return std::make_unique<base::Value>(hwid.value_or("")); } if (property_name == kPropertyCustomizationID) { - std::string customization_id; chromeos::system::StatisticsProvider* provider = chromeos::system::StatisticsProvider::GetInstance(); - provider->GetMachineStatistic(chromeos::system::kCustomizationIdKey, - &customization_id); - return std::make_unique<base::Value>(customization_id); + const absl::optional<base::StringPiece> customization_id = + provider->GetMachineStatistic(chromeos::system::kCustomizationIdKey); + return std::make_unique<base::Value>(customization_id.value_or("")); } if (property_name == kPropertyDeviceRequisition) { - std::string device_requisition; chromeos::system::StatisticsProvider* provider = chromeos::system::StatisticsProvider::GetInstance(); - provider->GetMachineStatistic(chromeos::system::kOemDeviceRequisitionKey, - &device_requisition); - return std::make_unique<base::Value>(device_requisition); + const absl::optional<base::StringPiece> device_requisition = + provider->GetMachineStatistic( + chromeos::system::kOemDeviceRequisitionKey); + return std::make_unique<base::Value>(device_requisition.value_or("")); } if (property_name == kPropertyMeetDevice) {
diff --git a/chrome/browser/ash/crosapi/network_settings_service_ash.cc b/chrome/browser/ash/crosapi/network_settings_service_ash.cc index 1be0902..858ca4d 100644 --- a/chrome/browser/ash/crosapi/network_settings_service_ash.cc +++ b/chrome/browser/ash/crosapi/network_settings_service_ash.cc
@@ -109,12 +109,16 @@ PrefService* pref_service = GetPrimaryLoggedInUserProfilePrefs(); DCHECK(pref_service); + extension_controlling_proxy_.reset(); + if (!proxy_config->extension) { LOG(ERROR) << "Received extension proxy configuration without extension data"; return; } + extension_controlling_proxy_ = proxy_config->extension.Clone(); + // Required to display the extension which is controlling the proxy in the OS // Settings > Network > Proxy window. base::Value proxy_extension(base::Value::Type::DICTIONARY); @@ -185,10 +189,11 @@ } void NetworkSettingsServiceAsh::ClearProxyPrefFromUserStore() { + extension_controlling_proxy_.reset(); PrefService* pref_service = GetPrimaryLoggedInUserProfilePrefs(); DCHECK(pref_service); - pref_service->ClearPref(proxy_config::prefs::kProxy); pref_service->ClearPref(ash::prefs::kLacrosProxyControllingExtension); + pref_service->ClearPref(proxy_config::prefs::kProxy); } void NetworkSettingsServiceAsh::DetermineEffectiveProxy() { @@ -201,6 +206,8 @@ .get(), cached_wpad_url_); + new_proxy_config->extension = extension_controlling_proxy_.Clone(); + // Trigger a proxy settings sync to Lacros if the proxy configuration changes. if (!cached_proxy_config_ || !new_proxy_config->Equals(*cached_proxy_config_)) {
diff --git a/chrome/browser/ash/crosapi/network_settings_service_ash.h b/chrome/browser/ash/crosapi/network_settings_service_ash.h index 941326f..fb30ca5 100644 --- a/chrome/browser/ash/crosapi/network_settings_service_ash.h +++ b/chrome/browser/ash/crosapi/network_settings_service_ash.h
@@ -85,6 +85,8 @@ void OnProfileManagerDestroying() override; crosapi::mojom::ProxyConfigPtr cached_proxy_config_; + crosapi::mojom::ExtensionControllingProxyPtr extension_controlling_proxy_; + // The PAC URL associated with `default_network_name_`, received via the DHCP // discovery method. GURL cached_wpad_url_;
diff --git a/chrome/browser/ash/crosapi/network_settings_service_ash_browsertest.cc b/chrome/browser/ash/crosapi/network_settings_service_ash_browsertest.cc index 89fc1a5f..1ca3033d 100644 --- a/chrome/browser/ash/crosapi/network_settings_service_ash_browsertest.cc +++ b/chrome/browser/ash/crosapi/network_settings_service_ash_browsertest.cc
@@ -6,6 +6,7 @@ #include "ash/constants/ash_pref_names.h" #include "base/callback.h" +#include "base/test/repeating_test_future.h" #include "chrome/browser/ash/crosapi/network_settings_translation.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" @@ -80,22 +81,19 @@ TestObserver& operator=(const TestObserver&) = delete; ~TestObserver() override = default; - void SetQuitClosure(base::OnceClosure quit_closure) { - quit_closure_ = std::move(quit_closure); - } - // crosapi::mojom::NetworkSettingsObserver: void OnProxyChanged(crosapi::mojom::ProxyConfigPtr proxy_config) override { - proxy_config_ = std::move(proxy_config); - if (quit_closure_) { - std::move(quit_closure_).Run(); - } + future_.AddValue(std::move(proxy_config)); } - crosapi::mojom::ProxyConfigPtr proxy_config_; + + crosapi::mojom::ProxyConfigPtr WaitForProxyConfig() { return future_.Take(); } + mojo::Receiver<crosapi::mojom::NetworkSettingsObserver> receiver_{this}; + bool AreAllProxyUpdatesRead() { return future_.IsEmpty(); } + private: - base::OnceClosure quit_closure_; + base::test::RepeatingTestFuture<crosapi::mojom::ProxyConfigPtr> future_; }; } // namespace @@ -179,20 +177,15 @@ // changes and propagates the network configurations to observers via the mojo // API. IN_PROC_BROWSER_TEST_F(NetworkSettingsServiceAshTest, ProxyConfigUpdate) { - base::RunLoop run_loop; - observer_->SetQuitClosure(run_loop.QuitClosure()); SetOncPolicy(kONCPolicyWifi0Proxy, policy::POLICY_SCOPE_USER); - // Wait for the `observer` to get the proxy configurations from the ONC - // policy. - run_loop.Run(); - ASSERT_TRUE(observer_->proxy_config_); - ASSERT_TRUE(observer_->proxy_config_->proxy_settings->is_manual()); + auto result = observer_->WaitForProxyConfig(); crosapi::mojom::ProxySettingsManualPtr manual = - std::move(observer_->proxy_config_->proxy_settings->get_manual()); + std::move(result->proxy_settings->get_manual()); ASSERT_EQ(manual->http_proxies.size(), 1u); EXPECT_EQ(manual->http_proxies[0]->host, "proxyhost"); EXPECT_EQ(manual->http_proxies[0]->port, 3128); + EXPECT_TRUE(result->extension.is_null()); } // Test suite for testing the AshNetworkSettingsService with proxies set via @@ -251,8 +244,16 @@ // Emulate receiving an initial proxy config from lacros-chrome. base::Value::Dict proxy_config = ProxyConfigDictionary::CreatePacScript(kPacUrl, /*pac_mandatory=*/true); + SendExtensionProxyConfig(proxy_config.Clone(), /*can_be_disabled=*/true); + + auto result = observer_->WaitForProxyConfig(); + ASSERT_FALSE(result.is_null()); + ASSERT_FALSE(result->extension.is_null()); + EXPECT_EQ(result->extension->name, kExtensionName); + EXPECT_EQ(result->extension->id, kExtensionId); + EXPECT_EQ(*(proxy_pref->GetValue()), proxy_config); EXPECT_EQ( *extension_proxy_pref->GetValue()->FindStringKey(kPrefExtensionNameKey), @@ -263,18 +264,12 @@ EXPECT_EQ( extension_proxy_pref->GetValue()->FindBoolKey(kPrefExtensionCanDisabled), true); - // Send an update. - SendExtensionProxyConfig(proxy_config.Clone(), - /*can_be_disabled=*/false); - EXPECT_EQ( - extension_proxy_pref->GetValue()->FindBoolKey(kPrefExtensionCanDisabled), - false); - // Send another update - clear. network_service_ash_->ClearExtensionProxy(); - WaitForLacrosProxyControllingExtensionPref( - base::Value(base::Value::Type::DICTIONARY)); + result = observer_->WaitForProxyConfig(); + ASSERT_FALSE(result.is_null()); + EXPECT_TRUE(result->extension.is_null()); EXPECT_EQ(*(extension_proxy_pref->GetValue()), base::Value(base::Value::Type::DICTIONARY)); // proxy_mode=system is the default value (see @@ -288,9 +283,16 @@ IN_PROC_BROWSER_TEST_F(NetworkSettingsServiceAshExtensionTest, UserPolicyHasPrecedence) { base::Value::Dict pac_proxy = - ProxyConfigDictionary::CreatePacScript(kPacUrl, /*pac_mandatory=*/true); + ProxyConfigDictionary::CreatePacScript(kPacUrl, + /*pac_mandatory=*/true); SendExtensionProxyConfig(pac_proxy.Clone(), /*can_be_disabled=*/true); + + auto result = observer_->WaitForProxyConfig(); + ASSERT_FALSE(result->extension.is_null()); + EXPECT_EQ(result->extension->name, kExtensionName); + EXPECT_EQ(result->extension->id, kExtensionId); + // Set proxy by policy. policy::PolicyMap policy; policy.Set(policy::key::kProxyMode, policy::POLICY_LEVEL_MANDATORY, @@ -308,6 +310,9 @@ browser()->profile()->GetPrefs()->GetDict( ash::prefs::kLacrosProxyControllingExtension); EXPECT_TRUE(extension_proxy_pref.empty()); + + result = observer_->WaitForProxyConfig(); + EXPECT_TRUE(result->extension.is_null()); } // Same as the `UserPolicyHasPrecedence` test, but with reverse order of proxies @@ -347,29 +352,28 @@ OncPolicyHasLowerPriority) { SetOncPolicy(kONCPolicyWifi0Proxy, policy::POLICY_SCOPE_USER); - EXPECT_TRUE(observer_->proxy_config_->proxy_settings->is_manual()); - { - base::RunLoop run_loop; - observer_->SetQuitClosure(run_loop.QuitClosure()); - base::Value::Dict pac_proxy = - ProxyConfigDictionary::CreatePacScript(kPacUrl, /*pac_mandatory=*/true); - SendExtensionProxyConfig(pac_proxy.Clone(), - /*can_be_disabled=*/true); - // Wait for the `observer` to get the proxy - // configurations from the extension. - run_loop.Run(); - } - ASSERT_TRUE(observer_->proxy_config_); - EXPECT_TRUE(observer_->proxy_config_->proxy_settings->is_pac()); + auto result = observer_->WaitForProxyConfig(); + EXPECT_TRUE(result->proxy_settings->is_manual()); - { - base::RunLoop run_loop; - observer_->SetQuitClosure(run_loop.QuitClosure()); - network_service_ash_->ClearExtensionProxy(); - run_loop.Run(); - } - ASSERT_TRUE(observer_->proxy_config_); - EXPECT_TRUE(observer_->proxy_config_->proxy_settings->is_manual()); + base::Value::Dict pac_proxy = + ProxyConfigDictionary::CreatePacScript(kPacUrl, + /*pac_mandatory=*/true); + SendExtensionProxyConfig(pac_proxy.Clone(), + /*can_be_disabled=*/true); + + result = observer_->WaitForProxyConfig(); + ASSERT_TRUE(result); + EXPECT_TRUE(result->proxy_settings->is_pac()); + ASSERT_FALSE(result->extension.is_null()); + EXPECT_EQ(result->extension->name, kExtensionName); + EXPECT_EQ(result->extension->id, kExtensionId); + + network_service_ash_->ClearExtensionProxy(); + + result = observer_->WaitForProxyConfig(); + ASSERT_TRUE(result); + EXPECT_TRUE(result->proxy_settings->is_manual()); + EXPECT_TRUE(result->extension.is_null()); } // Same as the `OncPolicyHasLowerPriority` test, but with reverse order of @@ -377,24 +381,24 @@ // to proxy source and not the latest applied config. IN_PROC_BROWSER_TEST_F(NetworkSettingsServiceAshExtensionTest, ExtensionHasHigherPriorityThanOncPolicy) { - { - base::RunLoop run_loop; - observer_->SetQuitClosure(run_loop.QuitClosure()); - base::Value::Dict pac_proxy = - ProxyConfigDictionary::CreatePacScript(kPacUrl, /*pac_mandatory=*/true); - SendExtensionProxyConfig(pac_proxy.Clone(), - /*can_be_disabled=*/true); - // Wait for the `observer` to get the proxy - // configurations from the extension. - run_loop.Run(); - } + base::Value::Dict pac_proxy = + ProxyConfigDictionary::CreatePacScript(kPacUrl, + /*pac_mandatory=*/true); + SendExtensionProxyConfig(pac_proxy.Clone(), + /*can_be_disabled=*/true); // Set a manual proxy. SetOncPolicy(kONCPolicyWifi0Proxy, policy::POLICY_SCOPE_USER); + auto result = observer_->WaitForProxyConfig(); + EXPECT_TRUE(observer_->AreAllProxyUpdatesRead()); + // Expect that the PAC proxy set by the extension is still active. - ASSERT_TRUE(observer_->proxy_config_); - EXPECT_TRUE(observer_->proxy_config_->proxy_settings->is_pac()); + ASSERT_TRUE(result); + EXPECT_TRUE(result->proxy_settings->is_pac()); + ASSERT_FALSE(result->extension.is_null()); + EXPECT_EQ(result->extension->name, kExtensionName); + EXPECT_EQ(result->extension->id, kExtensionId); } } // namespace crosapi
diff --git a/chrome/browser/ash/crosapi/test_controller_ash.cc b/chrome/browser/ash/crosapi/test_controller_ash.cc index 13b3d43..fd77470 100644 --- a/chrome/browser/ash/crosapi/test_controller_ash.cc +++ b/chrome/browser/ash/crosapi/test_controller_ash.cc
@@ -11,6 +11,10 @@ #include "ash/public/cpp/shelf_model.h" #include "ash/public/cpp/tablet_mode.h" #include "ash/public/cpp/window_properties.h" +#include "ash/root_window_controller.h" +#include "ash/shelf/shelf.h" +#include "ash/shelf/shelf_app_button.h" +#include "ash/shelf/shelf_view.h" #include "ash/shell.h" #include "ash/wm/overview/overview_controller.h" #include "ash/wm/overview/overview_observer.h" @@ -49,6 +53,7 @@ #include "ui/aura/window_event_dispatcher.h" #include "ui/aura/window_tree_host.h" #include "ui/base/user_activity/user_activity_detector.h" +#include "ui/display/screen.h" #include "ui/events/base_event_utils.h" #include "ui/events/event.h" #include "ui/events/event_source.h" @@ -228,6 +233,29 @@ std::move(callback).Run(); } +void TestControllerAsh::GetShelfItemState(const std::string& app_id, + GetShelfItemStateCallback callback) { + ash::RootWindowController* const controller = + ash::Shell::GetRootWindowControllerWithDisplayId( + display::Screen::GetScreen()->GetPrimaryDisplay().id()); + ash::ShelfView* const shelf_view = + controller->shelf()->GetShelfViewForTesting(); + const ash::ShelfAppButton* const app_button = + shelf_view->GetShelfAppButton(ash::ShelfID(app_id)); + uint32_t state = static_cast<uint32_t>(mojom::ShelfItemState::kNormal); + if (app_button) { + if (app_button->state() & ash::ShelfAppButton::STATE_ACTIVE) + state = static_cast<uint32_t>(mojom::ShelfItemState::kActive); + else if (app_button->state() & ash::ShelfAppButton::STATE_RUNNING) + state = static_cast<uint32_t>(mojom::ShelfItemState::kRunning); + + if (app_button->state() & ash::ShelfAppButton::STATE_NOTIFICATION) + state |= static_cast<uint32_t>(mojom::ShelfItemState::kNotification); + } + + std::move(callback).Run(state); +} + void TestControllerAsh::GetContextMenuForShelfItem( const std::string& item_id, GetContextMenuForShelfItemCallback callback) {
diff --git a/chrome/browser/ash/crosapi/test_controller_ash.h b/chrome/browser/ash/crosapi/test_controller_ash.h index aac6afca..0784457 100644 --- a/chrome/browser/ash/crosapi/test_controller_ash.h +++ b/chrome/browser/ash/crosapi/test_controller_ash.h
@@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_ASH_CROSAPI_TEST_CONTROLLER_ASH_H_ #define CHROME_BROWSER_ASH_CROSAPI_TEST_CONTROLLER_ASH_H_ +#include <stdint.h> + #include <memory> #include <string> #include <vector> @@ -49,6 +51,8 @@ void ExitOverviewMode(ExitOverviewModeCallback callback) override; void EnterTabletMode(EnterTabletModeCallback callback) override; void ExitTabletMode(ExitTabletModeCallback callback) override; + void GetShelfItemState(const std::string& app_id, + GetShelfItemStateCallback callback) override; void GetContextMenuForShelfItem( const std::string& item_id, GetContextMenuForShelfItemCallback callback) override;
diff --git a/chrome/browser/ash/file_manager/fusebox_mounter.cc b/chrome/browser/ash/file_manager/fusebox_mounter.cc index 48e55cc..01d9b41 100644 --- a/chrome/browser/ash/file_manager/fusebox_mounter.cc +++ b/chrome/browser/ash/file_manager/fusebox_mounter.cc
@@ -14,6 +14,7 @@ #include "base/logging.h" #include "base/memory/weak_ptr.h" #include "base/strings/string_util.h" +#include "base/task/thread_pool.h" #include "chrome/browser/ash/fusebox/fusebox_server.h" #include "chromeos/ash/components/dbus/cros_disks/cros_disks_client.h" #include "chromeos/ash/components/disks/disk_mount_manager.h" @@ -34,21 +35,30 @@ const std::string& url, bool read_only) { if (!mounted_) { + VLOG(1) << "Fusebox isn't mounted, queueing AttachStorage call"; + pending_attach_storage_calls_.emplace(subdir, + std::make_pair(url, read_only)); return; } fusebox::Server* fusebox_server = fusebox::Server::GetInstance(); if (fusebox_server) { fusebox_server->RegisterFSURLPrefix(subdir, url, read_only); + } else { + VLOG(1) << "No fusebox server available on AttachStorage"; } } void FuseBoxMounter::DetachStorage(const std::string& subdir) { if (!mounted_) { + VLOG(1) << "Fusebox isn't mounted, removing queued AttachStorage call"; + pending_attach_storage_calls_.erase(subdir); return; } fusebox::Server* fusebox_server = fusebox::Server::GetInstance(); if (fusebox_server) { fusebox_server->UnregisterFSURLPrefix(subdir); + } else { + VLOG(1) << "No fusebox server available on DetachStorage"; } } @@ -84,7 +94,16 @@ LOG(ERROR) << kFuseBoxMounterURI << " mount error " << error; } else { mounted_ = true; + if (!pending_attach_storage_calls_.empty()) { + VLOG(1) << "Calling " << pending_attach_storage_calls_.size() + << " queued AttachStorage calls"; + for (const auto& it : pending_attach_storage_calls_) { + const auto& [url, read_only] = it.second; + AttachStorage(it.first, url, read_only); + } + } } + pending_attach_storage_calls_.clear(); } void FuseBoxMounter::UnmountResponse(ash::MountError error) { @@ -93,6 +112,7 @@ } else { mounted_ = false; } + pending_attach_storage_calls_.clear(); } } // namespace file_manager
diff --git a/chrome/browser/ash/file_manager/fusebox_mounter.h b/chrome/browser/ash/file_manager/fusebox_mounter.h index a778d0b..3799224 100644 --- a/chrome/browser/ash/file_manager/fusebox_mounter.h +++ b/chrome/browser/ash/file_manager/fusebox_mounter.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_ASH_FILE_MANAGER_FUSEBOX_MOUNTER_H_ #define CHROME_BROWSER_ASH_FILE_MANAGER_FUSEBOX_MOUNTER_H_ +#include <map> #include <string> #include "base/callback_forward.h" @@ -18,6 +19,8 @@ using FuseBoxMountInfo = ::ash::disks::DiskMountManager::MountPoint; +using UrlReadOnlyPair = std::pair<std::string, bool>; + class FuseBoxMounter { public: FuseBoxMounter(); @@ -53,6 +56,10 @@ // True if this fusebox instance is mounted. bool mounted_ = false; + // A list of `AttachStorage` invocations that were called prior to the fusebox + // mounting, these get called when fusebox successfully mounts. + std::map<std::string, UrlReadOnlyPair> pending_attach_storage_calls_; + // base::WeakPtr{this} factory. base::WeakPtrFactory<FuseBoxMounter> weak_ptr_factory_{this}; };
diff --git a/chrome/browser/ash/hats/hats_config.h b/chrome/browser/ash/hats/hats_config.h index e625847..098c8c3 100644 --- a/chrome/browser/ash/hats/hats_config.h +++ b/chrome/browser/ash/hats/hats_config.h
@@ -54,9 +54,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::kHatsGeneralSurvey; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_HATS_HATS_CONFIG_H_
diff --git a/chrome/browser/ash/hats/hats_notification_controller.cc b/chrome/browser/ash/hats/hats_notification_controller.cc index 64fd943d..81c5a33 100644 --- a/chrome/browser/ash/hats/hats_notification_controller.cc +++ b/chrome/browser/ash/hats/hats_notification_controller.cc
@@ -44,6 +44,7 @@ #include "ui/strings/grit/ui_strings.h" namespace ash { + namespace { const char kNotificationOriginUrl[] = "chrome://hats"; @@ -187,7 +188,7 @@ // Observe NetworkStateHandler to be notified when an internet connection // is available. NetworkStateHandler* handler = - ash::NetworkHandler::Get()->network_state_handler(); + NetworkHandler::Get()->network_state_handler(); handler->AddObserver(this); // Create an immediate update for the current default network. const NetworkState* default_network = handler->DefaultNetwork(); @@ -274,7 +275,7 @@ state_ = HatsState::kNotificationClicked; // Remove the notification. - ash::NetworkHandler::Get()->network_state_handler()->RemoveObserver(this); + NetworkHandler::Get()->network_state_handler()->RemoveObserver(this); notification_.reset(nullptr); NotificationDisplayService::GetForProfile(profile_)->Close( NotificationHandler::Type::TRANSIENT, kNotificationId); @@ -297,7 +298,7 @@ if (by_user) { UpdateLastInteractionTime(); - ash::NetworkHandler::Get()->network_state_handler()->RemoveObserver(this); + NetworkHandler::Get()->network_state_handler()->RemoveObserver(this); notification_.reset(nullptr); state_ = HatsState::kNotificationDismissed; } @@ -305,8 +306,8 @@ // NetworkStateHandlerObserver override: void HatsNotificationController::PortalStateChanged( - const ash::NetworkState* default_network, - ash::NetworkState::PortalState portal_state) { + const NetworkState* default_network, + NetworkState::PortalState portal_state) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); VLOG(1) << "PortalStateChanged: default_network=" << (default_network ? default_network->path() : "")
diff --git a/chrome/browser/ash/hats/hats_notification_controller.h b/chrome/browser/ash/hats/hats_notification_controller.h index 9190249..329cd01 100644 --- a/chrome/browser/ash/hats/hats_notification_controller.h +++ b/chrome/browser/ash/hats/hats_notification_controller.h
@@ -19,6 +19,7 @@ class NetworkState; namespace ash { + struct HatsConfig; // TODO(jackshira): Extract non-notification specific code into a manager class. @@ -88,8 +89,8 @@ const absl::optional<std::u16string>& reply) override; // NetworkStateHandlerObserver override: - void PortalStateChanged(const ash::NetworkState* default_network, - ash::NetworkState::PortalState portal_state) override; + void PortalStateChanged(const NetworkState* default_network, + NetworkState::PortalState portal_state) override; void OnShuttingDown() override; // Must be run on a blocking thread pool. @@ -117,9 +118,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::HatsNotificationController; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_HATS_HATS_NOTIFICATION_CONTROLLER_H_
diff --git a/chrome/browser/ash/input_method/assistive_window_properties.h b/chrome/browser/ash/input_method/assistive_window_properties.h index 1d90081d..7950c075 100644 --- a/chrome/browser/ash/input_method/assistive_window_properties.h +++ b/chrome/browser/ash/input_method/assistive_window_properties.h
@@ -32,11 +32,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::AssistiveWindowProperties; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_ASSISTIVE_WINDOW_PROPERTIES_H_
diff --git a/chrome/browser/ash/input_method/input_method_configuration.cc b/chrome/browser/ash/input_method/input_method_configuration.cc index bf4366f0..bf4a968 100644 --- a/chrome/browser/ash/input_method/input_method_configuration.cc +++ b/chrome/browser/ash/input_method/input_method_configuration.cc
@@ -11,6 +11,7 @@ #include "chrome/browser/ash/input_method/input_method_delegate_impl.h" #include "chrome/browser/ash/input_method/input_method_manager_impl.h" #include "chrome/browser/ash/input_method/input_method_persistence.h" +#include "ui/base/ime/ash/input_method_manager.h" namespace ash { namespace input_method {
diff --git a/chrome/browser/ash/input_method/input_method_configuration.h b/chrome/browser/ash/input_method/input_method_configuration.h index 48a811e..c93c3db5 100644 --- a/chrome/browser/ash/input_method/input_method_configuration.h +++ b/chrome/browser/ash/input_method/input_method_configuration.h
@@ -6,12 +6,12 @@ #define CHROME_BROWSER_ASH_INPUT_METHOD_INPUT_METHOD_CONFIGURATION_H_ #include "base/task/sequenced_task_runner.h" -// TODO(https://crbug.com/1164001): remove and use forward declaration. -#include "ui/base/ime/ash/input_method_manager.h" namespace ash { namespace input_method { +class InputMethodManager; + void Initialize(); // Similar to Initialize(), but can inject an alternative InputMethodManager @@ -28,13 +28,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::Initialize; -using ::ash::input_method::InitializeForTesting; -using ::ash::input_method::Shutdown; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_INPUT_METHOD_CONFIGURATION_H_
diff --git a/chrome/browser/ash/input_method/input_method_configuration_unittest.cc b/chrome/browser/ash/input_method/input_method_configuration_unittest.cc index b92ccc5..929482a5 100644 --- a/chrome/browser/ash/input_method/input_method_configuration_unittest.cc +++ b/chrome/browser/ash/input_method/input_method_configuration_unittest.cc
@@ -11,6 +11,7 @@ #include "chrome/test/base/testing_browser_process.h" #include "components/session_manager/core/session_manager.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/base/ime/ash/input_method_manager.h" namespace ash { namespace input_method {
diff --git a/chrome/browser/ash/input_method/input_method_manager_impl.h b/chrome/browser/ash/input_method/input_method_manager_impl.h index cddd8f4..04410aae 100644 --- a/chrome/browser/ash/input_method/input_method_manager_impl.h +++ b/chrome/browser/ash/input_method/input_method_manager_impl.h
@@ -20,21 +20,21 @@ #include "chrome/browser/ash/input_method/candidate_window_controller.h" #include "chrome/browser/ash/input_method/ime_service_connector.h" #include "chrome/browser/profiles/profile.h" -// TODO(https://crbug.com/1164001): remove and use forward declaration. -#include "ui/base/ime/ash/component_extension_ime_manager.h" -#include "ui/base/ime/ash/text_input_method.h" -// TODO(https://crbug.com/1164001): remove and use forward declaration. -#include "ui/base/ime/ash/ime_keyboard.h" -// TODO(https://crbug.com/1164001): remove and use forward declaration. -#include "ui/base/ime/ash/input_method_delegate.h" #include "ui/base/ime/ash/input_method_manager.h" #include "ui/base/ime/ash/input_method_util.h" +#include "ui/base/ime/ash/text_input_method.h" namespace ui { class TextInputMethod; } // namespace ui namespace ash { + +class ComponentExtensionIMEManager; +class ComponentExtensionIMEManagerDelegate; +class ImeKeyboard; +class InputMethodDelegate; + namespace ime { struct AssistiveWindow; } // namespace ime @@ -333,11 +333,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::InputMethodManagerImpl; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_INPUT_METHOD_MANAGER_IMPL_H_
diff --git a/chrome/browser/ash/input_method/input_method_persistence.h b/chrome/browser/ash/input_method/input_method_persistence.h index c570c01..7e0e1df 100644 --- a/chrome/browser/ash/input_method/input_method_persistence.h +++ b/chrome/browser/ash/input_method/input_method_persistence.h
@@ -52,11 +52,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::SetUserLastInputMethodPreferenceForTesting; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_INPUT_METHOD_PERSISTENCE_H_
diff --git a/chrome/browser/ash/input_method/mock_input_method_engine.h b/chrome/browser/ash/input_method/mock_input_method_engine.h index d0931f20..5fcb3ea 100644 --- a/chrome/browser/ash/input_method/mock_input_method_engine.h +++ b/chrome/browser/ash/input_method/mock_input_method_engine.h
@@ -69,11 +69,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::MockInputMethodEngine; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_MOCK_INPUT_METHOD_ENGINE_H_
diff --git a/chrome/browser/ash/input_method/mock_input_method_manager_impl.h b/chrome/browser/ash/input_method/mock_input_method_manager_impl.h index 9217949..25a5dc4 100644 --- a/chrome/browser/ash/input_method/mock_input_method_manager_impl.h +++ b/chrome/browser/ash/input_method/mock_input_method_manager_impl.h
@@ -105,11 +105,4 @@ } // namespace input_method } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace input_method { -using ::ash::input_method::MockInputMethodManagerImpl; -} // namespace input_method -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_INPUT_METHOD_MOCK_INPUT_METHOD_MANAGER_IMPL_H_
diff --git a/chrome/browser/ash/kerberos/kerberos_credentials_manager.h b/chrome/browser/ash/kerberos/kerberos_credentials_manager.h index 1f95852..cf9c452 100644 --- a/chrome/browser/ash/kerberos/kerberos_credentials_manager.h +++ b/chrome/browser/ash/kerberos/kerberos_credentials_manager.h
@@ -307,9 +307,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromOS code migration is done. -namespace chromeos { -using ::ash::KerberosCredentialsManager; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_KERBEROS_KERBEROS_CREDENTIALS_MANAGER_H_
diff --git a/chrome/browser/ash/kerberos/kerberos_credentials_manager_factory.h b/chrome/browser/ash/kerberos/kerberos_credentials_manager_factory.h index b3c71ca..d2247b927 100644 --- a/chrome/browser/ash/kerberos/kerberos_credentials_manager_factory.h +++ b/chrome/browser/ash/kerberos/kerberos_credentials_manager_factory.h
@@ -59,9 +59,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromOS code migration is done. -namespace chromeos { -using ::ash::KerberosCredentialsManagerFactory; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_KERBEROS_KERBEROS_CREDENTIALS_MANAGER_FACTORY_H_
diff --git a/chrome/browser/ash/login/screens/reset_screen.cc b/chrome/browser/ash/login/screens/reset_screen.cc index 9ecab69b..f4cdcc9 100644 --- a/chrome/browser/ash/login/screens/reset_screen.cc +++ b/chrome/browser/ash/login/screens/reset_screen.cc
@@ -30,6 +30,7 @@ #include "chrome/common/pref_names.h" #include "chromeos/ash/components/dbus/session_manager/session_manager_client.h" #include "chromeos/ash/components/dbus/update_engine/update_engine_client.h" +#include "chromeos/ash/components/install_attributes/install_attributes.h" #include "chromeos/dbus/power/power_manager_client.h" #include "chromeos/system/statistics_provider.h" #include "components/prefs/pref_registry_simple.h" @@ -125,9 +126,13 @@ void ResetScreen::CheckIfPowerwashAllowed( base::OnceCallback<void(bool, absl::optional<tpm_firmware_update::Mode>)> callback) { - if (g_browser_process->platform_part() - ->browser_policy_connector_ash() - ->IsDeviceEnterpriseManaged()) { + if (InstallAttributes::Get()->IsDeviceLocked()) { + if (!InstallAttributes::Get()->IsEnterpriseManaged()) { + // The consumer owned device is always allowed to powerwash. + std::move(callback).Run(/*is_reset_allowed=*/true, absl::nullopt); + return; + } + // Powerwash is allowed by default, if the policy is loaded. Admin can // explicitly forbid powerwash. If the policy is not loaded yet, we // consider by default that the device is not allowed to powerwash. @@ -135,7 +140,7 @@ CrosSettings::Get()->GetBoolean(kDevicePowerwashAllowed, &is_powerwash_allowed); if (is_powerwash_allowed) { - std::move(callback).Run(true, absl::nullopt); + std::move(callback).Run(/*is_reset_allowed=*/true, absl::nullopt); return; }
diff --git a/chrome/browser/ash/login/screens/reset_screen_unittest.cc b/chrome/browser/ash/login/screens/reset_screen_unittest.cc new file mode 100644 index 0000000..aedbb4ec --- /dev/null +++ b/chrome/browser/ash/login/screens/reset_screen_unittest.cc
@@ -0,0 +1,115 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ash/login/screens/reset_screen.h" + +#include "base/test/test_future.h" +#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h" +#include "chromeos/ash/components/install_attributes/stub_install_attributes.h" +#include "chromeos/ash/components/settings/cros_settings_names.h" +#include "chromeos/system/fake_statistics_provider.h" +#include "content/public/test/browser_task_environment.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace ash { + +namespace { + +const char kEnrollmentDomain[] = "example.com"; +const char kEnrollmentId[] = "fake-id"; + +void ExpectPowerwashAllowed(bool is_reset_allowed) { + base::test::TestFuture<bool, absl::optional<tpm_firmware_update::Mode>> + future; + ResetScreen::CheckIfPowerwashAllowed(future.GetCallback()); + EXPECT_EQ(is_reset_allowed, future.Get<0>()); +} + +} // namespace + +class ResetScreenTest : public testing::Test { + public: + ResetScreenTest(); + + ResetScreenTest(const ResetScreenTest&) = delete; + ResetScreenTest& operator=(const ResetScreenTest&) = delete; + + ~ResetScreenTest() override = default; + + // Configure install attributes. + void SetUnowned(); + void SetEnterpriseOwned(); + void SetConsumerOwned(); + + // Configure policy + void SetPowerwashAllowedByPolicy(bool allowed); + + // Configure VPD values + void SetFreOn(); + void SetFreOff(); + + private: + ScopedCrosSettingsTestHelper cros_settings_test_helper_; + chromeos::system::ScopedFakeStatisticsProvider fake_statistics_provider_; + content::BrowserTaskEnvironment browser_task_environment_; +}; + +ResetScreenTest::ResetScreenTest() { + cros_settings_test_helper_.ReplaceDeviceSettingsProviderWithStub(); +} + +void ResetScreenTest::SetUnowned() { + cros_settings_test_helper_.InstallAttributes()->Clear(); + cros_settings_test_helper_.InstallAttributes()->set_device_locked(false); +} + +void ResetScreenTest::SetEnterpriseOwned() { + cros_settings_test_helper_.InstallAttributes()->SetCloudManaged( + kEnrollmentDomain, kEnrollmentId); +} + +void ResetScreenTest::SetConsumerOwned() { + cros_settings_test_helper_.InstallAttributes()->SetConsumerOwned(); +} + +void ResetScreenTest::SetPowerwashAllowedByPolicy(bool allowed) { + cros_settings_test_helper_.Set(kDevicePowerwashAllowed, base::Value(allowed)); +} + +void ResetScreenTest::SetFreOn() { + fake_statistics_provider_.SetMachineStatistic( + ash::system::kCheckEnrollmentKey, "1"); +} + +void ResetScreenTest::SetFreOff() { + fake_statistics_provider_.SetMachineStatistic( + ash::system::kCheckEnrollmentKey, "0"); +} + +TEST_F(ResetScreenTest, CheckPowerwashAllowedConsumerOwned) { + SetConsumerOwned(); + ExpectPowerwashAllowed(true); +} + +TEST_F(ResetScreenTest, CheckPowerwashAllowedOnEnrolledDevice) { + SetEnterpriseOwned(); + + SetPowerwashAllowedByPolicy(true); + ExpectPowerwashAllowed(true); + + SetPowerwashAllowedByPolicy(false); + ExpectPowerwashAllowed(false); +} + +TEST_F(ResetScreenTest, CheckPowerwashAllowedNotOwned) { + SetUnowned(); + + SetFreOn(); + ExpectPowerwashAllowed(false); + + SetFreOff(); + ExpectPowerwashAllowed(true); +} + +} // namespace ash
diff --git a/chrome/browser/ash/nearby/nearby_dependencies_provider_factory.h b/chrome/browser/ash/nearby/nearby_dependencies_provider_factory.h index 22680a6..c9ee5f4 100644 --- a/chrome/browser/ash/nearby/nearby_dependencies_provider_factory.h +++ b/chrome/browser/ash/nearby/nearby_dependencies_provider_factory.h
@@ -40,9 +40,4 @@ } // namespace ash::nearby -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos::nearby { -using ::ash::nearby::NearbyDependenciesProviderFactory; -} // namespace chromeos::nearby - #endif // CHROME_BROWSER_ASH_NEARBY_NEARBY_DEPENDENCIES_PROVIDER_FACTORY_H_
diff --git a/chrome/browser/ash/nearby/nearby_process_manager_factory.h b/chrome/browser/ash/nearby/nearby_process_manager_factory.h index aa5ba20..eb62628 100644 --- a/chrome/browser/ash/nearby/nearby_process_manager_factory.h +++ b/chrome/browser/ash/nearby/nearby_process_manager_factory.h
@@ -49,11 +49,4 @@ } // namespace nearby } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -namespace nearby { -using ::ash::nearby::NearbyProcessManagerFactory; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_NEARBY_NEARBY_PROCESS_MANAGER_FACTORY_H_
diff --git a/chrome/browser/ash/net/client_cert_store_ash.h b/chrome/browser/ash/net/client_cert_store_ash.h index dbbe98e..e7d6845 100644 --- a/chrome/browser/ash/net/client_cert_store_ash.h +++ b/chrome/browser/ash/net/client_cert_store_ash.h
@@ -65,9 +65,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::ClientCertStoreAsh; -} - #endif // CHROME_BROWSER_ASH_NET_CLIENT_CERT_STORE_ASH_H_
diff --git a/chrome/browser/ash/net/network_portal_detector_test_impl.h b/chrome/browser/ash/net/network_portal_detector_test_impl.h index 053356c2..d35a40332 100644 --- a/chrome/browser/ash/net/network_portal_detector_test_impl.h +++ b/chrome/browser/ash/net/network_portal_detector_test_impl.h
@@ -48,9 +48,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::NetworkPortalDetectorTestImpl; -} - #endif // CHROME_BROWSER_ASH_NET_NETWORK_PORTAL_DETECTOR_TEST_IMPL_H_
diff --git a/chrome/browser/ash/note_taking_helper.h b/chrome/browser/ash/note_taking_helper.h index 4965195c..ad464d3 100644 --- a/chrome/browser/ash/note_taking_helper.h +++ b/chrome/browser/ash/note_taking_helper.h
@@ -266,10 +266,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::NoteTakingAppInfo; -using ::ash::NoteTakingHelper; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_NOTE_TAKING_HELPER_H_
diff --git a/chrome/browser/ash/ownership/fake_owner_settings_service.h b/chrome/browser/ash/ownership/fake_owner_settings_service.h index 7505ce40..30bb6e2 100644 --- a/chrome/browser/ash/ownership/fake_owner_settings_service.h +++ b/chrome/browser/ash/ownership/fake_owner_settings_service.h
@@ -52,10 +52,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after //chrome/browser/chromeos -// source migration is finished. -namespace chromeos { -using ::ash::FakeOwnerSettingsService; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_OWNERSHIP_FAKE_OWNER_SETTINGS_SERVICE_H_
diff --git a/chrome/browser/ash/ownership/owner_settings_service_ash.h b/chrome/browser/ash/ownership/owner_settings_service_ash.h index 502828e..3bcfe86 100644 --- a/chrome/browser/ash/ownership/owner_settings_service_ash.h +++ b/chrome/browser/ash/ownership/owner_settings_service_ash.h
@@ -220,10 +220,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after //chrome/browser/chromeos -// source migration is finished. -namespace chromeos { -using ::ash::OwnerSettingsServiceAsh; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_OWNERSHIP_OWNER_SETTINGS_SERVICE_ASH_H_
diff --git a/chrome/browser/ash/ownership/owner_settings_service_ash_factory.h b/chrome/browser/ash/ownership/owner_settings_service_ash_factory.h index a365f50..085704d 100644 --- a/chrome/browser/ash/ownership/owner_settings_service_ash_factory.h +++ b/chrome/browser/ash/ownership/owner_settings_service_ash_factory.h
@@ -64,10 +64,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after //chrome/browser/chromeos -// source migration is finished. -namespace chromeos { -using ::ash::OwnerSettingsServiceAshFactory; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_OWNERSHIP_OWNER_SETTINGS_SERVICE_ASH_FACTORY_H_
diff --git a/chrome/browser/ash/phonehub/phone_hub_manager_factory.cc b/chrome/browser/ash/phonehub/phone_hub_manager_factory.cc index 625c01e..c23c3682 100644 --- a/chrome/browser/ash/phonehub/phone_hub_manager_factory.cc +++ b/chrome/browser/ash/phonehub/phone_hub_manager_factory.cc
@@ -8,6 +8,7 @@ #include "ash/components/phonehub/multidevice_feature_access_manager_impl.h" #include "ash/components/phonehub/multidevice_setup_state_updater.h" #include "ash/components/phonehub/onboarding_ui_tracker_impl.h" +#include "ash/components/phonehub/phone_hub_manager.h" #include "ash/components/phonehub/phone_hub_manager_impl.h" #include "ash/components/phonehub/recent_apps_interaction_handler_impl.h" #include "ash/components/phonehub/screen_lock_manager_impl.h" @@ -34,6 +35,7 @@ namespace ash { namespace phonehub { + namespace { content::BrowserContext* g_context_for_service = nullptr;
diff --git a/chrome/browser/ash/phonehub/phone_hub_manager_factory.h b/chrome/browser/ash/phonehub/phone_hub_manager_factory.h index 407025c..43f7836 100644 --- a/chrome/browser/ash/phonehub/phone_hub_manager_factory.h +++ b/chrome/browser/ash/phonehub/phone_hub_manager_factory.h
@@ -6,8 +6,6 @@ #define CHROME_BROWSER_ASH_PHONEHUB_PHONE_HUB_MANAGER_FACTORY_H_ #include "base/memory/singleton.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "ash/components/phonehub/phone_hub_manager.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h" class Profile; @@ -15,6 +13,8 @@ namespace ash { namespace phonehub { +class PhoneHubManager; + class PhoneHubManagerFactory : public ProfileKeyedServiceFactory { public: // Returns the PhoneHubManager instance associated with |profile|. Null is @@ -45,12 +45,4 @@ } // namespace phonehub } // namespace ash -// TODO(https://crbug.com/1164001): remove after the //chrome/browser/chromeos -// source migration is finished. -namespace chromeos { -namespace phonehub { -using ::ash::phonehub::PhoneHubManagerFactory; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PHONEHUB_PHONE_HUB_MANAGER_FACTORY_H_
diff --git a/chrome/browser/ash/platform_keys/platform_keys_service_factory.cc b/chrome/browser/ash/platform_keys/platform_keys_service_factory.cc index e50276c..2ed12f95 100644 --- a/chrome/browser/ash/platform_keys/platform_keys_service_factory.cc +++ b/chrome/browser/ash/platform_keys/platform_keys_service_factory.cc
@@ -28,9 +28,6 @@ namespace { -// TODO(https://crbug.com/1164001): remove when migrated to ash. -using ::chromeos::ClientCertStoreAsh; - // Invoked on the IO thread when a NSSCertDatabase is available, delegates back // to origin thread. void DidGetCertDbOnIoThread(
diff --git a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc index 185c759e..33d2624 100644 --- a/chrome/browser/ash/policy/core/device_local_account_browsertest.cc +++ b/chrome/browser/ash/policy/core/device_local_account_browsertest.cc
@@ -1673,30 +1673,30 @@ timezone_settings->SetTimezoneFromID(timezone_id1); SetSystemTimezoneAutomaticDetectionPolicy(em::SystemTimezoneProto::DISABLED); - chromeos::system::SetSystemTimezone(user, timezone_id2); + ash::system::SetSystemTimezone(user, timezone_id2); EXPECT_EQ(timezone_settings->GetCurrentTimezoneID(), timezone_id2_utf16); timezone_settings->SetTimezoneFromID(timezone_id1); SetSystemTimezoneAutomaticDetectionPolicy( em::SystemTimezoneProto::USERS_DECIDE); - chromeos::system::SetSystemTimezone(user, timezone_id2); + ash::system::SetSystemTimezone(user, timezone_id2); EXPECT_EQ(timezone_settings->GetCurrentTimezoneID(), timezone_id2_utf16); timezone_settings->SetTimezoneFromID(timezone_id1); SetSystemTimezoneAutomaticDetectionPolicy(em::SystemTimezoneProto::IP_ONLY); - chromeos::system::SetSystemTimezone(user, timezone_id2); + ash::system::SetSystemTimezone(user, timezone_id2); EXPECT_NE(timezone_settings->GetCurrentTimezoneID(), timezone_id2_utf16); timezone_settings->SetTimezoneFromID(timezone_id1); SetSystemTimezoneAutomaticDetectionPolicy( em::SystemTimezoneProto::SEND_WIFI_ACCESS_POINTS); - chromeos::system::SetSystemTimezone(user, timezone_id2); + ash::system::SetSystemTimezone(user, timezone_id2); EXPECT_NE(timezone_settings->GetCurrentTimezoneID(), timezone_id2_utf16); timezone_settings->SetTimezoneFromID(timezone_id1); SetSystemTimezoneAutomaticDetectionPolicy( em::SystemTimezoneProto::SEND_ALL_LOCATION_INFO); - chromeos::system::SetSystemTimezone(user, timezone_id2); + ash::system::SetSystemTimezone(user, timezone_id2); EXPECT_NE(timezone_settings->GetCurrentTimezoneID(), timezone_id2_utf16); }
diff --git a/chrome/browser/ash/policy/handlers/system_proxy_handler.h b/chrome/browser/ash/policy/handlers/system_proxy_handler.h index fb86c8c..0514d91 100644 --- a/chrome/browser/ash/policy/handlers/system_proxy_handler.h +++ b/chrome/browser/ash/policy/handlers/system_proxy_handler.h
@@ -18,7 +18,7 @@ // proxy credentials for system services connecting through System-proxy. class SystemProxyHandler { public: - explicit SystemProxyHandler(chromeos::CrosSettings* cros_settings); + explicit SystemProxyHandler(ash::CrosSettings* cros_settings); SystemProxyHandler(const SystemProxyHandler&) = delete; SystemProxyHandler& operator=(const SystemProxyHandler&) = delete; @@ -35,7 +35,7 @@ // Owned by the test fixture. ash::SystemProxyManager* system_proxy_manager_for_testing_ = nullptr; - chromeos::CrosSettings* cros_settings_; + ash::CrosSettings* cros_settings_; base::CallbackListSubscription system_proxy_subscription_; };
diff --git a/chrome/browser/ash/policy/handlers/system_proxy_handler_unittest.cc b/chrome/browser/ash/policy/handlers/system_proxy_handler_unittest.cc index f6f7570..23799e3 100644 --- a/chrome/browser/ash/policy/handlers/system_proxy_handler_unittest.cc +++ b/chrome/browser/ash/policy/handlers/system_proxy_handler_unittest.cc
@@ -106,7 +106,7 @@ std::unique_ptr<ash::NetworkHandlerTestHelper> network_handler_test_helper_; ScopedTestingLocalState local_state_; std::unique_ptr<TestingProfile> profile_; - chromeos::ScopedTestingCrosSettings scoped_testing_cros_settings_; + ash::ScopedTestingCrosSettings scoped_testing_cros_settings_; ash::ScopedDeviceSettingsTestHelper device_settings_test_helper_; ash::ScopedStubInstallAttributes test_install_attributes_; std::unique_ptr<SystemProxyHandler> system_proxy_handler_;
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_run_routine_job.cc b/chrome/browser/ash/policy/remote_commands/device_command_run_routine_job.cc index a805895..c295903 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_run_routine_job.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_run_routine_job.cc
@@ -513,6 +513,10 @@ target_state.value_or(true), std::move(response_callback)); break; } + case ash::cros_healthd::mojom::DiagnosticRoutineEnum::kLedLitUp: { + NOTIMPLEMENTED(); + break; + } } }
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job.cc b/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job.cc index 4b2ed90..bf094e05 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job.cc
@@ -46,12 +46,12 @@ // to log out only after the server got the ACK, otherwise we could log out // before ACKing and then the server would never get the ACK. service_->SetOnCommandAckedCallback( - base::BindOnce(&chromeos::user_removal_manager::LogOut)); + base::BindOnce(&ash::user_removal_manager::LogOut)); // Initiate the user removal process. Once the first part is done, the passed // callback gets called and signals that the command was successfully received // and will be executed. - chromeos::user_removal_manager::InitiateUserRemoval( + ash::user_removal_manager::InitiateUserRemoval( base::BindOnce(std::move(succeeded_callback), nullptr)); }
diff --git a/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job_unittest.cc b/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job_unittest.cc index 72deb43..84d2069 100644 --- a/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job_unittest.cc +++ b/chrome/browser/ash/policy/remote_commands/device_command_wipe_users_job_unittest.cc
@@ -161,7 +161,7 @@ run_loop->Quit(); }, &run_loop2, &log_out_called); - chromeos::user_removal_manager::OverrideLogOutForTesting( + ash::user_removal_manager::OverrideLogOutForTesting( std::move(log_out_callback)); base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
diff --git a/chrome/browser/ash/policy/reporting/metrics_reporting/usb/usb_events_browsertest.cc b/chrome/browser/ash/policy/reporting/metrics_reporting/usb/usb_events_browsertest.cc index 6150af7..002b2cc 100644 --- a/chrome/browser/ash/policy/reporting/metrics_reporting/usb/usb_events_browsertest.cc +++ b/chrome/browser/ash/policy/reporting/metrics_reporting/usb/usb_events_browsertest.cc
@@ -29,7 +29,7 @@ #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -namespace chromeos { +namespace reporting { namespace { namespace cros_healthd = ::ash::cros_healthd; @@ -78,9 +78,9 @@ ash::kReportDevicePeripherals, false); } - bool NoUsbEventsEnqueued(const std::vector<::reporting::Record>& records) { - return !base::Contains(records, ::reporting::Destination::PERIPHERAL_EVENTS, - &::reporting::Record::destination); + bool NoUsbEventsEnqueued(const std::vector<Record>& records) { + return !base::Contains(records, Destination::PERIPHERAL_EVENTS, + &Record::destination); } void LoginAffiliatedUser() { @@ -134,7 +134,7 @@ ash::FakeGaiaMixin fake_gaia_mixin_{&mixin_host_}; ash::LoginManagerMixin login_manager_mixin_{ &mixin_host_, ash::LoginManagerMixin::UserList(), &fake_gaia_mixin_}; - ScopedTestingCrosSettings scoped_testing_cros_settings_; + ash::ScopedTestingCrosSettings scoped_testing_cros_settings_; }; IN_PROC_BROWSER_TEST_F( @@ -145,21 +145,21 @@ LoginAffiliatedUser(); chromeos::MissiveClientTestObserver missive_observer_( - ::reporting::Destination::PERIPHERAL_EVENTS); + Destination::PERIPHERAL_EVENTS); cros_healthd::FakeCrosHealthd::Get()->EmitUsbAddEventForTesting(); - std::tuple<::reporting::Priority, ::reporting::Record> entry = + std::tuple<Priority, Record> entry = missive_observer_.GetNextEnqueuedRecord(); - ::reporting::Record record = std::get<1>(entry); - ::reporting::MetricData record_data; + Record record = std::get<1>(entry); + MetricData record_data; ASSERT_TRUE(record_data.ParseFromString(record.data())); EXPECT_TRUE(record_data.has_telemetry_data()); EXPECT_TRUE(record_data.telemetry_data().has_peripherals_telemetry()); EXPECT_THAT(record_data.event_data().type(), - ::testing::Eq(::reporting::MetricEventType::USB_ADDED)); + ::testing::Eq(MetricEventType::USB_ADDED)); EXPECT_THAT(record.destination(), - ::testing::Eq(reporting::Destination::PERIPHERAL_EVENTS)); + ::testing::Eq(Destination::PERIPHERAL_EVENTS)); ASSERT_TRUE(record.has_dm_token()); EXPECT_THAT(record.dm_token(), ::testing::StrEq(kDMToken)); } @@ -170,7 +170,7 @@ EnableUsbPolicy(); chromeos::MissiveClientTestObserver missive_observer_( - ::reporting::Destination::PERIPHERAL_EVENTS); + Destination::PERIPHERAL_EVENTS); auto usb_telemetry = CreateUsbTelemetry(); cros_healthd::FakeCrosHealthd::Get()->SetProbeTelemetryInfoResponseForTesting( @@ -179,10 +179,10 @@ // This triggers USB telemetry collection, a.k.a USB status updates LoginAffiliatedUser(); - std::tuple<::reporting::Priority, ::reporting::Record> entry = + std::tuple<Priority, Record> entry = missive_observer_.GetNextEnqueuedRecord(); - ::reporting::Record record = std::get<1>(entry); - ::reporting::MetricData record_data; + Record record = std::get<1>(entry); + MetricData record_data; ASSERT_TRUE(record_data.ParseFromString(record.data())); EXPECT_TRUE(record_data.has_telemetry_data()); @@ -190,11 +190,10 @@ // Even though USB status updates are triggered by affiliated login, they're // technically telemetry, not events, so their event type is // EVENT_TYPE_UNSPECIFIED - EXPECT_THAT( - record_data.event_data().type(), - ::testing::Eq(::reporting::MetricEventType::EVENT_TYPE_UNSPECIFIED)); + EXPECT_THAT(record_data.event_data().type(), + ::testing::Eq(MetricEventType::EVENT_TYPE_UNSPECIFIED)); EXPECT_THAT(record.destination(), - ::testing::Eq(::reporting::Destination::PERIPHERAL_EVENTS)); + ::testing::Eq(Destination::PERIPHERAL_EVENTS)); ASSERT_TRUE(record.has_dm_token()); EXPECT_THAT(record.dm_token(), ::testing::StrEq(kDMToken)); } @@ -205,14 +204,14 @@ EnableUsbPolicy(); chromeos::MissiveClientTestObserver missive_observer_( - ::reporting::Destination::PERIPHERAL_EVENTS); + Destination::PERIPHERAL_EVENTS); LoginUnaffiliatedUser(); cros_healthd::FakeCrosHealthd::Get()->EmitUsbAddEventForTesting(); EXPECT_TRUE(NoUsbEventsEnqueued( chromeos::MissiveClient::Get()->GetTestInterface()->GetEnqueuedRecords( - ::reporting::Priority::SECURITY))); + Priority::SECURITY))); } IN_PROC_BROWSER_TEST_F( @@ -227,7 +226,7 @@ // Shouldn't be any USB event related records in the MissiveClient queue EXPECT_TRUE(NoUsbEventsEnqueued( chromeos::MissiveClient::Get()->GetTestInterface()->GetEnqueuedRecords( - ::reporting::Priority::SECURITY))); + Priority::SECURITY))); } IN_PROC_BROWSER_TEST_F( @@ -242,8 +241,8 @@ // Shouldn't be any USB event related records in the MissiveClient queue EXPECT_TRUE(NoUsbEventsEnqueued( chromeos::MissiveClient::Get()->GetTestInterface()->GetEnqueuedRecords( - ::reporting::Priority::SECURITY))); + Priority::SECURITY))); } } // namespace -} // namespace chromeos +} // namespace reporting
diff --git a/chrome/browser/ash/policy/reporting/user_event_reporter_helper.cc b/chrome/browser/ash/policy/reporting/user_event_reporter_helper.cc index 82c0925..f1ed307 100644 --- a/chrome/browser/ash/policy/reporting/user_event_reporter_helper.cc +++ b/chrome/browser/ash/policy/reporting/user_event_reporter_helper.cc
@@ -38,7 +38,7 @@ const std::string& policy_path) const { DCHECK_CURRENTLY_ON(::content::BrowserThread::UI); bool enabled = false; - chromeos::CrosSettings::Get()->GetBoolean(policy_path, &enabled); + ash::CrosSettings::Get()->GetBoolean(policy_path, &enabled); return enabled; }
diff --git a/chrome/browser/ash/power/cpu_data_collector.h b/chrome/browser/ash/power/cpu_data_collector.h index 834a4be3..e7ddcd9b 100644 --- a/chrome/browser/ash/power/cpu_data_collector.h +++ b/chrome/browser/ash/power/cpu_data_collector.h
@@ -146,9 +146,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::CpuDataCollector; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_CPU_DATA_COLLECTOR_H_
diff --git a/chrome/browser/ash/power/freezer_cgroup_process_manager.h b/chrome/browser/ash/power/freezer_cgroup_process_manager.h index fd85057..d47a46f 100644 --- a/chrome/browser/ash/power/freezer_cgroup_process_manager.h +++ b/chrome/browser/ash/power/freezer_cgroup_process_manager.h
@@ -45,9 +45,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::FreezerCgroupProcessManager; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_FREEZER_CGROUP_PROCESS_MANAGER_H_
diff --git a/chrome/browser/ash/power/ml/boot_clock.h b/chrome/browser/ash/power/ml/boot_clock.h index daeee99e..26f8ab2c5 100644 --- a/chrome/browser/ash/power/ml/boot_clock.h +++ b/chrome/browser/ash/power/ml/boot_clock.h
@@ -38,13 +38,4 @@ } // namespace power } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace power { -namespace ml { -using ::ash::power::ml::BootClock; -} // namespace ml -} // namespace power -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_ML_BOOT_CLOCK_H_
diff --git a/chrome/browser/ash/power/ml/recent_events_counter.h b/chrome/browser/ash/power/ml/recent_events_counter.h index 3965471..7da2cb9 100644 --- a/chrome/browser/ash/power/ml/recent_events_counter.h +++ b/chrome/browser/ash/power/ml/recent_events_counter.h
@@ -72,13 +72,4 @@ } // namespace power } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace power { -namespace ml { -using ::ash::power::ml::RecentEventsCounter; -} // namespace ml -} // namespace power -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_ML_RECENT_EVENTS_COUNTER_H_
diff --git a/chrome/browser/ash/power/ml/user_activity_controller.h b/chrome/browser/ash/power/ml/user_activity_controller.h index 96cf346..ab7a894 100644 --- a/chrome/browser/ash/power/ml/user_activity_controller.h +++ b/chrome/browser/ash/power/ml/user_activity_controller.h
@@ -42,13 +42,4 @@ } // namespace power } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace power { -namespace ml { -using ::ash::power::ml::UserActivityController; -} // namespace ml -} // namespace power -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_ML_USER_ACTIVITY_CONTROLLER_H_
diff --git a/chrome/browser/ash/power/power_data_collector.h b/chrome/browser/ash/power/power_data_collector.h index b433c54f..e9f1ef83 100644 --- a/chrome/browser/ash/power/power_data_collector.h +++ b/chrome/browser/ash/power/power_data_collector.h
@@ -118,9 +118,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::PowerDataCollector; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_POWER_DATA_COLLECTOR_H_
diff --git a/chrome/browser/ash/power/process_data_collector.h b/chrome/browser/ash/power/process_data_collector.h index 249c0d5..3a3da24 100644 --- a/chrome/browser/ash/power/process_data_collector.h +++ b/chrome/browser/ash/power/process_data_collector.h
@@ -331,9 +331,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::ProcessDataCollector; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_POWER_PROCESS_DATA_COLLECTOR_H_
diff --git a/chrome/browser/ash/printing/cups_printers_manager.h b/chrome/browser/ash/printing/cups_printers_manager.h index 21c623fc..c84ea4cd 100644 --- a/chrome/browser/ash/printing/cups_printers_manager.h +++ b/chrome/browser/ash/printing/cups_printers_manager.h
@@ -137,10 +137,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ::ash::CupsPrintersManager; -using ::ash::IsIppUri; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_CUPS_PRINTERS_MANAGER_H_
diff --git a/chrome/browser/ash/printing/cups_printers_manager_factory.h b/chrome/browser/ash/printing/cups_printers_manager_factory.h index 7084814..b92295a 100644 --- a/chrome/browser/ash/printing/cups_printers_manager_factory.h +++ b/chrome/browser/ash/printing/cups_printers_manager_factory.h
@@ -55,9 +55,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ::ash::CupsPrintersManagerFactory; -} - #endif // CHROME_BROWSER_ASH_PRINTING_CUPS_PRINTERS_MANAGER_FACTORY_H_
diff --git a/chrome/browser/ash/printing/history/print_job_info_proto_conversions.h b/chrome/browser/ash/printing/history/print_job_info_proto_conversions.h index 0a8afb8..5f30a216 100644 --- a/chrome/browser/ash/printing/history/print_job_info_proto_conversions.h +++ b/chrome/browser/ash/printing/history/print_job_info_proto_conversions.h
@@ -24,9 +24,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ash::PrintSettingsToProto; -} - #endif // CHROME_BROWSER_ASH_PRINTING_HISTORY_PRINT_JOB_INFO_PROTO_CONVERSIONS_H_
diff --git a/chrome/browser/ash/printing/history/test_print_job_database.h b/chrome/browser/ash/printing/history/test_print_job_database.h index b231073..8653332 100644 --- a/chrome/browser/ash/printing/history/test_print_job_database.h +++ b/chrome/browser/ash/printing/history/test_print_job_database.h
@@ -38,9 +38,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::TestPrintJobDatabase; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_HISTORY_TEST_PRINT_JOB_DATABASE_H_
diff --git a/chrome/browser/ash/printing/ppd_provider_factory.h b/chrome/browser/ash/printing/ppd_provider_factory.h index 7187394..203c093 100644 --- a/chrome/browser/ash/printing/ppd_provider_factory.h +++ b/chrome/browser/ash/printing/ppd_provider_factory.h
@@ -19,9 +19,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::CreatePpdProvider; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_PPD_PROVIDER_FACTORY_H_
diff --git a/chrome/browser/ash/printing/printer_configurer.h b/chrome/browser/ash/printing/printer_configurer.h index bb510db..f03e497 100644 --- a/chrome/browser/ash/printing/printer_configurer.h +++ b/chrome/browser/ash/printing/printer_configurer.h
@@ -108,11 +108,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ::ash::PrinterConfigurer; -using ::ash::PrinterSetupResult; -using ::ash::UsbPrinterSetupSource; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_PRINTER_CONFIGURER_H_
diff --git a/chrome/browser/ash/printing/printer_detector.h b/chrome/browser/ash/printing/printer_detector.h index a394b775..5831102 100644 --- a/chrome/browser/ash/printing/printer_detector.h +++ b/chrome/browser/ash/printing/printer_detector.h
@@ -52,9 +52,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ::ash::PrinterDetector; -} - #endif // CHROME_BROWSER_ASH_PRINTING_PRINTER_DETECTOR_H_
diff --git a/chrome/browser/ash/printing/printer_event_tracker_factory.h b/chrome/browser/ash/printing/printer_event_tracker_factory.h index 1804ddc..96925d4c 100644 --- a/chrome/browser/ash/printing/printer_event_tracker_factory.h +++ b/chrome/browser/ash/printing/printer_event_tracker_factory.h
@@ -40,9 +40,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::PrinterEventTrackerFactory; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_PRINTER_EVENT_TRACKER_FACTORY_H_
diff --git a/chrome/browser/ash/printing/printing_stubs.h b/chrome/browser/ash/printing/printing_stubs.h index 902fee39c..73a2ab5 100644 --- a/chrome/browser/ash/printing/printing_stubs.h +++ b/chrome/browser/ash/printing/printing_stubs.h
@@ -49,10 +49,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when the migration is finished. -namespace chromeos { -using ::ash::StubCupsPrintersManager; -using ::ash::StubPrinterConfigurer; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_PRINTING_STUBS_H_
diff --git a/chrome/browser/ash/printing/server_printers_fetcher.h b/chrome/browser/ash/printing/server_printers_fetcher.h index a22b16cc..01a056cb 100644 --- a/chrome/browser/ash/printing/server_printers_fetcher.h +++ b/chrome/browser/ash/printing/server_printers_fetcher.h
@@ -65,10 +65,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -using ::ash::PrintServerQueryResult; -using ::ash::ServerPrintersFetcher; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_PRINTING_SERVER_PRINTERS_FETCHER_H_
diff --git a/chrome/browser/ash/release_notes/release_notes_notification.h b/chrome/browser/ash/release_notes/release_notes_notification.h index 623de68b..193add71 100644 --- a/chrome/browser/ash/release_notes/release_notes_notification.h +++ b/chrome/browser/ash/release_notes/release_notes_notification.h
@@ -55,9 +55,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromOS code migration is done. -namespace chromeos { -using ::ash::ReleaseNotesNotification; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_RELEASE_NOTES_RELEASE_NOTES_NOTIFICATION_H_
diff --git a/chrome/browser/ash/secure_channel/nearby_connector_factory.cc b/chrome/browser/ash/secure_channel/nearby_connector_factory.cc index b6d82be..7c21ed9 100644 --- a/chrome/browser/ash/secure_channel/nearby_connector_factory.cc +++ b/chrome/browser/ash/secure_channel/nearby_connector_factory.cc
@@ -8,6 +8,7 @@ #include "chrome/browser/ash/secure_channel/nearby_connector_impl.h" #include "chrome/browser/ash/secure_channel/secure_channel_client_provider.h" #include "chrome/browser/profiles/profile.h" +#include "chromeos/ash/services/secure_channel/public/cpp/client/nearby_connector.h" #include "chromeos/ash/services/secure_channel/public/cpp/client/secure_channel_client.h" namespace ash {
diff --git a/chrome/browser/ash/secure_channel/nearby_connector_factory.h b/chrome/browser/ash/secure_channel/nearby_connector_factory.h index 2c2e757..bf14d781 100644 --- a/chrome/browser/ash/secure_channel/nearby_connector_factory.h +++ b/chrome/browser/ash/secure_channel/nearby_connector_factory.h
@@ -7,14 +7,14 @@ #include "base/memory/singleton.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/ash/services/secure_channel/public/cpp/client/nearby_connector.h" class Profile; namespace ash { namespace secure_channel { +class NearbyConnector; + class NearbyConnectorFactory : public ProfileKeyedServiceFactory { public: static NearbyConnector* GetForProfile(Profile* profile); @@ -38,11 +38,4 @@ } // namespace secure_channel } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -namespace secure_channel { -using ::ash::secure_channel::NearbyConnectorFactory; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SECURE_CHANNEL_NEARBY_CONNECTOR_FACTORY_H_
diff --git a/chrome/browser/ash/secure_channel/secure_channel_client_provider.cc b/chrome/browser/ash/secure_channel/secure_channel_client_provider.cc index efc37f6..bbf81b9 100644 --- a/chrome/browser/ash/secure_channel/secure_channel_client_provider.cc +++ b/chrome/browser/ash/secure_channel/secure_channel_client_provider.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ash/secure_channel/secure_channel_client_provider.h" #include "base/no_destructor.h" +#include "chromeos/ash/services/secure_channel/public/cpp/client/secure_channel_client.h" #include "chromeos/ash/services/secure_channel/public/cpp/client/secure_channel_client_impl.h" #include "chromeos/ash/services/secure_channel/secure_channel_base.h" #include "chromeos/ash/services/secure_channel/secure_channel_initializer.h"
diff --git a/chrome/browser/ash/secure_channel/secure_channel_client_provider.h b/chrome/browser/ash/secure_channel/secure_channel_client_provider.h index 22f7a45d..8514c7a 100644 --- a/chrome/browser/ash/secure_channel/secure_channel_client_provider.h +++ b/chrome/browser/ash/secure_channel/secure_channel_client_provider.h
@@ -8,12 +8,12 @@ #include <memory> #include "base/no_destructor.h" -// TODO(https://crbug.com/1164001): move to forward declaration. -#include "chromeos/ash/services/secure_channel/public/cpp/client/secure_channel_client.h" namespace ash { namespace secure_channel { +class SecureChannelClient; + // Singleton that owns a single SecureChannelClient instance associated with the // browser process. class SecureChannelClientProvider { @@ -38,12 +38,4 @@ } // namespace secure_channel } // namespace ash -// TODO(https://crbug.com/1164001): remove after the //chrome/browser/chromeos -// source migration is finished. -namespace chromeos { -namespace secure_channel { -using ::ash::secure_channel::SecureChannelClientProvider; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SECURE_CHANNEL_SECURE_CHANNEL_CLIENT_PROVIDER_H_
diff --git a/chrome/browser/ash/set_time_dialog.h b/chrome/browser/ash/set_time_dialog.h index 8cd20ac5..2c2dc6f 100644 --- a/chrome/browser/ash/set_time_dialog.h +++ b/chrome/browser/ash/set_time_dialog.h
@@ -33,9 +33,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::SetTimeDialog; -} - #endif // CHROME_BROWSER_ASH_SET_TIME_DIALOG_H_
diff --git a/chrome/browser/ash/settings/about_flags.h b/chrome/browser/ash/settings/about_flags.h index 5e5da52..5471a70 100644 --- a/chrome/browser/ash/settings/about_flags.h +++ b/chrome/browser/ash/settings/about_flags.h
@@ -95,13 +95,4 @@ } // namespace about_flags } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace about_flags { -using ::ash::about_flags::OwnerFlagsStorage; -using ::ash::about_flags::ReadOnlyFlagsStorage; -} // namespace about_flags -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_ABOUT_FLAGS_H_
diff --git a/chrome/browser/ash/settings/device_settings_provider.h b/chrome/browser/ash/settings/device_settings_provider.h index f0ea7c2..356b72c9 100644 --- a/chrome/browser/ash/settings/device_settings_provider.h +++ b/chrome/browser/ash/settings/device_settings_provider.h
@@ -158,10 +158,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::DeviceSettingsProvider; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_DEVICE_SETTINGS_PROVIDER_H_
diff --git a/chrome/browser/ash/settings/device_settings_service.h b/chrome/browser/ash/settings/device_settings_service.h index 314bb3f..71b6907 100644 --- a/chrome/browser/ash/settings/device_settings_service.h +++ b/chrome/browser/ash/settings/device_settings_service.h
@@ -327,15 +327,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::DeviceSettingsService; -} // namespace chromeos - -// TODO(https://crbug.com/1164001): remove once the migration is finished. -namespace ash { -using ::chromeos::DeviceSettingsService; -} - #endif // CHROME_BROWSER_ASH_SETTINGS_DEVICE_SETTINGS_SERVICE_H_
diff --git a/chrome/browser/ash/settings/device_settings_test_helper.h b/chrome/browser/ash/settings/device_settings_test_helper.h index a8e1f977..f1f4f138 100644 --- a/chrome/browser/ash/settings/device_settings_test_helper.h +++ b/chrome/browser/ash/settings/device_settings_test_helper.h
@@ -92,11 +92,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::DeviceSettingsTestBase; -using ::ash::ScopedDeviceSettingsTestHelper; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_DEVICE_SETTINGS_TEST_HELPER_H_
diff --git a/chrome/browser/ash/settings/hardware_data_usage_controller.h b/chrome/browser/ash/settings/hardware_data_usage_controller.h index d260cb7..80dca34a 100644 --- a/chrome/browser/ash/settings/hardware_data_usage_controller.h +++ b/chrome/browser/ash/settings/hardware_data_usage_controller.h
@@ -34,10 +34,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::HWDataUsageController; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_HARDWARE_DATA_USAGE_CONTROLLER_H_
diff --git a/chrome/browser/ash/settings/scoped_testing_cros_settings.h b/chrome/browser/ash/settings/scoped_testing_cros_settings.h index e27a91a..473dd6e 100644 --- a/chrome/browser/ash/settings/scoped_testing_cros_settings.h +++ b/chrome/browser/ash/settings/scoped_testing_cros_settings.h
@@ -53,10 +53,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::ScopedTestingCrosSettings; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_SCOPED_TESTING_CROS_SETTINGS_H_
diff --git a/chrome/browser/ash/settings/stats_reporting_controller.h b/chrome/browser/ash/settings/stats_reporting_controller.h index fe680ab..53ccd25 100644 --- a/chrome/browser/ash/settings/stats_reporting_controller.h +++ b/chrome/browser/ash/settings/stats_reporting_controller.h
@@ -47,10 +47,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::StatsReportingController; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_STATS_REPORTING_CONTROLLER_H_
diff --git a/chrome/browser/ash/settings/stub_cros_settings_provider.h b/chrome/browser/ash/settings/stub_cros_settings_provider.h index 0345a91..68b4e08 100644 --- a/chrome/browser/ash/settings/stub_cros_settings_provider.h +++ b/chrome/browser/ash/settings/stub_cros_settings_provider.h
@@ -66,10 +66,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::StubCrosSettingsProvider; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_STUB_CROS_SETTINGS_PROVIDER_H_
diff --git a/chrome/browser/ash/settings/token_encryptor.h b/chrome/browser/ash/settings/token_encryptor.h index 9629010..17abb1b 100644 --- a/chrome/browser/ash/settings/token_encryptor.h +++ b/chrome/browser/ash/settings/token_encryptor.h
@@ -74,10 +74,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::CryptohomeTokenEncryptor; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SETTINGS_TOKEN_ENCRYPTOR_H_
diff --git a/chrome/browser/ash/smb_client/smb_errors.h b/chrome/browser/ash/smb_client/smb_errors.h index 5be836e9..9f23df6 100644 --- a/chrome/browser/ash/smb_client/smb_errors.h +++ b/chrome/browser/ash/smb_client/smb_errors.h
@@ -53,11 +53,4 @@ } // namespace smb_client } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace smb_client { -using ::ash::smb_client::SmbMountResult; -} // namespace smb_client -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SMB_CLIENT_SMB_ERRORS_H_
diff --git a/chrome/browser/ash/smb_client/smb_service.h b/chrome/browser/ash/smb_client/smb_service.h index 1fa6b4e..0a71efb 100644 --- a/chrome/browser/ash/smb_client/smb_service.h +++ b/chrome/browser/ash/smb_client/smb_service.h
@@ -258,11 +258,4 @@ } // namespace smb_client } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace smb_client { -using ::ash::smb_client::SmbService; -} // namespace smb_client -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SMB_CLIENT_SMB_SERVICE_H_
diff --git a/chrome/browser/ash/smb_client/smb_service_factory.h b/chrome/browser/ash/smb_client/smb_service_factory.h index 96b8eca..8f32f7c 100644 --- a/chrome/browser/ash/smb_client/smb_service_factory.h +++ b/chrome/browser/ash/smb_client/smb_service_factory.h
@@ -8,12 +8,12 @@ #include "base/memory/singleton.h" #include "chrome/browser/profiles/profile_keyed_service_factory.h" #include "content/public/browser/browser_context.h" -// TODO(https://crbug.com/1164001): remove and use forward declaration. -#include "chrome/browser/ash/smb_client/smb_service.h" namespace ash { namespace smb_client { +class SmbService; + class SmbServiceFactory : public ProfileKeyedServiceFactory { public: // Returns a service instance singleton, after creating it (if necessary). @@ -47,11 +47,4 @@ } // namespace smb_client } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace smb_client { -using ::ash::smb_client::SmbServiceFactory; -} // namespace smb_client -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SMB_CLIENT_SMB_SERVICE_FACTORY_H_
diff --git a/chrome/browser/ash/smb_client/smb_url.h b/chrome/browser/ash/smb_client/smb_url.h index 104ed6cc8..dc53d31 100644 --- a/chrome/browser/ash/smb_client/smb_url.h +++ b/chrome/browser/ash/smb_client/smb_url.h
@@ -78,11 +78,4 @@ } // namespace smb_client } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromeOS code migration is done. -namespace chromeos { -namespace smb_client { -using ::ash::smb_client::SmbUrl; -} // namespace smb_client -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SMB_CLIENT_SMB_URL_H_
diff --git a/chrome/browser/ash/system/device_disabling_manager.h b/chrome/browser/ash/system/device_disabling_manager.h index 8bfae44..e57cf46 100644 --- a/chrome/browser/ash/system/device_disabling_manager.h +++ b/chrome/browser/ash/system/device_disabling_manager.h
@@ -153,12 +153,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::DeviceDisablingManager; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_DEVICE_DISABLING_MANAGER_H_
diff --git a/chrome/browser/ash/system/input_device_settings.h b/chrome/browser/ash/system/input_device_settings.h index d12cbd76..08df681 100644 --- a/chrome/browser/ash/system/input_device_settings.h +++ b/chrome/browser/ash/system/input_device_settings.h
@@ -332,16 +332,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::InputDeviceSettings; -using ::ash::system::MouseSettings; -using ::ash::system::PointerSensitivity; -using ::ash::system::PointingStickSettings; -using ::ash::system::TouchpadSettings; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_INPUT_DEVICE_SETTINGS_H_
diff --git a/chrome/browser/ash/system/pointer_device_observer.h b/chrome/browser/ash/system/pointer_device_observer.h index f0b20f3..8c98d722 100644 --- a/chrome/browser/ash/system/pointer_device_observer.h +++ b/chrome/browser/ash/system/pointer_device_observer.h
@@ -65,12 +65,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::PointerDeviceObserver; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_POINTER_DEVICE_OBSERVER_H_
diff --git a/chrome/browser/ash/system/procfs_util.h b/chrome/browser/ash/system/procfs_util.h index 7b81a0dd..0bc06a63 100644 --- a/chrome/browser/ash/system/procfs_util.h +++ b/chrome/browser/ash/system/procfs_util.h
@@ -55,14 +55,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::GetCpuTimeJiffies; -using ::ash::system::GetSingleProcStat; -using ::ash::system::SingleProcStat; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_PROCFS_UTIL_H_
diff --git a/chrome/browser/ash/system/system_clock.h b/chrome/browser/ash/system/system_clock.h index 809d3194..1af9e7d 100644 --- a/chrome/browser/ash/system/system_clock.h +++ b/chrome/browser/ash/system/system_clock.h
@@ -102,12 +102,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::SystemClock; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_SYSTEM_CLOCK_H_
diff --git a/chrome/browser/ash/system/timezone_resolver_manager.h b/chrome/browser/ash/system/timezone_resolver_manager.h index 5f2a090..c9681a54 100644 --- a/chrome/browser/ash/system/timezone_resolver_manager.h +++ b/chrome/browser/ash/system/timezone_resolver_manager.h
@@ -113,12 +113,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::TimeZoneResolverManager; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_TIMEZONE_RESOLVER_MANAGER_H_
diff --git a/chrome/browser/ash/system/timezone_util.h b/chrome/browser/ash/system/timezone_util.h index a1759eb8..2c62f98 100644 --- a/chrome/browser/ash/system/timezone_util.h +++ b/chrome/browser/ash/system/timezone_util.h
@@ -75,19 +75,4 @@ } // namespace system } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system { -using ::ash::system::GetCurrentTimezoneName; -using ::ash::system::GetTimezoneList; -using ::ash::system::HasSystemTimezonePolicy; -using ::ash::system::PerUserTimezoneEnabled; -using ::ash::system::SetSystemAndSigninScreenTimezone; -using ::ash::system::SetSystemTimezone; -using ::ash::system::SetTimezoneFromUI; -using ::ash::system::UpdateSystemTimezone; -} // namespace system -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_TIMEZONE_UTIL_H_
diff --git a/chrome/browser/ash/system/user_removal_manager.h b/chrome/browser/ash/system/user_removal_manager.h index 5fc6b60..b51fc3f5 100644 --- a/chrome/browser/ash/system/user_removal_manager.h +++ b/chrome/browser/ash/system/user_removal_manager.h
@@ -40,15 +40,4 @@ } // namespace user_removal_manager } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace user_removal_manager { -using ::ash::user_removal_manager::InitiateUserRemoval; -using ::ash::user_removal_manager::LogOut; -using ::ash::user_removal_manager::OverrideLogOutForTesting; -using ::ash::user_removal_manager::RemoveUsersIfNeeded; -} // namespace user_removal_manager -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_USER_REMOVAL_MANAGER_H_
diff --git a/chrome/browser/ash/system_extensions/api/hid/hid_impl.cc b/chrome/browser/ash/system_extensions/api/hid/hid_impl.cc index 7bb6852..d1514e0 100644 --- a/chrome/browser/ash/system_extensions/api/hid/hid_impl.cc +++ b/chrome/browser/ash/system_extensions/api/hid/hid_impl.cc
@@ -33,8 +33,7 @@ void HIDImpl::Bind(Profile* profile, const content::ServiceWorkerVersionBaseInfo& info, mojo::PendingReceiver<blink::mojom::CrosHID> receiver) { - mojo::MakeSelfOwnedReceiver(std::make_unique<ash::HIDImpl>(), - std::move(receiver)); + mojo::MakeSelfOwnedReceiver(std::make_unique<HIDImpl>(), std::move(receiver)); } HIDImpl::HIDImpl() = default;
diff --git a/chrome/browser/ash/system_logs/debug_log_writer.h b/chrome/browser/ash/system_logs/debug_log_writer.h index 321b5f34..281bc85a 100644 --- a/chrome/browser/ash/system_logs/debug_log_writer.h +++ b/chrome/browser/ash/system_logs/debug_log_writer.h
@@ -25,12 +25,4 @@ } // namespace debug_log_writer } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace debug_log_writer { -using ::ash::debug_log_writer::StoreLogs; -} // namespace debug_log_writer -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_LOGS_DEBUG_LOG_WRITER_H_
diff --git a/chrome/browser/ash/system_logs/system_logs_writer.h b/chrome/browser/ash/system_logs/system_logs_writer.h index 2780e9f..3363aea 100644 --- a/chrome/browser/ash/system_logs/system_logs_writer.h +++ b/chrome/browser/ash/system_logs/system_logs_writer.h
@@ -27,12 +27,4 @@ } // namespace system_logs_writer } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -namespace system_logs_writer { -using ::ash::system_logs_writer::WriteSystemLogs; -} // namespace system_logs_writer -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_SYSTEM_LOGS_SYSTEM_LOGS_WRITER_H_
diff --git a/chrome/browser/ash/telemetry_extension/diagnostics_service_converters.cc b/chrome/browser/ash/telemetry_extension/diagnostics_service_converters.cc index 2ed78332..a77382d 100644 --- a/chrome/browser/ash/telemetry_extension/diagnostics_service_converters.cc +++ b/chrome/browser/ash/telemetry_extension/diagnostics_service_converters.cc
@@ -142,6 +142,9 @@ return crosapi::mojom::DiagnosticsRoutineUserMessageEnum::kUnplugACPower; case cros_healthd::mojom::DiagnosticRoutineUserMessageEnum::kPlugInACPower: return crosapi::mojom::DiagnosticsRoutineUserMessageEnum::kPlugInACPower; + case cros_healthd::mojom::DiagnosticRoutineUserMessageEnum::kCheckLedColor: + NOTIMPLEMENTED(); + return crosapi::mojom::DiagnosticsRoutineUserMessageEnum::kUnknown; } NOTREACHED(); return static_cast<crosapi::mojom::DiagnosticsRoutineUserMessageEnum>(
diff --git a/chrome/browser/ash/telemetry_extension/diagnostics_service_converters_unittest.cc b/chrome/browser/ash/telemetry_extension/diagnostics_service_converters_unittest.cc index 6f3de3a..5cfd3a9 100644 --- a/chrome/browser/ash/telemetry_extension/diagnostics_service_converters_unittest.cc +++ b/chrome/browser/ash/telemetry_extension/diagnostics_service_converters_unittest.cc
@@ -149,6 +149,10 @@ EXPECT_EQ( Convert(cros_healthd::DiagnosticRoutineUserMessageEnum::kPlugInACPower), crosapi::DiagnosticsRoutineUserMessageEnum::kPlugInACPower); + // LED routine is not yet supported in telemetry extension. + EXPECT_EQ( + Convert(cros_healthd::DiagnosticRoutineUserMessageEnum::kCheckLedColor), + crosapi::DiagnosticsRoutineUserMessageEnum::kUnknown); } TEST(DiagnosticsServiceConvertersTest, ConvertDiagnosticRoutineCommandEnum) {
diff --git a/chrome/browser/ash/tether/tether_service.h b/chrome/browser/ash/tether/tether_service.h index 3fdceb86..c298202 100644 --- a/chrome/browser/ash/tether/tether_service.h +++ b/chrome/browser/ash/tether/tether_service.h
@@ -286,11 +286,4 @@ } // namespace tether } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -namespace tether { -using ::ash::tether::TetherService; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_TETHER_TETHER_SERVICE_H_
diff --git a/chrome/browser/ash/throttle_observer.h b/chrome/browser/ash/throttle_observer.h index e911846..b5fc7e44 100644 --- a/chrome/browser/ash/throttle_observer.h +++ b/chrome/browser/ash/throttle_observer.h
@@ -72,9 +72,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::ThrottleObserver; -} - #endif // CHROME_BROWSER_ASH_THROTTLE_OBSERVER_H_
diff --git a/chrome/browser/ash/throttle_service.h b/chrome/browser/ash/throttle_service.h index 407e776..5806f49d 100644 --- a/chrome/browser/ash/throttle_service.h +++ b/chrome/browser/ash/throttle_service.h
@@ -106,9 +106,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -using ::ash::ThrottleService; -} - #endif // CHROME_BROWSER_ASH_THROTTLE_SERVICE_H_
diff --git a/chrome/browser/ash/tpm_firmware_update.h b/chrome/browser/ash/tpm_firmware_update.h index 7c0bdbb..62eddb9 100644 --- a/chrome/browser/ash/tpm_firmware_update.h +++ b/chrome/browser/ash/tpm_firmware_update.h
@@ -66,11 +66,4 @@ } // namespace tpm_firmware_update } // namespace ash -// TODO(https://crbug.com/1164001): remove after the migration is finished. -namespace chromeos { -namespace tpm_firmware_update { -using ::ash::tpm_firmware_update::Mode; -} -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_TPM_FIRMWARE_UPDATE_H_
diff --git a/chrome/browser/ash/usb/cros_usb_detector.h b/chrome/browser/ash/usb/cros_usb_detector.h index 925010d0..494c6d0 100644 --- a/chrome/browser/ash/usb/cros_usb_detector.h +++ b/chrome/browser/ash/usb/cros_usb_detector.h
@@ -325,12 +325,6 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when ChromOS code migration is done. -namespace chromeos { -using ::ash::CrosUsbDetector; -using ::ash::CrosUsbDeviceObserver; -} // namespace chromeos - namespace base { template <>
diff --git a/chrome/browser/ash/web_applications/help_app/help_app_discover_tab_notification.cc b/chrome/browser/ash/web_applications/help_app/help_app_discover_tab_notification.cc index f9ffac4a..d291195a 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_discover_tab_notification.cc +++ b/chrome/browser/ash/web_applications/help_app/help_app_discover_tab_notification.cc
@@ -53,10 +53,10 @@ void HelpAppDiscoverTabNotification::OnClick(absl::optional<int> button_index) { SystemNotificationHelper::GetInstance()->Close( kShowHelpAppDiscoverTabNotificationId); - ash::SystemAppLaunchParams params; + SystemAppLaunchParams params; params.url = GURL("chrome://help-app/discover"); params.launch_source = apps::LaunchSource::kFromDiscoverTabNotification; - LaunchSystemWebAppAsync(profile_, ash::SystemWebAppType::HELP, params); + LaunchSystemWebAppAsync(profile_, SystemWebAppType::HELP, params); base::RecordAction( base::UserMetricsAction("Discover.DiscoverTabNotification.Clicked"));
diff --git a/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc b/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc index 83000f3..b5998868 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc +++ b/chrome/browser/ash/web_applications/help_app/help_app_integration_browsertest.cc
@@ -70,6 +70,7 @@ #include "ui/gfx/geometry/size.h" namespace ash { + namespace { class HelpAppIntegrationTest : public SystemWebAppIntegrationTest { @@ -121,13 +122,13 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2) { const GURL url(kChromeUIHelpAppURL); EXPECT_NO_FATAL_FAILURE( - ExpectSystemWebAppValid(ash::SystemWebAppType::HELP, url, "Explore")); + ExpectSystemWebAppValid(SystemWebAppType::HELP, url, "Explore")); } // Test that the Help App is searchable by additional strings. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2SearchInLauncher) { WaitForTestSystemAppInstall(); - auto* system_app = GetManager().GetSystemApp(ash::SystemWebAppType::HELP); + auto* system_app = GetManager().GetSystemApp(SystemWebAppType::HELP); std::vector<int> search_terms = system_app->GetAdditionalSearchTerms(); std::vector<std::string> search_terms_strings; std::transform(search_terms.begin(), search_terms.end(), @@ -140,7 +141,7 @@ // Test that the Help App has a minimum window size of 600x320. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2MinWindowSize) { WaitForTestSystemAppInstall(); - auto* system_app = GetManager().GetSystemApp(ash::SystemWebAppType::HELP); + auto* system_app = GetManager().GetSystemApp(SystemWebAppType::HELP); EXPECT_EQ(system_app->GetMinimumWindowSize(), gfx::Size(600, 320)); } @@ -149,7 +150,7 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2DefaultWindowBounds) { WaitForTestSystemAppInstall(); Browser* browser; - LaunchApp(ash::SystemWebAppType::HELP, &browser); + LaunchApp(SystemWebAppType::HELP, &browser); gfx::Rect work_area = display::Screen::GetScreen()->GetDisplayForNewWindows().work_area(); int x = (work_area.width() - 960) / 2; @@ -170,7 +171,7 @@ GURL("chrome://help-app/")); navigation_observer.StartWatchingNewWebContents(); - proxy->Launch(*GetManager().GetAppIdForSystemApp(ash::SystemWebAppType::HELP), + proxy->Launch(*GetManager().GetAppIdForSystemApp(SystemWebAppType::HELP), ui::EF_NONE, apps::LaunchSource::kFromKeyboard, std::make_unique<apps::WindowInfo>(display::kDefaultDisplayId)); @@ -184,7 +185,7 @@ // Test that the Help App can log metrics in the untrusted frame. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2InAppMetrics) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); base::UserActionTester user_action_tester; @@ -202,7 +203,7 @@ HasCorrectThemeAndBackgroundColor) { WaitForTestSystemAppInstall(); web_app::AppId app_id = - *GetManager().GetAppIdForSystemApp(ash::SystemWebAppType::HELP); + *GetManager().GetAppIdForSystemApp(SystemWebAppType::HELP); web_app::WebAppRegistrar& registrar = web_app::WebAppProvider::GetForTest(profile())->registrar(); @@ -217,7 +218,7 @@ HasCorrectThemeAndBackgroundColor) { WaitForTestSystemAppInstall(); web_app::AppId app_id = - *GetManager().GetAppIdForSystemApp(ash::SystemWebAppType::HELP); + *GetManager().GetAppIdForSystemApp(SystemWebAppType::HELP); web_app::WebAppRegistrar& registrar = web_app::WebAppProvider::GetForTest(profile())->registrar(); @@ -346,7 +347,7 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2DiscoverTabNotification) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); auto display_service = std::make_unique<NotificationDisplayServiceTester>(/*profile=*/nullptr); base::UserActionTester user_action_tester; @@ -407,7 +408,7 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2ReleaseNotesNotificationFromBackground) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); auto display_service = std::make_unique<NotificationDisplayServiceTester>(/*profile=*/nullptr); base::UserActionTester user_action_tester; @@ -479,14 +480,14 @@ Browser* browser; content::WebContents* web_contents = - LaunchApp(ash::SystemWebAppType::HELP, &browser); + LaunchApp(SystemWebAppType::HELP, &browser); // There should be two browser windows, one regular and one for the newly // opened app. EXPECT_EQ(2u, chrome::GetTotalBrowserCount()); content::TestNavigationObserver navigation_observer(web_contents); - LaunchAppWithoutWaiting(ash::SystemWebAppType::HELP); + LaunchAppWithoutWaiting(SystemWebAppType::HELP); // If no navigation happens, then this test will time out due to the wait. navigation_observer.Wait(); @@ -498,7 +499,7 @@ // Test direct navigation to a subpage. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2DirectNavigation) { WaitForTestSystemAppInstall(); - auto params = LaunchParamsForApp(ash::SystemWebAppType::HELP); + auto params = LaunchParamsForApp(SystemWebAppType::HELP); params.override_url = GURL("chrome://help-app/help/"); content::WebContents* web_contents = LaunchApp(std::move(params)); @@ -512,7 +513,7 @@ // Test that the Help App can open the feedback dialog. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2OpenFeedbackDialog) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); // Script that tells the Help App to open the feedback dialog. constexpr char kScript[] = R"( @@ -534,7 +535,7 @@ // Test that the Help App opens the OS Settings family link page. IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2ShowParentalControls) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); // There should be two browser windows, one regular and one for the newly // opened help app. @@ -567,7 +568,7 @@ IN_PROC_BROWSER_TEST_P(HelpAppIntegrationTest, HelpAppV2UpdateLauncherSearchIndexAndSearch) { WaitForTestSystemAppInstall(); - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); // Script that adds a data item to the launcher search index. constexpr char kScript[] = R"( @@ -618,7 +619,7 @@ HelpAppV2UpdateLauncherSearchIndexFilterInvalid) { WaitForTestSystemAppInstall(); base::HistogramTester histogram_tester; - content::WebContents* web_contents = LaunchApp(ash::SystemWebAppType::HELP); + content::WebContents* web_contents = LaunchApp(SystemWebAppType::HELP); // Script that adds a data item to the launcher search index. constexpr char kScript[] = R"( @@ -698,7 +699,7 @@ // Wait for system apps background tasks to start. base::RunLoop run_loop; - ash::SystemWebAppManager::GetForTest(browser()->profile()) + SystemWebAppManager::GetForTest(browser()->profile()) ->on_tasks_started() .Post(FROM_HERE, run_loop.QuitClosure()); run_loop.Run(); @@ -707,11 +708,11 @@ // Find the help app's background task. const auto& help_task = base::ranges::find( - tasks, bg_task_url, &ash::SystemWebAppBackgroundTask::url_for_testing); + tasks, bg_task_url, &SystemWebAppBackgroundTask::url_for_testing); ASSERT_NE(help_task, tasks.end()); auto* timer = help_task->get()->get_timer_for_testing(); - EXPECT_EQ(ash::SystemWebAppBackgroundTask::INITIAL_WAIT, + EXPECT_EQ(SystemWebAppBackgroundTask::INITIAL_WAIT, help_task->get()->get_state_for_testing()); // The "Immediate" timer waits for several minutes, and it's hard to mock time // properly in a browser test, so just fire the timer now. We're not testing
diff --git a/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.cc b/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.cc index ca4f907..bb4d3a2 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.cc +++ b/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.cc
@@ -23,7 +23,9 @@ namespace ash { namespace { + constexpr gfx::Size HELP_DEFAULT_SIZE(960, 600); + } // namespace std::unique_ptr<WebAppInstallInfo> CreateWebAppInfoForHelpWebApp() { @@ -68,10 +70,10 @@ } HelpAppSystemAppDelegate::HelpAppSystemAppDelegate(Profile* profile) - : ash::SystemWebAppDelegate(ash::SystemWebAppType::HELP, - "Help", - GURL("chrome://help-app/pwa.html"), - profile) {} + : SystemWebAppDelegate(SystemWebAppType::HELP, + "Help", + GURL("chrome://help-app/pwa.html"), + profile) {} gfx::Rect HelpAppSystemAppDelegate::GetDefaultBounds(Browser* browser) const { return GetDefaultBoundsForHelpApp(browser); @@ -89,12 +91,12 @@ return {IDS_GENIUS_APP_NAME, IDS_HELP_APP_PERKS, IDS_HELP_APP_OFFERS}; } -absl::optional<ash::SystemWebAppBackgroundTaskInfo> +absl::optional<SystemWebAppBackgroundTaskInfo> HelpAppSystemAppDelegate::GetTimerInfo() const { if (base::FeatureList::IsEnabled(features::kHelpAppBackgroundPage)) { - return ash::SystemWebAppBackgroundTaskInfo( - absl::nullopt, GURL("chrome://help-app/background"), - /*open_immediately=*/true); + return SystemWebAppBackgroundTaskInfo(absl::nullopt, + GURL("chrome://help-app/background"), + /*open_immediately=*/true); } else { return absl::nullopt; }
diff --git a/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.h b/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.h index 61106e1..a64d5eac 100644 --- a/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.h +++ b/chrome/browser/ash/web_applications/help_app/help_app_web_app_info.h
@@ -20,17 +20,16 @@ namespace ash { -class HelpAppSystemAppDelegate : public ash::SystemWebAppDelegate { +class HelpAppSystemAppDelegate : public SystemWebAppDelegate { public: explicit HelpAppSystemAppDelegate(Profile* profile); - // ash::SystemWebAppDelegate overrides: + // SystemWebAppDelegate overrides: std::unique_ptr<WebAppInstallInfo> GetWebAppInfo() const override; gfx::Rect GetDefaultBounds(Browser*) const override; gfx::Size GetMinimumWindowSize() const override; std::vector<int> GetAdditionalSearchTerms() const override; - absl::optional<ash::SystemWebAppBackgroundTaskInfo> GetTimerInfo() - const override; + absl::optional<SystemWebAppBackgroundTaskInfo> GetTimerInfo() const override; bool ShouldCaptureNavigations() const override; };
diff --git a/chrome/browser/ash/web_applications/personalization_app/personalization_app_utils.cc b/chrome/browser/ash/web_applications/personalization_app/personalization_app_utils.cc index c288938b..1542cfd 100644 --- a/chrome/browser/ash/web_applications/personalization_app/personalization_app_utils.cc +++ b/chrome/browser/ash/web_applications/personalization_app/personalization_app_utils.cc
@@ -39,7 +39,7 @@ } const user_manager::User* GetUser(const Profile* profile) { - auto* profile_helper = chromeos::ProfileHelper::Get(); + auto* profile_helper = ProfileHelper::Get(); DCHECK(profile_helper); const user_manager::User* user = profile_helper->GetUserByProfile(profile); return user;
diff --git a/chrome/browser/ash/wilco_dtc_supportd/mojo_utils.h b/chrome/browser/ash/wilco_dtc_supportd/mojo_utils.h index 1c4efde..b3889f96 100644 --- a/chrome/browser/ash/wilco_dtc_supportd/mojo_utils.h +++ b/chrome/browser/ash/wilco_dtc_supportd/mojo_utils.h
@@ -59,10 +59,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::MojoUtils; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_WILCO_DTC_SUPPORTD_MOJO_UTILS_H_
diff --git a/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_client.h b/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_client.h index b1ebdc1..4e21a4bd 100644 --- a/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_client.h +++ b/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_client.h
@@ -48,10 +48,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::WilcoDtcSupportdClient; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_CLIENT_H_
diff --git a/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_manager.h b/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_manager.h index b1967c3..e1f0d0b 100644 --- a/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_manager.h +++ b/chrome/browser/ash/wilco_dtc_supportd/wilco_dtc_supportd_manager.h
@@ -93,10 +93,4 @@ } // namespace ash -// TODO(https://crbug.com/1164001): remove when Chrome OS code migration is -// done. -namespace chromeos { -using ::ash::WilcoDtcSupportdManager; -} // namespace chromeos - #endif // CHROME_BROWSER_ASH_WILCO_DTC_SUPPORTD_WILCO_DTC_SUPPORTD_MANAGER_H_
diff --git a/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.cc b/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.cc deleted file mode 100644 index 96bb2823..0000000 --- a/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.cc +++ /dev/null
@@ -1,62 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/autofill_assistant/annotate_dom_model_service_factory.h" - -#include "base/command_line.h" -#include "base/feature_list.h" -#include "base/memory/scoped_refptr.h" -#include "base/no_destructor.h" -#include "base/task/sequenced_task_runner.h" -#include "base/task/task_traits.h" -#include "base/task/thread_pool.h" -#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h" -#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h" -#include "chrome/browser/profiles/profile.h" -#include "components/autofill_assistant/browser/features.h" -#include "components/autofill_assistant/browser/switches.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" - -AnnotateDomModelServiceFactory::AnnotateDomModelServiceFactory() - : ProfileKeyedServiceFactory("AnnotateDomModelService") {} - -AnnotateDomModelServiceFactory::~AnnotateDomModelServiceFactory() = default; - -// static -AnnotateDomModelServiceFactory* AnnotateDomModelServiceFactory::GetInstance() { - static base::NoDestructor<AnnotateDomModelServiceFactory> factory; - return factory.get(); -} - -// static -autofill_assistant::AnnotateDomModelService* -AnnotateDomModelServiceFactory::GetForBrowserContext( - content::BrowserContext* browser_context) { - return static_cast<autofill_assistant::AnnotateDomModelService*>( - GetInstance()->GetServiceForBrowserContext(browser_context, true)); -} - -KeyedService* AnnotateDomModelServiceFactory::BuildServiceInstanceFor( - content::BrowserContext* context) const { - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - autofill_assistant::switches::kAutofillAssistantAnnotateDom) && - !base::FeatureList::IsEnabled( - autofill_assistant::features::kAutofillAssistantAnnotateDom)) { - return nullptr; - } - - // The optimization guide service must be available for the annotate DOM - // model service to be created. - auto* opt_guide = OptimizationGuideKeyedServiceFactory::GetForProfile( - Profile::FromBrowserContext(context)); - if (!opt_guide) { - return nullptr; - } - - scoped_refptr<base::SequencedTaskRunner> background_task_runner = - base::ThreadPool::CreateSequencedTaskRunner( - {base::MayBlock(), base::TaskPriority::BEST_EFFORT}); - return new autofill_assistant::AnnotateDomModelService( - opt_guide, background_task_runner); -}
diff --git a/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.h b/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.h deleted file mode 100644 index 033c1fdf..0000000 --- a/chrome/browser/autofill_assistant/annotate_dom_model_service_factory.h +++ /dev/null
@@ -1,40 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_AUTOFILL_ASSISTANT_ANNOTATE_DOM_MODEL_SERVICE_FACTORY_H_ -#define CHROME_BROWSER_AUTOFILL_ASSISTANT_ANNOTATE_DOM_MODEL_SERVICE_FACTORY_H_ - -#include "chrome/browser/profiles/profile_keyed_service_factory.h" - -namespace content { -class BrowserContext; -} // namespace content - -namespace autofill_assistant { -class AnnotateDomModelService; -} // namespace autofill_assistant - -// Creates instances of |AnnotateDomMOdelService| per |BrowserContext|. -class AnnotateDomModelServiceFactory : public ProfileKeyedServiceFactory { - public: - AnnotateDomModelServiceFactory(); - ~AnnotateDomModelServiceFactory() override; - - // Gets the lazy instance of the factory. - static AnnotateDomModelServiceFactory* GetInstance(); - - // Gets the |AnnotateDomModelService| for the |browser_context|. - // - // Returns nullptr if the features that allows for annotating DOM is disabled. - // Only available when the optimization guide service is. - static autofill_assistant::AnnotateDomModelService* GetForBrowserContext( - content::BrowserContext* context); - - private: - // BrowserContextKeyedServiceFactory: - KeyedService* BuildServiceInstanceFor( - content::BrowserContext* context) const override; -}; - -#endif // CHROME_BROWSER_AUTOFILL_ASSISTANT_ANNOTATE_DOM_MODEL_SERVICE_FACTORY_H_
diff --git a/chrome/browser/autofill_assistant/common_dependencies_chrome.cc b/chrome/browser/autofill_assistant/common_dependencies_chrome.cc index 4f61c0b1c..1b09659 100644 --- a/chrome/browser/autofill_assistant/common_dependencies_chrome.cc +++ b/chrome/browser/autofill_assistant/common_dependencies_chrome.cc
@@ -9,7 +9,6 @@ #include "base/values.h" #include "chrome/browser/autofill/personal_data_manager_factory.h" -#include "chrome/browser/autofill_assistant/annotate_dom_model_service_factory.h" #include "chrome/browser/autofill_assistant/assistant_field_trial_util_chrome.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/consent_auditor/consent_auditor_factory.h" @@ -22,7 +21,6 @@ #include "chrome/common/channel_info.h" #include "components/autofill_assistant/browser/assistant_field_trial_util.h" #include "components/autofill_assistant/browser/dependencies_util.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" #include "components/metrics/metrics_pref_names.h" #include "components/prefs/pref_service.h" #include "components/security_state/core/security_state.h" @@ -123,11 +121,6 @@ signin::Tribool::kFalse; } -AnnotateDomModelService* -CommonDependenciesChrome::GetOrCreateAnnotateDomModelService() const { - return AnnotateDomModelServiceFactory::GetForBrowserContext(browser_context_); -} - signin::IdentityManager* CommonDependenciesChrome::GetIdentityManager() const { return IdentityManagerFactory::GetForProfile(GetProfile()); }
diff --git a/chrome/browser/autofill_assistant/common_dependencies_chrome.h b/chrome/browser/autofill_assistant/common_dependencies_chrome.h index bf98b9c5..bef1f8c6 100644 --- a/chrome/browser/autofill_assistant/common_dependencies_chrome.h +++ b/chrome/browser/autofill_assistant/common_dependencies_chrome.h
@@ -63,9 +63,6 @@ content::WebContents* web_contents) const override; bool IsSupervisedUser() const override; bool IsAllowedForMachineLearning() const override; - // The AnnotateDomModelService is a KeyedService. There is only one per - // BrowserContext. - AnnotateDomModelService* GetOrCreateAnnotateDomModelService() const override; signin::IdentityManager* GetIdentityManager() const override; consent_auditor::ConsentAuditor* GetConsentAuditor() const override; version_info::Channel GetChannel() const override;
diff --git a/chrome/browser/browser_process_platform_part_ash.cc b/chrome/browser/browser_process_platform_part_ash.cc index 6dc845f..e98a2eb4 100644 --- a/chrome/browser/browser_process_platform_part_ash.cc +++ b/chrome/browser/browser_process_platform_part_ash.cc
@@ -229,11 +229,11 @@ g_browser_process->browser_policy_connector()); } -chromeos::system::TimeZoneResolverManager* +ash::system::TimeZoneResolverManager* BrowserProcessPlatformPart::GetTimezoneResolverManager() { if (!timezone_resolver_manager_.get()) { timezone_resolver_manager_ = - std::make_unique<chromeos::system::TimeZoneResolverManager>(); + std::make_unique<ash::system::TimeZoneResolverManager>(); } return timezone_resolver_manager_.get(); } @@ -270,9 +270,9 @@ BrowserProcessPlatformPartChromeOS::AttemptExit(try_to_quit_application); } -chromeos::system::SystemClock* BrowserProcessPlatformPart::GetSystemClock() { +ash::system::SystemClock* BrowserProcessPlatformPart::GetSystemClock() { if (!system_clock_.get()) - system_clock_ = std::make_unique<chromeos::system::SystemClock>(); + system_clock_ = std::make_unique<ash::system::SystemClock>(); return system_clock_.get(); }
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 24fa5204..b6c4c572 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc
@@ -567,7 +567,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) // Ignore ChromeOS helper profiles (sign-in, lockscreen, etc). - if (!chromeos::ProfileHelper::IsUserProfile(profile)) { + if (!ash::ProfileHelper::IsUserProfile(profile)) { // Notify of new profile initialization only for regular profiles. The // startup profile initialization is triggered by another code path. return;
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 2fef17a..b3aa9101c 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc
@@ -414,7 +414,6 @@ #include "chrome/browser/flags/android/chrome_feature_list.h" #include "chrome/browser/ui/android/tab_model/tab_model_list.h" #include "chrome/common/chrome_descriptors.h" -#include "components/autofill_assistant/content/common/switches.h" #include "components/browser_ui/accessibility/android/font_size_prefs_android.h" #include "components/cdm/browser/cdm_message_filter_android.h" #include "components/crash/content/browser/child_exit_observer_android.h" @@ -2910,16 +2909,6 @@ switches::kChangeStackGuardOnForkEnabled); } #endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) - -#if BUILDFLAG(IS_ANDROID) - if (browser_command_line.HasSwitch( - autofill_assistant::switches::kAutofillAssistantDebugAnnotateDom)) { - command_line->AppendSwitchASCII( - autofill_assistant::switches::kAutofillAssistantDebugAnnotateDom, - browser_command_line.GetSwitchValueASCII( - autofill_assistant::switches::kAutofillAssistantDebugAnnotateDom)); - } -#endif // BUILDFLAG(IS_ANDROID) } std::string
diff --git a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc index 34fea44..e222101 100644 --- a/chrome/browser/chrome_content_browser_client_receiver_bindings.cc +++ b/chrome/browser/chrome_content_browser_client_receiver_bindings.cc
@@ -24,8 +24,6 @@ #include "chrome/browser/predictors/loading_predictor_factory.h" #include "chrome/common/buildflags.h" #include "components/autofill/content/browser/content_autofill_driver_factory.h" -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" -#include "components/autofill_assistant/content/common/autofill_assistant_driver.mojom.h" #include "components/content_capture/browser/onscreen_content_provider.h" #include "components/metrics/call_stack_profile_collector.h" #include "components/offline_pages/buildflags/buildflags.h" @@ -442,16 +440,6 @@ RegisterAssociatedInterfaceBindersForRenderFrameHost( content::RenderFrameHost& render_frame_host, blink::AssociatedInterfaceRegistry& associated_registry) { - // TODO(lingqi): Swap the parameters so that lambda functions are not needed. - associated_registry.AddInterface< - autofill_assistant::mojom::AutofillAssistantDriver>(base::BindRepeating( - [](content::RenderFrameHost* render_frame_host, - mojo::PendingAssociatedReceiver< - autofill_assistant::mojom::AutofillAssistantDriver> receiver) { - autofill_assistant::ContentAutofillAssistantDriver::BindDriver( - std::move(receiver), render_frame_host); - }, - &render_frame_host)); associated_registry.AddInterface<autofill::mojom::AutofillDriver>( base::BindRepeating( [](content::RenderFrameHost* render_frame_host,
diff --git a/chrome/browser/chromeos/extensions/echo_private/echo_private_apitest.cc b/chrome/browser/chromeos/extensions/echo_private/echo_private_apitest.cc index f0e10a87..fcc06769 100644 --- a/chrome/browser/chromeos/extensions/echo_private/echo_private_apitest.cc +++ b/chrome/browser/chromeos/extensions/echo_private/echo_private_apitest.cc
@@ -126,7 +126,7 @@ protected: int expected_dialog_buttons_; DialogTestAction dialog_action_; - ScopedTestingCrosSettings scoped_testing_cros_settings_; + ash::ScopedTestingCrosSettings scoped_testing_cros_settings_; private: int dialog_invocation_count_;
diff --git a/chrome/browser/chromeos/extensions/file_system_provider/OWNERS b/chrome/browser/chromeos/extensions/file_system_provider/OWNERS index d3409d7..62ae02d 100644 --- a/chrome/browser/chromeos/extensions/file_system_provider/OWNERS +++ b/chrome/browser/chromeos/extensions/file_system_provider/OWNERS
@@ -1,2 +1,3 @@ +file://ui/file_manager/OWNERS yamaguchi@chromium.org file://ui/file_manager/OWNERS
diff --git a/chrome/browser/chromeos/extensions/login_screen/login/cleanup/print_jobs_cleanup_handler_unittest.cc b/chrome/browser/chromeos/extensions/login_screen/login/cleanup/print_jobs_cleanup_handler_unittest.cc index d9382867..bec959b 100644 --- a/chrome/browser/chromeos/extensions/login_screen/login/cleanup/print_jobs_cleanup_handler_unittest.cc +++ b/chrome/browser/chromeos/extensions/login_screen/login/cleanup/print_jobs_cleanup_handler_unittest.cc
@@ -86,7 +86,7 @@ // Set up `MockPrintingManager`. print_job_manager_ = std::make_unique<ash::TestCupsPrintJobManager>(testing_profile_); - auto print_job_database = std::make_unique<TestPrintJobDatabase>(); + auto print_job_database = std::make_unique<ash::TestPrintJobDatabase>(); print_job_history_service_ = std::make_unique<ash::PrintJobHistoryServiceImpl>( std::move(print_job_database), print_job_manager_.get(),
diff --git a/chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc b/chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc index e83a542..23c8554 100644 --- a/chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc +++ b/chrome/browser/device_identity/chromeos/device_oauth2_token_store_chromeos.cc
@@ -109,7 +109,7 @@ } void DeviceOAuth2TokenStoreChromeOS::EncryptAndSaveToken() { - CryptohomeTokenEncryptor encryptor(system_salt_); + ash::CryptohomeTokenEncryptor encryptor(system_salt_); std::string encrypted_refresh_token = encryptor.EncryptWithSystemSalt(refresh_token_); bool result = true; @@ -149,7 +149,7 @@ std::string encrypted_refresh_token = local_state_->GetString(prefs::kDeviceRobotAnyApiRefreshToken); if (!encrypted_refresh_token.empty()) { - CryptohomeTokenEncryptor encryptor(system_salt_); + ash::CryptohomeTokenEncryptor encryptor(system_salt_); refresh_token_ = encryptor.DecryptWithSystemSalt(encrypted_refresh_token); if (refresh_token_.empty()) { LOG(ERROR) << "Failed to decrypt refresh token.";
diff --git a/chrome/browser/devtools/device/port_forwarding_browsertest.cc b/chrome/browser/devtools/device/port_forwarding_browsertest.cc index 53f5eeb9..50b688f3 100644 --- a/chrome/browser/devtools/device/port_forwarding_browsertest.cc +++ b/chrome/browser/devtools/device/port_forwarding_browsertest.cc
@@ -178,5 +178,5 @@ run_loop.QuitWhenIdleClosure())); wait_for_port_forwarding.reset(); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); }
diff --git a/chrome/browser/devtools/devtools_browsertest.cc b/chrome/browser/devtools/devtools_browsertest.cc index ac7fef9..719ba9b 100644 --- a/chrome/browser/devtools/devtools_browsertest.cc +++ b/chrome/browser/devtools/devtools_browsertest.cc
@@ -804,7 +804,7 @@ scoped_refptr<DevToolsAgentHost> host; base::RunLoop run_loop; new WorkerCreationObserver(path, &host, run_loop.QuitWhenIdleClosure()); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); return host; }
diff --git a/chrome/browser/enterprise/connectors/analysis/local_binary_upload_service_unittest.cc b/chrome/browser/enterprise/connectors/analysis/local_binary_upload_service_unittest.cc index 09eb670..035f4659 100644 --- a/chrome/browser/enterprise/connectors/analysis/local_binary_upload_service_unittest.cc +++ b/chrome/browser/enterprise/connectors/analysis/local_binary_upload_service_unittest.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/enterprise/connectors/analysis/local_binary_upload_service.h" #include "base/callback_helpers.h" +#include "build/build_config.h" #include "chrome/browser/enterprise/connectors/analysis/analysis_settings.h" #include "chrome/browser/enterprise/connectors/analysis/fake_content_analysis_sdk_manager.h" #include "chrome/test/base/testing_profile.h" @@ -195,7 +196,13 @@ EXPECT_EQ(1u, lbus.GetPendingRequestCountForTesting()); } -TEST_F(LocalBinaryUploadServiceTest, PendingRequestsGetProcessed) { +// Flaky on mac, http://crbug.com/1365018 +#if BUILDFLAG(IS_MAC) +#define MAYBE_PendingRequestsGetProcessed DISABLED_PendingRequestsGetProcessed +#else +#define MAYBE_PendingRequestsGetProcessed PendingRequestsGetProcessed +#endif +TEST_F(LocalBinaryUploadServiceTest, MAYBE_PendingRequestsGetProcessed) { LocalBinaryUploadService lbus; content_analysis::sdk::ContentAnalysisResponse response;
diff --git a/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc b/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc index f7b05eb8..ed0a517 100644 --- a/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/device_trust_browsertest.cc
@@ -49,10 +49,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if BUILDFLAG(IS_WIN) -#include "chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.h" -#endif // #if BUILDFLAG(IS_WIN) - #if BUILDFLAG(IS_CHROMEOS_ASH) #include "chrome/browser/ash/attestation/mock_tpm_challenge_key.h" #include "chrome/browser/ash/attestation/tpm_challenge_key.h" @@ -265,71 +261,6 @@ return active_browser->profile()->GetPrefs(); } - void VerifyAttestationFlowOutcome() { - if (!is_enabled()) { - // If the feature flag is disabled, the attestation flow should not have - // been triggered (and that is the end of the test); - EXPECT_FALSE(initial_attestation_request_); - EXPECT_FALSE(challenge_response_request_); - - histogram_tester_.ExpectTotalCount(kFunnelHistogramName, 0); - histogram_tester_.ExpectTotalCount(kResultHistogramName, 0); - histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 0); - histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 0); - return; - } - - // Attestation flow should be fully done. - EXPECT_TRUE(initial_attestation_request_); - - // Validate that the two requests contain expected information. URLs' paths - // have to be used for comparison due to how the HostResolver is replacing - // domains with '127.0.0.1' in tests. - EXPECT_EQ(initial_attestation_request_->GetURL().path(), - GetRedirectUrl().path()); - EXPECT_EQ( - initial_attestation_request_->headers.find(kDeviceTrustHeader)->second, - kDeviceTrustHeaderValue); - - // Response header should always be set, even in error cases (i.e. - // use_v2_header is false). - EXPECT_TRUE(challenge_response_request_.has_value()); - - ExpectFunnelStep(DTAttestationFunnelStep::kAttestationFlowStarted); - ExpectFunnelStep(DTAttestationFunnelStep::kChallengeReceived); - - EXPECT_EQ(challenge_response_request_->GetURL().path(), - GetRedirectLocationUrl().path()); - const std::string& challenge_response = - challenge_response_request_->headers - .find(kVerifiedAccessResponseHeader) - ->second; - - if (use_v2_header()) { - // TODO(crbug.com/1241857): Add challenge-response validation. - EXPECT_TRUE(!challenge_response.empty()); - - ExpectFunnelStep(DTAttestationFunnelStep::kSignalsCollected); - ExpectFunnelStep(DTAttestationFunnelStep::kChallengeResponseSent); - histogram_tester_.ExpectUniqueSample(kResultHistogramName, - DTAttestationResult::kSuccess, 1); - histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 1); - histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 0); - } else { - static constexpr char kFailedToParseChallengeJsonResponse[] = - "{\"error\":\"failed_to_parse_challenge\"}"; - EXPECT_EQ(challenge_response, kFailedToParseChallengeJsonResponse); - histogram_tester_.ExpectBucketCount( - kFunnelHistogramName, DTAttestationFunnelStep::kSignalsCollected, 0); - histogram_tester_.ExpectBucketCount( - kFunnelHistogramName, DTAttestationFunnelStep::kChallengeResponseSent, - 0); - histogram_tester_.ExpectTotalCount(kResultHistogramName, 0); - histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 0); - histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 1); - } - } - net::test_server::EmbeddedTestServerHandle test_server_handle_; base::test::ScopedFeatureList scoped_feature_list_; base::HistogramTester histogram_tester_; @@ -421,12 +352,8 @@ void SetUpOnMainThread() override { DeviceTrustBrowserTestBase::SetUpOnMainThread(); -#if BUILDFLAG(IS_WIN) - device_trust_test_environment_win_.emplace(); -#else // BUILDFLAG(IS_WIN) scoped_persistence_delegate_factory_.emplace(); scoped_rotation_command_factory_.emplace(); -#endif safe_browsing::SetProfileDMToken(browser()->profile(), "dm_token"); @@ -455,15 +382,10 @@ } #endif -#if BUILDFLAG(IS_WIN) - absl::optional<DeviceTrustTestEnvironmentWin> - device_trust_test_environment_win_; -#else // BUILDFLAG(IS_WIN) absl::optional<test::ScopedKeyPersistenceDelegateFactory> scoped_persistence_delegate_factory_; absl::optional<ScopedKeyRotationCommandFactory> scoped_rotation_command_factory_; -#endif }; using DeviceTrustBrowserTest = DeviceTrustDesktopBrowserTest; @@ -471,22 +393,77 @@ // Tests that the whole attestation flow occurs when navigating to an // allowed domain. -IN_PROC_BROWSER_TEST_P(DeviceTrustBrowserTest, AttestationFullFlowKeyExists) { +IN_PROC_BROWSER_TEST_P(DeviceTrustBrowserTest, AttestationFullFlow) { GURL redirect_url = GetRedirectUrl(); TestNavigationManager first_navigation(web_contents(), redirect_url); -#if BUILDFLAG(IS_WIN) - // Windows DT test environment mocks the register and we need to manually - // create the DT key first - device_trust_test_environment_win_->SetUpExistingKey(); -#endif - // Add allowed domain to Prefs and trigger a navigation to it. SetPolicy(); NavigateToUrl(redirect_url); first_navigation.WaitForNavigationFinished(); - VerifyAttestationFlowOutcome(); + + if (!is_enabled()) { + // If the feature flag is disabled, the attestation flow should not have + // been triggered (and that is the end of the test); + EXPECT_FALSE(initial_attestation_request_); + EXPECT_FALSE(challenge_response_request_); + + histogram_tester_.ExpectTotalCount(kFunnelHistogramName, 0); + histogram_tester_.ExpectTotalCount(kResultHistogramName, 0); + histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 0); + histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 0); + return; + } + + // Attestation flow should be fully done. + EXPECT_TRUE(initial_attestation_request_); + + // Validate that the two requests contain expected information. URLs' paths + // have to be used for comparison due to how the HostResolver is replacing + // domains with '127.0.0.1' in tests. + EXPECT_EQ(initial_attestation_request_->GetURL().path(), + GetRedirectUrl().path()); + EXPECT_EQ( + initial_attestation_request_->headers.find(kDeviceTrustHeader)->second, + kDeviceTrustHeaderValue); + + // Response header should always be set, even in error cases (i.e. + // use_v2_header is false). + EXPECT_TRUE(challenge_response_request_.has_value()); + + ExpectFunnelStep(DTAttestationFunnelStep::kAttestationFlowStarted); + ExpectFunnelStep(DTAttestationFunnelStep::kChallengeReceived); + + EXPECT_EQ(challenge_response_request_->GetURL().path(), + GetRedirectLocationUrl().path()); + const std::string& challenge_response = + challenge_response_request_->headers.find(kVerifiedAccessResponseHeader) + ->second; + + if (use_v2_header()) { + // TODO(crbug.com/1241857): Add challenge-response validation. + EXPECT_TRUE(!challenge_response.empty()); + + ExpectFunnelStep(DTAttestationFunnelStep::kSignalsCollected); + ExpectFunnelStep(DTAttestationFunnelStep::kChallengeResponseSent); + histogram_tester_.ExpectUniqueSample(kResultHistogramName, + DTAttestationResult::kSuccess, 1); + histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 1); + histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 0); + } else { + static constexpr char kFailedToParseChallengeJsonResponse[] = + "{\"error\":\"failed_to_parse_challenge\"}"; + EXPECT_EQ(challenge_response, kFailedToParseChallengeJsonResponse); + histogram_tester_.ExpectBucketCount( + kFunnelHistogramName, DTAttestationFunnelStep::kSignalsCollected, 0); + histogram_tester_.ExpectBucketCount( + kFunnelHistogramName, DTAttestationFunnelStep::kChallengeResponseSent, + 0); + histogram_tester_.ExpectTotalCount(kResultHistogramName, 0); + histogram_tester_.ExpectTotalCount(kLatencySuccessHistogramName, 0); + histogram_tester_.ExpectTotalCount(kLatencyFailureHistogramName, 1); + } } // Tests that the attestation flow does not get triggered when navigating to a @@ -633,22 +610,6 @@ } } -#if BUILDFLAG(IS_WIN) -// Windows DT test environment mocks the registry and DT key does not exist by -// default In this test case a key will be created by DeviceTrustKeyManager -IN_PROC_BROWSER_TEST_P(DeviceTrustBrowserTest, AttestationKeyCreation) { - GURL redirect_url = GetRedirectUrl(); - TestNavigationManager first_navigation(web_contents(), redirect_url); - - // Add allowed domain to Prefs and trigger a navigation to it. - SetPolicy(); - NavigateToUrl(redirect_url); - - first_navigation.WaitForNavigationFinished(); - VerifyAttestationFlowOutcome(); -} -#endif - INSTANTIATE_TEST_SUITE_P(All, DeviceTrustBrowserTest, testing::Combine(testing::Bool(), testing::Bool()));
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/BUILD.gn b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/BUILD.gn index 73493cfc..65923cf4 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/BUILD.gn +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/BUILD.gn
@@ -3,11 +3,7 @@ # found in the LICENSE file. source_set("commands") { - friend = [ - "//chrome/browser/enterprise/connectors/device_trust/test:test_support", - ":test_support", - ":unit_tests", - ] + friend = [ ":unit_tests" ] public = [ "key_rotation_command.h", @@ -100,7 +96,6 @@ "//base", "//base/test:test_support", "//chrome/browser/enterprise/connectors/device_trust/common", - "//chrome/browser/enterprise/connectors/device_trust/test:test_support", "//testing/gtest", ]
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc index 5ca328d..b80a519 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.cc
@@ -146,25 +146,11 @@ } // namespace -WinKeyRotationCommand::WinKeyRotationCommand() - : WinKeyRotationCommand( - base::BindRepeating(&RunGoogleUpdateElevatedCommand)) {} +WinKeyRotationCommand::WinKeyRotationCommand() = default; WinKeyRotationCommand::WinKeyRotationCommand( RunGoogleUpdateElevatedCommandFn run_elevated_command) - : WinKeyRotationCommand( - run_elevated_command, - base::ThreadPool::CreateCOMSTATaskRunner( - {base::TaskPriority::USER_BLOCKING, base::MayBlock()})) {} - -WinKeyRotationCommand::WinKeyRotationCommand( - RunGoogleUpdateElevatedCommandFn run_elevated_command, - scoped_refptr<base::SingleThreadTaskRunner> com_thread_runner) - : com_thread_runner_(com_thread_runner), - run_elevated_command_(run_elevated_command) { - DCHECK(run_elevated_command_); - DCHECK(com_thread_runner_); -} + : run_elevated_command_(run_elevated_command) {} WinKeyRotationCommand::~WinKeyRotationCommand() = default; @@ -172,6 +158,15 @@ Callback callback) { DCHECK(!callback.is_null()); + if (!com_thread_runner_) { + com_thread_runner_ = base::ThreadPool::CreateCOMSTATaskRunner( + {base::TaskPriority::USER_BLOCKING, base::MayBlock()}); + } + + RunGoogleUpdateElevatedCommandFn run_elevated_command = + run_elevated_command_ ? run_elevated_command_ + : &RunGoogleUpdateElevatedCommand; + com_thread_runner_->PostTaskAndReplyWithResult( FROM_HERE, base::BindOnce( @@ -190,7 +185,7 @@ // and sleep time are pretty arbitrary choices. HRESULT hr = S_OK; for (int i = 0; i < 10; ++i) { - hr = run_elevated_command.Run( + hr = run_elevated_command( installer::kCmdRotateDeviceTrustKey, {token_base64, params.dm_server_url, nonce_base64}, &return_code); @@ -218,7 +213,7 @@ } return status; }, - params, run_elevated_command_, waiting_enabled_), + params, run_elevated_command, waiting_enabled_), std::move(callback)); }
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h index febd77d..3cf96875 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h
@@ -23,18 +23,15 @@ static const HRESULT GOOPDATE_E_APP_USING_EXTERNAL_UPDATER = 0xA043081D; using RunGoogleUpdateElevatedCommandFn = - base::RepeatingCallback<HRESULT(const wchar_t* command, - const std::vector<std::string>& args, - DWORD* return_code)>; + HRESULT (*)(const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code); // The second constructor is used in tests to override the behaviour of // Google Update. WinKeyRotationCommand(); explicit WinKeyRotationCommand( RunGoogleUpdateElevatedCommandFn run_elevated_command); - WinKeyRotationCommand( - RunGoogleUpdateElevatedCommandFn run_elevated_command, - scoped_refptr<base::SingleThreadTaskRunner> com_thread_runner); ~WinKeyRotationCommand() override; // KeyRotationCommand: @@ -46,7 +43,7 @@ private: scoped_refptr<base::SingleThreadTaskRunner> com_thread_runner_; bool waiting_enabled_ = true; - RunGoogleUpdateElevatedCommandFn run_elevated_command_; + RunGoogleUpdateElevatedCommandFn run_elevated_command_ = nullptr; }; } // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command_unittest.cc index 218ba59..b809a92 100644 --- a/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command_unittest.cc +++ b/chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command_unittest.cc
@@ -7,7 +7,6 @@ #include <winerror.h> #include "base/base64.h" -#include "base/functional/bind.h" #include "base/test/bind.h" #include "base/test/task_environment.h" #include "chrome/installer/util/util_constants.h" @@ -52,13 +51,13 @@ bool was_called = false; KeyRotationCommand::Status status = KeyRotationCommand::Status::TIMED_OUT; - WinKeyRotationCommand command(base::BindRepeating( - [](const wchar_t* command, const std::vector<std::string>& args, - DWORD* return_code) { - CheckCommandArgs(args); - *return_code = installer::ROTATE_DTKEY_SUCCESS; - return S_OK; - })); + WinKeyRotationCommand command([](const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code) { + CheckCommandArgs(args); + *return_code = installer::ROTATE_DTKEY_SUCCESS; + return S_OK; + }); command.Trigger(params, base::BindLambdaForTesting( [&was_called, @@ -78,13 +77,13 @@ bool was_called = false; KeyRotationCommand::Status status = KeyRotationCommand::Status::TIMED_OUT; - WinKeyRotationCommand command(base::BindRepeating( - [](const wchar_t* command, const std::vector<std::string>& args, - DWORD* return_code) { - CheckCommandArgs(args); - *return_code = installer::ROTATE_DTKEY_FAILED; - return S_OK; - })); + WinKeyRotationCommand command([](const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code) { + CheckCommandArgs(args); + *return_code = installer::ROTATE_DTKEY_FAILED; + return S_OK; + }); command.Trigger(params, base::BindLambdaForTesting( [&was_called, @@ -104,13 +103,13 @@ bool was_called = false; KeyRotationCommand::Status status = KeyRotationCommand::Status::FAILED; - WinKeyRotationCommand command(base::BindRepeating( - [](const wchar_t* command, const std::vector<std::string>& args, - DWORD* return_code) { - CheckCommandArgs(args); - // Not setting return_code. - return E_ABORT; - })); + WinKeyRotationCommand command([](const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code) { + CheckCommandArgs(args); + // Not setting return_code. + return E_ABORT; + }); command.Trigger(params, base::BindLambdaForTesting( [&was_called, @@ -130,13 +129,13 @@ bool was_called = false; KeyRotationCommand::Status status = KeyRotationCommand::Status::SUCCEEDED; - WinKeyRotationCommand command(base::BindRepeating( - [](const wchar_t* command, const std::vector<std::string>& args, - DWORD* return_code) { - CheckCommandArgs(args); - // Not setting return_code. - return WinKeyRotationCommand::GOOPDATE_E_APP_USING_EXTERNAL_UPDATER; - })); + WinKeyRotationCommand command([](const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code) { + CheckCommandArgs(args); + // Not setting return_code. + return WinKeyRotationCommand::GOOPDATE_E_APP_USING_EXTERNAL_UPDATER; + }); command.enable_waiting_for_testing(false); command.Trigger(params, base::BindLambdaForTesting( @@ -157,13 +156,13 @@ bool was_called = false; KeyRotationCommand::Status status = KeyRotationCommand::Status::SUCCEEDED; - WinKeyRotationCommand command(base::BindRepeating( - [](const wchar_t* command, const std::vector<std::string>& args, - DWORD* return_code) { - CheckCommandArgs(args); - // Not setting return_code. - return E_FAIL; - })); + WinKeyRotationCommand command([](const wchar_t* command, + const std::vector<std::string>& args, + DWORD* return_code) { + CheckCommandArgs(args); + // Not setting return_code. + return E_FAIL; + }); command.enable_waiting_for_testing(false); command.Trigger(params, base::BindLambdaForTesting(
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/BUILD.gn b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/BUILD.gn new file mode 100644 index 0000000..60e35fe --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/BUILD.gn
@@ -0,0 +1,31 @@ +# Copyright 2022 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +source_set("win") { + public = [ "win_signals_decorator.h" ] + + sources = [ "win_signals_decorator.cc" ] + + public_deps = [ "//chrome/browser/enterprise/connectors/device_trust/signals/decorators/common" ] + + deps = [ + "//base", + "//components/device_signals/core/common", + "//third_party/abseil-cpp:absl", + ] +} + +source_set("unit_tests") { + testonly = true + sources = [ "win_signals_decorator_unittest.cc" ] + + deps = [ + ":win", + "//base", + "//base/test:test_support", + "//components/device_signals/core/common", + "//testing/gtest", + "//third_party/abseil-cpp:absl", + ] +}
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.cc b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.cc new file mode 100644 index 0000000..9cd4c715 --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.cc
@@ -0,0 +1,88 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h" + +#include <string> + +#include "base/strings/string_number_conversions.h" +#include "base/strings/utf_string_conversions.h" +#include "base/values.h" +#include "base/win/registry.h" +#include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/metrics_utils.h" +#include "components/device_signals/core/common/signals_constants.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace enterprise_connectors { + +namespace { +constexpr char kLatencyHistogramVariant[] = "Win"; + +constexpr wchar_t kCSAgentRegPath[] = + L"SYSTEM\\CurrentControlSet\\services\\CSAgent\\Sim"; + +// CU is the registry value containing the customer ID. +constexpr wchar_t kCSCURegKey[] = L"CU"; + +// AG is the registry value containing the agent ID. +constexpr wchar_t kCSAGRegKey[] = L"AG"; + +absl::optional<std::string> GetHexStringRegValue( + const base::win::RegKey& key, + const std::wstring& reg_key_name) { + DWORD type = REG_NONE; + DWORD size = 0; + auto res = key.ReadValue(reg_key_name.c_str(), nullptr, &size, &type); + if (res == ERROR_SUCCESS && type == REG_BINARY) { + std::vector<uint8_t> raw_bytes(size); + res = key.ReadValue(reg_key_name.c_str(), raw_bytes.data(), &size, &type); + + if (res == ERROR_SUCCESS) { + return base::HexEncode(raw_bytes.data(), raw_bytes.size()); + } + } + + return absl::nullopt; +} + +} // namespace + +WinSignalsDecorator::WinSignalsDecorator() = default; + +WinSignalsDecorator::~WinSignalsDecorator() = default; + +void WinSignalsDecorator::Decorate(base::Value::Dict& signals, + base::OnceClosure done_closure) { + auto start_time = base::TimeTicks::Now(); + + base::win::RegKey key; + auto result = key.Open(HKEY_LOCAL_MACHINE, kCSAgentRegPath, + KEY_QUERY_VALUE | KEY_WOW64_64KEY); + + if (result == ERROR_SUCCESS && key.Valid()) { + base::Value::Dict crowdstrike_info; + + auto customer_id = GetHexStringRegValue(key, kCSCURegKey); + if (customer_id) { + crowdstrike_info.Set(device_signals::names::kCustomerId, + customer_id.value()); + } + + auto agent_id = GetHexStringRegValue(key, kCSAGRegKey); + if (agent_id) { + crowdstrike_info.Set(device_signals::names::kAgentId, agent_id.value()); + } + + if (customer_id || agent_id) { + signals.Set(device_signals::names::kCrowdStrike, + std::move(crowdstrike_info)); + } + } + + LogSignalsCollectionLatency(kLatencyHistogramVariant, start_time); + + std::move(done_closure).Run(); +} + +} // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h new file mode 100644 index 0000000..b50f8b3 --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h
@@ -0,0 +1,25 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_SIGNALS_DECORATORS_BROWSER_WIN_WIN_SIGNALS_DECORATOR_H_ +#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_SIGNALS_DECORATORS_BROWSER_WIN_WIN_SIGNALS_DECORATOR_H_ + +#include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/common/signals_decorator.h" + +namespace enterprise_connectors { + +// Definition of the SignalsDecorator collecting Windows-specific signals. +class WinSignalsDecorator : public SignalsDecorator { + public: + WinSignalsDecorator(); + ~WinSignalsDecorator() override; + + // SignalsDecorator: + void Decorate(base::Value::Dict& signals, + base::OnceClosure done_closure) override; +}; + +} // namespace enterprise_connectors + +#endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_SIGNALS_DECORATORS_BROWSER_WIN_WIN_SIGNALS_DECORATOR_H_
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator_unittest.cc b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator_unittest.cc new file mode 100644 index 0000000..21f6104 --- /dev/null +++ b/chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator_unittest.cc
@@ -0,0 +1,196 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h" + +#include <string> + +#include "base/strings/string_number_conversions.h" +#include "base/strings/utf_string_conversions.h" +#include "base/test/metrics/histogram_tester.h" +#include "base/test/task_environment.h" +#include "base/test/test_reg_util_win.h" +#include "base/values.h" +#include "base/win/registry.h" +#include "components/device_signals/core/common/signals_constants.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace enterprise_connectors { + +namespace { + +constexpr wchar_t kCSAgentRegPath[] = + L"SYSTEM\\CurrentControlSet\\services\\CSAgent\\Sim"; +constexpr wchar_t kCSCURegKey[] = L"CU"; +constexpr wchar_t kCSAGRegKey[] = L"AG"; + +// Those IDs are Hex values. +constexpr char kFakeCSAgentId[] = "ADEBCA432156ABDC"; +constexpr char kFakeCSCustomerId[] = "CABCDEF1234ABCD1234D"; + +constexpr char kLatencyHistogram[] = + "Enterprise.DeviceTrust.SignalsDecorator.Latency.Win"; + +void CreateRegistryKey(const std::wstring& key_path) { + base::win::RegKey key; + LONG res = key.Create(HKEY_LOCAL_MACHINE, key_path.c_str(), KEY_WRITE); + ASSERT_EQ(res, ERROR_SUCCESS); +} + +void SetUpCrowdStrikeInfo(const absl::optional<std::string>& customer_id, + const absl::optional<std::string>& agent_id) { + base::win::RegKey key; + LONG res = key.Open(HKEY_LOCAL_MACHINE, kCSAgentRegPath, KEY_WRITE); + ASSERT_EQ(res, ERROR_SUCCESS); + + if (customer_id) { + res = key.WriteValue(kCSCURegKey, customer_id->data(), customer_id->size(), + REG_BINARY); + ASSERT_EQ(res, ERROR_SUCCESS); + } + + if (agent_id) { + res = key.WriteValue(kCSAGRegKey, agent_id->data(), agent_id->size(), + REG_BINARY); + ASSERT_EQ(res, ERROR_SUCCESS); + } +} + +} // namespace + +class WinSignalsDecoratorTest : public testing::Test { + protected: + WinSignalsDecoratorTest() { + registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); + } + + base::test::TaskEnvironment task_environment_; + base::HistogramTester histogram_tester_; + registry_util::RegistryOverrideManager registry_override_manager_; + WinSignalsDecorator decorator_; +}; + +TEST_F(WinSignalsDecoratorTest, NoCSRegistry) { + // HKLM hive was overridden and no value was set, therefore no CS value should + // be returned. + base::RunLoop run_loop; + base::Value::Dict signals; + decorator_.Decorate(signals, run_loop.QuitClosure()); + run_loop.Run(); + + EXPECT_FALSE(signals.Find(device_signals::names::kCrowdStrike)); + + histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); +} + +TEST_F(WinSignalsDecoratorTest, EmptyCSRegistry) { + CreateRegistryKey(kCSAgentRegPath); + + base::RunLoop run_loop; + base::Value::Dict signals; + decorator_.Decorate(signals, run_loop.QuitClosure()); + run_loop.Run(); + + EXPECT_FALSE(signals.Find(device_signals::names::kCrowdStrike)); + + histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); +} + +TEST_F(WinSignalsDecoratorTest, SuccessCSCustomerId) { + CreateRegistryKey(kCSAgentRegPath); + + // Have to Hex-decode the values before storing them. + std::string decoded_customer_id; + ASSERT_TRUE(base::HexStringToString(kFakeCSCustomerId, &decoded_customer_id)); + + SetUpCrowdStrikeInfo(decoded_customer_id, absl::nullopt); + + base::RunLoop run_loop; + base::Value::Dict signals; + decorator_.Decorate(signals, run_loop.QuitClosure()); + run_loop.Run(); + + auto* cs_value = signals.Find(device_signals::names::kCrowdStrike); + ASSERT_TRUE(cs_value); + ASSERT_TRUE(cs_value->is_dict()); + + const auto& cs_value_dict = cs_value->GetDict(); + + auto* customer_id = + cs_value_dict.FindString(device_signals::names::kCustomerId); + ASSERT_TRUE(customer_id); + EXPECT_EQ(*customer_id, kFakeCSCustomerId); + + auto* agent_id = cs_value_dict.FindString(device_signals::names::kAgentId); + EXPECT_FALSE(agent_id); + + histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); +} + +TEST_F(WinSignalsDecoratorTest, SuccessCSAgentId) { + CreateRegistryKey(kCSAgentRegPath); + + // Have to Hex-decode the values before storing them. + std::string decoded_agent_id; + ASSERT_TRUE(base::HexStringToString(kFakeCSAgentId, &decoded_agent_id)); + SetUpCrowdStrikeInfo(absl::nullopt, decoded_agent_id); + + base::RunLoop run_loop; + base::Value::Dict signals; + decorator_.Decorate(signals, run_loop.QuitClosure()); + run_loop.Run(); + + auto* cs_value = signals.Find(device_signals::names::kCrowdStrike); + ASSERT_TRUE(cs_value); + ASSERT_TRUE(cs_value->is_dict()); + + const auto& cs_value_dict = cs_value->GetDict(); + + auto* customer_id = + cs_value_dict.FindString(device_signals::names::kCustomerId); + EXPECT_FALSE(customer_id); + + auto* agent_id = cs_value_dict.FindString(device_signals::names::kAgentId); + ASSERT_TRUE(agent_id); + EXPECT_EQ(*agent_id, kFakeCSAgentId); + + histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); +} + +TEST_F(WinSignalsDecoratorTest, SuccessAllCS) { + CreateRegistryKey(kCSAgentRegPath); + + // Have to Hex-decode the values before storing them. + std::string decoded_customer_id; + ASSERT_TRUE(base::HexStringToString(kFakeCSCustomerId, &decoded_customer_id)); + + std::string decoded_agent_id; + ASSERT_TRUE(base::HexStringToString(kFakeCSAgentId, &decoded_agent_id)); + SetUpCrowdStrikeInfo(decoded_customer_id, decoded_agent_id); + + base::RunLoop run_loop; + base::Value::Dict signals; + decorator_.Decorate(signals, run_loop.QuitClosure()); + run_loop.Run(); + + auto* cs_value = signals.Find(device_signals::names::kCrowdStrike); + ASSERT_TRUE(cs_value); + ASSERT_TRUE(cs_value->is_dict()); + + const auto& cs_value_dict = cs_value->GetDict(); + + auto* customer_id = + cs_value_dict.FindString(device_signals::names::kCustomerId); + ASSERT_TRUE(customer_id); + EXPECT_EQ(*customer_id, kFakeCSCustomerId); + + auto* agent_id = cs_value_dict.FindString(device_signals::names::kAgentId); + ASSERT_TRUE(agent_id); + EXPECT_EQ(*agent_id, kFakeCSAgentId); + + histogram_tester_.ExpectTotalCount(kLatencyHistogram, 1); +} + +} // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc b/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc index 4fb3d36..5bd7504 100644 --- a/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc +++ b/chrome/browser/enterprise/connectors/device_trust/signals/signals_service_factory.cc
@@ -18,6 +18,10 @@ #include "chrome/browser/profiles/profile.h" #include "components/policy/core/common/management/management_service.h" +#if BUILDFLAG(IS_WIN) +#include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/win/win_signals_decorator.h" +#endif // BUILDFLAG(IS_WIN) + #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) #include "base/check.h" #include "chrome/browser/enterprise/connectors/device_trust/signals/decorators/browser/browser_signals_decorator.h" @@ -54,6 +58,10 @@ enterprise_signals::ContextInfoFetcher::CreateInstance( profile, ConnectorsServiceFactory::GetForBrowserContext(profile)))); +#if BUILDFLAG(IS_WIN) + decorators.push_back(std::make_unique<WinSignalsDecorator>()); +#endif // BUILDFLAG(IS_WIN) + #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) policy::CloudPolicyStore* store = nullptr;
diff --git a/chrome/browser/enterprise/connectors/device_trust/test/BUILD.gn b/chrome/browser/enterprise/connectors/device_trust/test/BUILD.gn deleted file mode 100644 index 61d64612..0000000 --- a/chrome/browser/enterprise/connectors/device_trust/test/BUILD.gn +++ /dev/null
@@ -1,39 +0,0 @@ -# Copyright 2022 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -source_set("test_support") { - testonly = true - public = [ "device_trust_test_environment.h" ] - - sources = [] - - public_deps = [ - "//base", - "//chrome/browser/enterprise/connectors/device_trust/key_management/core/network:network", - ] - - deps = [] - - if (is_win) { - public += [ "device_trust_test_environment_win.h" ] - sources += [ "device_trust_test_environment_win.cc" ] - - public_deps += [ - "//base/test:test_support", - "//chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands:test_support", - "//chrome/browser/enterprise/connectors/device_trust/key_management/core/network:test_support", - "//crypto:test_support", - ] - - deps += [ - "//chrome/browser/enterprise/connectors/device_trust/key_management/core:constants", - "//chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence:persistence", - "//chrome/browser/enterprise/connectors/device_trust/key_management/installer:elevated_rotation", - "//chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service:rotate_util", - "//chrome/install_static:install_static_util", - "//chrome/installer/util:constants", - "//components/policy/proto", - ] - } -}
diff --git a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment.h b/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment.h deleted file mode 100644 index 443855c..0000000 --- a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment.h +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_H_ -#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_H_ - -#include "base/strings/string_piece.h" -#include "base/threading/thread.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/key_network_delegate.h" - -namespace enterprise_connectors { - -class DeviceTrustTestEnvironment { - public: - using HttpResponseCode = KeyNetworkDelegate::HttpResponseCode; - - DeviceTrustTestEnvironment(base::StringPiece thread_name, - HttpResponseCode upload_response_code) - : worker_thread_(std::string(thread_name)), - upload_response_code_(upload_response_code) {} - virtual ~DeviceTrustTestEnvironment() = default; - - // Set the result of key upload to test different behaviours of - // KeyNetworkDelegate - virtual void SetUploadResult(HttpResponseCode upload_response_code) = 0; - - // Set up an existing device trust key on the device, to test the case where a - // key already exists on the device - virtual void SetUpExistingKey() = 0; - - protected: - // Use a non-ThreadPool worker thread as the code that will run in the - // background uses a RunLoop, and those are prohibited from running on the - // ThreadPool. - base::Thread worker_thread_; - - // Preset response code of key upload, used to test different behaviours of - // KeyNetworkDelegate - HttpResponseCode upload_response_code_; -}; - -} // namespace enterprise_connectors - -#endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_H_
diff --git a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.cc b/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.cc deleted file mode 100644 index dc19a39..0000000 --- a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.cc +++ /dev/null
@@ -1,113 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.h" - -#include <windows.h> - -#include <memory> -#include <utility> - -#include "base/check.h" -#include "base/command_line.h" -#include "base/notreached.h" -#include "base/task/thread_pool.h" -#include "base/win/registry.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/win_key_rotation_command.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/mock_key_network_delegate.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence/key_persistence_delegate_factory.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/shared_command_constants.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/key_rotation_manager.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/installer/management_service/rotate_util.h" -#include "chrome/install_static/install_util.h" -#include "chrome/installer/util/util_constants.h" -#include "components/policy/proto/device_management_backend.pb.h" -#include "components/prefs/pref_service.h" -#include "services/network/public/cpp/shared_url_loader_factory.h" -#include "testing/gmock/include/gmock/gmock.h" - -using testing::_; -using testing::Invoke; -using testing::StrictMock; - -using BPKUR = enterprise_management::BrowserPublicKeyUploadRequest; - -namespace enterprise_connectors { - -using test::MockKeyNetworkDelegate; -using HttpResponseCode = KeyNetworkDelegate::HttpResponseCode; - -constexpr HttpResponseCode kSuccessCode = 200; - -HRESULT MockRunGoogleUpdateElevatedCommandFn( - HttpResponseCode upload_response_code, - const wchar_t* command, - const std::vector<std::string>& args, - DWORD* return_code) { - base::CommandLine cmd_line(base::CommandLine::NO_PROGRAM); - DCHECK(args.size() == 3); - cmd_line.AppendSwitchASCII(switches::kRotateDTKey, args[0]); - cmd_line.AppendSwitchASCII(switches::kDmServerUrl, args[1]); - cmd_line.AppendSwitchASCII(switches::kNonce, args[2]); - auto mock_network_delegate = - std::make_unique<StrictMock<MockKeyNetworkDelegate>>(); - EXPECT_CALL(*mock_network_delegate, SendPublicKeyToDmServer(_, _, _, _)) - .WillOnce(Invoke( - [upload_response_code](const GURL& url, const std::string& dm_token, - const std::string& body, - base::OnceCallback<void(int)> callback) { - std::move(callback).Run(upload_response_code); - })); - *return_code = enterprise_connectors::RotateDeviceTrustKey( - enterprise_connectors::KeyRotationManager::Create( - std::move(mock_network_delegate)), - cmd_line, install_static::GetChromeChannel()) - ? installer::InstallStatus::ROTATE_DTKEY_SUCCESS - : installer::InstallStatus::ROTATE_DTKEY_FAILED; - return S_OK; -} - -DeviceTrustTestEnvironmentWin::DeviceTrustTestEnvironmentWin() - : DeviceTrustTestEnvironment("device_trust_test_environment_win", - kSuccessCode) { - registry_override_manager_.OverrideRegistry(HKEY_LOCAL_MACHINE); - KeyRotationCommandFactory::SetFactoryInstanceForTesting(this); -} - -DeviceTrustTestEnvironmentWin::~DeviceTrustTestEnvironmentWin() { - KeyRotationCommandFactory::ClearFactoryInstanceForTesting(); -} - -std::unique_ptr<KeyRotationCommand> -DeviceTrustTestEnvironmentWin::CreateCommand( - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - PrefService* local_prefs) { - if (!worker_thread_.IsRunning()) { - // Make sure the worker thread is running. Its task runner can be reused for - // all created commands, and its destruction will be handled automatically. - DCHECK(worker_thread_.Start()); - } - return std::make_unique<WinKeyRotationCommand>( - base::BindRepeating(&MockRunGoogleUpdateElevatedCommandFn, - upload_response_code_), - worker_thread_.task_runner()); -} - -void DeviceTrustTestEnvironmentWin::SetUploadResult( - HttpResponseCode upload_response_code) { - upload_response_code_ = upload_response_code; -} - -void DeviceTrustTestEnvironmentWin::SetUpExistingKey() { - auto* factory = KeyPersistenceDelegateFactory::GetInstance(); - auto trust_level = BPKUR::CHROME_BROWSER_HW_KEY; - std::unique_ptr<KeyPersistenceDelegate> win_key_persistence_delegate = - factory->CreateKeyPersistenceDelegate(); - auto key_pair = win_key_persistence_delegate->CreateKeyPair(); - EXPECT_TRUE(win_key_persistence_delegate->StoreKeyPair( - trust_level, key_pair->key()->GetWrappedKey())); -} - -} // namespace enterprise_connectors
diff --git a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.h b/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.h deleted file mode 100644 index 38b2d4c..0000000 --- a/chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment_win.h +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_WIN_H_ -#define CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_WIN_H_ - -#include "base/test/test_reg_util_win.h" -#include "base/threading/thread.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands/scoped_key_rotation_command_factory.h" -#include "chrome/browser/enterprise/connectors/device_trust/key_management/core/network/mock_key_network_delegate.h" -#include "chrome/browser/enterprise/connectors/device_trust/test/device_trust_test_environment.h" -#include "crypto/scoped_mock_unexportable_key_provider.h" - -namespace enterprise_connectors { - -class DeviceTrustTestEnvironmentWin : public DeviceTrustTestEnvironment, - public KeyRotationCommandFactory { - public: - DeviceTrustTestEnvironmentWin(); - ~DeviceTrustTestEnvironmentWin() override; - - // KeyRotationCommandFactory: - std::unique_ptr<KeyRotationCommand> CreateCommand( - scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, - PrefService* local_prefs) override; - - // DeviceTrustTestEnvironment: - void SetUploadResult(HttpResponseCode upload_response_code) override; - - // DeviceTrustTestEnvironment: - void SetUpExistingKey() override; - - // RegistryOverrideManager for testing with registry - registry_util::RegistryOverrideManager registry_override_manager_; - crypto::ScopedMockUnexportableKeyProvider scoped_key_provider_; -}; - -} // namespace enterprise_connectors - -#endif // CHROME_BROWSER_ENTERPRISE_CONNECTORS_DEVICE_TRUST_TEST_DEVICE_TRUST_TEST_ENVIRONMENT_WIN_H_
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc index e3215a8..1fe35d3 100644 --- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_apitest_chromeos.cc
@@ -71,7 +71,7 @@ std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_; ash::ScopedCrosSettingsTestHelper settings_helper_; - std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_; + std::unique_ptr<ash::FakeOwnerSettingsService> owner_settings_service_; }; IN_PROC_BROWSER_TEST_F(BluetoothLowEnergyApiTestChromeOs,
diff --git a/chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_on_off.cc b/chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_on_off.cc index 648cb1f..925e188 100644 --- a/chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_on_off.cc +++ b/chrome/browser/extensions/api/settings_private/chromeos_resolve_time_zone_by_geolocation_on_off.cc
@@ -71,7 +71,7 @@ // Check if preference is policy or primary-user controlled, and therefore // cannot deactivate automatic timezone. - if (chromeos::system::TimeZoneResolverManager:: + if (ash::system::TimeZoneResolverManager:: IsTimeZoneResolutionPolicyControlled() || !profile_->IsSameOrParent(ProfileManager::GetPrimaryUserProfile())) { return SetPrefResult::PREF_NOT_MODIFIABLE; @@ -86,9 +86,9 @@ profile_->GetPrefs()->SetInteger( ::prefs::kResolveTimezoneByGeolocationMethod, - static_cast<int>(new_value ? chromeos::system::TimeZoneResolverManager:: + static_cast<int>(new_value ? ash::system::TimeZoneResolverManager:: TimeZoneResolveMethod::IP_ONLY - : chromeos::system::TimeZoneResolverManager:: + : ash::system::TimeZoneResolverManager:: TimeZoneResolveMethod::DISABLED)); return SetPrefResult::SUCCESS;
diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc index 9190df0..88cda6d 100644 --- a/chrome/browser/extensions/api/settings_private/prefs_util.cc +++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc
@@ -162,10 +162,6 @@ PrefsUtil::~PrefsUtil() {} -#if BUILDFLAG(IS_CHROMEOS_ASH) -using CrosSettings = chromeos::CrosSettings; -#endif - const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() { static PrefsUtil::TypedPrefMap* s_allowlist = nullptr; if (s_allowlist) @@ -997,7 +993,7 @@ new settings_api::PrefObject()); #if BUILDFLAG(IS_CHROMEOS_ASH) - const base::Value* value = CrosSettings::Get()->GetPref(name); + const base::Value* value = ash::CrosSettings::Get()->GetPref(name); if (!value) { LOG(WARNING) << "Cros settings pref not found: " << name; return nullptr; @@ -1386,7 +1382,7 @@ bool PrefsUtil::IsCrosSetting(const std::string& pref_name) { #if BUILDFLAG(IS_CHROMEOS_ASH) - return CrosSettings::Get()->IsCrosSettings(pref_name); + return ash::CrosSettings::Get()->IsCrosSettings(pref_name); #else return false; #endif
diff --git a/chrome/browser/extensions/api/video_capture/video_capture_apitest_chromeos.cc b/chrome/browser/extensions/api/video_capture/video_capture_apitest_chromeos.cc index 991e948..f2c2f22 100644 --- a/chrome/browser/extensions/api/video_capture/video_capture_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/video_capture/video_capture_apitest_chromeos.cc
@@ -74,7 +74,7 @@ std::unique_ptr<user_manager::ScopedUserManager> user_manager_enabler_; ash::ScopedCrosSettingsTestHelper settings_helper_; - std::unique_ptr<chromeos::FakeOwnerSettingsService> owner_settings_service_; + std::unique_ptr<ash::FakeOwnerSettingsService> owner_settings_service_; }; IN_PROC_BROWSER_TEST_F(VideoCaptureApiTestChromeOs,
diff --git a/chrome/browser/extensions/extension_context_menu_model_unittest.cc b/chrome/browser/extensions/extension_context_menu_model_unittest.cc index 0366ddcc..d40ee31a 100644 --- a/chrome/browser/extensions/extension_context_menu_model_unittest.cc +++ b/chrome/browser/extensions/extension_context_menu_model_unittest.cc
@@ -459,7 +459,7 @@ #if BUILDFLAG(IS_CHROMEOS_ASH) // The ash::KioskAppManager, if initialized, needs to be cleaned up. // TODO(devlin): This should probably go somewhere more central, like - // chromeos::ScopedCrosSettingsTestHelper. + // ash::ScopedCrosSettingsTestHelper. ash::KioskAppManager::Shutdown(); #endif
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json index a4b98ff..2f2d884 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json
@@ -6622,6 +6622,11 @@ "expiry_milestone": 90 }, { + "name": "truncate-table-view-cell-title", + "owners": [ "fedegermi", "bling-flags@google.com" ], + "expiry_milestone": 112 + }, + { "name": "trusted-web-activity-notification-permission-delegation", "owners": [ "mvanouwerkerk", "//chrome/android/java/src/org/chromium/chrome/browser/browserservices/OWNERS" ], "expiry_milestone": 108
diff --git a/chrome/browser/hid/hid_chooser_context.cc b/chrome/browser/hid/hid_chooser_context.cc index 968005aa..84fa9d0d 100644 --- a/chrome/browser/hid/hid_chooser_context.cc +++ b/chrome/browser/hid/hid_chooser_context.cc
@@ -698,7 +698,7 @@ bool HidChooserContext::CanApplyPolicy() { #if BUILDFLAG(IS_CHROMEOS_ASH) - auto* profile_helper = chromeos::ProfileHelper::Get(); + auto* profile_helper = ash::ProfileHelper::Get(); DCHECK(profile_helper); user_manager::User* user = profile_helper->GetUserByProfile(profile_); DCHECK(user);
diff --git a/chrome/browser/lacros/browser_test_util.cc b/chrome/browser/lacros/browser_test_util.cc index 4074ec6..ca3615f 100644 --- a/chrome/browser/lacros/browser_test_util.cc +++ b/chrome/browser/lacros/browser_test_util.cc
@@ -10,7 +10,6 @@ #include "base/time/time.h" #include "base/timer/timer.h" #include "chrome/browser/ui/lacros/window_utility.h" -#include "chromeos/crosapi/mojom/test_controller.mojom.h" #include "chromeos/lacros/lacros_service.h" #include "ui/aura/env.h" #include "ui/aura/window.h" @@ -158,6 +157,47 @@ outer_loop.Run(); } +// TODO(crbug.com/1208258): Use ASSERT or EXPECT macros instead of CHECK. +void WaitForShelfItemState(const std::string& id, + uint32_t state, + const base::Location& location) { + base::RunLoop outer_loop; + auto wait_for_state = base::BindRepeating( + [](base::RunLoop* outer_loop, const std::string& id, + uint32_t expected_state) { + auto* lacros_service = chromeos::LacrosService::Get(); + CHECK(lacros_service->IsAvailable<crosapi::mojom::TestController>()); + int interface_version = lacros_service->GetInterfaceVersion( + crosapi::mojom::TestController::Uuid_); + int min_version = + static_cast<int>(crosapi::mojom::TestController::MethodMinVersions:: + kGetShelfItemStateMinVersion); + CHECK_GE(interface_version, min_version); + + base::RunLoop inner_loop(base::RunLoop::Type::kNestableTasksAllowed); + uint32_t actual_state = + static_cast<uint32_t>(crosapi::mojom::ShelfItemState::kNormal); + lacros_service->GetRemote<crosapi::mojom::TestController>() + ->GetShelfItemState(id, + base::BindOnce( + [](base::RunLoop* loop, uint32_t* out_state, + uint32_t state) { + *out_state = std::move(state); + loop->Quit(); + }, + &inner_loop, &actual_state)); + inner_loop.Run(); + + if (actual_state == expected_state) + outer_loop->Quit(); + }, + &outer_loop, id, state); + + base::RepeatingTimer timer; + timer.Start(FROM_HERE, base::Milliseconds(1), std::move(wait_for_state)); + outer_loop.Run(location); +} + // Sends a TestController message to Ash to send a mouse click to this |window|. // Waits for both the mouse-down and the mouse-up events to be seen by // |window|. The AuraObserver only waits for the up-event to start processing
diff --git a/chrome/browser/lacros/browser_test_util.h b/chrome/browser/lacros/browser_test_util.h index 87c289dc..4e2d94c 100644 --- a/chrome/browser/lacros/browser_test_util.h +++ b/chrome/browser/lacros/browser_test_util.h
@@ -7,8 +7,13 @@ #ifndef CHROME_BROWSER_LACROS_BROWSER_TEST_UTIL_H_ #define CHROME_BROWSER_LACROS_BROWSER_TEST_UTIL_H_ +#include <stdint.h> + #include <string> +#include "base/location.h" +#include "chromeos/crosapi/mojom/test_controller.mojom.h" + namespace aura { class Window; } // namespace aura @@ -33,6 +38,13 @@ // |exists|. void WaitForShelfItem(const std::string& id, bool exists); +// Waits for the app to be closed, running or active, matching |state|, +// a bitmask of |crosapi::mojom::ShelfItemState| values. +void WaitForShelfItemState( + const std::string& id, + uint32_t state, + const base::Location& location = base::Location::Current()); + // This function relies on |window| already being available in ash. It prompts // ash to send the Wayland events associated with a mouse click to the |window|. // It waits for the events to be seen by Aura.
diff --git a/chrome/browser/lacros/net/proxy_config_service_lacros.cc b/chrome/browser/lacros/net/proxy_config_service_lacros.cc index 4ba30e8..4aac886 100644 --- a/chrome/browser/lacros/net/proxy_config_service_lacros.cc +++ b/chrome/browser/lacros/net/proxy_config_service_lacros.cc
@@ -26,20 +26,38 @@ net::ProxyConfigWithAnnotation GetConfigOrDirect( const absl::optional<net::ProxyConfigWithAnnotation>& optional_config, - PrefService* pref_service) { - if (!optional_config || !pref_service || - !pref_service->GetBoolean(prefs::kUseAshProxy)) { - net::ProxyConfigWithAnnotation config = - net::ProxyConfigWithAnnotation::CreateDirect(); - return config; + Profile* profile, + bool proxy_controlled_by_extension) { + DCHECK(profile); + + auto CreateDirect = net::ProxyConfigWithAnnotation::CreateDirect; + + if (!optional_config) + return CreateDirect(); + + // The primary profile always uses the OS proxy. + if (profile->IsMainProfile()) + return optional_config.value(); + + // Incognito profile doesn't apply proxies set by an extension in the main + // profile. + if (profile->IsIncognitoProfile()) { + if (proxy_controlled_by_extension) + return CreateDirect(); + return optional_config.value(); } - return optional_config.value(); + + // Secondary Lacros profiles can opt to use the OS proxy. + return profile->GetPrefs()->GetBoolean(prefs::kUseAshProxy) + ? optional_config.value() + : CreateDirect(); } } // namespace namespace chromeos { -ProxyConfigServiceLacros::ProxyConfigServiceLacros(Profile* profile) { +ProxyConfigServiceLacros::ProxyConfigServiceLacros(Profile* profile) + : profile_(profile) { DCHECK(profile); auto* lacros_service = chromeos::LacrosService::Get(); // crosapi is disabled in browser_tests. @@ -58,13 +76,11 @@ // TODO(acostinas, b:192915915) Enable secondary profiles to configure // `kUseAshProxy` from chrome://settings. if (profile->IsMainProfile()) { - profile->GetPrefs()->SetBoolean(prefs::kUseAshProxy, true); lacros_extension_proxy_tracker_ = std::make_unique<lacros::net::LacrosExtensionProxyTracker>(profile); } - profile_prefs_ = profile->GetPrefs(); - profile_pref_change_registrar_.Init(profile_prefs_); + profile_pref_change_registrar_.Init(profile->GetPrefs()); profile_pref_change_registrar_.Add( prefs::kUseAshProxy, base::BindRepeating(&ProxyConfigServiceLacros::OnUseAshProxyPrefChanged, @@ -75,6 +91,7 @@ void ProxyConfigServiceLacros::OnProxyChanged( crosapi::mojom::ProxyConfigPtr proxy_config) { + proxy_controlled_by_extension_ = !proxy_config->extension.is_null(); cached_config_ = CrosapiProxyToNetProxy(std::move(proxy_config)); NotifyObservers(); } @@ -86,7 +103,8 @@ void ProxyConfigServiceLacros::NotifyObservers() { for (auto& observer : observers_) { observer.OnProxyConfigChanged( - GetConfigOrDirect(cached_config_, profile_prefs_), + GetConfigOrDirect(cached_config_, profile_, + proxy_controlled_by_extension_), ConfigAvailability::CONFIG_VALID); } } @@ -111,7 +129,8 @@ // Returns the last proxy configuration that the Ash // NetworkSettingsService notified us, or the direct proxy if `cached_config_` // is not set. - *config = GetConfigOrDirect(cached_config_, profile_prefs_); + *config = GetConfigOrDirect(cached_config_, profile_, + proxy_controlled_by_extension_); return ConfigAvailability::CONFIG_VALID; }
diff --git a/chrome/browser/lacros/net/proxy_config_service_lacros.h b/chrome/browser/lacros/net/proxy_config_service_lacros.h index 3e4e540..6cd63b3 100644 --- a/chrome/browser/lacros/net/proxy_config_service_lacros.h +++ b/chrome/browser/lacros/net/proxy_config_service_lacros.h
@@ -14,7 +14,6 @@ #include "net/proxy_resolution/proxy_config_with_annotation.h" class PrefRegistrySimple; -class PrefService; class Profile; namespace lacros { @@ -55,9 +54,8 @@ void OnUseAshProxyPrefChanged(); void NotifyObservers(); - - // Owned by the Profile instance. - raw_ptr<PrefService> profile_prefs_ = nullptr; + // The profile associated with this ProxyConfigServiceLacros instance. + raw_ptr<Profile> profile_; PrefChangeRegistrar profile_pref_change_registrar_; @@ -69,6 +67,9 @@ // enforced in the browser only if the pref kUseAshProxy=true and the // kProxy pref, which has precedence, is unset or set to mode=system. absl::optional<net::ProxyConfigWithAnnotation> cached_config_; + // Indicates if the proxy config comes from an extension active in the main + // Lacros profile. + bool proxy_controlled_by_extension_ = false; // Forwards proxy configs set via extensions in the Lacros primary profile // to Ash-Chrome.
diff --git a/chrome/browser/lacros/net/proxy_config_service_lacros_browsertest.cc b/chrome/browser/lacros/net/proxy_config_service_lacros_browsertest.cc index ed43a02..92becb24 100644 --- a/chrome/browser/lacros/net/proxy_config_service_lacros_browsertest.cc +++ b/chrome/browser/lacros/net/proxy_config_service_lacros_browsertest.cc
@@ -5,10 +5,12 @@ #include "chrome/browser/lacros/net/proxy_config_service_lacros.h" #include "base/time/time.h" +#include "chrome/browser/browser_process.h" #include "chrome/browser/lacros/net/network_settings_translation.h" #include "chrome/browser/net/proxy_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/profiles/profile_test_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" @@ -21,6 +23,7 @@ #include "components/proxy_config/proxy_prefs.h" #include "content/public/test/browser_test.h" #include "mojo/public/cpp/bindings/receiver_set.h" +#include "mojo/public/cpp/bindings/remote_set.h" #include "net/proxy_resolution/proxy_config_service.h" namespace { @@ -38,14 +41,19 @@ delete; ~FakeNetworkSettingsService() override = default; - bool HasObserver() { return observer_.is_bound(); } + bool HasObservers() { return !observers_.empty(); } // crosapi::mojom::AshNetworService: void AddNetworkSettingsObserver( mojo::PendingRemote<crosapi::mojom::NetworkSettingsObserver> observer) override { - observer_ = mojo::Remote<crosapi::mojom::NetworkSettingsObserver>( + mojo::Remote<crosapi::mojom::NetworkSettingsObserver> remote( std::move(observer)); + if (cached_proxy_config_) { + remote->OnProxyChanged(cached_proxy_config_.Clone()); + } + observers_.Add(std::move(remote)); + if (quit_closure_) { std::move(quit_closure_).Run(); } @@ -68,13 +76,15 @@ } void SendProxyUpdate(crosapi::mojom::ProxyConfigPtr proxy_config) { - if (observer_) { - observer_->OnProxyChanged(std::move(proxy_config)); + cached_proxy_config_ = std::move(proxy_config); + for (const auto& obs : observers_) { + obs->OnProxyChanged(cached_proxy_config_.Clone()); } } private: - mojo::Remote<crosapi::mojom::NetworkSettingsObserver> observer_; + crosapi::mojom::ProxyConfigPtr cached_proxy_config_; + mojo::RemoteSet<crosapi::mojom::NetworkSettingsObserver> observers_; base::OnceClosure quit_closure_; }; @@ -140,32 +150,10 @@ ->GetRemote<crosapi::mojom::NetworkSettingsService>(); remote.reset(); receiver_.Bind(remote.BindNewPipeAndPassReceiver()); - - pref_proxy_config_tracker_ = - ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( - browser()->profile()->GetPrefs(), nullptr); - - base::RunLoop run_loop; - service_.SetQuitClosure(run_loop.QuitClosure()); - proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService( - pref_proxy_config_tracker_.get(), browser()->profile()); - // Wait for the mojom::NetworkSettingsObserver created by - // `proxy_config_service_` in Lacros to be added as an observer to the - // AshNetworkSettingsService in Ash-Chrome. - run_loop.Run(); - - proxy_monitor_ = std::make_unique<FakeProxyMonitor>(); - proxy_config_service_->AddObserver(proxy_monitor_.get()); + SetupProxyMonitoring(browser()->profile()); } - void TearDownOnMainThread() override { - proxy_config_service_->RemoveObserver(proxy_monitor_.get()); - pref_proxy_config_tracker_->DetachFromPrefService(); - pref_proxy_config_tracker_.reset(); - proxy_config_service_.reset(); - proxy_monitor_.reset(); - base::RunLoop().RunUntilIdle(); - } + void TearDownOnMainThread() override { ResetProxyMonitoring(); } protected: // Sends a proxy update via the AshNetworkSettingService in Ash-Chrome and @@ -177,6 +165,42 @@ run_loop.Run(); } + // Creates the objects that monitor proxy configs coming from Ash and from + // profile prefs. + void SetupProxyMonitoring(Profile* profile) { + pref_proxy_config_tracker_ = + ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( + profile->GetPrefs(), nullptr); + + base::RunLoop run_loop; + service_.SetQuitClosure(run_loop.QuitClosure()); + proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService( + pref_proxy_config_tracker_.get(), profile); + // Wait for the mojom::NetworkSettingsObserver created by + // `proxy_config_service_` in Lacros to be added as an observer to the + // AshNetworkSettingsService in Ash-Chrome. + run_loop.Run(); + + proxy_monitor_ = std::make_unique<FakeProxyMonitor>(); + proxy_config_service_->AddObserver(proxy_monitor_.get()); + } + + void ResetProxyMonitoring() { + proxy_config_service_->RemoveObserver(proxy_monitor_.get()); + pref_proxy_config_tracker_->DetachFromPrefService(); + pref_proxy_config_tracker_.reset(); + proxy_config_service_.reset(); + proxy_monitor_.reset(); + base::RunLoop().RunUntilIdle(); + } + + Profile* CreateSecondaryProfile() { + ProfileManager* profile_manager = g_browser_process->profile_manager(); + base::FilePath profile_path = + profile_manager->GenerateNextProfileDirectoryPath(); + return profiles::testing::CreateProfileSync(profile_manager, profile_path); + } + std::unique_ptr<net::ProxyConfigService> proxy_config_service_; // Monitors global and profile prefs related to proxy configuration. std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; @@ -193,7 +217,7 @@ IN_PROC_BROWSER_TEST_F(ProxyConfigServiceLacrosTest, ObserverSet) { if (!IsServiceAvailable()) return; - ASSERT_TRUE(service_.HasObserver()); + ASSERT_TRUE(service_.HasObservers()); } // Tests that proxy updates from the AshNetworkService in Ash-Chrome are @@ -275,35 +299,76 @@ CrosapiProxyToNetProxy(std::move(proxy_config)).value().ToValue()); } -// Test that verifies that the system proxy sent from Ash-Chrome is only applied -// if the pref `kUseAshProxy` is true. +// Test that verifies that for secondary profiles, the system proxy sent from +// Ash-Chrome is only applied if the pref `kUseAshProxy` is true. IN_PROC_BROWSER_TEST_F(ProxyConfigServiceLacrosTest, UseAshProxyPref) { if (!IsServiceAvailable()) return; - browser()->profile()->GetPrefs()->SetBoolean(prefs::kUseAshProxy, false); + const base::Value expectedDirect = net::ProxyConfig::CreateDirect().ToValue(); + const base::Value expectedAutoDetect = + net::ProxyConfig::CreateAutoDetect().ToValue(); + + ResetProxyMonitoring(); + auto* profile = CreateSecondaryProfile(); + SetupProxyMonitoring(profile); + + profile->GetPrefs()->SetBoolean(prefs::kUseAshProxy, false); crosapi::mojom::ProxyConfigPtr proxy_config = crosapi::mojom::ProxyConfig::New(); - crosapi::mojom::ProxySettingsWpadPtr wpad = - crosapi::mojom::ProxySettingsWpad::New(); - wpad->pac_url = GURL(kPacUrl); - // TODO(https://crbug.com/1320656): This test seems buggy; wpad is never used. proxy_config->proxy_settings = crosapi::mojom::ProxySettings::NewWpad( crosapi::mojom::ProxySettingsWpad::New()); service_.SendProxyUpdate(proxy_config.Clone()); base::RunLoop().RunUntilIdle(); // Verify that the system proxy is not applied. EXPECT_EQ(proxy_monitor_->cached_proxy_config_.value().ToValue(), - net::ProxyConfig::CreateDirect().ToValue()); + expectedDirect); - browser()->profile()->GetPrefs()->SetBoolean(prefs::kUseAshProxy, true); + profile->GetPrefs()->SetBoolean(prefs::kUseAshProxy, true); // Verify that the system proxy is applied. EXPECT_EQ(proxy_monitor_->cached_proxy_config_.value().ToValue(), - CrosapiProxyToNetProxy(proxy_config.Clone()).value().ToValue()); + expectedAutoDetect); // Verify that the system proxy is not applied. - browser()->profile()->GetPrefs()->SetBoolean(prefs::kUseAshProxy, false); + profile->GetPrefs()->SetBoolean(prefs::kUseAshProxy, false); EXPECT_EQ(proxy_monitor_->cached_proxy_config_.value().ToValue(), - net::ProxyConfig::CreateDirect().ToValue()); + expectedDirect); +} + +// Verifies that the proxy is only applied incognito if it's not controlled by a +// an extension active in the main Lacros profile. +IN_PROC_BROWSER_TEST_F(ProxyConfigServiceLacrosTest, IncognitoProfile) { + if (!IsServiceAvailable()) + return; + const base::Value expectedDirect = net::ProxyConfig::CreateDirect().ToValue(); + const base::Value expectedAutoDetect = + net::ProxyConfig::CreateAutoDetect().ToValue(); + + ResetProxyMonitoring(); + auto* incognito_profile = + browser()->profile()->GetPrimaryOTRProfile(/*create_if_needed=*/true); + SetupProxyMonitoring(incognito_profile); + + // kUseAshProxy should be ignored for the incognito profile. + incognito_profile->GetPrefs()->SetBoolean(prefs::kUseAshProxy, true); + + crosapi::mojom::ProxyConfigPtr proxy_config = + crosapi::mojom::ProxyConfig::New(); + proxy_config->proxy_settings = crosapi::mojom::ProxySettings::NewWpad( + crosapi::mojom::ProxySettingsWpad::New()); + proxy_config->extension = crosapi::mojom::ExtensionControllingProxy::New(); + service_.SendProxyUpdate(proxy_config.Clone()); + base::RunLoop().RunUntilIdle(); + + // Verify that the system proxy controlled by the pref is not applied. + EXPECT_EQ(proxy_monitor_->cached_proxy_config_.value().ToValue(), + expectedDirect); + + proxy_config->extension.reset(); + SendAshProxyUpdateAndWait(std::move(proxy_config)); + + // Verify that the system proxy is applied. + EXPECT_EQ(proxy_monitor_->cached_proxy_config_.value().ToValue(), + expectedAutoDetect); } } // namespace chromeos
diff --git a/chrome/browser/metrics/power/power_metrics_reporter.cc b/chrome/browser/metrics/power/power_metrics_reporter.cc index b495992..805e868 100644 --- a/chrome/browser/metrics/power/power_metrics_reporter.cc +++ b/chrome/browser/metrics/power/power_metrics_reporter.cc
@@ -248,7 +248,7 @@ new_battery_state->full_charged_capacity.value()); base::UmaHistogramBoolean( - "Power. BatteryDischargeGranularityAvailable", + "Power.BatteryDischargeGranularityAvailable", new_battery_state->battery_discharge_granularity.has_value()); DCHECK_EQ(new_battery_state->battery_discharge_granularity.has_value(),
diff --git a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc b/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc index 3db8618e..7b4b476 100644 --- a/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc +++ b/chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc
@@ -82,7 +82,6 @@ #include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/common/referrer.h" -#include "content/public/common/result_codes.h" #include "content/public/test/back_forward_cache_util.h" #include "content/public/test/browser_test.h" #include "content/public/test/browser_test_utils.h" @@ -100,7 +99,6 @@ #include "services/network/public/cpp/features.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/common/chrome_debug_urls.h" #include "third_party/blink/public/common/features.h" #include "third_party/blink/public/common/user_agent/user_agent_metadata.h" #include "third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom.h" @@ -3319,7 +3317,7 @@ ASSERT_EQ(all_frames_value, main_frame_value); } -class PageLoadMetricsBrowserTestTerminatedPage +class PageLoadMetricsBrowserTestDiscardedPage : public PageLoadMetricsBrowserTest { protected: void SetUpOnMainThread() override { @@ -3402,7 +3400,7 @@ } }; -IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestTerminatedPage, +IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestDiscardedPage, UkmIsRecordedForDiscardedForegroundTabPage) { // Open a new foreground tab and navigate. The new tab would be of index 1 // which would be used below in verifying the tab is discarded. @@ -3426,7 +3424,7 @@ lcp_time, 10); } -IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestTerminatedPage, +IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestDiscardedPage, UkmIsRecordedForDiscardedBackgroundTabPage) { // Open a new foreground tab and navigate. content::WebContents* contents = OpenTabAndNavigate(); @@ -3454,80 +3452,6 @@ lcp_time, 10); } -// This test is to verify page load metrics are recorded in case when the -// render process is shut down. -IN_PROC_BROWSER_TEST_F(PageLoadMetricsBrowserTestTerminatedPage, - UkmIsRecordedWhenRenderProcessShutsDown) { - content::WebContents* contents = OpenTabAndNavigate(); - - // Wait for LCP emission and observation. - double lcp_time = GetLCPTimeFromEmittedLCPEntry(contents); - content::RenderProcessHost* process = RenderFrameHost()->GetProcess(); - - // Shut down render process. - content::RenderProcessHostWatcher crash_observer( - process, content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); - EXPECT_TRUE(process->Shutdown(content::RESULT_CODE_KILLED)); - crash_observer.Wait(); - EXPECT_FALSE(RenderFrameHost()->IsRenderFrameLive()); - - // Verify page load metric is recorded. - EXPECT_NEAR( - GetUKMPageLoadMetric( - PageLoad::kPaintTiming_NavigationToLargestContentfulPaint2Name), - lcp_time, 10); -} - -// This class is used to verify page load metrics are recorded in case of -// crashes of different kinds. These crashes are simulated by navigating to the -// chrome debug urls. -class PageLoadMetricsBrowserTestCrashedPage - : public PageLoadMetricsBrowserTestTerminatedPage, - public ::testing::WithParamInterface<const char*> {}; - -IN_PROC_BROWSER_TEST_P(PageLoadMetricsBrowserTestCrashedPage, - UkmIsRecordedForCrashedTabPage) { - // Open a new foreground tab and navigate. - content::WebContents* contents = OpenTabAndNavigate(); - - // The back/forward cache is disabled because page load metrics can also be - // recorded when entering into the bfcache. We want to test that page load - // metrics are recorded via the PageLoadTracker destructor which is called in - // all crash cases. - content::DisableBackForwardCacheForTesting( - contents, content::BackForwardCache::TEST_REQUIRES_NO_CACHING); - - // Wait for LCP emission and observation. This is to ensure there is an LCP - // entry to report at the time of killing the page. - double lcp_time = GetLCPTimeFromEmittedLCPEntry(contents); - - // Kill the page. - content::ScopedAllowRendererCrashes scoped_allow_renderer_crashes; - EXPECT_TRUE(ui_test_utils::NavigateToURL(browser(), GURL(GetParam()))); - - // Page being crashed is only verifiable in these crashes. - if (GetParam() == blink::kChromeUIKillURL || - GetParam() == blink::kChromeUICrashURL) - EXPECT_TRUE( - browser()->tab_strip_model()->GetActiveWebContents()->IsCrashed()); - - // Verify page load metric is recorded. - EXPECT_NEAR( - GetUKMPageLoadMetric( - PageLoad::kPaintTiming_NavigationToLargestContentfulPaint2Name), - lcp_time, 10); -} - -INSTANTIATE_TEST_SUITE_P( - CrashCases, - PageLoadMetricsBrowserTestCrashedPage, - testing::ValuesIn({blink::kChromeUIKillURL, blink::kChromeUICrashURL, - blink::kChromeUIGpuCrashURL, - blink::kChromeUIBrowserCrashURL, - blink::kChromeUIMemoryExhaustURL, - blink::kChromeUINetworkErrorURL, - blink::kChromeUIProcessInternalsURL})); - // Test is flaky. https://crbug.com/1260953 #if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || \ BUILDFLAG(IS_WIN)
diff --git a/chrome/browser/platform_keys/extension_platform_keys_service.cc b/chrome/browser/platform_keys/extension_platform_keys_service.cc index 730c8d3..8e9885f 100644 --- a/chrome/browser/platform_keys/extension_platform_keys_service.cc +++ b/chrome/browser/platform_keys/extension_platform_keys_service.cc
@@ -959,7 +959,7 @@ // TODO(crbug.com/1146430) Revisit this place when Lacros-Chrome starts being // used on the login screen. #if BUILDFLAG(IS_CHROMEOS_ASH) - return ProfileHelper::IsSigninProfile( + return ash::ProfileHelper::IsSigninProfile( Profile::FromBrowserContext(browser_context_)); #else return false;
diff --git a/chrome/browser/platform_util_unittest.cc b/chrome/browser/platform_util_unittest.cc index ac28f24..9c1cd57 100644 --- a/chrome/browser/platform_util_unittest.cc +++ b/chrome/browser/platform_util_unittest.cc
@@ -117,9 +117,7 @@ JSONStringValueDeserializer json_string_deserializer(json_manifest); std::unique_ptr<base::Value> manifest = json_string_deserializer.Deserialize(&error_code, &error); - base::DictionaryValue* manifest_dictionary; - - manifest->GetAsDictionary(&manifest_dictionary); + base::Value::Dict* manifest_dictionary = manifest->GetIfDict(); ASSERT_TRUE(manifest_dictionary); scoped_refptr<extensions::Extension> extension =
diff --git a/chrome/browser/policy/networking/policy_cert_service_factory.cc b/chrome/browser/policy/networking/policy_cert_service_factory.cc index 7e808f6..164457ab 100644 --- a/chrome/browser/policy/networking/policy_cert_service_factory.cc +++ b/chrome/browser/policy/networking/policy_cert_service_factory.cc
@@ -49,7 +49,7 @@ if (!policy_certificate_provider) return nullptr; - if (chromeos::ProfileHelper::Get()->IsSigninProfile(profile)) { + if (ash::ProfileHelper::Get()->IsSigninProfile(profile)) { return new PolicyCertService(profile, policy_certificate_provider, /*may_use_profile_wide_trust_anchors=*/false); } @@ -57,9 +57,8 @@ // Don't allow policy-provided certificates for "special" Profiles except the // one listed above. user_manager::UserManager* user_manager = user_manager::UserManager::Get(); - const user_manager::User* user = - chromeos::ProfileHelper::Get()->GetUserByProfile( - profile->GetOriginalProfile()); + const user_manager::User* user = ash::ProfileHelper::Get()->GetUserByProfile( + profile->GetOriginalProfile()); if (!user) return nullptr;
diff --git a/chrome/browser/privacy_sandbox/android/BUILD.gn b/chrome/browser/privacy_sandbox/android/BUILD.gn index 1a5e717..d8290594 100644 --- a/chrome/browser/privacy_sandbox/android/BUILD.gn +++ b/chrome/browser/privacy_sandbox/android/BUILD.gn
@@ -33,6 +33,7 @@ "java/src/org/chromium/chrome/browser/privacy_sandbox/TopicPreference.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/AdMeasurementFragmentV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/FledgeFragmentV4.java", + "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeROWV4.java", "java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java", @@ -112,10 +113,12 @@ "java/res/drawable/ic_performance_max_24dp.xml", "java/res/drawable/privacy_sandbox_dialog_illustration.xml", "java/res/drawable/privacy_sandbox_illustration.xml", + "java/res/drawable/privacy_sandbox_interests_illustration_v4.xml", "java/res/drawable/privacy_sandbox_notice_eea_illustration_v4.xml", - "java/res/drawable/privacy_sandbox_notice_row_illustration_v4.xml", "java/res/layout/privacy_sandbox_consent.xml", "java/res/layout/privacy_sandbox_consent_dropdown.xml", + "java/res/layout/privacy_sandbox_consent_eea_dropdown_v4.xml", + "java/res/layout/privacy_sandbox_consent_eea_v4.xml", "java/res/layout/privacy_sandbox_header.xml", "java/res/layout/privacy_sandbox_notice.xml", "java/res/layout/privacy_sandbox_notice_bottom_sheet.xml",
diff --git a/chrome/browser/privacy_sandbox/android/java/res/drawable/privacy_sandbox_notice_row_illustration_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/drawable/privacy_sandbox_interests_illustration_v4.xml similarity index 100% rename from chrome/browser/privacy_sandbox/android/java/res/drawable/privacy_sandbox_notice_row_illustration_v4.xml rename to chrome/browser/privacy_sandbox/android/java/res/drawable/privacy_sandbox_interests_illustration_v4.xml
diff --git a/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_dropdown_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_dropdown_v4.xml new file mode 100644 index 0000000..d55734b --- /dev/null +++ b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_dropdown_v4.xml
@@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Copyright 2022 The Chromium Authors +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/privacy_sandbox_consent_eea_dropdown" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <TextView + android:layout_marginBottom="@dimen/promo_between_text_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_learn_more_heading" + style="@style/TextAppearance.TextMediumThick.Primary" /> + + <TextView + android:id="@+id/privacy_sandbox_m1_consent_learn_more_bullet_one" + android:layout_marginBottom="@dimen/promo_between_text_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <TextView + android:id="@+id/privacy_sandbox_m1_consent_learn_more_bullet_two" + android:layout_marginBottom="@dimen/promo_between_text_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <TextView + android:id="@+id/privacy_sandbox_m1_consent_learn_more_bullet_three" + android:layout_marginBottom="@dimen/list_item_default_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <TextView + android:layout_marginBottom="@dimen/promo_between_text_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_learn_more_link" + style="@style/TextAppearance.TextMedium.Secondary" /> + +</LinearLayout>
diff --git a/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_v4.xml new file mode 100644 index 0000000..1c35306 --- /dev/null +++ b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_consent_eea_v4.xml
@@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +Copyright 2022 The Chromium Authors +Use of this source code is governed by a BSD-style license that can be +found in the LICENSE file. +--> + +<LinearLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/privacy_sandbox_dialog" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <org.chromium.components.browser_ui.widget.BoundedLinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + app:maxWidthLandscape="@dimen/privacy_sandbox_dialog_max_width" + app:maxWidthPortrait="@dimen/privacy_sandbox_dialog_max_width"> + + <org.chromium.components.browser_ui.widget.FadingEdgeScrollView + android:id="@+id/privacy_sandbox_consent_eea_scroll_view" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_weight="1"> + + <LinearLayout + android:id="@+id/privacy_sandbox_consent_eea_content" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center_horizontal" + android:orientation="vertical"> + + <ImageView + android:layout_marginTop="@dimen/privacy_sandbox_dialog_illustration_margin_top" + android:layout_marginBottom="@dimen/privacy_sandbox_dialog_title_margin" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_height="@dimen/privacy_sandbox_chrome_logo_height" + android:layout_width="@dimen/privacy_sandbox_chrome_logo_width" + app:srcCompat="@drawable/chrome_sync_logo" + android:importantForAccessibility="no" /> + + <TextView + android:id="@+id/privacy_sandbox_notice_title" + android:layout_marginBottom="@dimen/privacy_sandbox_dialog_title_margin" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_title" + android:gravity="center" + style="@style/TextAppearance.Headline.Primary" /> + + <TextView + android:layout_marginBottom="@dimen/list_item_default_margin" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_description_1" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <TextView + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_description_2" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <ImageView + android:layout_marginTop="@dimen/privacy_sandbox_dialog_illustration_margin_top" + android:layout_marginBottom="@dimen/privacy_sandbox_dialog_illustration_margin_bottom" + android:layout_height="@dimen/privacy_sandbox_interests_illustration_height" + android:layout_width="match_parent" + app:srcCompat="@drawable/privacy_sandbox_interests_illustration_v4" + android:importantForAccessibility="no" /> + + <TextView + android:layout_marginBottom="@dimen/list_item_default_margin" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_description_3" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <LinearLayout + android:layout_marginBottom="@dimen/list_item_default_margin" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:id="@+id/dropdown_element" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:orientation="horizontal"> + + <TextView + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:minHeight="@dimen/privacy_sandbox_notice_dialog_dropdown_button_height" + android:text="@string/privacy_sandbox_m1_consent_learn_more_expand_label" + style="@style/TextAppearance.TextMedium.Secondary" /> + + <org.chromium.ui.widget.CheckableImageView + android:id="@+id/expand_arrow" + android:layout_width="24dp" + android:layout_height="@dimen/privacy_sandbox_notice_dialog_dropdown_button_height"/> + + </LinearLayout> + + <LinearLayout + android:id="@+id/dropdown_container" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="gone" /> + + <TextView + android:layout_marginBottom="@dimen/privacy_sandbox_notice_margin_bottom" + android:layout_marginHorizontal="@dimen/list_item_default_margin" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/privacy_sandbox_m1_consent_description_4" + style="@style/TextAppearance.TextMedium.Secondary" /> + + </LinearLayout> + + </org.chromium.components.browser_ui.widget.FadingEdgeScrollView> + + <LinearLayout + android:orientation="horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:weightSum="2" + android:layout_margin="@dimen/promo_dialog_padding" + android:layout_marginHorizontal="24dp"> + + <org.chromium.ui.widget.ButtonCompat + android:id="@+id/ack_button" + android:focusable="true" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/privacy_sandbox_consent_button_margin_between" + android:text="@string/privacy_sandbox_m1_consent_accept_button" + style="@style/OutlinedButton" /> + <org.chromium.ui.widget.ButtonCompat + android:id="@+id/settings_button" + android:focusable="true" + android:layout_width="0dp" + android:layout_weight="1" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/privacy_sandbox_consent_button_margin_between" + android:text="@string/privacy_sandbox_m1_consent_decline_button" + style="@style/OutlinedButton" /> + + </LinearLayout> + </org.chromium.components.browser_ui.widget.BoundedLinearLayout> +</LinearLayout>
diff --git a/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_notice_row_v4.xml b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_notice_row_v4.xml index fc007bc..2c712c4e 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_notice_row_v4.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/layout/privacy_sandbox_notice_row_v4.xml
@@ -37,8 +37,8 @@ android:layout_marginTop="@dimen/privacy_sandbox_dialog_illustration_margin_top" android:layout_marginBottom="@dimen/privacy_sandbox_dialog_title_margin" android:layout_marginHorizontal="@dimen/list_item_default_margin" - android:layout_height="@dimen/privacy_sandbox_notice_row_logo_height" - android:layout_width="@dimen/privacy_sandbox_notice_row_logo_width" + android:layout_height="@dimen/privacy_sandbox_chrome_logo_height" + android:layout_width="@dimen/privacy_sandbox_chrome_logo_width" app:srcCompat="@drawable/chrome_sync_logo" android:importantForAccessibility="no" /> @@ -72,7 +72,7 @@ android:layout_marginBottom="@dimen/privacy_sandbox_dialog_illustration_margin_bottom" android:layout_height="@dimen/privacy_sandbox_interests_illustration_height" android:layout_width="match_parent" - app:srcCompat="@drawable/privacy_sandbox_notice_row_illustration_v4" + app:srcCompat="@drawable/privacy_sandbox_interests_illustration_v4" android:importantForAccessibility="no" /> <TextView
diff --git a/chrome/browser/privacy_sandbox/android/java/res/values/dimens.xml b/chrome/browser/privacy_sandbox/android/java/res/values/dimens.xml index bd3b7d9..c954074 100644 --- a/chrome/browser/privacy_sandbox/android/java/res/values/dimens.xml +++ b/chrome/browser/privacy_sandbox/android/java/res/values/dimens.xml
@@ -18,7 +18,7 @@ <dimen name="privacy_sandbox_notice_margin_bottom">32dp</dimen> <dimen name="privacy_sandbox_dialog_title_margin">20dp</dimen> <dimen name="privacy_sandbox_dialog_buttons_margin_top">24dp</dimen> - <dimen name="privacy_sandbox_notice_row_logo_width">60dp</dimen> - <dimen name="privacy_sandbox_notice_row_logo_height">61dp</dimen> + <dimen name="privacy_sandbox_chrome_logo_width">60dp</dimen> + <dimen name="privacy_sandbox_chrome_logo_height">61dp</dimen> <dimen name="privacy_sandbox_interests_illustration_height">185dp</dimen> </resources>
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java new file mode 100644 index 0000000..6c9dc91 --- /dev/null +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogConsentEEAV4.java
@@ -0,0 +1,118 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.chrome.browser.privacy_sandbox.v4; + +import android.app.Dialog; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.ScrollView; + +import androidx.annotation.NonNull; + +import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxReferrer; +import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; +import org.chromium.chrome.browser.privacy_sandbox.R; +import org.chromium.components.browser_ui.settings.SettingsLauncher; +import org.chromium.ui.widget.ButtonCompat; +import org.chromium.ui.widget.CheckableImageView; + +/** + * Dialog in the form of a consent shown for the Privacy Sandbox. + */ +public class PrivacySandboxDialogConsentEEAV4 extends Dialog implements View.OnClickListener { + private SettingsLauncher mSettingsLauncher; + private View mContentView; + + private final CheckableImageView mExpandArrowView; + private LinearLayout mDropdownContainer; + private LinearLayout mDropdownElement; + + public PrivacySandboxDialogConsentEEAV4( + Context context, @NonNull SettingsLauncher settingsLauncher) { + super(context, R.style.ThemeOverlay_BrowserUI_Fullscreen); + mSettingsLauncher = settingsLauncher; + mContentView = + LayoutInflater.from(context).inflate(R.layout.privacy_sandbox_consent_eea_v4, null); + setContentView(mContentView); + + ButtonCompat ackButton = mContentView.findViewById(R.id.ack_button); + ackButton.setOnClickListener(this); + ButtonCompat settingsButton = mContentView.findViewById(R.id.settings_button); + settingsButton.setOnClickListener(this); + + // Controls for the expanding section. + mDropdownElement = mContentView.findViewById(R.id.dropdown_element); + mDropdownElement.setOnClickListener(this); + mDropdownContainer = mContentView.findViewById(R.id.dropdown_container); + mExpandArrowView = mContentView.findViewById(R.id.expand_arrow); + mExpandArrowView.setImageDrawable(PrivacySandboxDialogUtils.createExpandDrawable(context)); + mExpandArrowView.setChecked(isDropdownExpanded()); + } + + @Override + public void show() { + // TODO(b/254408752): Report show action. + super.show(); + } + + // OnClickListener: + @Override + public void onClick(View view) { + int id = view.getId(); + if (id == R.id.ack_button) { + // TODO(b/254408752): Report consent acknowledge action. + dismiss(); + } else if (id == R.id.settings_button) { + // TODO(b/254408752): Report open settings action. + dismiss(); + // TODO(b/254408752): Update referrer. + PrivacySandboxSettingsBaseFragment.launchPrivacySandboxSettings( + getContext(), mSettingsLauncher, PrivacySandboxReferrer.PRIVACY_SANDBOX_NOTICE); + } else if (id == R.id.dropdown_element) { + var content = mContentView.findViewById(R.id.privacy_sandbox_consent_eea_content); + ScrollView scrollView = + mContentView.findViewById(R.id.privacy_sandbox_consent_eea_scroll_view); + + if (isDropdownExpanded()) { + // TODO(b/254408752): Report consent eea more info section closed action. + mDropdownContainer.setVisibility(View.GONE); + mDropdownContainer.removeAllViews(); + scrollView.post(() -> { scrollView.fullScroll(ScrollView.FOCUS_UP); }); + } else { + mDropdownContainer.setVisibility(View.VISIBLE); + // TODO(b/254408752): Report consent eea more info section opened action. + LayoutInflater.from(getContext()) + .inflate(R.layout.privacy_sandbox_consent_eea_dropdown_v4, + mDropdownContainer); + + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_consent_learn_more_bullet_one, + R.string.privacy_sandbox_m1_consent_learn_more_bullet_1); + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_consent_learn_more_bullet_two, + R.string.privacy_sandbox_m1_consent_learn_more_bullet_2); + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_consent_learn_more_bullet_three, + R.string.privacy_sandbox_m1_consent_learn_more_bullet_3); + + scrollView.post(() -> { scrollView.scrollTo(0, mDropdownElement.getTop()); }); + } + + mExpandArrowView.setChecked(isDropdownExpanded()); + PrivacySandboxDialogUtils.updateDropdownControlContentDescription(getContext(), view, + isDropdownExpanded(), + R.string.privacy_sandbox_m1_consent_learn_more_expand_label); + view.announceForAccessibility(getContext().getResources().getString(isDropdownExpanded() + ? R.string.accessibility_expanded_group + : R.string.accessibility_collapsed_group)); + } + } + + private boolean isDropdownExpanded() { + return mDropdownContainer != null && mDropdownContainer.getVisibility() == View.VISIBLE; + } +}
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java index 45dd939..64a4c75 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogNoticeEEAV4.java
@@ -6,29 +6,21 @@ import android.app.Dialog; import android.content.Context; -import android.text.SpannableString; -import android.text.style.StyleSpan; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ScrollView; -import android.widget.TextView; -import androidx.annotation.IdRes; import androidx.annotation.NonNull; -import androidx.annotation.StringRes; import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxReferrer; import org.chromium.chrome.browser.privacy_sandbox.PrivacySandboxSettingsBaseFragment; import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.components.browser_ui.settings.SettingsLauncher; -import org.chromium.ui.text.SpanApplier; import org.chromium.ui.widget.ButtonCompat; import org.chromium.ui.widget.CheckableImageView; -import org.chromium.ui.widget.ChromeBulletSpan; /** * Dialog in the form of a notice shown for the Privacy Sandbox. @@ -103,13 +95,16 @@ .inflate(R.layout.privacy_sandbox_notice_eea_dropdown_v4, mDropdownContainer); - setDropdownDescription(mDropdownContainer, + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_notice_eea_learn_more_bullet_one, R.string.privacy_sandbox_m1_notice_eea_learn_more_bullet_1); - setDropdownDescription(mDropdownContainer, + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_notice_eea_learn_more_bullet_two, R.string.privacy_sandbox_m1_notice_eea_learn_more_bullet_2); - setDropdownDescription(mDropdownContainer, + PrivacySandboxDialogUtils.setBulletTextWithBoldContent(getContext(), + mDropdownContainer, R.id.privacy_sandbox_m1_notice_eea_learn_more_bullet_three, R.string.privacy_sandbox_m1_notice_eea_learn_more_bullet_3); @@ -131,17 +126,6 @@ } } - private void setDropdownDescription( - ViewGroup container, @IdRes int viewId, @StringRes int stringRes) { - TextView view = container.findViewById(viewId); - SpannableString spannableString = - SpanApplier.applySpans(getContext().getResources().getString(stringRes), - new SpanApplier.SpanInfo( - "<b>", "</b>", new StyleSpan(android.graphics.Typeface.BOLD))); - spannableString.setSpan(new ChromeBulletSpan(getContext()), 0, spannableString.length(), 0); - view.setText(spannableString); - } - private void setBulletsDescription() { PrivacySandboxDialogUtils.setBulletText(getContext(), mContentView, R.id.privacy_sandbox_m1_notice_eea_bullet_one,
diff --git a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java index 257b488..a958c4c 100644 --- a/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java +++ b/chrome/browser/privacy_sandbox/android/java/src/org/chromium/chrome/browser/privacy_sandbox/v4/PrivacySandboxDialogUtils.java
@@ -7,7 +7,9 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.text.SpannableString; +import android.text.style.StyleSpan; import android.view.View; +import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.IdRes; @@ -17,6 +19,7 @@ import org.chromium.chrome.browser.privacy_sandbox.R; import org.chromium.ui.drawable.StateListDrawableBuilder; +import org.chromium.ui.text.SpanApplier; import org.chromium.ui.widget.ChromeBulletSpan; /** @@ -87,4 +90,23 @@ bullet.setSpan(new ChromeBulletSpan(context), 0, bullet.length(), 0); bulletView.setText(bullet); } + + /** + * Creates a ChromeBulletSpan with bold content and set its text. + * + * @param context Current context. + * @param targetLayout The layout view where the bullet should live. + * @param bulletViewId The bullet viewId. + * @param stringRes The string resource from where the text is retrieved. + */ + public static void setBulletTextWithBoldContent(Context context, ViewGroup targetLayout, + @IdRes int bulletViewId, @StringRes int stringRes) { + TextView view = targetLayout.findViewById(bulletViewId); + SpannableString spannableString = + SpanApplier.applySpans(context.getResources().getString(stringRes), + new SpanApplier.SpanInfo( + "<b>", "</b>", new StyleSpan(android.graphics.Typeface.BOLD))); + spannableString.setSpan(new ChromeBulletSpan(context), 0, spannableString.length(), 0); + view.setText(spannableString); + } }
diff --git a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java index 277550a..cd39068 100644 --- a/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java +++ b/chrome/browser/privacy_sandbox/android/javatests/src/org/chromium/chrome/browser/privacy_sandbox/PrivacySandboxDialogTest.java
@@ -43,6 +43,7 @@ import org.chromium.base.test.util.JniMocker; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeSwitches; +import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogConsentEEAV4; import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeEEAV4; import org.chromium.chrome.browser.privacy_sandbox.v4.PrivacySandboxDialogNoticeROWV4; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; @@ -195,6 +196,18 @@ @Test @SmallTest @Feature({"RenderTest"}) + public void testRenderEEAConsent() throws IOException { + TestThreadUtils.runOnUiThreadBlocking(() -> { + mDialog = new PrivacySandboxDialogConsentEEAV4( + sActivityTestRule.getActivity(), mSettingsLauncher); + mDialog.show(); + }); + renderViewWithId(R.id.privacy_sandbox_dialog, "privacy_sandbox_eea_consent_dialog"); + } + + @Test + @SmallTest + @Feature({"RenderTest"}) public void testRenderEEANotice() throws IOException { PrivacySandboxDialogNotice notice = null; TestThreadUtils.runOnUiThreadBlocking(() -> {
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc index a2075e49..fc3709fc 100644 --- a/chrome/browser/profiles/profile_manager.cc +++ b/chrome/browser/profiles/profile_manager.cc
@@ -668,6 +668,8 @@ // static Profile* ProfileManager::GetLastUsedProfileIfLoaded() { ProfileManager* profile_manager = g_browser_process->profile_manager(); + if (!profile_manager) // Can be null in unit tests. + return nullptr; return profile_manager->GetProfileByPath( profile_manager->GetLastUsedProfileDir()); } @@ -730,6 +732,7 @@ return to_return; } +#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // static Profile* ProfileManager::GetPrimaryUserProfile() { #if BUILDFLAG(IS_CHROMEOS_ASH) @@ -762,6 +765,7 @@ return profile_manager->GetActiveUserOrOffTheRecordProfile(); } +#endif // BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // static Profile* ProfileManager::GetActiveUserProfile() {
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h index cfe4034..e0d0b86 100644 --- a/chrome/browser/profiles/profile_manager.h +++ b/chrome/browser/profiles/profile_manager.h
@@ -103,14 +103,11 @@ // like the System profile. static std::vector<Profile*> GetLastOpenedProfiles(); - // WARNING: do not use this function on Desktop platforms (Windows, Mac, - // Linux). See https://crbug.com/1264436 for more info. - // TODO(https://crbug.com/1264436): restrict this function to Android and - // ChromeOS. - // +#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID) // Get the profile for the user which created the current session. // Note that in case of a guest account this will return a 'suitable' profile. static Profile* GetPrimaryUserProfile(); +#endif // WARNING: do not use this function on Desktop platforms (Windows, Mac, // Linux). See https://crbug.com/1264436 for more info.
diff --git a/chrome/browser/profiles/profile_manager_unittest.cc b/chrome/browser/profiles/profile_manager_unittest.cc index 8e2958c..5462092 100644 --- a/chrome/browser/profiles/profile_manager_unittest.cc +++ b/chrome/browser/profiles/profile_manager_unittest.cc
@@ -936,7 +936,8 @@ TEST_F(ProfileManagerGuestTest, GuestProfileAttributes) { // In these tests, the primary profile is a guest one. - Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); + Profile* primary_profile = ProfileManager::GetLastUsedProfile(); + ASSERT_TRUE(primary_profile); ProfileAttributesEntry* entry = g_browser_process->profile_manager() ->GetProfileAttributesStorage()
diff --git a/chrome/browser/resources/chromeos/assistant_optin/BUILD.gn b/chrome/browser/resources/chromeos/assistant_optin/BUILD.gn index e0861f59..864805ce 100644 --- a/chrome/browser/resources/chromeos/assistant_optin/BUILD.gn +++ b/chrome/browser/resources/chromeos/assistant_optin/BUILD.gn
@@ -81,8 +81,6 @@ "assistant_common_styles.html", "assistant_optin.html", "assistant_optin.js", - "assistant_related_info.html", - "assistant_related_info.js", "assistant_value_prop.html", "assistant_value_prop.js", "assistant_voice_match.html", @@ -106,7 +104,6 @@ in_files = [ "assistant_common_styles.m.js", "assistant_icon.m.js", - "assistant_related_info.m.js", "assistant_value_prop.m.js", "assistant_voice_match.m.js", "browser_proxy.m.js", @@ -125,6 +122,7 @@ in_files = [ "assistant_loading.js", "assistant_optin_flow.js", + "assistant_related_info.js", "setting_zippy.js", ] } @@ -162,13 +160,13 @@ extra_deps = [ ":web_components" ] } -js_library("assistant_related_info.m") { - sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.m.js" ] +js_library("assistant_related_info") { + sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.js" ] deps = [ "../login/components/behaviors:oobe_i18n_behavior.m", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] - extra_deps = [ ":assistant_related_info_module" ] + extra_deps = [ ":web_components" ] } js_library("assistant_value_prop.m") { @@ -209,7 +207,6 @@ public_deps = [ ":assistant_common_styles_module", ":assistant_icon_module", - ":assistant_related_info_module", ":assistant_value_prop_module", ":assistant_voice_match_module", ":modulize", @@ -229,15 +226,6 @@ html_type = "iron-iconset" } -polymer_modulizer("assistant_related_info") { - js_file = "assistant_related_info.js" - html_file = "assistant_related_info.html" - html_type = "dom-module" - auto_imports = assistant_auto_imports - migrated_imports = assistant_migrated_imports - namespace_rewrites = assistant_namespace_rewrites -} - polymer_modulizer("assistant_value_prop") { js_file = "assistant_value_prop.js" html_file = "assistant_value_prop.html" @@ -277,6 +265,7 @@ js_files = [ "assistant_loading.js", "assistant_optin_flow.js", + "assistant_related_info.js", "setting_zippy.js", ] }
diff --git a/chrome/browser/resources/chromeos/assistant_optin/assistant_optin_flow.js b/chrome/browser/resources/chromeos/assistant_optin/assistant_optin_flow.js index b936278..ba3de846 100644 --- a/chrome/browser/resources/chromeos/assistant_optin/assistant_optin_flow.js +++ b/chrome/browser/resources/chromeos/assistant_optin/assistant_optin_flow.js
@@ -12,7 +12,7 @@ import './assistant_common_styles.m.js'; import './assistant_icon.m.js'; import './assistant_loading.js'; -import './assistant_related_info.m.js'; +import './assistant_related_info.js'; import './assistant_voice_match.m.js'; import './assistant_value_prop.m.js'; import './setting_zippy.js';
diff --git a/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.html b/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.html index d59ee54..1a23e8e0 100644 --- a/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.html +++ b/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.html
@@ -4,123 +4,100 @@ found in the LICENSE file. --> -<link rel="import" href="chrome://resources/html/polymer.html"> +<style include="oobe-dialog-host-styles assistant-common-styles"> + #content-container .content { + padding-bottom: 16px; + } -<link rel="import" href="chrome://resources/cr_elements/cr_lottie/cr_lottie.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> + .example-text { + color: var(--cros-text-color-primary); + font-family: var(--oobe-header-font-family); + font-size: 15px; + font-weight: 500; + line-height: 22px; + max-width: 330px; + } -<link rel="import" href="../components/behaviors/oobe_dialog_host_behavior.html"> -<link rel="import" href="../components/behaviors/oobe_i18n_behavior.html"> -<link rel="import" href="../components/buttons/oobe_next_button.html"> -<link rel="import" href="../components/buttons/oobe_text_button.html"> -<link rel="import" href="../components/common_styles/oobe_dialog_host_styles.html"> -<link rel="import" href="../components/dialogs/oobe_adaptive_dialog.html"> + #relatedInfoImg { + height: 288px; + } -<link rel="import" href="./assistant_common_styles.html"> -<link rel="import" href="./assistant_icon.html"> -<link rel="import" href="./browser_proxy.html"> -<link rel="import" href="./setting_zippy.html"> -<link rel="import" href="./utils.html"> + #subtitle-container div:not(:last-child) { + padding-bottom: 16px; + } -<dom-module id="assistant-related-info"> - <template> - <style include="oobe-dialog-host-styles assistant-common-styles"> - #content-container .content { - padding-bottom: 16px; - } - - .example-text { - color: var(--cros-text-color-primary); - font-family: var(--oobe-header-font-family); - font-size: 15px; - font-weight: 500; - line-height: 22px; - max-width: 330px; - } - - #relatedInfoImg { - height: 288px; - } - - #subtitle-container div:not(:last-child) { - padding-bottom: 16px; - } - - :host-context([orientation=vertical]) oobe-adaptive-dialog { - --oobe-adaptive-dialog-content-top-padding: 0; - } - </style> - <oobe-adaptive-dialog id="relatedInfoDialog" role="dialog" hide-shadow - aria-label$= - "[[getDialogTitle_(locale, skipActivityControl_, childName_)]]"> - <iron-icon slot="icon" icon="assistant-32:assistant" - aria-label$="[[i18nDynamic(locale, 'assistantLogo')]]"> - </iron-icon> - <h1 slot="title"> - [[getDialogTitle_(locale, skipActivityControl_, childName_)]] - </h1> - <div slot="subtitle" id="subtitle-container" - hidden$="[[skipActivityControl_]]"> - <div hidden="[[childName_]]"> - [[i18nDynamic(locale, 'assistantScreenContextDesc')]] - </div> - <div hidden="[[!childName_]]"> - [[i18nDynamic( - locale, 'assistantScreenContextDescForChild', childName_)]] - </div> - <div>[[i18nDynamic(locale, 'assistantRelatedInfoMessage')]]</div> + :host-context([orientation=vertical]) oobe-adaptive-dialog { + --oobe-adaptive-dialog-content-top-padding: 0; + } +</style> +<oobe-adaptive-dialog id="relatedInfoDialog" role="dialog" hide-shadow + aria-label$= + "[[getDialogTitle_(locale, skipActivityControl_, childName_)]]"> + <iron-icon slot="icon" icon="assistant-32:assistant" + aria-label$="[[i18nDynamic(locale, 'assistantLogo')]]"> + </iron-icon> + <h1 slot="title"> + [[getDialogTitle_(locale, skipActivityControl_, childName_)]] + </h1> + <div slot="subtitle" id="subtitle-container" + hidden$="[[skipActivityControl_]]"> + <div hidden="[[childName_]]"> + [[i18nDynamic(locale, 'assistantScreenContextDesc')]] + </div> + <div hidden="[[!childName_]]"> + [[i18nDynamic( + locale, 'assistantScreenContextDescForChild', childName_)]] + </div> + <div>[[i18nDynamic(locale, 'assistantRelatedInfoMessage')]]</div> + </div> + <div id="animation-container" hidden$="[[!skipActivityControl_]]"> + <webview id="assistant-animation-webview" tabindex="-1"></webview> + </div> + <div slot="content" class="flex layout vertical center center-justified" + hidden$="[[skipActivityControl_]]"> + <div class="example-text" hidden="[[childName_]]"> + [[i18nDynamic(locale, 'assistantRelatedInfoExample')]] + </div> + <div class="example-text" hidden="[[!childName_]]"> + [[i18nDynamic(locale, 'assistantRelatedInfoExampleForChild')]] + </div> + <cr-lottie id="relatedInfoImg" + animation-url="[[getAnimationUrl_(isDarkModeActive_)]]"> + </cr-lottie> + </div> + <div slot="content" id="content-container" class="landscape-header-aligned" + hidden$="[[!skipActivityControl_]]"> + <div class="content" hidden="[[childName_]]"> + [[i18nDynamic(locale, 'assistantRelatedInfoReturnedUserMessage')]] + </div> + <div class="content" hidden="[[!childName_]]"> + [[i18nDynamic(locale, + 'assistantRelatedInfoReturnedUserMessageForChild', childName_)]] + </div> + <div class="line"></div> + <setting-zippy id="zippy"> + <iron-media-query query="(prefers-color-scheme: dark)" + query-matches="{{isDarkModeActive_}}"> + </iron-media-query> + <div slot="title"> + [[i18nDynamic(locale, 'assistantScreenContextTitle')]] </div> - <div id="animation-container" hidden$="[[!skipActivityControl_]]"> - <webview id="assistant-animation-webview" tabindex="-1"></webview> + <div slot="content" hidden="[[childName_]]"> + [[i18nDynamic(locale, 'assistantScreenContextDesc')]] </div> - <div slot="content" class="flex layout vertical center center-justified" - hidden$="[[skipActivityControl_]]"> - <div class="example-text" hidden="[[childName_]]"> - [[i18nDynamic(locale, 'assistantRelatedInfoExample')]] - </div> - <div class="example-text" hidden="[[!childName_]]"> - [[i18nDynamic(locale, 'assistantRelatedInfoExampleForChild')]] - </div> - <cr-lottie id="relatedInfoImg" - animation-url="[[getAnimationUrl_(isDarkModeActive_)]]"> - </cr-lottie> + <div slot="content" hidden="[[!childName_]]"> + [[i18nDynamic(locale, + 'assistantScreenContextDescForChild', childName_)]] </div> - <div slot="content" id="content-container" class="landscape-header-aligned" - hidden$="[[!skipActivityControl_]]"> - <div class="content" hidden="[[childName_]]"> - [[i18nDynamic(locale, 'assistantRelatedInfoReturnedUserMessage')]] - </div> - <div class="content" hidden="[[!childName_]]"> - [[i18nDynamic(locale, - 'assistantRelatedInfoReturnedUserMessageForChild', childName_)]] - </div> - <div class="line"></div> - <setting-zippy id="zippy"> - <iron-media-query query="(prefers-color-scheme: dark)" - query-matches="{{isDarkModeActive_}}"> - </iron-media-query> - <div slot="title"> - [[i18nDynamic(locale, 'assistantScreenContextTitle')]] - </div> - <div slot="content" hidden="[[childName_]]"> - [[i18nDynamic(locale, 'assistantScreenContextDesc')]] - </div> - <div slot="content" hidden="[[!childName_]]"> - [[i18nDynamic(locale, - 'assistantScreenContextDescForChild', childName_)]] - </div> - </setting-zippy> - </div> - <div slot="bottom-buttons" class="layout horizontal end-justified"> - <oobe-text-button id="skip-button" disabled="[[loading]]" - text-key="assistantOptinNoThanksButton" on-click="onSkipTap_"> - </oobe-text-button> - <oobe-text-button id="next-button" inverse="[[!equalWeightButtons_]]" - disabled="[[loading]]" text-key="assistantOptinAgreeButton" - on-click="onNextTap_"> - </oobe-text-button> - </div> - </oobe-adaptive-dialog> - </template> - <script src="assistant_related_info.js"></script> -</dom-module> + </setting-zippy> + </div> + <div slot="bottom-buttons" class="layout horizontal end-justified"> + <oobe-text-button id="skip-button" disabled="[[loading]]" + text-key="assistantOptinNoThanksButton" on-click="onSkipTap_"> + </oobe-text-button> + <oobe-text-button id="next-button" inverse="[[!equalWeightButtons_]]" + disabled="[[loading]]" text-key="assistantOptinAgreeButton" + on-click="onNextTap_"> + </oobe-text-button> + </div> +</oobe-adaptive-dialog>
diff --git a/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.js b/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.js index 2df0425..ecefe72 100644 --- a/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.js +++ b/chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.js
@@ -10,7 +10,24 @@ * Event 'loaded' will be fired when the page has been successfully loaded. */ -/* #js_imports_placeholder */ +import '//resources/cr_elements/cr_lottie/cr_lottie.js'; +import '//resources/polymer/v3_0/iron-icon/iron-icon.js'; +import '../components/buttons/oobe_next_button.js'; +import '../components/buttons/oobe_text_button.js'; +import '../components/common_styles/oobe_dialog_host_styles.m.js'; +import '../components/dialogs/oobe_adaptive_dialog.js'; +import './assistant_common_styles.m.js'; +import './assistant_icon.m.js'; +import './setting_zippy.js'; + +import {afterNextRender, html, mixinBehaviors, Polymer, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + +import {OobeDialogHostBehavior} from '../components/behaviors/oobe_dialog_host_behavior.m.js'; +import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../components/behaviors/oobe_i18n_behavior.m.js'; + +import {BrowserProxyImpl} from './browser_proxy.m.js'; +import {AssistantNativeIconType, webviewStripLinksContentScript} from './utils.m.js'; + /** * Name of the screen. @@ -22,8 +39,8 @@ * @constructor * @extends {PolymerElement} */ -const AssistantRelatedInfoBase = Polymer.mixinBehaviors( - [OobeI18nBehavior, OobeDialogHostBehavior], Polymer.Element); +const AssistantRelatedInfoBase = + mixinBehaviors([OobeI18nBehavior, OobeDialogHostBehavior], PolymerElement); /** * @polymer @@ -33,7 +50,9 @@ return 'assistant-related-info'; } - /* #html_template_placeholder */ + static get template() { + return html`{__html_template__}`; + } static get properties() { return { @@ -148,8 +167,8 @@ */ this.screenShown_ = false; - /** @private {?assistant.BrowserProxy} */ - this.browserProxy_ = assistant.BrowserProxyImpl.getInstance(); + /** @private {?BrowserProxy} */ + this.browserProxy_ = BrowserProxyImpl.getInstance(); } setUrlTemplateForTesting(url) { @@ -314,8 +333,7 @@ this.reloadPage(); this.initialized_ = true; } else { - Polymer.RenderStatus.afterNextRender( - this, () => this.$['next-button'].focus()); + afterNextRender(this, () => this.$['next-button'].focus()); this.browserProxy_.screenShown(RELATED_INFO_SCREEN_ID); this.screenShown_ = true; }
diff --git a/chrome/browser/resources/chromeos/assistant_optin/modulization_utils.gni b/chrome/browser/resources/chromeos/assistant_optin/modulization_utils.gni index f69cc5d4..dbee7aaa 100644 --- a/chrome/browser/resources/chromeos/assistant_optin/modulization_utils.gni +++ b/chrome/browser/resources/chromeos/assistant_optin/modulization_utils.gni
@@ -37,6 +37,7 @@ # Assistant "chrome/browser/resources/chromeos/assistant_optin/assistant_loading.html", + "chrome/browser/resources/chromeos/assistant_optin/assistant_related_info.html", "chrome/browser/resources/chromeos/assistant_optin/setting_zippy.html", # Chrome
diff --git a/chrome/browser/resources/chromeos/login/BUILD.gn b/chrome/browser/resources/chromeos/login/BUILD.gn index 34722794..2bc9af4 100644 --- a/chrome/browser/resources/chromeos/login/BUILD.gn +++ b/chrome/browser/resources/chromeos/login/BUILD.gn
@@ -153,7 +153,10 @@ out_manifest = "$target_gen_dir/$existing_unconditional_files_manifest" in_files = [ "cr_ui.js", + "display_manager.js", "i18n_setup.js", + "login_ui_tools.js", + "multi_tap_detector.js", "oobe.css", "oobe.html", "oobe.js", @@ -190,9 +193,6 @@ out_folder = "$target_gen_dir/$oobe_preprocessed_folder" out_manifest = "$target_gen_dir/$autogenerated_unconditional_files_manifest" in_files = [ - "display_manager.m.js", - "login_ui_tools.m.js", - "multi_tap_detector.m.js", "components/behaviors/login_screen_behavior.m.js", "components/behaviors/multi_step_behavior.m.js", "components/behaviors/oobe_dialog_host_behavior.m.js", @@ -317,7 +317,6 @@ # Main group for Polymer3 elements group("polymer3_elements") { public_deps = [ - ":modulize", "../keyboard:modulize", "components:polymer3_elements", "debug:modulize", @@ -359,27 +358,24 @@ is_polymer3 = true closure_flags = default_closure_args deps = [ - ":cr_ui.m", - ":display_manager.m", - ":login_ui_tools.m", - ":multi_tap_detector.m", + ":cr_ui", + ":display_manager", + ":login_ui_tools", + ":multi_tap_detector", ] } ############################### # Closure compiler libraries below -js_library("login_ui_tools") { -} - js_library("i18n_setup") { deps = [ "//ui/webui/resources/js:load_time_data.m" ] } -js_library("cr_ui.m") { +js_library("cr_ui") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/cr_ui.js" ] deps = [ - ":display_manager.m", + ":display_manager", "//ash/webui/common/resources:cr_deprecated", "//ui/webui/resources/js:cr.m", "//ui/webui/resources/js:load_time_data.m", @@ -387,45 +383,41 @@ extra_deps = [ ":copy_js" ] } -js_library("display_manager.m") { - sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/display_manager.m.js" ] +js_library("display_manager") { + sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/display_manager.js" ] deps = [ - ":multi_tap_detector.m", + ":multi_tap_detector", "../keyboard:keyboard_utils.m", "components:display_manager_types.m", "components:oobe_types.m", ] extra_deps = [ - ":modulize", + ":copy_js", "../keyboard:modulize", ] } -js_library("login_ui_tools.m") { +js_library("login_ui_tools") { sources = [ - "$root_gen_dir/chrome/browser/resources/chromeos/login/login_ui_tools.m.js", + "$root_gen_dir/chrome/browser/resources/chromeos/login/login_ui_tools.js", ] deps = [] - extra_deps = [ ":modulize" ] + extra_deps = [ ":copy_js" ] } -js_library("multi_tap_detector.m") { - sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/multi_tap_detector.m.js" ] +js_library("multi_tap_detector") { + sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/multi_tap_detector.js" ] deps = [] - extra_deps = [ ":modulize" ] -} - -js_modulizer("modulize") { - input_files = [ - "display_manager.js", - "login_ui_tools.js", - "multi_tap_detector.js", - ] - namespace_rewrites = [ "cr.ui.toCssPx|toCssPx" ] + extra_deps = [ ":copy_js" ] } # Copy existing files to output directory for closure compilation. copy("copy_js") { - sources = [ "cr_ui.js" ] + sources = [ + "cr_ui.js", + "display_manager.js", + "login_ui_tools.js", + "multi_tap_detector.js", + ] outputs = [ "$target_gen_dir/{{source_file_part}}" ] }
diff --git a/chrome/browser/resources/chromeos/login/components/BUILD.gn b/chrome/browser/resources/chromeos/login/components/BUILD.gn index e81498f..21af39ad 100644 --- a/chrome/browser/resources/chromeos/login/components/BUILD.gn +++ b/chrome/browser/resources/chromeos/login/components/BUILD.gn
@@ -136,7 +136,7 @@ js_library("network_select_login") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/components/network_select_login.js" ] deps = [ - "../:cr_ui.m", + "../:cr_ui", "//ash/webui/common/resources/network:network_select", "//ash/webui/common/resources/network:onc_mojo", "//chromeos/services/network_config/public/mojom:mojom_webui_js",
diff --git a/chrome/browser/resources/chromeos/login/components/behaviors/multi_step_behavior.js b/chrome/browser/resources/chromeos/login/components/behaviors/multi_step_behavior.js index 7de367c..f95237d 100644 --- a/chrome/browser/resources/chromeos/login/components/behaviors/multi_step_behavior.js +++ b/chrome/browser/resources/chromeos/login/components/behaviors/multi_step_behavior.js
@@ -4,7 +4,7 @@ // clang-format off // #import {dom, Polymer} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -// #import {invokePolymerMethod} from '../../display_manager.m.js'; +// #import {invokePolymerMethod} from '../../display_manager.js'; // clang-format on /**
diff --git a/chrome/browser/resources/chromeos/login/components/behaviors/oobe_dialog_host_behavior.js b/chrome/browser/resources/chromeos/login/components/behaviors/oobe_dialog_host_behavior.js index 10fec16..61afa52 100644 --- a/chrome/browser/resources/chromeos/login/components/behaviors/oobe_dialog_host_behavior.js +++ b/chrome/browser/resources/chromeos/login/components/behaviors/oobe_dialog_host_behavior.js
@@ -4,7 +4,7 @@ // clang-format off // #import {dom, Polymer} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -// #import {invokePolymerMethod} from '../../display_manager.m.js'; +// #import {invokePolymerMethod} from '../../display_manager.js'; // clang-format on /**
diff --git a/chrome/browser/resources/chromeos/login/cr_ui.js b/chrome/browser/resources/chromeos/login/cr_ui.js index 1c0b0bad..1505ad5 100644 --- a/chrome/browser/resources/chromeos/login/cr_ui.js +++ b/chrome/browser/resources/chromeos/login/cr_ui.js
@@ -13,7 +13,7 @@ import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; import {addSingletonGetter} from 'chrome://resources/ash/common/cr_deprecated.js'; -import {DisplayManager} from './display_manager.m.js'; +import {DisplayManager} from './display_manager.js'; import {DISPLAY_TYPE} from './components/display_manager_types.m.js'; import {loadTimeData} from './i18n_setup.js'; import {OobeTypes} from './components/oobe_types.m.js';
diff --git a/chrome/browser/resources/chromeos/login/display_manager.js b/chrome/browser/resources/chromeos/login/display_manager.js index 6648d32..da11872d 100644 --- a/chrome/browser/resources/chromeos/login/display_manager.js +++ b/chrome/browser/resources/chromeos/login/display_manager.js
@@ -6,25 +6,23 @@ * @fileoverview Display manager for WebUI OOBE and login. */ -// #import {assert} from 'chrome://resources/js/assert.js'; -// #import {$, ensureTransitionEndEvent} from 'chrome://resources/js/util.js'; -// #import {loadTimeData} from './i18n_setup.js'; -// #import {OobeTypes} from './components/oobe_types.m.js'; +import {assert} from 'chrome://resources/js/assert.js'; +import {$, ensureTransitionEndEvent} from 'chrome://resources/js/util.js'; +import {loadTimeData} from './i18n_setup.js'; +import {OobeTypes} from './components/oobe_types.m.js'; - // #import {DISPLAY_TYPE, SCREEN_DEVICE_DISABLED, OOBE_UI_STATE, SCREEN_WELCOME } from './components/display_manager_types.m.js'; -// #import {MultiTapDetector} from './multi_tap_detector.m.js'; -// #import {keyboard} from './keyboard_utils.m.js' +import {DISPLAY_TYPE, SCREEN_DEVICE_DISABLED, OOBE_UI_STATE, SCREEN_WELCOME } from './components/display_manager_types.m.js'; +import {MultiTapDetector} from './multi_tap_detector.js'; +import {keyboard} from './keyboard_utils.m.js'; -cr.define('cr.ui.login', function() { /** * Maximum time in milliseconds to wait for step transition to finish. * The value is used as the duration for ensureTransitionEndEvent below. * It needs to be inline with the step screen transition duration time * defined in css file. The current value in css is 200ms. To avoid emulated * transitionend fired before real one, 250ms is used. - * @const */ - var MAX_SCREEN_TRANSITION_DURATION = 250; + const MAX_SCREEN_TRANSITION_DURATION = 250; /** * As Polymer behaviors do not provide true inheritance, when two behaviors @@ -41,7 +39,7 @@ * element.behaviors * TODO(crbug.com/1229130) - Remove this suppression. */ - /* #export */ function invokePolymerMethod(element, name, ...args) { + export function invokePolymerMethod(element, name, ...args) { const method = element[name]; if (!method || typeof method !== 'function') { return; @@ -53,7 +51,7 @@ // If element has behaviors call functions on them in reverse order, // ignoring case when method on element was derived from behavior. - for (var i = element.behaviors.length - 1; i >= 0; i--) { + for (let i = element.behaviors.length - 1; i >= 0; i--) { const behavior = element.behaviors[i]; const behaviorMethod = behavior[name]; if (!behaviorMethod || typeof behaviorMethod !== 'function') { @@ -70,7 +68,7 @@ * A display manager that manages initialization of screens, * transitions, error messages display. */ - /* #export */ class DisplayManager { + export class DisplayManager { constructor() { /** * Registered screens. @@ -478,10 +476,3 @@ $('bluetooth-name').textContent = bluetoothName; } } - // #cr_define_end - // Export - return { - DisplayManager: DisplayManager, - invokePolymerMethod: invokePolymerMethod, - }; -});
diff --git a/chrome/browser/resources/chromeos/login/login_ui_tools.js b/chrome/browser/resources/chromeos/login/login_ui_tools.js index c1c9906..11bc6b2 100644 --- a/chrome/browser/resources/chromeos/login/login_ui_tools.js +++ b/chrome/browser/resources/chromeos/login/login_ui_tools.js
@@ -6,13 +6,12 @@ * @fileoverview JS helpers used on login. */ -cr.define('cr.ui.LoginUITools', function() { /** * Listens to key events on input element. * @param {Element} element DOM element * @param {Object} callback */ - /* #export */ function addSubmitListener(element, callback) { + export function addSubmitListener(element, callback) { element.addEventListener('keydown', (function(callback, e) { if (e.keyCode != 13) { return; @@ -20,9 +19,3 @@ callback(); }).bind(undefined, callback)); } - // #cr_define_end - // Export - return { - addSubmitListener: addSubmitListener, - }; -});
diff --git a/chrome/browser/resources/chromeos/login/multi_tap_detector.js b/chrome/browser/resources/chromeos/login/multi_tap_detector.js index e85b7fd..9e98890 100644 --- a/chrome/browser/resources/chromeos/login/multi_tap_detector.js +++ b/chrome/browser/resources/chromeos/login/multi_tap_detector.js
@@ -6,10 +6,10 @@ * @fileoverview Multi-tap gesture detector for web UI OOBE. */ -// #import {assert} from 'chrome://resources/js/assert.js'; +import {assert} from 'chrome://resources/js/assert.js'; /** Multi-tap gesture detector. */ -/* #export */ class MultiTapDetector { +export class MultiTapDetector { /** * @param {?HTMLElement} element UI element to attach the multi-tap detector to. * @param {number} tapsCount Number of taps in multi-tap gesture to detect.
diff --git a/chrome/browser/resources/chromeos/login/oobe.js b/chrome/browser/resources/chromeos/login/oobe.js index 1f930ca..6773890 100644 --- a/chrome/browser/resources/chromeos/login/oobe.js +++ b/chrome/browser/resources/chromeos/login/oobe.js
@@ -7,12 +7,12 @@ import {$} from 'chrome://resources/js/util.js'; import {Oobe} from './cr_ui.js'; import * as OobeDebugger from './debug/debug.m.js'; -import {invokePolymerMethod} from './display_manager.m.js'; +import {invokePolymerMethod} from './display_manager.js'; import {loadTimeData} from './i18n_setup.js'; import 'chrome://oobe/components/test_util.m.js'; import 'chrome://oobe/test_api/test_api.m.js'; import {commonScreensList, loginScreensList, oobeScreensList} from 'chrome://oobe/screens.js'; -import {MultiTapDetector} from './multi_tap_detector.m.js'; +import {MultiTapDetector} from './multi_tap_detector.js'; import './components/common_styles/oobe_flex_layout_styles.m.js'; // clang-format on
diff --git a/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni b/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni index 3832c130..17d11de 100644 --- a/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni +++ b/chrome/browser/resources/chromeos/login/oobe_auto_imports.gni
@@ -58,7 +58,6 @@ "chrome/browser/resources/chromeos/login/screens/oobe/welcome_dialog.html|OobeWelcomeDialog", "chrome/browser/resources/chromeos/login/display_manager.html|DisplayManager,invokePolymerMethod", "chrome/browser/resources/chromeos/login/keyboard_utils.html|keyboard", - "chrome/browser/resources/chromeos/login/login_ui_tools.html|addSubmitListener", "chrome/browser/resources/gaia_auth_host/authenticator.html|Authenticator,AuthFlow,AuthMode,AuthParams,SUPPORTED_PARAMS", "ash/webui/common/resources/multidevice_setup/multidevice_setup_delegate.html|MultiDeviceSetupDelegate", "ash/webui/common/resources/network/mojo_interface_provider.html|MojoInterfaceProviderImpl",
diff --git a/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn b/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn index 563fb1c6..1c192d9 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn +++ b/chrome/browser/resources/chromeos/login/screens/common/BUILD.gn
@@ -125,7 +125,7 @@ js_library("arc_terms_of_service") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/arc_terms_of_service.js" ] deps = [ - "../../:display_manager.m", + "../../:display_manager", "../../components:oobe_select.m", "../../components:web_view_helper.m", "../../components:web_view_loader.m", @@ -166,7 +166,7 @@ js_library("consolidated_consent") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/consolidated_consent.js" ] deps = [ - "../..:display_manager.m", + "../..:display_manager", "../../components:display_manager_types.m", "../../components:oobe_select.m", "../../components:oobe_types.m", @@ -277,7 +277,7 @@ js_library("gaia_signin") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/gaia_signin.js" ] deps = [ - "../..:display_manager.m", + "../..:display_manager", "../../../../gaia_auth_host:authenticator", "../../components:gaia_dialog", "../../components:notification_card", @@ -296,7 +296,7 @@ js_library("guest_tos") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/guest_tos.js" ] deps = [ - "../..:display_manager.m", + "../..:display_manager", "../../components:web_view_helper.m", "../../components:web_view_loader.m", "../../components/behaviors:login_screen_behavior.m", @@ -421,7 +421,7 @@ js_library("oobe_eula") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/oobe_eula.js" ] deps = [ - "../../:display_manager.m", + "../../:display_manager", "../../components:web_view_helper.m", "../../components/behaviors:login_screen_behavior.m", "../../components/behaviors:multi_step_behavior.m", @@ -456,7 +456,7 @@ js_library("os_install") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/os_install.js" ] deps = [ - "../../:display_manager.m", + "../../:display_manager", "../../components/behaviors:login_screen_behavior.m", "../../components/behaviors:multi_step_behavior.m", "../../components/behaviors:oobe_dialog_host_behavior.m", @@ -549,7 +549,7 @@ js_library("saml_confirm_password") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/saml_confirm_password.js" ] deps = [ - "../../:login_ui_tools.m", + "../../:login_ui_tools", "../../components/behaviors:oobe_i18n_behavior.m", "../../components/buttons:oobe_next_button", "../../components/buttons:oobe_text_button", @@ -661,7 +661,7 @@ js_library("error_message") { sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/common/error_message.js" ] deps = [ - "../../:cr_ui.m", + "../../:cr_ui", "../../components:display_manager_types.m", "../../components:network_select_login", "../../components/behaviors:login_screen_behavior.m",
diff --git a/chrome/browser/resources/chromeos/login/screens/common/gaia_signin.js b/chrome/browser/resources/chromeos/login/screens/common/gaia_signin.js index 2a24afd7..97dbc125 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/gaia_signin.js +++ b/chrome/browser/resources/chromeos/login/screens/common/gaia_signin.js
@@ -31,7 +31,7 @@ import {OOBE_UI_STATE} from '../../components/display_manager_types.m.js'; import {OobeTypes} from '../../components/oobe_types.m.js'; import {Oobe} from '../../cr_ui.js'; -import {invokePolymerMethod} from '../../display_manager.m.js'; +import {invokePolymerMethod} from '../../display_manager.js'; // GAIA animation guard timer. Started when GAIA page is loaded (Authenticator
diff --git a/chrome/browser/resources/chromeos/login/screens/common/saml_confirm_password.js b/chrome/browser/resources/chromeos/login/screens/common/saml_confirm_password.js index 304e986..835a6765 100644 --- a/chrome/browser/resources/chromeos/login/screens/common/saml_confirm_password.js +++ b/chrome/browser/resources/chromeos/login/screens/common/saml_confirm_password.js
@@ -21,7 +21,7 @@ import {MultiStepBehavior, MultiStepBehaviorInterface} from '../../components/behaviors/multi_step_behavior.m.js'; import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.m.js'; import {OOBE_UI_STATE} from '../../components/display_manager_types.m.js'; -import {addSubmitListener} from '../../login_ui_tools.m.js'; +import {addSubmitListener} from '../../login_ui_tools.js'; /**
diff --git a/chrome/browser/resources/chromeos/login/screens/login/gaia_password_changed.js b/chrome/browser/resources/chromeos/login/screens/login/gaia_password_changed.js index 40dd24c..8b1c2eb 100644 --- a/chrome/browser/resources/chromeos/login/screens/login/gaia_password_changed.js +++ b/chrome/browser/resources/chromeos/login/screens/login/gaia_password_changed.js
@@ -23,7 +23,7 @@ import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.m.js'; import {OobeTextButton} from '../../components/buttons/oobe_text_button.js'; import {OOBE_UI_STATE} from '../../components/display_manager_types.m.js'; -import {addSubmitListener} from '../../login_ui_tools.m.js'; +import {addSubmitListener} from '../../login_ui_tools.js'; /**
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn b/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn index 5119997..83ded0b 100644 --- a/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn +++ b/chrome/browser/resources/chromeos/login/screens/oobe/BUILD.gn
@@ -181,7 +181,7 @@ sources = [ "$root_gen_dir/chrome/browser/resources/chromeos/login/screens/oobe/welcome.js" ] deps = [ ":welcome_dialog", - "../..:display_manager.m", + "../..:display_manager", "../../components:oobe_cr_lottie", "../../components:oobe_select.m", "../../components:oobe_types.m",
diff --git a/chrome/browser/resources/chromeos/login/screens/oobe/enterprise_enrollment.js b/chrome/browser/resources/chromeos/login/screens/oobe/enterprise_enrollment.js index 02add2f1..a810283ea 100644 --- a/chrome/browser/resources/chromeos/login/screens/oobe/enterprise_enrollment.js +++ b/chrome/browser/resources/chromeos/login/screens/oobe/enterprise_enrollment.js
@@ -31,7 +31,7 @@ import {KEYBOARD_UTILS_FOR_INJECTION} from '../../components/keyboard_utils_for_injection.m.js'; import {OobeTypes} from '../../components/oobe_types.m.js'; import {Oobe} from '../../cr_ui.js'; -import {DisplayManager, invokePolymerMethod} from '../../display_manager.m.js'; +import {DisplayManager, invokePolymerMethod} from '../../display_manager.js'; import {keyboard} from '../../keyboard_utils.m.js'; import {ActiveDirectoryErrorState, ADLoginStep, JoinConfigType} from '../common/offline_ad_login.js';
diff --git a/chrome/browser/resources/intro/dice_app.html b/chrome/browser/resources/intro/dice_app.html index cfb864a..2db2c015 100644 --- a/chrome/browser/resources/intro/dice_app.html +++ b/chrome/browser/resources/intro/dice_app.html
@@ -20,8 +20,6 @@ </style> <cr-view-manager id="viewManager"> - <!-- TODO(crbug.com/1347507): On load, transition to "splash" and trigger the - animation --> <div id="splash" slot="view"> <img id="product-logo-animation" src="product-logo-animation.svg"> </div>
diff --git a/chrome/browser/resources/intro/dice_app.ts b/chrome/browser/resources/intro/dice_app.ts index 39c18971..f974f2d 100644 --- a/chrome/browser/resources/intro/dice_app.ts +++ b/chrome/browser/resources/intro/dice_app.ts
@@ -12,7 +12,9 @@ import {getTemplate} from './dice_app.html.js'; export interface IntroAppElement { - $: {viewManager: CrViewManagerElement}; + $: { + viewManager: CrViewManagerElement, + }; } export class IntroAppElement extends PolymerElement { @@ -32,12 +34,13 @@ private async setupViewManager_(queryParams: URLSearchParams) { if (!queryParams.has('noAnimations')) { const kSplashViewDurationMillis = 1500; - this.$.viewManager.switchView('splash', 'fade-in', 'fade-out'); + this.$.viewManager.switchView('splash', 'no-animation', 'no-animation'); // Delay the switch to signInPromo based on the splash animation timing. await new Promise( resolve => setTimeout(resolve, kSplashViewDurationMillis)); } - this.$.viewManager.switchView('signInPromo', 'fade-in', 'no-animation'); + this.$.viewManager.switchView( + 'signInPromo', 'no-animation', 'no-animation'); } async setupViewManagerForTest(queryParams: URLSearchParams) {
diff --git a/chrome/browser/resources/intro/sign_in_promo.html b/chrome/browser/resources/intro/sign_in_promo.html index 3e7e0884..84f3084 100644 --- a/chrome/browser/resources/intro/sign_in_promo.html +++ b/chrome/browser/resources/intro/sign_in_promo.html
@@ -1,7 +1,8 @@ <style> :host { - --btn-margin: 24px; + --background-image-width: 17vw; --btn-container-height: calc(2 * var(--btn-margin) + var(--cr-button-height)); + --btn-margin: 24px; --card-background-color: var(--google-grey-50); --card-bottom-padding: 24px; --card-description-color: var(--cr-secondary-text-color); @@ -14,8 +15,12 @@ --gap-between-cards: 12px; --icon-color: var(--google-blue-600); --left-background-image-url: url(images/left_background.svg); + --product-logo-margin-top: 50px; --product-logo-size: 90px; --right-background-image-url: url(images/right_background.svg); + /* This is a dummy value, we set the actual one in javascript using + "setTranslationHeightToAlignLogoAndAnimation" */ + --safe-zone-animation-translation-height: 0; --scrollbar-background: var(--google-grey-100); --scrollbar-width: 4px; --subtitle-font-size: 1.67em; @@ -62,6 +67,44 @@ } } + @keyframes left-background-slide-animation { + 0% { + transform: translateX(calc(-1 * var(--background-image-width))); + } + 100% { + transform: translateX(0); + } + } + + @keyframes right-background-slide-animation { + 0% { + transform: translateX(var(--background-image-width)); + } + 100% { + transform: translateX(0); + } + } + + @keyframes fade-in-animation { + 0% { + opacity: 0; + } + 100% { + opacity: 100%; + } + } + + @keyframes safe-zone-transition-animation { + 0% { + top: 50%; + transform: translateY(calc(-1 * var(--safe-zone-animation-translation-height))); + } + 100% { + top: 0; + transform: translateY(0); + } + } + p { margin: 0; } @@ -87,19 +130,23 @@ margin-bottom: 16px; } - #content-area { + .fade-in { + animation: fade-in-animation 500ms 1 ease-in-out; + } + + #contentArea { --card-horizontal-size: calc(var(--card-width) + 2 * var(--card-horizontal-padding)); align-items: center; display: flex; flex-direction: column; - margin: auto 0; + margin: auto var(--gap-between-cards); text-align: center ; width: calc(3 * var(--card-horizontal-size) + 2 * var(--gap-between-cards)); } #product-logo { height: var(--product-logo-size); - margin-top: 50px; + margin-top: var(--product-logo-margin-top); width: var(--product-logo-size); } @@ -133,7 +180,7 @@ flex-direction: row; gap: 8px; height: var(--btn-container-height); - justify-content: right; + justify-content: flex-end; position: fixed; width: 100vw; } @@ -172,28 +219,35 @@ .background-image { position: fixed; top: 0; - width: calc(100vw * 17/100); + width: var(--background-image-width); } #left-background-image { + animation-duration: 500ms; + animation-iteration-count: 1; + animation-name: left-background-slide-animation, fade-in-animation; content: var(--left-background-image-url); left: 0; + transition-timing-function: ease-in-out; } #right-background-image { + animation-duration: 500ms; + animation-iteration-count: 1; + animation-name: right-background-slide-animation, fade-in-animation; content: var(--right-background-image-url); right: 0; } #safeZone { + animation: safe-zone-transition-animation 500ms 1 ease-in-out; box-sizing: border-box; display: flex; height: calc(100% - var(--btn-container-height)); justify-content: center; overflow-y: auto; - padding: 0 var(--gap-between-cards); position: fixed; - width: 100%; + width: 100vw; } #buttonContainer.division-line { @@ -205,13 +259,13 @@ <img class="background-image" id="right-background-image"> <div class="custom-scrollbar" id="safeZone"> - <div id="content-area"> + <div id="contentArea"> <img id="product-logo" src="product-logo.png"> - <h1>$i18n{pageTitle}</h1> - <p id="subtitle">$i18n{pageSubtitle}</p> + <h1 class="fade-in">$i18n{pageTitle}</h1> + <p class="fade-in" id="subtitle">$i18n{pageSubtitle}</p> <div id="benefit-cards-container"> <template is="dom-repeat" items="[[benefitCards_]]"> - <div class="benefit-card"> + <div class="benefit-card fade-in"> <iron-icon icon="[[item.iconName]]"></iron-icon> <h2>[[item.title]]</h2> <p class="benefit-card-description">[[item.description]]</p> @@ -221,7 +275,7 @@ </div> </div> -<div id="buttonContainer"> +<div class="fade-in" id="buttonContainer"> <cr-button id="declineSignInButton" on-click="onContinueWithoutAccountClick_">$i18n{declineSignInButtonTitle}</cr-button> <cr-button class="action-button" id="acceptSignInButton" on-click="onContinueWithAccountClick_">$i18n{acceptSignInButtonTitle} </cr-button>
diff --git a/chrome/browser/resources/intro/sign_in_promo.ts b/chrome/browser/resources/intro/sign_in_promo.ts index 777985d..1447ebaf 100644 --- a/chrome/browser/resources/intro/sign_in_promo.ts +++ b/chrome/browser/resources/intro/sign_in_promo.ts
@@ -20,6 +20,7 @@ $: { acceptSignInButton: CrButtonElement, buttonContainer: HTMLElement, + contentArea: HTMLElement, declineSignInButton: CrButtonElement, safeZone: HTMLElement, }; @@ -74,25 +75,58 @@ private browserProxy_: IntroBrowserProxy = IntroBrowserProxyImpl.getInstance(); private benefitCards_: BenefitCard[]; - private resizeObserver_: ResizeObserver|null = null; + private divisionLineResizeObserver_: ResizeObserver|null = null; override connectedCallback() { super.connectedCallback(); - this.addResizeObserver_(); + this.toggleDivisionLine_(); } override disconnectedCallback() { super.disconnectedCallback(); - this.resizeObserver_!.disconnect(); + this.divisionLineResizeObserver_!.disconnect(); } - private addResizeObserver_() { + override ready() { + super.ready(); + this.addEventListener('view-enter-start', this.onViewEnterStart_); + } + + private onViewEnterStart_() { + this.setTranslationHeightToAlignLogoAndAnimation(); + } + + private toggleDivisionLine_() { const safeZone = this.$.safeZone; - this.resizeObserver_ = new ResizeObserver(() => { + + this.divisionLineResizeObserver_ = new ResizeObserver(() => { this.$.buttonContainer.classList.toggle( 'division-line', safeZone.scrollHeight > safeZone.clientHeight); }); - this.resizeObserver_.observe(safeZone); + this.divisionLineResizeObserver_.observe(safeZone); + } + + // At the start of the signInPromo animation, the product logo should be at + // the same position as the splash view logo animation. To be able + // to do that, we had to translate the safeZone vertically up by the value + // calculated in the function below, after doing top:50%. + private setTranslationHeightToAlignLogoAndAnimation() { + const contentAreaHeight = this.$.contentArea.clientHeight; + const safeZoneHeight = this.$.safeZone.clientHeight; + const productLogoMarginTop = parseInt( + getComputedStyle(this).getPropertyValue('--product-logo-margin-top')); + const productLogoSize = parseInt( + getComputedStyle(this).getPropertyValue('--product-logo-size')); + + const contentAreaAndSafeZoneHeightDifference = + contentAreaHeight < safeZoneHeight ? + safeZoneHeight - contentAreaHeight : + 0; + const translationHeight = contentAreaAndSafeZoneHeightDifference / 2 + + productLogoMarginTop + productLogoSize / 2; + + this.style.setProperty( + '--safe-zone-animation-translation-height', translationHeight + 'px'); } private onContinueWithAccountClick_() {
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc index cdf7197..1943a47 100644 --- a/chrome/browser/search_engines/template_url_service_factory.cc +++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -92,8 +92,8 @@ // sign-in flow creates a window with a URL bar. The URL bar code currently // assumes a template URL service exists. (This is true even though the user // cannot search from the captive portal sign-in window.) - if (!chromeos::ProfileHelper::IsUserProfile(profile) && - !chromeos::ProfileHelper::IsSigninProfile(profile)) { + if (!ash::ProfileHelper::IsUserProfile(profile) && + !ash::ProfileHelper::IsSigninProfile(profile)) { return nullptr; } #endif
diff --git a/chrome/browser/sync/test/integration/bookmarks_helper.cc b/chrome/browser/sync/test/integration/bookmarks_helper.cc index ba9ee41..e47ea4e 100644 --- a/chrome/browser/sync/test/integration/bookmarks_helper.cc +++ b/chrome/browser/sync/test/integration/bookmarks_helper.cc
@@ -51,7 +51,6 @@ #include "components/sync/protocol/sync_entity.pb.h" #include "components/sync/protocol/unique_position.pb.h" #include "components/sync/test/entity_builder_factory.h" -#include "content/public/test/test_utils.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -144,7 +143,7 @@ void WaitUntilFaviconChangedToIconURL() { DCHECK(!run_loop_.running()); - content::RunThisRunLoop(&run_loop_); + run_loop_.Run(); } // bookmarks::BookmarkModelObserver:
diff --git a/chrome/browser/sync/test/integration/dictionary_helper.cc b/chrome/browser/sync/test/integration/dictionary_helper.cc index b92594d..0334f6f 100644 --- a/chrome/browser/sync/test/integration/dictionary_helper.cc +++ b/chrome/browser/sync/test/integration/dictionary_helper.cc
@@ -55,7 +55,7 @@ content::GetDeferredQuitTaskForRunLoop(&run_loop)); dictionary->AddObserver(&observer); dictionary->Load(); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); dictionary->RemoveObserver(&observer); ASSERT_TRUE(dictionary->IsLoaded()); }
diff --git a/chrome/browser/sync/test/integration/passwords_helper.cc b/chrome/browser/sync/test/integration/passwords_helper.cc index 88cdd42..b05689b 100644 --- a/chrome/browser/sync/test/integration/passwords_helper.cc +++ b/chrome/browser/sync/test/integration/passwords_helper.cc
@@ -58,7 +58,7 @@ std::vector<std::unique_ptr<PasswordForm>> WaitForResult() { DCHECK(!run_loop_.running()); - content::RunThisRunLoop(&run_loop_); + run_loop_.Run(); return std::move(result_); } @@ -67,7 +67,9 @@ } private: - base::RunLoop run_loop_; + // This RunLoop uses kNestableTasksAllowed because it runs nested within + // another RunLoop. + base::RunLoop run_loop_{base::RunLoop::Type::kNestableTasksAllowed}; std::vector<std::unique_ptr<PasswordForm>> result_; base::WeakPtrFactory<PasswordStoreConsumerHelper> weak_ptr_factory_{this}; };
diff --git a/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java b/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java index f0a9e76..5c6e2d8 100644 --- a/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java +++ b/chrome/browser/touch_to_fill/android/internal/java/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillMediator.java
@@ -28,7 +28,6 @@ import androidx.annotation.Px; import org.chromium.base.metrics.RecordHistogram; -import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.password_manager.PasswordManagerHelper; import org.chromium.chrome.browser.touch_to_fill.TouchToFillComponent.UserAction; import org.chromium.chrome.browser.touch_to_fill.TouchToFillProperties.CredentialProperties; @@ -134,14 +133,7 @@ : mContext.getString(R.string.touch_to_fill_sheet_title_passkey); } - if (ChromeFeatureList.isEnabled(ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION) - || PasswordManagerHelper.usesUnifiedPasswordManagerUI()) { - return mContext.getString(R.string.touch_to_fill_sheet_uniform_title); - } - - return mContext.getString((credentials.size() == 1) - ? R.string.touch_to_fill_sheet_title_single - : R.string.touch_to_fill_sheet_title); + return mContext.getString(R.string.touch_to_fill_sheet_uniform_title); } private String getManageButtonText(
diff --git a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings.grd b/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings.grd index 654e3a8..3a00bbdea 100644 --- a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings.grd +++ b/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings.grd
@@ -178,12 +178,6 @@ <release seq="1"> <messages fallback_to_english="true"> <!-- Touch To Fill --> - <message name="IDS_TOUCH_TO_FILL_SHEET_TITLE_SINGLE" desc="Header for Touch To Fill sheet where users only have a single credential to fill into a form to."> - Continue with account - </message> - <message name="IDS_TOUCH_TO_FILL_SHEET_TITLE" desc="Header for Touch To Fill sheet where users can pick a credential to fill into a form to."> - Choose an account - </message> <message name="IDS_TOUCH_TO_FILL_SHEET_UNIFORM_TITLE" desc="Header for Touch To Fill sheet where users can pick a password credential to fill into a form. Will replace SHEET_TITLE_SINGLE and SHEET_TITLE."> Use saved password? </message>
diff --git a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE.png.sha1 b/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE.png.sha1 deleted file mode 100644 index f21889cc1..0000000 --- a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -5c2d04c928c95b168528a69cc3f53e433c66eb7d \ No newline at end of file
diff --git a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE_SINGLE.png.sha1 b/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE_SINGLE.png.sha1 deleted file mode 100644 index 5812fd1..0000000 --- a/chrome/browser/touch_to_fill/android/internal/java/strings/android_touch_to_fill_strings_grd/IDS_TOUCH_TO_FILL_SHEET_TITLE_SINGLE.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -98f90cf832f4676079203a41654c08a0f111f23a \ No newline at end of file
diff --git a/chrome/browser/touch_to_fill/android/javatests/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillViewTest.java b/chrome/browser/touch_to_fill/android/javatests/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillViewTest.java index bffb304..3ac1cd13 100644 --- a/chrome/browser/touch_to_fill/android/javatests/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillViewTest.java +++ b/chrome/browser/touch_to_fill/android/javatests/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillViewTest.java
@@ -58,7 +58,6 @@ import org.chromium.chrome.browser.touch_to_fill.data.WebAuthnCredential; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeTabbedActivityTestRule; -import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController.SheetState; @@ -132,36 +131,6 @@ @Test @MediumTest - @DisableFeatures({ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION, - ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) - public void - testSingleCredentialTitleDisplayedWithSubmissionDisabled() { - // TODO(crbug.com/1283004): Remove the test once TOUCH_TO_FILL_PASSWORD_SUBMISSION is fully - // launched. - TestThreadUtils.runOnUiThreadBlocking(() -> { - mModel.get(SHEET_ITEMS) - .add(new MVCListAdapter.ListItem(TouchToFillProperties.ItemType.HEADER, - new PropertyModel.Builder(HeaderProperties.ALL_KEYS) - .with(TITLE, - getActivity().getString( - R.string.touch_to_fill_sheet_title_single)) - .with(FORMATTED_URL, "www.example.org") - .with(ORIGIN_SECURE, true) - .with(IMAGE_DRAWABLE_ID, - mResourceProvider.getHeaderImageDrawableId()) - .build())); - mModel.set(VISIBLE, true); - }); - BottomSheetTestSupport.waitForOpen(mBottomSheetController); - TextView title = - mTouchToFillView.getContentView().findViewById(R.id.touch_to_fill_sheet_title); - - assertThat(title.getText(), - is(getActivity().getString(R.string.touch_to_fill_sheet_title_single))); - } - - @Test - @MediumTest @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) public void testTitlePropagatesToView() { TestThreadUtils.runOnUiThreadBlocking(() -> { @@ -258,7 +227,6 @@ @Test @MediumTest - @EnableFeatures({ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) public void testSubmissionSubtitleUrlDisplayed() { TestThreadUtils.runOnUiThreadBlocking(() -> { mModel.get(SHEET_ITEMS) @@ -281,7 +249,6 @@ @Test @MediumTest - @EnableFeatures({ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) public void testNonSecureSubmissionSubtitleUrlDisplayed() { TestThreadUtils.runOnUiThreadBlocking(() -> { mModel.get(SHEET_ITEMS) @@ -393,8 +360,7 @@ @Test @MediumTest - @EnableFeatures({ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void testButtonTitleWithAutoSubmission() { + public void testButtonTitle() { TestThreadUtils.runOnUiThreadBlocking(() -> { mModel.get(SHEET_ITEMS) .addAll(asList(buildCredentialItem(ANA), buildConfirmationButton(ANA, true)));
diff --git a/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java b/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java index 8ed4bdd..2236743d 100644 --- a/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java +++ b/chrome/browser/touch_to_fill/android/junit/src/org/chromium/chrome/browser/touch_to_fill/TouchToFillControllerTest.java
@@ -62,7 +62,6 @@ import org.chromium.chrome.browser.touch_to_fill.data.Credential; import org.chromium.chrome.browser.touch_to_fill.data.WebAuthnCredential; import org.chromium.chrome.test.util.browser.Features; -import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.components.browser_ui.bottomsheet.BottomSheetController; import org.chromium.components.favicon.IconType; @@ -144,10 +143,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithMultipleEntries() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsWithMultipleEntries() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL), true); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -177,43 +174,8 @@ } @Test - @DisableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithMultipleEntriesWithUpmDisabled() { - mMediator.showCredentials( - TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL), true); - ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); - assertThat(itemList.size(), is(3)); // Header + 2 credentials - assertThat( - mModel.get(MANAGE_BUTTON_TEXT), is(mContext.getString(R.string.manage_passwords))); - - assertThat(itemList.get(0).type, is(ItemType.HEADER)); - assertThat(itemList.get(0).model.get(TITLE), - is(mContext.getString(R.string.touch_to_fill_sheet_title))); - assertThat( - itemList.get(0).model.get(FORMATTED_URL), is(formatForSecurityDisplay(TEST_URL))); - assertThat(itemList.get(0).model.get(ORIGIN_SECURE), is(true)); - assertThat(itemList.get(0).model.get(SHOW_SUBMIT_SUBTITLE), is(true)); - - assertThat(itemList.get(1).type, is(ItemType.CREDENTIAL)); - assertThat(itemList.get(1).model.get(CREDENTIAL), is(ANA)); - assertNotNull(itemList.get(1).model.get(ON_CLICK_LISTENER)); - assertThat(itemList.get(1).model.get(FORMATTED_ORIGIN), is(format(ANA.getOriginUrl()))); - - assertThat(itemList.get(2).type, is(ItemType.CREDENTIAL)); - assertThat(itemList.get(2).model.get(CREDENTIAL), is(CARL)); - assertNotNull(itemList.get(2).model.get(ON_CLICK_LISTENER)); - assertThat(itemList.get(2).model.get(FORMATTED_ORIGIN), is(format(CARL.getOriginUrl()))); - assertThat(itemList.get(0).model.get(IMAGE_DRAWABLE_ID), - is(R.drawable.touch_to_fill_header_image)); - } - - @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithSingleEntry() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsWithSingleEntry() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -238,38 +200,8 @@ } @Test - @DisableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithSingleEntryWithUpmDisabled() { - mMediator.showCredentials( - TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA), false); - ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); - assertThat(itemList.size(), is(3)); // Header + 1 credential + Button - assertThat( - mModel.get(MANAGE_BUTTON_TEXT), is(mContext.getString(R.string.manage_passwords))); - - assertThat(itemList.get(0).type, is(ItemType.HEADER)); - assertThat(itemList.get(0).model.get(TITLE), - is(mContext.getString(R.string.touch_to_fill_sheet_title_single))); - assertThat( - itemList.get(0).model.get(FORMATTED_URL), is(formatForSecurityDisplay(TEST_URL))); - assertThat(itemList.get(0).model.get(ORIGIN_SECURE), is(true)); - - assertThat(itemList.get(1).type, is(ItemType.CREDENTIAL)); - assertThat(itemList.get(1).model.get(CREDENTIAL), is(ANA)); - assertNotNull(itemList.get(1).model.get(ON_CLICK_LISTENER)); - assertThat(itemList.get(1).model.get(FORMATTED_ORIGIN), is(format(ANA.getOriginUrl()))); - - assertThat(itemList.get(2).type, is(ItemType.FILL_BUTTON)); - assertThat(itemList.get(2).model.get(SHOW_SUBMIT_BUTTON), is(false)); - } - - @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithSingleWebAuthnEntry() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsWithSingleWebAuthnEntry() { mMediator.showCredentials( TEST_URL, true, Arrays.asList(DINO), Collections.emptyList(), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -290,10 +222,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsWithWebAuthnAndPasswordEntries() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsWithWebAuthnAndPasswordEntries() { mMediator.showCredentials(TEST_URL, true, Arrays.asList(DINO), Arrays.asList(ANA), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); assertThat( @@ -316,10 +246,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsToSubmit() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsToSubmit() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA), true); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -335,10 +263,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsSetsCredentialListAndRequestsFavicons() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsSetsCredentialListAndRequestsFavicons() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL, BOB), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -362,10 +288,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testFetchFaviconUpdatesModel() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testFetchFaviconUpdatesModel() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Collections.singletonList(CARL), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -392,10 +316,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsFormatPslOrigins() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsFormatPslOrigins() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, BOB), false); assertThat(mModel.get(SHEET_ITEMS).size(), is(3)); // Header + two Credentials @@ -408,10 +330,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testClearsCredentialListWhenShowingAgain() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testClearsCredentialListWhenShowingAgain() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Collections.singletonList(ANA), false); ListModel<MVCListAdapter.ListItem> itemList = mModel.get(SHEET_ITEMS); @@ -431,20 +351,16 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testShowCredentialsSetsVisibile() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testShowCredentialsSetsVisibile() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL, BOB), false); assertThat(mModel.get(VISIBLE), is(true)); } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testCallsCallbackAndHidesOnSelectingItemDoesNotRecordIndexForSingleCredential() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testCallsCallbackAndHidesOnSelectingItemDoesNotRecordIndexForSingleCredential() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA), false); assertThat(mModel.get(VISIBLE), is(true)); @@ -463,10 +379,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testCallsCallbackAndHidesOnSelectingItem() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testCallsCallbackAndHidesOnSelectingItem() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL), false); assertThat(mModel.get(VISIBLE), is(true)); @@ -485,10 +399,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testCallsDelegateAndHidesOnDismiss() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testCallsDelegateAndHidesOnDismiss() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL), false); mMediator.onDismissed(BottomSheetController.StateChangeReason.BACK_PRESS); @@ -504,10 +416,8 @@ } @Test - @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID, - ChromeFeatureList.TOUCH_TO_FILL_PASSWORD_SUBMISSION}) - public void - testHidesWhenSelectingManagePasswords() { + @EnableFeatures({ChromeFeatureList.UNIFIED_PASSWORD_MANAGER_ANDROID}) + public void testHidesWhenSelectingManagePasswords() { mMediator.showCredentials( TEST_URL, true, Collections.emptyList(), Arrays.asList(ANA, CARL, BOB), false); assertThat(mModel.get(ON_CLICK_MANAGE), is(notNullValue()));
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd index 307d5f3..4c5e639c 100644 --- a/chrome/browser/ui/android/strings/android_chrome_strings.grd +++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -1113,6 +1113,47 @@ Chrome is finding new ways to reduce tracking and keep you even safer as you browse. Chrome also <ph name="BEGIN_LINK"><link></ph>estimates your interests<ph name="END_LINK"></link></ph> and enables you to manage them. Then, sites you visit can ask Chrome for your interests to show you ads. </message> + <!-- Privacy Sandbox v4 - Consent EEA. --> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_TITLE" translateable="false" desc="Privacy Sandbox dialog consent EEA: title."> + Lorem ipsum Consent + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_DESCRIPTION_1" translateable="false" desc="Privacy Sandbox dialog consent EEA: First section of the body, above the image."> + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pretium pulvinar metus non mollis. Quisque placerat eget nisl sit amet facilisis. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_DESCRIPTION_2" translateable="false" desc="Privacy Sandbox dialog consent EEA: Second section of the body, above the image."> + Nulla in tortor a ligula scelerisque laoreet. Sed sem velit, varius non purus vitae, imperdiet porttitor elit. Integer et libero id metus egestas consequat non a ipsum. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_DESCRIPTION_3" translateable="false" desc="Privacy Sandbox dialog consent EEA: Third section of the body, below the image, exclues the expand text."> + Vestibulum pretium placerat justo vel suscipit. Quisque urna arcu, elementum ut venenatis ornare, consequat ac turpis. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_EXPAND_LABEL" translateable="false" desc="Privacy Sandbox dialog consent EEA: Text user clicks to expand the collapsed section."> + Vestibulum orci risus, consectetur + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_DESCRIPTION_4" translateable="false" desc="Privacy Sandbox dialog consent EEA: Fourth section of the body, below the collapsed section."> + Vestibulum pretium placerat justo vel suscipit. Quisque urna arcu, elementum ut venenatis ornare, consequat ac turpis. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_ACCEPT_BUTTON" translateable="false" desc="Privacy Sandbox dialog consent EEA: Consent Yes button."> + Quisque + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_DECLINE_BUTTON" translateable="false" desc="Privacy Sandbox dialog consent EEA: Consent No button."> + Lorem + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_HEADING" translateable="false" desc="Privacy Sandbox dialog consent EEA: Header inside expand in consent."> + Esed purus vestibulum velit convalli + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_BULLET_1" translateable="false" desc="Privacy Sandbox dialog consent EEA: First bullet point in expand in consent."> + <ph name="BEGIN_BOLD"><b></ph>Nulla in tortor:<ph name="END_BOLD"></b></ph> a ligula scelerisque laoreet. Sed sem velit, varius non purus vitae, imperdiet porttitor elit. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_BULLET_2" translateable="false" desc="Privacy Sandbox dialog consent EEA: Second bullet point in expand in consent."> + <ph name="BEGIN_BOLD"><b></ph>Consectetur adipiscing elit:<ph name="END_BOLD"></b></ph> Duis pretium pulvinar metus non mollis + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_BULLET_3" translateable="false" desc="Privacy Sandbox dialog consent EEA: Third bullet point in expand in consent."> + <ph name="BEGIN_BOLD"><b></ph>Sed purus vestibulum: <ph name="END_BOLD"></b></ph> velit convallis suscipit. Aenean aliquam ut velit eget dapibus. Vestibulum orci risus, consectetur non odio vulputate, mattis dignissim purus. Cras id tempor mi. + </message> + <message name="IDS_PRIVACY_SANDBOX_M1_CONSENT_LEARN_MORE_LINK" translateable="false" desc="Privacy Sandbox dialog consent EEA: Non-interactable link out 'Learn more with Google's etc ect'"> + Esed purus vestibulum velit convalli + </message> + <!-- Privacy Sandbox v4 - Notice EEA. --> <message name="IDS_PRIVACY_SANDBOX_M1_NOTICE_EEA_TITLE" translateable="false" desc="Privacy Sandbox dialog notice EEA: title."> Lorem ipsum Notice EEA
diff --git a/chrome/browser/ui/app_list/search/os_settings_provider_unittest.cc b/chrome/browser/ui/app_list/search/os_settings_provider_unittest.cc index 37a2919a..477c1fe 100644 --- a/chrome/browser/ui/app_list/search/os_settings_provider_unittest.cc +++ b/chrome/browser/ui/app_list/search/os_settings_provider_unittest.cc
@@ -5,20 +5,133 @@ #include "chrome/browser/ui/app_list/search/os_settings_provider.h" #include <memory> +#include "chrome/browser/apps/app_service/app_service_proxy.h" +#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/ui/app_list/search/test/test_search_controller.h" #include "chrome/browser/ui/webui/settings/ash/fake_hierarchy.h" #include "chrome/browser/ui/webui/settings/ash/fake_os_settings_sections.h" #include "chrome/browser/ui/webui/settings/ash/search/search_handler.h" +#include "chrome/browser/web_applications/web_app_id_constants.h" +#include "chrome/grit/generated_resources.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile_manager.h" +#include "components/services/app_service/public/cpp/stub_icon_loader.h" #include "content/public/test/browser_task_environment.h" -#include "mojo/public/cpp/bindings/remote.h" -#include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" namespace app_list::test { +namespace mojom { +using ::chromeos::settings::mojom::kBluetoothSectionPath; +using ::chromeos::settings::mojom::Section; +using ::chromeos::settings::mojom::Setting; +using ::chromeos::settings::mojom::Subpage; +} // namespace mojom + +namespace { + +using SettingsResultPtr = ::ash::settings::mojom::SearchResultPtr; +using SearchResult = ::ash::settings::mojom::SearchResult; +using SearchResultIcon = ::ash::settings::mojom::SearchResultIcon; +using SearchResultType = ::ash::settings::mojom::SearchResultType; +using SearchResultDefaultRank = ::ash::settings::mojom::SearchResultDefaultRank; +using SearchResultIdentifier = ::ash::settings::mojom::SearchResultIdentifier; +using SearchCallback = base::OnceCallback<void(std::vector<SettingsResultPtr>)>; + +SettingsResultPtr NewSettingsResult(const std::string& url, + const std::u16string& title, + double relevance, + mojom::Setting setting) { + SettingsResultPtr result = SearchResult::New(); + + result->id = SearchResultIdentifier::NewSetting(setting); + result->type = SearchResultType::kSetting; + result->relevance_score = relevance; + result->url_path_with_parameters = url; + result->settings_page_hierarchy = {u"setting", u"setting details"}; + result->text = title; + result->canonical_text = title; + result->was_generated_from_text_match = false; + result->default_rank = SearchResultDefaultRank::kMedium; + return result; +} + +SettingsResultPtr NewSubpageResult(const std::string& url, + const std::u16string& text, + double relevance, + mojom::Subpage subpage) { + SettingsResultPtr result = SearchResult::New(); + + result->id = SearchResultIdentifier::NewSubpage(subpage); + result->type = SearchResultType::kSubpage; + result->relevance_score = relevance; + result->url_path_with_parameters = url; + result->settings_page_hierarchy = {u"subpage", u"subpage details"}; + result->text = text; + result->canonical_text = text; + result->was_generated_from_text_match = false; + result->default_rank = SearchResultDefaultRank::kMedium; + return result; +} + +SettingsResultPtr NewSectionResult(const std::string& url, + const std::u16string& text, + double relevance, + mojom::Section section) { + SettingsResultPtr result = SearchResult::New(); + + result->id = SearchResultIdentifier::NewSection(section); + result->type = SearchResultType::kSection; + result->relevance_score = relevance; + result->url_path_with_parameters = url; + result->settings_page_hierarchy = {u"section", u"section details"}; + result->text = text; + result->canonical_text = text; + result->was_generated_from_text_match = false; + result->default_rank = SearchResultDefaultRank::kMedium; + return result; +} + +class MockSearchHandler : public ash::settings::SearchHandler { + public: + MockSearchHandler(ash::settings::SearchTagRegistry* search_tag_registry, + ash::settings::OsSettingsSections* sections, + ash::settings::Hierarchy* hierarchy, + ash::local_search_service::LocalSearchServiceProxy* + local_search_service_proxy) + : ash::settings::SearchHandler(search_tag_registry, + sections, + hierarchy, + local_search_service_proxy), + search_tag_registry_(search_tag_registry), + sections_(sections), + hierarchy_(hierarchy) {} + ~MockSearchHandler() override = default; + + MockSearchHandler(const MockSearchHandler& other) = delete; + MockSearchHandler& operator=(const MockSearchHandler& other) = delete; + + void Search(const std::u16string& query, + uint32_t max_num_results, + ash::settings::mojom::ParentResultBehavior parent_result_behavior, + SearchCallback callback) override { + std::move(callback).Run(std::move(results_)); + } + + // Manually add in results which will be returned by the Search function. + void SetNextResults(std::vector<SettingsResultPtr> results) { + results_ = std::move(results); + } + + ash::settings::SearchTagRegistry* search_tag_registry_; + ash::settings::OsSettingsSections* sections_; + ash::settings::Hierarchy* hierarchy_; + std::vector<SettingsResultPtr> results_; +}; + +} // namespace + class OsSettingsProviderTest : public testing::Test { public: OsSettingsProviderTest() @@ -28,24 +141,48 @@ /*for_testing=*/true)), search_tag_registry_(local_search_service_proxy_.get()), fake_hierarchy_(&fake_sections_), - handler_(&search_tag_registry_, - &fake_sections_, - &fake_hierarchy_, - local_search_service_proxy_.get()) {} + mock_handler_(&search_tag_registry_, + &fake_sections_, + &fake_hierarchy_, + local_search_service_proxy_.get()) {} OsSettingsProviderTest(const OsSettingsProviderTest&) = delete; OsSettingsProviderTest& operator=(const OsSettingsProviderTest&) = delete; ~OsSettingsProviderTest() override = default; void SetUp() override { - handler_.BindInterface(handler_remote_.BindNewPipeAndPassReceiver()); - search_controller_ = std::make_unique<TestSearchController>(); profile_manager_ = std::make_unique<TestingProfileManager>( TestingBrowserProcess::GetGlobal()); ASSERT_TRUE(profile_manager_->SetUp()); profile_ = profile_manager_->CreateTestingProfile("name"); - provider_ = std::make_unique<OsSettingsProvider>(profile_, &handler_, - &fake_hierarchy_, nullptr); + proxy_ = apps::AppServiceProxyFactory::GetForProfile(profile_); + + apps::StubIconLoader stub_icon_loader; + proxy_->OverrideInnerIconLoaderForTesting(&stub_icon_loader); + + // Insert dummy map values so that the stub_icon_loader knows of the app. + stub_icon_loader.timelines_by_app_id_[web_app::kOsSettingsAppId] = 1; + + // Populate the fake hierarchy with data. + fake_hierarchy_.AddSubpageMetadata( + IDS_SETTINGS_BLUETOOTH_DEVICE_DETAIL_NAME, mojom::Section::kBluetooth, + mojom::Subpage::kBluetoothDevices, SearchResultIcon::kBluetooth, + SearchResultDefaultRank::kMedium, mojom::kBluetoothSectionPath); + fake_hierarchy_.AddSubpageMetadata( + IDS_SETTINGS_BLUETOOTH_SAVED_DEVICES, mojom::Section::kBluetooth, + mojom::Subpage::kBluetoothSavedDevices, SearchResultIcon::kBluetooth, + SearchResultDefaultRank::kMedium, mojom::kBluetoothSectionPath, + absl::make_optional(mojom::Subpage::kBluetoothDevices)); + fake_hierarchy_.AddSettingMetadata(mojom::Section::kPrinting, + mojom::Setting::kAddPrinter); + fake_hierarchy_.AddSettingMetadata(mojom::Section::kPrinting, + mojom::Setting::kSavedPrinters); + fake_hierarchy_.AddSettingMetadata( + mojom::Section::kBluetooth, mojom::Setting::kFastPairSavedDevices, + absl::make_optional(mojom::Subpage::kBluetoothSavedDevices)); + + provider_ = std::make_unique<OsSettingsProvider>(profile_, &mock_handler_, + &fake_hierarchy_, proxy_); provider_->set_controller(search_controller_.get()); task_environment_.RunUntilIdle(); } @@ -54,12 +191,16 @@ provider_.reset(); search_controller_.reset(); profile_ = nullptr; + proxy_ = nullptr; profile_manager_->DeleteTestingProfile("name"); } - const SearchProvider::Results& results() { return provider_->results(); } + const SearchProvider::Results& results() { + return search_controller_->last_results(); + } + MockSearchHandler* mock_handler() { return &mock_handler_; } - // Starts a search and waits for the query to be sent + // Starts a search and waits for the query to be sent. void StartSearch(const std::u16string& query) { provider_->Start(query); base::RunLoop().RunUntilIdle(); @@ -73,17 +214,158 @@ ash::settings::SearchTagRegistry search_tag_registry_; ash::settings::FakeOsSettingsSections fake_sections_; ash::settings::FakeHierarchy fake_hierarchy_; - ash::settings::SearchHandler handler_; - mojo::Remote<ash::settings::mojom::SearchHandler> handler_remote_; + MockSearchHandler mock_handler_; private: std::unique_ptr<TestingProfileManager> profile_manager_; TestingProfile* profile_; + apps::AppServiceProxy* proxy_; std::unique_ptr<OsSettingsProvider> provider_; }; TEST_F(OsSettingsProviderTest, Basic) { - StartSearch(u""); + // Manually add in results from the mocked search handler. + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back(NewSettingsResult( + "www.open.com", u"Add Printer", 0.5, mojom::Setting::kAddPrinter)); + settings_results.emplace_back(NewSettingsResult( + "www.close.com", u"Saved Printer", 0.6, mojom::Setting::kSavedPrinters)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // Should not return results if the query is too short. + StartSearch(u"on"); EXPECT_TRUE(results().empty()); + + StartSearch(u"query"); + ASSERT_EQ(2u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Add Printer"); + EXPECT_EQ(results()[0]->relevance(), 0.5); + EXPECT_EQ(results()[0]->result_type(), ResultType::kOsSettings); + EXPECT_EQ(results()[0]->category(), Category::kSettings); + EXPECT_EQ(results()[0]->display_type(), DisplayType::kList); + EXPECT_EQ(results()[0]->metrics_type(), ash::OS_SETTINGS); + EXPECT_EQ(results()[0]->accessible_name(), + u"Add Printer, setting details, setting"); + EXPECT_EQ(results()[0]->details(), u"setting details"); + EXPECT_TRUE(results()[0]->icon().dimension); +} + +TEST_F(OsSettingsProviderTest, WillFilterResultsBelowTheScoreThreshold) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back(NewSettingsResult( + "www.open.com", u"Add Printer", 0.1, mojom::Setting::kAddPrinter)); + settings_results.emplace_back( + NewSettingsResult("www.savedFast.com", u"Fast Pair Saved Devices", 0.2, + mojom::Setting::kFastPairSavedDevices)); + settings_results.emplace_back(NewSettingsResult( + "www.close.com", u"Saved Printer", 0.6, mojom::Setting::kSavedPrinters)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // Should only return the results with a high enough relevance. + StartSearch(u"query"); + ASSERT_EQ(1u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Saved Printer"); +} + +TEST_F(OsSettingsProviderTest, WillFilterOutDuplicateURLs) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back(NewSettingsResult( + "www.open.com", u"Add Printer", 0.8, mojom::Setting::kAddPrinter)); + settings_results.emplace_back( + NewSettingsResult("www.open.com", u"Fast Pair Saved Devices", 0.8, + mojom::Setting::kFastPairSavedDevices)); + settings_results.emplace_back(NewSettingsResult( + "www.close.com", u"Saved Printer", 0.6, mojom::Setting::kSavedPrinters)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // The second result will be filtered as its URL is identical to the first + // result. + StartSearch(u"query"); + ASSERT_EQ(2u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Add Printer"); + EXPECT_EQ(results()[1]->title(), u"Saved Printer"); +} + +TEST_F(OsSettingsProviderTest, WillFilterOutAlternateMatches) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back(NewSettingsResult( + "www.open.com", u"Add Printer", 0.8, mojom::Setting::kAddPrinter)); + SettingsResultPtr result = + NewSettingsResult("www.open.com", u"Fast Pair Saved Devices", 0.8, + mojom::Setting::kFastPairSavedDevices); + result->canonical_text = u"Saved Devices"; + settings_results.emplace_back(std::move(result)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // The second result will be filtered as its text does not match its canonical + // text. + StartSearch(u"query"); + ASSERT_EQ(1u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Add Printer"); +} + +TEST_F(OsSettingsProviderTest, + WillFilterOutSubpageResultsWithAHigherScoringAncestor) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back( + NewSubpageResult("www.bluetooth.com", u"Bluetooth Devices", 0.7, + mojom::Subpage::kBluetoothDevices)); + settings_results.emplace_back( + NewSubpageResult("www.savedBlue.com", u"Saved Blue Devices", 0.6, + mojom::Subpage::kBluetoothSavedDevices)); + settings_results.emplace_back( + NewSubpageResult("www.savedBluetooth.com", u"Saved Bluetooth Devices", + 0.9, mojom::Subpage::kBluetoothSavedDevices)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // The second result will be filtered out as there is a higher scoring + // ancestor also present in the results. + StartSearch(u"query"); + ASSERT_EQ(2u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Bluetooth Devices"); + EXPECT_EQ(results()[1]->title(), u"Saved Bluetooth Devices"); +} + +TEST_F(OsSettingsProviderTest, + WillFilterOutSettingsResultsWithAHigherScoringSubpageAncestor) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back( + NewSubpageResult("www.bluetooth.com", u"Bluetooth Devices", 0.7, + mojom::Subpage::kBluetoothDevices)); + settings_results.emplace_back( + NewSettingsResult("www.fastPair.com", u"Fast Pair Saved Devices", 0.6, + mojom::Setting::kFastPairSavedDevices)); + settings_results.emplace_back( + NewSettingsResult("www.fastPair2.com", u"Fast Pair Saved Devices2", 0.9, + mojom::Setting::kFastPairSavedDevices)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // The second result will be filtered out as there is a higher scoring + // ancestor also present in the results. + StartSearch(u"query"); + ASSERT_EQ(2u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Bluetooth Devices"); + EXPECT_EQ(results()[1]->title(), u"Fast Pair Saved Devices2"); +} + +TEST_F(OsSettingsProviderTest, + WillFilterOutSettingsResultsWithAHigherScoringSectionAncestor) { + std::vector<SettingsResultPtr> settings_results; + settings_results.emplace_back(NewSectionResult( + "www.bluetooth.com", u"Bluetooth", 0.7, mojom::Section::kBluetooth)); + settings_results.emplace_back( + NewSettingsResult("www.fastPair.com", u"Fast Pair Saved Devices", 0.6, + mojom::Setting::kFastPairSavedDevices)); + settings_results.emplace_back( + NewSettingsResult("www.fastPair2.com", u"Fast Pair Saved Devices2", 0.9, + mojom::Setting::kFastPairSavedDevices)); + mock_handler()->SetNextResults(std::move(settings_results)); + + // The second result will be filtered out as there is a higher scoring + // ancestor also present in the results. + StartSearch(u"query"); + ASSERT_EQ(2u, results().size()); + EXPECT_EQ(results()[0]->title(), u"Bluetooth"); + EXPECT_EQ(results()[1]->title(), u"Fast Pair Saved Devices2"); } } // namespace app_list::test
diff --git a/chrome/browser/ui/ash/projector/projector_utils.cc b/chrome/browser/ui/ash/projector/projector_utils.cc index d396aae..bf3a77f 100644 --- a/chrome/browser/ui/ash/projector/projector_utils.cc +++ b/chrome/browser/ui/ash/projector/projector_utils.cc
@@ -29,7 +29,7 @@ bool IsRealUserProfile(const Profile* profile) { // Return false for signin, lock screen and incognito profiles. - return chromeos::ProfileHelper::IsUserProfile(profile) && + return ash::ProfileHelper::IsUserProfile(profile) && !profile->IsOffTheRecord(); } @@ -40,7 +40,7 @@ if (!IsRealUserProfile(profile)) return false; - auto* user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile); + auto* user = ash::ProfileHelper::Get()->GetUserByProfile(profile); if (!user) return false;
diff --git a/chrome/browser/ui/ash/session_controller_client_impl_unittest.cc b/chrome/browser/ui/ash/session_controller_client_impl_unittest.cc index aecff36..af4ebf50 100644 --- a/chrome/browser/ui/ash/session_controller_client_impl_unittest.cc +++ b/chrome/browser/ui/ash/session_controller_client_impl_unittest.cc
@@ -124,7 +124,7 @@ ASSERT_TRUE(profile_manager_->SetUp()); cros_settings_test_helper_ = - std::make_unique<chromeos::ScopedCrosSettingsTestHelper>(); + std::make_unique<ash::ScopedCrosSettingsTestHelper>(); } void TearDown() override { @@ -205,8 +205,7 @@ // Owned by |user_manager_enabler_|. TestChromeUserManager* user_manager_ = nullptr; - std::unique_ptr<chromeos::ScopedCrosSettingsTestHelper> - cros_settings_test_helper_; + std::unique_ptr<ash::ScopedCrosSettingsTestHelper> cros_settings_test_helper_; }; // Make sure that cycling one user does not cause any harm.
diff --git a/chrome/browser/ui/ash/system_tray_client_impl.cc b/chrome/browser/ui/ash/system_tray_client_impl.cc index dfe30b1..4d21b16 100644 --- a/chrome/browser/ui/ash/system_tray_client_impl.cc +++ b/chrome/browser/ui/ash/system_tray_client_impl.cc
@@ -288,7 +288,7 @@ std::make_unique<EnterpriseAccountObserver>(this)) { // If this observes clock setting changes before ash comes up the IPCs will // be queued on |system_tray_|. - chromeos::system::SystemClock* clock = + ash::system::SystemClock* clock = g_browser_process->platform_part()->GetSystemClock(); clock->AddObserver(this); system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); @@ -818,7 +818,7 @@ // chromeos::system::SystemClockObserver: void SystemTrayClientImpl::OnSystemClockChanged( - chromeos::system::SystemClock* clock) { + ash::system::SystemClock* clock) { system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); }
diff --git a/chrome/browser/ui/hats/hats_service.cc b/chrome/browser/ui/hats/hats_service.cc index 60b51d2b..6e20ec8 100644 --- a/chrome/browser/ui/hats/hats_service.cc +++ b/chrome/browser/ui/hats/hats_service.cc
@@ -83,6 +83,8 @@ "ts-v2-safety-check"; constexpr char kHatsSurveyTriggerTrustSafetyV2TrustedSurface[] = "ts-v2-trusted-surface"; +constexpr char kHatsSurveyTriggerTrustSafetyV2PrivacyGuide[] = + "ts-v2-privacy-guide"; constexpr char kHatsNextSurveyTriggerIDTesting[] = "HLpeYy5Av0ugnJ3q1cK0XzzA8UHv"; @@ -276,6 +278,10 @@ kHatsSurveyTriggerTrustSafetyV2TrustedSurface, features::kTrustSafetySentimentSurveyV2TrustedSurfaceTriggerId.Get(), std::vector<std::string>{"Interacted with Page Info"}); + survey_configs.emplace_back( + &features::kTrustSafetySentimentSurveyV2, + kHatsSurveyTriggerTrustSafetyV2PrivacyGuide, + features::kTrustSafetySentimentSurveyV2PrivacyGuideTriggerId.Get()); // Accuracy tips survey. survey_configs.emplace_back(
diff --git a/chrome/browser/ui/hats/hats_service.h b/chrome/browser/ui/hats/hats_service.h index 6f38343..e249df61 100644 --- a/chrome/browser/ui/hats/hats_service.h +++ b/chrome/browser/ui/hats/hats_service.h
@@ -65,6 +65,7 @@ extern const char kHatsSurveyTriggerTrustSafetyV2PasswordCheck[]; extern const char kHatsSurveyTriggerTrustSafetyV2SafetyCheck[]; extern const char kHatsSurveyTriggerTrustSafetyV2TrustedSurface[]; +extern const char kHatsSurveyTriggerTrustSafetyV2PrivacyGuide[]; extern const char kHatsSurveyTriggerWhatsNew[]; // The Trigger ID for a test HaTS Next survey which is available for testing
diff --git a/chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h b/chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h index 61190464..f3585af6 100644 --- a/chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h +++ b/chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h
@@ -41,6 +41,7 @@ InteractedWithPrivacySandbox3, (FeatureArea feature_area), (override)); + MOCK_METHOD(void, FinishedPrivacyGuide, (), (override)); }; std::unique_ptr<KeyedService> BuildMockTrustSafetySentimentService(
diff --git a/chrome/browser/ui/hats/trust_safety_sentiment_service.cc b/chrome/browser/ui/hats/trust_safety_sentiment_service.cc index 98392e1..e513f83 100644 --- a/chrome/browser/ui/hats/trust_safety_sentiment_service.cc +++ b/chrome/browser/ui/hats/trust_safety_sentiment_service.cc
@@ -73,6 +73,8 @@ return kHatsSurveyTriggerTrustSafetyV2PasswordCheck; case (TrustSafetySentimentService::FeatureArea::kBrowsingData): return kHatsSurveyTriggerTrustSafetyV2BrowsingData; + case (TrustSafetySentimentService::FeatureArea::kPrivacyGuide): + return kHatsSurveyTriggerTrustSafetyV2PrivacyGuide; default: NOTREACHED(); return ""; @@ -132,6 +134,7 @@ case (TrustSafetySentimentService::FeatureArea::kSafetyCheck): case (TrustSafetySentimentService::FeatureArea::kPasswordCheck): case (TrustSafetySentimentService::FeatureArea::kBrowsingData): + case (TrustSafetySentimentService::FeatureArea::kPrivacyGuide): return isV2 == true; // Both Versions case (TrustSafetySentimentService::FeatureArea::kTrustedSurface): @@ -165,6 +168,10 @@ return base::RandDouble() < features::kTrustSafetySentimentSurveyV2BrowsingDataProbability .Get(); + case (TrustSafetySentimentService::FeatureArea::kPrivacyGuide): + return base::RandDouble() < + features::kTrustSafetySentimentSurveyV2PrivacyGuideProbability + .Get(); default: NOTREACHED(); return false; @@ -505,6 +512,10 @@ ; } +void TrustSafetySentimentService::FinishedPrivacyGuide() { + TriggerOccurred(FeatureArea::kPrivacyGuide, {}); +} + void TrustSafetySentimentService::InteractedWithPrivacySandbox3( FeatureArea feature_area) { std::map<std::string, bool> product_specific_data;
diff --git a/chrome/browser/ui/hats/trust_safety_sentiment_service.h b/chrome/browser/ui/hats/trust_safety_sentiment_service.h index 19640df..289dd43 100644 --- a/chrome/browser/ui/hats/trust_safety_sentiment_service.h +++ b/chrome/browser/ui/hats/trust_safety_sentiment_service.h
@@ -75,6 +75,10 @@ // Called when the user deletes data from Clear Browsing Data dialog. virtual void ClearedBrowsingData(browsing_data::BrowsingDataType datatype); + // Called when the user finishes the privacy guide. Virtual to allow mocking + // in tests. + virtual void FinishedPrivacyGuide(); + // Profile Observer: void OnOffTheRecordProfileCreated(Profile* off_the_record) override; void OnProfileWillBeDestroyed(Profile* profile) override; @@ -103,7 +107,8 @@ kSafetyCheck = 10, kPasswordCheck = 11, kBrowsingData = 12, - kMaxValue = kBrowsingData, + kPrivacyGuide = 13, + kMaxValue = kPrivacyGuide, }; // Called when the user interacts with Privacy Sandbox 3, |feature_area| @@ -135,6 +140,7 @@ FRIEND_TEST_ALL_PREFIXES(TrustSafetySentimentServiceTest, V2_BrowsingData); FRIEND_TEST_ALL_PREFIXES(TrustSafetySentimentServiceTest, V2_BrowsingData_NotInterested); + FRIEND_TEST_ALL_PREFIXES(TrustSafetySentimentServiceTest, V2_PrivacyGuide); // Struct representing a trigger (user action relevant to T&S) that previously // occurred, and is awaiting the appropriate eligibility steps before causing
diff --git a/chrome/browser/ui/hats/trust_safety_sentiment_service_unittest.cc b/chrome/browser/ui/hats/trust_safety_sentiment_service_unittest.cc index 94d2391..71d9ef25 100644 --- a/chrome/browser/ui/hats/trust_safety_sentiment_service_unittest.cc +++ b/chrome/browser/ui/hats/trust_safety_sentiment_service_unittest.cc
@@ -128,10 +128,12 @@ std::string password_check_probability = "0.4"; std::string safety_check_probability = "0.4"; std::string trusted_surface_probability = "0.4"; + std::string privacy_guide_probability = "0.4"; std::string browsing_data_trigger_id = "browsing-data-test"; std::string password_check_trigger_id = "password-check-test"; std::string safety_check_trigger_id = "safety-check-test"; std::string trusted_surface_trigger_id = "trusted-surface-test"; + std::string privacy_guide_trigger_id = "privacy-guide-test"; }; void SetupFeatureParametersV2(FeatureParamsV2 params) { @@ -147,10 +149,12 @@ {"password-check-probability", params.password_check_probability}, {"safety-check-probability", params.safety_check_probability}, {"trusted-surface-probability", params.trusted_surface_probability}, + {"privacy-guide-probability", params.privacy_guide_probability}, {"browsing-data-trigger-id", params.browsing_data_trigger_id}, {"password-check-trigger-id", params.password_check_trigger_id}, {"safety-check-trigger-id", params.safety_check_trigger_id}, {"trusted-surface-trigger-id", params.trusted_surface_trigger_id}, + {"privacy-guide-trigger-id", params.privacy_guide_trigger_id}, }); } @@ -983,3 +987,23 @@ service()->OpenedNewTabPage(); CheckHistograms({}, {}); } + +TEST_F(TrustSafetySentimentServiceTest, V2_PrivacyGuide) { + // Finishing the privacy guide is considered a trigger, and should make a user + // eligible to receive a survey. + FeatureParamsV2 params; + params.privacy_guide_probability = "1.0"; + params.min_time_to_prompt = "0s"; + params.ntp_visits_min_range = "0"; + params.ntp_visits_max_range = "0"; + SetupFeatureParametersV2(params); + + // The correct survey should be launched. + EXPECT_CALL( + *mock_hats_service(), + LaunchSurvey(kHatsSurveyTriggerTrustSafetyV2PrivacyGuide, _, _, _, _)); + service()->FinishedPrivacyGuide(); + service()->OpenedNewTabPage(); + CheckHistograms({TrustSafetySentimentService::FeatureArea::kPrivacyGuide}, + {TrustSafetySentimentService::FeatureArea::kPrivacyGuide}); +}
diff --git a/chrome/browser/ui/startup/first_run_service.cc b/chrome/browser/ui/startup/first_run_service.cc index 38d3377..4dcc93d 100644 --- a/chrome/browser/ui/startup/first_run_service.cc +++ b/chrome/browser/ui/startup/first_run_service.cc
@@ -38,24 +38,27 @@ namespace { bool IsFirstRunEligibleProfile(Profile* profile) { + // Profile selections should exclude these already. + DCHECK(!profile->IsOffTheRecord()); + #if BUILDFLAG(IS_CHROMEOS_LACROS) // Skip for users without Gaia account (e.g. Active Directory, Kiosk, Guest…) if (!profiles::SessionHasGaiaAccount()) return false; + // The profile in Guest user sessions is considered "regular" but should + // also be excluded here. + if (profile->IsGuestSession()) + return false; + // Having secondary profiles implies that the user already used Chrome and so // should not have to see the FRE. So we never want to run it for these. if (!profile->IsMainProfile()) return false; +#else + DCHECK(!profile->IsGuestSession()); #endif - // Don't show the FRE if we are in a Guest user pod or in a Guest profile. - if (profile->IsGuestSession()) - return false; - - if (profile->IsOffTheRecord()) - return false; - return true; } @@ -215,10 +218,10 @@ FirstRunServiceFactory::FirstRunServiceFactory() : ProfileKeyedServiceFactory( "FirstRunServiceFactory", - // TODO(crbug.com/1375277): Update this instead of checking - // the profile compatibility with `IsFirstRunEligibleProfile()`? ProfileSelections::Builder() + .WithRegular(ProfileSelection::kOriginalOnly) .WithGuest(ProfileSelection::kNone) + .WithSystem(ProfileSelection::kNone) .Build()) { // Used for checking Sync consent level. DependsOn(IdentityManagerFactory::GetInstance()); @@ -242,6 +245,9 @@ KeyedService* FirstRunServiceFactory::BuildServiceInstanceFor( content::BrowserContext* context) const { Profile* profile = Profile::FromBrowserContext(context); + // `ProfileSelections` exclude some profiles already, but they do not check + // for some more specific conditions where we don't want to instantiate the + // service. if (!IsFirstRunEligibleProfile(profile)) return nullptr;
diff --git a/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.cc b/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.cc index 6a5f91c..e1b1ffd 100644 --- a/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.cc +++ b/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.cc
@@ -142,19 +142,9 @@ ClearHostClosure clear_host_callback, Profile* profile, ProfilePicker::FirstRunExitedCallback first_run_exited_callback) - : ProfileManagementFlowController(host, - std::move(clear_host_callback), - Step::kIntro), + : ProfileManagementFlowController(host, std::move(clear_host_callback)), profile_(profile), - first_run_exited_callback_(std::move(first_run_exited_callback)) { - RegisterStep( - initial_step(), - CreateIntroStep(host, - base::BindRepeating( - &FirstRunFlowControllerDice::HandleIntroSigninChoice, - weak_ptr_factory_.GetWeakPtr()), - /*enable_animations=*/true)); -} + first_run_exited_callback_(std::move(first_run_exited_callback)) {} FirstRunFlowControllerDice::~FirstRunFlowControllerDice() { if (first_run_exited_callback_) { @@ -163,6 +153,19 @@ } } +void FirstRunFlowControllerDice::Init( + StepSwitchFinishedCallback step_switch_finished_callback) { + RegisterStep( + Step::kIntro, + CreateIntroStep(host(), + base::BindRepeating( + &FirstRunFlowControllerDice::HandleIntroSigninChoice, + weak_ptr_factory_.GetWeakPtr()), + /*enable_animations=*/true)); + SwitchToStep(Step::kIntro, /*reset_state=*/true, + std::move(step_switch_finished_callback)); +} + bool FirstRunFlowControllerDice::PreFinishWithBrowser() { DCHECK(first_run_exited_callback_); std::move(first_run_exited_callback_) @@ -187,12 +190,13 @@ // Binding as Unretained as `this` outlives the step // controllers. base::Unretained(this), ProfileManagementFlowController::Step::kIntro, - /*reset_state=*/false, /*pop_step_callback=*/base::OnceClosure(), - /*step_switch_finished_callback=*/base::OnceCallback<void(bool)>()); + /*reset_state=*/false, + /*step_switch_finished_callback=*/StepSwitchFinishedCallback(), + /*pop_step_callback=*/base::OnceClosure()); SwitchToStep(ProfileManagementFlowController::Step::kAccountSelection, /*reset_state=*/true, - /*pop_step_callback=*/std::move(pop_closure), /*step_switch_finished_callback=*/ base::IgnoreArgs<bool>(base::BindOnce( - &NavigateBackInOneSecond, weak_ptr_factory_.GetWeakPtr()))); + &NavigateBackInOneSecond, weak_ptr_factory_.GetWeakPtr())), + /*pop_step_callback=*/std::move(pop_closure)); }
diff --git a/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.h b/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.h index 047c429b..ae72d76 100644 --- a/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.h +++ b/chrome/browser/ui/views/profiles/first_run_flow_controller_dice.h
@@ -33,8 +33,10 @@ ProfilePicker::FirstRunExitedCallback first_run_exited_callback); ~FirstRunFlowControllerDice() override; - protected: // ProfileManagementFlowController: + void Init(StepSwitchFinishedCallback step_switch_finished_callback) override; + + protected: bool PreFinishWithBrowser() override; private:
diff --git a/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.cc b/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.cc index 0372600..8f2699d 100644 --- a/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.cc +++ b/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.cc
@@ -4,6 +4,7 @@ #include "chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.h" +#include "base/functional/callback.h" #include "base/logging.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile_manager.h" @@ -131,34 +132,10 @@ ClearHostClosure clear_host_callback, Profile* profile, ProfilePicker::DebugFirstRunExitedCallback first_run_exited_callback) - : ProfileManagementFlowController(host, - std::move(clear_host_callback), - Step::kPostSignInFlow), + : ProfileManagementFlowController(host, std::move(clear_host_callback)), + profile_(profile), first_run_exited_callback_(std::move(first_run_exited_callback)) { DCHECK(first_run_exited_callback_); - - auto mark_sync_confirmation_seen_callback = - base::BindOnce(&FirstRunFlowControllerLacros::MarkSyncConfirmationSeen, - // Unretained ok: the callback is passed to a step that - // the `this` will own and outlive. - base::Unretained(this)); - auto finish_flow_callback = FinishFlowCallback( - base::BindOnce(&FirstRunFlowControllerLacros::FinishFlowAndRunInBrowser, - // Unretained ok: the callback is passed to a step that - // the `this` will own and outlive. - base::Unretained(this), - // Unretained ok: `signed_in_flow` will register a profile - // keep alive. - base::Unretained(profile))); - auto signed_in_flow = std::make_unique<LacrosFirstRunSignedInFlowController>( - host, profile, - content::WebContents::Create(content::WebContents::CreateParams(profile)), - std::move(mark_sync_confirmation_seen_callback), - std::move(finish_flow_callback)); - - RegisterStep(initial_step(), - ProfileManagementStepController::CreateForPostSignInFlow( - host, std::move(signed_in_flow))); } FirstRunFlowControllerLacros::~FirstRunFlowControllerLacros() { @@ -175,6 +152,35 @@ } } +void FirstRunFlowControllerLacros::Init( + StepSwitchFinishedCallback step_switch_finished_callback) { + auto mark_sync_confirmation_seen_callback = + base::BindOnce(&FirstRunFlowControllerLacros::MarkSyncConfirmationSeen, + // Unretained ok: the callback is passed to a step that + // the `this` will own and outlive. + base::Unretained(this)); + auto finish_flow_callback = FinishFlowCallback( + base::BindOnce(&FirstRunFlowControllerLacros::FinishFlowAndRunInBrowser, + // Unretained ok: the callback is passed to a step that + // the `this` will own and outlive. + base::Unretained(this), + // Unretained ok: `signed_in_flow` will register a profile + // keep alive. + base::Unretained(profile_))); + auto signed_in_flow = std::make_unique<LacrosFirstRunSignedInFlowController>( + host(), profile_, + content::WebContents::Create( + content::WebContents::CreateParams(profile_)), + std::move(mark_sync_confirmation_seen_callback), + std::move(finish_flow_callback)); + + RegisterStep(Step::kPostSignInFlow, + ProfileManagementStepController::CreateForPostSignInFlow( + host(), std::move(signed_in_flow))); + SwitchToStep(Step::kPostSignInFlow, /*reset_state=*/true, + std::move(step_switch_finished_callback)); +} + bool FirstRunFlowControllerLacros::PreFinishWithBrowser() { std::move(first_run_exited_callback_) .Run(ProfilePicker::FirstRunExitStatus::kCompleted,
diff --git a/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.h b/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.h index f40e9112..3ec40a0 100644 --- a/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.h +++ b/chrome/browser/ui/views/profiles/first_run_flow_controller_lacros.h
@@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_FIRST_RUN_FLOW_CONTROLLER_LACROS_H_ #define CHROME_BROWSER_UI_VIEWS_PROFILES_FIRST_RUN_FLOW_CONTROLLER_LACROS_H_ +#include "base/memory/raw_ptr.h" #include "chrome/browser/ui/profile_picker.h" #include "chrome/browser/ui/views/profiles/profile_management_flow_controller.h" @@ -26,13 +27,19 @@ ~FirstRunFlowControllerLacros() override; - protected: // ProfileManagementFlowController: + void Init(StepSwitchFinishedCallback step_switch_finished_callback) override; + + protected: bool PreFinishWithBrowser() override; private: void MarkSyncConfirmationSeen(); + // Pointer to the primary profile. Safe to keep, in particular we are going to + // register a profile keep alive through the step we create in `Init()`. + const raw_ptr<Profile> profile_; + // Captures the operation that the user expected to run at the time we chose // to show them the FRE. When we exit the FRE, we MUST run this. We expect // that it will cause a UI for the primary profile to be opened.
diff --git a/chrome/browser/ui/views/profiles/profile_management_flow_controller.cc b/chrome/browser/ui/views/profiles/profile_management_flow_controller.cc index 352797e9..8dc8d60 100644 --- a/chrome/browser/ui/views/profiles/profile_management_flow_controller.cc +++ b/chrome/browser/ui/views/profiles/profile_management_flow_controller.cc
@@ -17,27 +17,18 @@ ProfileManagementFlowController::ProfileManagementFlowController( ProfilePickerWebContentsHost* host, - ClearHostClosure clear_host_callback, - Step initial_step) - : initial_step_(initial_step), - host_(host), - clear_host_callback_(std::move(clear_host_callback)) {} + ClearHostClosure clear_host_callback) + : host_(host), clear_host_callback_(std::move(clear_host_callback)) { + DCHECK(clear_host_callback_.value()); +} ProfileManagementFlowController::~ProfileManagementFlowController() = default; -void ProfileManagementFlowController::Init( - base::OnceCallback<void(bool)> initial_step_switch_finished_callback) { - DCHECK(clear_host_callback_.value()); - SwitchToStep(initial_step(), /*reset_state=*/true, - /*pop_step_callback=*/base::OnceClosure(), - std::move(initial_step_switch_finished_callback)); -} - void ProfileManagementFlowController::SwitchToStep( Step step, bool reset_state, - base::OnceClosure pop_step_callback, - base::OnceCallback<void(bool)> step_switch_finished_callback) { + StepSwitchFinishedCallback step_switch_finished_callback, + base::OnceClosure pop_step_callback) { DCHECK_NE(Step::kUnknown, step); DCHECK_NE(current_step_, step);
diff --git a/chrome/browser/ui/views/profiles/profile_management_flow_controller.h b/chrome/browser/ui/views/profiles/profile_management_flow_controller.h index 888c796..3e66518 100644 --- a/chrome/browser/ui/views/profiles/profile_management_flow_controller.h +++ b/chrome/browser/ui/views/profiles/profile_management_flow_controller.h
@@ -21,9 +21,9 @@ // `ProfileManagementStepController`s and owned by this object. // // Typical usage starts with calling `Init()` on the instantiated flow, which -// will switch to the `initial_step()`. Then as the user interacts with the -// flow, this controller will handle instantiating and navigating between the -// steps. +// will register and switch to the first step. Then as the user interacts with +// the flow, this controller will handle instantiating and navigating between +// the next steps. class ProfileManagementFlowController { public: // TODO(https://crbug.com/1358843): Split the steps more granularly across @@ -52,33 +52,30 @@ kIntro, }; - // Creates a flow controller that will advance to `initial_step` when it is - // `Init()`-ed. + // Creates a flow controller that will start showing UI when `Init()`-ed. // `clear_host_callback` will be called if `host` needs to be closed. - explicit ProfileManagementFlowController(ProfilePickerWebContentsHost* host, - ClearHostClosure clear_host_callback, - Step initial_step); + explicit ProfileManagementFlowController( + ProfilePickerWebContentsHost* host, + ClearHostClosure clear_host_callback); virtual ~ProfileManagementFlowController(); - // Switches to the `initial_step()`. - // If `initial_step_switch_finished_callback` is provided, it will be called - // with `true` when the navigation to the initial step succeeded, or with - // `false` otherwise. - virtual void Init( - base::OnceCallback<void(bool)> initial_step_switch_finished_callback = - base::OnceCallback<void(bool success)>()); + // Starts the flow by registering and switching to the first step. + // If `step_switch_finished_callback` is provided, it will be called with + // `true` when the navigation to the initial step succeeded, or with `false` + // otherwise. + virtual void Init(StepSwitchFinishedCallback step_switch_finished_callback = + StepSwitchFinishedCallback()) = 0; // Instructs a step registered as `step` to be shown. // If `step_switch_finished_callback` is provided, it will be called // with `true` when the navigation to `step` succeeded, or with // `false` otherwise. // Also see `ProfileManagementStepController::Show()`. - void SwitchToStep( - Step step, - bool reset_state, - base::OnceClosure pop_step_callback = base::OnceClosure(), - base::OnceCallback<void(bool)> step_switch_finished_callback = - base::OnceCallback<void(bool success)>()); + void SwitchToStep(Step step, + bool reset_state, + StepSwitchFinishedCallback step_switch_finished_callback = + StepSwitchFinishedCallback(), + base::OnceClosure pop_step_callback = base::OnceClosure()); void OnNavigateBackRequested(); @@ -115,15 +112,11 @@ Step current_step() const { return current_step_; } - Step initial_step() const { return initial_step_; } - ProfilePickerWebContentsHost* host() { return host_; } private: Step current_step_ = Step::kUnknown; - Step initial_step_; - raw_ptr<ProfilePickerWebContentsHost> host_; ClearHostClosure clear_host_callback_;
diff --git a/chrome/browser/ui/views/profiles/profile_management_step_controller.cc b/chrome/browser/ui/views/profiles/profile_management_step_controller.cc index c64d51f..827e349 100644 --- a/chrome/browser/ui/views/profiles/profile_management_step_controller.cc +++ b/chrome/browser/ui/views/profiles/profile_management_step_controller.cc
@@ -80,7 +80,7 @@ ~DiceSignInStepController() override = default; - void Show(base::OnceCallback<void(bool)> step_shown_callback, + void Show(StepSwitchFinishedCallback step_shown_callback, bool reset_state) override { DCHECK(step_shown_callback); DCHECK(signed_in_callback_) << "Attempting to show Dice step again while "
diff --git a/chrome/browser/ui/views/profiles/profile_management_step_controller.h b/chrome/browser/ui/views/profiles/profile_management_step_controller.h index ecdec68..c5ee191a 100644 --- a/chrome/browser/ui/views/profiles/profile_management_step_controller.h +++ b/chrome/browser/ui/views/profiles/profile_management_step_controller.h
@@ -68,7 +68,7 @@ // `reset_state` indicates that the step should reset its internal state and // appear as freshly created. Callers should pass `true` for newly created // steps. - virtual void Show(base::OnceCallback<void(bool success)> step_shown_callback, + virtual void Show(StepSwitchFinishedCallback step_shown_callback, bool reset_state = false) = 0; // Frees up unneeded resources. `Show()` will be called if it's needed again.
diff --git a/chrome/browser/ui/views/profiles/profile_management_utils.h b/chrome/browser/ui/views/profiles/profile_management_utils.h index ba0fd4a..8f00d034 100644 --- a/chrome/browser/ui/views/profiles/profile_management_utils.h +++ b/chrome/browser/ui/views/profiles/profile_management_utils.h
@@ -14,6 +14,13 @@ class Browser; class Profile; +// Type of the callbacks that are called to be notified that the switch to a +// given step by `ProfileManagementFlowController` is completed. `success` is +// is set to false if some sort of error is detected, and `true` otherwise. +// This type is intended for documentation purposes, there is no plan to treat +// it like an opaque type. +using StepSwitchFinishedCallback = base::OnceCallback<void(bool success)>; + // Callback executed when the flow finishes, after the host was cleared and // we opened a browser for the newly set up profile. // This callback should not rely on profile management flow instances, as we
diff --git a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc index ff497c11..6b6623c 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.cc
@@ -53,8 +53,12 @@ } // namespace ProfilePickerDiceSignInProvider::ProfilePickerDiceSignInProvider( - ProfilePickerWebContentsHost* host) - : host_(host) {} + ProfilePickerWebContentsHost* host, + absl::optional<base::FilePath> profile_path) + : host_(host), profile_path_(profile_path) { + // If the path is provided, it must be non-empty. + DCHECK(!(profile_path.has_value() && profile_path->empty())); +} ProfilePickerDiceSignInProvider::~ProfilePickerDiceSignInProvider() { // Handle unfinished signed-in profile creation (i.e. when callback was not @@ -63,9 +67,10 @@ if (IsInitialized()) { contents()->SetDelegate(nullptr); - // Schedule the profile for deletion if it wasn't deleted yet, since it's - // not needed any more. - if (!ProfileManager::IsProfileDirectoryMarkedForDeletion( + // Schedule the ephemeral profile for deletion if it wasn't deleted yet, + // since it's not needed any more. + if (!profile_path_.has_value() && + !ProfileManager::IsProfileDirectoryMarkedForDeletion( profile_->GetPath())) { g_browser_process->profile_manager() ->ScheduleEphemeralProfileForDeletion(profile_->GetPath()); @@ -93,17 +98,24 @@ return; } - size_t icon_index = profiles::GetPlaceholderAvatarIndex(); - // Silently create the new profile for browsing on GAIA (so that the sign-in - // cookies are stored in the right profile). - ProfileManager::CreateMultiProfileAsync( - g_browser_process->profile_manager() - ->GetProfileAttributesStorage() - .ChooseNameForNewProfile(icon_index), - icon_index, /*is_hidden=*/true, - base::BindOnce(&ProfilePickerDiceSignInProvider::OnProfileInitialized, - weak_ptr_factory_.GetWeakPtr(), - std::move(switch_finished_callback))); + auto profile_init_callback = base::BindOnce( + &ProfilePickerDiceSignInProvider::OnProfileInitialized, + weak_ptr_factory_.GetWeakPtr(), std::move(switch_finished_callback)); + ProfileManager* profile_manager = g_browser_process->profile_manager(); + if (profile_path_.has_value()) { + bool profile_exists = profile_manager->LoadProfileByPath( + profile_path_.value(), /*incognito=*/false, + std::move(profile_init_callback)); + DCHECK(profile_exists); + } else { + size_t icon_index = profiles::GetPlaceholderAvatarIndex(); + // Silently create the new profile for browsing on GAIA (so that the sign-in + // cookies are stored in the right profile). + ProfileManager::CreateMultiProfileAsync( + profile_manager->GetProfileAttributesStorage().ChooseNameForNewProfile( + icon_index), + icon_index, /*is_hidden=*/true, std::move(profile_init_callback)); + } } void ProfilePickerDiceSignInProvider::ReloadSignInPage() { @@ -156,7 +168,7 @@ bool ProfilePickerDiceSignInProvider::HandleKeyboardEvent( content::WebContents* source, const content::NativeWebKeyboardEvent& event) { - return host_->HandleKeyboardEvent(source, event); + return host_->GetWebContentsDelegate()->HandleKeyboardEvent(source, event); } void ProfilePickerDiceSignInProvider::NavigationStateChanged( @@ -184,7 +196,7 @@ web_modal::WebContentsModalDialogHost* ProfilePickerDiceSignInProvider::GetWebContentsModalDialogHost() { - return host_; + return host_->GetWebContentsModalDialogHost(); } void ProfilePickerDiceSignInProvider::OnRefreshTokenUpdatedForAccount( @@ -250,23 +262,27 @@ signin_metrics::AccessPoint::ACCESS_POINT_USER_MANAGER, signin_metrics::PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO); - // Apply the default theme to get consistent colors for toolbars (this matters - // for linux where the 'system' theme is used for new profiles). - auto* theme_service = ThemeServiceFactory::GetForProfile(profile_); - theme_service->UseDefaultTheme(); + // Apply the default theme to get consistent colors for toolbars in newly + // created profiles (this matters for linux where the 'system' theme is used + // for new profiles). + if (!profile_path_.has_value()) { + auto* theme_service = ThemeServiceFactory::GetForProfile(profile_); + theme_service->UseDefaultTheme(); + } // Make sure the web contents used for sign-in has proper background to match // the toolbar (for dark mode). views::WebContentsSetBackgroundColor::CreateForWebContentsWithColor( contents(), host_->GetPreferredBackgroundColor()); - std::move(switch_finished_callback).Run(true); - host_->ShowScreen( - contents(), GetSigninURL(host_->ShouldUseDarkColors()), + base::OnceClosure navigation_finished_closure = base::BindOnce(&ProfilePickerWebContentsHost::SetNativeToolbarVisible, // Unretained is enough as the callback is called by the // host itself. - base::Unretained(host_), /*visible=*/true)); + base::Unretained(host_), /*visible=*/true) + .Then(base::BindOnce(std::move(switch_finished_callback), true)); + host_->ShowScreen(contents(), GetSigninURL(host_->ShouldUseDarkColors()), + std::move(navigation_finished_closure)); } bool ProfilePickerDiceSignInProvider::IsInitialized() const {
diff --git a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h index b1c451b..08f5960 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h +++ b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h
@@ -5,7 +5,8 @@ #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_DICE_SIGN_IN_PROVIDER_H_ #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_DICE_SIGN_IN_PROVIDER_H_ -#include "base/callback.h" +#include "base/files/file_path.h" +#include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/profiles/keep_alive/scoped_profile_keep_alive.h" @@ -13,6 +14,7 @@ #include "chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h" #include "components/signin/public/identity_manager/identity_manager.h" #include "content/public/browser/web_contents_delegate.h" +#include "third_party/abseil-cpp/absl/types/optional.h" struct CoreAccountInfo; class ProfilePickerWebContentsHost; @@ -23,7 +25,7 @@ class WebContents; } // namespace content -// Class responsible for the GAIA sign-in within profile creation flow. +// Class responsible for the GAIA sign-in within profile management flows. class ProfilePickerDiceSignInProvider : public content::WebContentsDelegate, public ChromeWebModalDialogManagerDelegate, @@ -42,7 +44,13 @@ bool is_saml, std::unique_ptr<content::WebContents>)>; - explicit ProfilePickerDiceSignInProvider(ProfilePickerWebContentsHost* host); + // Creates a new provider that will render the Gaia sign-in flow in `host` for + // a profile at `profile_path`. + // If no `profile_path` is provided, a new profile (and associated directory) + // will be created. + explicit ProfilePickerDiceSignInProvider( + ProfilePickerWebContentsHost* host, + absl::optional<base::FilePath> profile_path = absl::nullopt); ~ProfilePickerDiceSignInProvider() override; ProfilePickerDiceSignInProvider(const ProfilePickerDiceSignInProvider&) = delete; @@ -65,7 +73,7 @@ void NavigateBack(); // Returns whether the flow is initialized (i.e. whether `profile_` has been - // created). + // loaded). bool IsInitialized() const; content::WebContents* contents() const { return contents_.get(); } @@ -97,7 +105,7 @@ void OnPrimaryAccountChanged( const signin::PrimaryAccountChangeEvent& event_details) override; - // Initializes the flow with the newly created profile. + // Initializes the flow with the newly created or loaded profile. void OnProfileInitialized( base::OnceCallback<void(bool)> switch_finished_callback, Profile* new_profile); @@ -113,6 +121,9 @@ // The host must outlive this object. const raw_ptr<ProfilePickerWebContentsHost> host_; + // The path to the profile in which to perform the sign-in. If absent, a new + // profile will be created. + const absl::optional<base::FilePath> profile_path_; // Sign-in callback, valid until it's called. SignedInCallback callback_; @@ -121,7 +132,7 @@ // Prevent |profile_| from being destroyed first. std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_; - // The web contents backed by `profile`. This is used for displaying the + // The web contents backed by `profile_`. This is used for displaying the // sign-in flow. std::unique_ptr<content::WebContents> contents_;
diff --git a/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc new file mode 100644 index 0000000..ab003b3 --- /dev/null +++ b/chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc
@@ -0,0 +1,134 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/functional/callback_helpers.h" +#include "base/test/mock_callback.h" +#include "chrome/browser/profiles/profile_manager.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h" +#include "chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h" +#include "chrome/test/base/in_process_browser_test.h" +#include "content/public/browser/web_contents.h" +#include "content/public/browser/web_contents_delegate.h" +#include "content/public/test/browser_test.h" +#include "testing/gmock/include/gmock/gmock.h" + +using testing::_; + +namespace { + +const char kExpectedSigninBaseUrl[] = + "https://accounts.google.com/signin/chrome/sync"; + +class MockHost : public ProfilePickerWebContentsHost { + public: + MOCK_METHOD(void, + ShowScreen, + (content::WebContents * contents, + const GURL& url, + base::OnceClosure navigation_finished_closure)); + MOCK_METHOD(void, + ShowScreenInPickerContents, + (const GURL& url, base::OnceClosure navigation_finished_closure)); + MOCK_METHOD(bool, ShouldUseDarkColors, (), (const)); + MOCK_METHOD(content::WebContents*, GetPickerContents, (), (const)); + MOCK_METHOD(void, SetNativeToolbarVisible, (bool visible)); + MOCK_METHOD(SkColor, GetPreferredBackgroundColor, (), (const)); + MOCK_METHOD(content::WebContentsDelegate*, GetWebContentsDelegate, ()); + MOCK_METHOD(web_modal::WebContentsModalDialogHost*, + GetWebContentsModalDialogHost, + ()); +}; + +Profile* GetContentsProfile(content::WebContents* contents) { + return Profile::FromBrowserContext(contents->GetBrowserContext()); +} + +} // namespace + +class ProfilePickerDiceSignInProviderBrowserTest : public InProcessBrowserTest { + public: + ProfilePickerDiceSignInProviderBrowserTest() = default; + ~ProfilePickerDiceSignInProviderBrowserTest() override = default; + + testing::NiceMock<MockHost>* host() { return &host_; } + + private: + testing::NiceMock<MockHost> host_; +}; + +IN_PROC_BROWSER_TEST_F(ProfilePickerDiceSignInProviderBrowserTest, + SwitchToSignInThenExit) { + base::FilePath provider_profile_path; + base::RunLoop switch_finished_loop; + base::MockCallback<ProfilePickerDiceSignInProvider::SignedInCallback> + signin_finished_callback; + + // Sign-in is exited, the callback should never run. + EXPECT_CALL(signin_finished_callback, Run(_, _, _)).Times(0); + + { + ProfilePickerDiceSignInProvider provider{host()}; + + EXPECT_CALL(*host(), ShowScreen(_, _, _)) + .WillOnce([&](content::WebContents* contents, const GURL& url, + base::OnceClosure callback) { + provider_profile_path = GetContentsProfile(contents)->GetPath(); + EXPECT_FALSE(provider_profile_path.empty()); + EXPECT_NE(browser()->profile()->GetPath(), provider_profile_path); + + EXPECT_TRUE(url.spec().starts_with(kExpectedSigninBaseUrl)); + + std::move(callback).Run(); + }); + + provider.SwitchToSignIn( + base::IgnoreArgs<bool>(switch_finished_loop.QuitClosure()), + signin_finished_callback.Get()); + + switch_finished_loop.Run(); + } + + // On exit, the provider should schedule the profile it created for deletion. + EXPECT_TRUE(ProfileManager::IsProfileDirectoryMarkedForDeletion( + provider_profile_path)); +} + +IN_PROC_BROWSER_TEST_F(ProfilePickerDiceSignInProviderBrowserTest, + SwitchToSignInThenExit_WithProfile) { + base::FilePath provider_profile_path; + base::RunLoop switch_finished_loop; + base::MockCallback<ProfilePickerDiceSignInProvider::SignedInCallback> + signin_finished_callback; + + // Sign-in is exited, the callback should never run. + EXPECT_CALL(signin_finished_callback, Run(_, _, _)).Times(0); + + { + ProfilePickerDiceSignInProvider provider{host(), + browser()->profile()->GetPath()}; + + EXPECT_CALL(*host(), ShowScreen(_, _, _)) + .WillOnce([&](content::WebContents* contents, const GURL& url, + base::OnceClosure callback) { + provider_profile_path = GetContentsProfile(contents)->GetPath(); + EXPECT_FALSE(provider_profile_path.empty()); + EXPECT_EQ(browser()->profile()->GetPath(), provider_profile_path); + + EXPECT_TRUE(url.spec().starts_with(kExpectedSigninBaseUrl)); + + std::move(callback).Run(); + }); + + provider.SwitchToSignIn( + base::IgnoreArgs<bool>(switch_finished_loop.QuitClosure()), + signin_finished_callback.Get()); + + switch_finished_loop.Run(); + } + + // Since a profile has been passed in, the provider should not delete it. + EXPECT_FALSE(ProfileManager::IsProfileDirectoryMarkedForDeletion( + provider_profile_path)); +}
diff --git a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc index 0f9f447..f0d1caf3 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc
@@ -256,21 +256,24 @@ ProfilePickerWebContentsHost* host, ClearHostClosure clear_host_callback, ProfilePicker::EntryPoint entry_point) - : ProfileManagementFlowController(host, - std::move(clear_host_callback), - Step::kProfilePicker), - entry_point_(entry_point) { - RegisterStep(initial_step(), - ProfileManagementStepController::CreateForProfilePickerApp( - host, GetInitialURL(entry_point_))); -} + : ProfileManagementFlowController(host, std::move(clear_host_callback)), + entry_point_(entry_point) {} ProfilePickerFlowController::~ProfilePickerFlowController() = default; +void ProfilePickerFlowController::Init( + StepSwitchFinishedCallback step_switch_finished_callback) { + RegisterStep(Step::kProfilePicker, + ProfileManagementStepController::CreateForProfilePickerApp( + host(), GetInitialURL(entry_point_))); + SwitchToStep(Step::kProfilePicker, /*reset_state=*/true, + std::move(step_switch_finished_callback)); +} + #if BUILDFLAG(ENABLE_DICE_SUPPORT) void ProfilePickerFlowController::SwitchToDiceSignIn( absl::optional<SkColor> profile_color, - base::OnceCallback<void(bool)> switch_finished_callback) { + StepSwitchFinishedCallback switch_finished_callback) { DCHECK_EQ(Step::kProfilePicker, current_step()); profile_color_ = profile_color; @@ -289,11 +292,12 @@ &ProfilePickerFlowController::SwitchToStep, // Unretained ok:`this` outlives the step controllers. base::Unretained(this), Step::kProfilePicker, - /*reset_state=*/false, /*pop_step_callback=*/base::OnceClosure(), - /*step_switch_finished_callback=*/base::OnceCallback<void(bool)>()); + /*reset_state=*/false, + /*step_switch_finished_callback=*/StepSwitchFinishedCallback(), + /*pop_step_callback=*/base::OnceClosure()); SwitchToStep(Step::kAccountSelection, - /*reset_state=*/step_needs_registration, std::move(pop_closure), - std::move(switch_finished_callback)); + /*reset_state=*/step_needs_registration, + std::move(switch_finished_callback), std::move(pop_closure)); } #endif
diff --git a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.h b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.h index 4175235..4abfc5b4 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_flow_controller.h +++ b/chrome/browser/ui/views/profiles/profile_picker_flow_controller.h
@@ -21,9 +21,10 @@ ProfilePicker::EntryPoint entry_point); ~ProfilePickerFlowController() override; - void SwitchToDiceSignIn( - absl::optional<SkColor> profile_color, - base::OnceCallback<void(bool)> switch_finished_callback); + void Init(StepSwitchFinishedCallback step_switch_finished_callback) override; + + void SwitchToDiceSignIn(absl::optional<SkColor> profile_color, + StepSwitchFinishedCallback switch_finished_callback); void SwitchToPostSignIn(Profile* signed_in_profile, #if BUILDFLAG(ENABLE_DICE_SUPPORT)
diff --git a/chrome/browser/ui/views/profiles/profile_picker_view.cc b/chrome/browser/ui/views/profiles/profile_picker_view.cc index 0923cbd..1e20a67 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_view.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_view.cc
@@ -454,6 +454,15 @@ return contents_.get(); } +content::WebContentsDelegate* ProfilePickerView::GetWebContentsDelegate() { + return this; +} + +web_modal::WebContentsModalDialogHost* +ProfilePickerView::GetWebContentsModalDialogHost() { + return this; +} + #if BUILDFLAG(ENABLE_DICE_SUPPORT) void ProfilePickerView::SetNativeToolbarVisible(bool visible) { if (!visible) {
diff --git a/chrome/browser/ui/views/profiles/profile_picker_view.h b/chrome/browser/ui/views/profiles/profile_picker_view.h index 17bb65a..e5c8909 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_view.h +++ b/chrome/browser/ui/views/profiles/profile_picker_view.h
@@ -41,7 +41,9 @@ // Dialog widget that contains the Desktop Profile picker webui. class ProfilePickerView : public views::WidgetDelegateView, - public ProfilePickerWebContentsHost { + public ProfilePickerWebContentsHost, + public content::WebContentsDelegate, + public web_modal::WebContentsModalDialogHost { public: ProfilePickerView(const ProfilePickerView&) = delete; ProfilePickerView& operator=(const ProfilePickerView&) = delete; @@ -66,6 +68,9 @@ base::OnceClosure()) override; bool ShouldUseDarkColors() const override; content::WebContents* GetPickerContents() const override; + web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() + override; + content::WebContentsDelegate* GetWebContentsDelegate() override; #if BUILDFLAG(ENABLE_DICE_SUPPORT) void SetNativeToolbarVisible(bool visible) override;
diff --git a/chrome/browser/ui/views/profiles/profile_picker_view_test_utils.cc b/chrome/browser/ui/views/profiles/profile_picker_view_test_utils.cc index c70168bb..1617514 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_view_test_utils.cc +++ b/chrome/browser/ui/views/profiles/profile_picker_view_test_utils.cc
@@ -56,25 +56,25 @@ Step step, ProfileManagementStepTestView::StepControllerFactory factory, base::OnceClosure initial_step_load_finished_closure) - : ProfileManagementFlowController(host, - std::move(clear_host_callback), - step), + : ProfileManagementFlowController(host, std::move(clear_host_callback)), + step_(step), + step_controller_factory_(std::move(factory)), initial_step_load_finished_closure_( - std::move(initial_step_load_finished_closure)) { - RegisterStep(initial_step(), factory.Run(host)); + std::move(initial_step_load_finished_closure)) {} + + void Init(StepSwitchFinishedCallback step_switch_finished_callback) override { + RegisterStep(step_, step_controller_factory_.Run(host())); + SwitchToStep( + step_, /*reset_state=*/true, + /*step_switch_finished_callback=*/ + base::BindOnce( + &TestProfileManagementFlowController::OnInitialStepSwitchFinished, + weak_ptr_factory_.GetWeakPtr(), + std::move(step_switch_finished_callback))); } - void Init(base::OnceCallback<void(bool)> - initial_step_switch_finished_callback) override { - ProfileManagementFlowController::Init(base::BindOnce( - &TestProfileManagementFlowController::OnInitialStepSwitchFinished, - weak_ptr_factory_.GetWeakPtr(), - std::move(initial_step_switch_finished_callback))); - } - - void OnInitialStepSwitchFinished( - base::OnceCallback<void(bool)> original_callback, - bool success) { + void OnInitialStepSwitchFinished(StepSwitchFinishedCallback original_callback, + bool success) { if (original_callback) { std::move(original_callback).Run(success); } @@ -93,6 +93,8 @@ std::move(initial_step_load_finished_closure_).Run(); } + Step step_; + ProfileManagementStepTestView::StepControllerFactory step_controller_factory_; base::OnceClosure initial_step_load_finished_closure_; base::WeakPtrFactory<TestProfileManagementFlowController> weak_ptr_factory_{ this};
diff --git a/chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h b/chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h index 91be9df..3e67dce 100644 --- a/chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h +++ b/chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h
@@ -5,10 +5,9 @@ #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_WEB_CONTENTS_HOST_H_ #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_PICKER_WEB_CONTENTS_HOST_H_ -#include "base/callback.h" +#include "base/functional/callback.h" #include "components/signin/public/base/signin_buildflags.h" #include "components/web_modal/web_contents_modal_dialog_host.h" -#include "content/public/browser/web_contents_delegate.h" #if BUILDFLAG(ENABLE_DICE_SUPPORT) #include "ui/views/controls/webview/web_contents_set_background_color.h" @@ -18,8 +17,13 @@ namespace content { class WebContents; +class WebContentsDelegate; } // namespace content +namespace web_modal { +class WebContentsModalDialogHost; +} + // Type for a callback that is used to close the `ProfilePickerWebContentsHost`. // It is the owner's responsibility to make sure that the issuing host is still // alive and that the callback is valid, before running it. @@ -28,9 +32,7 @@ // Class responsible for embedding a web contents in the profile picker and // providing extra UI such as a back button. -class ProfilePickerWebContentsHost - : public content::WebContentsDelegate, - public web_modal::WebContentsModalDialogHost { +class ProfilePickerWebContentsHost { public: // Shows a screen with `url` in `contents`. If `url` is empty, it only shows // `contents` with its currently loaded url. If both @@ -52,6 +54,11 @@ // Returns the picker WebContents. virtual content::WebContents* GetPickerContents() const = 0; + virtual content::WebContentsDelegate* GetWebContentsDelegate() = 0; + + virtual web_modal::WebContentsModalDialogHost* + GetWebContentsModalDialogHost() = 0; + #if BUILDFLAG(ENABLE_DICE_SUPPORT) // Changes the visibility of the host's native toolbar, which shows a back // button.
diff --git a/chrome/browser/ui/web_applications/BUILD.gn b/chrome/browser/ui/web_applications/BUILD.gn index bcc1b57..f34bca6 100644 --- a/chrome/browser/ui/web_applications/BUILD.gn +++ b/chrome/browser/ui/web_applications/BUILD.gn
@@ -106,7 +106,10 @@ } if (is_chromeos_lacros) { - sources += [ "lacros_web_app_browsertest.cc" ] + sources += [ + "lacros_web_app_browsertest.cc", + "lacros_web_app_shelf_browsertest.cc", + ] } defines = [ "HAS_OUT_OF_PROC_TEST_RUNNER" ] @@ -119,6 +122,7 @@ "//chrome/browser/web_applications:web_applications_test_support", "//chrome/test:test_support", "//chrome/test:test_support_ui", + "//components/app_constants", "//components/embedder_support", "//components/page_load_metrics/browser:test_support", "//components/services/app_service/public/cpp:intents",
diff --git a/chrome/browser/ui/web_applications/lacros_web_app_shelf_browsertest.cc b/chrome/browser/ui/web_applications/lacros_web_app_shelf_browsertest.cc new file mode 100644 index 0000000..29557f5 --- /dev/null +++ b/chrome/browser/ui/web_applications/lacros_web_app_shelf_browsertest.cc
@@ -0,0 +1,210 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/lacros/browser_test_util.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/tabs/tab_strip_model.h" +#include "chrome/browser/ui/web_applications/app_browser_controller.h" +#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h" +#include "chrome/browser/ui/web_applications/test/web_app_navigation_browsertest.h" +#include "chrome/browser/web_applications/test/app_registry_cache_waiter.h" +#include "chrome/browser/web_applications/test/web_app_install_test_utils.h" +#include "chrome/browser/web_applications/user_display_mode.h" +#include "chrome/browser/web_applications/web_app_provider.h" +#include "chrome/browser/web_applications/web_app_sync_bridge.h" +#include "chrome/browser/web_applications/web_app_utils.h" +#include "chromeos/crosapi/mojom/test_controller.mojom-test-utils.h" +#include "chromeos/crosapi/mojom/test_controller.mojom.h" +#include "chromeos/lacros/lacros_service.h" +#include "components/app_constants/constants.h" +#include "content/public/test/browser_test.h" +#include "content/public/test/browser_test_utils.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "url/gurl.h" + +using crosapi::mojom::ShelfItemState; + +namespace { + +constexpr char kFirstAppUrlHost[] = "first-pwa.test"; +constexpr char kSecondAppUrlHost[] = "second-pwa.test"; + +} // namespace + +namespace web_app { + +class LacrosWebAppShelfBrowserTest : public WebAppNavigationBrowserTest { + public: + LacrosWebAppShelfBrowserTest() = default; + ~LacrosWebAppShelfBrowserTest() override = default; + + void SetUpOnMainThread() override { + WebAppNavigationBrowserTest::SetUpOnMainThread(); + ASSERT_TRUE(https_server().Start()); + } + + protected: + // If ash is does not contain the relevant test controller functionality, then + // there's nothing to do for this test. + bool IsServiceAvailable() { + DCHECK(IsWebAppsCrosapiEnabled()); + if (chromeos::LacrosService::Get()->GetInterfaceVersion( + crosapi::mojom::TestController::Uuid_) < + static_cast<int>(crosapi::mojom::TestController::MethodMinVersions:: + kGetShelfItemStateMinVersion)) { + LOG(WARNING) << "Unsupported ash version."; + return false; + } + return true; + } +}; + +IN_PROC_BROWSER_TEST_F(LacrosWebAppShelfBrowserTest, Activation) { + if (!IsServiceAvailable()) + GTEST_SKIP(); + + const GURL app1_url = + https_server().GetURL(kFirstAppUrlHost, "/web_apps/basic.html"); + const AppId app1_id = + InstallWebAppFromPageAndCloseAppBrowser(browser(), app1_url); + + const GURL app2_url = https_server().GetURL( + kSecondAppUrlHost, "/web_apps/standalone/basic.html"); + const AppId app2_id = + InstallWebAppFromPageAndCloseAppBrowser(browser(), app2_url); + + AppReadinessWaiter(profile(), app1_id).Await(); + Browser* app_browser1 = LaunchWebAppBrowser(profile(), app1_id); + EXPECT_TRUE(AppBrowserController::IsForWebApp(app_browser1, app1_id)); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kActive)); + + AppReadinessWaiter(profile(), app2_id).Await(); + LaunchWebAppBrowser(profile(), app2_id); + browser_test_util::WaitForShelfItemState( + app2_id, static_cast<uint32_t>(ShelfItemState::kActive)); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kRunning)); + + CloseAndWait(app_browser1); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kNormal)); + + test::UninstallWebApp(profile(), app2_id); + AppReadinessWaiter(profile(), app2_id, apps::Readiness::kUninstalledByUser) + .Await(); + browser_test_util::WaitForShelfItemState( + app2_id, static_cast<uint32_t>(ShelfItemState::kNormal)); + + test::UninstallWebApp(profile(), app1_id); +} + +IN_PROC_BROWSER_TEST_F(LacrosWebAppShelfBrowserTest, BadgeShown) { + if (!IsServiceAvailable()) + GTEST_SKIP(); + + const GURL app_url = https_server().GetURL(kFirstAppUrlHost, + "/web_apps/minimal_ui/basic.html"); + const AppId app_id = + InstallWebAppFromPageAndCloseAppBrowser(browser(), app_url); + + AppReadinessWaiter(profile(), app_id).Await(); + Browser* app_browser = LaunchWebAppBrowser(profile(), app_id); + content::WebContents* const web_contents = + app_browser->tab_strip_model()->GetActiveWebContents(); + EXPECT_TRUE(AppBrowserController::IsForWebApp(app_browser, app_id)); + browser_test_util::WaitForShelfItemState( + app_id, static_cast<uint32_t>(ShelfItemState::kActive)); + + ASSERT_TRUE(content::ExecuteScript(web_contents, "navigator.setAppBadge();")); + browser_test_util::WaitForShelfItemState( + app_id, static_cast<uint32_t>(ShelfItemState::kActive) | + static_cast<uint32_t>(ShelfItemState::kNotification)); + + ASSERT_TRUE( + content::ExecuteScript(web_contents, "navigator.clearAppBadge();")); + browser_test_util::WaitForShelfItemState( + app_id, static_cast<uint32_t>(ShelfItemState::kActive)); + + test::UninstallWebApp(profile(), app_id); + browser_test_util::WaitForShelfItemState( + app_id, static_cast<uint32_t>(ShelfItemState::kNormal)); +} + +IN_PROC_BROWSER_TEST_F(LacrosWebAppShelfBrowserTest, RunningInTab) { + if (!IsServiceAvailable()) + GTEST_SKIP(); + + crosapi::mojom::TestController* const test_controller = + chromeos::LacrosService::Get() + ->GetRemote<crosapi::mojom::TestController>() + .get(); + crosapi::mojom::TestControllerAsyncWaiter waiter(test_controller); + const GURL app1_url = https_server().GetURL( + kFirstAppUrlHost, "/web_apps/standalone/basic.html"); + const AppId app1_id = + InstallWebAppFromPageAndCloseAppBrowser(browser(), app1_url); + + const GURL app2_url = + https_server().GetURL(kSecondAppUrlHost, "/web_apps/basic.html"); + const AppId app2_id = + InstallWebAppFromPageAndCloseAppBrowser(browser(), app2_url); + + { + auto& sync_bridge = WebAppProvider::GetForTest(profile())->sync_bridge(); + + Browser* app_browser1 = LaunchWebAppBrowser(profile(), app1_id); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kActive)); + waiter.PinOrUnpinItemInShelf(app1_id, /*pin=*/true); + CloseAndWait(app_browser1); + sync_bridge.SetAppUserDisplayMode(app1_id, UserDisplayMode::kBrowser, + /*is_user_action=*/true); + AppWindowModeWaiter(profile(), app1_id, apps::WindowMode::kBrowser).Await(); + + Browser* app_browser2 = LaunchWebAppBrowser(profile(), app2_id); + browser_test_util::WaitForShelfItemState( + app2_id, static_cast<uint32_t>(ShelfItemState::kActive)); + waiter.PinOrUnpinItemInShelf(app2_id, /*pin=*/true); + CloseAndWait(app_browser2); + sync_bridge.SetAppUserDisplayMode(app2_id, UserDisplayMode::kBrowser, + /*is_user_action=*/true); + AppWindowModeWaiter(profile(), app2_id, apps::WindowMode::kBrowser).Await(); + } + + browser_test_util::WaitForShelfItemState( + app_constants::kLacrosAppId, + static_cast<uint32_t>(ShelfItemState::kActive)); + + test_controller->LaunchAppFromAppList(app1_id); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kActive)); + browser_test_util::WaitForShelfItemState( + app_constants::kLacrosAppId, + static_cast<uint32_t>(ShelfItemState::kRunning)); + + test_controller->LaunchAppFromAppList(app2_id); + browser_test_util::WaitForShelfItemState( + app2_id, static_cast<uint32_t>(ShelfItemState::kActive)); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kRunning)); + + EXPECT_EQ(BrowserList::GetInstance()->size(), 1U); + TabStripModel* tab_strip_model = browser()->tab_strip_model(); + tab_strip_model->CloseWebContentsAt(tab_strip_model->active_index(), + TabCloseTypes::CLOSE_NONE); + browser_test_util::WaitForShelfItemState( + app2_id, static_cast<uint32_t>(ShelfItemState::kNormal)); + browser_test_util::WaitForShelfItemState( + app1_id, static_cast<uint32_t>(ShelfItemState::kActive)); + browser_test_util::WaitForShelfItemState( + app_constants::kLacrosAppId, + static_cast<uint32_t>(ShelfItemState::kRunning)); + + test::UninstallWebApp(profile(), app1_id); + test::UninstallWebApp(profile(), app2_id); +} + +} // namespace web_app
diff --git a/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.cc b/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.cc index ec2e37f9d..4389ce07 100644 --- a/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.cc +++ b/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.cc
@@ -203,11 +203,6 @@ return network_state_informer_->state() == NetworkStateInformer::ONLINE; } -void AppLaunchSplashScreenHandler::OnNetworkReady() { - // Purposely leave blank because the online case is handled in UpdateState - // call below. -} - void AppLaunchSplashScreenHandler::UpdateState( NetworkError::ErrorReason reason) { if (!delegate_)
diff --git a/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.h b/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.h index e95cd8d..a161475 100644 --- a/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.h +++ b/chrome/browser/ui/webui/ash/login/app_launch_splash_screen_handler.h
@@ -123,7 +123,6 @@ void ContinueAppLaunch() override; // NetworkStateInformer::NetworkStateInformerObserver implementation: - void OnNetworkReady() override; void UpdateState(NetworkError::ErrorReason reason) override; private:
diff --git a/chrome/browser/ui/webui/ash/login/core_oobe_handler.cc b/chrome/browser/ui/webui/ash/login/core_oobe_handler.cc index 713cce8..bb22618f 100644 --- a/chrome/browser/ui/webui/ash/login/core_oobe_handler.cc +++ b/chrome/browser/ui/webui/ash/login/core_oobe_handler.cc
@@ -84,7 +84,8 @@ ToggleSystemInfo(); } - if (system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation()) + if (ash::system::InputDeviceSettings::Get() + ->ForceKeyboardDrivenUINavigation()) CallJS("cr.ui.Oobe.enableKeyboardFlow", true); }
diff --git a/chrome/browser/ui/webui/ash/login/kiosk_autolaunch_screen_handler.cc b/chrome/browser/ui/webui/ash/login/kiosk_autolaunch_screen_handler.cc index e73712f2..f621b56 100644 --- a/chrome/browser/ui/webui/ash/login/kiosk_autolaunch_screen_handler.cc +++ b/chrome/browser/ui/webui/ash/login/kiosk_autolaunch_screen_handler.cc
@@ -23,6 +23,9 @@ namespace ash { +// TODO(https://crbug.com/1164001): remove after the migration to namespace ash +using ::ash::KioskAppManager; + KioskAutolaunchScreenHandler::KioskAutolaunchScreenHandler() : BaseScreenHandler(kScreenId) { KioskAppManager::Get()->AddObserver(this);
diff --git a/chrome/browser/ui/webui/ash/login/oobe_ui.cc b/chrome/browser/ui/webui/ash/login/oobe_ui.cc index f804dee..f71bf48 100644 --- a/chrome/browser/ui/webui/ash/login/oobe_ui.cc +++ b/chrome/browser/ui/webui/ash/login/oobe_ui.cc
@@ -661,8 +661,8 @@ localized_strings.Set("buildType", "chromium"); #endif - bool keyboard_driven_oobe = - system::InputDeviceSettings::Get()->ForceKeyboardDrivenUINavigation(); + bool keyboard_driven_oobe = ash::system::InputDeviceSettings::Get() + ->ForceKeyboardDrivenUINavigation(); localized_strings.Set("highlightStrength", keyboard_driven_oobe ? "strong" : "normal");
diff --git a/chrome/browser/ui/webui/ash/login/welcome_screen_handler.cc b/chrome/browser/ui/webui/ash/login/welcome_screen_handler.cc index 65efa8e..0e219a4 100644 --- a/chrome/browser/ui/webui/ash/login/welcome_screen_handler.cc +++ b/chrome/browser/ui/webui/ash/login/welcome_screen_handler.cc
@@ -285,7 +285,7 @@ CrosSettings::Get()->GetString(kSystemTimezone, ¤t_timezone_id); base::Value::List timezone_list; - base::Value::List timezones = system::GetTimezoneList(); + base::Value::List timezones = ash::system::GetTimezoneList(); for (const auto& value : timezones) { CHECK(value.is_list()); const base::Value::List& timezone = value.GetList();
diff --git a/chrome/browser/ui/webui/flags/flags_ui.cc b/chrome/browser/ui/webui/flags/flags_ui.cc index 0ebf855d..0f62b60 100644 --- a/chrome/browser/ui/webui/flags/flags_ui.cc +++ b/chrome/browser/ui/webui/flags/flags_ui.cc
@@ -117,9 +117,9 @@ if (current_user_is_owner) { ash::OwnerSettingsServiceAsh* service = ash::OwnerSettingsServiceAshFactory::GetForBrowserContext(profile); - dom_handler->Init(new chromeos::about_flags::OwnerFlagsStorage( - profile->GetPrefs(), service), - flags_ui::kOwnerAccessToFlags); + dom_handler->Init( + new ash::about_flags::OwnerFlagsStorage(profile->GetPrefs(), service), + flags_ui::kOwnerAccessToFlags); } else { dom_handler->Init( new flags_ui::PrefServiceFlagsStorage(profile->GetPrefs()),
diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chrome/browser/ui/webui/help/version_updater_chromeos.cc index 9132d24b..414f8e37 100644 --- a/chrome/browser/ui/webui/help/version_updater_chromeos.cc +++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -34,9 +34,9 @@ namespace { +using ::ash::OwnerSettingsServiceAsh; +using ::ash::OwnerSettingsServiceAshFactory; using ::ash::UpdateEngineClient; -using ::chromeos::OwnerSettingsServiceAsh; -using ::chromeos::OwnerSettingsServiceAshFactory; // Network status in the context of device update. enum NetworkStatus {
diff --git a/chrome/browser/ui/webui/management/management_ui_handler.cc b/chrome/browser/ui/webui/management/management_ui_handler.cc index 8077b67..24e754d3 100644 --- a/chrome/browser/ui/webui/management/management_ui_handler.cc +++ b/chrome/browser/ui/webui/management/management_ui_handler.cc
@@ -314,11 +314,11 @@ // Elements appear on the page in the order they are added. bool report_device_peripherals = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePeripherals, - &report_device_peripherals); + ash::CrosSettings::Get()->GetBoolean(ash::kReportDevicePeripherals, + &report_device_peripherals); bool report_audio_status = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceAudioStatus, - &report_audio_status); + ash::CrosSettings::Get()->GetBoolean(ash::kReportDeviceAudioStatus, + &report_audio_status); if (collector->IsReportingActivityTimes() || report_device_peripherals || report_audio_status || profile->GetPrefs()->GetBoolean(::prefs::kInsightsExtensionEnabled)) { @@ -360,8 +360,8 @@ } bool report_graphics_status = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceGraphicsStatus, - &report_graphics_status); + ash::CrosSettings::Get()->GetBoolean(ash::kReportDeviceGraphicsStatus, + &report_graphics_status); if (report_graphics_status) { AddDeviceReportingElement(report_sources, kManagementReportDeviceGraphicsStatus, @@ -375,8 +375,8 @@ } bool report_print_jobs = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDevicePrintJobs, - &report_print_jobs); + ash::CrosSettings::Get()->GetBoolean(ash::kReportDevicePrintJobs, + &report_print_jobs); if (report_print_jobs) { AddDeviceReportingElement(report_sources, kManagementReportPrintJobs, DeviceReportingType::kPrintJobs); @@ -421,16 +421,16 @@ } bool report_login_logout = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportDeviceLoginLogout, - &report_login_logout); + ash::CrosSettings::Get()->GetBoolean(ash::kReportDeviceLoginLogout, + &report_login_logout); if (report_login_logout) { AddDeviceReportingElement(report_sources, kManagementReportLoginLogout, DeviceReportingType::kLoginLogout); } bool report_crd_sessions = false; - chromeos::CrosSettings::Get()->GetBoolean(ash::kReportCRDSessions, - &report_crd_sessions); + ash::CrosSettings::Get()->GetBoolean(ash::kReportCRDSessions, + &report_crd_sessions); if (report_crd_sessions) { AddDeviceReportingElement(report_sources, kManagementReportCRDSessions, DeviceReportingType::kCRDSessions);
diff --git a/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc b/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc index f7294f7..2aec5e4 100644 --- a/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc +++ b/chrome/browser/ui/webui/management/management_ui_handler_unittest.cc
@@ -249,7 +249,7 @@ // TODO(1071436, marcgrimme): refactor so that ChromeOS and non ChromeOS part is // better separated. #if BUILDFLAG(IS_CHROMEOS_ASH) -using TestingBaseClass = chromeos::DeviceSettingsTestBase; +using TestingBaseClass = ash::DeviceSettingsTestBase; #else using TestingBaseClass = testing::Test; #endif
diff --git a/chrome/browser/ui/webui/settings/hats_handler.cc b/chrome/browser/ui/webui/settings/hats_handler.cc index f2937bd..bcb53b4a 100644 --- a/chrome/browser/ui/webui/settings/hats_handler.cc +++ b/chrome/browser/ui/webui/settings/hats_handler.cc
@@ -141,6 +141,8 @@ sentiment_service->OpenedPasswordManager(web_ui()->GetWebContents()); } else if (interaction == TrustSafetyInteraction::RAN_PASSWORD_CHECK) { sentiment_service->RanPasswordCheck(); + } else if (interaction == TrustSafetyInteraction::COMPLETED_PRIVACY_GUIDE) { + sentiment_service->FinishedPrivacyGuide(); } }
diff --git a/chrome/browser/ui/webui/web_ui_test_handler.cc b/chrome/browser/ui/webui/web_ui_test_handler.cc index 31e60ab6..c2110ae0 100644 --- a/chrome/browser/ui/webui/web_ui_test_handler.cc +++ b/chrome/browser/ui/webui/web_ui_test_handler.cc
@@ -95,7 +95,7 @@ { base::RunLoop run_loop; quit_closure_ = run_loop.QuitWhenIdleClosure(); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); } // Run a second message loop when not |run_test_done_| so that the sync test @@ -104,7 +104,7 @@ if (!run_test_done_ || (run_test_succeeded_ && !test_done_)) { base::RunLoop run_loop; quit_closure_ = run_loop.QuitWhenIdleClosure(); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); } // To succeed the test must execute as well as pass the test.
diff --git a/chrome/build/mac-arm.pgo.txt b/chrome/build/mac-arm.pgo.txt index 88e2220..f6a7b8d 100644 --- a/chrome/build/mac-arm.pgo.txt +++ b/chrome/build/mac-arm.pgo.txt
@@ -1 +1 @@ -chrome-mac-arm-main-1669334294-9e4ff31fb76575d2963428f586cb474b017a38a9.profdata +chrome-mac-arm-main-1669355823-26cbc4c79e17d967740b72eb9bb3e517653b7218.profdata
diff --git a/chrome/build/mac.pgo.txt b/chrome/build/mac.pgo.txt index 2d879d41..4ea39df 100644 --- a/chrome/build/mac.pgo.txt +++ b/chrome/build/mac.pgo.txt
@@ -1 +1 @@ -chrome-mac-main-1669334294-49e8c5f14b35ec0d22086c87d69eec2a6f4f0ca1.profdata +chrome-mac-main-1669355823-0b1c264208fb6410e0cd864b87ab165f40caa3e6.profdata
diff --git a/chrome/build/win32.pgo.txt b/chrome/build/win32.pgo.txt index 74416bc..95f2dbc 100644 --- a/chrome/build/win32.pgo.txt +++ b/chrome/build/win32.pgo.txt
@@ -1 +1 @@ -chrome-win32-main-1669334294-6c050235252f039dc44fe3c188e54e52d9cda943.profdata +chrome-win32-main-1669355823-4957e771a0c3fc325879b3e54e62c46a96eb4759.profdata
diff --git a/chrome/build/win64.pgo.txt b/chrome/build/win64.pgo.txt index d38b143..03cf611 100644 --- a/chrome/build/win64.pgo.txt +++ b/chrome/build/win64.pgo.txt
@@ -1 +1 @@ -chrome-win64-main-1669323590-eab5a01eee383ea057500fb46d667b8376579a9e.profdata +chrome-win64-main-1669366456-206fe2ddc4f4514caf4ce6a456abd16bc8646fc0.profdata
diff --git a/chrome/common/chrome_features.cc b/chrome/common/chrome_features.cc index d94b606d..c05631e 100644 --- a/chrome/common/chrome_features.cc +++ b/chrome/common/chrome_features.cc
@@ -1251,6 +1251,9 @@ const base::FeatureParam<double> kTrustSafetySentimentSurveyV2TrustedSurfaceProbability{ &kTrustSafetySentimentSurveyV2, "trusted-surface-probability", 0.0}; +const base::FeatureParam<double> + kTrustSafetySentimentSurveyV2PrivacyGuideProbability{ + &kTrustSafetySentimentSurveyV2, "privacy-guide-probability", 0.0}; // The HaTS trigger IDs, which determine which survey is delivered from the HaTS // backend. const base::FeatureParam<std::string> @@ -1265,6 +1268,9 @@ const base::FeatureParam<std::string> kTrustSafetySentimentSurveyV2TrustedSurfaceTriggerId{ &kTrustSafetySentimentSurveyV2, "trusted-surface-trigger-id", ""}; +const base::FeatureParam<std::string> + kTrustSafetySentimentSurveyV2PrivacyGuideTriggerId{ + &kTrustSafetySentimentSurveyV2, "privacy-guide-trigger-id", ""}; // The time the user must have the Trusted Surface bubble open to be considered. // Alternatively the user can interact with the bubble, in which case this time // is irrelevant.
diff --git a/chrome/common/chrome_features.h b/chrome/common/chrome_features.h index ee6579e..fabf015f 100644 --- a/chrome/common/chrome_features.h +++ b/chrome/common/chrome_features.h
@@ -717,6 +717,9 @@ extern const base::FeatureParam<double> kTrustSafetySentimentSurveyV2TrustedSurfaceProbability; COMPONENT_EXPORT(CHROME_FEATURES) +extern const base::FeatureParam<double> + kTrustSafetySentimentSurveyV2PrivacyGuideProbability; +COMPONENT_EXPORT(CHROME_FEATURES) extern const base::FeatureParam<std::string> kTrustSafetySentimentSurveyV2BrowsingDataTriggerId; COMPONENT_EXPORT(CHROME_FEATURES) @@ -729,6 +732,9 @@ extern const base::FeatureParam<std::string> kTrustSafetySentimentSurveyV2TrustedSurfaceTriggerId; COMPONENT_EXPORT(CHROME_FEATURES) +extern const base::FeatureParam<std::string> + kTrustSafetySentimentSurveyV2PrivacyGuideTriggerId; +COMPONENT_EXPORT(CHROME_FEATURES) extern const base::FeatureParam<base::TimeDelta> kTrustSafetySentimentSurveyV2TrustedSurfaceTime;
diff --git a/chrome/common/extensions/api/file_browser_handlers/file_browser_handler.cc b/chrome/common/extensions/api/file_browser_handlers/file_browser_handler.cc index 23c63b3..3d8a6ea 100644 --- a/chrome/common/extensions/api/file_browser_handlers/file_browser_handler.cc +++ b/chrome/common/extensions/api/file_browser_handlers/file_browser_handler.cc
@@ -150,13 +150,13 @@ std::unique_ptr<FileBrowserHandler> LoadFileBrowserHandler( const std::string& extension_id, - const base::DictionaryValue* file_browser_handler, + const base::Value::Dict* file_browser_handler, std::u16string* error) { std::unique_ptr<FileBrowserHandler> result(new FileBrowserHandler()); result->set_extension_id(extension_id); const std::string* handler_id = - file_browser_handler->FindStringKey(keys::kFileBrowserHandlerId); + file_browser_handler->FindString(keys::kFileBrowserHandlerId); // Read the file action |id| (mandatory). if (!handler_id) { *error = errors::kInvalidFileBrowserHandlerId; @@ -166,7 +166,7 @@ // Read the page action title from |default_title| (mandatory). const std::string* title = - file_browser_handler->FindStringKey(keys::kActionDefaultTitle); + file_browser_handler->FindString(keys::kActionDefaultTitle); if (!title) { *error = errors::kInvalidActionDefaultTitle; return nullptr; @@ -175,7 +175,7 @@ // Initialize access permissions (optional). const base::Value* access_list_value = - file_browser_handler->FindKey(keys::kFileAccessList); + file_browser_handler->Find(keys::kFileAccessList); if (access_list_value) { if (!access_list_value->is_list() || access_list_value->GetList().empty()) { *error = errors::kInvalidFileAccessList; @@ -199,15 +199,14 @@ // Initialize file filters (mandatory, unless "create" access is specified, // in which case is ignored). The list can be empty. if (!result->HasCreateAccessPermission()) { - const base::Value* file_filters = - file_browser_handler->FindListKey(keys::kFileFilters); - if (!file_filters) { + const base::Value::List* file_filters_list = + file_browser_handler->FindList(keys::kFileFilters); + if (!file_filters_list) { *error = errors::kInvalidFileFiltersList; return nullptr; } - const base::Value::List& file_filters_list = file_filters->GetList(); - for (size_t i = 0; i < file_filters_list.size(); ++i) { - const std::string* filter_in = file_filters_list[i].GetIfString(); + for (size_t i = 0; i < file_filters_list->size(); ++i) { + const std::string* filter_in = (*file_filters_list)[i].GetIfString(); if (!filter_in) { *error = extensions::ErrorUtils::FormatErrorMessageUTF16( errors::kInvalidFileFilterValue, base::NumberToString(i)); @@ -244,7 +243,7 @@ // Read the file browser action |default_icon| (optional). if (const base::Value* default_icon_val = - file_browser_handler->FindKey(keys::kActionDefaultIcon)) { + file_browser_handler->Find(keys::kActionDefaultIcon)) { const std::string* default_icon = default_icon_val->GetIfString(); if (!default_icon || default_icon->empty()) { *error = errors::kInvalidActionDefaultIcon; @@ -262,8 +261,8 @@ FileBrowserHandler::List* result, std::u16string* error) { for (const auto& entry : extension_actions) { - const base::DictionaryValue* dict; - if (!entry.GetAsDictionary(&dict)) { + const base::Value::Dict* dict = entry.GetIfDict(); + if (!dict) { *error = errors::kInvalidFileBrowserHandler16; return false; }
diff --git a/chrome/common/extensions/api/url_handlers/url_handlers_parser.cc b/chrome/common/extensions/api/url_handlers/url_handlers_parser.cc index 28a3143..8c6e638 100644 --- a/chrome/common/extensions/api/url_handlers/url_handlers_parser.cc +++ b/chrome/common/extensions/api/url_handlers/url_handlers_parser.cc
@@ -108,7 +108,7 @@ } bool ParseUrlHandler(const std::string& handler_id, - const base::DictionaryValue& handler_info, + const base::Value::Dict& handler_info, std::vector<UrlHandlerInfo>* url_handlers, std::u16string* error, Extension* extension) { @@ -118,22 +118,22 @@ handler.id = handler_id; if (const std::string* ptr = - handler_info.FindStringKey(mkeys::kUrlHandlerTitle)) { + handler_info.FindString(mkeys::kUrlHandlerTitle)) { handler.title = *ptr; } else { *error = merrors::kInvalidURLHandlerTitle; return false; } - const base::ListValue* manif_patterns = nullptr; - if (!handler_info.GetList(mkeys::kMatches, &manif_patterns) || - manif_patterns->GetList().size() == 0) { + const base::Value::List* manif_patterns = + handler_info.FindList(mkeys::kMatches); + if (!manif_patterns || manif_patterns->size() == 0) { *error = ErrorUtils::FormatErrorMessageUTF16( merrors::kInvalidURLHandlerPattern, handler_id); return false; } - for (const auto& entry : manif_patterns->GetList()) { + for (const auto& entry : *manif_patterns) { std::string str_pattern = entry.is_string() ? entry.GetString() : std::string(); // TODO(sergeygs): Limit this to non-top-level domains. @@ -166,8 +166,8 @@ for (const auto item : all_handlers->GetDict()) { // A URL handler entry is a title and a list of URL patterns to handle. - const base::DictionaryValue* handler = nullptr; - if (!item.second.GetAsDictionary(&handler)) { + const base::Value::Dict* handler = item.second.GetIfDict(); + if (!handler) { *error = merrors::kInvalidURLHandlerPatternElement16; return false; }
diff --git a/chrome/common/extensions/extension_test_util.cc b/chrome/common/extensions/extension_test_util.cc index dcea76a..0f56d53 100644 --- a/chrome/common/extensions/extension_test_util.cc +++ b/chrome/common/extensions/extension_test_util.cc
@@ -42,8 +42,8 @@ deserializer.Deserialize(nullptr, error); if (!result) return nullptr; - const base::DictionaryValue* dict; - CHECK(result->GetAsDictionary(&dict)); + const base::Value::Dict* dict = result->GetIfDict(); + CHECK(dict); scoped_refptr<Extension> extension = Extension::Create( path.DirName(), location, *dict, extra_flags, id, error);
diff --git a/chrome/renderer/BUILD.gn b/chrome/renderer/BUILD.gn index 893347b5..c38896d 100644 --- a/chrome/renderer/BUILD.gn +++ b/chrome/renderer/BUILD.gn
@@ -132,7 +132,6 @@ "//chrome/services/speech/buildflags", "//components/autofill/content/renderer", "//components/autofill/core/common:features", - "//components/autofill_assistant/content/renderer", "//components/base32", "//components/cdm/renderer", "//components/commerce/core:commerce_heuristics_data",
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 3d4c1e27..abbcd33 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -71,7 +71,6 @@ #include "components/autofill/content/renderer/password_autofill_agent.h" #include "components/autofill/content/renderer/password_generation_agent.h" #include "components/autofill/core/common/autofill_features.h" -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent.h" #include "components/commerce/core/commerce_feature_list.h" #include "components/content_capture/common/content_capture_features.h" #include "components/content_capture/renderer/content_capture_sender.h" @@ -682,11 +681,6 @@ associated_interfaces); } -#if BUILDFLAG(IS_ANDROID) - new autofill_assistant::AutofillAssistantAgent(render_frame, - associated_interfaces); -#endif - if (content_capture::features::IsContentCaptureEnabled()) { new content_capture::ContentCaptureSender(render_frame, associated_interfaces);
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index 344c2e2..66cb037 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -3201,7 +3201,6 @@ deps += [ "//chrome/browser/enterprise/connectors/device_trust/key_management/browser/commands:test_support", "//chrome/browser/enterprise/connectors/device_trust/key_management/core/persistence:test_support", - "//chrome/browser/enterprise/connectors/device_trust/test:test_support", "//chrome/browser/ui/webui/app_home:mojo_bindings", ] } @@ -4620,6 +4619,7 @@ if (is_win || is_mac || is_linux) { sources += [ "../browser/ui/startup/first_run_service_browsertest.cc", + "../browser/ui/views/profiles/profile_picker_dice_sign_in_provider_browsertest.cc", "../browser/ui/views/profiles/profile_picker_view_browsertest.cc", "../browser/ui/views/web_apps/web_app_integration_browsertest_mac_win_linux.cc", ] @@ -7331,6 +7331,7 @@ "../browser/apps/app_service/webapk/webapk_manager_unittest.cc", "../browser/ash/attestation/attestation_policy_unittest.cc", "../browser/ash/dbus/chrome_features_service_provider_unittest.cc", + "../browser/ash/login/screens/reset_screen_unittest.cc", "../browser/browser_process_platform_part_ash_unittest.cc", "../browser/component_updater/cros_component_installer_chromeos_unittest.cc", "../browser/component_updater/metadata_table_chromeos_unittest.cc", @@ -8545,6 +8546,10 @@ ] } + if (is_win) { + deps += [ "../browser/enterprise/connectors/device_trust/signals/decorators/browser/win:unit_tests" ] + } + if (is_linux || is_chromeos_ash || is_mac || is_win) { sources += [ "../browser/enterprise/connectors/device_trust/device_trust_connector_service_factory_unittest.cc",
diff --git a/chrome/test/data/webui/settings/privacy_guide_page_test.ts b/chrome/test/data/webui/settings/privacy_guide_page_test.ts index 8de8fc9..0ee3ca0 100644 --- a/chrome/test/data/webui/settings/privacy_guide_page_test.ts +++ b/chrome/test/data/webui/settings/privacy_guide_page_test.ts
@@ -7,7 +7,7 @@ import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {CookiePrimarySetting, PrivacyGuideCompletionFragmentElement, PrivacyGuideHistorySyncFragmentElement, PrivacyGuideStep, PrivacyGuideWelcomeFragmentElement, SafeBrowsingSetting, SettingsPrivacyGuideDialogElement, SettingsPrivacyGuidePageElement, SettingsRadioGroupElement} from 'chrome://settings/lazy_load.js'; -import {CrSettingsPrefs, MetricsBrowserProxyImpl, PrivacyGuideInteractions, PrivacyGuideSettingsStates, Router, routes, SettingsPrefsElement, StatusAction, SyncBrowserProxyImpl, SyncPrefs, syncPrefsIndividualDataTypes, SyncStatus} from 'chrome://settings/settings.js'; +import {HatsBrowserProxyImpl, TrustSafetyInteraction, CrSettingsPrefs, MetricsBrowserProxyImpl, PrivacyGuideInteractions, PrivacyGuideSettingsStates, Router, routes, SettingsPrefsElement, StatusAction, SyncBrowserProxyImpl, SyncPrefs, syncPrefsIndividualDataTypes, SyncStatus} from 'chrome://settings/settings.js'; import {assertEquals, assertFalse, assertTrue} from 'chrome://webui-test/chai_assert.js'; import {eventToPromise, isChildVisible} from 'chrome://webui-test/test_util.js'; import {flushTasks} from 'chrome://webui-test/polymer_test_util.js'; @@ -15,6 +15,7 @@ import {getSyncAllPrefs} from './sync_test_util.js'; import {TestMetricsBrowserProxy} from './test_metrics_browser_proxy.js'; import {TestSyncBrowserProxy} from './test_sync_browser_proxy.js'; +import {TestHatsBrowserProxy} from './test_hats_browser_proxy.js'; // clang-format on @@ -830,6 +831,7 @@ let settingsPrefs: SettingsPrefsElement; let syncBrowserProxy: TestSyncBrowserProxy; let testMetricsBrowserProxy: TestMetricsBrowserProxy; + let testHatsBrowserProxy: TestHatsBrowserProxy; suiteSetup(function() { settingsPrefs = document.createElement('settings-prefs'); @@ -846,6 +848,9 @@ page = createPrivacyGuidePageForTest(settingsPrefs); setupPrivacyGuidePageForTest(page, syncBrowserProxy); + testHatsBrowserProxy = new TestHatsBrowserProxy(); + HatsBrowserProxyImpl.setInstance(testHatsBrowserProxy); + return flushTasks(); }); @@ -920,6 +925,17 @@ await flushTasks(); assertCompletionCardVisible(page); }); + + test('hatsInformedOnFinish', async function() { + await navigateToStep(PrivacyGuideStep.COOKIES); + + page.shadowRoot!.querySelector<HTMLElement>('#nextButton')!.click(); + + // HaTS gets triggered if the user navigates to the completion page. + const interaction = + await testHatsBrowserProxy.whenCalled('trustSafetyInteractionOccurred'); + assertEquals(TrustSafetyInteraction.COMPLETED_PRIVACY_GUIDE, interaction); + }); }); suite('MsbbFragmentMetricsTests', function() {
diff --git a/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.cc b/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.cc index ed7d1f1..8ea30787 100644 --- a/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.cc +++ b/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.cc
@@ -785,6 +785,15 @@ callback_delay_); } +void FakeCrosHealthd::RunLedLitUpRoutine( + mojom::LedName name, + mojom::LedColor color, + mojo::PendingRemote<mojom::LedLitUpRoutineReplier> replier, + RunLedLitUpRoutineCallback callback) { + last_run_routine_ = mojom::DiagnosticRoutineEnum::kLedLitUp; + std::move(callback).Run(run_routine_response_.Clone()); +} + void FakeCrosHealthd::AddBluetoothObserver( mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> observer) { bluetooth_observers_.Add(std::move(observer));
diff --git a/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.h b/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.h index b74c371c7..32d0e43 100644 --- a/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.h +++ b/chromeos/ash/services/cros_healthd/public/cpp/fake_cros_healthd.h
@@ -327,6 +327,11 @@ void RunPrivacyScreenRoutine( bool target_state, RunPrivacyScreenRoutineCallback callback) override; + void RunLedLitUpRoutine( + mojom::LedName name, + mojom::LedColor color, + mojo::PendingRemote<mojom::LedLitUpRoutineReplier> replier, + RunLedLitUpRoutineCallback callback) override; // CrosHealthdEventService overrides: void AddBluetoothObserver(
diff --git a/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom b/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom index c496815..0fe38b5 100644 --- a/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom +++ b/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd.mojom
@@ -54,7 +54,7 @@ // Diagnostics interface exposed by the cros_healthd daemon. // -// NextMinVersion: 5, NextIndex: 37 +// NextMinVersion: 6, NextIndex: 38 [Stable] interface CrosHealthdDiagnosticsService { // Returns an array of all diagnostic routines that the platform supports. @@ -561,6 +561,44 @@ // * |target_state| - privacy screen target state. [MinVersion=4] RunPrivacyScreenRoutine@36(bool target_state) => (RunRoutineResponse response); + + // Requests that the LedLitUp routine is created and started on the + // platform. This routine lights up the target LED in the specified color and + // requests the caller to verify the change. + // The availability of this routine can be determined by checking that + // kLedLitUp is returned by GetAvailableRoutines. + // + // The routine proceeds with the following steps: + // 1. Set the specified LED with the specified color. If the LED name or color + // is not supported by EC, the routine fails at this step. + // 2. Invoke the |GetColorMatched| method of |replier|. The method should + // return |true| if the actual color matches the specified color and + // |false|, otherwise. Notice that there is no timeout so it will wait + // indefinitely. + // 3. After receiving the response from |replier|, the color of the LED will + // be reset (back the auto control). If the replier disconnects before + // the response is received, the LED will also be reset. + // 4. The status of the routine is updated. The routine passes when the + // response is |true|. If the response is |false| or the disconnection + // occurs, the routine fails. + // + // Requirement: + // * The LED name and color provided by the client must be valid. In other + // words, the specified LED must be installed and the specified color must + // be supported. + // + // The request: + // * |name| - specifies the LED to be lit up. + // * |color| - specifies the color to be lit up. + // * |replier| - a replier that can answer whether the actual LED color + // matches the expected color. + // + // The response: + // * |response| - contains a unique identifier and status for the created + // routine. + [MinVersion=5] RunLedLitUpRoutine@37(LedName name, LedColor color, + pending_remote<LedLitUpRoutineReplier> replier) + => (RunRoutineResponse response); }; // Event interface exposed by the cros_healthd daemon.
diff --git a/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom b/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom index 7171a944..6f0b9b46 100644 --- a/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom +++ b/chromeos/ash/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom
@@ -15,7 +15,7 @@ // Enumeration of each of the diagnostics routines the platform may support. // -// NextMinVersion: 4, NextIndex: 35 +// NextMinVersion: 5, NextIndex: 36 [Stable, Extensible] enum DiagnosticRoutineEnum { [Default] kUnknown = 30, @@ -52,7 +52,8 @@ [MinVersion=1] kSensitiveSensor = 31, [MinVersion=2] kFingerprint = 32, [MinVersion=2] kFingerprintAlive = 33, - [MinVersion=3] kPrivacyScreen = 34 + [MinVersion=3] kPrivacyScreen = 34, + [MinVersion=4] kLedLitUp = 35, }; // Enumeration of the possible DiskRead routine's command type @@ -91,12 +92,13 @@ // Enumeration of each of the messages a diagnostics routine can pass back. // These messages prompt interaction from the user of the routine. // -// NextMinVersion: 1, NextIndex: 3 +// NextMinVersion: 2, NextIndex: 4 [Stable, Extensible] enum DiagnosticRoutineUserMessageEnum { [Default] kUnknown = 2, kUnplugACPower = 0, // The user needs to unplug the AC power cord. kPlugInACPower = 1, // The user needs to plug in the AC power cord. + [MinVersion=1] kCheckLedColor = 3, // The user needs to check the LED color. }; // Enumeration of the possible commands to send a diagnostics routine. @@ -195,3 +197,47 @@ kShortSelfTest = 0, // Short time self-test. kLongSelfTest = 1, // Long time self-test. }; + +// Enumeration of each possible LEDs on a device. This enum type is a mirror of +// the enums defined in EC. To find out the actual names of each installed LEDs, +// please refer to the EC firmware. +// +// NextMinVersion: 1, NextIndex: 6 +[Stable, Extensible] +enum LedName { + // The default value is for backward compatibility, should not be used. + [Default] kUnmappedEnumField = 0, + kBattery = 1, + kPower = 2, + kAdapter = 3, + kLeft = 4, + kRight = 5, +}; + +// Enumeration of each possible supported LED colors. +// +// NextMinVersion: 1, NextIndex: 7 +[Stable, Extensible] +enum LedColor { + // The default value is for backward compatibility, should not be used. + [Default] kUnmappedEnumField = 0, + kRed = 1, + kGreen = 2, + kBlue = 3, + kYellow = 4, + kWhite = 5, + kAmber = 6, +}; + +// Replier interface for LED lit up routine. +// +// NextMinVersion: 1, NextIndex: 1 +[Stable] +interface LedLitUpRoutineReplier { + // Returns whether the actual LED color matches the expected color. + // + // The response: + // * |matched| - true if the actual LED color matches the expected color. + // Otherwise, false. + GetColorMatched@0() => (bool matched); +};
diff --git a/chromeos/crosapi/mojom/test_controller.mojom b/chromeos/crosapi/mojom/test_controller.mojom index 8bd5ec16..c66b23d 100644 --- a/chromeos/crosapi/mojom/test_controller.mojom +++ b/chromeos/crosapi/mojom/test_controller.mojom
@@ -10,6 +10,20 @@ import "mojo/public/mojom/base/values.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; +// The enum of possible states for a shelf item. +// Each value must be a power of 2. +[Stable, Extensible] +enum ShelfItemState { + // Usually represents an app with no running instance. + [Default] kNormal = 0, + // Shelf item has a running instance. + kRunning = 1, + // Shelf item owns the window that is currently active. + kActive = 2, + // App has at least 1 notification. + kNotification = 4 +}; + [Stable, Extensible] enum TouchEventType { kUnknown = 0, @@ -148,8 +162,8 @@ // This interface is implemented by Ash-Chrome. // This interface provides tests a mechanism to mutate or query ash. // In the future, this interface may merge with an automation or a11y interface. -// Next version: 21 -// Next method id: 32 +// Next version: 22 +// Next method id: 33 [Stable, Uuid="1f93f9d7-e466-466c-a675-c21b48cf30d3"] interface TestController { // Clicks the middle of the views element identified by |element_name|. @@ -324,4 +338,8 @@ // Clear App Service state, including from any previously installed apps. [MinVersion=20] ReinitializeAppService@31() => (); + + // Reads state of Shelf item. Returns a bitmask of `ShelfItemState` values. + [MinVersion=21] + GetShelfItemState@32(string app_id) => (uint32 state); };
diff --git a/components/BUILD.gn b/components/BUILD.gn index 4eb6ee4..7731d350 100644 --- a/components/BUILD.gn +++ b/components/BUILD.gn
@@ -334,8 +334,6 @@ "//components/autofill/core/common/mojom:unit_tests", "//components/autofill_assistant/browser:unit_tests", "//components/autofill_assistant/browser/public:unit_tests", - "//components/autofill_assistant/content/browser:unit_tests", - "//components/autofill_assistant/content/renderer:unit_tests", "//components/background_sync:unit_tests", "//components/blocked_content:unit_tests", "//components/browsing_data/content:unit_tests", @@ -917,11 +915,8 @@ "autofill_assistant/browser/service/mock_service.cc", "autofill_assistant/browser/service/mock_service.h", "autofill_assistant/browser/web/batch_element_checker_browsertest.cc", - "autofill_assistant/browser/web/mock_autofill_assistant_agent.cc", - "autofill_assistant/browser/web/mock_autofill_assistant_agent.h", "autofill_assistant/browser/web/mock_web_controller.cc", "autofill_assistant/browser/web/mock_web_controller.h", - "autofill_assistant/browser/web/semantic_element_finder_browsertest.cc", "autofill_assistant/browser/web/web_controller_browsertest.cc", "browser_ui/client_certificate/android/ssl_client_certificate_request_browsertest.cc", "test/android/browsertests_apk/components_browser_tests_jni_onload.cc", @@ -933,9 +928,6 @@ "//components/autofill_assistant/browser/devtools:gen_devtools_client_api", "//components/autofill_assistant/browser/public:password_change", "//components/autofill_assistant/browser/public:public", - "//components/autofill_assistant/content/common", - "//components/autofill_assistant/content/common:mojo_interfaces", - "//components/autofill_assistant/content/renderer:browser_tests", "//components/autofill_assistant/core/public:public", "//components/browser_ui/client_certificate/android", "//components/browser_ui/client_certificate/android:java",
diff --git a/components/autofill/core/browser/metrics/autofill_metrics.cc b/components/autofill/core/browser/metrics/autofill_metrics.cc index 7d0b7e6..17f17d57 100644 --- a/components/autofill/core/browser/metrics/autofill_metrics.cc +++ b/components/autofill/core/browser/metrics/autofill_metrics.cc
@@ -1121,9 +1121,12 @@ // static void AutofillMetrics::LogUnmaskPromptEvent(UnmaskPromptEvent event, - bool has_valid_nickname) { - base::UmaHistogramEnumeration("Autofill.UnmaskPrompt.Events", event, - NUM_UNMASK_PROMPT_EVENTS); + bool has_valid_nickname, + CreditCard::RecordType card_type) { + base::UmaHistogramEnumeration("Autofill.UnmaskPrompt" + + GetHistogramStringForCardType(card_type) + + ".Events", + event, NUM_UNMASK_PROMPT_EVENTS); if (has_valid_nickname) { base::UmaHistogramEnumeration("Autofill.UnmaskPrompt.Events.WithNickname", event, NUM_UNMASK_PROMPT_EVENTS);
diff --git a/components/autofill/core/browser/metrics/autofill_metrics.h b/components/autofill/core/browser/metrics/autofill_metrics.h index a5eb69f..55190bc 100644 --- a/components/autofill/core/browser/metrics/autofill_metrics.h +++ b/components/autofill/core/browser/metrics/autofill_metrics.h
@@ -1237,7 +1237,8 @@ // Logs |event| to the unmask prompt events histogram. static void LogUnmaskPromptEvent(UnmaskPromptEvent event, - bool has_valid_nickname); + bool has_valid_nickname, + CreditCard::RecordType card_type); // Logs |event| to cardholder name fix flow prompt events histogram. static void LogCardholderNameFixFlowPromptEvent(
diff --git a/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc b/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc index d11ad68..561251d 100644 --- a/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc +++ b/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.cc
@@ -72,7 +72,8 @@ unmasking_result_ = AutofillClient::PaymentsRpcResult::kNone; unmasking_number_of_attempts_ = 0; AutofillMetrics::LogUnmaskPromptEvent(AutofillMetrics::UNMASK_PROMPT_SHOWN, - card_.HasNonEmptyValidNickname()); + card_.HasNonEmptyValidNickname(), + card_.record_type()); } void CardUnmaskPromptControllerImpl::OnVerificationResult( @@ -426,7 +427,8 @@ void CardUnmaskPromptControllerImpl::LogOnCloseEvents() { AutofillMetrics::UnmaskPromptEvent close_reason_event = GetCloseReasonEvent(); AutofillMetrics::LogUnmaskPromptEvent(close_reason_event, - card_.HasNonEmptyValidNickname()); + card_.HasNonEmptyValidNickname(), + card_.record_type()); AutofillMetrics::LogUnmaskPromptEventDuration( AutofillClock::Now() - shown_timestamp_, close_reason_event, card_.HasNonEmptyValidNickname());
diff --git a/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc b/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc index 0cade395..c50989cb 100644 --- a/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc +++ b/components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl_unittest.cc
@@ -392,24 +392,39 @@ bool card_has_nickname_; }; -TEST_P(LoggingValidationTestForNickname, LogShown) { +TEST_P(LoggingValidationTestForNickname, + MaskedServerCard_LogUnmaskPromptShown) { base::HistogramTester histogram_tester; ShowPrompt(); - histogram_tester.ExpectUniqueSample("Autofill.UnmaskPrompt.Events", + histogram_tester.ExpectUniqueSample("Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_SHOWN, 1); histogram_tester.ExpectUniqueSample( "Autofill.UnmaskPrompt.Events.WithNickname", AutofillMetrics::UNMASK_PROMPT_SHOWN, card_has_nickname() ? 1 : 0); } +TEST_P(LoggingValidationTestForNickname, VirtualCard_LogUnmaskPromptShown) { + base::HistogramTester histogram_tester; + ShowPrompt(absl::optional<autofill::CardUnmaskChallengeOption>( + test::GetCardUnmaskChallengeOptions( + {CardUnmaskChallengeOptionType::kCvc})[0])); + + histogram_tester.ExpectUniqueSample( + "Autofill.UnmaskPrompt.VirtualCard.Events", + AutofillMetrics::UNMASK_PROMPT_SHOWN, 1); + histogram_tester.ExpectUniqueSample( + "Autofill.UnmaskPrompt.Events.WithNickname", + AutofillMetrics::UNMASK_PROMPT_SHOWN, card_has_nickname() ? 1 : 0); +} + TEST_P(LoggingValidationTestForNickname, LogClosedNoAttempts) { ShowPrompt(); base::HistogramTester histogram_tester; controller_->OnUnmaskDialogClosed(); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_CLOSED_NO_ATTEMPTS, 1); histogram_tester.ExpectBucketCount( "Autofill.UnmaskPrompt.Events.WithNickname", @@ -424,7 +439,7 @@ controller_->OnUnmaskDialogClosed(); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_CLOSED_ABANDON_UNMASKING, 1); histogram_tester.ExpectBucketCount( "Autofill.UnmaskPrompt.Events.WithNickname", @@ -446,7 +461,7 @@ controller_->GetVerificationResult()); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics ::UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_RETRIABLE_FAILURE, 1); histogram_tester.ExpectBucketCount( @@ -469,7 +484,7 @@ controller_->GetVerificationResult()); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics :: UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_NON_RETRIABLE_FAILURE, 1); @@ -495,7 +510,7 @@ controller_->GetVerificationResult()); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_UNMASKED_CARD_FIRST_ATTEMPT, 1); histogram_tester.ExpectBucketCount( "Autofill.UnmaskPrompt.Events.WithNickname", @@ -517,7 +532,7 @@ controller_->OnUnmaskDialogClosed(); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_UNMASKED_CARD_AFTER_FAILED_ATTEMPTS, 1); histogram_tester.ExpectBucketCount( "Autofill.UnmaskPrompt.Events.WithNickname", @@ -531,16 +546,16 @@ controller_->OnUnmaskDialogClosed(); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_IN, 0); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_IN, 0); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_OPT_OUT, 0); histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.ServerCard.Events", AutofillMetrics::UNMASK_PROMPT_LOCAL_SAVE_DID_NOT_OPT_OUT, 0); histogram_tester.ExpectBucketCount( "Autofill.UnmaskPrompt.Events.WithNickname", @@ -861,7 +876,7 @@ controller_->GetVerificationResult()); // Verify that prompt closing metrics are logged. histogram_tester.ExpectBucketCount( - "Autofill.UnmaskPrompt.Events", + "Autofill.UnmaskPrompt.VirtualCard.Events", AutofillMetrics:: UNMASK_PROMPT_CLOSED_FAILED_TO_UNMASK_NON_RETRIABLE_FAILURE, 1);
diff --git a/components/autofill_assistant/browser/BUILD.gn b/components/autofill_assistant/browser/BUILD.gn index 4eb837c..6da78e2b 100644 --- a/components/autofill_assistant/browser/BUILD.gn +++ b/components/autofill_assistant/browser/BUILD.gn
@@ -20,10 +20,7 @@ "service.proto", "view_layout.proto", ] - link_deps = [ - "//components/autofill_assistant/browser/public:proto", - "//components/autofill_assistant/content/common/proto:proto", - ] + link_deps = [ "//components/autofill_assistant/browser/public:proto" ] } proto_library("test_proto") { @@ -366,8 +363,6 @@ "web/selector_observer.cc", "web/selector_observer.h", "web/selector_observer_script.h", - "web/semantic_element_finder.cc", - "web/semantic_element_finder.h", "web/send_keyboard_input_worker.cc", "web/send_keyboard_input_worker.h", "web/web_controller.cc", @@ -387,9 +382,6 @@ "//components/autofill_assistant/browser/devtools", "//components/autofill_assistant/browser/public:password_change", "//components/autofill_assistant/browser/public:public", - "//components/autofill_assistant/content/browser", - "//components/autofill_assistant/content/common", - "//components/autofill_assistant/content/common:mojo_interfaces", "//components/autofill_assistant/core/public:public", "//components/client_update_protocol", "//components/consent_auditor", @@ -669,10 +661,7 @@ "service.proto", "view_layout.proto", ] - deps = [ - "//components/autofill_assistant/browser/public:proto_java", - "//components/autofill_assistant/content/common/proto:proto_java", - ] + deps = [ "//components/autofill_assistant/browser/public:proto_java" ] } java_cpp_enum("autofill_assistant_enums_java") {
diff --git a/components/autofill_assistant/browser/android/BUILD.gn b/components/autofill_assistant/browser/android/BUILD.gn index b42e92e..154fb8d0 100644 --- a/components/autofill_assistant/browser/android/BUILD.gn +++ b/components/autofill_assistant/browser/android/BUILD.gn
@@ -66,7 +66,6 @@ "//components/autofill_assistant/browser:proto", "//components/autofill_assistant/browser/public", "//components/autofill_assistant/browser/public:password_change", - "//components/autofill_assistant/content/browser", "//components/image_fetcher:android", "//components/keyed_service/content", "//components/module_installer/android:native", @@ -96,7 +95,6 @@ "//components/autofill/core/browser", "//components/autofill_assistant/android:jni_headers_public_dependencies", "//components/autofill_assistant/browser", - "//components/autofill_assistant/content/browser", "//components/password_manager/core/browser", "//components/variations/service", "//content/public/browser",
diff --git a/components/autofill_assistant/browser/android/client_android.cc b/components/autofill_assistant/browser/android/client_android.cc index 6552d14..8195394 100644 --- a/components/autofill_assistant/browser/android/client_android.cc +++ b/components/autofill_assistant/browser/android/client_android.cc
@@ -101,8 +101,6 @@ : content::WebContentsUserData<ClientAndroid>(*web_contents), dependencies_( DependenciesAndroid::CreateFromJavaDependencies(jdependencies)), - annotate_dom_model_service_(dependencies_->GetCommonDependencies() - ->GetOrCreateAnnotateDomModelService()), jdependencies_(jdependencies), java_object_(Java_AutofillAssistantClient_Constructor( AttachCurrentThread(), @@ -464,24 +462,6 @@ return false; } -void ClientAndroid::GetAnnotateDomModelVersion( - base::OnceCallback<void(absl::optional<int64_t>)> callback) const { - if (!annotate_dom_model_service_) { - std::move(callback).Run(absl::nullopt); - return; - } - - auto model_version = annotate_dom_model_service_->GetModelVersion(); - if (model_version.has_value()) { - std::move(callback).Run(model_version); - return; - } - - annotate_dom_model_service_->NotifyOnModelFileAvailable(base::BindOnce( - &ClientAndroid::OnAnnotateDomModelFileAvailable, - weak_ptr_factory_.GetMutableWeakPtr(), std::move(callback))); -} - bool ClientAndroid::IsXmlSigned(const std::string& xml_string) const { JNIEnv* env = AttachCurrentThread(); jboolean j_output = Java_AssistantParseSingleTagXmlUtilWrapper_isXmlSigned( @@ -504,13 +484,6 @@ return output_values; } -void ClientAndroid::OnAnnotateDomModelFileAvailable( - base::OnceCallback<void(absl::optional<int64_t>)> callback, - bool available) { - DCHECK(annotate_dom_model_service_); - std::move(callback).Run(annotate_dom_model_service_->GetModelVersion()); -} - void ClientAndroid::Shutdown(Metrics::DropOutReason reason) { if (!controller_) return; @@ -585,7 +558,7 @@ base::DefaultTickClock::GetInstance(), RuntimeManager::GetForWebContents(GetWebContents())->GetWeakPtr(), std::move(service), /* web_controller= */ nullptr, - ukm::UkmRecorder::Get(), annotate_dom_model_service_); + ukm::UkmRecorder::Get()); ui_controller_ = std::make_unique<UiController>( /* client= */ this, controller_.get(), std::move(tts_controller)); ui_controller_->StartListening();
diff --git a/components/autofill_assistant/browser/android/client_android.h b/components/autofill_assistant/browser/android/client_android.h index 9ce2a02..6c097dc 100644 --- a/components/autofill_assistant/browser/android/client_android.h +++ b/components/autofill_assistant/browser/android/client_android.h
@@ -124,9 +124,6 @@ bool HasHadUI() const override; ScriptExecutorUiDelegate* GetScriptExecutorUiDelegate() override; bool MustUseBackendData() const override; - void GetAnnotateDomModelVersion( - base::OnceCallback<void(absl::optional<int64_t>)> callback) - const override; bool IsXmlSigned(const std::string& xml_string) const override; const std::vector<std::string> ExtractValuesFromSingleTagXml( const std::string& xml_string, @@ -153,15 +150,10 @@ void AttachUI(const base::android::JavaRef<jobject>& joverlay_coordinator); void SafeDestroyControllerAndUI(Metrics::DropOutReason reason); - void OnAnnotateDomModelFileAvailable( - base::OnceCallback<void(absl::optional<int64_t>)> callback, - bool available); - WEB_CONTENTS_USER_DATA_KEY_DECL(); // Contains AssistantStaticDependencies which do not change. const std::unique_ptr<const DependenciesAndroid> dependencies_; - const raw_ptr<AnnotateDomModelService> annotate_dom_model_service_; // Can change based on activity attachment. const base::android::ScopedJavaGlobalRef<jobject> jdependencies_;
diff --git a/components/autofill_assistant/browser/android/dependencies_android.h b/components/autofill_assistant/browser/android/dependencies_android.h index feb5163..0c7f131 100644 --- a/components/autofill_assistant/browser/android/dependencies_android.h +++ b/components/autofill_assistant/browser/android/dependencies_android.h
@@ -12,7 +12,6 @@ #include "components/autofill_assistant/browser/assistant_field_trial_util.h" #include "components/autofill_assistant/browser/common_dependencies.h" #include "components/autofill_assistant/browser/platform_dependencies.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" #include "components/password_manager/core/browser/password_manager_client.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/web_contents.h"
diff --git a/components/autofill_assistant/browser/android/starter_delegate_android.cc b/components/autofill_assistant/browser/android/starter_delegate_android.cc index f1d899d6..5cd246e8 100644 --- a/components/autofill_assistant/browser/android/starter_delegate_android.cc +++ b/components/autofill_assistant/browser/android/starter_delegate_android.cc
@@ -63,11 +63,7 @@ preference_manager_(GetCommonDependencies()->GetPrefs()), website_login_manager_(std::make_unique<WebsiteLoginManagerImpl>( GetCommonDependencies()->GetPasswordManagerClient(web_contents), - web_contents)) { - // Create the AnnotateDomModelService when the browser starts, such that it - // starts listening to model changes early enough. - GetCommonDependencies()->GetOrCreateAnnotateDomModelService(); -} + web_contents)) {} StarterDelegateAndroid::~StarterDelegateAndroid() = default; @@ -325,9 +321,7 @@ /* action_extension_delegate= */ nullptr, GetWebsiteLoginManager(), base::DefaultTickClock::GetInstance(), RuntimeManager::GetForWebContents(&GetWebContents())->GetWeakPtr(), - ukm::UkmRecorder::Get(), - starter_->GetCommonDependencies() - ->GetOrCreateAnnotateDomModelService()); + ukm::UkmRecorder::Get()); headless_script_controller_ = std::make_unique<HeadlessScriptControllerImpl>( &GetWebContents(), starter_.get(), std::move(client));
diff --git a/components/autofill_assistant/browser/autofill_assistant_impl.cc b/components/autofill_assistant/browser/autofill_assistant_impl.cc index ab1b3de5..15c0a7f 100644 --- a/components/autofill_assistant/browser/autofill_assistant_impl.cc +++ b/components/autofill_assistant/browser/autofill_assistant_impl.cc
@@ -182,8 +182,7 @@ web_contents, starter->GetCommonDependencies(), action_extension_delegate, website_login_manager, base::DefaultTickClock::GetInstance(), RuntimeManager::GetForWebContents(web_contents)->GetWeakPtr(), - ukm::UkmRecorder::Get(), - starter->GetCommonDependencies()->GetOrCreateAnnotateDomModelService()); + ukm::UkmRecorder::Get()); return std::make_unique<HeadlessScriptControllerImpl>(web_contents, starter, std::move(client)); }
diff --git a/components/autofill_assistant/browser/client.h b/components/autofill_assistant/browser/client.h index bb1f2f5..979cc436 100644 --- a/components/autofill_assistant/browser/client.h +++ b/components/autofill_assistant/browser/client.h
@@ -134,10 +134,6 @@ // backend endpoint to query data. virtual bool MustUseBackendData() const = 0; - // Return the annotate DOM model version, if available. - virtual void GetAnnotateDomModelVersion( - base::OnceCallback<void(absl::optional<int64_t>)> callback) const = 0; - // Checks if given XML is signed or not. virtual bool IsXmlSigned(const std::string& xml_string) const = 0;
diff --git a/components/autofill_assistant/browser/client_context.cc b/components/autofill_assistant/browser/client_context.cc index 08636f8..f43184b3 100644 --- a/components/autofill_assistant/browser/client_context.cc +++ b/components/autofill_assistant/browser/client_context.cc
@@ -81,15 +81,6 @@ proto_.set_screen_orientation(client_->GetScreenOrientation()); } -void ClientContextImpl::UpdateAnnotateDomModelContext(int64_t model_version) { - auto* model_context = proto_.mutable_annotate_dom_model_context(); - model_context->set_model_version(model_version); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantAnnotateDom)) { - model_context->set_force_semantic_selection(true); - } -} - void ClientContextImpl::UpdateJsFlowLibraryLoaded( const bool js_flow_library_loaded) { proto_.set_js_flow_library_loaded(js_flow_library_loaded);
diff --git a/components/autofill_assistant/browser/client_context.h b/components/autofill_assistant/browser/client_context.h index 63ca0a7..4e43b74c 100644 --- a/components/autofill_assistant/browser/client_context.h +++ b/components/autofill_assistant/browser/client_context.h
@@ -18,8 +18,6 @@ virtual ~ClientContext() = default; // Updates the client context based on the current state of the client. virtual void Update(const TriggerContext& trigger_context) = 0; - // Updates the annotate DOM model context. - virtual void UpdateAnnotateDomModelContext(int64_t model_version) {} // Updates whether the JS flow library is loaded. virtual void UpdateJsFlowLibraryLoaded(bool js_flow_library_loaded) {} // Returns the proto representation of this client context. @@ -35,7 +33,6 @@ explicit ClientContextImpl(const Client* client); ~ClientContextImpl() override = default; void Update(const TriggerContext& trigger_context) override; - void UpdateAnnotateDomModelContext(int64_t model_version) override; void UpdateJsFlowLibraryLoaded(bool js_flow_library_loaded) override; ClientContextProto AsProto() const override;
diff --git a/components/autofill_assistant/browser/client_context_unittest.cc b/components/autofill_assistant/browser/client_context_unittest.cc index 2b4f71e9..225e87e 100644 --- a/components/autofill_assistant/browser/client_context_unittest.cc +++ b/components/autofill_assistant/browser/client_context_unittest.cc
@@ -135,15 +135,6 @@ EXPECT_THAT(actual_client_context.window_size().height_pixels(), Eq(1920)); EXPECT_THAT(actual_client_context.screen_orientation(), ClientContextProto::LANDSCAPE); - EXPECT_FALSE(actual_client_context.has_annotate_dom_model_context()); - - client_context.UpdateAnnotateDomModelContext(123456); - actual_client_context = client_context.AsProto(); - EXPECT_THAT( - actual_client_context.annotate_dom_model_context().model_version(), - Eq(123456)); - EXPECT_FALSE(actual_client_context.annotate_dom_model_context() - .force_semantic_selection()); } TEST_F(ClientContextTest, WindowSizeIsClearedIfNoLongerAvailable) { @@ -238,18 +229,6 @@ EXPECT_EQ(client_context.AsProto().js_flow_library_loaded(), false); } -TEST_F(ClientContextTest, AnnotateDomSwitchForcesSemanticSelection) { - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kAutofillAssistantAnnotateDom); - - ClientContextImpl client_context(&mock_client_); - client_context.UpdateAnnotateDomModelContext(123456); - - auto model_context = client_context.AsProto().annotate_dom_model_context(); - EXPECT_THAT(model_context.model_version(), Eq(123456)); - EXPECT_TRUE(model_context.force_semantic_selection()); -} - TEST(GetPlatformType, ReturnsCorrectPlatform) { #if BUILDFLAG(IS_ANDROID) EXPECT_THAT(ClientContext::GetPlatformType(),
diff --git a/components/autofill_assistant/browser/common_dependencies.h b/components/autofill_assistant/browser/common_dependencies.h index e46723d..5e8be67 100644 --- a/components/autofill_assistant/browser/common_dependencies.h +++ b/components/autofill_assistant/browser/common_dependencies.h
@@ -38,7 +38,6 @@ namespace autofill_assistant { -class AnnotateDomModelService; class AssistantFieldTrialUtil; // Interface for platform delegates that provide dependencies to the starter. @@ -74,9 +73,6 @@ virtual bool IsAllowedForMachineLearning() const; - virtual AnnotateDomModelService* GetOrCreateAnnotateDomModelService() - const = 0; - virtual signin::IdentityManager* GetIdentityManager() const = 0; virtual consent_auditor::ConsentAuditor* GetConsentAuditor() const = 0;
diff --git a/components/autofill_assistant/browser/controller.cc b/components/autofill_assistant/browser/controller.cc index d0284a1..a4e6c01 100644 --- a/components/autofill_assistant/browser/controller.cc +++ b/components/autofill_assistant/browser/controller.cc
@@ -44,19 +44,6 @@ #include "url/gurl.h" namespace autofill_assistant { -namespace { - -bool ShouldSendModelVersionInContext(const TriggerContext& trigger_context) { - return base::FeatureList::IsEnabled( - autofill_assistant::features:: - kAutofillAssistantSendModelVersionInClientContext) || - trigger_context.GetScriptParameters() - .GetSendAnnotateDomModelVersion() || - base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantAnnotateDom); -} - -} // namespace Controller::Controller(content::WebContents* web_contents, Client* client, @@ -64,8 +51,7 @@ base::WeakPtr<RuntimeManager> runtime_manager, std::unique_ptr<Service> service, std::unique_ptr<WebController> web_controller, - ukm::UkmRecorder* ukm_recorder, - AnnotateDomModelService* annotate_dom_model_service) + ukm::UkmRecorder* ukm_recorder) : content::WebContentsObserver(web_contents), client_(client), tick_clock_(tick_clock), @@ -75,8 +61,7 @@ client_)), web_controller_(std::move(web_controller)), navigating_to_new_document_(web_contents->IsWaitingForResponse()), - ukm_recorder_(ukm_recorder), - annotate_dom_model_service_(annotate_dom_model_service) {} + ukm_recorder_(ukm_recorder) {} Controller::~Controller() { // Record failure, iff an earlier call didn't already record. @@ -106,7 +91,7 @@ WebController* Controller::GetWebController() { if (!web_controller_) { web_controller_ = WebController::CreateForWebContents( - web_contents(), &user_data_, &log_info_, annotate_dom_model_service_, + web_contents(), &user_data_, &log_info_, base::FeatureList::IsEnabled( autofill_assistant::features:: kAutofillAssistantFullJsSnippetStackTraces)); @@ -443,23 +428,6 @@ void Controller::MaybeUpdateClientContextAndGetScriptsForUrl(const GURL& url) { DCHECK(trigger_context_); - if (!ShouldSendModelVersionInContext(*trigger_context_)) { - GetScriptsForUrl(url); - return; - } - - DCHECK(client_); - client_->GetAnnotateDomModelVersion( - base::BindOnce(&Controller::OnGetAnnotateDomModelVersionForGetScripts, - weak_ptr_factory_.GetWeakPtr(), url)); -} - -void Controller::OnGetAnnotateDomModelVersionForGetScripts( - const GURL& url, - absl::optional<int64_t> model_version) { - if (model_version) { - service_->UpdateAnnotateDomModelContext(*model_version); - } GetScriptsForUrl(url); } @@ -564,13 +532,6 @@ return; } - if (response_proto.has_semantic_selector_policy()) { - // TODO(b/228987849): A semantic policy is set unconditionally. It may be - // more appropriate to only set one if there are actual eligible scripts for - // the given domain. - SetSemanticSelectorPolicy( - std::move(response_proto.semantic_selector_policy())); - } if (response_proto.has_client_settings()) { SetClientSettings(response_proto.client_settings()); } @@ -945,13 +906,6 @@ } } -void Controller::SetSemanticSelectorPolicy(SemanticSelectorPolicy policy) { - DCHECK(annotate_dom_model_service_); - if (!annotate_dom_model_service_->SetOverridesPolicy(std::move(policy))) { - NOTREACHED() << "Setting overrides policy failed!"; - } -} - void Controller::OnRunnableScriptsChanged( const std::vector<ScriptHandle>& runnable_scripts) { // Script selection is disabled when a script is already running. We will
diff --git a/components/autofill_assistant/browser/controller.h b/components/autofill_assistant/browser/controller.h index a20d044..c7bf6a7 100644 --- a/components/autofill_assistant/browser/controller.h +++ b/components/autofill_assistant/browser/controller.h
@@ -31,7 +31,6 @@ #include "components/autofill_assistant/browser/user_data.h" #include "components/autofill_assistant/browser/user_model.h" #include "components/autofill_assistant/browser/web/web_controller.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" #include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_observer.h" #include "services/metrics/public/cpp/ukm_recorder.h" @@ -71,8 +70,7 @@ base::WeakPtr<RuntimeManager> runtime_manager, std::unique_ptr<Service> service, std::unique_ptr<WebController> web_controller, - ukm::UkmRecorder* ukm_recorder, - AnnotateDomModelService* annotate_dom_model_service); + ukm::UkmRecorder* ukm_recorder); Controller(const Controller&) = delete; Controller& operator=(const Controller&) = delete; @@ -288,13 +286,7 @@ // only record the first impression for each flow. void MaybeRecordFlowFinishedMetrics(Metrics::FlowFinishedState state); - // Sets the semantic selector in the DOM annotation service. - void SetSemanticSelectorPolicy(SemanticSelectorPolicy policy); - void MaybeUpdateClientContextAndGetScriptsForUrl(const GURL& url); - void OnGetAnnotateDomModelVersionForGetScripts( - const GURL& url, - absl::optional<int64_t> model_version); void GetScriptsForUrl(const GURL& url); bool NeedsUI() const; @@ -404,10 +396,6 @@ raw_ptr<ukm::UkmRecorder> ukm_recorder_; - // If instantiated, will start delivering the required model for annotating - // DOM nodes. May be nullptr. - const raw_ptr<AnnotateDomModelService> annotate_dom_model_service_; - // The accumulated network stats of an entire flow. Used for metrics upon // flow completion. RoundtripNetworkStats accumulated_network_stats_;
diff --git a/components/autofill_assistant/browser/controller_unittest.cc b/components/autofill_assistant/browser/controller_unittest.cc index 074ec0b..6197e10 100644 --- a/components/autofill_assistant/browser/controller_unittest.cc +++ b/components/autofill_assistant/browser/controller_unittest.cc
@@ -80,14 +80,6 @@ using ::testing::UnorderedElementsAre; using ::testing::WithArgs; -class MockAnnotateDomModelService : public AnnotateDomModelService { - public: - MockAnnotateDomModelService() : AnnotateDomModelService(nullptr, nullptr) {} - ~MockAnnotateDomModelService() override = default; - - MOCK_METHOD1(SetOverridesPolicy, bool(SemanticSelectorPolicy)); -}; - class ControllerTest : public testing::Test { public: ControllerTest() { @@ -117,8 +109,7 @@ controller_ = std::make_unique<Controller>( web_contents(), &mock_client_, task_environment()->GetMockTickClock(), mock_runtime_manager_->GetWeakPtr(), std::move(service), - std::move(web_controller), &ukm_recorder_, - &mock_annotate_dom_model_service_); + std::move(web_controller), &ukm_recorder_); ON_CALL(mock_client_, AttachUI()).WillByDefault(Invoke([this]() { controller_->SetUiShown(true); @@ -277,7 +268,6 @@ mock_password_change_success_tracker_; ukm::TestAutoSetUkmRecorder ukm_recorder_; std::unique_ptr<Controller> controller_; - NiceMock<MockAnnotateDomModelService> mock_annotate_dom_model_service_; std::vector<ukm::SourceId> navigation_ids_; }; @@ -1736,8 +1726,7 @@ auto controller = std::make_unique<Controller>( web_contents(), &mock_client_, task_environment()->GetMockTickClock(), mock_runtime_manager_->GetWeakPtr(), std::move(service), - std::move(web_controller), &ukm_recorder_, - /* annotate_dom_model_service= */ nullptr); + std::move(web_controller), &ukm_recorder_); SetWebControllerForTest(controller.get(), std::make_unique<NiceMock<MockWebController>>()); @@ -1858,11 +1847,10 @@ class ControllerPrerenderTest : public ControllerTest { public: ControllerPrerenderTest() { - feature_list_.InitWithFeatures( - {blink::features::kPrerender2}, + feature_list_.InitAndDisableFeature( // Disable the memory requirement of Prerender2 so the test can run on // any bot. - {blink::features::kPrerender2MemoryControls}); + blink::features::kPrerender2MemoryControls); } ~ControllerPrerenderTest() override = default; @@ -1971,109 +1959,6 @@ EXPECT_THAT(listener.events, IsEmpty()); } -TEST_F(ControllerTest, SemanticOverridesSetInService) { - EXPECT_CALL(mock_annotate_dom_model_service_, SetOverridesPolicy) - .WillOnce(Return(true)); - - SupportsScriptResponseProto script_response; - script_response.mutable_semantic_selector_policy() - ->mutable_bag_of_words() - ->add_data_point_map(); - *AddRunnableScript(&script_response, "runnable") - ->mutable_presentation() - ->mutable_precondition() - ->mutable_element_condition() - ->mutable_match() = ToSelectorProto("#element"); - SetNextScriptResponse(script_response); - - EXPECT_CALL(mock_client_, AttachUI()); - Start("http://a.example.com/path"); - EXPECT_EQ(AutofillAssistantState::STARTING, controller_->GetState()); -} - -TEST_F(ControllerTest, SkipModelVersionIfParameterNotSpecified) { - EXPECT_CALL(mock_client_, GetAnnotateDomModelVersion).Times(0); - EXPECT_CALL(*mock_service_, UpdateAnnotateDomModelContext).Times(0); - EXPECT_CALL(*mock_service_, GetScriptsForUrl) - .WillOnce(RunOnceCallback<2>(net::HTTP_OK, "", - ServiceRequestSender::ResponseInfo{})); - - controller_->Start(GURL("https://www.example.com"), - std::make_unique<TriggerContext>( - /* parameters = */ std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{{}}), - TriggerContext::Options())); -} - -TEST_F(ControllerTest, AttachesAvailableModelVersionOnStart) { - EXPECT_CALL(mock_client_, GetAnnotateDomModelVersion) - .WillOnce(RunOnceCallback<0>(123456)); - EXPECT_CALL(*mock_service_, UpdateAnnotateDomModelContext(123456)); - EXPECT_CALL(*mock_service_, GetScriptsForUrl) - .WillOnce(RunOnceCallback<2>(net::HTTP_OK, "", - ServiceRequestSender::ResponseInfo{})); - - controller_->Start(GURL("https://www.example.com"), - std::make_unique<TriggerContext>( - /* parameters = */ std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{ - {"SEND_ANNOTATE_DOM_MODEL_VERSION", "true"}}), - TriggerContext::Options())); -} - -TEST_F(ControllerTest, DoesNotAttachUnavailableModelVersionOnStart) { - EXPECT_CALL(mock_client_, GetAnnotateDomModelVersion) - .WillOnce(RunOnceCallback<0>(absl::nullopt)); - EXPECT_CALL(*mock_service_, UpdateAnnotateDomModelContext).Times(0); - EXPECT_CALL(*mock_service_, GetScriptsForUrl) - .WillOnce(RunOnceCallback<2>(net::HTTP_OK, "", - ServiceRequestSender::ResponseInfo{})); - - controller_->Start(GURL("https://www.example.com"), - std::make_unique<TriggerContext>( - /* parameters = */ std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{ - {"SEND_ANNOTATE_DOM_MODEL_VERSION", "true"}}), - TriggerContext::Options())); -} - -TEST_F(ControllerTest, AttachesAvailableModelVersionForCommandLineSwitch) { - base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( - switches::kAutofillAssistantAnnotateDom, "true"); - - EXPECT_CALL(mock_client_, GetAnnotateDomModelVersion) - .WillOnce(RunOnceCallback<0>(123456)); - EXPECT_CALL(*mock_service_, UpdateAnnotateDomModelContext(123456)); - EXPECT_CALL(*mock_service_, GetScriptsForUrl) - .WillOnce(RunOnceCallback<2>(net::HTTP_OK, "", - ServiceRequestSender::ResponseInfo{})); - - controller_->Start(GURL("https://www.example.com"), - std::make_unique<TriggerContext>( - /* parameters = */ std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{}), - TriggerContext::Options())); -} - -TEST_F(ControllerTest, AttachesAvailableModelVersionWhenFeatureEnabled) { - scoped_feature_list_.Reset(); - scoped_feature_list_.InitAndEnableFeature( - features::kAutofillAssistantSendModelVersionInClientContext); - - EXPECT_CALL(mock_client_, GetAnnotateDomModelVersion) - .WillOnce(RunOnceCallback<0>(123456)); - EXPECT_CALL(*mock_service_, UpdateAnnotateDomModelContext(123456)); - EXPECT_CALL(*mock_service_, GetScriptsForUrl) - .WillOnce(RunOnceCallback<2>(net::HTTP_OK, "", - ServiceRequestSender::ResponseInfo{})); - - controller_->Start(GURL("https://www.example.com"), - std::make_unique<TriggerContext>( - /* parameters = */ std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{}), - TriggerContext::Options())); -} - TEST_F(ControllerTest, UpdatesJsFlowLibraryLoaded) { EXPECT_CALL(*mock_service_, UpdateJsFlowLibraryLoaded(true));
diff --git a/components/autofill_assistant/browser/fake_common_dependencies.cc b/components/autofill_assistant/browser/fake_common_dependencies.cc index c295d2ba..f84ef27c 100644 --- a/components/autofill_assistant/browser/fake_common_dependencies.cc +++ b/components/autofill_assistant/browser/fake_common_dependencies.cc
@@ -65,11 +65,6 @@ return is_allowed_for_machine_learning_; } -AnnotateDomModelService* -FakeCommonDependencies::GetOrCreateAnnotateDomModelService() const { - return nullptr; -} - signin::IdentityManager* FakeCommonDependencies::GetIdentityManager() const { return identity_manager_; }
diff --git a/components/autofill_assistant/browser/fake_common_dependencies.h b/components/autofill_assistant/browser/fake_common_dependencies.h index ada4c448..b714e938 100644 --- a/components/autofill_assistant/browser/fake_common_dependencies.h +++ b/components/autofill_assistant/browser/fake_common_dependencies.h
@@ -42,7 +42,6 @@ content::WebContents* web_contents) const override; bool IsSupervisedUser() const override; bool IsAllowedForMachineLearning() const override; - AnnotateDomModelService* GetOrCreateAnnotateDomModelService() const override; signin::IdentityManager* GetIdentityManager() const override; consent_auditor::ConsentAuditor* GetConsentAuditor() const override; version_info::Channel GetChannel() const override;
diff --git a/components/autofill_assistant/browser/headless/client_headless.cc b/components/autofill_assistant/browser/headless/client_headless.cc index f062dc8..de1e214 100644 --- a/components/autofill_assistant/browser/headless/client_headless.cc +++ b/components/autofill_assistant/browser/headless/client_headless.cc
@@ -55,15 +55,13 @@ WebsiteLoginManager* website_login_manager, const base::TickClock* tick_clock, base::WeakPtr<RuntimeManager> runtime_manager, - ukm::UkmRecorder* ukm_recorder, - AnnotateDomModelService* annotate_dom_model_service) + ukm::UkmRecorder* ukm_recorder) : web_contents_(web_contents), common_dependencies_(common_dependencies), website_login_manager_(website_login_manager), tick_clock_(tick_clock), runtime_manager_(runtime_manager), - ukm_recorder_(ukm_recorder), - annotate_dom_model_service_(annotate_dom_model_service) { + ukm_recorder_(ukm_recorder) { headless_ui_controller_ = std::make_unique<HeadlessUiController>(action_extension_delegate); } @@ -89,8 +87,7 @@ } controller_ = std::make_unique<Controller>( web_contents_, /* client= */ this, tick_clock_, runtime_manager_, - std::move(service), std::move(web_controller), ukm_recorder_, - annotate_dom_model_service_); + std::move(service), std::move(web_controller), ukm_recorder_); controller_->AddObserver(headless_ui_controller_.get()); controller_->Start(url, std::move(trigger_context)); } @@ -208,11 +205,6 @@ return false; } -void ClientHeadless::GetAnnotateDomModelVersion( - base::OnceCallback<void(absl::optional<int64_t>)> callback) const { - std::move(callback).Run(absl::nullopt); -} - void ClientHeadless::Shutdown(Metrics::DropOutReason reason) { // This call can cause Controller to be destroyed. For this reason we delay it // to avoid UAF errors in the controller.
diff --git a/components/autofill_assistant/browser/headless/client_headless.h b/components/autofill_assistant/browser/headless/client_headless.h index 3946289f..d214d14 100644 --- a/components/autofill_assistant/browser/headless/client_headless.h +++ b/components/autofill_assistant/browser/headless/client_headless.h
@@ -48,8 +48,7 @@ WebsiteLoginManager* website_login_manager, const base::TickClock* tick_clock, base::WeakPtr<RuntimeManager> runtime_manager, - ukm::UkmRecorder* ukm_recorder, - AnnotateDomModelService* annotate_dom_model_service); + ukm::UkmRecorder* ukm_recorder); ClientHeadless(const ClientHeadless&) = delete; ClientHeadless& operator=(const ClientHeadless&) = delete; @@ -92,9 +91,6 @@ bool HasHadUI() const override; ScriptExecutorUiDelegate* GetScriptExecutorUiDelegate() override; bool MustUseBackendData() const override; - void GetAnnotateDomModelVersion( - base::OnceCallback<void(absl::optional<int64_t>)> callback) - const override; bool GetMakeSearchesAndBrowsingBetterEnabled() const override; bool GetMetricsReportingEnabled() const override; @@ -130,7 +126,6 @@ const raw_ptr<const base::TickClock> tick_clock_; base::WeakPtr<RuntimeManager> runtime_manager_; const raw_ptr<ukm::UkmRecorder> ukm_recorder_; - const raw_ptr<AnnotateDomModelService> annotate_dom_model_service_; // Only set while a script is running. base::OnceCallback<void(Metrics::DropOutReason reason)>
diff --git a/components/autofill_assistant/browser/headless/headless_script_controller_impl_unittest.cc b/components/autofill_assistant/browser/headless/headless_script_controller_impl_unittest.cc index 0343950..dee3f6a 100644 --- a/components/autofill_assistant/browser/headless/headless_script_controller_impl_unittest.cc +++ b/components/autofill_assistant/browser/headless/headless_script_controller_impl_unittest.cc
@@ -127,7 +127,7 @@ web_contents_.get(), starter_->GetCommonDependencies(), mock_external_action_delegate_.get(), nullptr, task_environment_.GetMockTickClock(), - mock_runtime_manager_->GetWeakPtr(), &ukm_recorder_, nullptr); + mock_runtime_manager_->GetWeakPtr(), &ukm_recorder_); headless_script_controller_ = std::make_unique<HeadlessScriptControllerImpl>( web_contents_.get(), starter_.get(), std::move(client));
diff --git a/components/autofill_assistant/browser/mock_client_context.h b/components/autofill_assistant/browser/mock_client_context.h index 4f5f849..1e12a64 100644 --- a/components/autofill_assistant/browser/mock_client_context.h +++ b/components/autofill_assistant/browser/mock_client_context.h
@@ -23,10 +23,6 @@ (const TriggerContext& trigger_context), (override)); MOCK_METHOD(void, - UpdateAnnotateDomModelContext, - (int64_t model_version), - (override)); - MOCK_METHOD(void, UpdateJsFlowLibraryLoaded, (bool js_flow_library_loaded), (override));
diff --git a/components/autofill_assistant/browser/mock_common_dependencies.h b/components/autofill_assistant/browser/mock_common_dependencies.h index bb959be..81fc315 100644 --- a/components/autofill_assistant/browser/mock_common_dependencies.h +++ b/components/autofill_assistant/browser/mock_common_dependencies.h
@@ -48,10 +48,6 @@ (const override)); MOCK_METHOD(bool, IsSupervisedUser, (), (const override)); MOCK_METHOD(bool, IsAllowedForMachineLearning, (), (const override)); - MOCK_METHOD(AnnotateDomModelService*, - GetOrCreateAnnotateDomModelService, - (), - (const override)); MOCK_METHOD(signin::IdentityManager*, GetIdentityManager, (),
diff --git a/components/autofill_assistant/browser/protocol_utils.cc b/components/autofill_assistant/browser/protocol_utils.cc index ec96fb2..8205129 100644 --- a/components/autofill_assistant/browser/protocol_utils.cc +++ b/components/autofill_assistant/browser/protocol_utils.cc
@@ -526,17 +526,11 @@ case ActionProto::ActionInfoCase::kSetNativeValue: return PerformOnSingleElementAction::WithClientId( delegate, action, action.set_native_value().client_id(), - base::BindOnce( - &action_delegate_util::PerformWithTextValue, delegate, - action.set_native_value().value(), - base::BindOnce(&WebController::SetNativeValue, - delegate->GetWebController()->GetWeakPtr()))); + base::DoNothing()); case ActionProto::ActionInfoCase::kSetNativeChecked: return PerformOnSingleElementAction::WithClientId( delegate, action, action.set_native_checked().client_id(), - base::BindOnce(&WebController::SetNativeChecked, - delegate->GetWebController()->GetWeakPtr(), - action.set_native_checked().checked())); + base::DoNothing()); case ActionProto::ActionInfoCase::kPromptQrCodeScan: return std::make_unique<PromptQrCodeScanAction>(delegate, action); case ActionProto::ActionInfoCase::kParseSingleTagXml:
diff --git a/components/autofill_assistant/browser/script_executor_browsertest.cc b/components/autofill_assistant/browser/script_executor_browsertest.cc index 66819db0..fc7d66b 100644 --- a/components/autofill_assistant/browser/script_executor_browsertest.cc +++ b/components/autofill_assistant/browser/script_executor_browsertest.cc
@@ -53,7 +53,7 @@ BaseBrowserTest::SetUpOnMainThread(); web_controller_ = WebController::CreateForWebContents( - shell()->web_contents(), &user_data_, &log_info_, nullptr, + shell()->web_contents(), &user_data_, &log_info_, /*enable_full_stack_traces= */ true); fake_script_executor_delegate_.SetWebController(web_controller_.get());
diff --git a/components/autofill_assistant/browser/selector.cc b/components/autofill_assistant/browser/selector.cc index 887de3e..3f075c9 100644 --- a/components/autofill_assistant/browser/selector.cc +++ b/components/autofill_assistant/browser/selector.cc
@@ -57,12 +57,6 @@ } } -bool operator<(const SelectorProto::SemanticFilter& a, - const SelectorProto::SemanticFilter& b) { - return std::make_tuple(a.objective(), a.role(), a.ignore_objective()) < - std::make_tuple(b.objective(), b.role(), b.ignore_objective()); -} - // Used by operator<(RepeatedPtrField<Filter>, RepeatedPtrField<Filter>) bool operator<(const SelectorProto::Filter& a, const SelectorProto::Filter& b); @@ -130,9 +124,6 @@ case SelectorProto::Filter::kProperty: return a.property() < b.property(); - case SelectorProto::Filter::kSemantic: - return a.semantic() < b.semantic(); - case SelectorProto::Filter::FILTER_NOT_SET: return false; } @@ -235,15 +226,6 @@ return true; } - int semantic_selector_count = base::ranges::count_if( - proto.filters(), [](const SelectorProto::Filter& filter) { - return filter.filter_case() == SelectorProto::Filter::kSemantic; - }); - if (semantic_selector_count > 0) { - return semantic_selector_count > 1 || - proto.filters(0).filter_case() != SelectorProto::Filter::kSemantic; - } - return !base::ranges::any_of( proto.filters(), [](const SelectorProto::Filter& filter) { return filter.filter_case() == SelectorProto::Filter::kCssSelector; @@ -298,18 +280,6 @@ return out; } -std::ostream& operator<<(std::ostream& out, - const SelectorProto::SemanticFilter& c) { - out << "Semantic { role: " << c.role() << ", objective: "; - if (c.ignore_objective()) { - out << "ignored"; - } else { - out << c.objective(); - } - out << " }"; - return out; -} - std::ostream& operator<<( std::ostream& out, const google::protobuf::RepeatedPtrField<SelectorProto::Filter>& filters) { @@ -411,10 +381,6 @@ out << "parent"; return out; - case SelectorProto::Filter::kSemantic: - out << f.semantic(); - return out; - case SelectorProto::Filter::FILTER_NOT_SET: // Either unset or set to an unsupported value. Let's assume the worse. out << "INVALID";
diff --git a/components/autofill_assistant/browser/selector_unittest.cc b/components/autofill_assistant/browser/selector_unittest.cc index 1e59b36..49631a8 100644 --- a/components/autofill_assistant/browser/selector_unittest.cc +++ b/components/autofill_assistant/browser/selector_unittest.cc
@@ -43,27 +43,6 @@ EXPECT_FALSE(Selector({"#test"}).empty()); } -TEST(SelectorTest, ValidateSemanticSelector) { - SelectorProto semantic_only_proto; - semantic_only_proto.add_filters()->mutable_semantic(); - EXPECT_FALSE(Selector(semantic_only_proto).empty()); - - SelectorProto semantic_and_css_proto; - semantic_and_css_proto.add_filters()->mutable_semantic(); - semantic_and_css_proto.add_filters()->set_css_selector("#id"); - EXPECT_FALSE(Selector(semantic_and_css_proto).empty()); - - SelectorProto css_and_semantic_proto; - css_and_semantic_proto.add_filters()->set_css_selector("#id"); - css_and_semantic_proto.add_filters()->mutable_semantic(); - EXPECT_TRUE(Selector(css_and_semantic_proto).empty()); - - SelectorProto semantic_and_semantic_proto; - semantic_and_semantic_proto.add_filters()->mutable_semantic(); - semantic_and_semantic_proto.add_filters()->mutable_semantic(); - EXPECT_TRUE(Selector(semantic_and_semantic_proto).empty()); -} - TEST(SelectorTest, Comparison) { // Note that comparison tests cover < indirectly through ==, since a == b is // defined as !(a < b) && !(b < a). This makes sense, as what matters is that @@ -285,25 +264,5 @@ EXPECT_FALSE(autofill_filter == autofill_filter_chunk); } -TEST(SelectorTest, ComparisonSemanticFilters) { - Selector semantic_selector; - auto* filter = semantic_selector.proto.add_filters(); - filter->mutable_semantic()->set_objective(1); - filter->mutable_semantic()->set_role(2); - - Selector semantic_selector_copy(semantic_selector.proto); - EXPECT_TRUE(semantic_selector == semantic_selector_copy); - - Selector ignored_objective_selector; - filter = ignored_objective_selector.proto.add_filters(); - filter->mutable_semantic()->set_ignore_objective(true); - filter->mutable_semantic()->set_role(2); - - Selector ignored_objective_selector_copy(ignored_objective_selector.proto); - EXPECT_TRUE(ignored_objective_selector == ignored_objective_selector_copy); - - EXPECT_FALSE(semantic_selector == ignored_objective_selector); -} - } // namespace } // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/service.proto b/components/autofill_assistant/browser/service.proto index 40b7a8f36..fffa7539 100644 --- a/components/autofill_assistant/browser/service.proto +++ b/components/autofill_assistant/browser/service.proto
@@ -17,7 +17,6 @@ import "components/autofill_assistant/browser/generic_ui.proto"; import "components/autofill_assistant/browser/model.proto"; import "components/autofill_assistant/browser/view_layout.proto"; -import "components/autofill_assistant/content/common/proto/semantic_feature_overrides.proto"; import "components/autofill_assistant/browser/public/external_action.proto"; // A field trial containing the name of the trial and the name of the @@ -139,21 +138,10 @@ } optional PlatformType platform_type = 20; - // The model for semantic dom annotation. - message AnnotateDomModelContextProto { - optional int64 model_version = 1; - - // If set to true, serve semantic selectors even if a user is not part of - // an official server side experiment. This is used for emulator use cases - // that do not necessarily have a signed in user or an account. - optional bool force_semantic_selection = 2; - } - optional AnnotateDomModelContextProto annotate_dom_model_context = 22; - // Set if the client has the JS flow library needed for JS flow execution. optional bool js_flow_library_loaded = 23; - reserved 19, 21; + reserved 19, 21, 22; } // Get the list of scripts that can potentially be run on a url. @@ -197,10 +185,7 @@ // The ScriptStoreConfig to use with the initial GetActions request. optional ScriptStoreConfig script_store_config = 6; - // Semantic selector related policy configuration. - optional SemanticSelectorPolicy semantic_selector_policy = 7; - - reserved 4, 5; + reserved 4, 5, 7; } // A privacy sensitive way to look up Capabilities. Allows querying for @@ -1606,39 +1591,7 @@ // If set, the document could not be resolved. optional bool get_document_failed = 5; - enum SemanticInferenceStatus { - // Unknown error. Should not occur. - UNKNOWN = 0; - // The model was run successfully. - SUCCESS = 1; - // An unexpected error happened when the model was run. E.g. the frame - // was not available where it was expected to be. - UNEXPECTED_ERROR = 2; - // The model was successfully loaded but could not initialize the executor. - INITIALIZATION_ERROR = 3; - // The model could not be loaded. This is unexpected and should not occur. - MODEL_LOAD_ERROR = 4; - // The model loading timed out. - MODEL_LOAD_TIMEOUT = 5; - } - message PredictedElement { - // The predicted objective and predicted role of this element. - optional SelectorProto.SemanticFilter semantic_filter = 4; - // The element's backend node id. - optional int32 backend_node_id = 3; - // Whether this element was found using a feature override. - optional bool used_override = 5; - - reserved 1, 2; - } - message SemanticInferenceResult { - // If this is empty, the model inference did not find any results. - repeated PredictedElement predicted_elements = 1; - // Status per frame. The order is not predictable, the results are - // collected async and arrive in random order. - repeated SemanticInferenceStatus status_per_frame = 2; - } - optional SemanticInferenceResult semantic_inference_result = 6; + reserved 6; } // The pseudo type values come from @@ -1791,19 +1744,9 @@ // Retrieve parent of current elements. EmptyFilter parent = 15; - - // Run the ML model over extracted node signals and retrieve a matching - // result. - // TODO(b/233340267): By convention this must be the first filter in the - // list. It can be followed by any set of other filters. - // TODO(b/233340267): The filter only supports returning a single element, - // although that element can have any number of children. Should it find - // multiple elements, the Selector will return a |TOO_MANY_ELEMENTS| - // error. - SemanticFilter semantic = 16; } - reserved 10; + reserved 10, 16; } // A regular expression value for filtering. @@ -1889,21 +1832,6 @@ optional int32 index = 1; } - message SemanticFilter { - // The objective we expect this Selector to have. - optional int32 objective = 1; - // The role we expect this Selector to have. - optional int32 role = 2; - // Timeout, defaults to 5s. - // TODO(b/218482826): Consider moving this to settings. - optional int32 model_timeout_ms = 3 [default = 5000]; - // If true, ignore the objective and treat it as a wildcard '*' when - // matching. - optional bool ignore_objective = 4; - - reserved 5; - } - reserved 1 to 8, 11; }
diff --git a/components/autofill_assistant/browser/service/service_impl.cc b/components/autofill_assistant/browser/service/service_impl.cc index e181cd9..b9b387a 100644 --- a/components/autofill_assistant/browser/service/service_impl.cc +++ b/components/autofill_assistant/browser/service/service_impl.cc
@@ -213,10 +213,6 @@ request_sender_->SetDisableRpcSigning(disable_rpc_signing); } -void ServiceImpl::UpdateAnnotateDomModelContext(int64_t model_version) { - client_context_->UpdateAnnotateDomModelContext(model_version); -} - void ServiceImpl::UpdateJsFlowLibraryLoaded(const bool js_flow_library_loaded) { client_context_->UpdateJsFlowLibraryLoaded(js_flow_library_loaded); }
diff --git a/components/autofill_assistant/browser/service/service_impl.h b/components/autofill_assistant/browser/service/service_impl.h index 64de37e..b2b33cc 100644 --- a/components/autofill_assistant/browser/service/service_impl.h +++ b/components/autofill_assistant/browser/service/service_impl.h
@@ -99,8 +99,6 @@ void SetDisableRpcSigning(bool disable_rpc_signing) override; - void UpdateAnnotateDomModelContext(int64_t model_version) override; - void UpdateJsFlowLibraryLoaded(bool js_flow_library_loaded) override; private:
diff --git a/components/autofill_assistant/browser/service/service_impl_unittest.cc b/components/autofill_assistant/browser/service/service_impl_unittest.cc index bf438405..03ed8f3 100644 --- a/components/autofill_assistant/browser/service/service_impl_unittest.cc +++ b/components/autofill_assistant/browser/service/service_impl_unittest.cc
@@ -256,11 +256,6 @@ mock_response_callback_.Get()); } -TEST_F(ServiceImplTest, UpdateAnnotateDomModelService) { - EXPECT_CALL(*mock_client_context_, UpdateAnnotateDomModelContext(123456)); - service_->UpdateAnnotateDomModelContext(123456); -} - TEST_F(ServiceImplTest, UpdateJsFlowLibraryLoaded) { EXPECT_CALL(*mock_client_context_, UpdateJsFlowLibraryLoaded(true)); service_->UpdateJsFlowLibraryLoaded(true);
diff --git a/components/autofill_assistant/browser/starter.cc b/components/autofill_assistant/browser/starter.cc index 22ca5818f..623ee6a 100644 --- a/components/autofill_assistant/browser/starter.cc +++ b/components/autofill_assistant/browser/starter.cc
@@ -670,7 +670,6 @@ web_contents(), /* user_data= */ nullptr, /* log_info= */ nullptr, - /* annotate_dom_model_service= */ nullptr, /* enable_full_stack_traces= */ false), std::move(service_request_sender), url_fetcher.GetTriggerScriptsEndpoint(),
diff --git a/components/autofill_assistant/browser/starter_unittest.cc b/components/autofill_assistant/browser/starter_unittest.cc index aa1ad64..9ebac3fa 100644 --- a/components/autofill_assistant/browser/starter_unittest.cc +++ b/components/autofill_assistant/browser/starter_unittest.cc
@@ -1926,11 +1926,10 @@ class StarterPrerenderTest : public StarterTest { public: StarterPrerenderTest() { - feature_list_.InitWithFeatures( - {blink::features::kPrerender2}, + feature_list_.InitAndDisableFeature( // Disable the memory requirement of Prerender2 so the test can run on // any bot. - {blink::features::kPrerender2MemoryControls}); + blink::features::kPrerender2MemoryControls); } ~StarterPrerenderTest() override = default;
diff --git a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc index 959708f..6f3020a 100644 --- a/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc +++ b/components/autofill_assistant/browser/trigger_scripts/trigger_script_coordinator_unittest.cc
@@ -1751,11 +1751,10 @@ : public TriggerScriptCoordinatorTest { public: TriggerScriptCoordinatorPrerenderTest() { - feature_list_.InitWithFeatures( - {blink::features::kPrerender2}, + feature_list_.InitAndDisableFeature( // Disable the memory requirement of Prerender2 so the test can run on // any bot. - {blink::features::kPrerender2MemoryControls}); + blink::features::kPrerender2MemoryControls); } ~TriggerScriptCoordinatorPrerenderTest() override = default;
diff --git a/components/autofill_assistant/browser/user_data_util.cc b/components/autofill_assistant/browser/user_data_util.cc index 752d987f..ae805e5 100644 --- a/components/autofill_assistant/browser/user_data_util.cc +++ b/components/autofill_assistant/browser/user_data_util.cc
@@ -904,7 +904,6 @@ case SelectorProto::Filter::kMatchCssSelector: case SelectorProto::Filter::kOnTop: case SelectorProto::Filter::kParent: - case SelectorProto::Filter::kSemantic: case SelectorProto::Filter::FILTER_NOT_SET: break; // Do not add default here. In case a new filter gets added (that may
diff --git a/components/autofill_assistant/browser/web/batch_element_checker_browsertest.cc b/components/autofill_assistant/browser/web/batch_element_checker_browsertest.cc index 5eca3da..b13b0be 100644 --- a/components/autofill_assistant/browser/web/batch_element_checker_browsertest.cc +++ b/components/autofill_assistant/browser/web/batch_element_checker_browsertest.cc
@@ -63,7 +63,6 @@ BaseBrowserTest::SetUpOnMainThread(); web_controller_ = WebController::CreateForWebContents( shell()->web_contents(), &user_data_, &log_info_, - /* annotate_dom_model_service= */ nullptr, /* enable_full_stack_traces= */ false); Observe(shell()->web_contents()); }
diff --git a/components/autofill_assistant/browser/web/css_element_finder.cc b/components/autofill_assistant/browser/web/css_element_finder.cc index 89c7c2b..8ed0d6c 100644 --- a/components/autofill_assistant/browser/web/css_element_finder.cc +++ b/components/autofill_assistant/browser/web/css_element_finder.cc
@@ -13,7 +13,6 @@ #include "components/autofill_assistant/browser/web/element_finder_result.h" #include "components/autofill_assistant/browser/web/js_filter_builder.h" #include "components/autofill_assistant/browser/web/web_controller_util.h" -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" @@ -214,13 +213,6 @@ } current_filter_index_range_start_ = next_filter_index_; - if (filters.Get(next_filter_index_).filter_case() == - SelectorProto::Filter::kSemantic) { - // TODO(b/233340267): By convention the semantic filter must be the first. - // Skip it. - DCHECK_EQ(next_filter_index_, 0); - ++next_filter_index_; - } const auto& filter = filters.Get(next_filter_index_); switch (filter.filter_case()) { case SelectorProto::Filter::kEnterFrame: { @@ -287,7 +279,6 @@ return; } - case SelectorProto::Filter::kSemantic: case SelectorProto::Filter::FILTER_NOT_SET: VLOG(1) << __func__ << " Unexpected filter in " << filter << " in " << selector_;
diff --git a/components/autofill_assistant/browser/web/element_finder.cc b/components/autofill_assistant/browser/web/element_finder.cc index 6c59879b2..489adeb 100644 --- a/components/autofill_assistant/browser/web/element_finder.cc +++ b/components/autofill_assistant/browser/web/element_finder.cc
@@ -11,33 +11,20 @@ #include "components/autofill_assistant/browser/user_data.h" #include "components/autofill_assistant/browser/web/base_element_finder.h" #include "components/autofill_assistant/browser/web/css_element_finder.h" -#include "components/autofill_assistant/browser/web/semantic_element_finder.h" #include "content/public/browser/web_contents.h" namespace autofill_assistant { -namespace { -bool HasSemanticRootFilter(const Selector& selector) { - return selector.proto.filters_size() > 0 && - selector.proto.filters(0).filter_case() == - SelectorProto::Filter::kSemantic; -} - -} // namespace - -ElementFinder::ElementFinder( - content::WebContents* web_contents, - DevtoolsClient* devtools_client, - const UserData* user_data, - ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service, - const Selector& selector, - ElementFinderResultType result_type) +ElementFinder::ElementFinder(content::WebContents* web_contents, + DevtoolsClient* devtools_client, + const UserData* user_data, + ProcessedActionStatusDetailsProto* log_info, + const Selector& selector, + ElementFinderResultType result_type) : web_contents_(web_contents), devtools_client_(devtools_client), user_data_(user_data), log_info_(log_info), - annotate_dom_model_service_(annotate_dom_model_service), selector_(selector), result_type_(result_type) {} @@ -54,26 +41,6 @@ return; } - // TODO(b/224747076): Coordinate the dom_model_service experiment in the - // backend. So that we don't get semantic selectors if the client doesn't - // support the model. - if (HasSemanticRootFilter(selector_)) { - if (!annotate_dom_model_service_) { - SendResult(ClientStatus(PRECONDITION_FAILED), - std::make_unique<ElementFinderResult>( - ElementFinderResult::EmptyResult())); - return; - } - - StartAndRetainRunner(start_element, - std::make_unique<SemanticElementFinder>( - web_contents_, devtools_client_, - annotate_dom_model_service_, selector_), - base::BindOnce(&ElementFinder::OnSemanticRunnerResult, - weak_ptr_factory_.GetWeakPtr())); - return; - } - StartAndRetainRunner( start_element, std::make_unique<CssElementFinder>(web_contents_, devtools_client_, @@ -113,30 +80,4 @@ ClientStatus(status.proto_status(), status.details()), std::move(result)); } -void ElementFinder::OnSemanticRunnerResult( - const ClientStatus& status, - std::unique_ptr<ElementFinderResult> result) { - if (!status.ok()) { - SendResult(status, std::move(result)); - return; - } - - if (selector_.proto.filters_size() > 1) { - // The semantic filter was only the root, there are more filters to run. - // Log and retain the current result and start a CSS lookup from here. - UpdateLogInfo(status); - current_result_ = std::move(result); - - StartAndRetainRunner( - *current_result_, - std::make_unique<CssElementFinder>(web_contents_, devtools_client_, - user_data_, result_type_, selector_), - base::BindOnce(&ElementFinder::SendResult, - weak_ptr_factory_.GetWeakPtr())); - return; - } - - SendResult(status, std::move(result)); -} - } // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/web/element_finder.h b/components/autofill_assistant/browser/web/element_finder.h index b731200..3c6036a 100644 --- a/components/autofill_assistant/browser/web/element_finder.h +++ b/components/autofill_assistant/browser/web/element_finder.h
@@ -18,7 +18,6 @@ #include "components/autofill_assistant/browser/web/element_finder_result.h" #include "components/autofill_assistant/browser/web/element_finder_result_type.h" #include "components/autofill_assistant/browser/web/web_controller_worker.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" namespace content { class WebContents; @@ -36,13 +35,11 @@ class ElementFinder : public WebControllerWorker { public: // |web_contents|, |devtools_client| and |user_data| must be valid for the - // lifetime of the instance. If |annotate_dom_model_service| is not nullptr, - // must be valid for the lifetime of the instance. + // lifetime of the instance. ElementFinder(content::WebContents* web_contents, DevtoolsClient* devtools_client, const UserData* user_data, ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service, const Selector& selector, ElementFinderResultType result_type); ~ElementFinder() override; @@ -73,7 +70,6 @@ const raw_ptr<DevtoolsClient> devtools_client_; const raw_ptr<const UserData> user_data_; const raw_ptr<ProcessedActionStatusDetailsProto> log_info_; - const raw_ptr<AnnotateDomModelService> annotate_dom_model_service_; const Selector selector_; const ElementFinderResultType result_type_; Callback callback_;
diff --git a/components/autofill_assistant/browser/web/js_filter_builder.cc b/components/autofill_assistant/browser/web/js_filter_builder.cc index c5ca0a04..e9c9daa 100644 --- a/components/autofill_assistant/browser/web/js_filter_builder.cc +++ b/components/autofill_assistant/browser/web/js_filter_builder.cc
@@ -165,7 +165,6 @@ case SelectorProto::Filter::kEnterFrame: case SelectorProto::Filter::kPseudoType: - case SelectorProto::Filter::kSemantic: case SelectorProto::Filter::FILTER_NOT_SET: return false; }
diff --git a/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.cc b/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.cc deleted file mode 100644 index c4d55473..0000000 --- a/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.cc +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h" - -#include "base/test/bind.h" -#include "content/public/browser/render_frame_host.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" - -namespace autofill_assistant { - -MockAutofillAssistantAgent::MockAutofillAssistantAgent() = default; -MockAutofillAssistantAgent::~MockAutofillAssistantAgent() = default; - -void MockAutofillAssistantAgent::BindPendingReceiver( - mojo::ScopedInterfaceEndpointHandle handle) { - receivers_.Add(this, - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantAgent>( - std::move(handle))); -} - -void MockAutofillAssistantAgent::ResetReceiversForTesting() { - receivers_.Clear(); -} - -// static -void MockAutofillAssistantAgent::RegisterForAllFrames( - content::WebContents* web_contents, - MockAutofillAssistantAgent* agent) { - web_contents->GetPrimaryMainFrame()->ForEachRenderFrameHost( - [agent](content::RenderFrameHost* host) { - host->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating( - &MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(agent))); - }); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h b/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h deleted file mode 100644 index 92e77409..0000000 --- a/components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h +++ /dev/null
@@ -1,60 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_MOCK_AUTOFILL_ASSISTANT_AGENT_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_MOCK_AUTOFILL_ASSISTANT_AGENT_H_ - -#include "base/callback.h" -#include "base/time/time.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" -#include "content/public/browser/web_contents.h" -#include "mojo/public/cpp/bindings/associated_receiver_set.h" -#include "mojo/public/cpp/bindings/pending_associated_receiver.h" -#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" -#include "testing/gmock/include/gmock/gmock.h" - -namespace autofill_assistant { - -class MockAutofillAssistantAgent : public mojom::AutofillAssistantAgent { - public: - MockAutofillAssistantAgent(); - ~MockAutofillAssistantAgent() override; - - void BindPendingReceiver(mojo::ScopedInterfaceEndpointHandle handle); - static void RegisterForAllFrames(content::WebContents* web_contents, - MockAutofillAssistantAgent* agent); - - void ResetReceiversForTesting(); - - MOCK_METHOD(void, - GetSemanticNodes, - (int32_t role, - int32_t objective, - bool ignore_objective, - base::TimeDelta model_timeout, - base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)> callback), - (override)); - MOCK_METHOD(void, - SetElementValue, - (int32_t backend_node_id, - const std::u16string& value, - bool send_events, - base::OnceCallback<void(bool)> callback), - (override)); - MOCK_METHOD(void, - SetElementChecked, - (int32_t backend_node_id, - bool checked, - bool send_events, - base::OnceCallback<void(bool)> callback), - (override)); - - private: - mojo::AssociatedReceiverSet<mojom::AutofillAssistantAgent> receivers_; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_MOCK_AUTOFILL_ASSISTANT_AGENT_H_
diff --git a/components/autofill_assistant/browser/web/mock_web_controller.cc b/components/autofill_assistant/browser/web/mock_web_controller.cc index 87bd0520..58d28a8 100644 --- a/components/autofill_assistant/browser/web/mock_web_controller.cc +++ b/components/autofill_assistant/browser/web/mock_web_controller.cc
@@ -10,8 +10,7 @@ : WebController(/* web_contents= */ nullptr, /* devtools_client= */ nullptr, /* user_data= */ nullptr, - /* log_info= */ nullptr, - /* annotate_dom_model_service= */ nullptr) {} + /* log_info= */ nullptr) {} MockWebController::~MockWebController() {} } // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/web/semantic_element_finder.cc b/components/autofill_assistant/browser/web/semantic_element_finder.cc deleted file mode 100644 index 546d41a..0000000 --- a/components/autofill_assistant/browser/web/semantic_element_finder.cc +++ /dev/null
@@ -1,313 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/browser/web/semantic_element_finder.h" - -#include <utility> - -#include "base/barrier_callback.h" -#include "base/time/time.h" -#include "components/autofill_assistant/browser/devtools/devtools_client.h" -#include "components/autofill_assistant/browser/service.pb.h" -#include "components/autofill_assistant/browser/user_data.h" -#include "components/autofill_assistant/browser/user_data_util.h" -#include "components/autofill_assistant/browser/web/element.h" -#include "components/autofill_assistant/browser/web/element_finder_result.h" -#include "components/autofill_assistant/browser/web/js_filter_builder.h" -#include "components/autofill_assistant/browser/web/web_controller_util.h" -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" -#include "content/public/browser/global_routing_id.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/web_contents.h" -#include "element.h" - -namespace autofill_assistant { - -namespace { - -ElementFinderInfoProto::SemanticInferenceStatus -NodeDataStatusToSemanticInferenceStatus( - mojom::NodeDataStatus node_data_status) { - switch (node_data_status) { - case mojom::NodeDataStatus::kSuccess: - return ElementFinderInfoProto::SUCCESS; - case mojom::NodeDataStatus::kUnexpectedError: - return ElementFinderInfoProto::UNEXPECTED_ERROR; - case mojom::NodeDataStatus::kInitializationError: - return ElementFinderInfoProto::INITIALIZATION_ERROR; - case mojom::NodeDataStatus::kModelLoadError: - return ElementFinderInfoProto::MODEL_LOAD_ERROR; - case mojom::NodeDataStatus::kModelLoadTimeout: - return ElementFinderInfoProto::MODEL_LOAD_TIMEOUT; - } -} - -} // namespace - -SemanticElementFinder::SemanticElementFinder( - content::WebContents* web_contents, - DevtoolsClient* devtools_client, - AnnotateDomModelService* annotate_dom_model_service, - const Selector& selector) - : WebContentsObserver(web_contents), - web_contents_(web_contents), - devtools_client_(devtools_client), - annotate_dom_model_service_(annotate_dom_model_service), - selector_(selector) { - DCHECK(annotate_dom_model_service_); - - DCHECK_GT(selector_.proto.filters_size(), 0); - DCHECK(selector_.proto.filters(0).filter_case() == - SelectorProto::Filter::kSemantic); - filter_ = selector_.proto.filters(0).semantic(); -} - -SemanticElementFinder::~SemanticElementFinder() = default; - -void SemanticElementFinder::GiveUpWithError(const ClientStatus& status) { - DCHECK(!status.ok()); - if (!callback_) { - return; - } - - SendResult(status, ElementFinderResult::EmptyResult()); -} - -void SemanticElementFinder::ResultFound(const SemanticNodeResult& node, - const std::string& object_id, - const std::string& devtools_frame_id) { - if (!callback_) { - return; - } - - ElementFinderResult result; - result.SetRenderFrameHostGlobalId(node.id.host_id()); - result.SetObjectId(object_id); - result.SetNodeFrameId(devtools_frame_id); - result.SetBackendNodeId(node.id.backend_node_id()); - - SendResult(OkClientStatus(), result); -} - -void SemanticElementFinder::SendResult(const ClientStatus& status, - const ElementFinderResult& result) { - DCHECK(callback_); - std::move(callback_).Run(status, - std::make_unique<ElementFinderResult>(result)); -} - -void SemanticElementFinder::Start(const ElementFinderResult& start_element, - BaseElementFinder::Callback callback) { - callback_ = std::move(callback); - - auto* start_frame = start_element.render_frame_host(); - if (!start_frame) { - start_frame = web_contents_->GetPrimaryMainFrame(); - } - RunAnnotateDomModel(start_frame); -} - -ElementFinderInfoProto SemanticElementFinder::GetLogInfo() const { - DCHECK(!callback_); // Run after finish. - - ElementFinderInfoProto info; - for (auto node_data_status : node_data_frame_status_) { - info.mutable_semantic_inference_result()->add_status_per_frame( - NodeDataStatusToSemanticInferenceStatus(node_data_status)); - } - for (const auto& semantic_node_result : semantic_node_results_) { - auto* predicted_element = - info.mutable_semantic_inference_result()->add_predicted_elements(); - predicted_element->set_backend_node_id( - semantic_node_result.id.backend_node_id()); - *predicted_element->mutable_semantic_filter() = filter_; - // TODO(b/217160707): For the ignore_objective case this is not correct - // and the inferred objective should be returned from the Agent and used - // here. - if (semantic_node_result.used_override) { - predicted_element->set_used_override(semantic_node_result.used_override); - } - } - return info; -} - -void SemanticElementFinder::RunAnnotateDomModel( - content::RenderFrameHost* start_frame) { - DCHECK(expected_frame_ids_.empty()); - - start_frame->ForEachRenderFrameHost([this](content::RenderFrameHost* host) { - if (host->IsRenderFrameLive()) { - expected_frame_ids_.insert(host->GetGlobalId()); - } - }); - - if (expected_frame_ids_.empty()) { - GiveUpWithError(ClientStatus(ELEMENT_RESOLUTION_FAILED)); - return; - } - - timer_ = std::make_unique<base::OneShotTimer>(); - timer_->Start(FROM_HERE, base::Milliseconds(filter_.model_timeout_ms()), - base::BindOnce(&SemanticElementFinder::OnTimeout, - weak_ptr_factory_.GetWeakPtr())); - - for (const auto& host_id : expected_frame_ids_) { - RunAnnotateDomModelOnFrame(host_id); - } -} - -void SemanticElementFinder::OnTimeout() { - Finalize(); -} - -void SemanticElementFinder::RunAnnotateDomModelOnFrame( - const content::GlobalRenderFrameHostId& host_id) { - content::RenderFrameHost* render_frame_host = - content::RenderFrameHost::FromID(host_id); - if (!render_frame_host) { - GiveUpWithError(ClientStatus(ELEMENT_RESOLUTION_FAILED)); - return; - } - - auto* driver = ContentAutofillAssistantDriver::GetOrCreateForRenderFrameHost( - render_frame_host, annotate_dom_model_service_); - if (!driver) { - GiveUpWithError(ClientStatus(ELEMENT_RESOLUTION_FAILED)); - return; - } - - driver->GetAutofillAssistantAgent()->GetSemanticNodes( - filter_.role(), filter_.objective(), filter_.ignore_objective(), - base::Milliseconds(filter_.model_timeout_ms()), - base::BindOnce(&SemanticElementFinder::OnRunAnnotateDomModelOnFrame, - weak_ptr_factory_.GetWeakPtr(), host_id)); -} - -void SemanticElementFinder::OnRunAnnotateDomModelOnFrame( - const content::GlobalRenderFrameHostId& host_id, - mojom::NodeDataStatus status, - const std::vector<NodeData>& node_data) { - if (!IsRenderFrameExpected(host_id)) { - // This can occur if the callback is called after the timeout. - return; - } - - node_data_frame_status_.emplace_back(status); - - std::vector<SemanticNodeResult> results; - for (const auto& node : node_data) { - SemanticNodeResult node_result; - node_result.id = GlobalBackendNodeId(host_id, node.backend_node_id); - node_result.used_override = node.used_override; - results.emplace_back(node_result); - } - received_results_.emplace(host_id, std::move(results)); - - MarkRenderFrameProcessed(host_id); -} - -void SemanticElementFinder::OnRunAnnotateDomModel() { - for (const auto& [backend_id, results] : received_results_) { - semantic_node_results_.insert(semantic_node_results_.end(), results.begin(), - results.end()); - } - - // For now we only support finding a single element. - // TODO(b/224746702): Emit multiple ResolveNode calls for the case where the - // result type is not ResultType::kExactlyOneMatch. - if (semantic_node_results_.size() > 1) { - VLOG(1) << __func__ << " Got " << semantic_node_results_.size() - << " matches for " << selector_ << ", when only 1 was expected."; - expected_frame_ids_.clear(); - GiveUpWithError(ClientStatus(TOO_MANY_ELEMENTS)); - return; - } - if (semantic_node_results_.empty()) { - if (expected_frame_ids_.empty()) { - GiveUpWithError(ClientStatus(ELEMENT_RESOLUTION_FAILED)); - } else { - expected_frame_ids_.clear(); - GiveUpWithError(ClientStatus(TIMED_OUT)); - } - return; - } - const auto& semantic_node_result = semantic_node_results_[0]; - - // A non-exitent frame should never happen at this point, better to be safe. - // E.g. crbug/1335205. - // Only assign a devtools frame id if the owning frame is in a different - // process than the main frame (in process frames are not tracked and do - // not have a session id in our |DevtoolsClient|). - std::string devtools_frame_id; - auto* frame = - content::RenderFrameHost::FromID(semantic_node_result.id.host_id()); - if (frame != nullptr && frame->IsRenderFrameLive() && - web_contents_->GetPrimaryMainFrame()->GetProcess() != - frame->GetProcess()) { - devtools_frame_id = frame->GetDevToolsFrameToken().ToString(); - } - - expected_frame_ids_.clear(); - - devtools_client_->GetDOM()->ResolveNode( - dom::ResolveNodeParams::Builder() - .SetBackendNodeId(semantic_node_result.id.backend_node_id()) - .Build(), - devtools_frame_id, - base::BindOnce(&SemanticElementFinder::OnResolveNodeForAnnotateDom, - weak_ptr_factory_.GetWeakPtr(), semantic_node_result, - devtools_frame_id)); -} - -void SemanticElementFinder::OnResolveNodeForAnnotateDom( - const SemanticNodeResult& node, - const std::string& devtools_frame_id, - const DevtoolsClient::ReplyStatus& reply_status, - std::unique_ptr<dom::ResolveNodeResult> result) { - if (result && result->GetObject() && result->GetObject()->HasObjectId()) { - ResultFound(node, result->GetObject()->GetObjectId(), devtools_frame_id); - return; - } - SendResult(ClientStatus(ELEMENT_RESOLUTION_FAILED), - ElementFinderResult::EmptyResult()); -} - -void SemanticElementFinder::RenderFrameDeleted( - content::RenderFrameHost* render_frame_host) { - const content::GlobalRenderFrameHostId host_id = - render_frame_host->GetGlobalId(); - MarkRenderFrameProcessed(host_id); -} - -void SemanticElementFinder::MarkRenderFrameProcessed( - content::GlobalRenderFrameHostId host_id) { - auto it = expected_frame_ids_.find(host_id); - - if (it != expected_frame_ids_.end()) { - expected_frame_ids_.erase(it); - if (expected_frame_ids_.empty()) { - Finalize(); - } - } -} - -void SemanticElementFinder::Finalize() { - if (!timer_) { - // Do nothing if annotation has not been started. - NOTREACHED(); - return; - } - timer_->Stop(); - - OnRunAnnotateDomModel(); -} - -bool SemanticElementFinder::IsRenderFrameExpected( - content::GlobalRenderFrameHostId host_id) { - auto it = expected_frame_ids_.find(host_id); - return it != expected_frame_ids_.end(); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/web/semantic_element_finder.h b/components/autofill_assistant/browser/web/semantic_element_finder.h deleted file mode 100644 index a54d68d9..0000000 --- a/components/autofill_assistant/browser/web/semantic_element_finder.h +++ /dev/null
@@ -1,133 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_SEMANTIC_ELEMENT_FINDER_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_SEMANTIC_ELEMENT_FINDER_H_ - -#include <set> -#include <string> -#include <vector> - -#include "base/memory/raw_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/timer/timer.h" -#include "components/autofill_assistant/browser/client_status.h" -#include "components/autofill_assistant/browser/devtools/devtools/domains/types_dom.h" -#include "components/autofill_assistant/browser/devtools/devtools_client.h" -#include "components/autofill_assistant/browser/selector.h" -#include "components/autofill_assistant/browser/web/base_element_finder.h" -#include "components/autofill_assistant/browser/web/element.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" -#include "components/autofill_assistant/content/common/autofill_assistant_types.mojom.h" -#include "components/autofill_assistant/content/common/node_data.h" -#include "content/public/browser/web_contents_observer.h" - -namespace content { -class WebContents; -class RenderFrameHost; -struct GlobalRenderFrameHostId; -} // namespace content - -namespace autofill_assistant { -class DevtoolsClient; -class ElementFinderResult; - -class SemanticElementFinder : public BaseElementFinder, - public content::WebContentsObserver { - public: - struct SemanticNodeResult { - GlobalBackendNodeId id = GlobalBackendNodeId(nullptr, -1); - bool used_override = false; - }; - - SemanticElementFinder(content::WebContents* web_contents, - DevtoolsClient* devtools_client, - AnnotateDomModelService* annotate_dom_model_service, - const Selector& selector); - ~SemanticElementFinder() override; - - SemanticElementFinder(const SemanticElementFinder&) = delete; - SemanticElementFinder& operator=(const SemanticElementFinder&) = delete; - - void Start(const ElementFinderResult& start_element, - BaseElementFinder::Callback callback) override; - - ElementFinderInfoProto GetLogInfo() const override; - - // content::WebContentsObserver: - void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - - private: - // Returns the given status and no element. This expects an error status. - void GiveUpWithError(const ClientStatus& status); - - // Builds a result from the provided information and returns it with an - // ok status. - void ResultFound(const SemanticNodeResult& node_id, - const std::string& object_id, - const std::string& devtools_frame_id); - - // Call |callback_| with the |status| and |result|. - // The callback may cause a deletion of this object. - void SendResult(const ClientStatus& status, - const ElementFinderResult& result); - - // Run the model annotation on all frames for the current |start_frame|. - void RunAnnotateDomModel(content::RenderFrameHost* start_frame); - - // Runs the model on the frame identified by |host_id|. - void RunAnnotateDomModelOnFrame( - const content::GlobalRenderFrameHostId& host_id); - void OnRunAnnotateDomModelOnFrame( - const content::GlobalRenderFrameHostId& host_id, - mojom::NodeDataStatus status, - const std::vector<NodeData>& node_data); - - // Called once the model has been run on all frames, or when the timeout has - // occurred. - void OnRunAnnotateDomModel(); - - void OnResolveNodeForAnnotateDom( - const SemanticNodeResult& node, - const std::string& devtools_frame_id, - const DevtoolsClient::ReplyStatus& reply_status, - std::unique_ptr<dom::ResolveNodeResult> result); - - // |MarkRenderFrameProcessed| and |MarkAllRenderFramesProcessed| mark frames - // as processed. If no unprocessed frames are left, the pending timeout is - // cancelled and |Finalize| is called. - void MarkRenderFrameProcessed(content::GlobalRenderFrameHostId host_id); - - // Cancel the pending timeout and call |OnRunAnnotateDomModel|. - void Finalize(); - - // Returns true if we expect a call for the given |host_id|. - bool IsRenderFrameExpected(content::GlobalRenderFrameHostId host_id); - - void OnTimeout(); - - const raw_ptr<content::WebContents> web_contents_; - const raw_ptr<DevtoolsClient> devtools_client_; - const raw_ptr<AnnotateDomModelService> annotate_dom_model_service_; - const Selector selector_; - SelectorProto::SemanticFilter filter_; - BaseElementFinder::Callback callback_; - - // Elements gathered through all frames. Unused if the |selector_| does not - // contain |SemanticInformation|. - std::vector<SemanticNodeResult> semantic_node_results_; - std::vector<mojom::NodeDataStatus> node_data_frame_status_; - - std::set<content::GlobalRenderFrameHostId> expected_frame_ids_; - std::map<content::GlobalRenderFrameHostId, std::vector<SemanticNodeResult>> - received_results_; - - std::unique_ptr<base::OneShotTimer> timer_ = nullptr; - - base::WeakPtrFactory<SemanticElementFinder> weak_ptr_factory_{this}; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_WEB_SEMANTIC_ELEMENT_FINDER_H_
diff --git a/components/autofill_assistant/browser/web/semantic_element_finder_browsertest.cc b/components/autofill_assistant/browser/web/semantic_element_finder_browsertest.cc deleted file mode 100644 index 96301ff..0000000 --- a/components/autofill_assistant/browser/web/semantic_element_finder_browsertest.cc +++ /dev/null
@@ -1,879 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/browser/web/web_controller.h" - -#include <memory> -#include <string> -#include <vector> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/callback_helpers.h" -#include "base/run_loop.h" -#include "base/task/single_thread_task_runner.h" -#include "base/test/bind.h" -#include "base/test/gmock_callback_support.h" -#include "base/test/mock_callback.h" -#include "base/threading/thread_task_runner_handle.h" -#include "base/time/time.h" -#include "components/autofill_assistant/browser/actions/wait_for_dom_action.h" -#include "components/autofill_assistant/browser/base_browsertest.h" -#include "components/autofill_assistant/browser/client_status.h" -#include "components/autofill_assistant/browser/fake_script_executor_ui_delegate.h" -#include "components/autofill_assistant/browser/mock_script_executor_delegate.h" -#include "components/autofill_assistant/browser/model.pb.h" -#include "components/autofill_assistant/browser/script.h" -#include "components/autofill_assistant/browser/script_executor.h" -#include "components/autofill_assistant/browser/selector.h" -#include "components/autofill_assistant/browser/service.pb.h" -#include "components/autofill_assistant/browser/service/mock_service.h" -#include "components/autofill_assistant/browser/trigger_context.h" -#include "components/autofill_assistant/browser/user_data.h" -#include "components/autofill_assistant/browser/web/element.h" -#include "components/autofill_assistant/browser/web/element_finder_result.h" -#include "components/autofill_assistant/browser/web/element_finder_result_type.h" -#include "components/autofill_assistant/browser/web/element_store.h" -#include "components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h" -#include "components/autofill_assistant/content/common/autofill_assistant_types.mojom.h" -#include "components/autofill_assistant/content/common/node_data.h" -#include "content/public/browser/render_frame_host.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_observer.h" -#include "content/public/test/browser_test.h" -#include "content/public/test/browser_test_utils.h" -#include "content/public/test/content_browser_test_utils.h" -#include "content/shell/browser/shell.h" -#include "mojo/public/cpp/bindings/associated_receiver_set.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" -#include "url/gurl.h" - -namespace autofill_assistant { -namespace { - -using ::base::test::RunOnceCallback; -using ::testing::_; -using ::testing::Eq; -using ::testing::Invoke; -using ::testing::IsEmpty; -using ::testing::Not; -using ::testing::Return; -using ::testing::WithArgs; - -} // namespace - -class SemanticElementFinderBrowserTest : public BaseBrowserTest, - public content::WebContentsObserver { - public: - SemanticElementFinderBrowserTest() - : BaseBrowserTest(/* start_iframe_server= */ true) {} - - SemanticElementFinderBrowserTest(const SemanticElementFinderBrowserTest&) = - delete; - SemanticElementFinderBrowserTest& operator=( - const SemanticElementFinderBrowserTest&) = delete; - - ~SemanticElementFinderBrowserTest() override {} - - void SetUpOnMainThread() override { - BaseBrowserTest::SetUpOnMainThread(); - - MockAutofillAssistantAgent::RegisterForAllFrames( - shell()->web_contents(), &autofill_assistant_agent_); - - annotate_dom_model_service_ = std::make_unique<AnnotateDomModelService>( - /* opt_guide= */ nullptr, /* background_task_runner= */ nullptr); - web_controller_ = WebController::CreateForWebContents( - shell()->web_contents(), &user_data_, &log_info_, - annotate_dom_model_service_.get(), - /* enable_full_stack_traces= */ true); - - Observe(shell()->web_contents()); - } - - void FindElement(const Selector& selector, - ClientStatus* status_out, - ElementFinderResult* result_out) { - base::RunLoop run_loop; - web_controller_->FindElement( - selector, /* strict_mode= */ true, - base::BindOnce(&SemanticElementFinderBrowserTest::OnFindElement, - base::Unretained(this), run_loop.QuitClosure(), - base::Unretained(status_out), - base::Unretained(result_out))); - run_loop.Run(); - } - - void OnFindElement(base::OnceClosure done_callback, - ClientStatus* status_out, - ElementFinderResult* result_out, - const ClientStatus& status, - std::unique_ptr<ElementFinderResult> result) { - ASSERT_TRUE(result); - std::move(done_callback).Run(); - if (status_out) - *status_out = status; - if (result_out) - *result_out = *result; - } - - void RunStrictElementCheck(const Selector& selector, bool expected_result) { - ClientStatus status; - ElementFinderResult ignored_element; - FindElement(selector, &status, &ignored_element); - EXPECT_EQ(expected_result, status.ok()) - << "selector: " << selector << " status: " << expected_result; - } - - void FindElementExpectEmptyResult(const Selector& selector) { - ClientStatus status; - ElementFinderResult element; - FindElement(selector, &status, &element); - EXPECT_EQ(ELEMENT_RESOLUTION_FAILED, status.proto_status()); - EXPECT_THAT(element.object_id(), IsEmpty()); - } - - void OnScriptFinished(base::OnceClosure done_callback, - const ScriptExecutor::Result& result) { - std::move(done_callback).Run(); - } - - ClientStatus RunWaitForDom( - const ActionProto& wait_for_dom_action, - bool use_observers, - base::OnceCallback<void(ScriptExecutor*)> run_expectations) { - MockScriptExecutorDelegate mock_script_executor_delegate; - ON_CALL(mock_script_executor_delegate, GetWebController) - .WillByDefault(Return(web_controller_.get())); - TriggerContext trigger_context; - if (use_observers) { - trigger_context.SetScriptParameters(std::make_unique<ScriptParameters>( - base::flat_map<std::string, std::string>{ - {"ENABLE_OBSERVER_WAIT_FOR_DOM", "true"}})); - } - - MockService mock_service; - ActionsResponseProto actions_response; - *actions_response.add_actions() = wait_for_dom_action; - std::string serialized_actions_response; - actions_response.SerializeToString(&serialized_actions_response); - EXPECT_CALL(mock_service, GetActions) - .WillOnce(RunOnceCallback<5>(200, serialized_actions_response, - ServiceRequestSender::ResponseInfo{})); - - std::vector<ProcessedActionProto> captured_processed_actions; - EXPECT_CALL(mock_service, GetNextActions) - .WillOnce(WithArgs<3, 6>( - [&captured_processed_actions]( - const std::vector<ProcessedActionProto>& processed_actions, - ServiceRequestSender::ResponseCallback callback) { - captured_processed_actions = processed_actions; - - // Send empty response to stop the script executor. - std::move(callback).Run(200, std::string(), - ServiceRequestSender::ResponseInfo{}); - })); - ON_CALL(mock_script_executor_delegate, GetTriggerContext()) - .WillByDefault(Return(&trigger_context)); - GURL test_script_url("https://example.com"); - ON_CALL(mock_script_executor_delegate, GetScriptURL()) - .WillByDefault(testing::ReturnRef(test_script_url)); - std::vector<std::unique_ptr<Script>> ordered_interrupts; - FakeScriptExecutorUiDelegate fake_script_executor_ui_delegate; - UserData fake_user_data; - ScriptExecutor script_executor( - /* script_path= */ std::string(), - /* additional_context= */ std::make_unique<TriggerContext>(), - /* global_payload= */ std::string(), - /* script_payload= */ std::string(), - /* listener= */ nullptr, &ordered_interrupts, - &mock_script_executor_delegate, &mock_service, - &fake_script_executor_ui_delegate, - /* is_interrupt_executor= */ false); - base::RunLoop run_loop; - script_executor.Run( - &fake_user_data, - base::BindOnce(&SemanticElementFinderBrowserTest::OnScriptFinished, - base::Unretained(this), run_loop.QuitClosure())); - run_loop.Run(); - std::move(run_expectations).Run(&script_executor); - - CHECK_EQ(captured_processed_actions.size(), 1u); - return ClientStatus(captured_processed_actions[0].status()); - } - - int GetBackendNodeId( - Selector selector, - ClientStatus* status_out, - content::GlobalRenderFrameHostId* frame_id_out = nullptr) { - std::unique_ptr<ElementFinderResult> element_result; - int backend_node_id = -1; - - base::RunLoop run_loop_1; - web_controller_->FindElement( - selector, true, - base::BindLambdaForTesting( - [&](const ClientStatus& status, - std::unique_ptr<ElementFinderResult> result) { - element_result = std::move(result); - *status_out = status; - run_loop_1.Quit(); - })); - run_loop_1.Run(); - if (!status_out->ok()) { - return backend_node_id; - } - - if (frame_id_out) { - *frame_id_out = element_result->render_frame_host()->GetGlobalId(); - } - - // Second part in sequence, lookup backend node id. - base::RunLoop run_loop_2; - web_controller_->GetBackendNodeId( - *element_result, - base::BindLambdaForTesting([&](const ClientStatus& status, int id) { - *status_out = status; - backend_node_id = id; - run_loop_2.Quit(); - })); - run_loop_2.Run(); - - log_info_.Clear(); - return backend_node_id; - } - - std::string GetFieldValue(Selector selector, ClientStatus* status_out) { - std::unique_ptr<ElementFinderResult> element_result; - std::string value; - - base::RunLoop run_loop_1; - web_controller_->FindElement( - selector, true, - base::BindLambdaForTesting( - [&](const ClientStatus& status, - std::unique_ptr<ElementFinderResult> result) { - element_result = std::move(result); - *status_out = status; - run_loop_1.Quit(); - })); - run_loop_1.Run(); - if (!status_out->ok()) { - return value; - } - - base::RunLoop run_loop_2; - web_controller_->GetFieldValue( - *element_result, - base::BindLambdaForTesting( - [&](const ClientStatus& status, const std::string& element_value) { - *status_out = status; - value = element_value; - run_loop_2.Quit(); - })); - run_loop_2.Run(); - - log_info_.Clear(); - return value; - } - - protected: - std::unique_ptr<WebController> web_controller_; - UserData user_data_; - ProcessedActionStatusDetailsProto log_info_; - MockAutofillAssistantAgent autofill_assistant_agent_; - std::unique_ptr<AnnotateDomModelService> annotate_dom_model_service_; -}; - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - WaitForDomForSemanticElement) { - // This element is unique. - SelectorProto baseline_selector = ToSelectorProto("#select"); - - ClientStatus element_status; - int backend_node_id = - GetBackendNodeId(Selector(baseline_selector), &element_status); - EXPECT_TRUE(element_status.ok()); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - // Capture any other frames. - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - ActionProto action_proto; - auto* wait_for_dom = action_proto.mutable_wait_for_dom(); - auto* condition = wait_for_dom->mutable_wait_condition(); - condition->mutable_client_id()->set_identifier("e"); - condition->set_require_unique_element(true); - auto* semantic_filter = - condition->mutable_match()->add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - base::MockCallback<base::OnceCallback<void(ScriptExecutor*)>> - run_expectations; - EXPECT_CALL(run_expectations, Run(_)) - .WillOnce([](ScriptExecutor* script_executor) { - EXPECT_TRUE(script_executor->GetElementStore()->HasElement("e")); - }); - ClientStatus status = RunWaitForDom(action_proto, /* use_observers= */ false, - run_expectations.Get()); - EXPECT_EQ(status.proto_status(), ACTION_APPLIED); - - ASSERT_EQ(log_info_.element_finder_info().size(), 1); - const auto& result = - log_info_.element_finder_info(0).semantic_inference_result(); - ASSERT_EQ(1, result.predicted_elements().size()); - EXPECT_EQ(backend_node_id, result.predicted_elements(0).backend_node_id()); - EXPECT_THAT(1, result.predicted_elements(0).semantic_filter().role()); - EXPECT_THAT(2, result.predicted_elements(0).semantic_filter().objective()); - EXPECT_FALSE(result.predicted_elements(0).used_override()); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - ElementExistenceCheckWithSemanticModel) { - ClientStatus status; - int backend_node_id = GetBackendNodeId(Selector({"#button"}), &status); - EXPECT_TRUE(status.ok()); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - // Capture any other frames. - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - // We pretend that the button is the correct element. - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - RunStrictElementCheck(Selector(proto), true); - - ASSERT_EQ(log_info_.element_finder_info().size(), 1); - const auto& result = - log_info_.element_finder_info(0).semantic_inference_result(); - ASSERT_EQ(1, result.predicted_elements().size()); - EXPECT_EQ(backend_node_id, result.predicted_elements(0).backend_node_id()); - EXPECT_THAT(1, result.predicted_elements(0).semantic_filter().role()); - EXPECT_THAT(2, result.predicted_elements(0).semantic_filter().objective()); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - ElementExistenceCheckWithSemanticModelOOPIF) { - // Frames return an error by default. - EXPECT_CALL(autofill_assistant_agent_, GetSemanticNodes) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - ClientStatus status; - content::GlobalRenderFrameHostId frame_id; - int backend_node_id = GetBackendNodeId( - Selector({"#iframeExternal", "#button"}), &status, &frame_id); - EXPECT_TRUE(status.ok()); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - MockAutofillAssistantAgent frame_autofill_assistant_agent_; - content::RenderFrameHost::FromID(frame_id) - ->GetRemoteAssociatedInterfaces() - ->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating( - &MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(&frame_autofill_assistant_agent_))); - EXPECT_CALL(frame_autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})); - - // We pretend that the button is the correct element. - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - RunStrictElementCheck(Selector(proto), true); - - ASSERT_EQ(log_info_.element_finder_info().size(), 1); - const auto& result = - log_info_.element_finder_info(0).semantic_inference_result(); - ASSERT_EQ(1, result.predicted_elements().size()); - EXPECT_EQ(backend_node_id, result.predicted_elements(0).backend_node_id()); - EXPECT_THAT(1, result.predicted_elements(0).semantic_filter().role()); - EXPECT_THAT(2, result.predicted_elements(0).semantic_filter().objective()); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - ElementExistenceCheckWithSemanticModelNotFound) { - // All frames return an empty list as a result. - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillRepeatedly(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{})); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - FindElementExpectEmptyResult(Selector(proto)); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - ElementExistenceCheckWithSemanticMultipleFound) { - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - NodeData node_data; - node_data.backend_node_id = 5; - NodeData node_data_other; - node_data_other.backend_node_id = 13; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data_other})) - // Capture any other frames. - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - // Two elements are found in different frames. - ClientStatus status; - FindElement(Selector(proto), &status, nullptr); - EXPECT_EQ(TOO_MANY_ELEMENTS, status.proto_status()); -} - -IN_PROC_BROWSER_TEST_F( - SemanticElementFinderBrowserTest, - ElementExistenceCheckWithSemanticModelUsesIgnoreObjective) { - NodeData node_data; - node_data.backend_node_id = 5; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, true, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - // All we want is this to be propagated to the GetSemanticNodes call as - // configured in the previous expectation. - semantic_filter->set_ignore_objective(true); - - ClientStatus ignore_status; - FindElement(Selector(proto), &ignore_status, nullptr); - - // TODO(b/217160707): For now we expect the originally passed in semantic info - // to be logged instead of the objective inferred by the model. - ASSERT_EQ(log_info_.element_finder_info().size(), 1); - const auto& result = - log_info_.element_finder_info(0).semantic_inference_result(); - ASSERT_EQ(1, result.predicted_elements().size()); - EXPECT_EQ(5, result.predicted_elements(0).backend_node_id()); - EXPECT_THAT(1, result.predicted_elements(0).semantic_filter().role()); - EXPECT_THAT(2, result.predicted_elements(0).semantic_filter().objective()); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - FindOptionInSemanticSelect) { - ClientStatus select_status; - int select_backend_node_id = - GetBackendNodeId(Selector({"#select"}), &select_status); - EXPECT_TRUE(select_status.ok()); - - NodeData node_data; - node_data.backend_node_id = select_backend_node_id; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - proto.add_filters()->set_css_selector("option:nth-child(2)"); - - ClientStatus option_status; - ElementFinderResult option_result; - FindElement(Selector(proto), &option_status, &option_result); - EXPECT_TRUE(option_status.ok()); - - base::RunLoop run_loop; - web_controller_->GetFieldValue( - option_result, base::BindLambdaForTesting([&](const ClientStatus& status, - const std::string& value) { - EXPECT_TRUE(status.ok()); - EXPECT_EQ(value, "two"); - run_loop.Quit(); - })); - run_loop.Run(); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, FillInputInMainFrame) { - // Frames return an error by default. - EXPECT_CALL(autofill_assistant_agent_, GetSemanticNodes) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - EXPECT_CALL(autofill_assistant_agent_, SetElementValue).Times(0); - - Selector css_selector({"#input1"}); - ClientStatus input_status; - content::GlobalRenderFrameHostId frame_id; - int backend_node_id = - GetBackendNodeId(css_selector, &input_status, &frame_id); - ASSERT_TRUE(input_status.ok()); - - auto* frame = content::RenderFrameHost::FromID(frame_id); - ASSERT_TRUE(frame != nullptr); - EXPECT_THAT(frame, Eq(web_contents()->GetPrimaryMainFrame())); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - MockAutofillAssistantAgent frame_autofill_assistant_agent_; - frame->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating(&MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(&frame_autofill_assistant_agent_))); - EXPECT_CALL(frame_autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, _, _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})); - std::u16string expected_value = u"native"; - EXPECT_CALL(frame_autofill_assistant_agent_, - SetElementValue(backend_node_id, expected_value, - /* send_events= */ true, _)) - .WillOnce(RunOnceCallback<3>(true)); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - ElementFinderResult element; - ClientStatus element_status; - FindElement(Selector(proto), &element_status, &element); - ASSERT_TRUE(element_status.ok()); - - base::RunLoop devtools_run_loop; - web_controller_->SetValueAttribute( - "devtools", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - devtools_run_loop.Quit(); - })); - devtools_run_loop.Run(); - ClientStatus check_status; - EXPECT_EQ(GetFieldValue(css_selector, &check_status), "devtools"); - EXPECT_TRUE(check_status.ok()); - - base::RunLoop native_run_loop; - web_controller_->SetNativeValue( - "native", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - native_run_loop.Quit(); - })); - native_run_loop.Run(); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, FillInputInIFrame) { - // Frames return an error by default. - EXPECT_CALL(autofill_assistant_agent_, GetSemanticNodes) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - EXPECT_CALL(autofill_assistant_agent_, SetElementValue).Times(0); - - Selector css_selector({"#iframe", "#input"}); - ClientStatus input_status; - content::GlobalRenderFrameHostId frame_id; - int backend_node_id = - GetBackendNodeId(css_selector, &input_status, &frame_id); - ASSERT_TRUE(input_status.ok()); - - auto* frame = content::RenderFrameHost::FromID(frame_id); - ASSERT_TRUE(frame != nullptr); - EXPECT_THAT(frame, Not(Eq(web_contents()->GetPrimaryMainFrame()))); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - MockAutofillAssistantAgent frame_autofill_assistant_agent_; - frame->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating(&MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(&frame_autofill_assistant_agent_))); - EXPECT_CALL(frame_autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, _, _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})); - std::u16string expected_value = u"native"; - EXPECT_CALL(frame_autofill_assistant_agent_, - SetElementValue(backend_node_id, expected_value, - /* send_events= */ true, _)) - .WillOnce(RunOnceCallback<3>(true)); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - ElementFinderResult element; - ClientStatus element_status; - FindElement(Selector(proto), &element_status, &element); - ASSERT_TRUE(element_status.ok()); - - base::RunLoop devtools_run_loop; - web_controller_->SetValueAttribute( - "devtools", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - devtools_run_loop.Quit(); - })); - devtools_run_loop.Run(); - ClientStatus check_status; - EXPECT_EQ(GetFieldValue(css_selector, &check_status), "devtools"); - EXPECT_TRUE(check_status.ok()); - - base::RunLoop native_run_loop; - web_controller_->SetNativeValue( - "native", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - native_run_loop.Quit(); - })); - native_run_loop.Run(); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, FillInputInOOPIF) { - // Frames return an error by default. - EXPECT_CALL(autofill_assistant_agent_, GetSemanticNodes) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - EXPECT_CALL(autofill_assistant_agent_, SetElementValue).Times(0); - - Selector css_selector({"#iframeExternal", "#input"}); - ClientStatus input_status; - content::GlobalRenderFrameHostId frame_id; - int backend_node_id = - GetBackendNodeId(css_selector, &input_status, &frame_id); - ASSERT_TRUE(input_status.ok()); - - auto* frame = content::RenderFrameHost::FromID(frame_id); - ASSERT_TRUE(frame != nullptr); - EXPECT_THAT(frame, Not(Eq(web_contents()->GetPrimaryMainFrame()))); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - MockAutofillAssistantAgent frame_autofill_assistant_agent_; - frame->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating(&MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(&frame_autofill_assistant_agent_))); - EXPECT_CALL(frame_autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, _, _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})); - std::u16string expected_value = u"native"; - EXPECT_CALL(frame_autofill_assistant_agent_, - SetElementValue(backend_node_id, expected_value, - /* send_events= */ true, _)) - .WillOnce(RunOnceCallback<3>(true)); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - ElementFinderResult element; - ClientStatus element_status; - FindElement(Selector(proto), &element_status, &element); - ASSERT_TRUE(element_status.ok()); - - base::RunLoop devtools_run_loop; - web_controller_->SetValueAttribute( - "devtools", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - devtools_run_loop.Quit(); - })); - devtools_run_loop.Run(); - ClientStatus check_status; - EXPECT_EQ(GetFieldValue(css_selector, &check_status), "devtools"); - EXPECT_TRUE(check_status.ok()); - - base::RunLoop native_run_loop; - web_controller_->SetNativeValue( - "native", element, - base::BindLambdaForTesting([&](const ClientStatus& status) { - EXPECT_TRUE(status.ok()); - native_run_loop.Quit(); - })); - native_run_loop.Run(); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, HandlesDeletedIframe) { - // Frames return an error by default. - EXPECT_CALL(autofill_assistant_agent_, GetSemanticNodes) - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - EXPECT_CALL(autofill_assistant_agent_, SetElementValue).Times(0); - - Selector css_selector({"#iframe", "#input"}); - ClientStatus input_status; - content::GlobalRenderFrameHostId frame_id; - int backend_node_id = - GetBackendNodeId(css_selector, &input_status, &frame_id); - ASSERT_TRUE(input_status.ok()); - - auto* frame = content::RenderFrameHost::FromID(frame_id); - ASSERT_TRUE(frame != nullptr); - EXPECT_THAT(frame, Not(Eq(web_contents()->GetPrimaryMainFrame()))); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - MockAutofillAssistantAgent frame_autofill_assistant_agent_; - frame->GetRemoteAssociatedInterfaces()->OverrideBinderForTesting( - mojom::AutofillAssistantAgent::Name_, - base::BindRepeating(&MockAutofillAssistantAgent::BindPendingReceiver, - base::Unretained(&frame_autofill_assistant_agent_))); - EXPECT_CALL(frame_autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, _, _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - semantic_filter->set_model_timeout_ms(100); - - ElementFinderResult element; - ClientStatus element_status; - - base::RunLoop run_loop; - web_controller_->FindElement( - Selector(proto), /* strict_mode= */ true, - base::BindOnce(&SemanticElementFinderBrowserTest::OnFindElement, - base::Unretained(this), run_loop.QuitClosure(), - base::Unretained(&element_status), - base::Unretained(&element))); - - EXPECT_TRUE(content::ExecJs(shell(), - R"javascript( - document.querySelector('[name="test_iframe"]').remove(); - )javascript")); - - run_loop.Run(); - - EXPECT_FALSE(element_status.ok()); - EXPECT_EQ(element_status.proto_status(), ELEMENT_RESOLUTION_FAILED); -} - -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, RespectsTimeout) { - // This element is unique. - SelectorProto baseline_selector = ToSelectorProto("#select"); - - ClientStatus element_status; - int backend_node_id = - GetBackendNodeId(Selector(baseline_selector), &element_status); - EXPECT_TRUE(element_status.ok()); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - - // Reset receivers to simulate deletion during the callback - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(10), _)) - .WillOnce(Invoke( - [this] { autofill_assistant_agent_.ResetReceiversForTesting(); })); - - SelectorProto proto; - auto* semantic_filter = proto.add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - semantic_filter->set_model_timeout_ms(10); - proto.add_filters()->set_css_selector("option:nth-child(2)"); - - ClientStatus option_status; - ElementFinderResult option_result; - FindElement(Selector(proto), &option_status, &option_result); - EXPECT_FALSE(option_status.ok()); - EXPECT_EQ(option_status.proto_status(), TIMED_OUT); -} - -#if BUILDFLAG(IS_ANDROID) -IN_PROC_BROWSER_TEST_F(SemanticElementFinderBrowserTest, - WaitForDomForSemanticElementWithOverride) { - // This element is unique. - SelectorProto baseline_selector = ToSelectorProto("#select"); - - ClientStatus element_status; - int backend_node_id = - GetBackendNodeId(Selector(baseline_selector), &element_status); - EXPECT_TRUE(element_status.ok()); - - NodeData node_data; - node_data.backend_node_id = backend_node_id; - node_data.used_override = true; - EXPECT_CALL(autofill_assistant_agent_, - GetSemanticNodes(1, 2, false, base::Milliseconds(5000), _)) - .WillOnce(RunOnceCallback<4>(mojom::NodeDataStatus::kSuccess, - std::vector<NodeData>{node_data})) - // Capture any other frames. - .WillRepeatedly(RunOnceCallback<4>( - mojom::NodeDataStatus::kUnexpectedError, std::vector<NodeData>())); - - ActionProto action_proto; - auto* wait_for_dom = action_proto.mutable_wait_for_dom(); - auto* condition = wait_for_dom->mutable_wait_condition(); - condition->mutable_client_id()->set_identifier("e"); - condition->set_require_unique_element(true); - auto* semantic_filter = - condition->mutable_match()->add_filters()->mutable_semantic(); - semantic_filter->set_role(1); - semantic_filter->set_objective(2); - - base::MockCallback<base::OnceCallback<void(ScriptExecutor*)>> - run_expectations; - EXPECT_CALL(run_expectations, Run(_)) - .WillOnce([](ScriptExecutor* script_executor) { - EXPECT_TRUE(script_executor->GetElementStore()->HasElement("e")); - }); - ClientStatus status = RunWaitForDom(action_proto, /* use_observers= */ false, - run_expectations.Get()); - EXPECT_EQ(status.proto_status(), ACTION_APPLIED); - ASSERT_EQ(log_info_.element_finder_info().size(), 1); - const auto& result = - log_info_.element_finder_info(0).semantic_inference_result(); - ASSERT_EQ(1, result.predicted_elements().size()); - EXPECT_EQ(backend_node_id, result.predicted_elements(0).backend_node_id()); - EXPECT_THAT(1, result.predicted_elements(0).semantic_filter().role()); - EXPECT_THAT(2, result.predicted_elements(0).semantic_filter().objective()); - EXPECT_TRUE(result.predicted_elements(0).used_override()); -} -#endif - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/web/web_controller.cc b/components/autofill_assistant/browser/web/web_controller.cc index 110f76d..86dabb7 100644 --- a/components/autofill_assistant/browser/web/web_controller.cc +++ b/components/autofill_assistant/browser/web/web_controller.cc
@@ -36,8 +36,6 @@ #include "components/autofill_assistant/browser/web/element_finder_result_type.h" #include "components/autofill_assistant/browser/web/selector_observer.h" #include "components/autofill_assistant/browser/web/web_controller_util.h" -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" @@ -424,27 +422,23 @@ content::WebContents* web_contents, const UserData* user_data, ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service, bool enable_full_stack_traces) { return std::make_unique<WebController>( web_contents, std::make_unique<DevtoolsClient>( content::DevToolsAgentHost::GetOrCreateFor(web_contents), enable_full_stack_traces), - user_data, log_info, annotate_dom_model_service); + user_data, log_info); } -WebController::WebController( - content::WebContents* web_contents, - std::unique_ptr<DevtoolsClient> devtools_client, - const UserData* user_data, - ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service) +WebController::WebController(content::WebContents* web_contents, + std::unique_ptr<DevtoolsClient> devtools_client, + const UserData* user_data, + ProcessedActionStatusDetailsProto* log_info) : web_contents_(web_contents), devtools_client_(std::move(devtools_client)), user_data_(user_data), - log_info_(log_info), - annotate_dom_model_service_(annotate_dom_model_service) {} + log_info_(log_info) {} WebController::~WebController() {} @@ -918,8 +912,8 @@ ElementFinderResultType result_type, ElementFinder::Callback callback) { auto finder = std::make_unique<ElementFinder>( - web_contents_, devtools_client_.get(), user_data_, log_info_, - annotate_dom_model_service_, selector, result_type); + web_contents_, devtools_client_.get(), user_data_, log_info_, selector, + result_type); auto* ptr = finder.get(); pending_workers_.emplace_back(std::move(finder)); @@ -1654,60 +1648,6 @@ WebControllerErrorInfoProto::EXECUTE_JS, std::move(callback)); } -ContentAutofillAssistantDriver* WebController::GetDriverForElement( - const ElementFinderResult& element) const { - if (!element.backend_node_id()) { - DVLOG(1) << __func__ - << "No backend node id on element intended for native execution."; - return nullptr; - } - - auto* render_frame_host = element.render_frame_host(); - DCHECK(render_frame_host); - - return ContentAutofillAssistantDriver::GetOrCreateForRenderFrameHost( - render_frame_host, annotate_dom_model_service_); -} - -void WebController::SetNativeValue( - const std::string& value, - const ElementFinderResult& element, - base::OnceCallback<void(const ClientStatus&)> callback) { - ContentAutofillAssistantDriver* driver = GetDriverForElement(element); - if (!driver) { - std::move(callback).Run(UnexpectedErrorStatus(__FILE__, __LINE__)); - return; - } - driver->GetAutofillAssistantAgent()->SetElementValue( - *element.backend_node_id(), base::UTF8ToUTF16(value), - /* send_events= */ true, - base::BindOnce(&WebController::OnSetNativeExecution, - weak_ptr_factory_.GetWeakPtr(), std::move(callback))); -} - -void WebController::SetNativeChecked( - bool checked, - const ElementFinderResult& element, - base::OnceCallback<void(const ClientStatus&)> callback) { - ContentAutofillAssistantDriver* driver = GetDriverForElement(element); - if (!driver) { - std::move(callback).Run(UnexpectedErrorStatus(__FILE__, __LINE__)); - return; - } - driver->GetAutofillAssistantAgent()->SetElementChecked( - *element.backend_node_id(), checked, - /* send_events= */ true, - base::BindOnce(&WebController::OnSetNativeExecution, - weak_ptr_factory_.GetWeakPtr(), std::move(callback))); -} - -void WebController::OnSetNativeExecution( - base::OnceCallback<void(const ClientStatus&)> callback, - bool success) const { - std::move(callback).Run(success ? OkClientStatus() - : UnexpectedErrorStatus(__FILE__, __LINE__)); -} - base::WeakPtr<WebController> WebController::GetWeakPtr() { return weak_ptr_factory_.GetWeakPtr(); }
diff --git a/components/autofill_assistant/browser/web/web_controller.h b/components/autofill_assistant/browser/web/web_controller.h index ac095cb7a..c37a197 100644 --- a/components/autofill_assistant/browser/web/web_controller.h +++ b/components/autofill_assistant/browser/web/web_controller.h
@@ -32,7 +32,6 @@ #include "components/autofill_assistant/browser/web/selector_observer.h" #include "components/autofill_assistant/browser/web/send_keyboard_input_worker.h" #include "components/autofill_assistant/browser/web/web_controller_worker.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" #include "components/autofill_assistant/core/public/autofill_assistant_intent.h" #include "content/public/browser/web_contents_observer.h" #include "third_party/icu/source/common/unicode/umachine.h" @@ -53,7 +52,6 @@ } // namespace content namespace autofill_assistant { -class ContentAutofillAssistantDriver; class ElementFinderResult; enum class ElementFinderResultType; @@ -68,8 +66,8 @@ // multiple operations, whether in sequence or in parallel. class WebController { public: - // Create web controller for a given |web_contents|. |user_data|, |log_info| - // and |annotate_dom_model_service| (if not nullptr) must be valid + // Create web controller for a given |web_contents|. |user_data|, and + // |log_info| (if not nullptr) must be valid // for the lifetime of the controller. |enable_full_stack_traces| should only // be enabled if the thrown exceptions will be caught and handled, otherwise // this will unnecessarily decrease performance. @@ -77,16 +75,14 @@ content::WebContents* web_contents, const UserData* user_data, ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service, bool enable_full_stack_traces); - // |web_contents|, |user_data|, |log_info| and |annotate_dom_model_service| + // |web_contents|, |user_data| and |log_info| // (if not nullptr) must outlive this web controller. WebController(content::WebContents* web_contents, std::unique_ptr<DevtoolsClient> devtools_client, const UserData* user_data, - ProcessedActionStatusDetailsProto* log_info, - AnnotateDomModelService* annotate_dom_model_service); + ProcessedActionStatusDetailsProto* log_info); WebController(const WebController&) = delete; WebController& operator=(const WebController&) = delete; @@ -391,16 +387,6 @@ const ElementFinderResult& element, base::OnceCallback<void(const ClientStatus&)> callback); - virtual void SetNativeValue( - const std::string& value, - const ElementFinderResult& element, - base::OnceCallback<void(const ClientStatus&)> callback); - - virtual void SetNativeChecked( - bool checked, - const ElementFinderResult& element, - base::OnceCallback<void(const ClientStatus&)> callback); - virtual base::WeakPtr<WebController> GetWeakPtr(); private: @@ -545,14 +531,6 @@ void OnDispatchJsEvent(base::OnceCallback<void(const ClientStatus&)> callback, const DevtoolsClient::ReplyStatus& reply_status, std::unique_ptr<runtime::EvaluateResult> result) const; - void OnSetNativeExecution( - base::OnceCallback<void(const ClientStatus&)> callback, - bool success) const; - // Get the driver for the given element finder results. Will return a nullptr - // if the driver is not available. Requires that the element has a backend - // node id. - autofill_assistant::ContentAutofillAssistantDriver* GetDriverForElement( - const ElementFinderResult& element) const; // Weak pointer is fine here since it must outlive this web controller, which // is guaranteed by the owner of this object. @@ -562,10 +540,6 @@ // Must not be |nullptr| and outlive this web controller. const raw_ptr<const UserData, DanglingUntriaged> user_data_; const raw_ptr<ProcessedActionStatusDetailsProto, DanglingUntriaged> log_info_; - // Can be |nullptr|, if not must outlive this web controller. - const raw_ptr<AnnotateDomModelService, DanglingUntriaged> - annotate_dom_model_service_; - // Currently running workers. std::vector<std::unique_ptr<WebControllerWorker>> pending_workers_;
diff --git a/components/autofill_assistant/browser/web/web_controller_browsertest.cc b/components/autofill_assistant/browser/web/web_controller_browsertest.cc index 1abcd26a..a91238c 100644 --- a/components/autofill_assistant/browser/web/web_controller_browsertest.cc +++ b/components/autofill_assistant/browser/web/web_controller_browsertest.cc
@@ -58,7 +58,6 @@ #include "components/autofill_assistant/browser/web/element_finder_result.h" #include "components/autofill_assistant/browser/web/element_finder_result_type.h" #include "components/autofill_assistant/browser/web/element_store.h" -#include "components/autofill_assistant/browser/web/mock_autofill_assistant_agent.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" @@ -97,12 +96,8 @@ void SetUpOnMainThread() override { BaseBrowserTest::SetUpOnMainThread(); - MockAutofillAssistantAgent::RegisterForAllFrames( - shell()->web_contents(), &autofill_assistant_agent_); - web_controller_ = WebController::CreateForWebContents( shell()->web_contents(), &user_data_, &log_info_, - /* annotate_dom_model_service= */ nullptr, /*enable_full_stack_traces= */ true); Observe(shell()->web_contents()); @@ -1031,7 +1026,6 @@ UserData user_data_; UserModel user_model_; ProcessedActionStatusDetailsProto log_info_; - MockAutofillAssistantAgent autofill_assistant_agent_; }; IN_PROC_BROWSER_TEST_F(WebControllerBrowserTest, ElementExistenceCheck) { @@ -3605,59 +3599,4 @@ EXPECT_NEAR(after_reset_width, initial_width, 1); } -IN_PROC_BROWSER_TEST_F(WebControllerBrowserTest, SetFieldValueThroughNative) { - ClientStatus element_status; - ElementFinderResult input; - FindElement(Selector({"#input1"}), &element_status, &input); - ASSERT_EQ(ACTION_APPLIED, element_status.proto_status()); - - int backend_node_id; - ASSERT_EQ(ACTION_APPLIED, - GetBackendNodeId(input, &backend_node_id).proto_status()); - std::u16string expected_value = u"native"; - EXPECT_CALL(autofill_assistant_agent_, - SetElementValue(backend_node_id, expected_value, - /* send_events= */ true, _)) - .WillOnce(RunOnceCallback<3>(true)); - - ClientStatus fill_status; - base::RunLoop run_loop; - web_controller_->SetNativeValue( - "native", input, - base::BindOnce(&WebControllerBrowserTest::OnClientStatus, - base::Unretained(this), run_loop.QuitClosure(), - &fill_status)); - run_loop.Run(); - - EXPECT_EQ(ACTION_APPLIED, fill_status.proto_status()); -} - -IN_PROC_BROWSER_TEST_F(WebControllerBrowserTest, - SetElementCheckedThroughNative) { - ClientStatus element_status; - ElementFinderResult input; - FindElement(Selector({"#option1"}), &element_status, &input); - ASSERT_EQ(ACTION_APPLIED, element_status.proto_status()); - - int backend_node_id; - ASSERT_EQ(ACTION_APPLIED, - GetBackendNodeId(input, &backend_node_id).proto_status()); - - EXPECT_CALL(autofill_assistant_agent_, - SetElementChecked(backend_node_id, true, - /* send_events= */ true, _)) - .WillOnce(RunOnceCallback<3>(true)); - - ClientStatus fill_status; - base::RunLoop run_loop; - web_controller_->SetNativeChecked( - true, input, - base::BindOnce(&WebControllerBrowserTest::OnClientStatus, - base::Unretained(this), run_loop.QuitClosure(), - &fill_status)); - run_loop.Run(); - - EXPECT_EQ(ACTION_APPLIED, fill_status.proto_status()); -} - } // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/browser/BUILD.gn b/components/autofill_assistant/content/browser/BUILD.gn deleted file mode 100644 index 1433f59..0000000 --- a/components/autofill_assistant/content/browser/BUILD.gn +++ /dev/null
@@ -1,39 +0,0 @@ -# Copyright 2021 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//third_party/protobuf/proto_library.gni") - -static_library("browser") { - sources = [ - "annotate_dom_model_service.cc", - "annotate_dom_model_service.h", - "content_autofill_assistant_driver.cc", - "content_autofill_assistant_driver.h", - ] - - deps = [ - "//base", - "//components/autofill_assistant/content/common:mojo_interfaces", - "//components/autofill_assistant/content/common/proto:proto", - "//components/keyed_service/core", - "//components/optimization_guide/core", - "//components/optimization_guide/proto:optimization_guide_proto", - "//content/public/browser", - "//content/public/common", - "//mojo/public/cpp/bindings", - ] -} - -source_set("unit_tests") { - testonly = true - sources = [ "content_autofill_assistant_driver_unittest.cc" ] - - deps = [ - ":browser", - "//base", - "//base/test:test_support", - "//content/public/browser", - "//content/test:test_support", - ] -}
diff --git a/components/autofill_assistant/content/browser/DEPS b/components/autofill_assistant/content/browser/DEPS deleted file mode 100644 index bc96810..0000000 --- a/components/autofill_assistant/content/browser/DEPS +++ /dev/null
@@ -1,9 +0,0 @@ -include_rules = [ - "+content/public/browser", - "+content/public/test", - "+third_party/blink/public/common", - "+mojo/public/cpp/bindings", - "+components/keyed_service/core", - "+components/optimization_guide", - "+components/optimization_guide/content", -]
diff --git a/components/autofill_assistant/content/browser/annotate_dom_model_service.cc b/components/autofill_assistant/content/browser/annotate_dom_model_service.cc deleted file mode 100644 index 34a82679..0000000 --- a/components/autofill_assistant/content/browser/annotate_dom_model_service.cc +++ /dev/null
@@ -1,154 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" - -#include "base/bind.h" -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/files/file_util.h" -#include "components/optimization_guide/core/optimization_guide_model_provider.h" -#include "components/optimization_guide/proto/models.pb.h" -#include "content/public/browser/browser_thread.h" -#include "mojo/public/cpp/bindings/pending_remote.h" - -namespace autofill_assistant { -namespace { - -// Load the model file at the provided file path. -base::File LoadModelFile(const base::FilePath& model_file_path) { - if (!base::PathExists(model_file_path)) - return base::File(); - - return base::File(model_file_path, - base::File::FLAG_OPEN | base::File::FLAG_READ); -} - -// Close the provided model file. -void CloseModelFile(base::File model_file) { - if (!model_file.IsValid()) - return; - model_file.Close(); -} - -// The maximum number of pending model requests allowed to be kept by the -// AnnotateDomModelService. -constexpr int kMaxPendingRequestsAllowed = 100; - -} // namespace - -AnnotateDomModelService::AnnotateDomModelService( - optimization_guide::OptimizationGuideModelProvider* opt_guide, - const scoped_refptr<base::SequencedTaskRunner>& background_task_runner) - : opt_guide_(opt_guide), background_task_runner_(background_task_runner) { - if (opt_guide_) { - opt_guide_->AddObserverForOptimizationTargetModel( - optimization_guide::proto::OPTIMIZATION_TARGET_AUTOFILL_ASSISTANT, - /* model_metadata= */ absl::nullopt, this); - } -} - -AnnotateDomModelService::~AnnotateDomModelService() = default; - -void AnnotateDomModelService::Shutdown() { - opt_guide_->RemoveObserverForOptimizationTargetModel( - optimization_guide::proto::OPTIMIZATION_TARGET_AUTOFILL_ASSISTANT, this); - opt_guide_ = nullptr; - - // This and the optimization guide are keyed services, currently optimization - // guide is a BrowserContextKeyedService, it will be cleaned first so removing - // the observer should not be performed. - if (model_file_) { - // If the model file is already loaded, it should be closed on a - // background thread. - background_task_runner_->PostTask( - FROM_HERE, base::BindOnce(&CloseModelFile, std::move(*model_file_))); - } - for (auto& pending_request : pending_model_requests_) { - // Clear any pending requests, no model file is acceptable as |Shutdown| is - // happening. - std::move(pending_request).Run(false); - } - pending_model_requests_.clear(); -} - -void AnnotateDomModelService::OnModelUpdated( - optimization_guide::proto::OptimizationTarget optimization_target, - const optimization_guide::ModelInfo& model_info) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (optimization_target != - optimization_guide::proto::OPTIMIZATION_TARGET_AUTOFILL_ASSISTANT) { - return; - } - background_task_runner_->PostTaskAndReplyWithResult( - FROM_HERE, base::BindOnce(&LoadModelFile, model_info.GetModelFilePath()), - base::BindOnce(&AnnotateDomModelService::OnModelFileLoaded, - weak_ptr_factory_.GetWeakPtr(), model_info.GetVersion())); -} - -void AnnotateDomModelService::OnModelFileLoaded(int64_t model_version, - base::File model_file) { - DCHECK_CURRENTLY_ON(content::BrowserThread::UI); - if (!model_file.IsValid()) { - return; - } - - if (model_file_) { - // If the model file is already loaded, it should be closed on a background - // thread. - background_task_runner_->PostTask( - FROM_HERE, base::BindOnce(&CloseModelFile, std::move(*model_file_))); - } - model_file_ = std::move(model_file); - model_version_ = model_version; - for (auto& pending_request : pending_model_requests_) { - if (!pending_request) { - continue; - } - std::move(pending_request).Run(true); - } - pending_model_requests_.clear(); -} - -absl::optional<base::File> AnnotateDomModelService::GetModelFile() const { - if (!model_file_) { - return absl::nullopt; - } - // The model must be valid at this point. - DCHECK(model_file_->IsValid()); - return model_file_->Duplicate(); -} - -absl::optional<int64_t> AnnotateDomModelService::GetModelVersion() const { - return model_version_; -} - -std::string AnnotateDomModelService::GetOverridesPolicy() const { - return overrides_policy_binary_proto_; -} - -bool AnnotateDomModelService::SetOverridesPolicy( - SemanticSelectorPolicy policy) { - return policy.SerializeToString(&overrides_policy_binary_proto_); -} - -void AnnotateDomModelService::NotifyOnModelFileAvailable( - NotifyModelAvailableCallback callback) { - DCHECK(!model_file_); - if (pending_model_requests_.size() < kMaxPendingRequestsAllowed) { - pending_model_requests_.emplace_back(std::move(callback)); - return; - } - std::move(callback).Run(false); -} - -void AnnotateDomModelService::SetModelFileForTest(base::File model_file) { - model_file_ = std::move(model_file); - for (auto& pending_request : pending_model_requests_) { - std::move(pending_request).Run(true); - } - pending_model_requests_.clear(); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/browser/annotate_dom_model_service.h b/components/autofill_assistant/content/browser/annotate_dom_model_service.h deleted file mode 100644 index 779a591..0000000 --- a/components/autofill_assistant/content/browser/annotate_dom_model_service.h +++ /dev/null
@@ -1,102 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_ANNOTATE_DOM_MODEL_SERVICE_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_ANNOTATE_DOM_MODEL_SERVICE_H_ - -#include <memory> -#include <vector> - -#include "base/callback.h" -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/memory/raw_ptr.h" -#include "base/memory/weak_ptr.h" -#include "components/autofill_assistant/content/common/proto/semantic_feature_overrides.pb.h" -#include "components/keyed_service/core/keyed_service.h" -#include "components/optimization_guide/core/optimization_target_model_observer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" - -namespace optimization_guide { -class OptimizationGuideModelProvider; -} // namespace optimization_guide - -namespace autofill_assistant { - -// Service that manages models required to support annotating DOM in the -// browser for Autofill Assistant. Currently, the service should only be used -// in the browser as it relies on the Optimization Guide. -class AnnotateDomModelService - : public KeyedService, - public optimization_guide::OptimizationTargetModelObserver { - public: - using NotifyModelAvailableCallback = base::OnceCallback<void(bool)>; - - AnnotateDomModelService( - optimization_guide::OptimizationGuideModelProvider* opt_guide, - const scoped_refptr<base::SequencedTaskRunner>& background_task_runner); - ~AnnotateDomModelService() override; - - // KeyedService implementation: - void Shutdown() override; - - // optimization_guide::OptimizationTargetModelObserver implementation: - void OnModelUpdated( - optimization_guide::proto::OptimizationTarget optimization_target, - const optimization_guide::ModelInfo& model_info) override; - - // Returns the annotate dom model file. If this returns a nullopt, see the - // |NotifyOnModelFileAvailable| for an asynchronous notification of the model - // being available. - absl::optional<base::File> GetModelFile() const; - - // Returns the model of the version. If this returns a nullopt, see the - // |NotifyOnModelFileAvailable| for an asynchronous notification of the model - // being available. - absl::optional<int64_t> GetModelVersion() const; - - // Returns the overrides policy as a serialized binary proto representation - // that will be passed to renderer processes. - std::string GetOverridesPolicy() const; - virtual bool SetOverridesPolicy(SemanticSelectorPolicy policy); - - // If the model file is not available, requestors can ask to be notified, via - // |callback|. This enables a two-step approach to relabily get the model file - // when it becomes available if the requestor needs the file right when it - // becomes available. This is to ensure that if the |callback| becomes empty, - // only the notification gets dropped, rather than the model file which has - // to be closed on a background thread. - void NotifyOnModelFileAvailable(NotifyModelAvailableCallback callback); - - void SetModelFileForTest(base::File model_file); - - private: - void OnModelFileLoaded(int64_t model_version, base::File model_file); - - // Optimization Guide Service that provides model files for this service. - raw_ptr<optimization_guide::OptimizationGuideModelProvider> opt_guide_ = - nullptr; - - // The file that contains the annotate DOM model. Available when the - // file path has been provided by the Optimization Guide and has been - // successfully loaded. - absl::optional<base::File> model_file_; - // The version of the current model. - absl::optional<int64_t> model_version_; - - // A serialized binary representation of a SemanticSelectorPolicy proto. - std::string overrides_policy_binary_proto_; - - // The set of callbacks associated with requests for the language detection - // model. - std::vector<NotifyModelAvailableCallback> pending_model_requests_; - - scoped_refptr<base::SequencedTaskRunner> background_task_runner_; - - base::WeakPtrFactory<AnnotateDomModelService> weak_ptr_factory_{this}; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_ANNOTATE_DOM_MODEL_SERVICE_H_
diff --git a/components/autofill_assistant/content/browser/content_autofill_assistant_driver.cc b/components/autofill_assistant/content/browser/content_autofill_assistant_driver.cc deleted file mode 100644 index 1ecfb91..0000000 --- a/components/autofill_assistant/content/browser/content_autofill_assistant_driver.cc +++ /dev/null
@@ -1,149 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" - -#include "base/files/file.h" -#include "base/guid.h" -#include "base/location.h" -#include "components/autofill_assistant/content/common/proto/semantic_feature_overrides.pb.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" - -namespace autofill_assistant { - -DOCUMENT_USER_DATA_KEY_IMPL(ContentAutofillAssistantDriver); - -ContentAutofillAssistantDriver::PendingCall::PendingCall( - std::unique_ptr<base::OneShotTimer> timer, - GetAnnotateDomModelCallback callback) - : timer_(std::move(timer)), callback_(std::move(callback)) {} - -ContentAutofillAssistantDriver::PendingCall::~PendingCall() = default; - -ContentAutofillAssistantDriver::ContentAutofillAssistantDriver( - content::RenderFrameHost* render_frame_host) - : content::DocumentUserData<ContentAutofillAssistantDriver>( - render_frame_host) {} -ContentAutofillAssistantDriver::~ContentAutofillAssistantDriver() = default; - -// static -void ContentAutofillAssistantDriver::BindDriver( - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantDriver> - pending_receiver, - content::RenderFrameHost* render_frame_host) { - DCHECK(render_frame_host); - auto* driver = ContentAutofillAssistantDriver::GetOrCreateForCurrentDocument( - render_frame_host); - if (driver) { - driver->BindPendingReceiver(std::move(pending_receiver)); - } -} - -// static -ContentAutofillAssistantDriver* -ContentAutofillAssistantDriver::GetOrCreateForRenderFrameHost( - content::RenderFrameHost* render_frame_host, - AnnotateDomModelService* annotate_dom_model_service) { - ContentAutofillAssistantDriver* driver = - ContentAutofillAssistantDriver::GetOrCreateForCurrentDocument( - render_frame_host); - if (driver && annotate_dom_model_service) { - driver->SetAnnotateDomModelService(annotate_dom_model_service); - } - return driver; -} - -void ContentAutofillAssistantDriver::BindPendingReceiver( - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantDriver> - pending_receiver) { - receiver_.Bind(std::move(pending_receiver)); -} - -const mojo::AssociatedRemote<mojom::AutofillAssistantAgent>& -ContentAutofillAssistantDriver::GetAutofillAssistantAgent() { - // Here is a lazy binding, and will not reconnect after connection error. - if (!autofill_assistant_agent_) { - render_frame_host().GetRemoteAssociatedInterfaces()->GetInterface( - &autofill_assistant_agent_); - } - - return autofill_assistant_agent_; -} - -void ContentAutofillAssistantDriver::GetAnnotateDomModel( - base::TimeDelta timeout, - GetAnnotateDomModelCallback callback) { - if (!annotate_dom_model_service_) { - std::move(callback).Run(mojom::ModelStatus::kUnexpectedError, base::File(), - /*overrides_policy=*/""); - return; - } - - absl::optional<base::File> file = annotate_dom_model_service_->GetModelFile(); - if (file) { - std::move(callback).Run(mojom::ModelStatus::kSuccess, *std::move(file), - GetOverridesPolicy()); - return; - } - - std::string guid(base::GenerateGUID()); - auto pending_call = std::make_unique<PendingCall>( - std::make_unique<base::OneShotTimer>(), std::move(callback)); - pending_call->timer_->Start( - FROM_HERE, timeout, - base::BindOnce(&ContentAutofillAssistantDriver::RunCallback, - weak_pointer_factory_.GetWeakPtr(), guid, - mojom::ModelStatus::kTimeout, base::File())); - pending_calls_.emplace(guid, std::move(pending_call)); - - annotate_dom_model_service_->NotifyOnModelFileAvailable(base::BindOnce( - &ContentAutofillAssistantDriver::OnModelAvailabilityChanged, - weak_pointer_factory_.GetWeakPtr(), guid)); -} - -void ContentAutofillAssistantDriver::OnModelAvailabilityChanged( - const std::string& guid, - bool is_available) { - if (!is_available) { - RunCallback(guid, mojom::ModelStatus::kUnexpectedError, base::File()); - return; - } - - absl::optional<base::File> file = annotate_dom_model_service_->GetModelFile(); - if (!file) { - NOTREACHED() << "No model file where expected."; - RunCallback(guid, mojom::ModelStatus::kUnexpectedError, base::File()); - return; - } - RunCallback(guid, mojom::ModelStatus::kSuccess, *std::move(file)); -} - -void ContentAutofillAssistantDriver::RunCallback( - const std::string& guid, - mojom::ModelStatus model_status, - base::File model_file) { - auto it = pending_calls_.find(guid); - if (it == pending_calls_.end()) { - return; - } - DCHECK(it->second->callback_); - std::move(it->second->callback_) - .Run(model_status, std::move(model_file), GetOverridesPolicy()); - pending_calls_.erase(it); -} - -void ContentAutofillAssistantDriver::SetAnnotateDomModelService( - AnnotateDomModelService* annotate_dom_model_service) { - annotate_dom_model_service_ = annotate_dom_model_service; -} - -std::string ContentAutofillAssistantDriver::GetOverridesPolicy() const { - if (!annotate_dom_model_service_) { - return ""; - } - return annotate_dom_model_service_->GetOverridesPolicy(); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/browser/content_autofill_assistant_driver.h b/components/autofill_assistant/content/browser/content_autofill_assistant_driver.h deleted file mode 100644 index 444dfca..0000000 --- a/components/autofill_assistant/content/browser/content_autofill_assistant_driver.h +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_CONTENT_AUTOFILL_ASSISTANT_DRIVER_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_CONTENT_AUTOFILL_ASSISTANT_DRIVER_H_ - -#include "base/containers/flat_map.h" -#include "base/memory/raw_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/time/time.h" -#include "base/timer/timer.h" -#include "components/autofill_assistant/content/browser/annotate_dom_model_service.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" -#include "components/autofill_assistant/content/common/autofill_assistant_driver.mojom.h" -#include "content/public/browser/document_user_data.h" -#include "content/public/browser/render_frame_host.h" -#include "mojo/public/cpp/bindings/associated_receiver.h" -#include "mojo/public/cpp/bindings/associated_remote.h" -#include "mojo/public/cpp/bindings/pending_receiver.h" - -namespace autofill_assistant { - -// ContentAutofillAssistantDriver operates in the browser process based on -// communication from the renderer. There is one instance per RenderFrameHost. -class ContentAutofillAssistantDriver - : public mojom::AutofillAssistantDriver, - public content::DocumentUserData<ContentAutofillAssistantDriver> { - public: - ~ContentAutofillAssistantDriver() override; - - ContentAutofillAssistantDriver(const ContentAutofillAssistantDriver&) = - delete; - ContentAutofillAssistantDriver& operator=( - const ContentAutofillAssistantDriver&) = delete; - - static void BindDriver(mojo::PendingAssociatedReceiver< - mojom::AutofillAssistantDriver> pending_receiver, - content::RenderFrameHost* render_frame_host); - - static ContentAutofillAssistantDriver* GetOrCreateForRenderFrameHost( - content::RenderFrameHost* render_frame_host, - AnnotateDomModelService* annotate_dom_model_service); - - void BindPendingReceiver( - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantDriver> - pending_receiver); - - const mojo::AssociatedRemote<mojom::AutofillAssistantAgent>& - GetAutofillAssistantAgent(); - - // autofill_assistant::mojom::AutofillAssistantDriver: - void GetAnnotateDomModel(base::TimeDelta timeout, - GetAnnotateDomModelCallback callback) override; - - void SetAnnotateDomModelService( - AnnotateDomModelService* annotate_dom_model_service); - - private: - friend class ContentAutofillAssistantDriverTest; - explicit ContentAutofillAssistantDriver( - content::RenderFrameHost* render_frame_host); - - friend DocumentUserData; - DOCUMENT_USER_DATA_KEY_DECL(); - - void OnModelAvailabilityChanged(const std::string& guid, bool is_available); - void RunCallback(const std::string& guid, - mojom::ModelStatus model_status, - base::File model_file); - std::string GetOverridesPolicy() const; - - raw_ptr<AnnotateDomModelService> annotate_dom_model_service_ = nullptr; - - struct PendingCall { - PendingCall(std::unique_ptr<base::OneShotTimer> timer, - GetAnnotateDomModelCallback callback); - ~PendingCall(); - - PendingCall(const PendingCall&) = delete; - void operator=(const PendingCall&) = delete; - - std::unique_ptr<base::OneShotTimer> timer_; - GetAnnotateDomModelCallback callback_; - }; - - base::flat_map<std::string, std::unique_ptr<PendingCall>> pending_calls_; - - mojo::AssociatedReceiver<mojom::AutofillAssistantDriver> receiver_{this}; - - mojo::AssociatedRemote<mojom::AutofillAssistantAgent> - autofill_assistant_agent_; - - base::WeakPtrFactory<ContentAutofillAssistantDriver> weak_pointer_factory_{ - this}; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_BROWSER_CONTENT_AUTOFILL_ASSISTANT_DRIVER_H_
diff --git a/components/autofill_assistant/content/browser/content_autofill_assistant_driver_unittest.cc b/components/autofill_assistant/content/browser/content_autofill_assistant_driver_unittest.cc deleted file mode 100644 index 0c83a55..0000000 --- a/components/autofill_assistant/content/browser/content_autofill_assistant_driver_unittest.cc +++ /dev/null
@@ -1,161 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/browser/content_autofill_assistant_driver.h" - -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/memory/ptr_util.h" -#include "base/path_service.h" -#include "base/test/mock_callback.h" -#include "base/test/task_environment.h" -#include "base/time/time.h" -#include "content/public/browser/web_contents.h" -#include "content/public/test/browser_task_environment.h" -#include "content/public/test/test_browser_context.h" -#include "content/public/test/test_renderer_host.h" -#include "content/public/test/web_contents_tester.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace autofill_assistant { -namespace { - -using ::testing::_; - -} // namespace - -class ContentAutofillAssistantDriverTest : public testing::Test { - public: - ContentAutofillAssistantDriverTest() - : task_environment_(base::test::TaskEnvironment::TimeSource::MOCK_TIME) { - base::FilePath source_root_dir; - base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir); - base::FilePath model_file_path = source_root_dir.AppendASCII("components") - .AppendASCII("test") - .AppendASCII("data") - .AppendASCII("autofill_assistant") - .AppendASCII("model") - .AppendASCII("model.tflite"); - model_file_ = base::File(model_file_path, - (base::File::FLAG_OPEN | base::File::FLAG_READ)); - - annotate_dom_model_service_ = std::make_unique<AnnotateDomModelService>( - /* opt_guide= */ nullptr, /* background_task_runner= */ nullptr); - - web_contents_ = content::WebContentsTester::CreateTestWebContents( - &browser_context_, nullptr); - // Constructor of ContentAutofillAssistantDriver is private, cannot use - // std::make_unique. - driver_ = base::WrapUnique(new ContentAutofillAssistantDriver( - web_contents_->GetPrimaryMainFrame())); - } - - void SetUp() override { - driver_->SetAnnotateDomModelService(annotate_dom_model_service_.get()); - } - - bool HasPendingCallbacks() { return !driver_->pending_calls_.empty(); } - - protected: - // The task_environment_ must be first to guarantee other field creations run - // in that environment. - content::BrowserTaskEnvironment task_environment_{ - base::test::TaskEnvironment::TimeSource::MOCK_TIME}; - content::RenderViewHostTestEnabler rvh_test_enabler_; - content::TestBrowserContext browser_context_; - std::unique_ptr<content::WebContents> web_contents_; - - std::unique_ptr<ContentAutofillAssistantDriver> driver_; - std::unique_ptr<AnnotateDomModelService> annotate_dom_model_service_; - base::File model_file_; - - base::MockCallback<base::OnceCallback< - void(mojom::ModelStatus, base::File, const std::string&)>> - callback_; -}; - -TEST_F(ContentAutofillAssistantDriverTest, GetLoadedModelFromService) { - // Model has been loaded before. - annotate_dom_model_service_->SetModelFileForTest(model_file_.Duplicate()); - - EXPECT_CALL(callback_, Run(mojom::ModelStatus::kSuccess, _, _)); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -TEST_F(ContentAutofillAssistantDriverTest, GetModelFromServiceAfterLoading) { - EXPECT_CALL(callback_, Run(mojom::ModelStatus::kSuccess, _, _)); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - // Model loaded after being requested. - annotate_dom_model_service_->SetModelFileForTest(model_file_.Duplicate()); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -TEST_F(ContentAutofillAssistantDriverTest, GetModelTimesOut) { - EXPECT_CALL(callback_, Run(mojom::ModelStatus::kTimeout, _, _)); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - // Model does not get loaded. - task_environment_.FastForwardBy(base::Seconds(2)); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -TEST_F(ContentAutofillAssistantDriverTest, MultipleParallelCalls) { - EXPECT_CALL(callback_, Run(mojom::ModelStatus::kTimeout, _, _)).Times(3); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - // Model does not get loaded. - task_environment_.FastForwardBy(base::Seconds(2)); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -TEST_F(ContentAutofillAssistantDriverTest, EmptyOverrides) { - EXPECT_CALL(callback_, Run(mojom::ModelStatus::kSuccess, _, std::string())); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - // Model loaded after being requested. - annotate_dom_model_service_->SetModelFileForTest(model_file_.Duplicate()); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -class ContentAutofillAssistantDriverMissingDomServiceTest - : public ContentAutofillAssistantDriverTest { - // Do not set the dom model service. - void SetUp() override {} -}; - -TEST_F(ContentAutofillAssistantDriverMissingDomServiceTest, - MissingDomModelService) { - EXPECT_CALL(callback_, - Run(mojom::ModelStatus::kUnexpectedError, _, std::string())) - .Times(1); - - driver_->GetAnnotateDomModel(/* timeout= */ base::Milliseconds(1000), - callback_.Get()); - - EXPECT_FALSE(HasPendingCallbacks()); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/common/BUILD.gn b/components/autofill_assistant/content/common/BUILD.gn deleted file mode 100644 index 9bd89f7..0000000 --- a/components/autofill_assistant/content/common/BUILD.gn +++ /dev/null
@@ -1,47 +0,0 @@ -# Copyright 2021 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//mojo/public/tools/bindings/mojom.gni") - -static_library("common") { - sources = [ - "node_data.cc", - "node_data.h", - "switches.cc", - "switches.h", - ] -} - -mojom("mojo_types") { - sources = [ "autofill_assistant_types.mojom" ] - - public_deps = [ "//mojo/public/mojom/base" ] - - cpp_typemaps = [ - { - types = [ - { - mojom = "autofill_assistant.mojom.NodeData" - cpp = "::autofill_assistant::NodeData" - }, - ] - traits_headers = [ "autofill_assistant_types_mojom_traits.h" ] - traits_sources = [ "autofill_assistant_types_mojom_traits.cc" ] - traits_public_deps = [ - ":common", - "//base", - ] - }, - ] -} - -mojom("mojo_interfaces") { - sources = [ - "autofill_assistant_agent.mojom", - "autofill_assistant_driver.mojom", - ] - - public_deps = [ "//mojo/public/mojom/base" ] - deps = [ ":mojo_types" ] -}
diff --git a/components/autofill_assistant/content/common/DEPS b/components/autofill_assistant/content/common/DEPS deleted file mode 100644 index 9d9e160..0000000 --- a/components/autofill_assistant/content/common/DEPS +++ /dev/null
@@ -1,3 +0,0 @@ -include_rules = [ - "+mojo/public" -]
diff --git a/components/autofill_assistant/content/common/OWNERS b/components/autofill_assistant/content/common/OWNERS deleted file mode 100644 index 1feb514..0000000 --- a/components/autofill_assistant/content/common/OWNERS +++ /dev/null
@@ -1,4 +0,0 @@ -per-file *.mojom=set noparent -per-file *.mojom=file://ipc/SECURITY_OWNERS -per-file *_mojom_traits*.*=set noparent -per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/components/autofill_assistant/content/common/autofill_assistant_agent.mojom b/components/autofill_assistant/content/common/autofill_assistant_agent.mojom deleted file mode 100644 index 7d572c9c..0000000 --- a/components/autofill_assistant/content/common/autofill_assistant_agent.mojom +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module autofill_assistant.mojom; - -import "components/autofill_assistant/content/common/autofill_assistant_types.mojom"; -import "mojo/public/mojom/base/string16.mojom"; -import "mojo/public/mojom/base/time.mojom"; - -// There is one instance of this interface per render frame in the renderer -// process. All methods are called by browser on renderer. -interface AutofillAssistantAgent { - // Evaluates all input, textarea and select nodes in the frame's document and - // returns all that match the given semantic role and objective. - GetSemanticNodes(int32 role, int32 objective, bool ignore_objective, - mojo_base.mojom.TimeDelta timeout) - => (NodeDataStatus status, - array<autofill_assistant.mojom.NodeData> nodes); - - // Set the value of a web element. The target needs to be a form control - // element, otherwise the call fails. This works for input, textarea and - // select. For a select element it finds the option with a value matching - // the given parameter (exactly) and makes that option the current selection. - SetElementValue(int32 backend_node_id, mojo_base.mojom.String16 value, - bool send_events) - => (bool success); - - // Set the checked property on a web input element. - // The element should be a checkable WebInputElement: a checkbox or a - // radio button. - SetElementChecked(int32 backend_node_id, bool checked, bool send_events) - => (bool success); -};
diff --git a/components/autofill_assistant/content/common/autofill_assistant_driver.mojom b/components/autofill_assistant/content/common/autofill_assistant_driver.mojom deleted file mode 100644 index 35dc535c..0000000 --- a/components/autofill_assistant/content/common/autofill_assistant_driver.mojom +++ /dev/null
@@ -1,20 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module autofill_assistant.mojom; - -import "components/autofill_assistant/content/common/autofill_assistant_types.mojom"; -import "mojo/public/mojom/base/byte_string.mojom"; -import "mojo/public/mojom/base/read_only_file.mojom"; -import "mojo/public/mojom/base/time.mojom"; - -// There is one instance of this interface per RenderFrameHost in the browser -// process. All methods are called by renderer on browser. -interface AutofillAssistantDriver { - // Request that the annotate DOM model is being loaded and returned for use - // by the AutofillAssistantAgent. - GetAnnotateDomModel(mojo_base.mojom.TimeDelta timeout) - => (ModelStatus status, mojo_base.mojom.ReadOnlyFile? model_file, - mojo_base.mojom.ByteString overrides_policy); -};
diff --git a/components/autofill_assistant/content/common/autofill_assistant_types.mojom b/components/autofill_assistant/content/common/autofill_assistant_types.mojom deleted file mode 100644 index 0f594cf..0000000 --- a/components/autofill_assistant/content/common/autofill_assistant_types.mojom +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module autofill_assistant.mojom; - -// A set of possible model status. -enum ModelStatus { - kSuccess, - kUnexpectedError, - kTimeout -}; - -// A set of possible result status. -enum NodeDataStatus { - kSuccess, - kUnexpectedError, - kInitializationError, - kModelLoadError, - kModelLoadTimeout -}; - -// autofill_assistant::NodeData -struct NodeData { - // The BackendNodeId of this element. - int32 backend_node_id; - - // Whether an override was used. - bool used_override; -};
diff --git a/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.cc b/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.cc deleted file mode 100644 index 7aa16daa..0000000 --- a/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.cc +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.h" - -#include "mojo/public/cpp/base/string16_mojom_traits.h" - -namespace mojo { - -// static -bool StructTraits<autofill_assistant::mojom::NodeDataDataView, - autofill_assistant::NodeData>:: - Read(autofill_assistant::mojom::NodeDataDataView data, - autofill_assistant::NodeData* out) { - out->backend_node_id = data.backend_node_id(); - out->used_override = data.used_override(); - return true; -} - -} // namespace mojo
diff --git a/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.h b/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.h deleted file mode 100644 index 70b25a5..0000000 --- a/components/autofill_assistant/content/common/autofill_assistant_types_mojom_traits.h +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_AUTOFILL_ASSISTANT_TYPES_MOJOM_TRAITS_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_AUTOFILL_ASSISTANT_TYPES_MOJOM_TRAITS_H_ - -#include <stdint.h> - -#include "components/autofill_assistant/content/common/autofill_assistant_types.mojom-shared.h" -#include "components/autofill_assistant/content/common/node_data.h" -#include "mojo/public/cpp/bindings/struct_traits.h" - -namespace mojo { - -template <> -struct StructTraits<autofill_assistant::mojom::NodeDataDataView, - autofill_assistant::NodeData> { - static int32_t backend_node_id(const autofill_assistant::NodeData& r) { - return r.backend_node_id; - } - - static bool used_override(const autofill_assistant::NodeData& r) { - return r.used_override; - } - - static bool Read(autofill_assistant::mojom::NodeDataDataView data, - autofill_assistant::NodeData* out); -}; - -} // namespace mojo - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_AUTOFILL_ASSISTANT_TYPES_MOJOM_TRAITS_H_
diff --git a/components/autofill_assistant/content/common/node_data.cc b/components/autofill_assistant/content/common/node_data.cc deleted file mode 100644 index 9009eaa..0000000 --- a/components/autofill_assistant/content/common/node_data.cc +++ /dev/null
@@ -1,21 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/common/node_data.h" - -namespace autofill_assistant { - -NodeData::NodeData() = default; - -NodeData::NodeData(const NodeData&) = default; - -NodeData& NodeData::operator=(const NodeData&) = default; - -NodeData::NodeData(NodeData&&) = default; - -NodeData& NodeData::operator=(NodeData&&) = default; - -NodeData::~NodeData() = default; - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/common/node_data.h b/components/autofill_assistant/content/common/node_data.h deleted file mode 100644 index 5ae2562..0000000 --- a/components/autofill_assistant/content/common/node_data.h +++ /dev/null
@@ -1,26 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_NODE_DATA_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_NODE_DATA_H_ - -#include <stdint.h> - -namespace autofill_assistant { - -struct NodeData { - NodeData(); - NodeData(const NodeData&); - NodeData& operator=(const NodeData&); - NodeData(NodeData&&); - NodeData& operator=(NodeData&&); - ~NodeData(); - - int32_t backend_node_id = -1; - bool used_override = false; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_AUTOFILL_ASSISTANT_DATA_H_
diff --git a/components/autofill_assistant/content/common/proto/BUILD.gn b/components/autofill_assistant/content/common/proto/BUILD.gn deleted file mode 100644 index be3882d60..0000000 --- a/components/autofill_assistant/content/common/proto/BUILD.gn +++ /dev/null
@@ -1,21 +0,0 @@ -# Copyright 2022 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//third_party/protobuf/proto_library.gni") - -if (is_android) { - import("//build/config/android/rules.gni") -} - -proto_library("proto") { - proto_in_dir = "//" - sources = [ "semantic_feature_overrides.proto" ] -} - -if (is_android) { - proto_java_library("proto_java") { - proto_path = "//components/autofill_assistant/" - sources = [ "semantic_feature_overrides.proto" ] - } -}
diff --git a/components/autofill_assistant/content/common/proto/semantic_feature_overrides.proto b/components/autofill_assistant/content/common/proto/semantic_feature_overrides.proto deleted file mode 100644 index c3417d3..0000000 --- a/components/autofill_assistant/content/common/proto/semantic_feature_overrides.proto +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -syntax = "proto2"; - -option optimize_for = LITE_RUNTIME; -option java_package = "org.chromium.chrome.browser.autofill_assistant.proto"; -option java_multiple_files = true; - -package autofill_assistant; - -message SparseEncoding { - optional int32 feature_concatenation_index = 1; - optional int32 vocabulary_index = 2; - optional int32 number_of_occurrences = 3; -} - -message PredictionLabel { - optional int32 objective = 1; - optional int32 semantic_role = 2; -} - -message VersionedFeatureOverrides { - message DataPoint { - repeated SparseEncoding key_coordinate = 1; - optional PredictionLabel value = 2; - } - repeated DataPoint data_point_map = 1; -} - -message SemanticSelectorPolicy { - oneof feature_overrides { VersionedFeatureOverrides bag_of_words = 1; } -}
diff --git a/components/autofill_assistant/content/common/switches.cc b/components/autofill_assistant/content/common/switches.cc deleted file mode 100644 index ce0f3b8..0000000 --- a/components/autofill_assistant/content/common/switches.cc +++ /dev/null
@@ -1,13 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/common/switches.h" - -namespace autofill_assistant::switches { - -// Enables annotating DOM debugging when set. -const char kAutofillAssistantDebugAnnotateDom[] = - "autofill-assistant-debug-annotate-dom"; - -} // namespace autofill_assistant::switches
diff --git a/components/autofill_assistant/content/common/switches.h b/components/autofill_assistant/content/common/switches.h deleted file mode 100644 index 230dc99..0000000 --- a/components/autofill_assistant/content/common/switches.h +++ /dev/null
@@ -1,15 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_SWITCHES_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_SWITCHES_H_ - -namespace autofill_assistant::switches { - -// All switches in alphabetical order. -extern const char kAutofillAssistantDebugAnnotateDom[]; - -} // namespace autofill_assistant::switches - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_COMMON_SWITCHES_H_
diff --git a/components/autofill_assistant/content/renderer/BUILD.gn b/components/autofill_assistant/content/renderer/BUILD.gn deleted file mode 100644 index a5fa3cd..0000000 --- a/components/autofill_assistant/content/renderer/BUILD.gn +++ /dev/null
@@ -1,88 +0,0 @@ -# Copyright 2021 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//components/optimization_guide/features.gni") -import("//third_party/protobuf/proto_library.gni") - -proto_library("model_metadata_proto") { - sources = [ "model_metadata.proto" ] -} - -static_library("renderer") { - sources = [ - "autofill_assistant_agent.cc", - "autofill_assistant_agent.h", - "autofill_assistant_model_executor_result.h", - ] - - deps = [ - ":model_metadata_proto", - "//base", - "//components/autofill_assistant/content/common:common", - "//components/autofill_assistant/content/common:mojo_interfaces", - "//components/autofill_assistant/content/common/proto:proto", - "//components/optimization_guide:machine_learning_tflite_buildflags", - "//content/public/common:common", - "//content/public/renderer:renderer", - "//mojo/public/cpp/bindings", - "//third_party/abseil-cpp:absl", - "//third_party/blink/public:blink", - "//third_party/blink/public/common", - ] - - if (build_with_tflite_lib) { - sources += [ - "autofill_assistant_agent_debug_utils.cc", - "autofill_assistant_agent_debug_utils.h", - "autofill_assistant_model_executor.cc", - "autofill_assistant_model_executor.h", - ] - deps += [ "//components/optimization_guide/core:model_executor" ] - public_deps = [ - "//third_party/tflite", - "//third_party/tflite:tflite_public_headers", - "//third_party/tflite_support", - "//third_party/tflite_support:tflite_support_proto", - ] - } -} - -source_set("unit_tests") { - testonly = true - sources = [] - - if (build_with_tflite_lib) { - sources += [ - "autofill_assistant_agent_debug_utils_unittest.cc", - "autofill_assistant_model_executor_unittest.cc", - ] - } - - deps = [ - ":renderer", - "//base", - "//base/test:test_support", - "//third_party/blink/public:blink", - ] -} - -source_set("browser_tests") { - testonly = true - sources = [] - - if (build_with_tflite_lib) { - sources += [ "autofill_assistant_agent_browsertest.cc" ] - } - - deps = [ - ":renderer", - "//base", - "//base/test:test_support", - "//components/autofill_assistant/content/common:mojo_interfaces", - "//components/autofill_assistant/content/common/proto:proto", - "//content/public/browser", - "//content/public/renderer", - "//content/test:test_support", - ] -}
diff --git a/components/autofill_assistant/content/renderer/DEPS b/components/autofill_assistant/content/renderer/DEPS deleted file mode 100644 index 9218c07..0000000 --- a/components/autofill_assistant/content/renderer/DEPS +++ /dev/null
@@ -1,16 +0,0 @@ -include_rules = [ - "+components/optimization_guide", - "+content/public/common", - "+content/public/renderer", - "+content/public/test", - "+mojo/public/cpp/bindings", - "+mojo/public/cpp/bindings/binding.h", - "+services/service_manager/public/cpp", - "+third_party/abseil-cpp/absl/status/status.h", - "+third_party/blink/public/common", - "+third_party/blink/public/platform", - "+third_party/blink/public/web", - "+third_party/protobuf/src/google/protobuf/repeated_field.h", - "+third_party/tflite", - "+third_party/tflite_support", -]
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent.cc b/components/autofill_assistant/content/renderer/autofill_assistant_agent.cc deleted file mode 100644 index 67ef6cd8a..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent.cc +++ /dev/null
@@ -1,336 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent.h" - -#include <ostream> - -#include "base/command_line.h" -#include "components/autofill_assistant/content/common/switches.h" -#include "components/optimization_guide/machine_learning_tflite_buildflags.h" -#include "content/public/renderer/render_frame.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" -#include "third_party/blink/public/platform/web_string.h" -#include "third_party/blink/public/platform/web_vector.h" -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" -#include "third_party/blink/public/web/web_element.h" -#include "third_party/blink/public/web/web_form_control_element.h" -#include "third_party/blink/public/web/web_input_element.h" -#include "third_party/blink/public/web/web_local_frame.h" -#include "third_party/protobuf/src/google/protobuf/repeated_field.h" - -#if BUILDFLAG(BUILD_WITH_TFLITE_LIB) -#include "components/autofill_assistant/content/common/proto/semantic_feature_overrides.pb.h" -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h" -#include "components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h" -#endif // BUILDFLAG(BUILD_WITH_TFLITE_LIB) - -namespace autofill_assistant { -namespace { - -#if BUILDFLAG(BUILD_WITH_TFLITE_LIB) - -constexpr char16_t kSemanticPredictionAttributeName[] = u"semantic-prediction"; - -using OverridesMap = AutofillAssistantModelExecutor::OverridesMap; -using SparseVector = AutofillAssistantModelExecutor::SparseVector; - -SparseVector KeyCoordinatesToSparseVector( - const ::google::protobuf::RepeatedPtrField<SparseEncoding>& - key_coordinates) { - SparseVector sparse_vector; - for (const auto& coordinate : key_coordinates) { - sparse_vector.emplace_back( - std::make_pair(std::make_pair(coordinate.feature_concatenation_index(), - coordinate.vocabulary_index()), - coordinate.number_of_occurrences())); - } - return sparse_vector; -} - -absl::optional<OverridesMap> ParseOverridesPolicyToMap( - std::string overrides_policy) { - SemanticSelectorPolicy policy; - if (!policy.ParseFromString( - std::string(overrides_policy.begin(), overrides_policy.end()))) { - return absl::nullopt; - } - if (policy.bag_of_words().data_point_map().empty()) { - return absl::nullopt; - } - OverridesMap overrides_map; - for (const auto& data_point : policy.bag_of_words().data_point_map()) { - if (data_point.key_coordinate().empty()) { - continue; - } - const auto& value = data_point.value(); - overrides_map[KeyCoordinatesToSparseVector(data_point.key_coordinate())] = - std::make_pair(value.semantic_role(), value.objective()); - } - return overrides_map; -} - -#endif // BUILDFLAG(BUILD_WITH_TFLITE_LIB) - -} // namespace - -AutofillAssistantAgent::AutofillAssistantAgent( - content::RenderFrame* render_frame, - blink::AssociatedInterfaceRegistry* registry) - : content::RenderFrameObserver(render_frame) { - registry->AddInterface<mojom::AutofillAssistantAgent>(base::BindRepeating( - &AutofillAssistantAgent::BindPendingReceiver, base::Unretained(this))); - - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantDebugAnnotateDom)) { - std::string jsonEncodedSemanticEnums = - base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( - autofill_assistant::switches::kAutofillAssistantDebugAnnotateDom); -#if BUILDFLAG(BUILD_WITH_TFLITE_LIB) - semantic_labels = - DecodeSemanticPredictionLabelsJson(jsonEncodedSemanticEnums); -#endif - } -} - -// The destructor is not guaranteed to be called. Destruction happens (only) -// through the OnDestruct() event, which posts a task to delete this object. -// The process may be killed before this deletion can happen. -AutofillAssistantAgent::~AutofillAssistantAgent() = default; - -void AutofillAssistantAgent::BindPendingReceiver( - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantAgent> - pending_receiver) { - receiver_.Bind(std::move(pending_receiver)); - receiver_.reset_on_disconnect(); -} - -void AutofillAssistantAgent::OnDestruct() { - delete this; -} - -base::WeakPtr<AutofillAssistantAgent> AutofillAssistantAgent::GetWeakPtr() { - return weak_ptr_factory_.GetWeakPtr(); -} - -void AutofillAssistantAgent::GetSemanticNodes( - int32_t role, - int32_t objective, - bool ignore_objective, - base::TimeDelta model_timeout, - GetSemanticNodesCallback callback) { - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); - if (!frame) { - VLOG(1) << "Failed to get semantic nodes, no frame."; - std::move(callback).Run(mojom::NodeDataStatus::kUnexpectedError, - std::vector<NodeData>()); - return; - } - - GetAnnotateDomModel( - model_timeout, - base::BindOnce(&AutofillAssistantAgent::OnGetModelFile, - weak_ptr_factory_.GetWeakPtr(), base::Time::Now(), frame, - role, objective, ignore_objective, std::move(callback))); -} - -void AutofillAssistantAgent::GetAnnotateDomModel( - base::TimeDelta model_timeout, - base::OnceCallback<void(mojom::ModelStatus, base::File, const std::string&)> - callback) { - mojo::AssociatedRemote<mojom::AutofillAssistantDriver>& driver = GetDriver(); - - if (!driver || !driver.is_connected()) { - std::move(callback).Run(mojom::ModelStatus::kUnexpectedError, base::File(), - /*overrides_policy=*/""); - return; - } - driver->GetAnnotateDomModel(model_timeout, std::move(callback)); -} - -mojo::AssociatedRemote<mojom::AutofillAssistantDriver>& -AutofillAssistantAgent::GetDriver() { - if (!driver_) { - render_frame()->GetRemoteAssociatedInterfaces()->GetInterface(&driver_); - driver_.reset_on_disconnect(); - } - return driver_; -} - -void AutofillAssistantAgent::OnGetModelFile( - base::Time start_time, - blink::WebLocalFrame* frame, - int32_t role, - int32_t objective, - bool ignore_objective, - GetSemanticNodesCallback callback, - mojom::ModelStatus model_status, - base::File model, - const std::string& overrides_policy) { - std::vector<NodeData> nodes; - switch (model_status) { - case mojom::ModelStatus::kSuccess: - break; - case mojom::ModelStatus::kUnexpectedError: - std::move(callback).Run(mojom::NodeDataStatus::kModelLoadError, nodes); - return; - case mojom::ModelStatus::kTimeout: - std::move(callback).Run(mojom::NodeDataStatus::kModelLoadTimeout, nodes); - return; - } - - base::Time on_get_model_file = base::Time::Now(); - DVLOG(3) << "AutofillAssistant, loading model file: " - << (on_get_model_file - start_time).InMilliseconds() << "ms"; - - blink::WebVector<blink::AutofillAssistantNodeSignals> node_signals = - blink::GetAutofillAssistantNodeSignals(frame->GetDocument()); - - base::Time on_node_signals = base::Time::Now(); - DVLOG(3) << "AutofillAssistant, signals extraction: " - << (on_node_signals - on_get_model_file).InMilliseconds() << "ms"; - -#if BUILDFLAG(BUILD_WITH_TFLITE_LIB) - AutofillAssistantModelExecutor model_executor( - ParseOverridesPolicyToMap(std::move(overrides_policy))); - if (!model_executor.InitializeModelFromFile(std::move(model))) { - std::move(callback).Run(mojom::NodeDataStatus::kInitializationError, nodes); - return; - } - - base::Time on_executor_initialized = base::Time::Now(); - DVLOG(3) << "AutofillAssistant, executor initialization: " - << (on_executor_initialized - on_node_signals).InMilliseconds() - << "ms"; - DVLOG(3) << "Expected role: " << role << " and objective: " << objective; - - for (const auto& node_signal : node_signals) { - auto result = model_executor.ExecuteModelWithInput(node_signal); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantDebugAnnotateDom)) { - VLOG(3) << NodeSignalsToDebugString(node_signal); - if (result) { - std::u16string result_string = SemanticPredictionResultToDebugString( - semantic_labels.first, semantic_labels.second, result.value(), - ignore_objective); - VLOG(3) << "Result found " << result_string; - - SetElementAttribute(node_signal.backend_node_id, - kSemanticPredictionAttributeName, result_string, - /*send_events=*/false); - } - } - - if (result && result->role == role && - (result->objective == objective || ignore_objective)) { - NodeData node_data; - node_data.backend_node_id = node_signal.backend_node_id; - node_data.used_override = result->used_override; - nodes.push_back(node_data); - } - } - - base::Time on_node_signals_evaluated = base::Time::Now(); - DVLOG(3) - << "AutofillAssistant, node evaluation (for " << node_signals.size() - << " nodes): " - << (on_node_signals_evaluated - on_executor_initialized).InMilliseconds() - << "ms"; -#endif // BUILDFLAG(BUILD_WITH_TFLITE_LIB) - - std::move(callback).Run(mojom::NodeDataStatus::kSuccess, nodes); -} - -void AutofillAssistantAgent::SetElementValue(const int32_t backend_node_id, - const std::u16string& value, - bool send_events, - SetElementValueCallback callback) { - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); - if (!frame) { - VLOG(1) << "Failed to set Element value, no frame."; - std::move(callback).Run(false); - return; - } - - blink::WebElement target_element = - frame->GetDocument().GetElementByDevToolsNodeId(backend_node_id); - if (target_element.IsNull() || !target_element.IsFormControlElement()) { - VLOG(3) << "Failed to set Element value, invalid target."; - std::move(callback).Run(false); - return; - } - - blink::WebFormControlElement target_form_control_element = - target_element.To<blink::WebFormControlElement>(); - target_form_control_element.SetValue(blink::WebString::FromUTF16(value), - send_events); - std::move(callback).Run(true); -} - -void AutofillAssistantAgent::SetElementAttribute( - const int32_t backend_node_id, - const std::u16string& attribute_name, - const std::u16string& value, - bool send_events) { - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); - if (!frame) { - VLOG(1) << "Failed to set Element attribute, no frame."; - return; - } - - blink::WebElement target_element = - frame->GetDocument().GetElementByDevToolsNodeId(backend_node_id); - if (target_element.IsNull() || !target_element.IsFormControlElement()) { - VLOG(3) << "Failed to set Element attribute, invalid target."; - return; - } - - blink::WebFormControlElement target_form_control_element = - target_element.To<blink::WebFormControlElement>(); - target_form_control_element.SetAttribute( - blink::WebString::FromUTF16(attribute_name), - blink::WebString::FromUTF16(value)); -} - -void AutofillAssistantAgent::SetElementChecked( - const int32_t backend_node_id, - bool checked, - bool send_events, - SetElementCheckedCallback callback) { - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); - if (!frame) { - VLOG(1) << "Failed to set Element checked state, no frame."; - std::move(callback).Run(false); - return; - } - - blink::WebElement target_element = - frame->GetDocument().GetElementByDevToolsNodeId(backend_node_id); - if (target_element.IsNull()) { - VLOG(3) << "Failed to set Element checked state, invalid target."; - std::move(callback).Run(false); - return; - } - - blink::WebInputElement web_input_element = - target_element.DynamicTo<blink::WebInputElement>(); - if (web_input_element.IsNull()) { - VLOG(3) << "Failed to set Element checked state, target is not an input " - "element."; - std::move(callback).Run(false); - return; - } - - if (!web_input_element.IsCheckbox() && !web_input_element.IsRadioButton()) { - VLOG(3) << "Failed to set Element checked state, target is not a checkbox " - "or a radio button."; - std::move(callback).Run(false); - return; - } - - web_input_element.SetChecked(checked, send_events); - std::move(callback).Run(true); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent.h b/components/autofill_assistant/content/renderer/autofill_assistant_agent.h deleted file mode 100644 index b1e4044..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent.h +++ /dev/null
@@ -1,98 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_H_ - -#include "base/callback_forward.h" -#include "base/files/file.h" -#include "base/memory/weak_ptr.h" -#include "base/time/time.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" -#include "components/autofill_assistant/content/common/autofill_assistant_driver.mojom.h" -#include "components/autofill_assistant/content/common/node_data.h" -#include "content/public/renderer/render_frame_observer.h" -#include "mojo/public/cpp/bindings/associated_receiver.h" -#include "mojo/public/cpp/bindings/associated_remote.h" -#include "mojo/public/cpp/bindings/pending_associated_receiver.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" - -namespace blink { -class WebLocalFrame; -} - -namespace autofill_assistant { - -// Autofill assistant agent to control a web page. -class AutofillAssistantAgent : public content::RenderFrameObserver, - public mojom::AutofillAssistantAgent { - public: - AutofillAssistantAgent(content::RenderFrame* render_frame, - blink::AssociatedInterfaceRegistry* registry); - ~AutofillAssistantAgent() override; - - AutofillAssistantAgent(const AutofillAssistantAgent&) = delete; - void operator=(const AutofillAssistantAgent&) = delete; - - void BindPendingReceiver( - mojo::PendingAssociatedReceiver<mojom::AutofillAssistantAgent> - pending_receiver); - - base::WeakPtr<AutofillAssistantAgent> GetWeakPtr(); - - // mojom::AutofillAssistantAgent: - void GetSemanticNodes(int32_t role, - int32_t objective, - bool ignore_objective, - base::TimeDelta model_timeout, - GetSemanticNodesCallback callback) override; - void SetElementValue(int32_t backend_node_id, - const std::u16string& value, - bool send_events, - SetElementValueCallback callback) override; - void SetElementChecked(int32_t backend_node_id, - bool checked, - bool send_events, - SetElementCheckedCallback callback) override; - - private: - // content::RenderFrameObserver: - void OnDestruct() override; - - void GetAnnotateDomModel( - base::TimeDelta model_timeout, - base::OnceCallback< - void(mojom::ModelStatus, base::File, const std::string&)> callback); - - mojo::AssociatedRemote<mojom::AutofillAssistantDriver>& GetDriver(); - - void OnGetModelFile(base::Time start_time, - blink::WebLocalFrame* frame, - int32_t role, - int32_t objective, - bool ignore_objective, - GetSemanticNodesCallback callback, - mojom::ModelStatus model_status, - base::File model, - const std::string& overrides_policy); - - void SetElementAttribute(int32_t backend_node_id, - const std::u16string& attribute_value, - const std::u16string& value, - bool send_events); - - using SemanticPredictionLabelMap = base::flat_map<int, std::string>; - using SemanticLabelsPair = - std::pair<SemanticPredictionLabelMap, SemanticPredictionLabelMap>; - SemanticLabelsPair semantic_labels; - - mojo::AssociatedRemote<mojom::AutofillAssistantDriver> driver_; - - mojo::AssociatedReceiver<mojom::AutofillAssistantAgent> receiver_{this}; - base::WeakPtrFactory<AutofillAssistantAgent> weak_ptr_factory_{this}; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_H_
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent_browsertest.cc b/components/autofill_assistant/content/renderer/autofill_assistant_agent_browsertest.cc deleted file mode 100644 index 8357414..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent_browsertest.cc +++ /dev/null
@@ -1,466 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent.h" - -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/path_service.h" -#include "base/run_loop.h" -#include "base/test/bind.h" -#include "base/test/gmock_callback_support.h" -#include "base/test/mock_callback.h" -#include "components/autofill_assistant/content/common/autofill_assistant_agent.mojom.h" -#include "components/autofill_assistant/content/common/autofill_assistant_driver.mojom.h" -#include "components/autofill_assistant/content/common/proto/semantic_feature_overrides.pb.h" -#include "components/autofill_assistant/content/common/switches.h" -#include "content/public/renderer/render_frame.h" -#include "content/public/test/render_view_test.h" -#include "mojo/public/cpp/bindings/associated_receiver_set.h" -#include "testing/gmock/include/gmock/gmock-matchers.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" -#include "third_party/blink/public/web/web_document.h" -#include "third_party/blink/public/web/web_element.h" -#include "third_party/blink/public/web/web_form_control_element.h" -#include "third_party/blink/public/web/web_input_element.h" -#include "third_party/blink/public/web/web_local_frame.h" - -namespace autofill_assistant { -namespace { - -using ::base::test::RunOnceCallback; -using ::testing::_; -using ::testing::Field; -using ::testing::SizeIs; - -constexpr int kDummySemanticRole = 9999; -constexpr int kDummyObjective = 1111; - -class MockAutofillAssistantDriver : public mojom::AutofillAssistantDriver { - public: - void BindPendingReceiver(mojo::ScopedInterfaceEndpointHandle handle) { - receivers_.Add( - this, mojo::PendingAssociatedReceiver<mojom::AutofillAssistantDriver>( - std::move(handle))); - } - - MOCK_METHOD( - void, - GetAnnotateDomModel, - (base::TimeDelta timeout, - base::OnceCallback< - void(mojom::ModelStatus, base::File, const std::string&)> callback), - (override)); - - mojo::AssociatedReceiverSet<mojom::AutofillAssistantDriver> receivers_; -}; - -class AutofillAssistantAgentBrowserTest : public content::RenderViewTest { - public: - AutofillAssistantAgentBrowserTest() = default; - - void SetUp() override { - RenderViewTest::SetUp(); - - GetMainRenderFrame() - ->GetRemoteAssociatedInterfaces() - ->OverrideBinderForTesting( - mojom::AutofillAssistantDriver::Name_, - base::BindRepeating( - &MockAutofillAssistantDriver::BindPendingReceiver, - base::Unretained(&autofill_assistant_driver_))); - autofill_assistant_agent_ = std::make_unique<AutofillAssistantAgent>( - GetMainRenderFrame(), &associated_interfaces_); - - base::FilePath source_root_dir; - base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir); - base::FilePath model_file_path = source_root_dir.AppendASCII("components") - .AppendASCII("test") - .AppendASCII("data") - .AppendASCII("autofill_assistant") - .AppendASCII("model") - .AppendASCII("model.tflite"); - model_file_ = base::File(model_file_path, - (base::File::FLAG_OPEN | base::File::FLAG_READ)); - } - - void TearDown() override { - autofill_assistant_agent_.reset(); - RenderViewTest::TearDown(); - } - - protected: - MockAutofillAssistantDriver autofill_assistant_driver_; - std::unique_ptr<AutofillAssistantAgent> autofill_assistant_agent_; - base::File model_file_; - - private: - blink::AssociatedInterfaceRegistry associated_interfaces_; -}; - -TEST_F(AutofillAssistantAgentBrowserTest, GetSemanticNodes) { - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kSuccess, - model_file_.Duplicate(), std::string())); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, - Run(mojom::NodeDataStatus::kSuccess, - ElementsAre(Field(&NodeData::used_override, false)))); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - - base::RunLoop().RunUntilIdle(); - - const auto web_element = - GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("street")) - .To<blink::WebFormControlElement>(); - // Ensure we don't create semantic prediction attribute when not in debug mode - EXPECT_FALSE(web_element.HasAttribute("semantic-prediction")); -} - -TEST_F(AutofillAssistantAgentBrowserTest, ReconnectsAfterDisconnect) { - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .Times(2) - .WillRepeatedly( - [&](base::TimeDelta model_timeout, - base::OnceCallback<void(mojom::ModelStatus, base::File, - const std::string&)> callback) { - std::move(callback).Run(mojom::ModelStatus::kSuccess, - model_file_.Duplicate(), std::string()); - }); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - - EXPECT_CALL(callback, Run(mojom::NodeDataStatus::kSuccess, SizeIs(1))) - .Times(2); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - - base::RunLoop().RunUntilIdle(); - - // Simulate a destroyed driver: - autofill_assistant_driver_.receivers_.Clear(); - - base::RunLoop().RunUntilIdle(); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, GetSemanticNodesModelTimeout) { - // Do not reply to the model call. - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kTimeout, base::File(), - std::string())); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, Run(mojom::NodeDataStatus::kModelLoadTimeout, _)); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(0), callback.Get()); - - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, GetSemanticNodesModelError) { - // Do not reply to the model call. - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kUnexpectedError, - base::File(), std::string())); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, Run(mojom::NodeDataStatus::kModelLoadError, _)); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, GetSemanticNodesIgnoreObjective) { - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kSuccess, - model_file_.Duplicate(), std::string())); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, Run(mojom::NodeDataStatus::kSuccess, SizeIs(1))); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 6 /* FILL_BILLING_ADDRESS */, - /* ignore_objective= */ true, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, Overrides) { - SemanticSelectorPolicy policy_proto; - auto* single_override = - policy_proto.mutable_bag_of_words()->add_data_point_map(); - - auto* coordinate = single_override->add_key_coordinate(); - coordinate->set_feature_concatenation_index(0); - // Vocabulary entry "input" - coordinate->set_vocabulary_index(1); - coordinate->set_number_of_occurrences(1); - - auto* coordinate2 = single_override->add_key_coordinate(); - coordinate2->set_feature_concatenation_index(3); - // Vocabulary entry "street" - coordinate2->set_vocabulary_index(862); - coordinate2->set_number_of_occurrences(1); - - auto* value = single_override->mutable_value(); - value->set_objective(kDummyObjective); - value->set_semantic_role(kDummySemanticRole); - - std::string policy; - ASSERT_TRUE(policy_proto.SerializeToString(&policy)); - - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kSuccess, - model_file_.Duplicate(), policy)); - - LoadHTML(R"( - <div> - <label for="street">street</label><input id="street"> - </div>)"); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, - Run(mojom::NodeDataStatus::kSuccess, - ElementsAre(Field(&NodeData::used_override, true)))); - - autofill_assistant_agent_->GetSemanticNodes( - kDummySemanticRole, kDummyObjective, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, SetElementCheckedForCheckbox) { - LoadHTML(R"(<input type="checkbox" id="checkbox">)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(true)); - - const auto web_element = - GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("checkbox")) - .To<blink::WebInputElement>(); - autofill_assistant_agent_->SetElementChecked( - web_element.GetDevToolsNodeIdForTest(), true, - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(web_element.IsChecked(), true); -} - -TEST_F(AutofillAssistantAgentBrowserTest, SetElementCheckedForRadioButton) { - LoadHTML(R"(<input type="radio" id="radio_button">)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(true)); - - const auto web_element = - GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("radio_button")) - .To<blink::WebInputElement>(); - autofill_assistant_agent_->SetElementChecked( - web_element.GetDevToolsNodeIdForTest(), true, - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); - EXPECT_EQ(web_element.IsChecked(), true); -} - -TEST_F(AutofillAssistantAgentBrowserTest, SetCheckedFailsForNonCheckableInput) { - LoadHTML(R"(<input type="text" id="text_input">)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(false)); - - const auto web_element = - GetMainRenderFrame()->GetWebFrame()->GetDocument().GetElementById( - blink::WebString::FromUTF8("text_input")); - - autofill_assistant_agent_->SetElementChecked( - web_element.GetDevToolsNodeIdForTest(), true, - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, SetElementValueForInput) { - LoadHTML(R"(<input id="id">)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(true)); - - const auto web_element = GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("id")) - .To<blink::WebFormControlElement>(); - - autofill_assistant_agent_->SetElementValue( - web_element.GetDevToolsNodeIdForTest(), u"value", - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); - - EXPECT_EQ(web_element.Value(), "value"); -} - -TEST_F(AutofillAssistantAgentBrowserTest, SetElementValueForSelect) { - LoadHTML(R"( - <select id="id"> - <option value="dog">Dog</option> - <option value="cat">Cat</option> - </select>)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(true)); - - const auto web_element = GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("id")) - .To<blink::WebFormControlElement>(); - - EXPECT_EQ(web_element.Value(), "dog"); - - autofill_assistant_agent_->SetElementValue( - web_element.GetDevToolsNodeIdForTest(), u"cat", - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); - - EXPECT_EQ(web_element.Value(), "cat"); -} - -TEST_F(AutofillAssistantAgentBrowserTest, - SetElementValueFailsForNonFormControl) { - LoadHTML(R"( - <div id="id"></div>)"); - - base::MockCallback<base::OnceCallback<void(bool)>> callback; - EXPECT_CALL(callback, Run(false)); - - const auto web_element = - GetMainRenderFrame()->GetWebFrame()->GetDocument().GetElementById( - blink::WebString::FromUTF8("id")); - - autofill_assistant_agent_->SetElementValue( - web_element.GetDevToolsNodeIdForTest(), u"value", - /* send_events= */ true, callback.Get()); - base::RunLoop().RunUntilIdle(); -} - -TEST_F(AutofillAssistantAgentBrowserTest, - SemanticPredictionsAreAddedAsAttributesWhenDebugging) { - // Add the debug switch to turn on DOM annotation - base::CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kAutofillAssistantDebugAnnotateDom); - - EXPECT_CALL(autofill_assistant_driver_, GetAnnotateDomModel) - .WillOnce(RunOnceCallback<1>(mojom::ModelStatus::kSuccess, - model_file_.Duplicate(), std::string())); - - base::MockCallback<base::OnceCallback<void(mojom::NodeDataStatus, - const std::vector<NodeData>&)>> - callback; - EXPECT_CALL(callback, Run(mojom::NodeDataStatus::kSuccess, SizeIs(1))); - - LoadHTML(R"( - <div> - <h1>Shipping address</h1> - <label for="street">Street Address</label><input id="street"> - </div>)"); - - autofill_assistant_agent_->GetSemanticNodes( - /* role= */ 47 /* ADDRESS_LINE1 */, - /* objective= */ 7 /* FILL_DELIVERY_ADDRESS */, - /* ignore_objective= */ false, - /* model_timeout= */ base::Milliseconds(1000), callback.Get()); - base::RunLoop().RunUntilIdle(); - - const auto web_element = - GetMainRenderFrame() - ->GetWebFrame() - ->GetDocument() - .GetElementById(blink::WebString::FromUTF8("street")) - .To<blink::WebFormControlElement>(); - EXPECT_EQ(web_element.GetAttribute("semantic-prediction").Ascii(), - "{role: 47, objective: 7}"); -} - -} // namespace -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.cc b/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.cc deleted file mode 100644 index ee30af96..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.cc +++ /dev/null
@@ -1,115 +0,0 @@ -// Copyright 2022 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h" - -#include "base/base64.h" -#include "base/containers/flat_map.h" -#include "base/json/json_reader.h" -#include "base/strings/strcat.h" -#include "base/strings/string_number_conversions.h" -#include "third_party/abseil-cpp/absl/types/optional.h" - -namespace autofill_assistant { - -namespace { - -constexpr char kRoleLabelsJsonParameter[] = "roles"; -constexpr char kObjectiveLabelsJsonParameter[] = "objectives"; - -} // namespace - -std::string NodeSignalsToDebugString( - const blink::AutofillAssistantNodeSignals& node_signals) { - std::ostringstream out; - - out << "AutofillAssistantNodeSignals {\n" - << "\tbackend_node_id: " << node_signals.backend_node_id - << "\n\tnode_features {"; - for (const auto& text : node_signals.node_features.text) { - out << "\n\t\ttext: " << text.Utf16(); - } - out << "\n\t\taria: " << node_signals.node_features.aria.Utf16() - << "\n\t\thtml_tag: " << node_signals.node_features.html_tag.Utf16() - << "\n\t\ttype: " << node_signals.node_features.type.Utf16() - << "\n\t\tinvisible_attributes: " - << node_signals.node_features.invisible_attributes.Utf16() - << "\n\t}\n\tlabel_features {"; - for (const auto& text : node_signals.label_features.text) { - out << "\n\t\ttext: " << text.Utf16(); - } - out << "\n\t}\n\tcontext_features {"; - for (const auto& header_text : node_signals.context_features.header_text) { - out << "\n\t\theader_text: " << header_text.Utf16(); - } - out << "\n\t\tform_type: " << node_signals.context_features.form_type.Utf16() - << "\n\t}\n}"; - - return out.str(); -} - -SemanticLabelsPair DecodeSemanticPredictionLabelsJson(std::string encodedJson) { - std::string decoded_json; - base::Base64Decode(encodedJson, &decoded_json); - absl::optional<base::Value> parsed_json = - base::JSONReader::Read(decoded_json); - - SemanticPredictionLabelMap roles; - SemanticPredictionLabelMap objectives; - if (parsed_json.has_value() && parsed_json.value().is_dict()) { - for (const auto [param, enum_list] : parsed_json->DictItems()) { - if ((param != kRoleLabelsJsonParameter && - param != kObjectiveLabelsJsonParameter) || - !enum_list.is_list()) { - continue; - } - auto* curr_map = - (param == kRoleLabelsJsonParameter ? &roles : &objectives); - for (const auto& enum_pair : enum_list.GetList()) { - if (!enum_pair.is_dict() || enum_pair.DictSize() != 2) { - continue; - } - - const base::Value* id = enum_pair.GetDict().Find("id"); - const base::Value* name = enum_pair.GetDict().Find("name"); - if (!(id && id->is_int() && name && name->is_string())) { - continue; - } - curr_map->try_emplace(id->GetInt(), name->GetString()); - } - } - } - return std::make_pair(roles, objectives); -} - -std::u16string SemanticPredictionResultToDebugString( - SemanticPredictionLabelMap roles, - SemanticPredictionLabelMap objectives, - const ModelExecutorResult& result, - bool ignore_objective) { - int role = result.role; - int objective = result.objective; - if (!roles.empty() || !objectives.empty()) { - std::string result_label = - roles.contains(role) ? roles.at(role) - : "(missing-label) " + base::NumberToString(role); - std::string objective_label = - objectives.contains(objective) - ? objectives.at(objective) - : "(missing-label) " + base::NumberToString(objective); - return base::StrCat( - {u"{role: ", std::u16string(result_label.begin(), result_label.end()), - u", objective: ", - std::u16string(objective_label.begin(), objective_label.end()), - (ignore_objective ? u"(ignored)}" : u"}"), - (result.used_override ? u"[override]" : u"")}); - } - - return base::StrCat({u"{role: ", base::NumberToString16(role), - u", objective: ", base::NumberToString16(objective), - (ignore_objective ? u"(ignored)}" : u"}"), - (result.used_override ? u"[override]" : u"")}); -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h b/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h deleted file mode 100644 index 1ef8ac6..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h +++ /dev/null
@@ -1,42 +0,0 @@ -// Copyright 2022 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_DEBUG_UTILS_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_DEBUG_UTILS_H_ - -#include <string> - -#include "base/containers/flat_map.h" -#include "components/autofill_assistant/content/renderer/autofill_assistant_model_executor_result.h" -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" - -namespace autofill_assistant { - -using SemanticPredictionLabelMap = base::flat_map<int, std::string>; -using SemanticLabelsPair = - std::pair<SemanticPredictionLabelMap, SemanticPredictionLabelMap>; - -std::string NodeSignalsToDebugString( - const blink::AutofillAssistantNodeSignals& node_signals); - -// Base64 encoded string that contains a JSON object in the following format: -// { -// "roles": [{"id": role_id, "name": label}...], -// "objectives": [{"id": objective_id, "name": label}...] -// } -// This function decodes and parses the string and returns a -// map<("roles"|"objectives"), map<id, label>> object if it's a valid JSON. -SemanticLabelsPair DecodeSemanticPredictionLabelsJson(std::string encodedJson); - -// Maps the role and objective indexes from a semantic prediction to their -// corresponding labels. -std::u16string SemanticPredictionResultToDebugString( - SemanticPredictionLabelMap roles, - SemanticPredictionLabelMap objectives, - const ModelExecutorResult& result, - bool ignore_objective); - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_AGENT_DEBUG_UTILS_H_
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils_unittest.cc b/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils_unittest.cc deleted file mode 100644 index 6c5d8cd1..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils_unittest.cc +++ /dev/null
@@ -1,218 +0,0 @@ -// Copyright 2022 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_agent_debug_utils.h" - -#include "base/base64.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace autofill_assistant { -namespace { - -class SemanticLabelsJsonParsingTest : public ::testing::Test { - protected: - ModelExecutorResult model_executor_result_ = - ModelExecutorResult(47, 7, false); -}; - -TEST_F(SemanticLabelsJsonParsingTest, ValidJson) { - std::string json_input = R"({ - "roles": [{"id": 47, "name": "ADDRESS_LINE1"}], - "objectives": [{"id": 7, "name": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: ADDRESS_LINE1, objective: FILL_DELIVERY_ADDRESS}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, UseOverrideField) { - std::string json_input = R"({ - "roles": [{"id": 47, "name": "ADDRESS_LINE1"}], - "objectives": [{"id": 7, "name": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: ADDRESS_LINE1, objective: FILL_DELIVERY_ADDRESS}[override]"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, ModelExecutorResult(47, 7, true), false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, ValidJson_MoreThanOneObjectPerList) { - std::string json_input = R"({ - "roles": [ - {"id": 0, "name": "UNKNOWN_ROLE"}, - {"id": 47, "name": "ADDRESS_LINE1"} - ], - "objectives": [ - {"id": 0, "name": "UNKNOWN_OBJECTIVE"}, - {"id": 7, "name": "FILL_DELIVERY_ADDRESS"} - ] - })"; - std::string expected_output = - "{role: ADDRESS_LINE1, objective: FILL_DELIVERY_ADDRESS}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_NotAnObject) { - std::string json_input = R"( [{"id": 47, "name": "ADDRESS_LINE1"}] )"; - std::string expected_output = "{role: 47, objective: 7}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_RolesNotPresent) { - std::string json_input = R"({ - "not_roles": [{"id": 47, "name": "ADDRESS_LINE1"}], - "objectives": [{"id": 7, "name": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: (missing-label) 47, objective: FILL_DELIVERY_ADDRESS}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_ObjectivesNotPresent) { - std::string json_input = R"({ - "roles": [{"id": 47, "name": "ADDRESS_LINE1"}], - "not_objectives": [{"id": 7, "name": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: ADDRESS_LINE1, objective: (missing-label) 7}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_EnumsNotAList) { - std::string json_input = R"({ - "roles": {"id": 47, "name": "ADDRESS_LINE1"}, - "objectives": {"id": 7, "name": "FILL_DELIVERY_ADDRESS"} - })"; - std::string expected_output = "{role: 47, objective: 7}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_IndexFieldNotNamedId) { - std::string json_input = R"({ - "roles": [{"index": 47, "name": "ADDRESS_LINE1"}], - "objectives": [{"id": 7, "name": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: (missing-label) 47, objective: FILL_DELIVERY_ADDRESS}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_LabelValueFieldNotNamedName) { - std::string json_input = R"({ - "roles": [{"id": 47, "name": "ADDRESS_LINE1"}], - "objectives": [{"id": 7, "label": "FILL_DELIVERY_ADDRESS"}] - })"; - std::string expected_output = - "{role: ADDRESS_LINE1, objective: (missing-label) 7}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -TEST_F(SemanticLabelsJsonParsingTest, InvalidJson_Empty) { - std::string json_input = ""; - std::string expected_output = "{role: 47, objective: 7}"; - - // Encode the JSON and add it to the debug DOM annotations switch - std::string base64_json; - base::Base64Encode(json_input, &base64_json); - - SemanticLabelsPair labels = DecodeSemanticPredictionLabelsJson(base64_json); - - std::u16string debug_string = SemanticPredictionResultToDebugString( - labels.first, labels.second, model_executor_result_, false); - EXPECT_EQ(debug_string, - std::u16string(expected_output.begin(), expected_output.end())); -} - -} // namespace -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.cc b/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.cc deleted file mode 100644 index 8b3a60b..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.cc +++ /dev/null
@@ -1,368 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h" - -#include <ostream> - -#include "autofill_assistant_model_executor.h" -#include "base/command_line.h" -#include "base/i18n/case_conversion.h" -#include "base/no_destructor.h" -#include "base/strings/utf_string_conversions.h" -#include "components/autofill_assistant/content/common/switches.h" -#include "components/optimization_guide/core/execution_status.h" -#include "components/optimization_guide/core/tflite_op_resolver.h" -#include "third_party/abseil-cpp/absl/status/status.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/tflite/src/tensorflow/lite/kernels/internal/runtime_shape.h" -#include "third_party/tflite/src/tensorflow/lite/kernels/internal/tensor_ctypes.h" -#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/task_utils.h" -#include "third_party/tflite_support/src/tensorflow_lite_support/metadata/cc/metadata_extractor.h" - -namespace autofill_assistant { -namespace { - -std::string SparseVectorToDebugString( - AutofillAssistantModelExecutor::SparseVector sparse_vector) { - std::ostringstream out; - out << "Sparse vector representation:\n"; - for (const auto& entry : sparse_vector) { - out << " [idx: [" << entry.first.first << ", " << entry.first.second - << "], count: " << entry.second << "]"; - } - return out.str(); -} - -void DenseEncode( - const AutofillAssistantModelExecutor::SparseVector& sparse_vector, - std::vector<std::vector<float>>& inputs) { - for (const auto& entry : sparse_vector) { - const auto& coordinates = entry.first; - if (static_cast<size_t>(coordinates.first) >= inputs.size()) { - NOTREACHED(); - continue; - } - if (static_cast<size_t>(coordinates.second) >= - inputs[coordinates.first].size()) { - NOTREACHED(); - continue; - } - inputs[coordinates.first][coordinates.second] = entry.second; - } -} - -} // namespace - -AutofillAssistantModelExecutor::AutofillAssistantModelExecutor( - absl::optional<OverridesMap> overrides) - : overrides_(std::move(overrides)) {} - -AutofillAssistantModelExecutor::~AutofillAssistantModelExecutor() = default; - -bool AutofillAssistantModelExecutor::InitializeModelFromFile( - base::File model_file) { - if (!model_file.IsValid() || !model_file_.Initialize(std::move(model_file))) { - return false; - } - - std::unique_ptr<tflite::task::core::TfLiteEngine> tflite_engine = - std::make_unique<tflite::task::core::TfLiteEngine>( - std::make_unique<optimization_guide::TFLiteOpResolver>()); - absl::Status model_load_status = tflite_engine->BuildModelFromFlatBuffer( - reinterpret_cast<const char*>(model_file_.data()), model_file_.length()); - if (!model_load_status.ok()) { - DLOG(ERROR) << "Failed to load model: " << model_load_status.ToString(); - return false; - } - absl::Status interpreter_status = tflite_engine->InitInterpreter( - tflite::proto::ComputeSettings(), /* num_threads= */ 1); - if (!interpreter_status.ok()) { - DLOG(ERROR) << "Failed to initialize model interpreter: " - << interpreter_status.ToString(); - return false; - } - - auto metadata_or = - tflite_engine->metadata_extractor()->GetAssociatedFile("metadata.pb"); - if (!metadata_or.ok()) { - DLOG(ERROR) << "Could not read metadata: " - << metadata_or.status().ToString(); - return false; - } - if (!model_metadata_.ParseFromArray(metadata_or->data(), - metadata_or->size())) { - DLOG(ERROR) << "Could not parse metadata."; - return false; - } - - InitializeTagsTokenizer("\\s+", model_metadata_.input().tag().vocabulary()); - InitializeTypesTokenizer("\\s+", model_metadata_.input().type().vocabulary()); - InitializeTextTokenizer(model_metadata_.input().text().regex(), - model_metadata_.input().text().vocabulary()); - - BuildExecutionTask(std::move(tflite_engine)); - - return true; -} - -void AutofillAssistantModelExecutor::BuildExecutionTask( - std::unique_ptr<tflite::task::core::TfLiteEngine> tflite_engine) { - execution_task_ = - std::make_unique<ExecutionTask>(std::move(tflite_engine), this); -} - -absl::optional<ModelExecutorResult> -AutofillAssistantModelExecutor::ExecuteModelWithInput( - const blink::AutofillAssistantNodeSignals& node_signals) { - if (!execution_task_) { - NOTREACHED() << "No available task"; - return absl::nullopt; - } - optimization_guide::ExecutionStatus out_status; - return Execute(execution_task_.get(), &out_status, node_signals); -} - -void AutofillAssistantModelExecutor::InitializeTagsTokenizer( - const std::string& pattern, - const std::string& vocabulary) { - DCHECK(!pattern.empty()); - DCHECK(!vocabulary.empty()); - tags_tokenizer_ = - std::make_unique<tflite::support::text::tokenizer::RegexTokenizer>( - pattern, vocabulary.data(), vocabulary.size()); -} - -void AutofillAssistantModelExecutor::InitializeTypesTokenizer( - const std::string& pattern, - const std::string& vocabulary) { - DCHECK(!pattern.empty()); - DCHECK(!vocabulary.empty()); - types_tokenizer_ = - std::make_unique<tflite::support::text::tokenizer::RegexTokenizer>( - pattern, vocabulary.data(), vocabulary.size()); -} - -void AutofillAssistantModelExecutor::InitializeTextTokenizer( - const std::string& pattern, - const std::string& vocabulary) { - DCHECK(!pattern.empty()); - DCHECK(!vocabulary.empty()); - text_tokenizer_ = - std::make_unique<tflite::support::text::tokenizer::RegexTokenizer>( - pattern, vocabulary.data(), vocabulary.size()); -} - -bool AutofillAssistantModelExecutor::Preprocess( - const std::vector<TfLiteTensor*>& input_tensors, - const blink::AutofillAssistantNodeSignals& node_signals) { - if (input_tensors.size() < 5u) { - NOTREACHED() << "Input tensors mismatch."; - return false; - } - - SparseVector sparse_vector = TokenizeSignalsToSparseVector(node_signals); - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantDebugAnnotateDom)) { - VLOG(3) << SparseVectorToDebugString(sparse_vector); - } - - if (overrides_ && overrides_->contains(sparse_vector)) { - overrides_result_ = (*overrides_)[sparse_vector]; - return true; - } - - std::vector<std::vector<float>> inputs; - for (const auto* input_tensor : input_tensors) { - tflite::RuntimeShape shape = tflite::GetTensorShape(input_tensor); - if (shape.DimensionsCount() < 2) { - return false; - } - inputs.emplace_back(std::vector(shape.Dims(1), 0.0f)); - } - DenseEncode(sparse_vector, inputs); - - for (size_t i = 0; i < inputs.size(); ++i) { - absl::Status tensor_status = - tflite::task::core::PopulateTensor<float>(inputs[i], input_tensors[i]); - if (!tensor_status.ok()) { - return false; - } - } - return true; -} - -bool AutofillAssistantModelExecutor::GetIndexOfBestRole( - const std::vector<float>& output_role, - size_t* index_of_best_role) const { - if (output_role.size() < - static_cast<size_t>( - model_metadata_.output().semantic_role().classes_size())) { - NOTREACHED(); - return false; - } - *index_of_best_role = std::distance( - output_role.begin(), - std::max_element( - output_role.begin(), - output_role.begin() + - model_metadata_.output().semantic_role().classes_size())); - return true; -} - -bool AutofillAssistantModelExecutor::GetBlockIndex( - const std::vector<float>& output_role, - size_t index_of_best_role, - int* block_index) const { - if (index_of_best_role >= - static_cast<size_t>(model_metadata_.output() - .semantic_role() - .objective_block_index_size())) { - NOTREACHED(); - return false; - } - *block_index = model_metadata_.output().semantic_role().objective_block_index( - index_of_best_role); - return true; -} - -bool AutofillAssistantModelExecutor::GetObjective( - const std::vector<float>& output_objective, - int block_index, - int* objective) const { - if (block_index + 1 >= model_metadata_.output().objective().blocks_size()) { - NOTREACHED(); - return false; - } - auto block_start = output_objective.begin() + - model_metadata_.output().objective().blocks(block_index); - auto block_end = output_objective.begin() + - model_metadata_.output().objective().blocks(block_index + 1); - size_t index_of_best_objective = std::distance( - output_objective.begin(), std::max_element(block_start, block_end)); - if (index_of_best_objective >= - static_cast<size_t>( - model_metadata_.output().objective().classes_size())) { - NOTREACHED(); - return false; - } - - *objective = - model_metadata_.output().objective().classes(index_of_best_objective); - return true; -} - -absl::optional<ModelExecutorResult> AutofillAssistantModelExecutor::Postprocess( - const std::vector<const TfLiteTensor*>& output_tensors) { - // Check if we have an override for this execution and return that instead. - if (overrides_result_) { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kAutofillAssistantDebugAnnotateDom)) { - VLOG(3) << "Found override, using (role: " << overrides_result_->first - << ", objective: " << overrides_result_->second << ")"; - } - // Cleanup the result in case this executor is reused. - ModelExecutorResult result(overrides_result_->first, - overrides_result_->second, true); - overrides_result_.reset(); - return result; - } - if (output_tensors.size() < 2u) { - NOTREACHED() << "Output Tensors mismatch."; - return absl::nullopt; - } - std::vector<float> output_role; - absl::Status role_status = tflite::task::core::PopulateVector<float>( - output_tensors[0], &output_role); - if (!role_status.ok()) { - return absl::nullopt; - } - std::vector<float> output_objective; - absl::Status objective_status = tflite::task::core::PopulateVector<float>( - output_tensors[1], &output_objective); - if (!objective_status.ok()) { - return absl::nullopt; - } - - size_t index_of_best_role; - if (!GetIndexOfBestRole(output_role, &index_of_best_role)) { - return absl::nullopt; - } - if (index_of_best_role >= - static_cast<size_t>( - model_metadata_.output().semantic_role().classes_size())) { - NOTREACHED(); - return absl::nullopt; - } - int semantic_role = - model_metadata_.output().semantic_role().classes(index_of_best_role); - if (semantic_role == 0) { - return ModelExecutorResult(/*r=*/0, /*o=*/0, /*with_override=*/false); - } - - int block_index; - if (!GetBlockIndex(output_role, index_of_best_role, &block_index)) { - return absl::nullopt; - } - int objective; - if (!GetObjective(output_objective, block_index, &objective)) { - return absl::nullopt; - } - - ModelExecutorResult result(semantic_role, objective, false); - return result; -} - -void AutofillAssistantModelExecutor::Tokenize( - const std::u16string& input, - tflite::support::text::tokenizer::RegexTokenizer* tokenizer, - const int feature_index, - SparseMap& output_map) { - auto result = - tokenizer->Tokenize(base::UTF16ToUTF8(base::i18n::ToUpper(input))); - for (const auto& token : result.subwords) { - int index; - if (tokenizer->LookupId(token, &index)) { - output_map[std::make_pair(feature_index, index)]++; - } - } -} - -AutofillAssistantModelExecutor::SparseVector -AutofillAssistantModelExecutor::TokenizeSignalsToSparseVector( - const blink::AutofillAssistantNodeSignals& node_signals) { - SparseMap sparse_map; - - DCHECK(tags_tokenizer_); - Tokenize(node_signals.node_features.html_tag.Utf16(), tags_tokenizer_.get(), - /* feature_index= */ 0, sparse_map); - DCHECK(types_tokenizer_); - Tokenize(node_signals.node_features.type.Utf16(), types_tokenizer_.get(), - /* feature_index= */ 1, sparse_map); - DCHECK(text_tokenizer_); - Tokenize(node_signals.node_features.invisible_attributes.Utf16(), - text_tokenizer_.get(), /* feature_index= */ 2, sparse_map); - for (const auto& text : node_signals.node_features.text) { - Tokenize(text.Utf16(), text_tokenizer_.get(), /* feature_index= */ 2, - sparse_map); - } - for (const auto& text : node_signals.label_features.text) { - Tokenize(text.Utf16(), text_tokenizer_.get(), /* feature_index= */ 3, - sparse_map); - } - for (const auto& text : node_signals.context_features.header_text) { - Tokenize(text.Utf16(), text_tokenizer_.get(), /* feature_index= */ 4, - sparse_map); - } - Tokenize(node_signals.context_features.form_type.Utf16(), - text_tokenizer_.get(), /* feature_index= */ 4, sparse_map); - - SparseVector sparse_vector; - for (const auto& entry : sparse_map) { - sparse_vector.emplace_back(entry); - } - return sparse_vector; -} - -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h b/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h deleted file mode 100644 index 88d662b..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h +++ /dev/null
@@ -1,124 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_H_ - -#include <string> -#include <utility> -#include <vector> - -#include "base/files/file.h" -#include "base/files/memory_mapped_file.h" -#include "components/autofill_assistant/content/renderer/autofill_assistant_model_executor_result.h" -#include "components/autofill_assistant/content/renderer/model_metadata.pb.h" -#include "components/optimization_guide/core/base_model_executor.h" -#include "components/optimization_guide/core/base_model_executor_helpers.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" -#include "third_party/tflite/src/tensorflow/lite/c/common.h" -#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/base_task_api.h" -#include "third_party/tflite_support/src/tensorflow_lite_support/cc/task/core/tflite_engine.h" -#include "third_party/tflite_support/src/tensorflow_lite_support/cc/text/tokenizers/regex_tokenizer.h" - -namespace autofill_assistant { - -// Holds and executes the AnnotateDOM model to predict semantic roles based on -// node signals. -class AutofillAssistantModelExecutor - : public optimization_guide::BaseModelExecutor< - ModelExecutorResult, - const blink::AutofillAssistantNodeSignals&> { - public: - using ExecutionTask = optimization_guide::GenericModelExecutionTask< - ModelExecutorResult, - const blink::AutofillAssistantNodeSignals&>; - using SparseVector = std::vector<std::pair<std::pair<int, int>, int>>; - using SparseMap = base::flat_map<std::pair<int, int>, int>; - using OverridesMap = base::flat_map<SparseVector, std::pair<int, int>>; - - explicit AutofillAssistantModelExecutor( - absl::optional<OverridesMap> policy = absl::nullopt); - ~AutofillAssistantModelExecutor() override; - - AutofillAssistantModelExecutor(const AutofillAssistantModelExecutor&) = - delete; - void operator=(const AutofillAssistantModelExecutor&) = delete; - - // Initialize the model from the |model_file|. Sets |model_initialized_|. - bool InitializeModelFromFile(base::File model_file); - - // Execute the model with the given input. - absl::optional<ModelExecutorResult> ExecuteModelWithInput( - const blink::AutofillAssistantNodeSignals& node_signals); - - protected: - // optimization_guide::InferenceDelegate: - bool Preprocess( - const std::vector<TfLiteTensor*>& input_tensors, - const blink::AutofillAssistantNodeSignals& node_signals) override; - absl::optional<ModelExecutorResult> Postprocess( - const std::vector<const TfLiteTensor*>& output_tensors) override; - - private: - // Initialize Tokenizers with |pattern| for splitting and the |vocabulary| in - // the form of "<word> <index>" per line. - void InitializeTagsTokenizer(const std::string& pattern, - const std::string& vocabulary); - void InitializeTypesTokenizer(const std::string& pattern, - const std::string& vocabulary); - void InitializeTextTokenizer(const std::string& pattern, - const std::string& vocabulary); - - // Build the execution task from the model file. - void BuildExecutionTask( - std::unique_ptr<tflite::task::core::TfLiteEngine> tflite_engine); - - // Tokenize the |input| and count words into the |output_map|. The same - // |output_map| should be reused for all relevant inputs for a signal. - void Tokenize(const std::u16string& input, - tflite::support::text::tokenizer::RegexTokenizer* tokenizer, - const int feature_index, - SparseMap& output_map); - - SparseVector TokenizeSignalsToSparseVector( - const blink::AutofillAssistantNodeSignals& node_signals); - - // Helper functions for post processing based on |model_metadata_|. - bool GetIndexOfBestRole(const std::vector<float>& output_role, - size_t* index_of_best_role) const; - bool GetBlockIndex(const std::vector<float>& output_role, - size_t index_of_best_role, - int* block_index) const; - bool GetObjective(const std::vector<float>& output_objective, - int block_index, - int* objective) const; - - // Tokenizer for HTML tag. - std::unique_ptr<tflite::support::text::tokenizer::RegexTokenizer> - tags_tokenizer_; - // Tokenizer for HTML attribute "type". - std::unique_ptr<tflite::support::text::tokenizer::RegexTokenizer> - types_tokenizer_; - // Tokenizer for arbitrary text. - std::unique_ptr<tflite::support::text::tokenizer::RegexTokenizer> - text_tokenizer_; - - // The task for this executor. - std::unique_ptr<ExecutionTask> execution_task_; - // Model file held in memory by this instance. - base::MemoryMappedFile model_file_; - // Model Metadata for handling input/output. - ModelMetadata model_metadata_; - // Data regarding business logic for model execution. - // Set if there is an override for this model execution. - // Sparse encoding of a feature vector table. - // The format is: overrides_[vector] = (semantic_role, objective) - absl::optional<OverridesMap> overrides_; - absl::optional<std::pair<int, int>> overrides_result_; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_H_
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_result.h b/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_result.h deleted file mode 100644 index 42c40fd..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_result.h +++ /dev/null
@@ -1,26 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_RESULT_H_ -#define COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_RESULT_H_ - -namespace autofill_assistant { - -// Result used to communicated model execution results between interested -// parties. -struct ModelExecutorResult { - ModelExecutorResult() = default; - ModelExecutorResult(int r, int o, bool with_override) - : role(r), objective(o), used_override(with_override) {} - - // Role and objective pair. - int role = 0; - int objective = 0; - // Whether this result came from an override. - bool used_override = false; -}; - -} // namespace autofill_assistant - -#endif // COMPONENTS_AUTOFILL_ASSISTANT_CONTENT_RENDERER_AUTOFILL_ASSISTANT_MODEL_EXECUTOR_RESULT_H_
diff --git a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_unittest.cc b/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_unittest.cc deleted file mode 100644 index 862620e..0000000 --- a/components/autofill_assistant/content/renderer/autofill_assistant_model_executor_unittest.cc +++ /dev/null
@@ -1,179 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/autofill_assistant/content/renderer/autofill_assistant_model_executor.h" - -#include <string> -#include <utility> -#include <vector> - -#include "base/files/file.h" -#include "base/files/file_path.h" -#include "base/path_service.h" -#include "base/strings/strcat.h" -#include "base/strings/string_number_conversions.h" -#include "base/strings/string_util.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/platform/web_string.h" -#include "third_party/blink/public/platform/web_vector.h" -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" - -namespace autofill_assistant { -namespace { - -using OverridesMap = AutofillAssistantModelExecutor::OverridesMap; -using SparseVector = AutofillAssistantModelExecutor::SparseVector; - -constexpr int kDummyObjective = 9999; -constexpr int kDummySemanticRole = 1111; - -class AutofillAssistantModelExecutorTest : public testing::Test { - public: - AutofillAssistantModelExecutorTest() { - base::FilePath model_file_path = - GetTestDataDir().AppendASCII("model.tflite"); - model_file_ = base::File(model_file_path, - (base::File::FLAG_OPEN | base::File::FLAG_READ)); - } - - ~AutofillAssistantModelExecutorTest() override = default; - - protected: - OverridesMap CreateOverrides() { - OverridesMap map; - SparseVector vector; - // First, create a feature vector of the feature "street" that is found - // twice on the website for the "second" feature index. - vector.push_back(std::make_pair( - std::make_pair(/* feature_index = */ 2, /* feature= */ 862), - /* count= */ 2)); - // Add an override with a dummy objetive and semantic role for that feature - // vector. - map[vector] = std::make_pair(kDummyObjective, kDummySemanticRole); - return map; - } - - base::File model_file_; - AutofillAssistantModelExecutor model_executor_; - - private: - base::FilePath GetTestDataDir() { - base::FilePath source_root_dir; - base::PathService::Get(base::DIR_SOURCE_ROOT, &source_root_dir); - return source_root_dir.AppendASCII("components") - .AppendASCII("test") - .AppendASCII("data") - .AppendASCII("autofill_assistant") - .AppendASCII("model"); - } -}; - -TEST_F(AutofillAssistantModelExecutorTest, DoesNotInitializeFromEmptyFile) { - EXPECT_FALSE(model_executor_.InitializeModelFromFile(base::File())); -} - -TEST_F(AutofillAssistantModelExecutorTest, OnlyInitializesModelOnce) { - EXPECT_TRUE(model_executor_.InitializeModelFromFile(model_file_.Duplicate())); - EXPECT_FALSE( - model_executor_.InitializeModelFromFile(model_file_.Duplicate())); -} - -TEST_F(AutofillAssistantModelExecutorTest, ExecuteWithLoadedModel) { - ASSERT_TRUE(model_executor_.InitializeModelFromFile(model_file_.Duplicate())); - - blink::AutofillAssistantNodeSignals node_signals; - node_signals.node_features.html_tag = blink::WebString::FromUTF8("INPUT"); - node_signals.node_features.type = blink::WebString::FromUTF8("TEXT"); - node_signals.node_features.text.push_back( - blink::WebString::FromUTF8("street")); - node_signals.label_features.text.push_back( - blink::WebString::FromUTF8("Street Address:")); - node_signals.label_features.text.push_back( - blink::WebString::FromUTF8("Line 1")); - node_signals.context_features.header_text.push_back( - blink::WebString::FromUTF8("Street Address")); - node_signals.context_features.header_text.push_back( - blink::WebString::FromUTF8("Checkout")); - node_signals.context_features.header_text.push_back( - blink::WebString::FromUTF8("SHIPPING")); - - auto result = model_executor_.ExecuteModelWithInput(node_signals); - ASSERT_TRUE(result.has_value()); - EXPECT_EQ(result->role, 47 /* ADDRESS_LINE1 */); - EXPECT_EQ(result->objective, 7 /* FILL_DELIVERY_ADDRESS */); -} - -TEST_F(AutofillAssistantModelExecutorTest, OverridesMatch) { - AutofillAssistantModelExecutor model_executor = - AutofillAssistantModelExecutor(CreateOverrides()); - - ASSERT_TRUE(model_executor.InitializeModelFromFile(model_file_.Duplicate())); - - blink::AutofillAssistantNodeSignals node_signals; - node_signals.node_features.invisible_attributes = - blink::WebString::FromUTF8("street"); - node_signals.node_features.text.push_back( - blink::WebString::FromUTF8("street")); - - auto result = model_executor.ExecuteModelWithInput(node_signals); - ASSERT_TRUE(result.has_value()); - EXPECT_EQ(result->role, 9999); - EXPECT_EQ(result->objective, 1111); - EXPECT_TRUE(result->used_override); -} - -TEST_F(AutofillAssistantModelExecutorTest, OverridesNoMatch) { - AutofillAssistantModelExecutor model_executor = - AutofillAssistantModelExecutor(CreateOverrides()); - - ASSERT_TRUE(model_executor.InitializeModelFromFile(model_file_.Duplicate())); - - blink::AutofillAssistantNodeSignals node_signals; - node_signals.node_features.text.push_back( - blink::WebString::FromUTF8("street")); - - auto result = model_executor.ExecuteModelWithInput(node_signals); - ASSERT_TRUE(result.has_value()); - EXPECT_NE(result->role, 9999); - EXPECT_NE(result->objective, 1111); - EXPECT_FALSE(result->used_override); -} - -TEST_F(AutofillAssistantModelExecutorTest, OverridesResultNotReused) { - AutofillAssistantModelExecutor model_executor = - AutofillAssistantModelExecutor(CreateOverrides()); - - ASSERT_TRUE(model_executor.InitializeModelFromFile(model_file_.Duplicate())); - { - blink::AutofillAssistantNodeSignals node_signals; - node_signals.node_features.invisible_attributes = - blink::WebString::FromUTF8("street"); - node_signals.node_features.text.push_back( - blink::WebString::FromUTF8("street")); - - auto result = model_executor.ExecuteModelWithInput(node_signals); - ASSERT_TRUE(result.has_value()); - EXPECT_EQ(result->role, 9999); - EXPECT_EQ(result->objective, 1111); - EXPECT_TRUE(result->used_override); - } - - // We expect the internal overrides result from the previous execution to have - // been cleared. - { - blink::AutofillAssistantNodeSignals node_signals; - node_signals.node_features.text.push_back( - blink::WebString::FromUTF8("unknown")); - - auto result = model_executor.ExecuteModelWithInput(node_signals); - ASSERT_TRUE(result.has_value()); - EXPECT_NE(result->role, 9999); - EXPECT_NE(result->objective, 1111); - EXPECT_FALSE(result->used_override); - } -} - -} // namespace -} // namespace autofill_assistant
diff --git a/components/autofill_assistant/content/renderer/model_metadata.proto b/components/autofill_assistant/content/renderer/model_metadata.proto deleted file mode 100644 index 8d4503de..0000000 --- a/components/autofill_assistant/content/renderer/model_metadata.proto +++ /dev/null
@@ -1,71 +0,0 @@ -// Copyright 2022 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -syntax = "proto2"; - -option optimize_for = LITE_RUNTIME; - -package autofill_assistant; - -// Metadata required to preprocess the model inputs and postprocess the model -// outputs. -message ModelMetadata { - // Metadata to preprocess the tag features. - message TagMetadata { - // Vocabulary in the format needed by RegexTokenizer (one token and token - // index per line). - optional string vocabulary = 1; - } - // Metadata to preprocess the type features. - message TypeMetadata { - // Vocabulary in the format needed by RegexTokenizer (one token and token - // index per line). - optional string vocabulary = 1; - } - // Metadata to preprocess the text features. - message TextMetadata { - // Vocabulary in the format needed by RegexTokenizer (one token and token - // index per line). - optional string vocabulary = 1; - // Regex for the RegexTokenizer. - optional string regex = 2; - } - // Metadata needed to preprocess the model inputs. - message InputMetadata { - optional TagMetadata tag = 1; - optional TypeMetadata type = 2; - optional TextMetadata text = 3; - } - - // Metadata used to evaluate the semantic role. - message SemanticRoleMetadata { - // List of semantic roles corresponding to each index of the semantic role - // output vector. - repeated int32 classes = 1 [packed = true]; - // For each index i of the output vector, objective_block_index[i] gives the - // index of the block of objectives to read to decode the objective. See - // ObjectiveMetadata.blocks. - repeated int32 objective_block_index = 2 [packed = true]; - } - // Metadata used to evaluate the objective. - message ObjectiveMetadata { - // List of objectives corresponding to each index of the objective output - // vector. - repeated int32 classes = 1 [packed = true]; - // A list of integers describing how to split the objective output vector v - // into interpretable blocks. The outputs v[blocks[i]:blocks[i+1]] - // correspond to the scores of a block of objective predictions. In - // particular, blocks[-1] is always equal to the size of the objective - // output vector. - repeated int32 blocks = 2 [packed = true]; - } - // Metadata needed to interpret the model outputs. - message OutputMetadata { - optional SemanticRoleMetadata semantic_role = 1; - optional ObjectiveMetadata objective = 2; - } - - optional InputMetadata input = 1; - optional OutputMetadata output = 2; -}
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java index 2b34ce3..d6150d1 100644 --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/ContentSettingsResources.java
@@ -158,10 +158,10 @@ : R.string.cookies_title, ContentSettingValues.ALLOW, ContentSettingValues.BLOCK, delegate.isPrivacySandboxSettings4Enabled() - ? R.string.website_settings_category_site_data_page_allow_radio_label + ? R.string.website_settings_site_data_page_toggle_sub_label_allow : R.string.website_settings_category_cookie_allowed, delegate.isPrivacySandboxSettings4Enabled() - ? R.string.website_settings_category_site_data_page_block_radio_label + ? R.string.website_settings_site_data_page_toggle_sub_label_block : 0); case ContentSettingsType.REQUEST_DESKTOP_SITE:
diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java index 73493345..07ce3ae 100644 --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleCategorySettings.java
@@ -525,28 +525,26 @@ PrefService prefService = UserPrefs.get(browserContextHandle); if (BINARY_TOGGLE_KEY.equals(preference.getKey())) { assert !mCategory.isManaged(); + boolean toggleValue = (boolean) newValue; - for (@SiteSettingsCategory.Type int type = 0; - type < SiteSettingsCategory.Type.NUM_ENTRIES; type++) { - if (mCategory.getType() != type) { - continue; - } - - WebsitePreferenceBridge.setCategoryEnabled(browserContextHandle, - SiteSettingsCategory.contentSettingsType(type), (boolean) newValue); - - if (type == SiteSettingsCategory.Type.NOTIFICATIONS) { - updateNotificationsSecondaryControls(); - } else if (type == SiteSettingsCategory.Type.AUTO_DARK_WEB_CONTENT) { - AutoDarkMetrics.recordAutoDarkSettingsChangeSource( - AutoDarkSettingsChangeSource.SITE_SETTINGS_GLOBAL, (boolean) newValue); - } else if (type == SiteSettingsCategory.Type.REQUEST_DESKTOP_SITE) { - recordSiteLayoutChanged((boolean) newValue); - updateDesktopSiteSecondaryControls(); - } - break; + @SiteSettingsCategory.Type + int type = mCategory.getType(); + if (type == SiteSettingsCategory.Type.SITE_DATA && !toggleValue) { + showDisableSiteDataConfirmationDialog(); + return false; } + WebsitePreferenceBridge.setCategoryEnabled(browserContextHandle, + SiteSettingsCategory.contentSettingsType(type), toggleValue); + if (type == SiteSettingsCategory.Type.NOTIFICATIONS) { + updateNotificationsSecondaryControls(); + } else if (type == SiteSettingsCategory.Type.AUTO_DARK_WEB_CONTENT) { + AutoDarkMetrics.recordAutoDarkSettingsChangeSource( + AutoDarkSettingsChangeSource.SITE_SETTINGS_GLOBAL, toggleValue); + } else if (type == SiteSettingsCategory.Type.REQUEST_DESKTOP_SITE) { + recordSiteLayoutChanged(toggleValue); + updateDesktopSiteSecondaryControls(); + } getInfoForOrigins(); } else if (TRI_STATE_TOGGLE_KEY.equals(preference.getKey())) { @ContentSettingValues @@ -577,6 +575,29 @@ return true; } + private void showDisableSiteDataConfirmationDialog() { + assert mCategory.getType() == SiteSettingsCategory.Type.SITE_DATA; + BrowserContextHandle browserContextHandle = + getSiteSettingsDelegate().getBrowserContextHandle(); + AlertDialog.Builder builder = + new AlertDialog.Builder(getContext(), R.style.ThemeOverlay_BrowserUI_AlertDialog); + builder.setTitle(R.string.website_settings_site_data_page_block_confirm_dialog_title) + .setMessage( + R.string.website_settings_site_data_page_block_confirm_dialog_description) + .setNegativeButton( + R.string.website_settings_site_data_page_block_confirm_dialog_cancel_button, + null) + .setPositiveButton( + R.string.website_settings_site_data_page_block_confirm_dialog_confirm_button, + (dialog, which) -> { + WebsitePreferenceBridge.setCategoryEnabled(browserContextHandle, + mCategory.getContentSettingsType(), false); + getInfoForOrigins(); + dialog.dismiss(); + }); + builder.show(); + } + private void setCookieSettingsPreference(CookieSettingsState state) { assert mCategory.getType() == SiteSettingsCategory.Type.COOKIES; boolean allowCookies; @@ -669,8 +690,8 @@ case SiteSettingsCategory.Type.SITE_DATA: resource = WebsitePreferenceBridge.isCategoryEnabled( browserContextHandle, ContentSettingsType.COOKIES) - ? R.string.website_settings_add_site_description_site_data_block - : R.string.website_settings_add_site_description_site_data_allow; + ? R.string.website_settings_site_data_page_add_block_exception_description + : R.string.website_settings_site_data_page_add_allow_exception_description; break; case SiteSettingsCategory.Type.THIRD_PARTY_COOKIES: resource = getCookieControlsMode() == CookieControlsMode.BLOCK_THIRD_PARTY @@ -1061,6 +1082,8 @@ Preference infoText = screen.findPreference(INFO_TEXT_KEY); if (mCategory.getType() == SiteSettingsCategory.Type.COOKIES) { infoText.setSummary(R.string.website_settings_cookie_info); + } else if (mCategory.getType() == SiteSettingsCategory.Type.SITE_DATA) { + infoText.setSummary(R.string.website_settings_site_data_page_description); } else if (mCategory.getType() == SiteSettingsCategory.Type.THIRD_PARTY_COOKIES) { infoText.setSummary(R.string.website_settings_third_party_cookies_page_description); } else {
diff --git a/components/browser_ui/strings/android/browser_ui_strings.grd b/components/browser_ui/strings/android/browser_ui_strings.grd index 3eb2a0c..b8557b2 100644 --- a/components/browser_ui/strings/android/browser_ui_strings.grd +++ b/components/browser_ui/strings/android/browser_ui_strings.grd
@@ -568,9 +568,6 @@ <message name="IDS_PAGE_INFO_COOKIES_CLEAR_CONFIRMATION" desc="Description of the confirmation dialog when the user clicked 'Delete cookies'."> This deletes cookies and other site data for <ph name="WEBSITE">%1$s<ex>example.com</ex></ph> </message> - <message name="IDS_PAGE_INFO_COOKIES_CLEAR_FPS_CONFIRMATION" desc="Description of the confirmation dialog when the user clicked 'Delete cookies'."> - This deletes cookies and other site data for <ph name="FPS_MEMBER">%1$s<ex>freep.com</ex></ph> and for sites in <ph name="FPS_OWNER">%2$s<ex>gannett.com</ex></ph>’s group of sites - </message> <message name="IDS_PAGE_INFO_COOKIES_CLEAR_CONFIRMATION_BUTTON" desc="Button in the confirmation dialog when the user clicked 'Delete cookies'."> Delete </message>
diff --git a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_COOKIES_CLEAR_FPS_CONFIRMATION.png.sha1 b/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_COOKIES_CLEAR_FPS_CONFIRMATION.png.sha1 deleted file mode 100644 index 940d24b..0000000 --- a/components/browser_ui/strings/android/browser_ui_strings_grd/IDS_PAGE_INFO_COOKIES_CLEAR_FPS_CONFIRMATION.png.sha1 +++ /dev/null
@@ -1 +0,0 @@ -4d44c666b2ae6286a76d2f509b93914a8af86546 \ No newline at end of file
diff --git a/components/browser_ui/strings/android/site_settings.grdp b/components/browser_ui/strings/android/site_settings.grdp index 5b8888fe..73bb6444 100644 --- a/components/browser_ui/strings/android/site_settings.grdp +++ b/components/browser_ui/strings/android/site_settings.grdp
@@ -387,21 +387,43 @@ <message name="IDS_WEBSITE_SETTINGS_CATEGORY_COOKIE_ALLOWED" desc="Summary text explaining that sites are allowed to use cookies and that it is the recommended setting."> Allow sites to save and read cookie data (recommended) </message> - <message name="IDS_WEBSITE_SETTINGS_CATEGORY_SITE_DATA_PAGE_ALLOW_RADIO_LABEL" desc="Summary text explaining that sites are allowed to use cookies." translateable="false"> - Sites can save data on your device - </message> - <message name="IDS_WEBSITE_SETTINGS_CATEGORY_SITE_DATA_PAGE_BLOCK_RADIO_LABEL" desc="Summary text explaining that sites are blocked from using cookies and that it is not a recommended setting." translateable="false"> - Don't allow sites to save data on your device (not recommended) - </message> <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_COOKIES_ALLOW" desc="The description for the allow Cookies for website dialog."> Allow cookies for a specific site. </message> <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_COOKIES_BLOCK" desc="The description for the block Cookies for website dialog."> Block cookies for a specific site. </message> - <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_SITE_DATA_ALLOW" desc="The description for the allow site data for website dialog." translateable="false"> + + <!-- Site data page --> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_DESCRIPTION" desc="" translateable="false"> + Sed finibus augue vel risus pellentesque, id auctor enim congue. Donec tincidunt pulvinar orci, et mattis dolor egestas ut. Nam ultrices mauris tortor, et maximus arcu iaculis vitae. + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_TOGGLE_SUB_LABEL_ALLOW" desc="" translateable="false"> + Sites can save data on your device + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_TOGGLE_SUB_LABEL_BLOCK" desc="" translateable="false"> + Don't allow sites to save data on your device (not recommended) + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_ADD_ALLOW_EXCEPTION_DESCRIPTION" desc="" translateable="false"> Allow site data for a specific site. </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_ADD_BLOCK_EXCEPTION_DESCRIPTION" desc="" translateable="false"> + Block site data for a specific site. + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_BLOCK_CONFIRM_DIALOG_TITLE" desc="" translateable="false"> + Duis non nisi sed lectus viverra venenati? + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_BLOCK_CONFIRM_DIALOG_DESCRIPTION" desc="" translateable="false"> + Suspendisse vitae malesuada purus, ut molestie eros. Fusce malesuada ullamcorper sem a blandit. + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_BLOCK_CONFIRM_DIALOG_CONFIRM_BUTTON" desc="" translateable="false"> + Turn off + </message> + <message name="IDS_WEBSITE_SETTINGS_SITE_DATA_PAGE_BLOCK_CONFIRM_DIALOG_CANCEL_BUTTON" desc="" translateable="false"> + Cancel + </message> + + <!-- Third-party cookies page --> <message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_COOKIES_PAGE_DESCRIPTION" desc="" translateable="false"> Suspendisse non porta leo. Donec egestas semper justo, ac ultricies quam malesuada a. Sed vestibulum enim non consectetur volutpat. Nullam vel dolor at nunc pulvinar lobortis quis aliquam nulla. Curabitur id pharetra felis, at tempor urna. </message> @@ -426,9 +448,6 @@ <message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_COOKIES_PAGE_BLOCK_RADIO_SUB_LABEL_FPS_ADDITION" desc="" translateable="false"> Related sites can see your activity in the group </message> - <message name="IDS_WEBSITE_SETTINGS_ADD_SITE_DESCRIPTION_SITE_DATA_BLOCK" desc="The description for the block site data for website dialog." translateable="false"> - Block site data for a specific site. - </message> <message name="IDS_WEBSITE_SETTINGS_THIRD_PARTY_COOKIES_PAGE_ADD_ALLOW_EXCEPTION_DESCRIPTION" desc="The description for the allow third-party cookies for website dialog." translateable="false"> Allow third-party cookies for a specific site. </message>
diff --git a/components/content_settings/browser/page_specific_content_settings_unittest.cc b/components/content_settings/browser/page_specific_content_settings_unittest.cc index ea04847e..2844cf4 100644 --- a/components/content_settings/browser/page_specific_content_settings_unittest.cc +++ b/components/content_settings/browser/page_specific_content_settings_unittest.cc
@@ -593,11 +593,10 @@ : public PageSpecificContentSettingsTest { public: PageSpecificContentSettingsWithPrerenderTest() { - feature_list_.InitWithFeatures( - {blink::features::kPrerender2}, + feature_list_.InitAndDisableFeature( // Disable the memory requirement of Prerender2 so the test can run on // any bot. - {blink::features::kPrerender2MemoryControls}); + blink::features::kPrerender2MemoryControls); } ~PageSpecificContentSettingsWithPrerenderTest() override = default;
diff --git a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java index ede49f2..d057f9d1 100644 --- a/components/cronet/android/api/src/org/chromium/net/CronetEngine.java +++ b/components/cronet/android/api/src/org/chromium/net/CronetEngine.java
@@ -11,6 +11,7 @@ import androidx.annotation.VisibleForTesting; import java.io.IOException; +import java.lang.reflect.Method; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandlerFactory; @@ -91,6 +92,8 @@ // NOTE(kapishnikov): In order to avoid breaking the existing API clients, all future methods // added to this class and other API classes must have default implementation. public static class Builder { + private static final String TAG = "CronetEngine.Builder"; + /** * A class which provides a method for loading the cronet native library. Apps needing to * implement custom library loading logic can inherit from this class and pass an instance @@ -386,6 +389,14 @@ * @return constructed {@link CronetEngine}. */ public CronetEngine build() { + int implLevel = getImplementationApiLevel(); + if (implLevel != -1 && implLevel < getMaximumApiLevel()) { + Log.w(TAG, + "The implementation version is lower than the API version. Calls to " + + "methods added in API " + (implLevel + 1) + " and newer will " + + "likely have no effect."); + } + return mBuilderDelegate.build(); } @@ -494,6 +505,29 @@ } return Integer.signum(s1segments.length - s2segments.length); } + + private int getMaximumApiLevel() { + return ApiVersion.getMaximumAvailableApiLevel(); + } + + /** + * Returns the implementation version, the implementation being represented by the delegate + * builder, or {@code -1} if the version couldn't be retrieved. + */ + private int getImplementationApiLevel() { + try { + ClassLoader implClassLoader = mBuilderDelegate.getClass().getClassLoader(); + Class<?> implVersionClass = + implClassLoader.loadClass("org.chromium.net.impl.ImplVersion"); + Method getApiLevel = implVersionClass.getMethod("getApiLevel"); + int implementationApiLevel = (Integer) getApiLevel.invoke(null); + + return implementationApiLevel; + } catch (Exception e) { + // Any exception in the block above isn't critical, don't bother the app about it. + return -1; + } + } } /**
diff --git a/components/cronet/android/test/javatests/AndroidManifest.xml b/components/cronet/android/test/javatests/AndroidManifest.xml index 178e610a..3b3eef7d 100644 --- a/components/cronet/android/test/javatests/AndroidManifest.xml +++ b/components/cronet/android/test/javatests/AndroidManifest.xml
@@ -36,7 +36,13 @@ <application android:name="org.chromium.net.CronetTestApplication" android:label="Cronet Test" android:networkSecurityConfig="@xml/network_security_config" - android:requestLegacyExternalStorage="true" /> + android:requestLegacyExternalStorage="true"> + <!-- Disables at startup init of Emoji2. See crbug.com/1393109. --> + <provider android:authorities="org.chromium.net.tests.androidx-startup" + android:name="androidx.startup.InitializationProvider" + android:exported="false" + tools:node="remove" /> + </application> <!-- Does not use BaseChromiumAndroidJUnitRunner so that it's easy to run tests when dropped into non-chromium repositories. --> <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
diff --git a/components/device_signals/core/common/signals_constants.cc b/components/device_signals/core/common/signals_constants.cc index 7b58679..7b54db4 100644 --- a/components/device_signals/core/common/signals_constants.cc +++ b/components/device_signals/core/common/signals_constants.cc
@@ -8,6 +8,10 @@ namespace names { +// Sub-property name for representing an Agent ID value. This is used for +// forwarding third-party agent signals. +const char kAgentId[] = "agentId"; + // Name of the signal for getting information of the AllowScreenLock // policy https://chromeenterprise.google/policies/?policy=AllowScreenLock. const char kAllowScreenLock[] = "allowSreenLock"; @@ -27,6 +31,14 @@ // access other computers from Chrome using Chrome Remote Desktop. const char kChromeRemoteDesktopAppBlocked[] = "chromeRemoteDesktopAppBlocked"; +// Name of a signal object containing information about a CrowdStrike agent +// currently installed. +const char kCrowdStrike[] = "crowdStrike"; + +// Sub-property name for representing a Customer ID value. This is used for +// forwarding third-party agent signals. +const char kCustomerId[] = "customerId"; + // Customer IDs of organizations that are affiliated with the organization // that is currently managing the device (or browser for non-CrOS platforms). const char kDeviceAffiliationIds[] = "deviceAffiliationIds";
diff --git a/components/device_signals/core/common/signals_constants.h b/components/device_signals/core/common/signals_constants.h index 09b133ad..1a3bb51 100644 --- a/components/device_signals/core/common/signals_constants.h +++ b/components/device_signals/core/common/signals_constants.h
@@ -11,11 +11,14 @@ // dictionaries. namespace names { +extern const char kAgentId[]; extern const char kAllowScreenLock[]; extern const char kBrowserVersion[]; extern const char kBuiltInDnsClientEnabled[]; extern const char kChromeCleanupEnabled[]; extern const char kChromeRemoteDesktopAppBlocked[]; +extern const char kCrowdStrike[]; +extern const char kCustomerId[]; extern const char kDeviceAffiliationIds[]; extern const char kDeviceHostName[]; extern const char kDeviceManufacturer[];
diff --git a/components/device_signals/test/BUILD.gn b/components/device_signals/test/BUILD.gn index d804659d..654dec3 100644 --- a/components/device_signals/test/BUILD.gn +++ b/components/device_signals/test/BUILD.gn
@@ -13,6 +13,7 @@ deps = [ "//base", + "//base/test:test_support", "//components/device_signals/core/common", ] }
diff --git a/components/device_signals/test/signals_contract.cc b/components/device_signals/test/signals_contract.cc index d958a7a..64b62ff 100644 --- a/components/device_signals/test/signals_contract.cc +++ b/components/device_signals/test/signals_contract.cc
@@ -6,6 +6,7 @@ #include "base/bind.h" #include "base/callback.h" +#include "base/test/bind.h" #include "build/build_config.h" #include "components/device_signals/core/common/signals_constants.h" @@ -152,6 +153,29 @@ base::BindRepeating(VerifyOptionalString, names::kWindowsUserDomain); contract[names::kSecureBootEnabled] = base::BindRepeating(VerifyIsSettingInteger, names::kSecureBootEnabled); + + contract[names::kCrowdStrike] = + base::BindLambdaForTesting([](const base::Value::Dict& signals) { + // CrowdStrike signals are optional. But if the object is set, then at + // least one of the values must be present. + auto* cs_value = signals.Find(device_signals::names::kCrowdStrike); + if (!cs_value) { + return true; + } + + if (!cs_value->is_dict()) { + return false; + } + + const auto& cs_dict = cs_value->GetDict(); + auto* customer_id = + cs_dict.FindString(device_signals::names::kCustomerId); + auto* agent_id = cs_dict.FindString(device_signals::names::kAgentId); + + return (customer_id && !customer_id->empty()) || + (agent_id && !agent_id->empty()); + }); + #else // Windows-only signals that shouldn't be set on other platforms. contract[names::kChromeCleanupEnabled] = @@ -162,6 +186,8 @@ base::BindRepeating(VerifyUnset, names::kWindowsUserDomain); contract[names::kSecureBootEnabled] = base::BindRepeating(VerifyUnset, names::kSecureBootEnabled); + contract[names::kCrowdStrike] = + base::BindRepeating(VerifyUnset, names::kCrowdStrike); #endif #if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
diff --git a/components/optimization_guide/content/browser/page_text_observer_unittest.cc b/components/optimization_guide/content/browser/page_text_observer_unittest.cc index fc85846..4d26ecc 100644 --- a/components/optimization_guide/content/browser/page_text_observer_unittest.cc +++ b/components/optimization_guide/content/browser/page_text_observer_unittest.cc
@@ -1067,11 +1067,10 @@ class PageTextObserverWithPrerenderTest : public PageTextObserverTest { public: PageTextObserverWithPrerenderTest() { - scoped_feature_list_.InitWithFeatures( - {blink::features::kPrerender2}, + scoped_feature_list_.InitAndDisableFeature( // Disable the memory requirement of Prerender2 so the test can run on // any bot. - {blink::features::kPrerender2MemoryControls}); + blink::features::kPrerender2MemoryControls); } ~PageTextObserverWithPrerenderTest() override = default;
diff --git a/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoCookiesPreference.java b/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoCookiesPreference.java index b7c657b8f..d355bb1 100644 --- a/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoCookiesPreference.java +++ b/components/page_info/android/java/src/org/chromium/components/page_info/PageInfoCookiesPreference.java
@@ -120,12 +120,8 @@ new AlertDialog.Builder(getContext(), R.style.ThemeOverlay_BrowserUI_AlertDialog) .setTitle(R.string.page_info_cookies_clear) .setMessage(R.string.page_info_cookies_clear_confirmation) - .setMessage(mFPSInfo != null - ? getContext().getString( - R.string.page_info_cookies_clear_fps_confirmation, - mHostName, mFPSInfo.getOwner()) - : getString(R.string.page_info_cookies_clear_confirmation, - mHostName)) + .setMessage( + getString(R.string.page_info_cookies_clear_confirmation, mHostName)) .setPositiveButton(R.string.page_info_cookies_clear_confirmation_button, (dialog, which) -> mOnClearCallback.run()) .setNegativeButton(
diff --git a/components/page_load_metrics/browser/observers/page_load_metrics_observer_content_test_harness.cc b/components/page_load_metrics/browser/observers/page_load_metrics_observer_content_test_harness.cc index f2fd63a..8159234 100644 --- a/components/page_load_metrics/browser/observers/page_load_metrics_observer_content_test_harness.cc +++ b/components/page_load_metrics/browser/observers/page_load_metrics_observer_content_test_harness.cc
@@ -20,7 +20,6 @@ PageLoadMetricsObserverContentTestHarness() { scoped_feature_list_.InitWithFeaturesAndParameters( { - {blink::features::kPrerender2, {}}, {blink::features::kFencedFrames, {{"implementation_type", "mparch"}}}, }, {
diff --git a/components/password_manager/core/common/password_manager_features.h b/components/password_manager/core/common/password_manager_features.h index e2e3e036..e7886132 100644 --- a/components/password_manager/core/common/password_manager_features.h +++ b/components/password_manager/core/common/password_manager_features.h
@@ -97,6 +97,13 @@ constexpr base::FeatureParam<bool> kPasswordChangeLiveExperimentParam = { &kPasswordDomainCapabilitiesFetching, "live_experiment", false}; +// If true, then password strength indicator will display a minimized state for +// passwords with more than 5 characters as long as they are weak. Otherwise, +// the full dropdown will be displayed as long as the password is weak. +constexpr base::FeatureParam<bool> + kPasswordStrengthIndicatorWithMinimizedState = { + &kPasswordStrengthIndicator, "strength_indicator_minimized", false}; + #if BUILDFLAG(IS_ANDROID) extern const base::FeatureParam<int> kMigrationVersion;
diff --git a/components/performance_manager/public/mojom/v8_contexts.mojom b/components/performance_manager/public/mojom/v8_contexts.mojom index ec7f7da1..0da5891 100644 --- a/components/performance_manager/public/mojom/v8_contexts.mojom +++ b/components/performance_manager/public/mojom/v8_contexts.mojom
@@ -26,6 +26,8 @@ kMain, // Corresponds to the main world of a worker or worklet. kWorkerOrWorklet, + // Corresponds to a ShadowRealm. + kShadowRealm, // Corresponds to an extension. Will have a stable extension ID. kExtension, // Corresponds to a non-extension isolated world. Will have a human readable
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_helpers.cc b/components/performance_manager/v8_memory/v8_context_tracker_helpers.cc index 645c439..5361d6e2 100644 --- a/components/performance_manager/v8_memory/v8_context_tracker_helpers.cc +++ b/components/performance_manager/v8_memory/v8_context_tracker_helpers.cc
@@ -119,6 +119,15 @@ return V8ContextDescriptionStatus::kUnexpectedLocalFrameToken; } break; + case mojom::V8ContextWorldType::kShadowRealm: { + if (description.world_name) + return V8ContextDescriptionStatus::kUnexpectedWorldName; + if (!description.execution_context_token) + return V8ContextDescriptionStatus::kMissingExecutionContextToken; + if (!description.execution_context_token->Is<blink::ShadowRealmToken>()) + return V8ContextDescriptionStatus::kMissingShadowRealmToken; + } break; + case mojom::V8ContextWorldType::kExtension: { if (!description.world_name) return V8ContextDescriptionStatus::kMissingWorldName; @@ -180,6 +189,7 @@ } case mojom::V8ContextWorldType::kWorkerOrWorklet: + case mojom::V8ContextWorldType::kShadowRealm: case mojom::V8ContextWorldType::kExtension: case mojom::V8ContextWorldType::kIsolated: case mojom::V8ContextWorldType::kInspector:
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_helpers.h b/components/performance_manager/v8_memory/v8_context_tracker_helpers.h index 3f9e8b90..4e11eab 100644 --- a/components/performance_manager/v8_memory/v8_context_tracker_helpers.h +++ b/components/performance_manager/v8_memory/v8_context_tracker_helpers.h
@@ -67,6 +67,7 @@ kMissingLocalFrameToken, kUnexpectedLocalFrameToken, kUnexpectedWorkletToken, + kMissingShadowRealmToken, }; // Validates the given V8ContextDescription.
diff --git a/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc b/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc index f7709b4..2c89c352 100644 --- a/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc +++ b/components/performance_manager/v8_memory/v8_context_tracker_helpers_unittest.cc
@@ -206,6 +206,41 @@ } TEST_F(V8ContextTrackerHelpersTest, + ValidateV8ContextDescriptionShadowRealmWorld) { + // A valid shadow realm description. + blink::ShadowRealmToken shadow_realm_token; + auto desc = mojom::V8ContextDescription( + blink::V8ContextToken(), mojom::V8ContextWorldType::kShadowRealm, + /* world_name */ absl::nullopt, shadow_realm_token); + EXPECT_EQ(V8ContextDescriptionStatus::kValid, + ValidateV8ContextDescription(desc)); + EXPECT_EQ(false, + ExpectIframeAttributionDataForV8ContextDescription(desc, graph())); + + // A shadow realm should not have a world name. + EXPECT_EQ( + V8ContextDescriptionStatus::kUnexpectedWorldName, + ValidateV8ContextDescription(mojom::V8ContextDescription( + blink::V8ContextToken(), mojom::V8ContextWorldType::kShadowRealm, + kWorldName, shadow_realm_token))); + + // A shadow realm must have an |execution_context_token|. + EXPECT_EQ( + V8ContextDescriptionStatus::kMissingExecutionContextToken, + ValidateV8ContextDescription(mojom::V8ContextDescription( + blink::V8ContextToken(), mojom::V8ContextWorldType::kShadowRealm, + /* world_name */ absl::nullopt, + /* execution_context_token */ absl::nullopt))); + + // A shadow realm must have a valid shadow realm token. + EXPECT_EQ( + V8ContextDescriptionStatus::kMissingShadowRealmToken, + ValidateV8ContextDescription(mojom::V8ContextDescription( + blink::V8ContextToken(), mojom::V8ContextWorldType::kShadowRealm, + /* world_name */ absl::nullopt, blink::LocalFrameToken()))); +} + +TEST_F(V8ContextTrackerHelpersTest, ValidateV8ContextDescriptionExtensionWorld) { // A valid extension description. auto desc = mojom::V8ContextDescription(
diff --git a/components/permissions/permission_request_manager.cc b/components/permissions/permission_request_manager.cc index 6e76bc8..6e9ea8e8 100644 --- a/components/permissions/permission_request_manager.cc +++ b/components/permissions/permission_request_manager.cc
@@ -763,32 +763,37 @@ validated_requests_set_.insert(request); } - if (!permission_ui_selectors_.empty()) { - DCHECK(!current_request_ui_to_use_.has_value()); - // Initialize the selector decisions vector. - DCHECK(selector_decisions_.empty()); - selector_decisions_.resize(permission_ui_selectors_.size()); - - for (size_t selector_index = 0; - selector_index < permission_ui_selectors_.size(); ++selector_index) { - if (permission_ui_selectors_[selector_index] - ->IsPermissionRequestSupported( - requests_.front()->request_type())) { - permission_ui_selectors_[selector_index]->SelectUiToUse( - requests_.front(), - base::BindOnce( - &PermissionRequestManager::OnPermissionUiSelectorDone, - weak_factory_.GetWeakPtr(), selector_index)); - } else { - OnPermissionUiSelectorDone( - selector_index, - PermissionUiSelector::Decision::UseNormalUiAndShowNoWarning()); - } - } - } else { + if (permission_ui_selectors_.empty()) { current_request_ui_to_use_ = UiDecision(UiDecision::UseNormalUi(), UiDecision::ShowNoWarning()); ShowPrompt(); + return; + } + + DCHECK(!current_request_ui_to_use_.has_value()); + // Initialize the selector decisions vector. + DCHECK(selector_decisions_.empty()); + selector_decisions_.resize(permission_ui_selectors_.size()); + + for (size_t selector_index = 0; + selector_index < permission_ui_selectors_.size(); ++selector_index) { + // Skip if we have already made a decision due to a higher priority + // selector + if (current_request_ui_to_use_.has_value()) + break; + + if (permission_ui_selectors_[selector_index]->IsPermissionRequestSupported( + requests_.front()->request_type())) { + permission_ui_selectors_[selector_index]->SelectUiToUse( + requests_.front(), + base::BindOnce(&PermissionRequestManager::OnPermissionUiSelectorDone, + weak_factory_.GetWeakPtr(), selector_index)); + continue; + } + + OnPermissionUiSelectorDone( + selector_index, + PermissionUiSelector::Decision::UseNormalUiAndShowNoWarning()); } }
diff --git a/components/permissions/permission_request_manager.h b/components/permissions/permission_request_manager.h index 920460c..7c6e339 100644 --- a/components/permissions/permission_request_manager.h +++ b/components/permissions/permission_request_manager.h
@@ -204,6 +204,12 @@ permission_ui_selectors_.clear(); } + // Getter for testing. + const std::vector<std::unique_ptr<PermissionUiSelector>>& + get_permission_ui_selectors_for_testing() { + return permission_ui_selectors_; + } + void set_view_factory_for_testing(PermissionPrompt::Factory view_factory) { view_factory_ = std::move(view_factory); }
diff --git a/components/permissions/permission_request_manager_unittest.cc b/components/permissions/permission_request_manager_unittest.cc index 4fad316f..5233e1d5 100644 --- a/components/permissions/permission_request_manager_unittest.cc +++ b/components/permissions/permission_request_manager_unittest.cc
@@ -737,6 +737,7 @@ void SelectUiToUse(PermissionRequest* request, DecisionMadeCallback callback) override { + selected_ui_to_use_ = true; Decision decision(quiet_ui_reason_, Decision::ShowNoWarning()); if (async_delay_) { base::SequencedTaskRunner::GetCurrentDefault()->PostDelayedTask( @@ -768,11 +769,14 @@ quiet_ui_reason, prediction_likelihood, async_delay)); } + bool selected_ui_to_use() const { return selected_ui_to_use_; } + private: absl::optional<QuietUiReason> quiet_ui_reason_; absl::optional<PermissionUmaUtil::PredictionGrantLikelihood> prediction_likelihood_; absl::optional<base::TimeDelta> async_delay_; + bool selected_ui_to_use_ = false; }; // Same as the MockNotificationPermissionUiSelector but handling only the @@ -881,8 +885,27 @@ Accept(); } -TEST_P(PermissionRequestManagerTest, MultipleUiSelectors) { +TEST_P(PermissionRequestManagerTest, SkipNextUiSelector) { + manager_->clear_permission_ui_selector_for_testing(); + MockNotificationPermissionUiSelector::CreateForManager( + manager_, QuietUiReason::kEnabledInPrefs, + /* async_delay */ absl::nullopt); + MockNotificationPermissionUiSelector::CreateForManager( + manager_, PermissionUiSelector::Decision::UseNormalUi(), + /* async_delay */ absl::nullopt); + MockPermissionRequest request1(RequestType::kNotifications, + PermissionRequestGestureType::GESTURE); + manager_->AddRequest(web_contents()->GetPrimaryMainFrame(), &request1); + WaitForBubbleToBeShown(); + auto* next_selector = + manager_->get_permission_ui_selectors_for_testing().back().get(); + EXPECT_FALSE(static_cast<MockNotificationPermissionUiSelector*>(next_selector) + ->selected_ui_to_use()); + EXPECT_TRUE(manager_->ShouldCurrentRequestUseQuietUI()); + Accept(); +} +TEST_P(PermissionRequestManagerTest, MultipleUiSelectors) { const struct { std::vector<absl::optional<QuietUiReason>> quiet_ui_reasons; std::vector<bool> simulate_delayed_decision;
diff --git a/content/public/test/test_utils.cc b/content/public/test/test_utils.cc index af4a015..2690ba4 100644 --- a/content/public/test/test_utils.cc +++ b/content/public/test/test_utils.cc
@@ -132,13 +132,7 @@ } void RunMessageLoop() { - base::RunLoop run_loop; - RunThisRunLoop(&run_loop); -} - -void RunThisRunLoop(base::RunLoop* run_loop) { - base::CurrentThread::ScopedNestableTaskAllower allow; - run_loop->Run(); + base::RunLoop(base::RunLoop::Type::kNestableTasksAllowed).Run(); } void RunAllPendingInMessageLoop() { @@ -343,7 +337,7 @@ return; loop_running_ = true; - RunThisRunLoop(&run_loop_); + run_loop_.Run(); } base::OnceClosure MessageLoopRunner::QuitClosure() {
diff --git a/content/public/test/test_utils.h b/content/public/test/test_utils.h index d20c4aed..41b21604 100644 --- a/content/public/test/test_utils.h +++ b/content/public/test/test_utils.h
@@ -52,9 +52,6 @@ // force nesting in browser tests. void RunMessageLoop(); -// Deprecated: Invoke |run_loop->Run()| directly. -void RunThisRunLoop(base::RunLoop* run_loop); - // Turns on nestable tasks, runs all pending tasks in the message loop, then // resets nestable tasks to what they were originally. Can only be called from // the UI thread. Only use this instead of RunLoop::RunUntilIdle() to work @@ -209,7 +206,7 @@ // True after closure returned by |QuitClosure| has been called. bool quit_closure_called_ = false; - base::RunLoop run_loop_; + base::RunLoop run_loop_{base::RunLoop::Type::kNestableTasksAllowed}; base::ThreadChecker thread_checker_; };
diff --git a/docs/telemetry_extension/README.md b/docs/telemetry_extension/README.md index 8e4a9f6e..874f49e18 100644 --- a/docs/telemetry_extension/README.md +++ b/docs/telemetry_extension/README.md
@@ -242,6 +242,14 @@ Select the generated `CA.pem` file and click open. Now your Chrome instance and testing environment trust each other. +# Further reads + +For information around configuration of certain cros-config values please visit: + +1. [Customization Guide - OEM Name](add_oem_name.md) + +2. [Customization Guide - Fingerprint Diagnostics](fingerprint_diag.md) + # FAQs Q: I found a bug, how do I report it?<br> @@ -251,4 +259,4 @@ You need a partner account to do that. Q: Have a question?<br> -A: Please reach out to cros-oem-services-team@google.com. +A: Please reach out to chromeos-oem-services@google.com.
diff --git a/docs/telemetry_extension/add_oem_name.md b/docs/telemetry_extension/add_oem_name.md index 5e91f25..a0fa6c4 100644 --- a/docs/telemetry_extension/add_oem_name.md +++ b/docs/telemetry_extension/add_oem_name.md
@@ -3,6 +3,9 @@ # Objective Provide the instructions on the OEM name customization on ChromeOS devices. +For an overview of the Telemetry Extension platform, please visit our +[main documentation](README.md). + [TOC] # Overview
diff --git a/docs/telemetry_extension/fingerprint_diag.md b/docs/telemetry_extension/fingerprint_diag.md index c43aa48..64a6ec1 100644 --- a/docs/telemetry_extension/fingerprint_diag.md +++ b/docs/telemetry_extension/fingerprint_diag.md
@@ -4,6 +4,9 @@ Provide the instructions on the fingerprint diagnostic routines on ChromeOS devices. +For an overview of the Telemetry Extension platform, please visit our +[main documentation](README.md). + [TOC] # Instructions
diff --git a/extensions/test/result_catcher.cc b/extensions/test/result_catcher.cc index 9622826..42299579 100644 --- a/extensions/test/result_catcher.cc +++ b/extensions/test/result_catcher.cc
@@ -16,14 +16,13 @@ ResultCatcher::~ResultCatcher() = default; bool ResultCatcher::GetNextResult() { - // Depending on the tests, multiple results can come in from a single call - // to RunMessageLoop(), so we maintain a queue of results and just pull them - // off as the test calls this, going to the run loop only when the queue is - // empty. + // Depending on the tests, multiple results can come in from a single call to + // RunLoop::Run() so we maintain a queue of results and just pull them off as + // the test calls this, going to the run loop only when the queue is empty. if (results_.empty()) { - base::RunLoop run_loop; + base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); quit_closure_ = content::GetDeferredQuitTaskForRunLoop(&run_loop); - content::RunThisRunLoop(&run_loop); + run_loop.Run(); } if (!results_.empty()) {
diff --git a/infra/config/generated/luci/cr-buildbucket.cfg b/infra/config/generated/luci/cr-buildbucket.cfg index 7477ee77e..ce6d211f 100644 --- a/infra/config/generated/luci/cr-buildbucket.cfg +++ b/infra/config/generated/luci/cr-buildbucket.cfg
@@ -11711,7 +11711,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -11802,7 +11802,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -11893,7 +11893,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -12435,7 +12435,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -12615,7 +12615,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -12706,7 +12706,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -12888,7 +12888,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -13068,7 +13068,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -13884,7 +13884,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -13975,7 +13975,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -14157,7 +14157,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -14248,7 +14248,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -15068,7 +15068,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -15157,7 +15157,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -21973,7 +21973,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -22064,7 +22064,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -22155,7 +22155,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -26138,7 +26138,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -33577,7 +33577,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -38796,7 +38796,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -40604,7 +40604,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3" @@ -45415,7 +45415,7 @@ } experiments { key: "luci.buildbucket.omit_python2" - value: 0 + value: 100 } experiments { key: "luci.recipes.use_python3"
diff --git a/infra/config/subprojects/chromium/ci/chromium.memory.star b/infra/config/subprojects/chromium/ci/chromium.memory.star index 5b7ad835..1a906dc 100644 --- a/infra/config/subprojects/chromium/ci/chromium.memory.star +++ b/infra/config/subprojects/chromium/ci/chromium.memory.star
@@ -23,9 +23,6 @@ service_account = ci.DEFAULT_SERVICE_ACCOUNT, sheriff_rotations = sheriff_rotations.CHROMIUM, tree_closing = True, - - # TODO(crbug.com/1362440): remove this. - omit_python2 = False, ) consoles.console_view(
diff --git a/ios/chrome/app/resources/chrome_localize_strings_config.plist b/ios/chrome/app/resources/chrome_localize_strings_config.plist index 6f4d6c23..208479b 100644 --- a/ios/chrome/app/resources/chrome_localize_strings_config.plist +++ b/ios/chrome/app/resources/chrome_localize_strings_config.plist
@@ -55,6 +55,7 @@ <string>IDS_IOS_KEYBOARD_GO_TO_TAB_GRID</string> <string>IDS_IOS_KEYBOARD_CLEAR_BROWSING_DATA</string> <string>IDS_IOS_KEYBOARD_FIND</string> + <string>IDS_IOS_KEYBOARD_CLOSE_ALL</string> <string>IDS_IOS_UI_BLOCKED_USE_OTHER_WINDOW_DESCRIPTION</string> <string>IDS_IOS_UI_BLOCKED_USE_OTHER_WINDOW_SWITCH_WINDOW_ACTION</string> </array>
diff --git a/ios/chrome/app/strings/ios_strings.grd b/ios/chrome/app/strings/ios_strings.grd index fc70827..02a5d5779 100644 --- a/ios/chrome/app/strings/ios_strings.grd +++ b/ios/chrome/app/strings/ios_strings.grd
@@ -1273,6 +1273,9 @@ <message name="IDS_IOS_KEYBOARD_CLEAR_BROWSING_DATA" desc="Title of the keyboard shortcut to clear the browsing data." meaning="Used as a command title in the iPad command menu."> Clear Browsing Data… </message> + <message name="IDS_IOS_KEYBOARD_CLOSE_ALL" desc="Title of the button in the tab grid UI that closes all the tabs in the grid." meaning="Used as a command title in the iPad command menu."> + Close All + </message> <message name="IDS_IOS_KEYBOARD_CLOSE_TAB" desc="Title of the keyboard shortcut to close the current tab." meaning="Used as a command title in the iPad command menu."> Close Tab </message>
diff --git a/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_KEYBOARD_CLOSE_ALL.png.sha1 b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_KEYBOARD_CLOSE_ALL.png.sha1 new file mode 100644 index 0000000..d34d9ef --- /dev/null +++ b/ios/chrome/app/strings/ios_strings_grd/IDS_IOS_KEYBOARD_CLOSE_ALL.png.sha1
@@ -0,0 +1 @@ +1b82c6faebe728b6b4e70e6abb7d7ddc45321d8d \ No newline at end of file
diff --git a/ios/chrome/browser/flags/BUILD.gn b/ios/chrome/browser/flags/BUILD.gn index dbdc6d1d1..6093722 100644 --- a/ios/chrome/browser/flags/BUILD.gn +++ b/ios/chrome/browser/flags/BUILD.gn
@@ -83,6 +83,7 @@ "//ios/chrome/browser/ui/post_restore_signin:features", "//ios/chrome/browser/ui/start_surface:feature_flags", "//ios/chrome/browser/ui/tab_switcher/pinned_tabs:features", + "//ios/chrome/browser/ui/table_view/cells:features", "//ios/chrome/browser/ui/toolbar_container:feature_flags", "//ios/chrome/browser/ui/whats_new:feature_flags", "//ios/chrome/browser/web:feature_flags",
diff --git a/ios/chrome/browser/flags/about_flags.mm b/ios/chrome/browser/flags/about_flags.mm index a38dd67..ec23114 100644 --- a/ios/chrome/browser/flags/about_flags.mm +++ b/ios/chrome/browser/flags/about_flags.mm
@@ -96,6 +96,7 @@ #import "ios/chrome/browser/ui/post_restore_signin/features.h" #import "ios/chrome/browser/ui/start_surface/start_surface_features.h" #import "ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.h" +#import "ios/chrome/browser/ui/table_view/cells/features.h" #import "ios/chrome/browser/ui/toolbar_container/toolbar_container_features.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/whats_new/feature_flags.h" @@ -1307,6 +1308,10 @@ flag_descriptions::kCredentialProviderExtensionPromoName, flag_descriptions::kCredentialProviderExtensionPromoDescription, flags_ui::kOsIos, FEATURE_VALUE_TYPE(kCredentialProviderExtensionPromo)}, + {"truncate-table-view-cell-title", + flag_descriptions::kTruncateTableViewCellTitleName, + flag_descriptions::kTruncateTableViewCellTitleDescription, + flags_ui::kOsIos, FEATURE_VALUE_TYPE(kTruncateTableViewCellTitle)}, }; bool SkipConditionalFeatureEntry(const flags_ui::FeatureEntry& entry) {
diff --git a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc index 1de0af1..b78cec1 100644 --- a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc +++ b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc
@@ -771,6 +771,11 @@ extern const char kTrendingQueriesModuleDescription[] = "When enabled, the trending queries module will be shown in the NTP"; +extern const char kTruncateTableViewCellTitleName[] = + "Truncate title of table view cell"; +extern const char kTruncateTableViewCellTitleDescription[] = + "When enabled, title of table view cell is truncated and not wrapped"; + const char kUpdateHistoryEntryPointsInIncognitoName[] = "Update history entry points in Incognito."; const char kUpdateHistoryEntryPointsInIncognitoDescription[] =
diff --git a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h index fe2b523..8b2e3309 100644 --- a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h +++ b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h
@@ -683,6 +683,10 @@ extern const char kTrendingQueriesModuleName[]; extern const char kTrendingQueriesModuleDescription[]; +// Title and description for the flag to truncate title of table view cell. +extern const char kTruncateTableViewCellTitleName[]; +extern const char kTruncateTableViewCellTitleDescription[]; + // Title and description for the flag to enable removing any entry points to the // history UI from Incognito mode. extern const char kUpdateHistoryEntryPointsInIncognitoName[];
diff --git a/ios/chrome/browser/ui/autofill/manual_fill/full_card_requester_unittest.mm b/ios/chrome/browser/ui/autofill/manual_fill/full_card_requester_unittest.mm index 21eaa84..3587953 100644 --- a/ios/chrome/browser/ui/autofill/manual_fill/full_card_requester_unittest.mm +++ b/ios/chrome/browser/ui/autofill/manual_fill/full_card_requester_unittest.mm
@@ -78,7 +78,7 @@ web_state_.SetBrowserState(chrome_browser_state_.get()); personal_data_manager_.SetPrefService(chrome_browser_state_->GetPrefs()); - AddCreditCard(autofill::test::GetCreditCard()); // Visa. + AddCreditCard(autofill::test::GetMaskedServerCard()); // Mastercard. auto frames_manager = std::make_unique<web::FakeWebFramesManager>(); auto main_frame = web::FakeWebFrame::CreateMainWebFrame(
diff --git a/ios/chrome/browser/ui/icons/resources/arrow_clockwise.symbolset/arrow.clockwise.cr.svg b/ios/chrome/browser/ui/icons/resources/arrow_clockwise.symbolset/arrow.clockwise.cr.svg index f25b422..85ae556 100644 --- a/ios/chrome/browser/ui/icons/resources/arrow_clockwise.symbolset/arrow.clockwise.cr.svg +++ b/ios/chrome/browser/ui/icons/resources/arrow_clockwise.symbolset/arrow.clockwise.cr.svg
@@ -1,161 +1,162 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--Generator: Apple Native CoreSVG 149--> -<!DOCTYPE svg -PUBLIC "-//W3C//DTD SVG 1.1//EN" - "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="3300" height="2200"> - <!--glyph: "", point size: 100.0, font version: "17.0d8e1", template writer version: "58"--> - <g id="Notes"> - <rect height="2200" id="artboard" style="fill:white;opacity:1" width="3300" x="0" y="0"/> - <line style="fill:none;stroke:black;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="292" y2="292"/> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;font-weight:bold;" transform="matrix(1 0 0 1 263 322)">Weight/Scale Variations</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 559.711 322)">Ultralight</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 856.422 322)">Thin</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 1153.13 322)">Light</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 1449.84 322)">Regular</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 1746.56 322)">Medium</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 2043.27 322)">Semibold</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 2339.98 322)">Bold</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 2636.69 322)">Heavy</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:middle;" transform="matrix(1 0 0 1 2933.4 322)">Black</text> - <line style="fill:none;stroke:black;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="1903" y2="1903"/> - <g transform="matrix(1 0 0 1 263 1933)"> - <path d="M9.24805 0.830078Q10.8691 0.830078 12.2949 0.214844Q13.7207-0.400391 14.8096-1.49414Q15.8984-2.58789 16.5186-4.01367Q17.1387-5.43945 17.1387-7.05078Q17.1387-8.66211 16.5186-10.0879Q15.8984-11.5137 14.8047-12.6074Q13.7109-13.7012 12.2852-14.3164Q10.8594-14.9316 9.23828-14.9316Q7.62695-14.9316 6.20117-14.3164Q4.77539-13.7012 3.69141-12.6074Q2.60742-11.5137 1.9873-10.0879Q1.36719-8.66211 1.36719-7.05078Q1.36719-5.43945 1.9873-4.01367Q2.60742-2.58789 3.69629-1.49414Q4.78516-0.400391 6.21094 0.214844Q7.63672 0.830078 9.24805 0.830078ZM9.24805-0.654297Q7.91992-0.654297 6.7627-1.14746Q5.60547-1.64062 4.73145-2.51953Q3.85742-3.39844 3.36426-4.56055Q2.87109-5.72266 2.87109-7.05078Q2.87109-8.37891 3.35938-9.54102Q3.84766-10.7031 4.72168-11.582Q5.5957-12.4609 6.75293-12.9541Q7.91016-13.4473 9.23828-13.4473Q10.5762-13.4473 11.7334-12.9541Q12.8906-12.4609 13.7695-11.582Q14.6484-10.7031 15.1465-9.54102Q15.6445-8.37891 15.6445-7.05078Q15.6445-5.72266 15.1514-4.56055Q14.6582-3.39844 13.7842-2.51953Q12.9102-1.64062 11.748-1.14746Q10.5859-0.654297 9.24805-0.654297ZM5.83984-7.04102Q5.83984-6.71875 6.04492-6.51855Q6.25-6.31836 6.5918-6.31836L8.50586-6.31836L8.50586-4.39453Q8.50586-4.0625 8.70605-3.85742Q8.90625-3.65234 9.22852-3.65234Q9.56055-3.65234 9.76562-3.85742Q9.9707-4.0625 9.9707-4.39453L9.9707-6.31836L11.8945-6.31836Q12.2266-6.31836 12.4316-6.51855Q12.6367-6.71875 12.6367-7.04102Q12.6367-7.37305 12.4316-7.57812Q12.2266-7.7832 11.8945-7.7832L9.9707-7.7832L9.9707-9.69727Q9.9707-10.0391 9.76562-10.2441Q9.56055-10.4492 9.22852-10.4492Q8.90625-10.4492 8.70605-10.2441Q8.50586-10.0391 8.50586-9.69727L8.50586-7.7832L6.5918-7.7832Q6.25-7.7832 6.04492-7.57812Q5.83984-7.37305 5.83984-7.04102Z"/> - </g> - <g transform="matrix(1 0 0 1 281.867 1933)"> - <path d="M11.709 2.91016Q13.75 2.91016 15.5518 2.12891Q17.3535 1.34766 18.7305-0.0292969Q20.1074-1.40625 20.8887-3.20801Q21.6699-5.00977 21.6699-7.05078Q21.6699-9.0918 20.8887-10.8936Q20.1074-12.6953 18.7305-14.0723Q17.3535-15.4492 15.5469-16.2305Q13.7402-17.0117 11.6992-17.0117Q9.6582-17.0117 7.85645-16.2305Q6.05469-15.4492 4.68262-14.0723Q3.31055-12.6953 2.5293-10.8936Q1.74805-9.0918 1.74805-7.05078Q1.74805-5.00977 2.5293-3.20801Q3.31055-1.40625 4.6875-0.0292969Q6.06445 1.34766 7.86621 2.12891Q9.66797 2.91016 11.709 2.91016ZM11.709 1.25Q9.98047 1.25 8.47656 0.605469Q6.97266-0.0390625 5.83496-1.17676Q4.69727-2.31445 4.05762-3.81836Q3.41797-5.32227 3.41797-7.05078Q3.41797-8.7793 4.05762-10.2832Q4.69727-11.7871 5.83008-12.9297Q6.96289-14.0723 8.4668-14.7119Q9.9707-15.3516 11.6992-15.3516Q13.4277-15.3516 14.9316-14.7119Q16.4355-14.0723 17.5781-12.9297Q18.7207-11.7871 19.3652-10.2832Q20.0098-8.7793 20.0098-7.05078Q20.0098-5.32227 19.3701-3.81836Q18.7305-2.31445 17.5928-1.17676Q16.4551-0.0390625 14.9463 0.605469Q13.4375 1.25 11.709 1.25ZM7.39258-7.04102Q7.39258-6.68945 7.62695-6.46484Q7.86133-6.24023 8.23242-6.24023L10.8789-6.24023L10.8789-3.57422Q10.8789-3.21289 11.1035-2.9834Q11.3281-2.75391 11.6797-2.75391Q12.0508-2.75391 12.2852-2.9834Q12.5195-3.21289 12.5195-3.57422L12.5195-6.24023L15.1758-6.24023Q15.5371-6.24023 15.7715-6.46484Q16.0059-6.68945 16.0059-7.04102Q16.0059-7.41211 15.7715-7.6416Q15.5371-7.87109 15.1758-7.87109L12.5195-7.87109L12.5195-10.5176Q12.5195-10.8984 12.2852-11.1279Q12.0508-11.3574 11.6797-11.3574Q11.3281-11.3574 11.1035-11.1279Q10.8789-10.8984 10.8789-10.5176L10.8789-7.87109L8.23242-7.87109Q7.85156-7.87109 7.62207-7.6416Q7.39258-7.41211 7.39258-7.04102Z"/> - </g> - <g transform="matrix(1 0 0 1 305.646 1933)"> - <path d="M14.9707 5.66406Q17.0605 5.66406 18.96 5.01465Q20.8594 4.36523 22.4512 3.19336Q24.043 2.02148 25.2197 0.429688Q26.3965-1.16211 27.0459-3.06641Q27.6953-4.9707 27.6953-7.05078Q27.6953-9.14062 27.0459-11.04Q26.3965-12.9395 25.2197-14.5312Q24.043-16.123 22.4512-17.2998Q20.8594-18.4766 18.9551-19.126Q17.0508-19.7754 14.9609-19.7754Q12.8711-19.7754 10.9717-19.126Q9.07227-18.4766 7.48535-17.2998Q5.89844-16.123 4.72168-14.5312Q3.54492-12.9395 2.90039-11.04Q2.25586-9.14062 2.25586-7.05078Q2.25586-4.9707 2.90527-3.06641Q3.55469-1.16211 4.72656 0.429688Q5.89844 2.02148 7.49023 3.19336Q9.08203 4.36523 10.9814 5.01465Q12.8809 5.66406 14.9707 5.66406ZM14.9707 3.84766Q13.1641 3.84766 11.5283 3.2959Q9.89258 2.74414 8.53516 1.74805Q7.17773 0.751953 6.17676-0.610352Q5.17578-1.97266 4.62891-3.6084Q4.08203-5.24414 4.08203-7.05078Q4.08203-8.86719 4.62891-10.5029Q5.17578-12.1387 6.17188-13.501Q7.16797-14.8633 8.52539-15.8594Q9.88281-16.8555 11.5186-17.4023Q13.1543-17.9492 14.9609-17.9492Q16.7773-17.9492 18.4131-17.4023Q20.0488-16.8555 21.4111-15.8594Q22.7734-14.8633 23.7695-13.501Q24.7656-12.1387 25.3174-10.5029Q25.8691-8.86719 25.8691-7.05078Q25.8789-5.24414 25.332-3.6084Q24.7852-1.97266 23.7842-0.610352Q22.7832 0.751953 21.4209 1.74805Q20.0586 2.74414 18.4229 3.2959Q16.7871 3.84766 14.9707 3.84766ZM9.45312-7.04102Q9.45312-6.66016 9.71191-6.41113Q9.9707-6.16211 10.3711-6.16211L14.0625-6.16211L14.0625-2.46094Q14.0625-2.06055 14.3115-1.80664Q14.5605-1.55273 14.9414-1.55273Q15.3516-1.55273 15.6055-1.80664Q15.8594-2.06055 15.8594-2.46094L15.8594-6.16211L19.5605-6.16211Q19.9609-6.16211 20.2148-6.41113Q20.4688-6.66016 20.4688-7.04102Q20.4688-7.45117 20.2148-7.70508Q19.9609-7.95898 19.5605-7.95898L15.8594-7.95898L15.8594-11.6504Q15.8594-12.0605 15.6055-12.3145Q15.3516-12.5684 14.9414-12.5684Q14.5605-12.5684 14.3115-12.3096Q14.0625-12.0508 14.0625-11.6504L14.0625-7.95898L10.3711-7.95898Q9.96094-7.95898 9.70703-7.70508Q9.45312-7.45117 9.45312-7.04102Z"/> - </g> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;font-weight:bold;" transform="matrix(1 0 0 1 263 1953)">Design Variations</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 1971)">Symbols are supported in up to nine weights and three scales.</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 1989)">For optimal layout with text and other symbols, vertically align</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 2007)">symbols with the adjacent text.</text> - <line style="fill:none;stroke:#00AEEF;stroke-width:0.5;opacity:1.0;" x1="776" x2="776" y1="1919" y2="1933"/> - <g transform="matrix(1 0 0 1 776 1933)"> - <path d="M3.31055 0.15625Q3.70117 0.15625 3.91602-0.00976562Q4.13086-0.175781 4.26758-0.585938L5.52734-4.0332L11.2891-4.0332L12.5488-0.585938Q12.6855-0.175781 12.9004-0.00976562Q13.1152 0.15625 13.4961 0.15625Q13.8867 0.15625 14.1162-0.0585938Q14.3457-0.273438 14.3457-0.644531Q14.3457-0.869141 14.2383-1.17188L9.6582-13.3691Q9.48242-13.8184 9.17969-14.043Q8.87695-14.2676 8.4082-14.2676Q7.5-14.2676 7.17773-13.3789L2.59766-1.16211Q2.49023-0.859375 2.49023-0.634766Q2.49023-0.263672 2.70996-0.0537109Q2.92969 0.15625 3.31055 0.15625ZM6.00586-5.51758L8.37891-12.0898L8.42773-12.0898L10.8008-5.51758Z"/> - </g> - <line style="fill:none;stroke:#00AEEF;stroke-width:0.5;opacity:1.0;" x1="793.197" x2="793.197" y1="1919" y2="1933"/> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;font-weight:bold;" transform="matrix(1 0 0 1 776 1953)">Margins</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 776 1971)">Leading and trailing margins on the left and right side of each symbol</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 776 1989)">can be adjusted by modifying the x-location of the margin guidelines.</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 776 2007)">Modifications are automatically applied proportionally to all</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 776 2025)">scales and weights.</text> - <g transform="matrix(1 0 0 1 1289 1933)"> - <path d="M2.8418 1.86523L4.54102 3.57422Q5.18555 4.22852 5.90332 4.17969Q6.62109 4.13086 7.31445 3.35938L18.0078-8.42773L17.041-9.4043L6.42578 2.27539Q6.16211 2.57812 5.89355 2.61719Q5.625 2.65625 5.27344 2.30469L4.10156 1.14258Q3.75 0.791016 3.79395 0.522461Q3.83789 0.253906 4.14062-0.0195312L15.6152-10.8203L14.6387-11.7871L3.04688-0.898438Q2.30469-0.214844 2.25098 0.498047Q2.19727 1.21094 2.8418 1.86523ZM9.25781-16.3281Q8.94531-16.0254 8.90625-15.6348Q8.86719-15.2441 9.04297-14.9512Q9.21875-14.6777 9.55566-14.541Q9.89258-14.4043 10.3809-14.5215Q11.4746-14.7754 12.5977-14.7314Q13.7207-14.6875 14.7949-13.9844L14.209-12.5293Q13.9551-11.9043 14.0674-11.4404Q14.1797-10.9766 14.5801-10.5664L16.875-8.25195Q17.2363-7.88086 17.5781-7.82227Q17.9199-7.76367 18.3398-7.8418L19.4043-8.03711L20.0684-7.36328L20.0293-6.80664Q20-6.43555 20.1221-6.12305Q20.2441-5.81055 20.6055-5.44922L21.3672-4.70703Q21.7285-4.3457 22.1533-4.33105Q22.5781-4.31641 22.9297-4.66797L25.8398-7.58789Q26.1914-7.93945 26.1816-8.35449Q26.1719-8.76953 25.8105-9.13086L25.0391-9.89258Q24.6875-10.2539 24.3799-10.3857Q24.0723-10.5176 23.7109-10.4883L23.1348-10.4395L22.4902-11.0742L22.7344-12.1973Q22.832-12.6172 22.6953-12.9834Q22.5586-13.3496 22.1191-13.7891L19.9219-15.9766Q18.6719-17.2168 17.2607-17.8369Q15.8496-18.457 14.4189-18.4814Q12.9883-18.5059 11.665-17.959Q10.3418-17.4121 9.25781-16.3281ZM10.752-15.957Q11.6602-16.6211 12.7002-16.9043Q13.7402-17.1875 14.8047-17.085Q15.8691-16.9824 16.8701-16.5137Q17.8711-16.0449 18.7012-15.2051L21.1328-12.793Q21.3086-12.6172 21.3525-12.4512Q21.3965-12.2852 21.3379-12.0312L21.0156-10.5469L22.5195-9.0625L23.5059-9.12109Q23.6914-9.13086 23.7891-9.09668Q23.8867-9.0625 24.0332-8.91602L24.6094-8.33984L22.168-5.89844L21.5918-6.47461Q21.4453-6.62109 21.4062-6.71875Q21.3672-6.81641 21.377-7.01172L21.4453-7.98828L19.9512-9.47266L18.4277-9.21875Q18.1836-9.16992 18.042-9.2041Q17.9004-9.23828 17.7148-9.41406L15.7129-11.416Q15.5176-11.5918 15.4932-11.7529Q15.4688-11.9141 15.5859-12.1875L16.4648-14.2773Q15.293-15.3711 13.8281-15.791Q12.3633-16.2109 10.8398-15.7617Q10.7227-15.7324 10.6885-15.8057Q10.6543-15.8789 10.752-15.957Z"/> - </g> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;font-weight:bold;" transform="matrix(1 0 0 1 1289 1953)">Exporting</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 1289 1971)">Symbols should be outlined when exporting to ensure the</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 1289 1989)">design is preserved when submitting to Xcode.</text> - <text id="template-version" style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:end;" transform="matrix(1 0 0 1 3036 1933)">Template v.2.0</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:end;" transform="matrix(1 0 0 1 3036 1951)">Requires Xcode 13 or greater</text> - <text id="descriptive-name" style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:end;" transform="matrix(1 0 0 1 3036 1969)">Generated from arrow.clockwise.cr</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;text-anchor:end;" transform="matrix(1 0 0 1 3036 1987)">Typeset at 100 points</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 726)">Small</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 1156)">Medium</text> - <text style="stroke:none;fill:black;font-family:SF Pro,SF Pro Display,SF Pro Text,sans-serif;font-size:13;" transform="matrix(1 0 0 1 263 1586)">Large</text> - </g> - <g id="Guides"> - <g id="H-reference" style="fill:#27AAE1;stroke:none;" transform="matrix(1 0 0 1 339 696)"> - <path d="M0.993347 0L3.6377 0L29.3282-67.1326L30.0301-67.1326L30.0301-70.459L28.1227-70.459ZM11.6882-24.4797L46.9818-24.4797L46.2311-26.7288L12.4382-26.7288ZM55.1193 0L57.7637 0L30.6381-70.459L29.4327-70.459L29.4327-67.1326Z"/> - </g> - <line id="Baseline-S" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="696" y2="696"/> - <line id="Capline-S" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="625.541" y2="625.541"/> - <g id="H-reference" style="fill:#27AAE1;stroke:none;" transform="matrix(1 0 0 1 339 1126)"> - <path d="M0.993347 0L3.6377 0L29.3282-67.1326L30.0301-67.1326L30.0301-70.459L28.1227-70.459ZM11.6882-24.4797L46.9818-24.4797L46.2311-26.7288L12.4382-26.7288ZM55.1193 0L57.7637 0L30.6381-70.459L29.4327-70.459L29.4327-67.1326Z"/> - </g> - <line id="Baseline-M" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="1126" y2="1126"/> - <line id="Capline-M" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="1055.54" y2="1055.54"/> - <g id="H-reference" style="fill:#27AAE1;stroke:none;" transform="matrix(1 0 0 1 339 1556)"> - <path d="M0.993347 0L3.6377 0L29.3282-67.1326L30.0301-67.1326L30.0301-70.459L28.1227-70.459ZM11.6882-24.4797L46.9818-24.4797L46.2311-26.7288L12.4382-26.7288ZM55.1193 0L57.7637 0L30.6381-70.459L29.4327-70.459L29.4327-67.1326Z"/> - </g> - <line id="Baseline-L" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="1556" y2="1556"/> - <line id="Capline-L" style="fill:none;stroke:#27AAE1;opacity:1;stroke-width:0.5;" x1="263" x2="3036" y1="1485.54" y2="1485.54"/> - <line id="left-margin" style="fill:none;stroke:#00AEEF;stroke-width:0.5;opacity:1.0;" x1="1397.96" x2="1397.96" y1="1126" y2="1126"/> - <line id="right-margin" style="fill:none;stroke:#00AEEF;stroke-width:0.5;opacity:1.0;" x1="1501.72" x2="1501.72" y1="1126" y2="1126"/> - </g> - <g id="Symbols"> - <g id="Black-L" transform="matrix(1 0 0 1 2862.27 1556)"> - <path d="M71.21-90.25C43.72-90.25 21.54-68.14 21.54-41C21.54-13.86 43.72 8.25 71.21 8.25C79.92 8.25 88.08 6.04 95.17 2.15C99.41-0.17 104.73 1.39 107.05 5.63C109.37 9.87 107.81 15.19 103.57 17.51C93.96 22.76 82.92 25.75 71.21 25.75C34.17 25.75 4.04-4.08 4.04-41C4.04-77.92 34.17-107.75 71.21-107.75C90.44-107.75 107.79-99.72 120.04-86.84L120.04-99C120.04-103.83 123.96-107.75 128.79-107.75C133.62-107.75 137.54-103.83 137.54-99L137.54-59.57C137.54-54.46 133.4-50.32 128.29-50.32L88.69-50.32C83.86-50.32 79.94-54.24 79.94-59.07C79.94-63.9 83.86-67.82 88.69-67.82L112.88-67.82C104.02-81.31 88.68-90.25 71.21-90.25Z"/> - </g> - <g id="Heavy-L" transform="matrix(1 0 0 1 2566.56 1556)"> - <path d="M70.21-89.25C42.17-89.25 19.54-66.7 19.54-39C19.54-11.3 42.17 11.25 70.21 11.25C79.09 11.25 87.41 8.99 94.65 5.03C98.4 2.98 103.11 4.35 105.17 8.11C107.22 11.86 105.84 16.57 102.09 18.63C92.63 23.81 81.75 26.75 70.21 26.75C33.72 26.75 4.04-2.63 4.04-39C4.04-75.37 33.72-104.75 70.21-104.75C90.08-104.75 107.91-96.05 120.04-82.26L120.04-97C120.04-101.28 123.51-104.75 127.79-104.75C132.07-104.75 135.54-101.28 135.54-97L135.54-57.57C135.54-53.02 131.85-49.32 127.29-49.32L87.69-49.32C83.41-49.32 79.94-52.79 79.94-57.07C79.94-61.35 83.41-64.82 87.69-64.82L113.69-64.82C104.84-79.45 88.69-89.25 70.21-89.25Z"/> - </g> - <g id="Bold-L" transform="matrix(1 0 0 1 2271.6 1556)"> - <path d="M68.46-92C39.47-92 16.04-68.68 16.04-40C16.04-11.32 39.47 12 68.46 12C77.64 12 86.25 9.66 93.74 5.57C96.65 3.98 100.29 5.04 101.88 7.95C103.47 10.86 102.41 14.5 99.5 16.09C90.29 21.14 79.7 24 68.46 24C32.92 24 4.04-4.61 4.04-40C4.04-75.39 32.92-104 68.46-104C89.55-104 108.29-93.93 120.04-78.35L120.04-98C120.04-101.31 122.73-104 126.04-104C129.35-104 132.04-101.31 132.04-98L132.04-58.57C132.04-54.98 129.13-52.07 125.54-52.07L85.94-52.07C82.63-52.07 79.94-54.76 79.94-58.07C79.94-61.39 82.63-64.07 85.94-64.07L114.94-64.07C106.19-80.66 88.66-92 68.46-92Z"/> - </g> - <g id="Semibold-L" transform="matrix(1 0 0 1 1975.39 1556)"> - <path d="M67.96-91.5C38.7-91.5 15.04-67.96 15.04-39C15.04-10.04 38.7 13.5 67.96 13.5C77.23 13.5 85.92 11.14 93.48 7.01C96.14 5.55 99.49 6.53 100.94 9.19C102.4 11.85 101.42 15.2 98.76 16.65C89.62 21.66 79.11 24.5 67.96 24.5C32.7 24.5 4.04-3.89 4.04-39C4.04-74.11 32.7-102.5 67.96-102.5C89.44-102.5 108.45-91.98 120.04-75.82L120.04-97C120.04-100.04 122.5-102.5 125.54-102.5C128.58-102.5 131.04-100.04 131.04-97L131.04-57.57C131.04-54.26 128.35-51.57 125.04-51.57L85.44-51.57C82.41-51.57 79.94-54.03 79.94-57.07C79.94-60.11 82.41-62.57 85.44-62.57L115.26-62.57C106.56-79.72 88.65-91.5 67.96-91.5Z"/> - </g> - <g id="Medium-L" transform="matrix(1 0 0 1 1679.18 1556)"> - <path d="M67.46-91C37.92-91 14.04-67.24 14.04-38C14.04-8.76 37.92 15 67.46 15C76.81 15 85.59 12.62 93.22 8.44C95.64 7.12 98.68 8.01 100.01 10.43C101.33 12.85 100.44 15.89 98.02 17.22C88.95 22.18 78.53 25 67.46 25C32.47 25 4.04-3.17 4.04-38C4.04-72.83 32.47-101 67.46-101C89.34-101 108.64-89.99 120.04-73.24L120.04-96C120.04-98.76 122.28-101 125.04-101C127.8-101 130.04-98.76 130.04-96L130.04-56.57C130.04-53.53 127.58-51.07 124.54-51.07L84.94-51.07C82.18-51.07 79.94-53.31 79.94-56.07C79.94-58.83 82.18-61.07 84.94-61.07L115.57-61.07C106.92-78.78 88.64-91 67.46-91Z"/> - </g> - <g id="Regular-L" transform="matrix(1 0 0 1 1383.46 1556)"> - <path d="M66.46-92C36.38-92 12.04-67.8 12.04-38C12.04-8.2 36.38 16 66.46 16C75.98 16 84.92 13.58 92.7 9.32C94.64 8.26 97.07 8.97 98.13 10.91C99.19 12.85 98.48 15.28 96.54 16.34C87.61 21.22 77.36 24 66.46 24C32.01 24 4.04-3.73 4.04-38C4.04-72.27 32.01-100 66.46-100C89.21-100 109.13-87.91 120.04-69.82L120.04-96C120.04-98.21 121.83-100 124.04-100C126.25-100 128.04-98.21 128.04-96L128.04-56.57C128.04-54.09 126.03-52.07 123.54-52.07L83.94-52.07C81.74-52.07 79.94-53.86 79.94-56.07C79.94-58.28 81.74-60.07 83.94-60.07L116.14-60.07C107.64-78.89 88.6-92 66.46-92Z"/> - </g> - <g id="Light-L" transform="matrix(1 0 0 1 1087.25 1556)"> - <path d="M65.96-92.5C35.6-92.5 11.04-68.08 11.04-38C11.04-7.92 35.6 16.5 65.96 16.5C75.57 16.5 84.59 14.05 92.44 9.76C94.14 8.83 96.26 9.45 97.19 11.15C98.12 12.85 97.5 14.97 95.8 15.9C86.95 20.75 76.77 23.5 65.96 23.5C31.79 23.5 4.04-4.01 4.04-38C4.04-71.99 31.79-99.5 65.96-99.5C89.2-99.5 109.45-86.79 120.04-67.97L120.04-96C120.04-97.93 121.61-99.5 123.54-99.5C125.47-99.5 127.04-97.93 127.04-96L127.04-56.57C127.04-54.36 125.25-52.57 123.04-52.57L83.44-52.57C81.51-52.57 79.94-54.14 79.94-56.07C79.94-58.01 81.51-59.57 83.44-59.57L116.41-59.57C107.99-78.94 88.58-92.5 65.96-92.5Z"/> - </g> - <g id="Thin-L" transform="matrix(1 0 0 1 791.542 1556)"> - <path d="M64.96-93.5C34.059-93.5 9.04-68.63 9.04-38C9.04-7.37 34.059 17.5 64.96 17.5C74.741 17.5 83.928 15.01 91.92 10.64C93.131 9.97 94.65 10.42 95.313 11.63C95.976 12.84 95.531 14.36 94.32 15.02C85.609 19.79 75.6 22.5 64.96 22.5C31.332 22.5 4.04-4.57 4.04-38C4.04-71.43 31.332-98.5 64.96-98.5C89.277-98.5 110.271-84.35 120.04-63.88L120.04-96C120.04-97.38 121.159-98.5 122.54-98.5C123.921-98.5 125.04-97.38 125.04-96L125.04-56.57C125.04-54.92 123.697-53.57 122.04-53.57L82.444-53.57C81.064-53.57 79.944-54.69 79.944-56.07C79.944-57.45 81.064-58.57 82.444-58.57L116.914-58.57C108.681-79.03 88.526-93.5 64.96-93.5Z"/> - </g> - <g id="Ultralight-L" transform="matrix(1 0 0 1 495.331 1556)"> - <path d="M64.46-94C33.287-94 8.04-68.91 8.04-38C8.04-7.09 33.287 18 64.46 18C74.327 18 83.596 15.49 91.66 11.08C92.629 10.55 93.844 10.9 94.374 11.87C94.905 12.84 94.549 14.05 93.58 14.58C84.941 19.31 75.014 22 64.46 22C31.105 22 4.04-4.85 4.04-38C4.04-71.15 31.105-98 64.46-98C89.4-98 110.816-82.99 120.04-61.57L120.04-96C120.04-97.1 120.936-98 122.04-98C123.145-98 124.04-97.1 124.04-96L124.04-56.57C124.04-55.19 122.921-54.07 121.54-54.07L81.944-54.07C80.84-54.07 79.944-54.97 79.944-56.07C79.944-57.18 80.84-58.07 81.944-58.07L117.149-58.07C109.019-79.08 88.498-94 64.46-94Z"/> - </g> - <g id="Black-M" transform="matrix(1 0 0 1 2878.52 1126)"> - <path d="M54.86-75C34.47-75 18.04-58.61 18.04-38.5C18.04-18.39 34.47-2 54.86-2C61.31-2 67.36-3.64 72.61-6.52C76.01-8.37 80.26-7.13 82.12-3.74C83.97-0.35 82.73 3.91 79.34 5.76C72.07 9.74 63.71 12 54.86 12C26.84 12 4.04-10.56 4.04-38.5C4.04-66.44 26.84-89 54.86-89C69.01-89 81.82-83.25 91.04-73.95L91.04-82C91.04-85.87 94.17-89 98.04-89C101.91-89 105.04-85.87 105.04-82L105.04-52.55C105.04-48.41 101.68-45.05 97.54-45.05L67.97-45.05C64.1-45.05 60.97-48.19 60.97-52.05C60.97-55.92 64.1-59.05 67.97-59.05L85.28-59.05C78.66-68.67 67.51-75 54.86-75Z"/> - </g> - <g id="Heavy-M" transform="matrix(1 0 0 1 2582.31 1126)"> - <path d="M54.36-73.5C33.7-73.5 17.04-56.89 17.04-36.5C17.04-16.11 33.7 0.5 54.36 0.5C60.9 0.5 67.03-1.16 72.35-4.08C75.5-5.8 79.45-4.65 81.18-1.5C82.9 1.65 81.74 5.6 78.6 7.32C71.4 11.26 63.13 13.5 54.36 13.5C26.61 13.5 4.04-8.84 4.04-36.5C4.04-64.16 26.61-86.5 54.36-86.5C68.82-86.5 81.86-80.44 91.04-70.72L91.04-80C91.04-83.59 93.95-86.5 97.54-86.5C101.13-86.5 104.04-83.59 104.04-80L104.04-50.55C104.04-46.69 100.91-43.55 97.04-43.55L67.47-43.55C63.88-43.55 60.97-46.46 60.97-50.05C60.97-53.64 63.88-56.55 67.47-56.55L85.72-56.55C79.08-66.74 67.52-73.5 54.36-73.5Z"/> - </g> - <g id="Bold-M" transform="matrix(1 0 0 1 2286.6 1126)"> - <path d="M53.36-75.5C32.16-75.5 15.04-58.45 15.04-37.5C15.04-16.55 32.16 0.5 53.36 0.5C60.07 0.5 66.36-1.21 71.83-4.2C74.5-5.66 77.84-4.68 79.3-2.02C80.76 0.65 79.78 3.99 77.12 5.45C70.06 9.31 61.96 11.5 53.36 11.5C26.16 11.5 4.04-10.4 4.04-37.5C4.04-64.6 26.16-86.5 53.36-86.5C68.46-86.5 81.99-79.75 91.04-69.11L91.04-81C91.04-84.04 93.5-86.5 96.54-86.5C99.58-86.5 102.04-84.04 102.04-81L102.04-51.55C102.04-48.24 99.35-45.55 96.04-45.55L66.47-45.55C63.43-45.55 60.97-48.02 60.97-51.05C60.97-54.09 63.43-56.55 66.47-56.55L86.51-56.55C79.88-67.88 67.52-75.5 53.36-75.5Z"/> - </g> - <g id="Semibold-M" transform="matrix(1 0 0 1 1990.39 1126)"> - <path d="M52.86-75C31.38-75 14.04-57.73 14.04-36.5C14.04-15.27 31.38 2 52.86 2C59.65 2 66.03 0.27 71.57-2.76C74-4.09 77.04-3.2 78.36-0.78C79.69 1.64 78.8 4.68 76.37 6.01C69.39 9.83 61.37 12 52.86 12C25.93 12 4.04-9.68 4.04-36.5C4.04-63.32 25.93-85 52.86-85C68.31-85 82.09-77.86 91.04-66.72L91.04-80C91.04-82.76 93.28-85 96.04-85C98.8-85 101.04-82.76 101.04-80L101.04-50.55C101.04-47.52 98.58-45.05 95.54-45.05L65.97-45.05C63.21-45.05 60.97-47.29 60.97-50.05C60.97-52.82 63.21-55.05 65.97-55.05L86.87-55.05C80.27-66.94 67.52-75 52.86-75Z"/> - </g> - <g id="Medium-M" transform="matrix(1 0 0 1 1694.18 1126)"> - <path d="M52.36-74.5C30.61-74.5 13.04-57.01 13.04-35.5C13.04-13.99 30.61 3.5 52.36 3.5C59.24 3.5 65.7 1.75 71.31-1.33C73.49-2.52 76.23-1.72 77.42 0.46C78.62 2.64 77.82 5.38 75.63 6.57C68.72 10.35 60.79 12.5 52.36 12.5C25.7 12.5 4.04-8.96 4.04-35.5C4.04-62.04 25.7-83.5 52.36-83.5C68.17-83.5 82.22-75.95 91.04-64.26L91.04-79C91.04-81.49 93.05-83.5 95.54-83.5C98.03-83.5 100.04-81.49 100.04-79L100.04-49.55C100.04-46.79 97.8-44.55 95.04-44.55L65.47-44.55C62.98-44.55 60.97-46.57 60.97-49.05C60.97-51.54 62.98-53.55 65.47-53.55L87.21-53.55C80.65-66 67.51-74.5 52.36-74.5Z"/> - </g> - <g id="Regular-M" transform="matrix(1 0 0 1 1397.96 1126)"> - <path d="M51.86-75C29.84-75 12.04-57.29 12.04-35.5C12.04-13.71 29.84 4 51.86 4C58.83 4 65.37 2.23 71.05-0.89C72.99-1.95 75.42-1.24 76.48 0.7C77.54 2.64 76.83 5.07 74.9 6.13C68.06 9.87 60.2 12 51.86 12C25.47 12 4.04-9.24 4.04-35.5C4.04-61.76 25.47-83 51.86-83C68.06-83 82.39-74.99 91.04-62.73L91.04-79C91.04-81.21 92.83-83 95.04-83C97.25-83 99.04-81.21 99.04-79L99.04-49.55C99.04-47.07 97.03-45.05 94.54-45.05L64.97-45.05C62.76-45.05 60.97-46.84 60.97-49.05C60.97-51.26 62.76-53.05 64.97-53.05L87.53-53.05C81.02-66.06 67.5-75 51.86-75Z"/> - </g> - <g id="Light-M" transform="matrix(1 0 0 1 1102.25 1126)"> - <path d="M50.86-76C28.29-76 10.04-57.85 10.04-35.5C10.04-13.15 28.29 5 50.86 5C58 5 64.7 3.18 70.53-0.01C71.99-0.8 73.81-0.27 74.61 1.18C75.4 2.64 74.87 4.46 73.41 5.25C66.72 8.92 59.03 11 50.86 11C25.02 11 4.04-9.8 4.04-35.5C4.04-61.2 25.02-82 50.86-82C67.92-82 82.86-72.93 91.04-59.37L91.04-79C91.04-80.66 92.38-82 94.04-82C95.7-82 97.04-80.66 97.04-79L97.04-49.55C97.04-47.62 95.47-46.05 93.54-46.05L63.97-46.05C62.31-46.05 60.97-47.4 60.97-49.05C60.97-50.71 62.31-52.05 63.97-52.05L88.12-52.05C81.74-66.16 67.46-76 50.86-76Z"/> - </g> - <g id="Thin-M" transform="matrix(1 0 0 1 806.792 1126)"> - <path d="M49.605-77.25C26.361-77.25 7.54-58.55 7.54-35.5C7.54-12.45 26.361 6.25 49.605 6.25C56.962 6.25 63.873 4.38 69.885 1.09C70.733 0.62 71.796 0.93 72.26 1.78C72.724 2.63 72.413 3.69 71.565 4.16C65.05 7.72 57.563 9.75 49.605 9.75C24.452 9.75 4.04-10.5 4.04-35.5C4.04-60.5 24.452-80.75 49.605-80.75C67.993-80.75 83.84-69.93 91.04-54.35L91.04-79C91.04-79.97 91.823-80.75 92.79-80.75C93.756-80.75 94.54-79.97 94.54-79L94.54-49.55C94.54-48.31 93.532-47.3 92.29-47.3L62.718-47.3C61.752-47.3 60.968-48.09 60.968-49.05C60.968-50.02 61.752-50.8 62.718-50.8L88.755-50.8C82.605-66.29 67.397-77.25 49.605-77.25Z"/> - </g> - <g id="Ultralight-M" transform="matrix(1 0 0 1 510.581 1126)"> - <path d="M49.105-77.75C25.589-77.75 6.54-58.83 6.54-35.5C6.54-12.17 25.589 6.75 49.105 6.75C56.548 6.75 63.541 4.85 69.625 1.53C70.23 1.19 70.99 1.42 71.321 2.02C71.653 2.63 71.43 3.39 70.825 3.72C64.382 7.24 56.977 9.25 49.105 9.25C24.225 9.25 4.04-10.78 4.04-35.5C4.04-60.22 24.225-80.25 49.105-80.25C68.154-80.25 84.446-68.51 91.04-51.92L91.04-79C91.04-79.69 91.599-80.25 92.29-80.25C92.98-80.25 93.54-79.69 93.54-79L93.54-49.55C93.54-48.59 92.756-47.8 91.79-47.8L62.218-47.8C61.528-47.8 60.968-48.36 60.968-49.05C60.968-49.74 61.528-50.3 62.218-50.3L88.985-50.3C82.942-66.33 67.368-77.75 49.105-77.75Z"/> - </g> - <g id="Black-S" transform="matrix(1 0 0 1 2888.52 696)"> - <path d="M44.79-65C28.87-65 16.04-52.199 16.04-36.5C16.04-20.801 28.87-8 44.79-8C49.83-8 54.55-9.282 58.66-11.529C61.57-13.119 65.21-12.052 66.8-9.145C68.39-6.238 67.33-2.592 64.42-1.002C58.59 2.189 51.89 4 44.79 4C22.33 4 4.04-14.092 4.04-36.5C4.04-58.908 22.33-77 44.79-77C55.75-77 65.71-72.695 73.04-65.687L73.04-71C73.04-74.314 75.73-77 79.04-77C82.35-77 85.04-74.314 85.04-71L85.04-47.75C85.04-44.16 82.13-41.25 78.54-41.25L55.19-41.25C51.88-41.25 49.19-43.936 49.19-47.25C49.19-50.564 51.88-53.25 55.19-53.25L68.05-53.25C62.83-60.366 54.36-65 44.79-65Z"/> - </g> - <g id="Heavy-S" transform="matrix(1 0 0 1 2592.81 696)"> - <path d="M43.79-66C27.33-66 14.04-52.758 14.04-36.5C14.04-20.242 27.33-7 43.79-7C49-7 53.89-8.326 58.14-10.651C60.56-11.977 63.6-11.088 64.93-8.665C66.25-6.243 65.36-3.204 62.94-1.879C57.25 1.233 50.72 3 43.79 3C21.87 3 4.04-14.651 4.04-36.5C4.04-58.349 21.87-76 43.79-76C55.36-76 65.77-71.09 73.04-63.247L73.04-71C73.04-73.761 75.28-76 78.04-76C80.8-76 83.04-73.761 83.04-71L83.04-47.75C83.04-44.712 80.58-42.25 77.54-42.25L54.19-42.25C51.43-42.25 49.19-44.489 49.19-47.25C49.19-50.011 51.43-52.25 54.19-52.25L68.95-52.25C63.68-60.508 54.39-66 43.79-66Z"/> - </g> - <g id="Bold-S" transform="matrix(1 0 0 1 2296.6 696)"> - <path d="M43.29-65.5C26.55-65.5 13.04-52.038 13.04-35.5C13.04-18.962 26.55-5.5 43.29-5.5C48.59-5.5 53.56-6.848 57.88-9.213C60.06-10.406 62.79-9.605 63.99-7.425C65.18-5.245 64.38-2.51 62.2-1.317C56.59 1.755 50.14 3.5 43.29 3.5C21.64 3.5 4.04-13.93 4.04-35.5C4.04-57.07 21.64-74.5 43.29-74.5C55.18-74.5 65.84-69.246 73.04-60.94L73.04-70C73.04-72.485 75.05-74.5 77.54-74.5C80.03-74.5 82.04-72.485 82.04-70L82.04-46.75C82.04-43.988 79.8-41.75 77.04-41.75L53.69-41.75C51.2-41.75 49.19-43.765 49.19-46.25C49.19-48.735 51.2-50.75 53.69-50.75L69.35-50.75C64.08-59.574 54.39-65.5 43.29-65.5Z"/> - </g> - <g id="Semibold-S" transform="matrix(1 0 0 1 2000.14 696)"> - <path d="M43.04-65.75C26.17-65.75 12.54-52.178 12.54-35.5C12.54-18.822 26.17-5.25 43.04-5.25C48.38-5.25 53.39-6.609 57.75-8.993C59.81-10.12 62.39-9.364 63.52-7.305C64.65-5.246 63.89-2.664 61.83-1.537C56.25 1.516 49.84 3.25 43.04 3.25C21.53 3.25 4.04-14.07 4.04-35.5C4.04-56.93 21.53-74.25 43.04-74.25C55.1-74.25 65.88-68.811 73.04-60.261L73.04-70C73.04-72.347 74.94-74.25 77.29-74.25C79.64-74.25 81.54-72.347 81.54-70L81.54-46.75C81.54-44.127 79.41-42 76.79-42L53.44-42C51.09-42 49.19-43.903 49.19-46.25C49.19-48.597 51.09-50.5 53.44-50.5L69.53-50.5C64.28-59.606 54.39-65.75 43.04-65.75Z"/> - </g> - <g id="Medium-S" transform="matrix(1 0 0 1 1703.68 696)"> - <path d="M42.79-66C25.78-66 12.04-52.318 12.04-35.5C12.04-18.682 25.78-5 42.79-5C48.18-5 53.23-6.37 57.62-8.774C59.56-9.835 61.99-9.123 63.05-7.185C64.11-5.247 63.4-2.817 61.46-1.756C55.92 1.277 49.55 3 42.79 3C21.42 3 4.04-14.21 4.04-35.5C4.04-56.79 21.42-74 42.79-74C55.02-74 65.94-68.367 73.04-59.563L73.04-70C73.04-72.209 74.83-74 77.04-74C79.25-74 81.04-72.209 81.04-70L81.04-46.75C81.04-44.265 79.03-42.25 76.54-42.25L53.19-42.25C50.98-42.25 49.19-44.041 49.19-46.25C49.19-48.459 50.98-50.25 53.19-50.25L69.71-50.25C64.47-59.637 54.38-66 42.79-66Z"/> - </g> - <g id="Regular-S" transform="matrix(1 0 0 1 1407.46 696)"> - <path d="M42.29-67.5C25.01-67.5 11.04-53.597 11.04-36.5C11.04-19.403 25.01-5.5 42.29-5.5C47.76-5.5 52.9-6.892 57.36-9.335C59.06-10.263 61.18-9.641 62.11-7.945C63.04-6.249 62.42-4.123 60.72-3.195C55.25-0.201 48.96 1.5 42.29 1.5C21.19 1.5 4.04-15.489 4.04-36.5C4.04-57.511 21.19-74.5 42.29-74.5C54.89-74.5 66.07-68.448 73.04-59.103L73.04-71C73.04-72.933 74.61-74.5 76.54-74.5C78.47-74.5 80.04-72.933 80.04-71L80.04-47.75C80.04-45.541 78.25-43.75 76.04-43.75L52.69-43.75C50.76-43.75 49.19-45.317 49.19-47.25C49.19-49.183 50.76-50.75 52.69-50.75L70.05-50.75C64.85-60.696 54.38-67.5 42.29-67.5Z"/> - </g> - <g id="Light-S" transform="matrix(1 0 0 1 1111.75 696)"> - <path d="M41.29-68.5C23.46-68.5 9.04-54.156 9.04-36.5C9.04-18.844 23.46-4.5 41.29-4.5C46.93-4.5 52.23-5.936 56.84-8.458C58.05-9.121 59.57-8.676 60.23-7.465C60.9-6.254 60.45-4.735 59.24-4.072C53.91-1.157 47.79 0.5 41.29 0.5C20.73 0.5 4.04-16.048 4.04-36.5C4.04-56.952 20.73-73.5 41.29-73.5C54.71-73.5 66.48-66.446 73.04-55.859L73.04-71C73.04-72.381 74.16-73.5 75.54-73.5C76.92-73.5 78.04-72.381 78.04-71L78.04-47.75C78.04-46.093 76.7-44.75 75.04-44.75L51.69-44.75C50.31-44.75 49.19-45.869 49.19-47.25C49.19-48.631 50.31-49.75 51.69-49.75L70.65-49.75C65.58-60.807 54.34-68.5 41.29-68.5Z"/> - </g> - <g id="Thin-S" transform="matrix(1 0 0 1 815.917 696)"> - <path d="M40.415-68.375C22.109-68.375 7.29-53.645 7.29-35.5C7.29-17.355 22.109-2.625 40.415-2.625C46.209-2.625 51.651-4.1 56.385-6.691C57.172-7.121 58.16-6.832 58.591-6.045C59.021-5.258 58.732-4.27 57.945-3.84C52.744-0.993 46.767 0.625 40.415 0.625C20.337 0.625 4.04-15.538 4.04-35.5C4.04-55.462 20.337-71.625 40.415-71.625C54.72-71.625 67.099-63.424 73.04-51.492L73.04-70C73.04-70.897 73.768-71.625 74.665-71.625C75.562-71.625 76.29-70.897 76.29-70L76.29-46.75C76.29-45.576 75.339-44.625 74.165-44.625L50.815-44.625C49.918-44.625 49.19-45.352 49.19-46.25C49.19-47.147 49.918-47.875 50.815-47.875L71.113-47.875C66.189-59.895 54.302-68.375 40.415-68.375Z"/> - </g> - <g id="Ultralight-S" transform="matrix(1 0 0 1 519.706 696)"> - <path d="M39.915-68.875C21.337-68.875 6.29-53.925 6.29-35.5C6.29-17.075 21.337-2.125 39.915-2.125C45.795-2.125 51.319-3.622 56.125-6.252C56.67-6.55 57.354-6.35 57.652-5.805C57.95-5.26 57.75-4.576 57.205-4.278C52.076-1.471 46.181 0.125 39.915 0.125C20.109 0.125 4.04-15.817 4.04-35.5C4.04-55.183 20.109-71.125 39.915-71.125C54.836-71.125 67.633-62.078 73.04-49.202L73.04-70C73.04-70.621 73.544-71.125 74.165-71.125C74.786-71.125 75.29-70.621 75.29-70L75.29-46.75C75.29-45.852 74.562-45.125 73.665-45.125L50.315-45.125C49.694-45.125 49.19-45.629 49.19-46.25C49.19-46.871 49.694-47.375 50.315-47.375L71.35-47.375C66.528-59.942 54.274-68.875 39.915-68.875Z"/> - </g> - </g> +<svg width="3300" height="2200" viewBox="0 0 3300 2200" fill="none" xmlns="http://www.w3.org/2000/svg"> +<g id="arrow.clockwise.bling" clip-path="url(#clip0_907_3757)"> +<g id="Notes"> +<path id="artboard" d="M3300 0H0V2200H3300V0Z" fill="white"/> +<path id="Vector" d="M263 292H3036" stroke="black" stroke-width="0.5"/> +<text id="Weight/Scale Variations" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" font-weight="bold" letter-spacing="0em"><tspan x="263" y="320.943">Weight/Scale Variations</tspan></text> +<text id="Ultralight" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="533.211" y="320.943">Ultralight</tspan></text> +<text id="Thin" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="843.422" y="320.943">Thin</tspan></text> +<text id="Light" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="1138.63" y="320.943">Light</tspan></text> +<text id="Regular" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="1427.34" y="320.943">Regular</tspan></text> +<text id="Medium" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="1722.56" y="320.943">Medium</tspan></text> +<text id="Semibold" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2015.77" y="320.943">Semibold</tspan></text> +<text id="Bold" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2326.48" y="320.943">Bold</tspan></text> +<text id="Heavy" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2618.69" y="320.943">Heavy</tspan></text> +<text id="Black" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2917.4" y="320.943">Black</tspan></text> +<path id="Vector_2" d="M263 1903H3036" stroke="black" stroke-width="0.5"/> +<g id="Group"> +<path id="Vector_3" d="M272.248 1933.83C273.329 1933.83 274.344 1933.62 275.295 1933.21C276.245 1932.8 277.084 1932.23 277.81 1931.51C278.535 1930.78 279.105 1929.94 279.519 1928.99C279.932 1928.04 280.139 1927.02 280.139 1925.95C280.139 1924.87 279.932 1923.86 279.519 1922.91C279.105 1921.96 278.534 1921.12 277.805 1920.39C277.075 1919.66 276.236 1919.09 275.285 1918.68C274.335 1918.27 273.319 1918.07 272.238 1918.07C271.164 1918.07 270.152 1918.27 269.201 1918.68C268.251 1919.09 267.414 1919.66 266.691 1920.39C265.969 1921.12 265.401 1921.96 264.987 1922.91C264.574 1923.86 264.367 1924.87 264.367 1925.95C264.367 1927.02 264.574 1928.04 264.987 1928.99C265.401 1929.94 265.97 1930.78 266.696 1931.51C267.422 1932.23 268.26 1932.8 269.211 1933.21C270.161 1933.62 271.174 1933.83 272.248 1933.83ZM272.248 1932.35C271.363 1932.35 270.534 1932.18 269.763 1931.85C268.991 1931.52 268.314 1931.07 267.731 1930.48C267.149 1929.89 266.693 1929.21 266.364 1928.44C266.035 1927.66 265.871 1926.83 265.871 1925.95C265.871 1925.06 266.034 1924.23 266.359 1923.46C266.685 1922.68 267.139 1922 267.722 1921.42C268.304 1920.83 268.981 1920.37 269.753 1920.05C270.524 1919.72 271.353 1919.55 272.238 1919.55C273.13 1919.55 273.962 1919.72 274.733 1920.05C275.505 1920.37 276.184 1920.83 276.769 1921.42C277.355 1922 277.814 1922.68 278.146 1923.46C278.478 1924.23 278.644 1925.06 278.644 1925.95C278.644 1926.83 278.48 1927.66 278.151 1928.44C277.823 1929.21 277.367 1929.89 276.784 1930.48C276.202 1931.07 275.523 1931.52 274.748 1931.85C273.973 1932.18 273.14 1932.35 272.248 1932.35ZM268.654 1925.95C268.654 1926.16 268.723 1926.34 268.859 1926.47C268.996 1926.61 269.178 1926.67 269.406 1926.67H271.516V1928.79C271.516 1929.01 271.581 1929.18 271.711 1929.32C271.841 1929.46 272.017 1929.53 272.238 1929.53C272.453 1929.53 272.631 1929.46 272.771 1929.32C272.91 1929.18 272.98 1929.01 272.98 1928.79V1926.67H275.09C275.311 1926.67 275.49 1926.61 275.627 1926.47C275.764 1926.34 275.832 1926.16 275.832 1925.95C275.832 1925.73 275.764 1925.55 275.627 1925.41C275.49 1925.28 275.311 1925.21 275.09 1925.21H272.98V1923.1C272.98 1922.88 272.91 1922.7 272.771 1922.56C272.631 1922.42 272.453 1922.35 272.238 1922.35C272.017 1922.35 271.841 1922.42 271.711 1922.56C271.581 1922.7 271.516 1922.88 271.516 1923.1V1925.21H269.406C269.178 1925.21 268.996 1925.28 268.859 1925.41C268.723 1925.55 268.654 1925.73 268.654 1925.95Z" fill="black"/> +</g> +<g id="Group_2"> +<path id="Vector_4" d="M293.576 1935.91C294.937 1935.91 296.218 1935.65 297.419 1935.13C298.62 1934.61 299.68 1933.89 300.598 1932.97C301.516 1932.05 302.235 1930.99 302.756 1929.79C303.277 1928.59 303.537 1927.31 303.537 1925.95C303.537 1924.59 303.277 1923.31 302.756 1922.11C302.235 1920.91 301.516 1919.85 300.598 1918.93C299.68 1918.01 298.618 1917.29 297.414 1916.77C296.21 1916.25 294.927 1915.99 293.566 1915.99C292.206 1915.99 290.925 1916.25 289.724 1916.77C288.522 1917.29 287.465 1918.01 286.55 1918.93C285.635 1919.85 284.917 1920.91 284.396 1922.11C283.876 1923.31 283.615 1924.59 283.615 1925.95C283.615 1927.31 283.876 1928.59 284.396 1929.79C284.917 1930.99 285.637 1932.05 286.555 1932.97C287.473 1933.89 288.532 1934.61 289.733 1935.13C290.935 1935.65 292.215 1935.91 293.576 1935.91ZM293.576 1934.25C292.424 1934.25 291.346 1934.04 290.344 1933.61C289.341 1933.18 288.461 1932.58 287.702 1931.82C286.944 1931.06 286.351 1930.18 285.925 1929.18C285.498 1928.18 285.285 1927.1 285.285 1925.95C285.285 1924.8 285.498 1923.72 285.925 1922.72C286.351 1921.71 286.942 1920.83 287.697 1920.07C288.452 1919.31 289.331 1918.71 290.334 1918.29C291.337 1917.86 292.414 1917.65 293.566 1917.65C294.719 1917.65 295.796 1917.86 296.799 1918.29C297.801 1918.71 298.684 1919.31 299.445 1920.07C300.207 1920.83 300.803 1921.71 301.232 1922.72C301.662 1923.72 301.877 1924.8 301.877 1925.95C301.877 1927.1 301.664 1928.18 301.237 1929.18C300.811 1930.18 300.218 1931.06 299.46 1931.82C298.702 1932.58 297.819 1933.18 296.813 1933.61C295.808 1934.04 294.729 1934.25 293.576 1934.25ZM289.045 1925.95C289.045 1926.18 289.123 1926.38 289.279 1926.53C289.436 1926.68 289.637 1926.75 289.885 1926.75H292.756V1929.63C292.756 1929.88 292.831 1930.08 292.98 1930.23C293.13 1930.38 293.322 1930.46 293.557 1930.46C293.804 1930.46 294.004 1930.38 294.157 1930.23C294.31 1930.08 294.387 1929.88 294.387 1929.63V1926.75H297.268C297.515 1926.75 297.715 1926.68 297.868 1926.53C298.021 1926.38 298.098 1926.18 298.098 1925.95C298.098 1925.7 298.021 1925.5 297.868 1925.35C297.715 1925.2 297.515 1925.12 297.268 1925.12H294.387V1922.25C294.387 1921.99 294.31 1921.79 294.157 1921.64C294.004 1921.48 293.804 1921.41 293.557 1921.41C293.322 1921.41 293.13 1921.49 292.98 1921.64C292.831 1921.8 292.756 1922 292.756 1922.25V1925.12H289.885C289.631 1925.12 289.427 1925.2 289.274 1925.35C289.121 1925.5 289.045 1925.7 289.045 1925.95Z" fill="black"/> +</g> +<g id="Group_3"> +<path id="Vector_5" d="M320.617 1938.66C322.01 1938.66 323.34 1938.45 324.606 1938.01C325.872 1937.58 327.036 1936.97 328.097 1936.19C329.158 1935.41 330.081 1934.49 330.866 1933.43C331.65 1932.37 332.259 1931.2 332.692 1929.93C333.125 1928.66 333.341 1927.34 333.341 1925.95C333.341 1924.56 333.125 1923.23 332.692 1921.96C332.259 1920.69 331.65 1919.53 330.866 1918.47C330.081 1917.41 329.158 1916.48 328.097 1915.7C327.036 1914.92 325.871 1914.31 324.601 1913.87C323.332 1913.44 322 1913.22 320.607 1913.22C319.214 1913.22 317.884 1913.44 316.618 1913.87C315.351 1914.31 314.189 1914.92 313.131 1915.7C312.073 1916.48 311.152 1917.41 310.368 1918.47C309.583 1919.53 308.976 1920.69 308.546 1921.96C308.117 1923.23 307.902 1924.56 307.902 1925.95C307.902 1927.34 308.118 1928.66 308.551 1929.93C308.984 1931.2 309.591 1932.37 310.373 1933.43C311.154 1934.49 312.075 1935.41 313.136 1936.19C314.197 1936.97 315.361 1937.58 316.627 1938.01C317.894 1938.45 319.223 1938.66 320.617 1938.66ZM320.617 1936.85C319.412 1936.85 318.265 1936.66 317.174 1936.3C316.084 1935.93 315.086 1935.41 314.181 1934.75C313.276 1934.08 312.49 1933.3 311.823 1932.39C311.155 1931.48 310.639 1930.48 310.275 1929.39C309.91 1928.3 309.728 1927.15 309.728 1925.95C309.728 1924.74 309.91 1923.59 310.275 1922.5C310.639 1921.41 311.154 1920.41 311.818 1919.5C312.482 1918.59 313.266 1917.8 314.171 1917.14C315.076 1916.48 316.074 1915.96 317.165 1915.6C318.255 1915.23 319.402 1915.05 320.607 1915.05C321.818 1915.05 322.969 1915.23 324.059 1915.6C325.15 1915.96 326.149 1916.48 327.057 1917.14C327.965 1917.8 328.751 1918.59 329.415 1919.5C330.08 1920.41 330.596 1921.41 330.963 1922.5C331.331 1923.59 331.515 1924.74 331.515 1925.95C331.522 1927.15 331.343 1928.3 330.978 1929.39C330.613 1930.48 330.098 1931.48 329.43 1932.39C328.763 1933.3 327.975 1934.08 327.067 1934.75C326.159 1935.41 325.159 1935.93 324.069 1936.3C322.978 1936.66 321.828 1936.85 320.617 1936.85ZM314.845 1925.95C314.845 1926.2 314.931 1926.41 315.104 1926.58C315.277 1926.75 315.496 1926.83 315.763 1926.83H319.708V1930.78C319.708 1931.05 319.791 1931.27 319.957 1931.44C320.123 1931.61 320.337 1931.7 320.597 1931.7C320.864 1931.7 321.084 1931.62 321.256 1931.45C321.429 1931.28 321.515 1931.06 321.515 1930.78V1926.83H325.47C325.737 1926.83 325.955 1926.75 326.124 1926.58C326.294 1926.41 326.378 1926.2 326.378 1925.95C326.378 1925.68 326.294 1925.45 326.124 1925.29C325.955 1925.12 325.737 1925.03 325.47 1925.03H321.515V1921.09C321.515 1920.81 321.429 1920.59 321.256 1920.42C321.084 1920.24 320.864 1920.16 320.597 1920.16C320.337 1920.16 320.123 1920.24 319.957 1920.42C319.791 1920.59 319.708 1920.81 319.708 1921.09V1925.03H315.763C315.49 1925.03 315.268 1925.12 315.099 1925.29C314.93 1925.45 314.845 1925.68 314.845 1925.95Z" fill="black"/> +</g> +<text id="Design Variations" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" font-weight="bold" letter-spacing="0em"><tspan x="263" y="1951.94">Design Variations</tspan></text> +<text id="Symbols are supported in up to nine weights and three scales." fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="1969.94">Symbols are supported in up to nine weights and three scales.</tspan></text> +<text id="For optimal layout with text and other symbols, vertically align" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="1987.94">For optimal layout with text and other symbols, vertically align</tspan></text> +<text id="symbols with the adjacent text." fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="2005.94">symbols with the adjacent text.</tspan></text> +<path id="Vector_6" d="M776 1919V1933" stroke="#00AEEF" stroke-width="0.5"/> +<g id="Group_4"> +<path id="Vector_7" d="M779.311 1933.16C779.571 1933.16 779.773 1933.1 779.916 1932.99C780.059 1932.88 780.176 1932.69 780.268 1932.41L781.527 1928.97H787.289L788.549 1932.41C788.64 1932.69 788.757 1932.88 788.9 1932.99C789.044 1933.1 789.242 1933.16 789.496 1933.16C789.757 1933.16 789.963 1933.08 790.116 1932.94C790.269 1932.8 790.346 1932.6 790.346 1932.36C790.346 1932.21 790.31 1932.03 790.238 1931.83L785.658 1919.63C785.541 1919.33 785.382 1919.11 785.18 1918.96C784.978 1918.81 784.721 1918.73 784.408 1918.73C783.803 1918.73 783.393 1919.03 783.178 1919.62L778.598 1931.84C778.526 1932.04 778.49 1932.22 778.49 1932.37C778.49 1932.61 778.563 1932.81 778.71 1932.95C778.856 1933.09 779.057 1933.16 779.311 1933.16ZM782.006 1927.48L784.379 1920.91H784.428L786.801 1927.48H782.006Z" fill="black"/> +</g> +<path id="Vector_8" d="M793.197 1919V1933" stroke="#00AEEF" stroke-width="0.5"/> +<text id="Margins" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" font-weight="bold" letter-spacing="0em"><tspan x="776" y="1951.94">Margins</tspan></text> +<text id="Leading and trailing margins on the left and right side of each symbol" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="776" y="1969.94">Leading and trailing margins on the left and right side of each symbol</tspan></text> +<text id="can be adjusted by modifying the x-location of the margin guidelines." fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="776" y="1987.94">can be adjusted by modifying the x-location of the margin guidelines.</tspan></text> +<text id="Modifications are automatically applied proportionally to all" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="776" y="2005.94">Modifications are automatically applied proportionally to all</tspan></text> +<text id="scales and weights." fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="776" y="2023.94">scales and weights.</tspan></text> +<g id="Group_5"> +<path id="Vector_9" d="M1291.84 1934.87L1293.54 1936.57C1293.97 1937.01 1294.42 1937.21 1294.9 1937.18C1295.38 1937.15 1295.85 1936.87 1296.31 1936.36L1307.01 1924.57L1306.04 1923.6L1295.43 1935.28C1295.25 1935.48 1295.07 1935.59 1294.89 1935.62C1294.71 1935.64 1294.51 1935.54 1294.27 1935.3L1293.1 1934.14C1292.87 1933.91 1292.76 1933.7 1292.79 1933.52C1292.82 1933.34 1292.94 1933.16 1293.14 1932.98L1304.62 1922.18L1303.64 1921.21L1292.05 1932.1C1291.55 1932.56 1291.29 1933.02 1291.25 1933.5C1291.22 1933.97 1291.41 1934.43 1291.84 1934.87ZM1298.26 1916.67C1298.05 1916.87 1297.93 1917.1 1297.91 1917.37C1297.88 1917.63 1297.93 1917.85 1298.04 1918.05C1298.16 1918.23 1298.33 1918.37 1298.56 1918.46C1298.78 1918.55 1299.06 1918.56 1299.38 1918.48C1300.11 1918.31 1300.85 1918.24 1301.6 1918.27C1302.35 1918.3 1303.08 1918.55 1303.79 1919.02L1303.21 1920.47C1303.04 1920.89 1302.99 1921.25 1303.07 1921.56C1303.14 1921.87 1303.31 1922.16 1303.58 1922.43L1305.87 1924.75C1306.12 1925 1306.35 1925.14 1306.58 1925.18C1306.81 1925.22 1307.06 1925.21 1307.34 1925.16L1308.4 1924.96L1309.07 1925.64L1309.03 1926.19C1309.01 1926.44 1309.04 1926.67 1309.12 1926.88C1309.2 1927.09 1309.36 1927.31 1309.61 1927.55L1310.37 1928.29C1310.61 1928.53 1310.87 1928.66 1311.15 1928.67C1311.44 1928.68 1311.7 1928.57 1311.93 1928.33L1314.84 1925.41C1315.07 1925.18 1315.19 1924.92 1315.18 1924.65C1315.18 1924.37 1315.05 1924.11 1314.81 1923.87L1314.04 1923.11C1313.8 1922.87 1313.58 1922.7 1313.38 1922.61C1313.17 1922.53 1312.95 1922.49 1312.71 1922.51L1312.13 1922.56L1311.49 1921.93L1311.73 1920.8C1311.8 1920.52 1311.79 1920.26 1311.7 1920.02C1311.6 1919.77 1311.41 1919.5 1311.12 1919.21L1308.92 1917.02C1308.09 1916.2 1307.2 1915.58 1306.26 1915.16C1305.32 1914.75 1304.37 1914.53 1303.42 1914.52C1302.47 1914.5 1301.55 1914.68 1300.66 1915.04C1299.78 1915.41 1298.98 1915.95 1298.26 1916.67ZM1299.75 1917.04C1300.36 1916.6 1301.01 1916.28 1301.7 1916.1C1302.39 1915.91 1303.1 1915.85 1303.8 1915.92C1304.51 1915.98 1305.2 1916.17 1305.87 1916.49C1306.54 1916.8 1307.15 1917.24 1307.7 1917.79L1310.13 1920.21C1310.25 1920.32 1310.32 1920.44 1310.35 1920.55C1310.38 1920.66 1310.38 1920.8 1310.34 1920.97L1310.02 1922.45L1311.52 1923.94L1312.51 1923.88C1312.63 1923.87 1312.72 1923.88 1312.79 1923.9C1312.85 1923.93 1312.94 1923.99 1313.03 1924.08L1313.61 1924.66L1311.17 1927.1L1310.59 1926.53C1310.49 1926.43 1310.43 1926.35 1310.41 1926.28C1310.38 1926.22 1310.37 1926.12 1310.38 1925.99L1310.45 1925.01L1308.95 1923.53L1307.43 1923.78C1307.26 1923.81 1307.14 1923.82 1307.04 1923.8C1306.95 1923.77 1306.84 1923.7 1306.71 1923.59L1304.71 1921.58C1304.58 1921.47 1304.51 1921.35 1304.49 1921.25C1304.48 1921.14 1304.51 1920.99 1304.59 1920.81L1305.46 1918.72C1304.68 1917.99 1303.8 1917.49 1302.83 1917.21C1301.85 1916.93 1300.86 1916.94 1299.84 1917.24C1299.76 1917.26 1299.71 1917.24 1299.69 1917.19C1299.67 1917.15 1299.69 1917.1 1299.75 1917.04Z" fill="black"/> +</g> +<text id="Exporting" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" font-weight="bold" letter-spacing="0em"><tspan x="1289" y="1951.94">Exporting</tspan></text> +<text id="Symbols should be outlined when exporting to ensure the" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="1289" y="1969.94">Symbols should be outlined when exporting to ensure the</tspan></text> +<text id="design is preserved when submitting to Xcode." fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="1289" y="1987.94">design is preserved when submitting to Xcode.</tspan></text> +<text id="template-version" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2951" y="1931.94">Template v.3.0</tspan></text> +<text id="Requires Xcode 13 or greater" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2868" y="1949.94">Requires Xcode 13 or greater</tspan></text> +<text id="descriptive-name" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2849" y="1967.94">Generated from arrow.clockwise</tspan></text> +<text id="Typeset at 100 points" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="2911" y="1985.94">Typeset at 100 points</tspan></text> +<text id="Small" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="724.943">Small</tspan></text> +<text id="Medium_2" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="1154.94">Medium</tspan></text> +<text id="Large" fill="black" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="13" letter-spacing="0em"><tspan x="263" y="1584.94">Large</tspan></text> +</g> +<g id="Guides"> +<g id="H-reference"> +<path id="Vector_10" d="M339.977 696H342.662L368.346 628.861H369.029V625.541H367.125L339.977 696ZM350.67 671.537H385.973L385.24 669.291H351.451L350.67 671.537ZM394.127 696H396.764L369.615 625.541H368.443V628.861L394.127 696Z" fill="#27AAE1"/> +</g> +<path id="Baseline-S" d="M263 696H3036" stroke="#27AAE1" stroke-width="0.5"/> +<path id="Capline-S" d="M263 625.541H3036" stroke="#27AAE1" stroke-width="0.5"/> +<g id="H-reference_2"> +<path id="Vector_11" d="M339.977 1126H342.662L368.346 1058.86H369.029V1055.54H367.125L339.977 1126ZM350.67 1101.54H385.973L385.24 1099.29H351.451L350.67 1101.54ZM394.127 1126H396.764L369.615 1055.54H368.443V1058.86L394.127 1126Z" fill="#27AAE1"/> +</g> +<path id="Baseline-M" d="M263 1126H3036" stroke="#27AAE1" stroke-width="0.5"/> +<path id="Capline-M" d="M263 1055.54H3036" stroke="#27AAE1" stroke-width="0.5"/> +<g id="H-reference_3"> +<path id="Vector_12" d="M339.977 1556H342.662L368.346 1488.86H369.029V1485.54H367.125L339.977 1556ZM350.67 1531.54H385.973L385.24 1529.29H351.451L350.67 1531.54ZM394.127 1556H396.764L369.615 1485.54H368.443V1488.86L394.127 1556Z" fill="#27AAE1"/> +</g> +<path id="Baseline-L" d="M263 1556H3036" stroke="#27AAE1" stroke-width="0.5"/> +<path id="Capline-L" d="M263 1485.54H3036" stroke="#27AAE1" stroke-width="0.5"/> +<path id="left-margin-Regular-M" d="M1397.96 1030.79V1150.12" stroke="#00AEEF" stroke-width="0.5"/> +<path id="right-margin-Regular-M" d="M1501.72 1030.79V1150.12" stroke="#00AEEF" stroke-width="0.5"/> +</g> +<g id="Symbols"> +<g id="Black-L"> +<path id="Union (Stroke)" fill-rule="evenodd" clip-rule="evenodd" d="M2934.42 1465.75C2906.93 1465.75 2884.75 1487.86 2884.75 1515C2884.75 1542.14 2906.93 1564.25 2934.42 1564.25C2943.13 1564.25 2951.29 1562.04 2958.38 1558.15C2962.62 1555.83 2967.94 1557.39 2970.26 1561.63C2972.58 1565.87 2971.02 1571.19 2966.78 1573.51C2957.17 1578.76 2946.13 1581.75 2934.42 1581.75C2897.38 1581.75 2867.25 1551.92 2867.25 1515C2867.25 1478.08 2897.38 1448.25 2934.42 1448.25C2953.65 1448.25 2971 1456.28 2983.25 1469.16V1457C2983.25 1452.17 2987.17 1448.25 2992 1448.25C2996.83 1448.25 3000.75 1452.17 3000.75 1457V1496.43C3000.75 1501.54 2996.61 1505.68 2991.5 1505.68H2951.9C2947.07 1505.68 2943.15 1501.76 2943.15 1496.93C2943.15 1492.1 2947.07 1488.18 2951.9 1488.18H2976.09C2967.23 1474.69 2951.89 1465.75 2934.42 1465.75Z" fill="black"/> +</g> +<g id="Heavy-L"> +<path id="Union (Stroke)_2" fill-rule="evenodd" clip-rule="evenodd" d="M2638.42 1468.75C2610.93 1468.75 2588.75 1490.86 2588.75 1518C2588.75 1545.14 2610.93 1567.25 2638.42 1567.25C2647.13 1567.25 2655.29 1565.04 2662.38 1561.15C2666.62 1558.83 2671.94 1560.39 2674.26 1564.63C2676.58 1568.87 2675.02 1574.19 2670.78 1576.51C2661.17 1581.76 2650.13 1584.75 2638.42 1584.75C2601.38 1584.75 2571.25 1554.92 2571.25 1518C2571.25 1481.08 2601.38 1451.25 2638.42 1451.25C2657.65 1451.25 2675 1459.28 2687.25 1472.16V1460C2687.25 1455.17 2691.17 1451.25 2696 1451.25C2700.83 1451.25 2704.75 1455.17 2704.75 1460V1499.43C2704.75 1504.54 2700.61 1508.68 2695.5 1508.68H2655.9C2651.07 1508.68 2647.15 1504.76 2647.15 1499.93C2647.15 1495.1 2651.07 1491.18 2655.9 1491.18H2680.09C2671.23 1477.69 2655.89 1468.75 2638.42 1468.75Z" fill="black"/> +</g> +<g id="Bold-L"> +<path id="Union (Stroke)_3" fill-rule="evenodd" clip-rule="evenodd" d="M2342.42 1467.75C2314.38 1467.75 2291.75 1490.3 2291.75 1518C2291.75 1545.7 2314.38 1568.25 2342.42 1568.25C2351.3 1568.25 2359.62 1565.99 2366.86 1562.03C2370.61 1559.98 2375.32 1561.35 2377.38 1565.11C2379.43 1568.86 2378.05 1573.57 2374.3 1575.63C2364.84 1580.81 2353.96 1583.75 2342.42 1583.75C2305.93 1583.75 2276.25 1554.37 2276.25 1518C2276.25 1481.63 2305.93 1452.25 2342.42 1452.25C2362.29 1452.25 2380.12 1460.95 2392.25 1474.74V1460C2392.25 1455.72 2395.72 1452.25 2400 1452.25C2404.28 1452.25 2407.75 1455.72 2407.75 1460V1499.43C2407.75 1503.98 2404.06 1507.68 2399.5 1507.68H2359.9C2355.62 1507.68 2352.15 1504.21 2352.15 1499.93C2352.15 1495.65 2355.62 1492.18 2359.9 1492.18H2385.9C2377.05 1477.55 2360.9 1467.75 2342.42 1467.75Z" fill="black"/> +</g> +<g id="Semibold-L"> +<path id="Union (Stroke)_4" fill-rule="evenodd" clip-rule="evenodd" d="M2045.42 1466C2016.43 1466 1993 1489.32 1993 1518C1993 1546.68 2016.43 1570 2045.42 1570C2054.6 1570 2063.21 1567.66 2070.7 1563.57C2073.61 1561.98 2077.25 1563.04 2078.84 1565.95C2080.43 1568.86 2079.37 1572.5 2076.46 1574.09C2067.25 1579.14 2056.66 1582 2045.42 1582C2009.88 1582 1981 1553.39 1981 1518C1981 1482.61 2009.88 1454 2045.42 1454C2066.51 1454 2085.25 1464.07 2097 1479.65V1460C2097 1456.69 2099.69 1454 2103 1454C2106.31 1454 2109 1456.69 2109 1460V1499.43C2109 1503.02 2106.09 1505.93 2102.5 1505.93H2062.9C2059.59 1505.93 2056.9 1503.24 2056.9 1499.93C2056.9 1496.61 2059.59 1493.93 2062.9 1493.93H2091.9C2083.15 1477.34 2065.62 1466 2045.42 1466Z" fill="black"/> +</g> +<g id="Medium-L"> +<path id="Union (Stroke)_5" fill-rule="evenodd" clip-rule="evenodd" d="M1747.42 1466.5C1718.16 1466.5 1694.5 1490.04 1694.5 1519C1694.5 1547.96 1718.16 1571.5 1747.42 1571.5C1756.69 1571.5 1765.38 1569.14 1772.94 1565.01C1775.6 1563.55 1778.95 1564.53 1780.4 1567.19C1781.86 1569.85 1780.89 1573.2 1778.22 1574.65C1769.08 1579.66 1758.57 1582.5 1747.42 1582.5C1712.16 1582.5 1683.5 1554.11 1683.5 1519C1683.5 1483.89 1712.16 1455.5 1747.42 1455.5C1768.9 1455.5 1787.91 1466.02 1799.5 1482.18V1461C1799.5 1457.96 1801.96 1455.5 1805 1455.5C1808.04 1455.5 1810.5 1457.96 1810.5 1461V1500.43C1810.5 1503.74 1807.81 1506.43 1804.5 1506.43H1764.9C1761.87 1506.43 1759.4 1503.97 1759.4 1500.93C1759.4 1497.89 1761.87 1495.43 1764.9 1495.43H1794.72C1786.02 1478.28 1768.11 1466.5 1747.42 1466.5Z" fill="black"/> +</g> +<g id="Regular-L"> +<path id="Union (Stroke)_6" fill-rule="evenodd" clip-rule="evenodd" d="M1452.42 1467C1422.88 1467 1399 1490.76 1399 1520C1399 1549.24 1422.88 1573 1452.42 1573C1461.77 1573 1470.55 1570.62 1478.18 1566.44C1480.6 1565.12 1483.64 1566.01 1484.97 1568.43C1486.29 1570.85 1485.4 1573.89 1482.98 1575.22C1473.91 1580.18 1463.49 1583 1452.42 1583C1417.43 1583 1389 1554.83 1389 1520C1389 1485.17 1417.43 1457 1452.42 1457C1474.3 1457 1493.6 1468.01 1505 1484.76V1462C1505 1459.24 1507.24 1457 1510 1457C1512.76 1457 1515 1459.24 1515 1462V1501.43C1515 1504.47 1512.54 1506.93 1509.5 1506.93H1469.9C1467.14 1506.93 1464.9 1504.69 1464.9 1501.93C1464.9 1499.17 1467.14 1496.93 1469.9 1496.93H1500.53C1491.88 1479.22 1473.6 1467 1452.42 1467Z" fill="black"/> +</g> +<g id="Light-L"> +<path id="Union (Stroke)_7" fill-rule="evenodd" clip-rule="evenodd" d="M1153.42 1465C1123.34 1465 1099 1489.2 1099 1519C1099 1548.8 1123.34 1573 1153.42 1573C1162.94 1573 1171.88 1570.58 1179.66 1566.32C1181.6 1565.26 1184.03 1565.97 1185.09 1567.91C1186.15 1569.85 1185.44 1572.28 1183.5 1573.34C1174.57 1578.22 1164.32 1581 1153.42 1581C1118.97 1581 1091 1553.27 1091 1519C1091 1484.73 1118.97 1457 1153.42 1457C1176.17 1457 1196.09 1469.09 1207 1487.18V1461C1207 1458.79 1208.79 1457 1211 1457C1213.21 1457 1215 1458.79 1215 1461V1500.43C1215 1502.91 1212.99 1504.93 1210.5 1504.93H1170.9C1168.7 1504.93 1166.9 1503.14 1166.9 1500.93C1166.9 1498.72 1168.7 1496.93 1170.9 1496.93H1203.1C1194.6 1478.11 1175.56 1465 1153.42 1465Z" fill="black"/> +</g> +<g id="Thin-L"> +<path id="Union (Stroke)_8" fill-rule="evenodd" clip-rule="evenodd" d="M858.42 1464.5C828.065 1464.5 803.5 1488.92 803.5 1519C803.5 1549.08 828.065 1573.5 858.42 1573.5C868.029 1573.5 877.051 1571.05 884.9 1566.76C886.595 1565.83 888.722 1566.45 889.65 1568.15C890.578 1569.85 889.956 1571.97 888.26 1572.9C879.406 1577.75 869.231 1580.5 858.42 1580.5C824.247 1580.5 796.5 1552.99 796.5 1519C796.5 1485.01 824.247 1457.5 858.42 1457.5C881.655 1457.5 901.907 1470.21 912.5 1489.03V1461C912.5 1459.07 914.067 1457.5 916 1457.5C917.933 1457.5 919.5 1459.07 919.5 1461V1500.43C919.5 1502.64 917.709 1504.43 915.5 1504.43H875.904C873.971 1504.43 872.404 1502.86 872.404 1500.93C872.404 1498.99 873.971 1497.43 875.904 1497.43H908.872C900.452 1478.06 881.036 1464.5 858.42 1464.5Z" fill="black"/> +</g> +<g id="Ultralight-L"> +<path id="Union (Stroke)_9" fill-rule="evenodd" clip-rule="evenodd" d="M560.42 1463.5C529.519 1463.5 504.5 1488.37 504.5 1519C504.5 1549.63 529.519 1574.5 560.42 1574.5C570.201 1574.5 579.388 1572.01 587.38 1567.64C588.591 1566.97 590.11 1567.42 590.773 1568.63C591.436 1569.84 590.991 1571.36 589.78 1572.02C581.069 1576.79 571.06 1579.5 560.42 1579.5C526.792 1579.5 499.5 1552.43 499.5 1519C499.5 1485.57 526.792 1458.5 560.42 1458.5C584.737 1458.5 605.731 1472.65 615.5 1493.12V1461C615.5 1459.62 616.619 1458.5 618 1458.5C619.381 1458.5 620.5 1459.62 620.5 1461V1500.43C620.5 1502.08 619.157 1503.43 617.5 1503.43H577.904C576.524 1503.43 575.404 1502.31 575.404 1500.93C575.404 1499.55 576.524 1498.43 577.904 1498.43H612.374C604.141 1477.97 583.986 1463.5 560.42 1463.5Z" fill="black"/> +</g> +<g id="Black-M"> +<path id="Union (Stroke)_10" fill-rule="evenodd" clip-rule="evenodd" d="M2932.81 1057C2912.98 1057 2897 1072.94 2897 1092.5C2897 1112.06 2912.98 1128 2932.81 1128C2939.09 1128 2944.97 1126.4 2950.08 1123.61C2953.47 1121.75 2957.73 1122.99 2959.58 1126.39C2961.44 1129.78 2960.19 1134.03 2956.8 1135.89C2949.68 1139.79 2941.49 1142 2932.81 1142C2905.35 1142 2883 1119.89 2883 1092.5C2883 1065.11 2905.35 1043 2932.81 1043C2946.54 1043 2958.99 1048.53 2968 1057.47V1050C2968 1046.13 2971.13 1043 2975 1043C2978.87 1043 2982 1046.13 2982 1050V1078.76C2982 1082.9 2978.64 1086.26 2974.5 1086.26H2945.62C2941.75 1086.26 2938.62 1083.12 2938.62 1079.26C2938.62 1075.39 2941.75 1072.26 2945.62 1072.26H2962.23C2955.77 1063.04 2945 1057 2932.81 1057Z" fill="black"/> +</g> +<g id="Heavy-M"> +<path id="Union (Stroke)_11" fill-rule="evenodd" clip-rule="evenodd" d="M2634.81 1057C2614.98 1057 2599 1072.94 2599 1092.5C2599 1112.06 2614.98 1128 2634.81 1128C2641.09 1128 2646.97 1126.4 2652.08 1123.61C2655.47 1121.75 2659.73 1122.99 2661.58 1126.39C2663.44 1129.78 2662.19 1134.03 2658.8 1135.89C2651.68 1139.79 2643.49 1142 2634.81 1142C2607.35 1142 2585 1119.89 2585 1092.5C2585 1065.11 2607.35 1043 2634.81 1043C2648.54 1043 2660.99 1048.53 2670 1057.47V1050C2670 1046.13 2673.13 1043 2677 1043C2680.87 1043 2684 1046.13 2684 1050V1078.76C2684 1082.9 2680.64 1086.26 2676.5 1086.26H2647.62C2643.75 1086.26 2640.62 1083.12 2640.62 1079.26C2640.62 1075.39 2643.75 1072.26 2647.62 1072.26H2664.23C2657.77 1063.04 2647 1057 2634.81 1057Z" fill="black"/> +</g> +<g id="Bold-M"> +<path id="Union (Stroke)_12" fill-rule="evenodd" clip-rule="evenodd" d="M2339.81 1056C2319.71 1056 2303.5 1072.16 2303.5 1092C2303.5 1111.84 2319.71 1128 2339.81 1128C2346.17 1128 2352.14 1126.38 2357.32 1123.54C2360.47 1121.82 2364.42 1122.98 2366.14 1126.13C2367.87 1129.27 2366.71 1133.22 2363.56 1134.95C2356.51 1138.81 2348.41 1141 2339.81 1141C2312.62 1141 2290.5 1119.11 2290.5 1092C2290.5 1064.89 2312.62 1043 2339.81 1043C2353.84 1043 2366.52 1048.83 2375.5 1058.19V1049.5C2375.5 1045.91 2378.41 1043 2382 1043C2385.59 1043 2388.5 1045.91 2388.5 1049.5V1078.26C2388.5 1082.12 2385.37 1085.26 2381.5 1085.26H2352.62C2349.03 1085.26 2346.12 1082.35 2346.12 1078.76C2346.12 1075.17 2349.03 1072.26 2352.62 1072.26H2370.18C2363.69 1062.47 2352.52 1056 2339.81 1056Z" fill="black"/> +</g> +<g id="Semibold-M"> +<path id="Union (Stroke)_13" fill-rule="evenodd" clip-rule="evenodd" d="M2042.81 1055.5C2022.3 1055.5 2005.75 1071.99 2005.75 1092.25C2005.75 1112.51 2022.3 1129 2042.81 1129C2049.3 1129 2055.39 1127.35 2060.68 1124.45C2063.47 1122.93 2066.96 1123.95 2068.49 1126.74C2070.01 1129.52 2068.99 1133.02 2066.2 1134.54C2059.26 1138.34 2051.28 1140.5 2042.81 1140.5C2016.03 1140.5 1994.25 1118.94 1994.25 1092.25C1994.25 1065.56 2016.03 1044 2042.81 1044C2057.32 1044 2070.35 1050.33 2079.25 1060.36V1049.75C2079.25 1046.57 2081.82 1044 2085 1044C2088.18 1044 2090.75 1046.57 2090.75 1049.75V1078.51C2090.75 1081.96 2087.95 1084.76 2084.5 1084.76H2055.62C2052.44 1084.76 2049.87 1082.18 2049.87 1079.01C2049.87 1075.83 2052.44 1073.26 2055.62 1073.26H2074.54C2068.05 1062.62 2056.27 1055.5 2042.81 1055.5Z" fill="black"/> +</g> +<g id="Medium-M"> +<path id="Union (Stroke)_14" fill-rule="evenodd" clip-rule="evenodd" d="M1744.81 1055C1723.89 1055 1707 1071.82 1707 1092.5C1707 1113.18 1723.89 1130 1744.81 1130C1751.43 1130 1757.64 1128.32 1763.04 1125.36C1765.46 1124.03 1768.5 1124.92 1769.83 1127.35C1771.15 1129.77 1770.26 1132.81 1767.84 1134.13C1761 1137.87 1753.15 1140 1744.81 1140C1718.44 1140 1697 1118.77 1697 1092.5C1697 1066.23 1718.44 1045 1744.81 1045C1759.83 1045 1773.23 1051.88 1782 1062.65V1050C1782 1047.24 1784.24 1045 1787 1045C1789.76 1045 1792 1047.24 1792 1050V1078.76C1792 1081.79 1789.54 1084.26 1786.5 1084.26H1757.62C1754.86 1084.26 1752.62 1082.02 1752.62 1079.26C1752.62 1076.5 1754.86 1074.26 1757.62 1074.26H1777.85C1771.39 1062.78 1759.02 1055 1744.81 1055Z" fill="black"/> +</g> +<g id="Regular-M"> +<path id="Union (Stroke)_15" fill-rule="evenodd" clip-rule="evenodd" d="M1450.81 1054.5C1429.76 1054.5 1412.75 1071.43 1412.75 1092.25C1412.75 1113.07 1429.76 1130 1450.81 1130C1457.47 1130 1463.73 1128.3 1469.16 1125.33C1471.46 1124.07 1474.35 1124.91 1475.61 1127.22C1476.87 1129.52 1476.02 1132.4 1473.72 1133.66C1466.92 1137.39 1459.11 1139.5 1450.81 1139.5C1424.57 1139.5 1403.25 1118.38 1403.25 1092.25C1403.25 1066.12 1424.57 1045 1450.81 1045C1466 1045 1479.54 1052.08 1488.25 1063.11V1049.75C1488.25 1047.13 1490.38 1045 1493 1045C1495.62 1045 1497.75 1047.13 1497.75 1049.75V1078.51C1497.75 1081.41 1495.4 1083.76 1492.5 1083.76H1463.62C1461 1083.76 1458.87 1081.63 1458.87 1079.01C1458.87 1076.38 1461 1074.26 1463.62 1074.26H1484.27C1477.83 1062.5 1465.27 1054.5 1450.81 1054.5Z" fill="black"/> +</g> +<g id="Light-M"> +<path id="Union (Stroke)_16" fill-rule="evenodd" clip-rule="evenodd" d="M1153.81 1053.5C1132.48 1053.5 1115.25 1070.65 1115.25 1091.75C1115.25 1112.85 1132.48 1130 1153.81 1130C1160.56 1130 1166.89 1128.28 1172.4 1125.27C1174.46 1124.14 1177.04 1124.9 1178.17 1126.96C1179.3 1129.01 1178.54 1131.6 1176.48 1132.72C1169.75 1136.41 1162.02 1138.5 1153.81 1138.5C1127.85 1138.5 1106.75 1117.6 1106.75 1091.75C1106.75 1065.9 1127.85 1045 1153.81 1045C1169.37 1045 1183.18 1052.51 1191.75 1064.09V1049.25C1191.75 1046.9 1193.65 1045 1196 1045C1198.35 1045 1200.25 1046.9 1200.25 1049.25V1078.01C1200.25 1080.63 1198.12 1082.76 1195.5 1082.76H1166.62C1164.27 1082.76 1162.37 1080.85 1162.37 1078.51C1162.37 1076.16 1164.27 1074.26 1166.62 1074.26H1188.11C1181.71 1061.94 1168.76 1053.5 1153.81 1053.5Z" fill="black"/> +</g> +<g id="Thin-M"> +<path id="Union (Stroke)_17" fill-rule="evenodd" clip-rule="evenodd" d="M856.808 1052.5C834.666 1052.5 816.75 1070.32 816.75 1092.25C816.75 1114.18 834.666 1132 856.808 1132C863.817 1132 870.398 1130.22 876.122 1127.08C877.454 1126.35 879.125 1126.84 879.855 1128.18C880.584 1129.51 880.095 1131.18 878.762 1131.91C872.248 1135.47 864.762 1137.5 856.808 1137.5C831.666 1137.5 811.25 1117.26 811.25 1092.25C811.25 1067.24 831.666 1047 856.808 1047C873.652 1047 888.366 1056.08 896.25 1069.59V1049.75C896.25 1048.23 897.481 1047 899 1047C900.519 1047 901.75 1048.23 901.75 1049.75V1078.51C901.75 1080.3 900.295 1081.76 898.5 1081.76H869.62C868.101 1081.76 866.87 1080.53 866.87 1079.01C866.87 1077.49 868.101 1076.26 869.62 1076.26H893.493C887.292 1062.27 873.203 1052.5 856.808 1052.5Z" fill="black"/> +</g> +<g id="Ultralight-M"> +<path id="Union (Stroke)_18" fill-rule="evenodd" clip-rule="evenodd" d="M558.808 1051.5C536.12 1051.5 517.75 1069.76 517.75 1092.25C517.75 1114.74 536.12 1133 558.808 1133C565.989 1133 572.734 1131.17 578.602 1127.96C579.45 1127.5 580.513 1127.81 580.977 1128.66C581.441 1129.5 581.13 1130.57 580.282 1131.03C573.911 1134.52 566.59 1136.5 558.808 1136.5C534.211 1136.5 514.25 1116.7 514.25 1092.25C514.25 1067.8 534.211 1048 558.808 1048C576.724 1048 592.174 1058.5 599.25 1073.65V1049.75C599.25 1048.78 600.033 1048 601 1048C601.966 1048 602.75 1048.78 602.75 1049.75V1078.51C602.75 1079.75 601.743 1080.76 600.5 1080.76H571.62C570.653 1080.76 569.87 1079.97 569.87 1079.01C569.87 1078.04 570.653 1077.26 571.62 1077.26H596.998C590.982 1062.17 576.153 1051.5 558.808 1051.5Z" fill="black"/> +</g> +<g id="Black-S"> +<path id="Union (Stroke)_19" fill-rule="evenodd" clip-rule="evenodd" d="M2931.75 631C2915.83 631 2903 643.801 2903 659.5C2903 675.199 2915.83 688 2931.75 688C2936.79 688 2941.51 686.718 2945.62 684.471C2948.53 682.881 2952.17 683.948 2953.76 686.855C2955.35 689.762 2954.29 693.408 2951.38 694.998C2945.55 698.189 2938.85 700 2931.75 700C2909.29 700 2891 681.908 2891 659.5C2891 637.092 2909.29 619 2931.75 619C2942.71 619 2952.67 623.305 2960 630.313V625C2960 621.686 2962.69 619 2966 619C2969.31 619 2972 621.686 2972 625V648.25C2972 651.84 2969.09 654.75 2965.5 654.75H2942.15C2938.84 654.75 2936.15 652.064 2936.15 648.75C2936.15 645.436 2938.84 642.75 2942.15 642.75H2955.01C2949.79 635.634 2941.32 631 2931.75 631Z" fill="black"/> +</g> +<g id="Heavy-S"> +<path id="Union (Stroke)_20" fill-rule="evenodd" clip-rule="evenodd" d="M2637.75 632C2621.83 632 2609 644.801 2609 660.5C2609 676.199 2621.83 689 2637.75 689C2642.79 689 2647.51 687.718 2651.62 685.471C2654.53 683.881 2658.17 684.948 2659.76 687.855C2661.35 690.762 2660.29 694.408 2657.38 695.998C2651.55 699.189 2644.85 701 2637.75 701C2615.29 701 2597 682.908 2597 660.5C2597 638.092 2615.29 620 2637.75 620C2648.71 620 2658.67 624.305 2666 631.313V626C2666 622.686 2668.69 620 2672 620C2675.31 620 2678 622.686 2678 626V649.25C2678 652.84 2675.09 655.75 2671.5 655.75H2648.15C2644.84 655.75 2642.15 653.064 2642.15 649.75C2642.15 646.436 2644.84 643.75 2648.15 643.75H2661.01C2655.79 636.634 2647.32 632 2637.75 632Z" fill="black"/> +</g> +<g id="Bold-S"> +<path id="Union (Stroke)_21" fill-rule="evenodd" clip-rule="evenodd" d="M2339.75 632C2323.29 632 2310 645.242 2310 661.5C2310 677.758 2323.29 691 2339.75 691C2344.96 691 2349.85 689.674 2354.1 687.349C2356.52 686.023 2359.56 686.912 2360.89 689.335C2362.21 691.757 2361.32 694.796 2358.9 696.121C2353.21 699.233 2346.68 701 2339.75 701C2317.83 701 2300 683.349 2300 661.5C2300 639.651 2317.83 622 2339.75 622C2351.32 622 2361.73 626.91 2369 634.753V627C2369 624.239 2371.24 622 2374 622C2376.76 622 2379 624.239 2379 627V650.25C2379 653.288 2376.54 655.75 2373.5 655.75H2350.15C2347.39 655.75 2345.15 653.511 2345.15 650.75C2345.15 647.989 2347.39 645.75 2350.15 645.75H2364.91C2359.64 637.492 2350.35 632 2339.75 632Z" fill="black"/> +</g> +<g id="Semibold-S"> +<path id="Union (Stroke)_22" fill-rule="evenodd" clip-rule="evenodd" d="M2044.75 630.5C2028.01 630.5 2014.5 643.962 2014.5 660.5C2014.5 677.038 2028.01 690.5 2044.75 690.5C2050.05 690.5 2055.02 689.152 2059.34 686.787C2061.52 685.594 2064.25 686.395 2065.45 688.575C2066.64 690.755 2065.84 693.49 2063.66 694.683C2058.05 697.755 2051.6 699.5 2044.75 699.5C2023.1 699.5 2005.5 682.07 2005.5 660.5C2005.5 638.93 2023.1 621.5 2044.75 621.5C2056.64 621.5 2067.3 626.754 2074.5 635.06V626C2074.5 623.515 2076.51 621.5 2079 621.5C2081.49 621.5 2083.5 623.515 2083.5 626V649.25C2083.5 652.012 2081.26 654.25 2078.5 654.25H2055.15C2052.66 654.25 2050.65 652.235 2050.65 649.75C2050.65 647.265 2052.66 645.25 2055.15 645.25H2070.81C2065.54 636.426 2055.85 630.5 2044.75 630.5Z" fill="black"/> +</g> +<g id="Medium-S"> +<path id="Union (Stroke)_23" fill-rule="evenodd" clip-rule="evenodd" d="M1746.75 631.25C1729.88 631.25 1716.25 644.822 1716.25 661.5C1716.25 678.178 1729.88 691.75 1746.75 691.75C1752.09 691.75 1757.1 690.391 1761.46 688.007C1763.52 686.88 1766.1 687.636 1767.23 689.695C1768.36 691.754 1767.6 694.336 1765.54 695.463C1759.96 698.516 1753.55 700.25 1746.75 700.25C1725.24 700.25 1707.75 682.93 1707.75 661.5C1707.75 640.07 1725.24 622.75 1746.75 622.75C1758.81 622.75 1769.59 628.189 1776.75 636.739V627C1776.75 624.653 1778.65 622.75 1781 622.75C1783.35 622.75 1785.25 624.653 1785.25 627V650.25C1785.25 652.873 1783.12 655 1780.5 655H1757.15C1754.8 655 1752.9 653.097 1752.9 650.75C1752.9 648.403 1754.8 646.5 1757.15 646.5H1773.24C1767.99 637.394 1758.1 631.25 1746.75 631.25Z" fill="black"/> +</g> +<g id="Regular-S"> +<path id="Union (Stroke)_24" fill-rule="evenodd" clip-rule="evenodd" d="M1450.75 629C1433.74 629 1420 642.682 1420 659.5C1420 676.318 1433.74 690 1450.75 690C1456.14 690 1461.19 688.63 1465.58 686.226C1467.52 685.165 1469.95 685.877 1471.01 687.815C1472.07 689.753 1471.36 692.183 1469.42 693.244C1463.88 696.277 1457.51 698 1450.75 698C1429.38 698 1412 680.79 1412 659.5C1412 638.21 1429.38 621 1450.75 621C1462.98 621 1473.9 626.633 1481 635.437V625C1481 622.791 1482.79 621 1485 621C1487.21 621 1489 622.791 1489 625V648.25C1489 650.735 1486.99 652.75 1484.5 652.75H1461.15C1458.94 652.75 1457.15 650.959 1457.15 648.75C1457.15 646.541 1458.94 644.75 1461.15 644.75H1477.67C1472.43 635.363 1462.34 629 1450.75 629Z" fill="black"/> +</g> +<g id="Light-S"> +<path id="Union (Stroke)_25" fill-rule="evenodd" clip-rule="evenodd" d="M1151.75 630.5C1134.47 630.5 1120.5 644.403 1120.5 661.5C1120.5 678.597 1134.47 692.5 1151.75 692.5C1157.22 692.5 1162.36 691.108 1166.82 688.665C1168.52 687.737 1170.64 688.359 1171.57 690.055C1172.5 691.751 1171.88 693.877 1170.18 694.805C1164.71 697.799 1158.42 699.5 1151.75 699.5C1130.65 699.5 1113.5 682.511 1113.5 661.5C1113.5 640.489 1130.65 623.5 1151.75 623.5C1164.35 623.5 1175.53 629.552 1182.5 638.897V627C1182.5 625.067 1184.07 623.5 1186 623.5C1187.93 623.5 1189.5 625.067 1189.5 627V650.25C1189.5 652.459 1187.71 654.25 1185.5 654.25H1162.15C1160.22 654.25 1158.65 652.683 1158.65 650.75C1158.65 648.817 1160.22 647.25 1162.15 647.25H1179.51C1174.31 637.304 1163.84 630.5 1151.75 630.5Z" fill="black"/> +</g> +<g id="Thin-S"> +<path id="Union (Stroke)_26" fill-rule="evenodd" clip-rule="evenodd" d="M857.75 629.5C839.922 629.5 825.5 643.844 825.5 661.5C825.5 679.156 839.922 693.5 857.75 693.5C863.394 693.5 868.692 692.064 873.3 689.542C874.511 688.879 876.03 689.324 876.693 690.535C877.356 691.746 876.911 693.265 875.7 693.928C870.373 696.843 864.252 698.5 857.75 698.5C837.194 698.5 820.5 681.952 820.5 661.5C820.5 641.048 837.194 624.5 857.75 624.5C871.174 624.5 882.944 631.554 889.5 642.141V627C889.5 625.619 890.619 624.5 892 624.5C893.381 624.5 894.5 625.619 894.5 627V650.25C894.5 651.907 893.157 653.25 891.5 653.25H868.15C866.769 653.25 865.65 652.131 865.65 650.75C865.65 649.369 866.769 648.25 868.15 648.25H887.115C882.039 637.193 870.803 629.5 857.75 629.5Z" fill="black"/> +</g> +<g id="Ultralight-S"> +<path id="Union (Stroke)_27" fill-rule="evenodd" clip-rule="evenodd" d="M559.75 628.625C541.444 628.625 526.625 643.355 526.625 661.5C526.625 679.645 541.444 694.375 559.75 694.375C565.544 694.375 570.986 692.9 575.72 690.309C576.507 689.879 577.495 690.168 577.926 690.955C578.356 691.742 578.067 692.73 577.28 693.16C572.079 696.007 566.102 697.625 559.75 697.625C539.672 697.625 523.375 681.462 523.375 661.5C523.375 641.538 539.672 625.375 559.75 625.375C574.055 625.375 586.434 633.576 592.375 645.508V627C592.375 626.103 593.103 625.375 594 625.375C594.897 625.375 595.625 626.103 595.625 627V650.25C595.625 651.424 594.674 652.375 593.5 652.375H570.15C569.253 652.375 568.525 651.648 568.525 650.75C568.525 649.853 569.253 649.125 570.15 649.125H590.448C585.524 637.105 573.637 628.625 559.75 628.625Z" fill="black"/> +</g> +</g> +</g> +<defs> +<clipPath id="clip0_907_3757"> +<rect width="3300" height="2200" fill="white"/> +</clipPath> +</defs> </svg>
diff --git a/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h b/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h index 905b3e8..6f71180 100644 --- a/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h +++ b/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h
@@ -68,6 +68,8 @@ @property(class, nonatomic, readonly) UIKeyCommand* cr_showReadingList; @property(class, nonatomic, readonly) UIKeyCommand* cr_goToTabGrid; @property(class, nonatomic, readonly) UIKeyCommand* cr_clearBrowsingData; +@property(class, nonatomic, readonly) UIKeyCommand* cr_closeAll; +@property(class, nonatomic, readonly) UIKeyCommand* cr_undo; // Returns a symbolic description of the key command. For example: ⇧⌘T. @property(nonatomic, readonly) NSString* cr_symbolicDescription;
diff --git a/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.mm b/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.mm index 574b69f..687548c 100644 --- a/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.mm +++ b/ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.mm
@@ -453,6 +453,24 @@ titleIDAsString:@"IDS_IOS_KEYBOARD_CLEAR_BROWSING_DATA"]; } ++ (UIKeyCommand*)cr_closeAll { + return [self cr_commandWithInput:@"w" + modifierFlags:ShiftCommand + action:@selector(keyCommand_closeAll) + titleIDAsString:@"IDS_IOS_KEYBOARD_CLOSE_ALL"]; +} + ++ (UIKeyCommand*)cr_undo { + UIKeyCommand* keyCommand = + [self keyCommandWithInput:@"z" + modifierFlags:Command + action:@selector(keyCommand_undo)]; + if (@available(iOS 15.0, *)) { + keyCommand.wantsPriorityOverSystemBehavior = YES; + } + return keyCommand; +} + #pragma mark - Symbolic Description - (NSString*)cr_symbolicDescription {
diff --git a/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm b/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm index 4de5746..642683a 100644 --- a/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm +++ b/ios/chrome/browser/ui/keyboard/UIKeyCommand+ChromeTest.mm
@@ -130,6 +130,9 @@ IDS_IOS_KEYBOARD_GO_TO_TAB_GRID); Verify(UIKeyCommand.cr_clearBrowsingData, @"⇧⌘⌫", @"keyCommand_clearBrowsingData", IDS_IOS_KEYBOARD_CLEAR_BROWSING_DATA); + Verify(UIKeyCommand.cr_closeAll, @"⇧⌘W", @"keyCommand_closeAll", + IDS_IOS_KEYBOARD_CLOSE_ALL); + Verify(UIKeyCommand.cr_undo, @"⌘Z", @"keyCommand_undo"); // Prior to iOS 15, RTL needs to be handled manually. Check it for key // commands that need to adapt.
diff --git a/ios/chrome/browser/ui/keyboard/key_command_actions.h b/ios/chrome/browser/ui/keyboard/key_command_actions.h index be8eec5..1f23a59 100644 --- a/ios/chrome/browser/ui/keyboard/key_command_actions.h +++ b/ios/chrome/browser/ui/keyboard/key_command_actions.h
@@ -52,6 +52,8 @@ - (void)keyCommand_showReadingList; - (void)keyCommand_goToTabGrid; - (void)keyCommand_clearBrowsingData; +- (void)keyCommand_closeAll; +- (void)keyCommand_undo; @end
diff --git a/ios/chrome/browser/ui/keyboard/menu_builder.mm b/ios/chrome/browser/ui/keyboard/menu_builder.mm index d18fe675..3e6b2d5d 100644 --- a/ios/chrome/browser/ui/keyboard/menu_builder.mm +++ b/ios/chrome/browser/ui/keyboard/menu_builder.mm
@@ -34,6 +34,7 @@ UIKeyCommand.cr_openLocation, UIKeyCommand.cr_closeTab, UIKeyCommand.cr_voiceSearch, + UIKeyCommand.cr_closeAll, ]]; [builder insertChildMenu:fileMenu atStartOfMenuForIdentifier:UIMenuFile];
diff --git a/ios/chrome/browser/ui/omnibox/popup/BUILD.gn b/ios/chrome/browser/ui/omnibox/popup/BUILD.gn index 22b22d3..c33cd6ea 100644 --- a/ios/chrome/browser/ui/omnibox/popup/BUILD.gn +++ b/ios/chrome/browser/ui/omnibox/popup/BUILD.gn
@@ -83,6 +83,7 @@ "//components/open_from_clipboard", "//components/search_engines", "//components/strings:components_strings_grit", + "//components/variations", "//ios/chrome/app/strings", "//ios/chrome/browser/browser_state", "//ios/chrome/browser/default_browser", @@ -157,6 +158,8 @@ "omnibox_popup_row_cell.mm", "omnibox_popup_view_controller.h", "omnibox_popup_view_controller.mm", + "popup_debug_info_view_controller.h", + "popup_debug_info_view_controller.mm", "simple_omnibox_icon.h", "simple_omnibox_icon.mm", ] @@ -176,6 +179,7 @@ "//components/omnibox/common", "//ios/chrome/app/strings", "//ios/chrome/app/theme", + "//ios/chrome/browser/flags:system_flags", "//ios/chrome/browser/net:crurl", "//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui/commands", @@ -235,6 +239,7 @@ "content_providing.h", "omnibox_icon.h", "omnibox_pedal.h", + "popup_debug_info_consumer.h", "popup_match_preview_delegate.h", ] configs += [ "//build/config/compiler:enable_arc" ]
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.mm index 791db7f..c2667b87 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.mm +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.mm
@@ -15,6 +15,7 @@ #import "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h" #import "ios/chrome/browser/favicon/ios_chrome_large_icon_cache_factory.h" #import "ios/chrome/browser/favicon/ios_chrome_large_icon_service_factory.h" +#import "ios/chrome/browser/flags/system_flags.h" #import "ios/chrome/browser/history/top_sites_factory.h" #import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/net/crurl.h" @@ -41,6 +42,7 @@ #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_ios.h" #import "ios/chrome/browser/ui/omnibox/popup/pedal_section_extractor.h" +#import "ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.h" #import "ios/chrome/browser/ui/omnibox/popup/popup_swift.h" #import "ios/chrome/browser/ui/sharing/sharing_coordinator.h" #import "ios/chrome/browser/ui/ui_feature_flags.h" @@ -161,6 +163,10 @@ incognito:isIncognito]; _popupView->SetMediator(self.mediator); + + if (experimental_flags::IsOmniboxDebuggingEnabled()) { + [self setupDebug]; + } } - (void)stop { @@ -210,4 +216,18 @@ [self.sharingCoordinator start]; } +#pragma mark - private + +- (void)setupDebug { + DCHECK(experimental_flags::IsOmniboxDebuggingEnabled()); + + PopupDebugInfoViewController* viewController = + [[PopupDebugInfoViewController alloc] init]; + self.mediator.debugInfoConsumer = viewController; + + UINavigationController* navController = [[UINavigationController alloc] + initWithRootViewController:viewController]; + self.popupViewController.debugInfoViewController = navController; +} + @end
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h index a06c371..4ef821f 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h
@@ -10,11 +10,12 @@ #include <memory> #import "components/history/core/browser/top_sites.h" -#include "components/omnibox/browser/autocomplete_result.h" +#import "components/omnibox/browser/autocomplete_result.h" #import "ios/chrome/browser/ui/omnibox/popup/autocomplete_result_consumer.h" #import "ios/chrome/browser/ui/omnibox/popup/carousel_item_menu_provider.h" #import "ios/chrome/browser/ui/omnibox/popup/favicon_retriever.h" #import "ios/chrome/browser/ui/omnibox/popup/image_retriever.h" +#import "ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h" #import "ui/base/window_open_disposition.h" @protocol BrowserCommands; @@ -85,6 +86,8 @@ @property(nonatomic, weak) id<BrowserCommands> dispatcher; @property(nonatomic, weak) id<AutocompleteResultConsumer> consumer; +// Consumer for debug info. +@property(nonatomic, weak) id<PopupDebugInfoConsumer> debugInfoConsumer; // Scheduler to notify about events happening in this popup. @property(nonatomic, weak) DefaultBrowserPromoNonModalScheduler* promoScheduler; @property(nonatomic, assign, getter=isIncognito) BOOL incognito;
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm index e38fe9a..f75727f 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm
@@ -17,7 +17,10 @@ #import "components/omnibox/browser/autocomplete_result.h" #import "components/omnibox/common/omnibox_features.h" #import "components/strings/grit/components_strings.h" +#import "components/variations/variations_associated_data.h" +#import "components/variations/variations_ids_provider.h" #import "ios/chrome/browser/favicon/favicon_loader.h" +#import "ios/chrome/browser/flags/system_flags.h" #import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/default_promo/default_browser_promo_non_modal_scheduler.h" #import "ios/chrome/browser/ui/menu/browser_action_factory.h" @@ -30,6 +33,7 @@ #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h" #import "ios/chrome/browser/ui/omnibox/popup/pedal_section_extractor.h" #import "ios/chrome/browser/ui/omnibox/popup/pedal_suggestion_wrapper.h" +#import "ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h" #import "ios/chrome/browser/ui/omnibox/popup/popup_swift.h" #import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/common/ui/favicon/favicon_attributes.h" @@ -105,6 +109,16 @@ // get only one grouping. [self requestResultsWithVisibleSuggestionCount:_currentResult.size()]; } + + if (self.debugInfoConsumer) { + DCHECK(experimental_flags::IsOmniboxDebuggingEnabled()); + + [self.debugInfoConsumer + setVariationIDString: + base::SysUTF8ToNSString( + variations::VariationsIdsProvider::GetInstance() + ->GetTriggerVariationsString())]; + } } - (void)updateWithResults:(const AutocompleteResult&)result {
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h index 968c42d8..b31d210a 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h
@@ -48,6 +48,12 @@ @property(nonatomic, assign) LargeIconCache* largeIconCache; @property(nonatomic, weak) id<CarouselItemMenuProvider> carouselMenuProvider; +// View controller that displays debug information. +// Must only be set when OmniboxDebuggingEnabled flag is set. +// When set, this view controller will present `debugInfoViewController` when a +// special debug gesture is executed. +@property(nonatomic, strong) UIViewController* debugInfoViewController; + @property(nonatomic, strong) NSArray<id<AutocompleteSuggestionGroup>>* currentResult;
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.mm index 22e96554..ca3e0979 100644 --- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.mm +++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.mm
@@ -11,6 +11,7 @@ #import "base/time/time.h" #import "components/favicon/core/large_icon_service.h" #import "components/omnibox/common/omnibox_features.h" +#import "ios/chrome/browser/flags/system_flags.h" #import "ios/chrome/browser/net/crurl.h" #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_tile_layout_util.h" #import "ios/chrome/browser/ui/elements/self_sizing_table_view.h" @@ -356,6 +357,18 @@ self.alignment = alignment; } +- (void)setDebugInfoViewController:(UIViewController*)viewController { + DCHECK(experimental_flags::IsOmniboxDebuggingEnabled()); + _debugInfoViewController = viewController; + + UITapGestureRecognizer* debugGestureRecognizer = + [[UITapGestureRecognizer alloc] initWithTarget:self + action:@selector(showDebugUI)]; + debugGestureRecognizer.numberOfTapsRequired = 2; + debugGestureRecognizer.numberOfTouchesRequired = 2; + [self.view addGestureRecognizer:debugGestureRecognizer]; +} + - (void)newResultsAvailable { if (self.shouldUpdateVisibleSuggestionCount) { [self updateVisibleSuggestionCount]; @@ -1077,4 +1090,10 @@ completion:completion]; } +- (void)showDebugUI { + [self presentViewController:self.debugInfoViewController + animated:YES + completion:nil]; +} + @end
diff --git a/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h new file mode 100644 index 0000000..8e1aba4 --- /dev/null +++ b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h
@@ -0,0 +1,18 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_CONSUMER_H_ +#define IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_CONSUMER_H_ + +#import <UIKit/UIKit.h> + +// An abstract consumer of omnibox popup debug info. +@protocol PopupDebugInfoConsumer <NSObject> + +// Gives the consumer a new variation IDs string to display. +- (void)setVariationIDString:(NSString*)string; + +@end + +#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_CONSUMER_H_
diff --git a/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.h b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.h new file mode 100644 index 0000000..3ecaae2 --- /dev/null +++ b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.h
@@ -0,0 +1,24 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_VIEW_CONTROLLER_H_ +#define IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_VIEW_CONTROLLER_H_ + +#import <UIKit/UIKit.h> + +#import "ios/chrome/browser/ui/omnibox/popup/popup_debug_info_consumer.h" + +// View controller used to display omnibox and popup related debug info. +@interface PopupDebugInfoViewController + : UIViewController <PopupDebugInfoConsumer> + +- (instancetype)init NS_DESIGNATED_INITIALIZER; + +- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE; +- (instancetype)initWithNibName:(NSString*)nibNameOrNil + bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE; + +@end + +#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_POPUP_DEBUG_INFO_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.mm b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.mm new file mode 100644 index 0000000..07c1b756a --- /dev/null +++ b/ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.mm
@@ -0,0 +1,55 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/ui/omnibox/popup/popup_debug_info_view_controller.h" +#import "ios/chrome/common/ui/util/constraints_ui_util.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +@interface PopupDebugInfoViewController () + +@property(nonatomic, strong) UITextView* variationIDTextView; + +@end + +@implementation PopupDebugInfoViewController + +- (instancetype)init { + if (self = [super initWithNibName:nil bundle:nil]) { + self.variationIDTextView = [[UITextView alloc] init]; + } + return self; +} + +- (void)viewDidLoad { + [super viewDidLoad]; + + self.variationIDTextView.editable = NO; + self.variationIDTextView.translatesAutoresizingMaskIntoConstraints = NO; + [self.view addSubview:self.variationIDTextView]; + AddSameConstraints(self.view, self.variationIDTextView); + + self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] + initWithBarButtonSystemItem:UIBarButtonSystemItemDone + target:self + action:@selector(doneButtonPressed)]; +} + +#pragma mark - PopupDebugInfoConsumer + +- (void)setVariationIDString:(NSString*)string { + self.variationIDTextView.text = + [NSString stringWithFormat:@"Variation IDs:%@", string]; +} + +#pragma mark - private + +- (void)doneButtonPressed { + [self.presentingViewController dismissViewControllerAnimated:YES + completion:nil]; +} + +@end
diff --git a/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.h b/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.h index 6a0f6b3..1b8f0380 100644 --- a/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.h +++ b/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.h
@@ -17,7 +17,7 @@ extern const char kEnablePinnedTabsTopParam[]; // Positions of the Pinned tabs. -enum PinnedTabsTopPosition { +enum PinnedTabsPosition { kBottomPosition = 0, kTopPosition, }; @@ -26,6 +26,6 @@ bool IsPinnedTabsEnabled(); // Convenience method for determining the position of Pinned Tabs. -PinnedTabsTopPosition GetPinnedTabsPosition(); +PinnedTabsPosition GetPinnedTabsPosition(); #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_PINNED_TABS_FEATURES_H_
diff --git a/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.mm b/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.mm index 32d9e575..df459f4 100644 --- a/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.mm +++ b/ios/chrome/browser/ui/tab_switcher/pinned_tabs/features.mm
@@ -23,11 +23,11 @@ return base::FeatureList::IsEnabled(kEnablePinnedTabs); } -PinnedTabsTopPosition GetPinnedTabsPosition() { +PinnedTabsPosition GetPinnedTabsPosition() { DCHECK(IsPinnedTabsEnabled()); std::string featureParam = base::GetFieldTrialParamValueByFeature( kEnablePinnedTabs, kEnablePinnedTabsParameterName); if (featureParam == kEnablePinnedTabsTopParam) - return PinnedTabsTopPosition::kTopPosition; - return PinnedTabsTopPosition::kBottomPosition; + return PinnedTabsPosition::kTopPosition; + return PinnedTabsPosition::kBottomPosition; }
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/BUILD.gn b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/BUILD.gn index 5aadb99..1e61eb1 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/BUILD.gn +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/BUILD.gn
@@ -47,7 +47,6 @@ ":grid_ui_constants", "resources:grid_cell_close_button", "resources:grid_cell_plus_sign", - "resources:grid_theme_dark_selection_tint_color", "resources:grid_theme_selection_tint_color", "resources:plus_sign_grid_cell_background_color", "//base",
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_cell.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_cell.mm index d328df0..42f4633 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_cell.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_cell.mm
@@ -106,7 +106,11 @@ [self setupSelectedBackgroundView]; UIView* contentView = self.contentView; - contentView.layer.cornerRadius = kGridCellCornerRadius; + if (UseSymbols()) { + contentView.layer.cornerRadius = kGridCellCornerRadius; + } else { + contentView.layer.cornerRadius = kLegacyGridCellCornerRadius; + } contentView.layer.masksToBounds = YES; UIView* topBar = [self setupTopBar]; TopAlignedImageView* snapshotView = [[TopAlignedImageView alloc] init]; @@ -137,7 +141,11 @@ self.titleLabel.textColor = [UIColor colorNamed:kTextPrimaryColor]; self.closeIconView.tintColor = [UIColor colorNamed:kCloseButtonColor]; - self.layer.cornerRadius = kGridCellCornerRadius; + if (UseSymbols()) { + self.layer.cornerRadius = kGridCellCornerRadius; + } else { + self.layer.cornerRadius = kLegacyGridCellCornerRadius; + } self.layer.shadowColor = [UIColor blackColor].CGColor; self.layer.shadowOffset = CGSizeMake(0, 0); self.layer.shadowRadius = 4.0f; @@ -255,12 +263,16 @@ // enough here. switch (theme) { case GridThemeLight: - self.border.layer.borderColor = - [UIColor colorNamed:@"grid_theme_selection_tint_color"].CGColor; + if (UseSymbols()) { + self.border.layer.borderColor = + [UIColor colorNamed:kStaticBlue400Color].CGColor; + } else { + self.border.layer.borderColor = + [UIColor colorNamed:@"grid_theme_selection_tint_color"].CGColor; + } break; case GridThemeDark: - self.border.layer.borderColor = - [UIColor colorNamed:@"grid_theme_dark_selection_tint_color"].CGColor; + self.border.layer.borderColor = UIColor.whiteColor.CGColor; break; } @@ -575,9 +587,15 @@ border.hidden = self.isInSelectionMode; border.translatesAutoresizingMaskIntoConstraints = NO; border.backgroundColor = [UIColor colorNamed:kGridBackgroundColor]; - border.layer.cornerRadius = kGridCellCornerRadius + - kGridCellSelectionRingGapWidth + - kGridCellSelectionRingTintWidth; + if (UseSymbols()) { + border.layer.cornerRadius = kGridCellCornerRadius + + kGridCellSelectionRingGapWidth + + kGridCellSelectionRingTintWidth; + } else { + border.layer.cornerRadius = kLegacyGridCellCornerRadius + + kGridCellSelectionRingGapWidth + + kGridCellSelectionRingTintWidth; + } border.layer.borderWidth = kGridCellSelectionRingTintWidth; [self.selectedBackgroundView addSubview:border]; _border = border;
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h index 088c17c..b23bfca 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h
@@ -92,6 +92,7 @@ extern const CGSize kGridCellSizeMedium; extern const CGSize kGridCellSizeLarge; extern const CGSize kGridCellSizeAccessibility; +extern const CGFloat kLegacyGridCellCornerRadius; extern const CGFloat kGridCellCornerRadius; extern const CGFloat kGridCellIconCornerRadius; // The cell header contains the icon, title, and close button.
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.mm index 20a0629..d45a8e1 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.mm
@@ -83,7 +83,8 @@ const CGSize kGridCellSizeMedium = CGSize{168.0f, 202.0f}; const CGSize kGridCellSizeLarge = CGSize{228.0f, 256.0f}; const CGSize kGridCellSizeAccessibility = CGSize{288.0f, 336.0f}; -const CGFloat kGridCellCornerRadius = 13.0f; +const CGFloat kLegacyGridCellCornerRadius = 13.0f; +const CGFloat kGridCellCornerRadius = 16.0f; const CGFloat kGridCellIconCornerRadius = 3.0f; // The cell header contains the icon, title, and close button. const CGFloat kGridCellHeaderHeight = 32.0f;
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.mm index e0c88fc..0bef9e5 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.mm
@@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/plus_sign_cell.h" +#import "ios/chrome/browser/ui/icons/symbols.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h" #import "ios/chrome/common/ui/colors/semantic_color_names.h" #import "ios/chrome/common/ui/util/constraints_ui_util.h" @@ -25,7 +26,11 @@ - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { - self.layer.cornerRadius = kGridCellCornerRadius; + if (UseSymbols()) { + self.layer.cornerRadius = kGridCellCornerRadius; + } else { + self.layer.cornerRadius = kLegacyGridCellCornerRadius; + } self.layer.masksToBounds = YES; UIImageView* plusSignView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"grid_cell_plus_sign"]];
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/BUILD.gn b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/BUILD.gn index 7d493d1..0e5e2e0 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/BUILD.gn +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/BUILD.gn
@@ -24,10 +24,6 @@ sources = [ "grid_theme_selection_tint_color.colorset/Contents.json" ] } -colorset("grid_theme_dark_selection_tint_color") { - sources = [ "grid_theme_dark_selection_tint_color.colorset/Contents.json" ] -} - colorset("plus_sign_grid_cell_background_color") { sources = [ "plus_sign_grid_cell_background_color.colorset/Contents.json" ] }
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/grid_theme_dark_selection_tint_color.colorset/Contents.json b/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/grid_theme_dark_selection_tint_color.colorset/Contents.json deleted file mode 100644 index bd4986a..0000000 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/grid/resources/grid_theme_dark_selection_tint_color.colorset/Contents.json +++ /dev/null
@@ -1,20 +0,0 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - }, - "colors" : [ - { - "idiom" : "universal", - "color" : { - "color-space" : "display-p3", - "components" : { - "alpha" : "1.000", - "red" : "0xFF", - "green" : "0xFF", - "blue" : "0xFF" - } - } - } - ] -}
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/BUILD.gn b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/BUILD.gn index aa46a344..26a3cd7 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/BUILD.gn +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/BUILD.gn
@@ -19,6 +19,7 @@ "resources", "//base", "//ios/chrome/app/strings", + "//ios/chrome/browser/ui/icons:symbols", "//ios/chrome/browser/ui/tab_switcher/tab_grid/grid:grid_ui_constants", "//ios/chrome/browser/ui/table_view", "//ios/chrome/browser/ui/table_view:styler",
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_grid_cell.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_grid_cell.mm index 4a8d270..b4a3ee4 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_grid_cell.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_grid_cell.mm
@@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_grid_cell.h" +#import "ios/chrome/browser/ui/icons/symbols.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h" #import "ios/chrome/common/ui/util/constraints_ui_util.h" @@ -16,7 +17,11 @@ - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { - self.layer.cornerRadius = kGridCellCornerRadius; + if (UseSymbols()) { + self.layer.cornerRadius = kGridCellCornerRadius; + } else { + self.layer.cornerRadius = kLegacyGridCellCornerRadius; + } self.layer.masksToBounds = YES; self.overrideUserInterfaceStyle = UIUserInterfaceStyleDark; self.backgroundView = [[UIView alloc] init];
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_view_controller.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_view_controller.mm index bd5be46d..e9c694c 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_view_controller.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_view_controller.mm
@@ -8,6 +8,7 @@ #import "base/check_op.h" #import "base/mac/foundation_util.h" +#import "ios/chrome/browser/ui/icons/symbols.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/grid/grid_constants.h" #import "ios/chrome/browser/ui/tab_switcher/tab_grid/suggested_actions/suggested_actions_delegate.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_image_item.h" @@ -85,7 +86,11 @@ [self.tableView setTableHeaderView:[[UIView alloc] initWithFrame:frame]]; [self.tableView setTableFooterView:[[UIView alloc] initWithFrame:frame]]; - self.tableView.layer.cornerRadius = kGridCellCornerRadius; + if (UseSymbols()) { + self.tableView.layer.cornerRadius = kGridCellCornerRadius; + } else { + self.tableView.layer.cornerRadius = kLegacyGridCellCornerRadius; + } [self loadModel]; [self.tableView reloadData]; [self.tableView layoutIfNeeded];
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_page_control.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_page_control.mm index 8274763..9d39b80 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_page_control.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_page_control.mm
@@ -283,6 +283,12 @@ _incognitoAccessibilityElement, _regularAccessibilityElement, _remoteAccessibilityElement ]; + + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(accessibilityBoldTextStatusDidChange) + name:UIAccessibilityBoldTextStatusDidChangeNotification + object:nil]; } return self; } @@ -794,6 +800,22 @@ self.tapRecognizer = tapRecognizer; } +// Returns the font to be used for the Tab Number label, in the `selected` state +// or not. +- (UIFont*)fontForLabelSelected:(BOOL)selected { + CGFloat size = selected ? kSelectedLabelSize : kLabelSize; + if (!UseSymbols()) + return [UIFont systemFontOfSize:size * .6 weight:UIFontWeightBold]; + + UIFontWeight weight = + UIAccessibilityIsBoldTextEnabled() ? UIFontWeightHeavy : UIFontWeightBold; + CGFloat fontSize = size * .6; + UIFont* font = [UIFont systemFontOfSize:fontSize weight:weight]; + UIFontDescriptor* descriptor = [font.fontDescriptor + fontDescriptorWithDesign:UIFontDescriptorSystemDesignRounded]; + return font = [UIFont fontWithDescriptor:descriptor size:fontSize]; +} + // Creates a label for use in this control. // Selected labels use a different size and are black. - (UILabel*)labelSelected:(BOOL)selected { @@ -810,15 +832,7 @@ label.backgroundColor = UIColor.clearColor; label.textAlignment = NSTextAlignmentCenter; label.textColor = color; - if (UseSymbols()) { - CGFloat fontSize = size * .6; - UIFont* font = [UIFont systemFontOfSize:fontSize weight:UIFontWeightBold]; - UIFontDescriptor* descriptor = [font.fontDescriptor - fontDescriptorWithDesign:UIFontDescriptorSystemDesignRounded]; - label.font = [UIFont fontWithDescriptor:descriptor size:fontSize]; - } else { - label.font = [UIFont systemFontOfSize:size * .6 weight:UIFontWeightBold]; - } + label.font = [self fontForLabelSelected:selected]; return label; } @@ -870,6 +884,12 @@ return separator; } +// Callback for the notification that the user changed the bold status. +- (void)accessibilityBoldTextStatusDidChange { + self.regularLabel.font = [self fontForLabelSelected:NO]; + self.regularSelectedLabel.font = [self fontForLabelSelected:YES]; +} + #pragma mark UIPointerInteractionDelegate - (UIPointerRegion*)pointerInteraction:(UIPointerInteraction*)interaction
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h index 27c7627..284028b 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.h
@@ -189,6 +189,9 @@ // Animation is used if `animated` is YES. - (void)setCurrentPageAndPageControl:(TabGridPage)page animated:(BOOL)animated; +// YES if it is possible to undo the close all conditions. +@property(nonatomic, assign) BOOL undoCloseAllAvailable; + @end #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_GRID_TAB_GRID_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm index 3d1e9b8..5c6b62a4 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller.mm
@@ -163,7 +163,6 @@ @property(nonatomic, strong) UIControl* scrimView; @property(nonatomic, weak) TabGridTopToolbar* topToolbar; @property(nonatomic, weak) TabGridBottomToolbar* bottomToolbar; -@property(nonatomic, assign) BOOL undoCloseAllAvailable; // Bool informing if the confirmation action sheet is displayed. @property(nonatomic, assign) BOOL closeAllConfirmationDisplayed; @property(nonatomic, assign) TabGridConfiguration configuration; @@ -1499,14 +1498,14 @@ constant:-kPinnedViewHorizontalPadding], ]]; switch (GetPinnedTabsPosition()) { - case PinnedTabsTopPosition::kBottomPosition: + case PinnedTabsPosition::kBottomPosition: [pinnedTabsConstraints addObject:[pinnedTabsViewController.view.bottomAnchor constraintEqualToAnchor:self.bottomToolbar.topAnchor constant:-kPinnedViewBottomPadding]]; break; - case PinnedTabsTopPosition::kTopPosition: + case PinnedTabsPosition::kTopPosition: [pinnedTabsConstraints addObject:[pinnedTabsViewController.view.topAnchor constraintEqualToAnchor:self.topToolbar.bottomAnchor @@ -2617,6 +2616,29 @@ } } +#pragma mark - UIResponder Helper + +// Returns YES if "close all" can be performed. Conditions are: +// * Tab grid is currently displayed, +// * There are tabs to close in the current page, +// * Not in an undo scenario. +- (BOOL)canCloseAllTab { + return self.currentState == ViewRevealState::Revealed && + ((self.currentPage == TabGridPageIncognitoTabs && + !self.incognitoTabsViewController.gridEmpty) || + (self.currentPage == TabGridPageRegularTabs && + !self.regularTabsViewController.gridEmpty && + !self.undoCloseAllAvailable)); +} + +// Returns YES if "undo" the close all action can be performed. +- (BOOL)canUndoCloseAllTab { + return /* Ensure the tab grid is currently displayed. */ self.currentState == + ViewRevealState::Revealed && + self.currentPage == TabGridPageRegularTabs && + self.undoCloseAllAvailable; +} + #pragma mark - UIResponder // To always be able to register key commands via -keyCommands, the VC must be @@ -2630,6 +2652,7 @@ // Other key commands are already declared in the menu. return @[ UIKeyCommand.cr_openNewRegularTab, + UIKeyCommand.cr_undo, // TODO(crbug.com/1385469): Move it to the menu builder once we have the // strings. UIKeyCommand.cr_select2, @@ -2653,6 +2676,12 @@ if (sel_isEqual(action, @selector(keyCommand_find))) { return self.currentState == ViewRevealState::Revealed; } + if (sel_isEqual(action, @selector(keyCommand_closeAll))) { + return [self canCloseAllTab]; + } + if (sel_isEqual(action, @selector(keyCommand_undo))) { + return [self canUndoCloseAllTab]; + } return [super canPerformAction:action withSender:sender]; } @@ -2706,4 +2735,15 @@ [self setCurrentPageAndPageControl:TabGridPageRemoteTabs animated:YES]; } +- (void)keyCommand_closeAll { + base::RecordAction(base::UserMetricsAction("MobileKeyCommandCloseAll")); + [self closeAllButtonTapped:nil]; +} + +- (void)keyCommand_undo { + base::RecordAction(base::UserMetricsAction("MobileKeyCommandUndo")); + // This function is also responsible for handling undo. + [self closeAllButtonTapped:nil]; +} + @end
diff --git a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller_unittest.mm b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller_unittest.mm index 3f7277d..3bfcc46 100644 --- a/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller_unittest.mm +++ b/ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_view_controller_unittest.mm
@@ -10,19 +10,44 @@ #import "base/test/metrics/user_action_tester.h" #import "base/test/scoped_feature_list.h" +#import "ios/chrome/browser/browser_state/test_chrome_browser_state.h" +#import "ios/chrome/browser/main/test_browser.h" +#import "ios/chrome/browser/snapshots/snapshot_browser_agent.h" +#import "ios/chrome/browser/snapshots/snapshot_tab_helper.h" #import "ios/chrome/browser/ui/gestures/view_revealing_vertical_pan_handler.h" #import "ios/chrome/browser/ui/keyboard/features.h" +#import "ios/chrome/browser/ui/tab_switcher/tab_grid/tab_grid_mediator.h" +#import "ios/chrome/browser/web_state_list/fake_web_state_list_delegate.h" #import "ios/chrome/grit/ios_strings.h" +#import "ios/web/public/test/web_task_environment.h" #import "testing/platform_test.h" #import "ui/base/l10n/l10n_util.h" namespace { +// Fake WebStateList delegate that attaches the required tab helper. +class TabGridFakeWebStateListDelegate : public FakeWebStateListDelegate { + public: + TabGridFakeWebStateListDelegate() {} + ~TabGridFakeWebStateListDelegate() override {} + + // WebStateListDelegate implementation. + void WillAddWebState(web::WebState* web_state) override { + SnapshotTabHelper::CreateForWebState(web_state); + } +}; + class TabGridViewControllerTest : public PlatformTest { protected: TabGridViewControllerTest() { view_controller_ = [[TabGridViewController alloc] initWithPageConfiguration:TabGridPageConfiguration::kAllPagesEnabled]; + + browser_state_ = TestChromeBrowserState::Builder().Build(); + browser_ = std::make_unique<TestBrowser>( + browser_state_.get(), + std::make_unique<TabGridFakeWebStateListDelegate>()); + SnapshotBrowserAgent::CreateForBrowser(browser_.get()); } ~TabGridViewControllerTest() override {} @@ -46,8 +71,11 @@ EXPECT_EQ(user_action_tester_.GetActionCount(user_action), 1); } + web::WebTaskEnvironment task_environment_; base::UserActionTester user_action_tester_; TabGridViewController* view_controller_; + std::unique_ptr<TestChromeBrowserState> browser_state_; + std::unique_ptr<TestBrowser> browser_; }; // Checks that TabGridViewController returns key commands when the Keyboard @@ -113,6 +141,8 @@ [view_controller_ keyCommand_openNewRegularTab]; [view_controller_ keyCommand_openNewIncognitoTab]; [view_controller_ keyCommand_find]; + [view_controller_ keyCommand_closeAll]; + [view_controller_ keyCommand_undo]; } // Checks that metrics are correctly reported. @@ -125,6 +155,8 @@ ExpectUMA(@"keyCommand_openNewIncognitoTab", "MobileKeyCommandOpenNewIncognitoTab"); ExpectUMA(@"keyCommand_find", "MobileKeyCommandSearchTabs"); + ExpectUMA(@"keyCommand_closeAll", "MobileKeyCommandCloseAll"); + ExpectUMA(@"keyCommand_undo", "MobileKeyCommandUndo"); } // This test ensure 2 things: @@ -164,4 +196,64 @@ } } +TEST_F(TabGridViewControllerTest, CanPerform_CloseAllAndUndo) { + // Load the view. + [view_controller_.view self]; + EXPECT_FALSE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + // Create a view revealing vertical pan handler. + ViewRevealingVerticalPanHandler* pan_handler = + [[ViewRevealingVerticalPanHandler alloc] + initWithPeekedHeight:212.0f + baseViewHeight:800.0f + initialState:ViewRevealState::Peeked]; + + [pan_handler addAnimatee:view_controller_]; + + [pan_handler setNextState:ViewRevealState::Revealed + animated:NO + trigger:ViewRevealTrigger::Unknown]; + + [view_controller_ setCurrentPageAndPageControl:TabGridPageIncognitoTabs + animated:NO]; + EXPECT_FALSE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + TabGridMediator* incognitoMediator = [[TabGridMediator alloc] + initWithConsumer:view_controller_.incognitoTabsConsumer]; + [incognitoMediator setBrowser:browser_.get()]; + view_controller_.incognitoTabsDelegate = incognitoMediator; + [view_controller_.incognitoTabsDelegate addNewItem]; + EXPECT_TRUE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + [view_controller_.incognitoTabsDelegate closeAllItems]; + EXPECT_FALSE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + + [view_controller_ setCurrentPageAndPageControl:TabGridPageRegularTabs + animated:NO]; + EXPECT_FALSE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + TabGridMediator* regularMediator = [[TabGridMediator alloc] + initWithConsumer:view_controller_.regularTabsConsumer]; + [regularMediator setBrowser:browser_.get()]; + view_controller_.regularTabsDelegate = regularMediator; + [view_controller_.regularTabsDelegate addNewItem]; + EXPECT_TRUE(CanPerform(@"keyCommand_closeAll")); + EXPECT_FALSE(CanPerform(@"keyCommand_undo")); + [view_controller_.incognitoTabsDelegate closeAllItems]; + EXPECT_FALSE(CanPerform(@"keyCommand_closeAll")); + + // closeAllItems from the mediator do not change the value of the boolean, set + // it manually. + view_controller_.undoCloseAllAvailable = YES; + EXPECT_TRUE(CanPerform(@"keyCommand_undo")); + + // Forces the TabGridMediator to removes its Observer from WebStateList + // before the Browser is destroyed. + incognitoMediator.browser = nullptr; + incognitoMediator = nil; + + regularMediator.browser = nullptr; + regularMediator = nil; +} } // namespace
diff --git a/ios/chrome/browser/ui/table_view/cells/BUILD.gn b/ios/chrome/browser/ui/table_view/cells/BUILD.gn index ecfc7fb..dfaa47e 100644 --- a/ios/chrome/browser/ui/table_view/cells/BUILD.gn +++ b/ios/chrome/browser/ui/table_view/cells/BUILD.gn
@@ -119,3 +119,12 @@ configs += [ "//build/config/compiler:enable_arc" ] } + +source_set("features") { + configs += [ "//build/config/compiler:enable_arc" ] + sources = [ + "features.h", + "features.mm", + ] + public_deps = [ "//base" ] +}
diff --git a/ios/chrome/browser/ui/table_view/cells/features.h b/ios/chrome/browser/ui/table_view/cells/features.h new file mode 100644 index 0000000..535483382 --- /dev/null +++ b/ios/chrome/browser/ui/table_view/cells/features.h
@@ -0,0 +1,16 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_FEATURES_H_ +#define IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_FEATURES_H_ + +#include "base/feature_list.h" + +// Feature flag enabling the wrapping of table view cell title. +BASE_DECLARE_FEATURE(kTruncateTableViewCellTitle); + +// Returns true if Truncate Table View Cell Title feature is enabled. +bool IsTruncateTableViewCellTitleEnabled(); + +#endif // IOS_CHROME_BROWSER_UI_TABLE_VIEW_CELLS_FEATURES_H_
diff --git a/ios/chrome/browser/ui/table_view/cells/features.mm b/ios/chrome/browser/ui/table_view/cells/features.mm new file mode 100644 index 0000000..5f336bb --- /dev/null +++ b/ios/chrome/browser/ui/table_view/cells/features.mm
@@ -0,0 +1,19 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import "ios/chrome/browser/ui/table_view/cells/features.h" + +#import "base/feature_list.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +BASE_FEATURE(kTruncateTableViewCellTitle, + "TruncateTableViewCelltitle", + base::FEATURE_DISABLED_BY_DEFAULT); + +bool IsTruncateTableViewCellTitleEnabled() { + return base::FeatureList::IsEnabled(kTruncateTableViewCellTitle); +}
diff --git a/ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.mm b/ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.mm index e1917ff6..67d55fc 100644 --- a/ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.mm +++ b/ios/chrome/browser/ui/toolbar/buttons/toolbar_tab_grid_button.mm
@@ -52,6 +52,12 @@ - (UILabel*)tabCountLabel { if (!_tabCountLabel) { + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(accessibilityBoldTextStatusDidChange) + name:UIAccessibilityBoldTextStatusDidChangeNotification + object:nil]; + _tabCountLabel = [[UILabel alloc] init]; [self addSubview:_tabCountLabel]; @@ -62,8 +68,7 @@ ]]; AddSameCenterConstraints(self, _tabCountLabel); - _tabCountLabel.font = [UIFont systemFontOfSize:kTabGridButtonFontSize - weight:UIFontWeightBold]; + _tabCountLabel.font = [self labelFont]; _tabCountLabel.adjustsFontSizeToFitWidth = YES; _tabCountLabel.minimumScaleFactor = 0.1; _tabCountLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; @@ -73,4 +78,18 @@ return _tabCountLabel; } +#pragma mark - Private + +// Returns the font for the label. +- (UIFont*)labelFont { + UIFontWeight weight = + UIAccessibilityIsBoldTextEnabled() ? UIFontWeightHeavy : UIFontWeightBold; + return [UIFont systemFontOfSize:kTabGridButtonFontSize weight:weight]; +} + +// Callback for the notification that the user changed the bold status. +- (void)accessibilityBoldTextStatusDidChange { + self.tabCountLabel.font = [self labelFont]; +} + @end
diff --git a/ios/web/js_messaging/web_view_js_utils_unittest.mm b/ios/web/js_messaging/web_view_js_utils_unittest.mm index df59759..1e9ac3a34 100644 --- a/ios/web/js_messaging/web_view_js_utils_unittest.mm +++ b/ios/web/js_messaging/web_view_js_utils_unittest.mm
@@ -84,19 +84,16 @@ std::unique_ptr<base::Value> value( web::ValueResultFromWKResult(test_dictionary)); - base::DictionaryValue* dictionary = nullptr; - value->GetAsDictionary(&dictionary); + base::Value::Dict* dictionary = value->GetIfDict(); EXPECT_NE(nullptr, dictionary); - std::string value1; - dictionary->GetString("Key1", &value1); - EXPECT_EQ("Value1", value1); + std::string* value1 = dictionary->FindString("Key1"); + EXPECT_EQ("Value1", *value1); - base::DictionaryValue const* inner_dictionary = nullptr; - dictionary->GetDictionary("Key2", &inner_dictionary); + base::Value::Dict const* inner_dictionary = dictionary->FindDict("Key2"); EXPECT_NE(nullptr, inner_dictionary); - EXPECT_EQ(42, *inner_dictionary->FindDoubleKey("Key3")); + EXPECT_EQ(42, *inner_dictionary->FindDouble("Key3")); } // Tests that ValueResultFromWKResult converts NSArray to properly @@ -144,17 +141,15 @@ // `kMaximumParsingRecursionDepth`. std::unique_ptr<base::Value> value = web::ValueResultFromWKResult(test_dictionary); - base::DictionaryValue* current_dictionary = nullptr; - base::DictionaryValue* inner_dictionary = nullptr; + base::Value::Dict* current_dictionary = value->GetIfDict(); + base::Value::Dict* inner_dictionary = nullptr; - value->GetAsDictionary(¤t_dictionary); EXPECT_NE(nullptr, current_dictionary); for (int current_depth = 0; current_depth <= kMaximumParsingRecursionDepth; current_depth++) { EXPECT_NE(nullptr, current_dictionary); - inner_dictionary = nullptr; - current_dictionary->GetDictionary(key, &inner_dictionary); + inner_dictionary = current_dictionary->FindDict(key); current_dictionary = inner_dictionary; } EXPECT_EQ(nullptr, current_dictionary);
diff --git a/ios/web/public/test/web_view_interaction_test_util.mm b/ios/web/public/test/web_view_interaction_test_util.mm index 27e4ebdc..ae8f6b1 100644 --- a/ios/web/public/test/web_view_interaction_test_util.mm +++ b/ios/web/public/test/web_view_interaction_test_util.mm
@@ -197,19 +197,16 @@ " };" "})();"; - __block std::unique_ptr<base::DictionaryValue> rect; + __block std::unique_ptr<base::Value::Dict> rect; bool found = WaitUntilConditionOrTimeout(kWaitForUIElementTimeout, ^{ std::unique_ptr<base::Value> value = ExecuteJavaScript(web_state, kGetBoundsScript); - base::DictionaryValue* dictionary = nullptr; - if (value && value->GetAsDictionary(&dictionary)) { - std::string error; - if (dictionary->GetString("error", &error)) { + if (base::Value::Dict* dictionary = value->GetIfDict()) { + if (const std::string* error = dictionary->FindString("error")) { DLOG(ERROR) << "Error getting rect: " << error << ", retrying.."; } else { - rect = base::DictionaryValue::From( - base::Value::ToUniquePtrValue(dictionary->Clone())); + rect = std::make_unique<base::Value::Dict>(dictionary->Clone()); return true; } } @@ -219,10 +216,10 @@ if (!found) return CGRectNull; - absl::optional<double> left = rect->FindDoubleKey("left"); - absl::optional<double> top = rect->FindDoubleKey("top"); - absl::optional<double> width = rect->FindDoubleKey("width"); - absl::optional<double> height = rect->FindDoubleKey("height"); + absl::optional<double> left = rect->FindDouble("left"); + absl::optional<double> top = rect->FindDouble("top"); + absl::optional<double> width = rect->FindDouble("width"); + absl::optional<double> height = rect->FindDouble("height"); if (!(left && top && width && height)) return CGRectNull;
diff --git a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc index 9b63ffac..17bf3ff 100644 --- a/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc +++ b/services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.cc
@@ -288,8 +288,7 @@ // True if the module of the stack frame will be considered valid by the trace // processor. bool has_valid_module() const { - return !module_name.empty() && !module_id.empty() && - module_base_address > 0; + return !module_name.empty() && module_base_address > 0; } bool has_valid_frame() const { @@ -317,9 +316,7 @@ if (module_base_address == 0) { module_base_address = 1; } - if (module_id.empty()) { - module_id = "missing"; - } + // TODO(crbug/1393372): Investigate and maybe cleanup this logic. if (module_name.empty()) { module_name = "missing"; } @@ -362,12 +359,6 @@ } module_base_address = reinterpret_cast<uintptr_t>(info.dli_fbase); rel_pc = frame_ip - module_base_address; - // We have already symbolized these frames, so module ID is not necessary. - // Reading the real ID can cause crashes and we can't symbolize these - // server-side anyways. - // TODO(ssid): Remove this once perfetto can keep the frames without module - // ID. - module_id = "system"; DCHECK(has_valid_frame()); DCHECK(has_valid_module()); @@ -636,8 +627,10 @@ frame_details.FillWithDummyFields(frame.instruction_pointer); } - frame_details.module_id = - base::TransformModuleIDToBreakpadFormat(frame_details.module_id); + if (!frame_details.module_id.empty()) { + frame_details.module_id = + base::TransformModuleIDToBreakpadFormat(frame_details.module_id); + } // Allow uploading function names passed from unwinder, which would be // coming from static compile time strings.
diff --git a/testing/buildbot/chromium.chromiumos.json b/testing/buildbot/chromium.chromiumos.json index ba467a4..d1dba70 100644 --- a/testing/buildbot/chromium.chromiumos.json +++ b/testing/buildbot/chromium.chromiumos.json
@@ -5715,73 +5715,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -5793,8 +5729,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -5812,9 +5748,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -5826,8 +5762,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -5843,6 +5779,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "isolate_profile_data": true, "merge": { "args": [], @@ -5885,71 +5887,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -5961,8 +5901,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -5979,9 +5919,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -5993,8 +5933,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -6010,6 +5950,70 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], "isolate_profile_data": true, @@ -6034,73 +6038,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -6112,8 +6052,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -6131,9 +6071,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -6145,8 +6085,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -6162,6 +6102,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "isolate_profile_data": true, "merge": { "args": [],
diff --git a/testing/buildbot/chromium.fyi.json b/testing/buildbot/chromium.fyi.json index 886d108..5189fca6 100644 --- a/testing/buildbot/chromium.fyi.json +++ b/testing/buildbot/chromium.fyi.json
@@ -85317,63 +85317,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -85385,8 +85331,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", @@ -85399,9 +85345,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -85413,8 +85359,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", @@ -85425,6 +85371,62 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "isolate_profile_data": true, "merge": { "args": [], @@ -85457,61 +85459,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -85523,8 +85473,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" @@ -85536,9 +85486,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -85550,8 +85500,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" @@ -85562,6 +85512,60 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], "isolate_profile_data": true, @@ -85581,63 +85585,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -85649,8 +85599,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", @@ -85663,9 +85613,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -85677,8 +85627,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", @@ -85689,6 +85639,62 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "isolate_profile_data": true, "merge": { "args": [], @@ -86922,73 +86928,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -86999,8 +86941,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -87019,9 +86961,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87032,8 +86974,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -87050,6 +86992,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87092,71 +87100,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87167,8 +87113,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -87186,9 +87132,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87199,8 +87145,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -87217,6 +87163,70 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], "merge": { @@ -87241,73 +87251,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87318,8 +87264,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -87338,9 +87284,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -87351,8 +87297,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -87369,6 +87315,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -88777,73 +88789,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -88854,8 +88802,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -88874,9 +88822,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -88887,8 +88835,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -88905,6 +88853,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -88947,71 +88961,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89022,8 +88974,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -89041,9 +88993,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89054,8 +89006,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -89072,6 +89024,70 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter" ], "merge": { @@ -89096,73 +89112,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04", - "ssd": "0" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89173,8 +89125,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -89193,9 +89145,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89206,8 +89158,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -89224,6 +89176,72 @@ "variant_id": "Lacros version skew testing ash canary" }, { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04", + "ssd": "0" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash stable" + }, + { "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89881,71 +89899,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome" ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome" - ], - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89956,8 +89912,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -89975,9 +89931,9 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome" + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "merge": { "args": [], "script": "//testing/merge_scripts/standard_gtest_merge.py" @@ -89988,8 +89944,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -90003,6 +89959,70 @@ "test": "interactive_ui_tests", "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", "variant_id": "Lacros version skew testing ash canary" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" } ] },
diff --git a/testing/buildbot/chromium.memory.json b/testing/buildbot/chromium.memory.json index 0bac7356..3d62758d 100644 --- a/testing/buildbot/chromium.memory.json +++ b/testing/buildbot/chromium.memory.json
@@ -18579,79 +18579,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "interactive_ui_tests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 3 - }, - "test": "interactive_ui_tests", - "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -18663,8 +18595,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -18682,11 +18614,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -18698,8 +18630,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -18716,6 +18648,76 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.filter;../../testing/buildbot/filters/linux-lacros.interactive_ui_tests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "interactive_ui_tests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 3 + }, + "test": "interactive_ui_tests", + "test_id_prefix": "ninja://chrome/test:interactive_ui_tests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], @@ -18763,77 +18765,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" - }, - "test": "lacros_chrome_browsertests", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -18845,8 +18781,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -18863,11 +18799,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -18879,8 +18815,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -18896,6 +18832,74 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com" + }, + "test": "lacros_chrome_browsertests", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.filter", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" @@ -18922,79 +18926,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 104.0.5112.110", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v104.0.5112.110", - "revision": "version:104.0.5112.110" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 104.0.5112.110" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "isolate_profile_data": true, - "merge": { - "args": [], - "script": "//testing/merge_scripts/standard_gtest_merge.py" - }, - "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash 106.0.5249.12", - "swarming": { - "can_use_on_swarming_builders": true, - "cipd_packages": [ - { - "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v106.0.5249.12", - "revision": "version:106.0.5249.12" - } - ], - "dimension_sets": [ - { - "os": "Ubuntu-18.04" - } - ], - "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", - "shards": 2 - }, - "test": "lacros_chrome_browsertests_run_in_series", - "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", - "variant_id": "Lacros version skew testing ash 106.0.5249.12" - }, - { - "args": [ - "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome", - "--test-launcher-print-test-stdio=always", - "--combine-ash-logs-on-bots" - ], - "description": "Run with ash-chrome version 108.0.5359.45", + "description": "Run with ash-chrome version 108.0.5359.58", "isolate_profile_data": true, "merge": { "args": [], @@ -19006,8 +18942,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v108.0.5359.45", - "revision": "version:108.0.5359.45" + "location": "lacros_version_skew_tests_v108.0.5359.58", + "revision": "version:108.0.5359.58" } ], "dimension_sets": [ @@ -19025,11 +18961,11 @@ { "args": [ "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", - "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome", "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ], - "description": "Run with ash-chrome version 110.0.5437.0", + "description": "Run with ash-chrome version 110.0.5439.0", "isolate_profile_data": true, "merge": { "args": [], @@ -19041,8 +18977,8 @@ "cipd_packages": [ { "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", - "location": "lacros_version_skew_tests_v110.0.5437.0", - "revision": "version:110.0.5437.0" + "location": "lacros_version_skew_tests_v110.0.5439.0", + "revision": "version:110.0.5439.0" } ], "dimension_sets": [ @@ -19059,6 +18995,76 @@ }, { "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 109.0.5414.7", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash dev", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v109.0.5414.7", + "revision": "version:109.0.5414.7" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash dev" + }, + { + "args": [ + "--test-launcher-filter-file=../../testing/buildbot/filters/linux-lacros.lacros_chrome_browsertests.skew.filter", + "--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome", + "--test-launcher-print-test-stdio=always", + "--combine-ash-logs-on-bots" + ], + "description": "Run with ash-chrome version 107.0.5304.110", + "isolate_profile_data": true, + "merge": { + "args": [], + "script": "//testing/merge_scripts/standard_gtest_merge.py" + }, + "name": "lacros_chrome_browsertests_run_in_series Lacros version skew testing ash stable", + "swarming": { + "can_use_on_swarming_builders": true, + "cipd_packages": [ + { + "cipd_package": "chromium/testing/linux-ash-chromium/x86_64/ash.zip", + "location": "lacros_version_skew_tests_v107.0.5304.110", + "revision": "version:107.0.5304.110" + } + ], + "dimension_sets": [ + { + "os": "Ubuntu-18.04" + } + ], + "service_account": "chromium-tester@chops-service-accounts.iam.gserviceaccount.com", + "shards": 2 + }, + "test": "lacros_chrome_browsertests_run_in_series", + "test_id_prefix": "ninja://chrome/test:lacros_chrome_browsertests_run_in_series/", + "variant_id": "Lacros version skew testing ash stable" + }, + { + "args": [ "--test-launcher-print-test-stdio=always", "--combine-ash-logs-on-bots" ],
diff --git a/testing/buildbot/variants.pyl b/testing/buildbot/variants.pyl index 6b2a1cc4..244a1a5c9 100644 --- a/testing/buildbot/variants.pyl +++ b/testing/buildbot/variants.pyl
@@ -22,62 +22,64 @@ }, 'LACROS_VERSION_SKEW_CANARY': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5437.0/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v110.0.5439.0/test_ash_chrome', ], - 'description': 'Run with ash-chrome version 110.0.5437.0', + 'description': 'Run with ash-chrome version 110.0.5439.0', 'identifier': 'Lacros version skew testing ash canary', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v110.0.5437.0', - 'revision': 'version:110.0.5437.0', + 'location': 'lacros_version_skew_tests_v110.0.5439.0', + 'revision': 'version:110.0.5439.0', }, ], }, }, 'LACROS_VERSION_SKEW_DEV': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v106.0.5249.12/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v109.0.5414.7/test_ash_chrome', ], - 'identifier': 'Lacros version skew testing ash 106.0.5249.12', + 'description': 'Run with ash-chrome version 109.0.5414.7', + 'identifier': 'Lacros version skew testing ash dev', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v106.0.5249.12', - 'revision': 'version:106.0.5249.12', + 'location': 'lacros_version_skew_tests_v109.0.5414.7', + 'revision': 'version:109.0.5414.7', }, ], }, }, 'LACROS_VERSION_SKEW_BETA': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.45/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v108.0.5359.58/test_ash_chrome', ], - 'description': 'Run with ash-chrome version 108.0.5359.45', + 'description': 'Run with ash-chrome version 108.0.5359.58', 'identifier': 'Lacros version skew testing ash beta', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v108.0.5359.45', - 'revision': 'version:108.0.5359.45', + 'location': 'lacros_version_skew_tests_v108.0.5359.58', + 'revision': 'version:108.0.5359.58', }, ], }, }, 'LACROS_VERSION_SKEW_STABLE': { 'args': [ - '--ash-chrome-path-override=../../lacros_version_skew_tests_v104.0.5112.110/test_ash_chrome', + '--ash-chrome-path-override=../../lacros_version_skew_tests_v107.0.5304.110/test_ash_chrome', ], - 'identifier': 'Lacros version skew testing ash 104.0.5112.110', + 'description': 'Run with ash-chrome version 107.0.5304.110', + 'identifier': 'Lacros version skew testing ash stable', 'swarming': { 'cipd_packages': [ { 'cipd_package': 'chromium/testing/linux-ash-chromium/x86_64/ash.zip', - 'location': 'lacros_version_skew_tests_v104.0.5112.110', - 'revision': 'version:104.0.5112.110', + 'location': 'lacros_version_skew_tests_v107.0.5304.110', + 'revision': 'version:107.0.5304.110', }, ], },
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index 683cf7f54..519d54e 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -5464,34 +5464,6 @@ ] } ], - "IOSExpKitCalendar": [ - { - "platforms": [ - "ios" - ], - "experiments": [ - { - "name": "Enabled", - "enable_features": [ - "CalendarExperienceKit" - ], - "disable_features": [ - "EnableExpKitCalendarTextClassifier" - ] - }, - { - "name": "EnabledWithTextClassifier", - "params": { - "confidence_score_threshold": "0.0" - }, - "enable_features": [ - "CalendarExperienceKit", - "EnableExpKitCalendarTextClassifier" - ] - } - ] - } - ], "IOSExpKitMaps": [ { "platforms": [
diff --git a/third_party/android_crazy_linker/BUILD.gn b/third_party/android_crazy_linker/BUILD.gn deleted file mode 100644 index 6358fa4..0000000 --- a/third_party/android_crazy_linker/BUILD.gn +++ /dev/null
@@ -1,483 +0,0 @@ -# Copyright 2014 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//build/config/android/config.gni") -import("//testing/libfuzzer/fuzzer_test.gni") -import("//testing/test.gni") - -# NOTE: This file is included in Linux builds to build the -# crazy_linker_zip_fuzzer target (see below). However, the rest of the -# crazy linker doesn't build or work on Linux yet. -# -# NOTE: Instructions for testing the crazy linker are in -# android_linker_testing.md. - -config("crazy_config") { - include_dirs = [ "src/include" ] - if (is_android) { - libs = [ - "log", - "dl", - ] - } -} - -if (is_android) { - group("android_crazy_linker_tests") { - deps = [ - ":android_crazy_linker_unittests", - ":crazy_linker_bench_load_library", - ":crazy_linker_test_constructors_destructors", - ":crazy_linker_test_dl_wrappers", - ":crazy_linker_test_dl_wrappers_recursive", - ":crazy_linker_test_dl_wrappers_valid_handles", - ":crazy_linker_test_dl_wrappers_with_android_dlopen_ext", - ":crazy_linker_test_dl_wrappers_with_system_handle", - ":crazy_linker_test_jni_hooks", - ":crazy_linker_test_load_library", - ":crazy_linker_test_load_library_depends", - ":crazy_linker_test_load_library_with_fd", - ":crazy_linker_test_load_library_with_gnu_hash_table", - ":crazy_linker_test_load_library_with_relr_relocations", - ":crazy_linker_test_load_library_with_reserved_map", - ":crazy_linker_test_relocated_shared_relro", - ":crazy_linker_test_search_path_list", - ":crazy_linker_test_shared_relro", - ":crazy_linker_test_two_shared_relros", - ":run_android_crazy_linker_tests", - ] - testonly = true - } - - # Template to define a source set for the crazy linker. - # This takes a single boolean parameter: - # - # unit_tests: if true, build a version with unit-testing support. - # - template("crazy_linker_library") { - source_set(target_name) { - forward_variables_from(invoker, "*") - sources = [ - "src/include/crazy_linker.h", - "src/src/crazy_linker_api.cpp", - "src/src/crazy_linker_ashmem.cpp", - "src/src/crazy_linker_ashmem.h", - "src/src/crazy_linker_debug.cpp", - "src/src/crazy_linker_debug.h", - "src/src/crazy_linker_defines.h", - "src/src/crazy_linker_elf_hash_table.cpp", - "src/src/crazy_linker_elf_hash_table.h", - "src/src/crazy_linker_elf_loader.cpp", - "src/src/crazy_linker_elf_loader.h", - "src/src/crazy_linker_elf_relocations.cpp", - "src/src/crazy_linker_elf_relocations.h", - "src/src/crazy_linker_elf_relro.cpp", - "src/src/crazy_linker_elf_relro.h", - "src/src/crazy_linker_elf_symbols.cpp", - "src/src/crazy_linker_elf_symbols.h", - "src/src/crazy_linker_elf_view.cpp", - "src/src/crazy_linker_elf_view.h", - "src/src/crazy_linker_error.cpp", - "src/src/crazy_linker_error.h", - "src/src/crazy_linker_expected.h", - "src/src/crazy_linker_globals.cpp", - "src/src/crazy_linker_globals.h", - "src/src/crazy_linker_gnu_hash_table.cpp", - "src/src/crazy_linker_gnu_hash_table.h", - "src/src/crazy_linker_library_list.cpp", - "src/src/crazy_linker_library_list.h", - "src/src/crazy_linker_library_view.cpp", - "src/src/crazy_linker_library_view.h", - "src/src/crazy_linker_line_reader.cpp", - "src/src/crazy_linker_line_reader.h", - "src/src/crazy_linker_load_params.h", - "src/src/crazy_linker_memory_mapping.cpp", - "src/src/crazy_linker_memory_mapping.h", - "src/src/crazy_linker_pointer_set.cpp", - "src/src/crazy_linker_pointer_set.h", - "src/src/crazy_linker_proc_maps.cpp", - "src/src/crazy_linker_proc_maps.h", - "src/src/crazy_linker_rdebug.cpp", - "src/src/crazy_linker_rdebug.h", - "src/src/crazy_linker_relr_relocations.cpp", - "src/src/crazy_linker_relr_relocations.h", - "src/src/crazy_linker_search_path_list.cpp", - "src/src/crazy_linker_search_path_list.h", - "src/src/crazy_linker_shared_library.cpp", - "src/src/crazy_linker_shared_library.h", - "src/src/crazy_linker_system.cpp", - "src/src/crazy_linker_system.h", - "src/src/crazy_linker_system_android.cpp", - "src/src/crazy_linker_system_android.h", - "src/src/crazy_linker_system_linker.cpp", - "src/src/crazy_linker_system_linker.h", - "src/src/crazy_linker_thread_data.cpp", - "src/src/crazy_linker_thread_data.h", - "src/src/crazy_linker_util.cpp", - "src/src/crazy_linker_util.h", - "src/src/crazy_linker_wrappers.cpp", - "src/src/crazy_linker_wrappers.h", - "src/src/crazy_linker_zip.cpp", - "src/src/crazy_linker_zip.h", - "src/src/elf_traits.h", - "src/src/linker_phdr.cpp", - "src/src/linker_phdr.h", - "src/src/linker_reloc_iterators.h", - "src/src/linker_sleb128.h", - ] - - include_dirs = [ "src/src" ] - - if (defined(unit_tests) && unit_tests) { - sources += [ - "src/src/crazy_linker_system_mock.cpp", - "src/src/crazy_linker_system_mock.h", - ] - defines = [ - "UNIT_TEST", - "CRAZY_DEBUG=1", - ] - } else { - # Disable r_brk() calls for release builds. This is a work-around for - # unexplained runtime crashes that happen on Intel-based Android - # devices that run ARM binaries through Houdini. For more details - # see https://crbug.com/796938 - if (!is_debug) { - defines = [ "CRAZY_DISABLE_R_BRK" ] - } - } - - public_configs = [ ":crazy_config" ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - # Disable orderfile instrumentation. Code in this target is in a different - # .so, cannot call unexported instrumentation functions from another one - # (link time error). - configs -= [ "//build/config/android:default_orderfile_instrumentation" ] - - # This is used to allow shared memory regions to work on Android Q+ - # See http://crbug.com/949804 - deps = [ "//third_party/ashmem" ] - } - } - - crazy_linker_library("android_crazy_linker") { - } - - crazy_linker_library("android_crazy_linker_for_unittests") { - unit_tests = true - } - - test("android_crazy_linker_unittests") { - sources = [ - "src/src/crazy_linker_ashmem_unittest.cpp", - "src/src/crazy_linker_elf_hash_table_unittest.cpp", - "src/src/crazy_linker_elf_symbols_unittest.cpp", - "src/src/crazy_linker_error_unittest.cpp", - "src/src/crazy_linker_expected_unittest.cpp", - "src/src/crazy_linker_globals_unittest.cpp", - "src/src/crazy_linker_gnu_hash_table_unittest.cpp", - "src/src/crazy_linker_line_reader_unittest.cpp", - "src/src/crazy_linker_pointer_set_unittest.cpp", - "src/src/crazy_linker_proc_maps_unittest.cpp", - "src/src/crazy_linker_rdebug_unittest.cpp", - "src/src/crazy_linker_relr_relocations_unittest.cpp", - "src/src/crazy_linker_search_path_list_unittest.cpp", - "src/src/crazy_linker_system_unittest.cpp", - "src/src/crazy_linker_thread_data_unittest.cpp", - "src/src/crazy_linker_util_threads_unittest.cpp", - "src/src/crazy_linker_util_unittest.cpp", - "src/src/crazy_linker_zip_test_data.cpp", - "src/src/crazy_linker_zip_test_data.h", - "src/src/crazy_linker_zip_unittest.cpp", - ] - - include_dirs = [ "src/src" ] - - # Required by crazy_linker_expected_unittest.cpp - defines = [ "CRAZY_DEBUG=1" ] - - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - deps = [ - ":android_crazy_linker_for_unittests", - "//testing/gtest", - "//testing/gtest:gtest_main", - ] - - if (is_android) { - use_raw_android_executable = true - } - } - - # The following are shared libraries used by the integration tests. - - template("crazy_linker_test_library") { - shared_library(target_name) { - forward_variables_from(invoker, - [ - "deps", - "data_deps", - "defines", - "ldflags", - ]) - sources = invoker.sources - libs = [ "log" ] - if (defined(invoker.libs)) { - libs += invoker.libs - } - - if (defined(invoker.configs)) { - configs += invoker.configs - } - - # This is not Chromium code. - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - - # All libraries expects their symbols to be visible. - if (is_android) { - configs -= [ "//build/config/android:hide_all_but_jni_onload" ] - } - configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] - configs += [ "//build/config/gcc:symbol_visibility_default" ] - } - } - - crazy_linker_test_library("crazy_linker_tests_libfoo") { - sources = [ "src/tests/foo.cpp" ] - } - - crazy_linker_test_library("crazy_linker_tests_libfoo_with_gnu_hash_table") { - sources = [ "src/tests/foo.cpp" ] - ldflags = [ "-Wl,--hash-style=gnu" ] - } - - crazy_linker_test_library("crazy_linker_tests_libfoo2") { - sources = [ "src/tests/foo2.cpp" ] - } - - crazy_linker_test_library("crazy_linker_tests_libfoo_with_relro") { - sources = [ "src/tests/foo_with_relro.cpp" ] - } - - crazy_linker_test_library("crazy_linker_tests_libfoo_with_relro_and_relr") { - sources = [ "src/tests/foo_with_relro.cpp" ] - configs = [ "//build/config/android:lld_relr_relocations" ] - } - - crazy_linker_test_library( - "crazy_linker_tests_libfoo_with_static_constructor") { - sources = [ "src/tests/foo_with_static_constructor.cpp" ] - } - - crazy_linker_test_library("crazy_linker_tests_libbar") { - sources = [ "src/tests/bar.cpp" ] - deps = [ ":crazy_linker_tests_libfoo" ] - } - - crazy_linker_test_library("crazy_linker_tests_libbar_with_relro") { - sources = [ "src/tests/bar_with_relro.cpp" ] - deps = [ ":crazy_linker_tests_libfoo_with_relro" ] - } - - crazy_linker_test_library("crazy_linker_tests_libbar_with_two_dlopens") { - sources = [ "src/tests/bar_with_two_dlopens.cpp" ] - data_deps = [ - ":crazy_linker_tests_libfoo", - ":crazy_linker_tests_libfoo2", - ] - libs = [ "dl" ] - } - - crazy_linker_test_library("crazy_linker_tests_libzoo") { - sources = [ "src/tests/zoo.cpp" ] - data_deps = [ ":crazy_linker_tests_libbar" ] - } - - crazy_linker_test_library( - "crazy_linker_tests_libzoo_with_android_dlopen_ext") { - sources = [ "src/tests/zoo_with_android_dlopen_ext.cpp" ] - libs = [ "dl" ] - } - - crazy_linker_test_library("crazy_linker_tests_libzoo_with_dlopen_handle") { - sources = [ "src/tests/zoo_with_dlopen_handle.cpp" ] - libs = [ "dl" ] - } - - crazy_linker_test_library("crazy_linker_tests_libzoo_dlopen_in_initializer") { - sources = [ "src/tests/zoo_with_dlopen_in_elf_initializer.cpp" ] - defines = [ - "THIS_LIB_NAME=\"libzoo_dlopen_in_initializer\"", - "LIB_NAME=\"libcrazy_linker_tests_libzoo_dlopen_in_initializer_inner.so\"", - ] - data_deps = [ ":crazy_linker_tests_libzoo_dlopen_in_initializer_inner" ] - libs = [ "dl" ] - } - - crazy_linker_test_library( - "crazy_linker_tests_libzoo_dlopen_in_initializer_inner") { - sources = [ "src/tests/zoo_with_dlopen_in_elf_initializer.cpp" ] - defines = [ - "THIS_LIB_NAME=\"libzoo_dlopen_in_initializer_inner\"", - "LIB_NAME=\"libcrazy_linker_tests_libzoo.so\"", - ] - data_deps = [ ":crazy_linker_tests_libzoo" ] - libs = [ "dl" ] - } - - crazy_linker_test_library("crazy_linker_tests_libjni_lib") { - sources = [ "src/tests/jni_lib.cpp" ] - } - - # Integration tests are provided as standalone executables for now. - - executable("crazy_linker_bench_load_library") { - sources = [ "src/tests/bench_load_library.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_jni_hooks") { - sources = [ "src/tests/test_jni_hooks.cpp" ] - data_deps = [ ":crazy_linker_tests_libjni_lib" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library") { - sources = [ "src/tests/test_load_library.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library_with_fd") { - sources = [ "src/tests/test_load_library_with_fd.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library_with_reserved_map") { - sources = [ "src/tests/test_load_library_with_reserved_map.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library_with_relr_relocations") { - sources = [ "src/tests/test_load_library.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo_with_relro_and_relr" ] - defines = - [ "LIB_NAME=\"libcrazy_linker_tests_libfoo_with_relro_and_relr.so\"" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library_depends") { - sources = [ "src/tests/test_load_library_depends.cpp" ] - data_deps = [ ":crazy_linker_tests_libbar" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_constructors_destructors") { - sources = [ "src/tests/test_constructors_destructors.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo_with_static_constructor" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_load_library_with_gnu_hash_table") { - sources = [ "src/tests/test_load_library.cpp" ] - defines = - [ "LIB_NAME=\"libcrazy_linker_tests_libfoo_with_gnu_hash_table.so\"" ] - data_deps = [ ":crazy_linker_tests_libfoo_with_gnu_hash_table" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_dl_wrappers") { - sources = [ "src/tests/test_dl_wrappers.cpp" ] - data_deps = [ ":crazy_linker_tests_libzoo" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_dl_wrappers_recursive") { - sources = [ "src/tests/test_dl_wrappers_recursive.cpp" ] - data_deps = [ ":crazy_linker_tests_libzoo_dlopen_in_initializer" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_dl_wrappers_with_system_handle") { - sources = [ "src/tests/test_dl_wrappers_with_system_handle.cpp" ] - data_deps = [ ":crazy_linker_tests_libzoo_with_dlopen_handle" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_dl_wrappers_with_android_dlopen_ext") { - sources = [ "src/tests/test_dl_wrappers_with_android_dlopen_ext.cpp" ] - data_deps = [ ":crazy_linker_tests_libzoo_with_android_dlopen_ext" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_dl_wrappers_valid_handles") { - sources = [ "src/tests/test_dl_wrappers_valid_handles.cpp" ] - data_deps = [ ":crazy_linker_tests_libbar_with_two_dlopens" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_search_path_list") { - sources = [ "src/tests/test_search_path_list.cpp" ] - data_deps = [ - ":crazy_linker_tests_libfoo", - ":crazy_linker_tests_libfoo2", - ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_relocated_shared_relro") { - sources = [ "src/tests/test_relocated_shared_relro.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo_with_relro" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_shared_relro") { - sources = [ "src/tests/test_shared_relro.cpp" ] - data_deps = [ ":crazy_linker_tests_libfoo_with_relro" ] - deps = [ ":android_crazy_linker" ] - } - - executable("crazy_linker_test_two_shared_relros") { - sources = [ "src/tests/test_two_shared_relros.cpp" ] - data_deps = [ - ":crazy_linker_tests_libbar_with_relro", - ":crazy_linker_tests_libfoo_with_relro", - ] - deps = [ ":android_crazy_linker" ] - } - - # Copy the script that runs all integration tests to the right directory. - copy("run_android_crazy_linker_tests") { - sources = [ "src/run_tests.sh" ] - outputs = [ "$root_out_dir/bin/run_android_crazy_linker_tests" ] - } -} # is_android - -# NOTE: To build and run this on Linux, use the following commands after -# performing a Release build for Android: -# -# cd $CHROMIUM_SRC_DIR -# mkdir out/Fuzz -# gn gen out/Fuzz '--args=use_libfuzzer=true is_asan=true is_debug=false' -# ninja -C out/Fuzz android_crazy_linker_zip_fuzzer -# out/Fuzz/android_crazy_linker_zip_fuzzer out/Release/apks -# -fuzzer_test("android_crazy_linker_zip_fuzzer") { - sources = [ - "src/src/crazy_linker_system.cpp", - "src/src/crazy_linker_system.h", - "src/src/crazy_linker_util.cpp", - "src/src/crazy_linker_util.h", - "src/src/crazy_linker_zip.cpp", - "src/src/crazy_linker_zip.h", - ] - - defines = [ "CRAZY_LINKER_ENABLE_FUZZING" ] -}
diff --git a/third_party/android_crazy_linker/DIR_METADATA b/third_party/android_crazy_linker/DIR_METADATA deleted file mode 100644 index c914ddc4..0000000 --- a/third_party/android_crazy_linker/DIR_METADATA +++ /dev/null
@@ -1,5 +0,0 @@ -monorail { - component: "Build" -} - -team_email: "build@chromium.org"
diff --git a/third_party/android_crazy_linker/LICENSE b/third_party/android_crazy_linker/LICENSE deleted file mode 100644 index 2a1f6d5..0000000 --- a/third_party/android_crazy_linker/LICENSE +++ /dev/null
@@ -1,55 +0,0 @@ -// Copyright 2014 The Chromium Authors -// -// 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 LLC 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. - -/* - * Copyright (C) 2012 The Android Open Source Project - * 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. - * - * 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. - */
diff --git a/third_party/android_crazy_linker/OWNERS b/third_party/android_crazy_linker/OWNERS deleted file mode 100644 index fb6cbe1f..0000000 --- a/third_party/android_crazy_linker/OWNERS +++ /dev/null
@@ -1,2 +0,0 @@ -digit@chromium.org -pasko@chromium.org
diff --git a/third_party/android_crazy_linker/README.chromium b/third_party/android_crazy_linker/README.chromium deleted file mode 100644 index 8ae247c..0000000 --- a/third_party/android_crazy_linker/README.chromium +++ /dev/null
@@ -1,112 +0,0 @@ -Name: Android Crazy Linker -URL: https://chromium.googlesource.com/chromium/src.git/+/master/third_party/android_crazy_linker/ -Version: 0 -Revision: Forked from https://android.googlesource.com/platform/ndk/+/681f1b744aec1b0888f4c7a68165720db9670300/sources/android/crazy_linker/ -Security Critical: no -License: Apache Version 2.0 - -Description: -Fork of the Android NDK crazy linker. - -Local Modifications: -- Forked from: - android/platform/ndk/f96c7168b688f2d8cc99c220e7a40e3739476848 - -- Add a required license header to a cpp module, missing in the original - -- Rolled to: - android/platform/ndk/681f1b744aec1b0888f4c7a68165720db9670300 - (Re-add license header to crazy_linker_elf_view.cpp) - -- Fix for crbug/373695 (NDK crazy linker: Bug in library file name handling) - -- Fix for crbug/386594 (Crazy linker fails to load a browser on MIPS) - -- Add support for unpacking packed R_ARM_RELATIVE relocation data. - https://code.google.com/p/chromium/issues/detail?id=385553 - -- Add support for opening library within a zipfile. - -- Fix -Werror=sign-compare error encountered in NDK build. - -- Improve permission denied message to mention upgrading from L-preview. - -- Fix for crbug/394306 (Chrome crashes during startup ... on Arm64 AAW15) - -- Move packed relocation dynamic tags from DT_LOPROC range to DT_LOOS range. - -- Add support for x86_64. - -- Speculative fix for crbug/397634. - -- Implement LEB128 decoding more efficiently. - -- Add support for unpacking relative relocations with addends, for arm64. - -- Fix phdr_table_get_dynamic_section() call in ElfView::InitUnmapped(). - -- Fix typo in LOG() call, added in arm64 packed relative relocations change. - -- Add an error message for failures where no shared RELRO pages are swapped. - -- Remove excess newline from the message added above. - -- Avoid mixing size_t and uint32_t in Leb128Decoder::Dequeue(). - -- Re-order application of relocation sections to match the system linker. - -- Add a check whether file is uncompressed in zip file. - -- Fix -Wreorder warning (error with -Werror) in class ElfLoader. - -- Control static_assert invocations with a new COMPILE_ASSERT macro. - -- Fix unit test crash caused by use of deleted data inside an unload callback. - -- Fix for crbug/444714 (Chrome_Android: Crash Report - -1DB24FB5) - -- Speculative fix for crbug/450659. - -- Add basic LD_PRELOAD handling, for crbug/448968. - -- Speculative fix for crbug/479220. - -- Fix RELRO sharing issue caused by packing relocations. - -- Correct fix for crbug/479220 (replace IsSystemLibrary() with caller flags). - -- Fix link_map_.l_addr (was load address, should be load bias). - -- Convert packed relocation code to handle Android packed relocations. - -- Implement a stub __cxa_demangle to avoid linking to LLVM's implementation. - -- Change relocation packing constant names for C++ style (cosmetic only). - -- Add a Breakpad "guard region" to the start of reserved address space. - -- Remove CVE-2011-1149 detection machinery. - -- Start zip EOCD signature search at size of EOCD record bytes from file end. - -- Add custom operator new(size_t) and operator delete(void*) in order to - reduce the size of the final binaries (24 kiB on ARM, 64 kiB on AARCH4). - -- Define CRAZY_DISABLE_R_BRK to disable debugger support. - -- Enable integration and unit tests when building with Chromium. - -- Support passing system library handles in dlsym() / dlclose() wrappers. - -- Improve FileDescriptor class. - -- Safer zip parsing code (avoid integer overflows and add range checks). - -- Add a document about testing the crazy linker in a Chromium checkout - -- Remove unnecessary alignment check for size of area that is about to mmap(2). - -- Fix -Wshadow warning (error with -Werror) in struct RelroLibrary. - -- Updated the copyright headers to the latest style. -
diff --git a/third_party/android_crazy_linker/src/Android.mk b/third_party/android_crazy_linker/src/Android.mk deleted file mode 100644 index 72446f0..0000000 --- a/third_party/android_crazy_linker/src/Android.mk +++ /dev/null
@@ -1,64 +0,0 @@ -# Copyright 2014 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -LOCAL_PATH := $(call my-dir) - -crazy_linker_sources := \ - src/crazy_linker_api.cpp \ - src/crazy_linker_ashmem.cpp \ - src/crazy_linker_debug.cpp \ - src/crazy_linker_elf_loader.cpp \ - src/crazy_linker_elf_relocations.cpp \ - src/crazy_linker_elf_relro.cpp \ - src/crazy_linker_elf_symbols.cpp \ - src/crazy_linker_elf_view.cpp \ - src/crazy_linker_error.cpp \ - src/crazy_linker_globals.cpp \ - src/crazy_linker_library_list.cpp \ - src/crazy_linker_library_view.cpp \ - src/crazy_linker_line_reader.cpp \ - src/crazy_linker_proc_maps.cpp \ - src/crazy_linker_rdebug.cpp \ - src/crazy_linker_search_path_list.cpp \ - src/crazy_linker_shared_library.cpp \ - src/crazy_linker_thread.cpp \ - src/crazy_linker_util.cpp \ - src/crazy_linker_wrappers.cpp \ - src/crazy_linker_system.cpp \ - src/linker_phdr.cpp \ - -# The crazy linker itself. -include $(CLEAR_VARS) -LOCAL_MODULE := crazy_linker -LOCAL_C_INCLUDES = $(LOCAL_PATH)/include $(LOCAL_PATH)/src -LOCAL_CFLAGS := -Os -fvisibility=hidden -Wall -Werror -LOCAL_SRC_FILES := $(crazy_linker_sources) -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_EXPORT_LDLIBS := -llog -include $(BUILD_STATIC_LIBRARY) - -# The crazy linker unit tests. -include $(CLEAR_VARS) - -LOCAL_MODULE := crazylinker_unittest -LOCAL_SRC_FILES := \ - $(crazy_linker_sources) \ - src/crazy_linker_ashmem_unittest.cpp \ - src/crazy_linker_error_unittest.cpp \ - src/crazy_linker_line_reader_unittest.cpp \ - src/crazy_linker_system_mock.cpp \ - src/crazy_linker_system_unittest.cpp \ - src/crazy_linker_globals_unittest.cpp \ - src/crazy_linker_proc_maps_unittest.cpp \ - src/crazy_linker_search_path_list_unittest.cpp \ - src/crazy_linker_util_unittest.cpp \ - src/crazy_linker_thread_unittest.cpp \ - minitest/minitest.cc \ - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/src -LOCAL_CFLAGS += -DUNIT_TESTS -LOCAL_LDLIBS := -llog - -include $(BUILD_EXECUTABLE) -
diff --git a/third_party/android_crazy_linker/src/DESIGN.TXT b/third_party/android_crazy_linker/src/DESIGN.TXT deleted file mode 100644 index ea4482d..0000000 --- a/third_party/android_crazy_linker/src/DESIGN.TXT +++ /dev/null
@@ -1,205 +0,0 @@ -The design of crazy_linker: -=========================== - -Introduction: -------------- - -A system linker (e.g. ld.so on Linux, or /system/bin/linker on Android), is a -particularly sophisticated piece of code because it is used to load and start -_executables_ on the system. This requires dealing with really low-level -details like: - - - The way the kernel loads and initializes binaries into a new process. - - - The way it passes initialization data (e.g. command-line arguments) to - the process being launched. - - - Setting up the C runtime library, thread-local storage, and others properly - before calling main(). - - - Be very careful in the way it operates, due to the fact that it will be used - to load set-uid programs. - - - Need to support a flurry of exotic flags and environment variables that - affect runtime behaviour in "interesting" but mostly unpredictable ways - (see the manpages for dlopen, dlsym and ld.so for details). - -Add to this that most of this must be done without the C library being loaded or -initialized yet. No wonder this code is really complex. - -By contrast, crazy_linker is a static library whose only purpose is to load -ELF shared libraries, inside an _existing_ executable process. This makes it -considerably simpler: - - - The runtime environment (C library, libstdc++) is available and properly - initialized. - - - No need to care about kernel interfaces. Everything uses mmap() and simple - file accesses. - - - The API is simple, and straightforward (no hidden behaviour changes due to - environment variables). - -This document explains how the crazy_linker works. A good understanding of the -ELF file format is recommended, though not necessary. - - -I. ELF Loading Basics: ----------------------- - -When it comes to loading shared libraries, an ELF file mainly consists in the -following parts: - - - A fixed-size header that identifies the file as an ELF file and gives - offsets/sizes to other tables. - - - A table (called the "program header table"), containing entries describing - 'segments' of interest in the ELF file. - - - A table (called the "dynamic table"), containing entries describing - properties of the ELF library. The most interesting ones are the list - of libraries the current one depends on. - - - A table describing the symbols (function or global names) that the library - references or exports. - - - One or more tables containing 'relocations'. Because libraries can be loaded - at any page-aligned address in memory, numerical pointers they contain must - be adjusted after load. That's what the relocation entries do. They can - also reference symbols to be found in other libraries. - -The process of loading a given ELF shared library can be decomposed into 4 steps: - - 1) Map loadable segments into memory. - - This step parses the program header table to identify 'loadable' segments, - reserve the corresponding address space, then map them directly into - memory with mmap(). - - Related: src/crazy_linker_elf_loader.cpp - - - 2) Load library dependencies. - - This step parses the dynamic table to identify all the other shared - libraries the current one depends on, then will _recursively_ load them. - - Related: src/crazy_linker_library_list.cpp - (crazy::LibraryList::LoadLibrary()) - - 3) Apply all relocations. - - This steps adjusts all pointers within the library for the actual load - address. This can also reference symbols that appear in other libraries - loaded in step 2). - - Related: src/crazy_linker_elf_relocator.cpp - - 4) Run constructors. - - Libraries include a list of functions to be run at load time, typically - to perform static C++ initialization. - - Related: src/crazy_linker_shared_library.cpp - (SharedLibrary::RunConstructors()) - -Unloading a library is similar, but in reverse order: - - 1) Run destructors. - 2) Unload dependencies recursively. - 3) Unmap loadable segments. - - -II. Managing the list of libraries: ------------------------------------ - -It is crucial to avoid loading the same library twice in the same process, -otherwise some really bad undefined behaviour may happen. - -This implies that, inside an Android application process, all system libraries -should be loaded by the system linker (because otherwise, the Dalvik-based -framework might load the same library on demand, at an unpredictable time). - -To handle this, the crazy_linker uses a custom class (crazy::LibraryList) where -each entry (crazy::LibraryView) is reference-counted, and either references: - - - An application shared libraries, loaded by the crazy_linker itself. - - A system shared libraries, loaded through the system dlopen(). - -Libraries loaded by the crazy_linker are modelled by a crazy::SharedLibrary -object. The source code comments often refer to these objects as -"crazy libraries", as opposed to "system libraries". - -As an example, here's a diagram that shows the list after loading a library -'libfoo.so' that depends on the system libraries 'libc.so', 'libm.so' and -'libOpenSLES.so'. - - +-------------+ - | LibraryList | - +-------------+ - | - | +-------------+ - +----| LibraryView | ----> libc.so - | +-------------+ - | - | +-------------+ - +----| LibraryView | ----> libm.so - | +-------------+ - | - | +-------------+ - +----| LibraryView | ----> libOpenSLES.so - | +-------------+ - | - | +-------------+ +-------------+ - +----| LibraryView |----->|SharedLibrary| ---> libfoo.so - | +-------------+ +-------------+ - | - ___ - _ - -System libraries are identified by name. Only the official NDK-official system -libraries are listed. It is likely that using crazy_linker to load non-NDK -system libraries will not work correctly, so don't do it. - - -III. Wrapping of linker symbols within crazy ones: --------------------------------------------------- - -Libraries loaded by the crazy linker are not visible to the system linker. - -This means that directly calling the system dlopen() or dlsym() from a library -code loaded by the crazy_linker will not work properly. - -To work-around this, crazy_linker redirects all linker symbols to its own -wrapper implementation. This redirection happens transparently. - - Related: src/crazy_linker_wrappers.cpp - -This also includes a few "hidden" dynamic linker symbols which are used for -stack-unwinding. This guarantees that C++ exception propagation works. - - -IV. GDB support: ----------------- - -The crazy_linker contains support code to ensure that libraries loaded with it -are visible through GDB at runtime. For more details, see the extensive comments -in src/crazy_linker_rdebug.h - - -V. Other Implementation details: --------------------------------- - -The crazy_linker is written in C++, but its API is completely C-based. - -The implementation doesn't require any C++ STL feature (except for new -and delete). - -Very little of the code is actually Android-specific. The target system's -bitness is abstracted through a C++ traits class (see src/elf_traits.h). - -Written originally for Chrome, so follows the Chromium coding style. Which can -be enforced by using the 'clang-format' tool with: - - cd /path/to/crazy_linker/ - find . -name "*.h" -o -name "*.cpp" | xargs clang-format -style Chromium -i
diff --git a/third_party/android_crazy_linker/src/DIR_METADATA b/third_party/android_crazy_linker/src/DIR_METADATA deleted file mode 100644 index 14b5edb5..0000000 --- a/third_party/android_crazy_linker/src/DIR_METADATA +++ /dev/null
@@ -1,3 +0,0 @@ -monorail { - component: "Internals" -}
diff --git a/third_party/android_crazy_linker/src/LICENSE b/third_party/android_crazy_linker/src/LICENSE deleted file mode 100644 index 3c87aaf..0000000 --- a/third_party/android_crazy_linker/src/LICENSE +++ /dev/null
@@ -1,55 +0,0 @@ -// Copyright 2014 The Chromium Authors -// -// 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. - -/* - * Copyright (C) 2012 The Android Open Source Project - * 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. - * - * 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. - */
diff --git a/third_party/android_crazy_linker/src/README.TXT b/third_party/android_crazy_linker/src/README.TXT deleted file mode 100644 index c08168ec..0000000 --- a/third_party/android_crazy_linker/src/README.TXT +++ /dev/null
@@ -1,130 +0,0 @@ -Introduction: -------------- - -A custom dynamic linker for Android programs that adds a few interesting -features compared to /system/bin/linker: - - - Support changing the library search path. The system linker, when used - inside Android applications, is limited to the value of LD_LIBRARY_PATH - at boot time, that only looks into system directories, not application - ones. - - This linker allows the client to add application paths before the - default system ones, this has two benefits: - - - Library dependencies are loaded automatically in the right order. - - - Libraries from the application paths are favored over system ones. - This avoids conflicts when one of your application's libraries - has the same name than a system one (which happens randomly - on certain devices due to system application bundling). - - (Note: The system linker issue above has been fixed in Android 4.3). - - - Supports any number of shared libraries. On older Android platforms, - the system linker will refuse to load more than 64 or 128 libraries - in a single process (Note: Fixed in Android 4.3). - - - Supports loading a library at an explicit (page-aligned) memory - address. The system linker always randomizes the address. Note that - this is generally a _bad_ idea for security reasons. Consider using - this only when using shared RELROs (see below). - - - Supports loading a library from an explicit (page-aligned) file - offset. This can be useful to load a library directly from an .apk, - provided that it is uncompressed and at a page-aligned offset. - - - Support sharing of RELRO sections. When two processes load the same - library at exactly the same address, the content of its RELRO section - is identical. By default, each instance uses private RAM pages to host - it, but it is possible to use a single ashmem region to share the same - data instead. - -See include/crazy_linker.h for the API and its documentation. - -See LICENSE file for full licensing details (hint: BSD) - -A few notes: - - - Do not use this if you don't know what you're doing. Read the API - documentation first, and look at the test programs for usage examples. - - - The crazy linker will always use the system linker to load NDK-exposed - system libraries (e.g. liblog.so and others). This avoids having two - instances of the same library in the same process, and correctly - resolving any symbols from system libraries. - - - Any library loaded by the crazy linker, and which uses functions of - libdl.so will continue to work. However, calls to dlopen(), dlsym(), - et al will be redirected to the crazy linker's own wrappers. - - This ensures that if a library is loaded by the crazy linker, any of - its dependencies will be loaded by it too. - - - Libraries loaded with the crazy linker are visible to GDB, or Breakpad, - and stack unwinding / C++ exception propagation should just work. - - -Caveats: --------- - - You can't call the crazy_linker code directly from Java in your Android - application (it's a static library). You need to put it into your own - shared library, loaded with System.loadLibrary() instead (or alternatively, - inside your NativeActivity's shared library). - - Also, libraries loaded with the crazy linker are not visible to the system - one. In practice, it means that lazy native method lookup will not work. I.e.: - - The first time you call a native method like: - - 'mypackage.MyClass.myNativeMethod()' - - The VM will look into existing native libraries with dlsym() for a - function symbol named like: - - Java_mypackage_MyClass_myNativeMethod - - This will not work if the symbol is inside a library loaded with the - crazy_linker. - - To work-around this, register the native methods explicitely - in your JNI_OnLoad() by calling env->RegisterNatives() with the - appropriate parameters. - - -Usage instructions: -------------------- - - 1/ Add the following to your module definition in your project's Android.mk: - - LOCAL_STATIC_LIBRARIES := crazy_linker - - 2/ Also Include the top-level crazy_linker Android.mk, as in: - - include /path/to/crazy_linker/Android.mk - - 3/ In your C or C++ source: - - #include <crazy_linker.h> - - Read the header for API documentation. - - If your library implements native methods, it must explicitely register - them with env->RegisterNatives() before they become usable. - -BUGS & TODOs: -------------- - - - Libraries loaded by the crazy linker are not automatically closed when - the process exits. - - - dlopen() when called inside a library loaded by the crazy linker doesn't - support RTLD_MAIN or RTLD_NEXT. - -Testing: --------- - - See android_linker_testing.md - - See DESIGN.TXT for an overview of the library's design.
diff --git a/third_party/android_crazy_linker/src/android_linker_testing.md b/third_party/android_crazy_linker/src/android_linker_testing.md deleted file mode 100644 index f38955b..0000000 --- a/third_party/android_crazy_linker/src/android_linker_testing.md +++ /dev/null
@@ -1,33 +0,0 @@ -# Testing the Android Crazy Linker - -The crazy linker is a custom dynamic linker used by Chrome on older Android -versions where dynamic linking is not as advanced. It provides -`android_dlopen_ext` functionality, RELRO sharing, compressed relocations, etc. - -These instructions assume -[Building Chromium for Android](android_build_instructions.md) as a -prerequisite. - -## Code Locations - -The tested functionality is spread across these locations: -``` -third_party/android_crazy_linker -base/android/java/src/org/chromium/base/library_loader -``` - -## Running native tests - -This will run both unittests and regression tests: -``` -autoninja -C out/Release android_crazy_linker_tests -out/Release/bin/run_android_crazy_linker_tests --unit-tests -``` - -Verbosity of the output can be increased by setting `CRAZY_DEBUG` to 1 in -`crazy_linker_debug.h`. - -## Fuzzer Tests - -There are also a few tests for fuzzing the ZIP parser. The instructions to run -them are at the bottom of `third_party/android_crazy_linker/BUILD.gn`.
diff --git a/third_party/android_crazy_linker/src/include/crazy_linker.h b/third_party/android_crazy_linker/src/include/crazy_linker.h deleted file mode 100644 index 26aeebfe..0000000 --- a/third_party/android_crazy_linker/src/include/crazy_linker.h +++ /dev/null
@@ -1,280 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_H -#define CRAZY_LINKER_H - -// This is the crazy linker, a custom dynamic linker that can be used -// by NDK applications to load shared libraries (not executables) with -// a twist. -// -// Compared to the dynamic linker, the crazy one has the following -// features: -// -// - It can use an arbitrary search path. -// -// - It can load a library at a memory fixed address. -// -// - It can load libraries from zip archives (as long as they are -// page aligned and uncompressed). Even when running on pre-Android M -// systems. -// -// - It can share the RELRO section between two libraries -// loaded at the same address in two distinct processes. -// -#include <dlfcn.h> -#include <stdbool.h> -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -// Function attribute to indicate that it needs to be exported by -// the library. -#define _CRAZY_PUBLIC __attribute__((__visibility__("default"))) - -// Maximum path length of a file in a zip file. -const size_t kMaxFilePathLengthInZip = 256; - -// Status values returned by crazy linker functions to indicate -// success or failure. They were chosen to match boolean values, -// this allows one to test for failures with: -// -// if (!crazy_linker_function(....)) { -// ... an error occured. -// } -// -// If the function called used a crazy_context_t, it is possible to -// retrieve the error details with crazy_context_get_error(). -typedef enum { - CRAZY_STATUS_FAILURE = 0, - CRAZY_STATUS_SUCCESS = 1 -} crazy_status_t; - -// Opaque handle to a context object that will hold parameters -// for the crazy linker's operations. For example, this is where -// you would set the explicit load address, and other user-provided -// values before calling functions like crazy_library_open(). -// -// The context holds a list of library search paths, initialized to -// the content of the LD_LIBRARY_PATH variable on creation. -// -// The context also holds a string buffer to hold error messages that -// can be queried with crazy_context_get_error(). -typedef struct crazy_context_t crazy_context_t; - -// Create a new context object. -crazy_context_t* crazy_context_create(void) _CRAZY_PUBLIC; - -// Return current error string, or NULL if there was no error. -const char* crazy_context_get_error(crazy_context_t* context) _CRAZY_PUBLIC; - -// Clear error in a given context. -void crazy_context_clear_error(crazy_context_t* context) _CRAZY_PUBLIC; - -// Set the explicit load address in a context object. Value 0 means -// the address is randomized. NOTE: This will achieve a best-effort load, -// if the address range is reserved, the library will still be loaded at -// a different address. Use crazy_context_set_reserved_map() if you want -// to ensure that the library can only be loaded at a fixed address. -void crazy_context_set_load_address(crazy_context_t* context, - size_t load_address) _CRAZY_PUBLIC; - -// Return the current load address in a context. -size_t crazy_context_get_load_address(crazy_context_t* context) _CRAZY_PUBLIC; - -// Set the explicit library file descriptor in a context object. Values >= 0 -// will be used during the next crazy_library_open() call to read the library -// file, instead of opening it using its path. -void crazy_context_set_library_fd(crazy_context_t* context, - int fd) _CRAZY_PUBLIC; - -// Return the current library file descriptor in a context. -int crazy_context_get_library_fd(crazy_context_t* context) _CRAZY_PUBLIC; - -// Set an explicit reserved memory mapping to be used on the next library -// load. |reserved_address| is the page-aligned reserved address, -// |reserved_size| is the page-aligned reserved size, and if |load_fallback| -// is true, then the linker will try to load the library at a different -// address if it fails to load its segments at the reserved address range. -void crazy_context_set_reserved_map(crazy_context_t* context, - uintptr_t reserved_address, - size_t reserved_size, - bool load_fallback) _CRAZY_PUBLIC; - -// Destroy a given context object. -void crazy_context_destroy(crazy_context_t* context) _CRAZY_PUBLIC; - -// Record the value of |java_vm| inside of |context|. If this is not NULL, -// which is the default, then after loading any library, the crazy linker -// will look for a "JNI_OnLoad" symbol within it, and, if it exists, will call -// it, passing the value of |java_vm| to it. If the function returns with -// a jni version number that is smaller than |minimum_jni_version|, then -// the library load will fail with an error. -// -// The |java_vm| field is also saved in the crazy_library_t object, and -// used at unload time to call JNI_OnUnload() if it exists. -void crazy_set_java_vm(void* java_vm, int minimum_jni_version); - -// Retrieves the last values set with crazy_context_set_java_vm(). -// A value of NUMM in |*java_vm| means the feature is disabled. -void crazy_get_java_vm(void** java_vm, int* minimum_jni_version); - -// Add one or more paths to the global list of library search paths. |path| is a -// string using a column (:) as a list separator. As with the PATH variable, -// an empty list item is equivalent to '.', the current directory. -// This can fail if too many paths are added to the context. -// -// NOTE: Calling this function appends new paths to the global search list, -// but all paths added with this function will be searched before -// the ones listed in LD_LIBRARY_PATH. -crazy_status_t crazy_add_search_path(const char* file_path) _CRAZY_PUBLIC; - -// Find the ELF binary that contains |address|, and add its directory -// path to the global list of search directories. This is useful to -// load libraries in the same directory as the current program itself. -crazy_status_t crazy_add_search_path_for_address(void* address) _CRAZY_PUBLIC; - -// Reset the search paths to the value of the LD_LIBRARY_PATH -// environment variable. This essentially removes any paths -// that were added with crazy_add_search_path() or -// crazy_context_add_search_path_for_address(). -void crazy_reset_search_paths(void) _CRAZY_PUBLIC; - -// Opaque handle to a library as seen/loaded by the crazy linker. -typedef struct crazy_library_t crazy_library_t; - -// Try to open or load a library with the crazy linker. -// |lib_name| if the library name or path. If it contains a directory -// separator (/), this is treated as a explicit file path, otherwise -// it is treated as a base name, and the context's search path list -// will be used to locate the corresponding file. -// |context| is a linker context handle. Can be NULL for defaults. -// On success, return CRAZY_STATUS_SUCCESS and sets |*library|. -// Libraries are reference-counted, trying to open the same library -// twice will return the same library handle. -// -// NOTE: The load address and file offset from the context only apply -// to the library being loaded (when not already in the process). If the -// operations needs to load any dependency libraries, these will use -// offset and address values of 0 to do so. -// -// NOTE: It is possible to open NDK system libraries (e.g. "liblog.so") -// with this function, but they will be loaded with the system dlopen(). -crazy_status_t crazy_library_open(crazy_library_t** library, - const char* lib_name, - crazy_context_t* context) _CRAZY_PUBLIC; - -// A structure used to hold information about a given library. -// |load_address| is the library's actual (page-aligned) load address. -// |load_size| is the library's actual (page-aligned) size. -// |relro_start| is the address of the library's RELRO section in memory. -// |relso_size| is the size of the library's RELRO section (or 0 if none). -// |relro_fd| is the ashmem file descriptor for the shared section, if one -// was created with crazy_library_enable_relro_sharing(), -1 otherwise. -typedef struct { - size_t load_address; - size_t load_size; - size_t relro_start; - size_t relro_size; -} crazy_library_info_t; - -// Retrieve information about a given library. -// |library| is a library handle. -// |context| will get an error message on failure. -// On success, return true and sets |*info|. -// Note that this function will fail for system libraries. -crazy_status_t crazy_library_get_info(crazy_library_t* library, - crazy_context_t* context, - crazy_library_info_t* info); - -// Create an ashmem region containing a copy of the RELRO section for a given -// |library|. This can be used with crazy_library_use_shared_relro(). -// |load_address| can be specified as non-0 to ensure that the content of the -// ashmem region corresponds to a RELRO relocated for a new load address. -// on success, return CRAZY_STATUS_SUCCESS and sets |*relro_start| to the -// start of the RELRO section in memory, |*relro_size| to its size in bytes -// and |*relro_fd| to a file descriptor to a read-only ashmem region containing -// the data. On failure, return false and set error message in |context|. -// NOTE: On success, the caller becomes the owner of |*relro_fd| and is shall -// close it appropriately. -crazy_status_t crazy_library_create_shared_relro(crazy_library_t* library, - crazy_context_t* context, - size_t load_address, - size_t* relro_start, - size_t* relro_size, - int* relro_fd) _CRAZY_PUBLIC; - -// Use the shared RELRO section of the same library loaded in a different -// address space. On success, return CRAZY_STATUS_SUCCESS and owns |relro_fd|. -// On failure, return CRAZY_STATUS_FAILURE and sets error message in |context|. -// |library| is the library handle. -// |relro_start| is the address of the RELRO section in memory. -// |relro_size| is the size of the RELRO section. -// |relro_fd| is the file descriptor for the shared RELRO ashmem region. -// |context| will receive an error in case of failure. -// NOTE: This will fail if this is a system library, or if the RELRO -// parameters do not match the library's actual load address. -// NOTE: The caller is responsible for closing the file descriptor after this -// call. -crazy_status_t crazy_library_use_shared_relro(crazy_library_t* library, - crazy_context_t* context, - size_t relro_start, - size_t relro_size, - int relro_fd) _CRAZY_PUBLIC; - -// Look for a library named |library_name| in the set of currently -// loaded libraries, and return a handle for it in |*library| on success. -// Note that this increments the reference count on the library, thus -// the caller shall call crazy_library_close() when it's done with it. -crazy_status_t crazy_library_find_by_name(const char* library_name, - crazy_library_t** library); - -// Find the library that contains a given |address| in memory. -// On success, return CRAZY_STATUS_SUCCESS and sets |*library|. -crazy_status_t crazy_linker_find_library_from_address( - void* address, - crazy_library_t** library) _CRAZY_PUBLIC; - -// Lookup a symbol's address by its |symbol_name| in a given library. -// This only looks at the symbols in |library|. -// On success, returns CRAZY_STATUS_SUCCESS and sets |*symbol_address|, -// which could be NULL for some symbols. -crazy_status_t crazy_library_find_symbol(crazy_library_t* library, - const char* symbol_name, - void** symbol_address) _CRAZY_PUBLIC; - -// Lookup a symbol's address in all libraries known by the crazy linker. -// |symbol_name| is the symbol name. On success, returns CRAZY_STATUS_SUCCESS -// and sets |*symbol_address|. -// NOTE: This will _not_ look into system libraries that were not opened -// with the crazy linker. -crazy_status_t crazy_linker_find_symbol(const char* symbol_name, - void** symbol_address) _CRAZY_PUBLIC; - -// Find the in-process library that contains a given memory address. -// Note that this works even if the memory is inside a system library that -// was not previously opened with crazy_library_open(). -// |address| is the memory address. -// On success, returns CRAZY_STATUS_SUCCESS and sets |*library|. -// The caller muyst call crazy_library_close() once it's done with the -// library. -crazy_status_t crazy_library_find_from_address( - void* address, - crazy_library_t** library) _CRAZY_PUBLIC; - -// Close a library. This decrements its reference count. If it reaches -// zero, the library be unloaded from the process. -void crazy_library_close(crazy_library_t* library) _CRAZY_PUBLIC; - -// Close a library, with associated context to support delayed operations. -void crazy_library_close_with_context(crazy_library_t* library, - crazy_context_t* context) _CRAZY_PUBLIC; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* CRAZY_LINKER_H */
diff --git a/third_party/android_crazy_linker/src/run_tests.sh b/third_party/android_crazy_linker/src/run_tests.sh deleted file mode 100755 index 9ea4836..0000000 --- a/third_party/android_crazy_linker/src/run_tests.sh +++ /dev/null
@@ -1,249 +0,0 @@ -#!/bin/sh -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -set -e -export LANG=C -export LC_ALL=C - -PROGNAME=$(basename $0) -PROGDIR=$(dirname "$0") - -# Print an error message then exit immediately. -panic () { - echo "ERROR: $@" - exit 1 -} - -run () { - if [ "$VERBOSE" -ge 1 ]; then - "$@" - else - "$@" 2>&1 >/dev/null - fi -} - -ADB=${ADB:-adb} - -# Run a command through adb shell, strip the extra \r from the output -# and return the correct status code to detect failures. This assumes -# that the adb shell command prints a final \n to stdout. -# $1+: command to run -# Out: command's stdout -# Return: command's status -# Note: the command's stderr is lost -adb_shell () { - local TMPOUT="$(mktemp)" - local LASTLINE RET - - # The weird sed rule is to strip the final \r on each output line - # Since 'adb shell' never returns the command's proper exit/status code, - # we force it to print it as '%%<status>' in the temporary output file, - # which we will later strip from it. - echo "[$ADB shell $@ ; ... ]" - $ADB shell $@ ";" echo "%%\$?" 2>/dev/null | \ - sed -e 's![[:cntrl:]]!!g' > $TMPOUT - # Get last line in log, which contains the exit code from the command - LASTLINE=$(sed -e '$!d' $TMPOUT) - # Extract the status code from the end of the line, which must - # be '%%<code>'. - RET=$(echo "$LASTLINE" | \ - awk '{ if (match($0, "%%[0-9]+$")) { print substr($0,RSTART+2); } }') - # Remove the status code from the last line. Note that this may result - # in an empty line. - LASTLINE=$(echo "$LASTLINE" | \ - awk '{ if (match($0, "%%[0-9]+$")) { print substr($0,1,RSTART-1); } }') - # The output itself: all lines except the status code. - sed -e '$d' $TMPOUT && printf "%s" "$LASTLINE" - # Remove temp file. - rm -f $TMPOUT - # Exit with the appropriate status. - return $RET -} - -# Command-line parsing. -VERBOSE=0 -DO_HELP= -DO_TEST= -DO_UNIT_TESTS= -for OPT; do - case $OPT in - --output-dir=*) - CHROMIUM_OUTPUT_DIR=${OPT##--output-dir=} - ;; - --help|-?) - DO_HELP=true - ;; - --unit-tests) - DO_UNIT_TESTS=true - ;; - --verbose) - VERBOSE=$(( $VERBOSE + 1 )) - ;; - -*) - panic "Invalid option $OPT, see --help." - ;; - *) - if [ -n "$DO_TEST" ]; then - panic "This script can only take one argument" - fi - DO_TEST=$OPT - ;; - esac -done - -if [ "$DO_HELP" ]; then - cat <<EOF -Usage: $PROGNAME [options] [test-name] - -This script is used to run all integration tests for the Android crazy linker. -You should have rebuilt all binaries with the following commands: - - gn \$OUT_DIR android_crazy_linker_tests - -Then call this script with: - - \$OUT_DIR/bin/$PROGNAME - -Where \$OUT_DIR is your Chromium output directory, which can be set either -through the CHROMIUM_OUTPUT_DIR environment variable or with the --output-dir -option. - -Possible options: - - --help|-? Print this message. - --output-dir=<dir> Manually set the Chromium output directory. - --unit-tests Also run the unit-tests suite (for convenience). - --verbose Increment verbosity. - -EOF - exit 0 -fi - -if [ -z "$CHROMIUM_OUTPUT_DIR" ]; then - # Check whether this is under $OUTPUT_DIR/bin/ - PROGDIR_PARENT=$(cd "$PROGDIR/.." && pwd) - if [ -f "$PROGDIR_PARENT/bin/$PROGNAME" ]; then - CHROMIUM_OUTPUT_DIR=$PROGDIR_PARENT - fi -fi - -if [ -z "$CHROMIUM_OUTPUT_DIR" ]; then - panic "Please set CHROMIUM_OUTPUT_DIR or use --output-dir, see --help." -fi - -if [ ! -d "$CHROMIUM_OUTPUT_DIR" ]; then - panic "Invalid directory: $CHROMIUM_OUTPUT_DIR" -fi - -# The directory on the device where all tests will be copied and run. -# TODO(digit): Create random temporary directory under /data/local/tmp/ -RUN_DIR=/data/local/tmp - -# The list of files to copy to $RUN_DIR/ -LIBRARY_FILES="\ -libcrazy_linker_tests_libbar.so \ -libcrazy_linker_tests_libbar_with_relro.so \ -libcrazy_linker_tests_libbar_with_two_dlopens.so \ -libcrazy_linker_tests_libfoo.so \ -libcrazy_linker_tests_libfoo_with_relro.so \ -libcrazy_linker_tests_libfoo_with_relro_and_relr.so \ -libcrazy_linker_tests_libfoo_with_static_constructor.so \ -libcrazy_linker_tests_libfoo_with_gnu_hash_table.so \ -libcrazy_linker_tests_libfoo2.so \ -libcrazy_linker_tests_libjni_lib.so \ -libcrazy_linker_tests_libzoo.so \ -libcrazy_linker_tests_libzoo_dlopen_in_initializer.so \ -libcrazy_linker_tests_libzoo_dlopen_in_initializer_inner.so \ -libcrazy_linker_tests_libzoo_with_dlopen_handle.so \ -libcrazy_linker_tests_libzoo_with_android_dlopen_ext.so \ -" - -TEST_FILES="\ -crazy_linker_bench_load_library \ -crazy_linker_test_constructors_destructors \ -crazy_linker_test_dl_wrappers \ -crazy_linker_test_dl_wrappers_recursive \ -crazy_linker_test_dl_wrappers_valid_handles \ -crazy_linker_test_dl_wrappers_with_android_dlopen_ext \ -crazy_linker_test_dl_wrappers_with_system_handle \ -crazy_linker_test_jni_hooks \ -crazy_linker_test_load_library \ -crazy_linker_test_load_library_depends \ -crazy_linker_test_load_library_with_fd \ -crazy_linker_test_load_library_with_gnu_hash_table \ -crazy_linker_test_load_library_with_relr_relocations \ -crazy_linker_test_load_library_with_reserved_map \ -crazy_linker_test_relocated_shared_relro \ -crazy_linker_test_search_path_list \ -crazy_linker_test_shared_relro \ -crazy_linker_test_two_shared_relros \ -" - -ALL_FILES="$LIBRARY_FILES $TEST_FILES" - -# Check that all files were built properly. -MISSING_FILES= -for FILE in $ALL_FILES; do - if [ ! -f "$CHROMIUM_OUTPUT_DIR/$FILE" ]; then - echo "ERROR: Missing file: $FILE" - MISSING_FILES="$MISSING_FILES $FILE" - fi -done -if [ -n "$MISSING_FILES" ]; then - panic "Please rebuild all crazy linker tests before using this script" -fi - -(cd $CHROMIUM_OUTPUT_DIR && run adb push $ALL_FILES $RUN_DIR/) || - panic "Could not copy files to Android device" - -# Run a single test on the device. -run_test () { - local TEST_NAME=$1 - shift - if [ "$VERBOSE" -ge 1 ]; then - # Using adb_shell doesn't print stderr, but it gives a status code. - # Consider that this is lesser important when debugging the test execution - # and run "adb shell" from the command-line instead. - echo "cd $RUN_DIR && LD_LIBRARY_PATH=. ./$TEST_NAME $@" | "$ADB" shell - else - run adb_shell "cd $RUN_DIR && LD_LIBRARY_PATH=. ./$TEST_NAME $@" - fi -} - -if [ -n "$DO_UNIT_TESTS" ]; then - UT_FLAGS= - if [ "$VERBOSE" -ge 1 ]; then - UT_FLAGS="--verbose" - fi - $PROGDIR/run_android_crazy_linker_unittests $UT_FLAGS -fi - -if [ -n "$DO_TEST" ]; then - run_test "$DO_TEST" -else - PASSES=0 - FAILURES=0 - TOTAL=0 - for TEST in $TEST_FILES; do - echo "[ BEGIN ] $TEST" - if ! run_test $TEST; then - echo "[ FAILED ] $TEST" - FAILURES=$(( $FAILURES + 1 )) - else - PASSES=$(( $PASSES + 1 )) - echo "[ SUCCESS ] $TEST" - fi - TOTAL=$(( $TOTAL + 1 )) - done - echo "Tests passed: $PASSES" - echo "Tests failed: $FAILURES" - echo "Tests total: $TOTAL" - if [ "$FAILURES" != "0" ]; then - exit 1 - fi - echo "SUCCESS!!" -fi - -# TODO(digit): Cleanup by removing copied files from device.
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp deleted file mode 100644 index e4ba5ee4..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_api.cpp +++ /dev/null
@@ -1,290 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Implements the crazy linker C-based API exposed by <crazy_linker.h> - -#include <crazy_linker.h> - -#include <string.h> - -#include "crazy_linker_ashmem.h" -#include "crazy_linker_error.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_library_view.h" -#include "crazy_linker_proc_maps.h" -#include "crazy_linker_search_path_list.h" -#include "crazy_linker_shared_library.h" -#include "crazy_linker_system.h" -#include "crazy_linker_thread_data.h" -#include "crazy_linker_util.h" - -using crazy::Globals; -using crazy::Error; -using crazy::RDebug; -using crazy::SearchPathList; -using crazy::ScopedLockedGlobals; -using crazy::LibraryView; - -// -// crazy_context_t -// - -struct crazy_context_t { - size_t load_address = 0; - int library_fd = -1; - size_t reserved_size = 0; - bool reserved_load_fallback = false; - Error error; -}; - -// -// API functions -// - -extern "C" { - -crazy_context_t* crazy_context_create() { - return new crazy_context_t(); -} - -const char* crazy_context_get_error(crazy_context_t* context) { - const char* error = context->error.c_str(); - return (error[0] != '\0') ? error : NULL; -} - -// Clear error in a given context. -void crazy_context_clear_error(crazy_context_t* context) { - context->error = ""; -} - -void crazy_context_set_load_address(crazy_context_t* context, - size_t load_address) { - context->load_address = load_address; - context->reserved_load_fallback = true; -} - -size_t crazy_context_get_load_address(crazy_context_t* context) { - return context->load_address; -} - -void crazy_context_set_library_fd(crazy_context_t* context, int fd) { - context->library_fd = fd; -} - -int crazy_context_get_library_fd(crazy_context_t* context) { - return context->library_fd; -} - -void crazy_context_set_reserved_map(crazy_context_t* context, - uintptr_t reserved_address, - size_t reserved_size, - bool load_fallback) { - context->load_address = reserved_address; - context->reserved_size = reserved_size; - context->reserved_load_fallback = load_fallback; -} - -void crazy_context_destroy(crazy_context_t* context) { - delete context; -} - -void crazy_set_java_vm(void* java_vm, int minimum_jni_version) { - ScopedLockedGlobals globals; - globals->InitJavaVm(java_vm, minimum_jni_version); -} - -void crazy_get_java_vm(void** java_vm, int* minimum_jni_version) { - ScopedLockedGlobals globals; - *java_vm = globals->java_vm(); - *minimum_jni_version = globals->minimum_jni_version(); -} - -crazy_status_t crazy_add_search_path(const char* file_path) { - ScopedLockedGlobals globals; - globals->search_path_list()->AddPaths(file_path); - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_add_search_path_for_address(void* address) { - uintptr_t load_address; - char path[512]; - char* p; - - if (crazy::FindElfBinaryForAddress( - address, &load_address, path, sizeof(path)) && - (p = strrchr(path, '/')) != NULL && p[1]) { - *p = '\0'; - return crazy_add_search_path(path); - } - - return CRAZY_STATUS_FAILURE; -} - -void crazy_reset_search_paths(void) { - ScopedLockedGlobals globals; - globals->search_path_list()->ResetFromEnv("LD_LIBRARY_PATH"); -} - -crazy_status_t crazy_library_open(crazy_library_t** library, - const char* lib_name, - crazy_context_t* context) { - ScopedLockedGlobals globals; - crazy::LibraryList* libs = globals->libraries(); - crazy::LoadParams params; - params.wanted_address = context->load_address; - params.reserved_size = context->reserved_size; - params.reserved_load_fallback = context->reserved_load_fallback; - crazy::Expected<LibraryView*> found = - libs->FindAndCheckLoadedLibrary(lib_name, params, &context->error); - if (!found.has_value()) - return CRAZY_STATUS_FAILURE; - - LibraryView* view = found.value(); - if (!view) { - if (context->library_fd >= 0) { - params.library_path = lib_name; - params.library_fd = context->library_fd; - } else { - if (!libs->LocateLibraryFile(lib_name, *globals->search_path_list(), - ¶ms, &context->error)) { - return CRAZY_STATUS_FAILURE; - } - } - view = libs->LoadLibraryInternal(params, &context->error); - - // Cleanup context. - context->library_fd = -1; - context->load_address = 0; - context->reserved_size = 0; - context->reserved_load_fallback = false; - } - - if (!view) - return CRAZY_STATUS_FAILURE; - - *library = reinterpret_cast<crazy_library_t*>(view); - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_library_get_info(crazy_library_t* library, - crazy_context_t* context, - crazy_library_info_t* info) { - if (!library) { - context->error = "Invalid library file handle"; - return CRAZY_STATUS_FAILURE; - } - - LibraryView* wrap = reinterpret_cast<LibraryView*>(library); - if (!wrap->GetInfo(&info->load_address, - &info->load_size, - &info->relro_start, - &info->relro_size, - &context->error)) { - return CRAZY_STATUS_FAILURE; - } - - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_library_create_shared_relro(crazy_library_t* library, - crazy_context_t* context, - size_t load_address, - size_t* relro_start, - size_t* relro_size, - int* relro_fd) { - LibraryView* wrap = reinterpret_cast<LibraryView*>(library); - - if (!library || !wrap->IsCrazy()) { - context->error = "Invalid library file handle"; - return CRAZY_STATUS_FAILURE; - } - - crazy::SharedLibrary* lib = wrap->GetCrazy(); - if (!lib->CreateSharedRelro( - load_address, relro_start, relro_size, relro_fd, &context->error)) - return CRAZY_STATUS_FAILURE; - - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_library_use_shared_relro(crazy_library_t* library, - crazy_context_t* context, - size_t relro_start, - size_t relro_size, - int relro_fd) { - LibraryView* wrap = reinterpret_cast<LibraryView*>(library); - - if (!library || !wrap->IsCrazy()) { - context->error = "Invalid library file handle"; - return CRAZY_STATUS_FAILURE; - } - - crazy::SharedLibrary* lib = wrap->GetCrazy(); - if (!lib->UseSharedRelro(relro_start, relro_size, relro_fd, &context->error)) - return CRAZY_STATUS_FAILURE; - - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_library_find_by_name(const char* library_name, - crazy_library_t** library) { - { - ScopedLockedGlobals globals; - LibraryView* wrap = globals->libraries()->FindLibraryByName(library_name); - if (!wrap) - return CRAZY_STATUS_FAILURE; - - wrap->AddRef(); - *library = reinterpret_cast<crazy_library_t*>(wrap); - } - return CRAZY_STATUS_SUCCESS; -} - -crazy_status_t crazy_library_find_symbol(crazy_library_t* library, - const char* symbol_name, - void** symbol_address) { - LibraryView* wrap = reinterpret_cast<LibraryView*>(library); - - // TODO(digit): Handle NULL symbols properly. - LibraryView::SearchResult sym = wrap->LookupSymbol(symbol_name); - *symbol_address = sym.address; - return sym.IsValid() ? CRAZY_STATUS_SUCCESS : CRAZY_STATUS_FAILURE; -} - -crazy_status_t crazy_linker_find_symbol(const char* symbol_name, - void** symbol_address) { - // TODO(digit): Implement this. - return CRAZY_STATUS_FAILURE; -} - -crazy_status_t crazy_library_find_from_address(void* address, - crazy_library_t** library) { - { - ScopedLockedGlobals globals; - LibraryView* wrap = globals->libraries()->FindLibraryForAddress(address); - if (!wrap) - return CRAZY_STATUS_FAILURE; - - wrap->AddRef(); - - *library = reinterpret_cast<crazy_library_t*>(wrap); - return CRAZY_STATUS_SUCCESS; - } -} - -void crazy_library_close(crazy_library_t* library) { - crazy_library_close_with_context(library, NULL); -} - -void crazy_library_close_with_context(crazy_library_t* library, - crazy_context_t* context) { - if (library) { - ScopedLockedGlobals globals; - LibraryView* wrap = reinterpret_cast<LibraryView*>(library); - - globals->libraries()->UnloadLibrary(wrap); - } -} - -} // extern "C"
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.cpp deleted file mode 100644 index 8fd5f68f..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.cpp +++ /dev/null
@@ -1,72 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_ashmem.h" - -#include <fcntl.h> -#include <string.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include "third_party/ashmem/ashmem.h" - -#include "crazy_linker_system.h" -#include "crazy_linker_memory_mapping.h" - -namespace crazy { - -bool AshmemRegion::Allocate(size_t region_size, const char* region_name) { - int fd = ashmem_create_region(region_name, region_size); - if (fd < 0) - return false; - - Reset(fd); - return true; -} - -bool AshmemRegion::SetProtectionFlags(int prot) { - return ashmem_set_prot_region(fd_, prot) == 0; -} - -// static -bool AshmemRegion::CheckFileDescriptorIsReadOnly(int fd) { - const size_t map_size = PAGE_SIZE; - - // First, check that trying to map a page of the region with PROT_WRITE - // fails with EPERM. - MemoryMapping map = - MemoryMapping::Create(nullptr, map_size, MemoryMapping::CAN_WRITE, fd); - if (map.IsValid()) { - LOG("Region could be mapped writable. Should not happen."); - errno = EPERM; - return false; - } - if (errno != EPERM) { - LOG_ERRNO("Region failed writable mapping with unexpected error"); - return false; - } - - // Second, check that it can be mapped PROT_READ, but cannot be remapped - // with PROT_READ | PROT_WRITE through mprotect(). - map = MemoryMapping::Create(nullptr, map_size, MemoryMapping::CAN_READ, fd); - if (!map.IsValid()) { - LOG_ERRNO("Failed to map region read-only"); - return false; - } - if (map.SetProtection(MemoryMapping::CAN_READ_WRITE)) { - LOG_ERRNO("Region could be remapped read-write. Should not happen."); - return false; - } - if (errno != EACCES) { - LOG_ERRNO("Region failed to be remapped read-write with unexpected error"); - return false; - } - - // Everything's good. - return true; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.h b/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.h deleted file mode 100644 index 5e44372..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem.h +++ /dev/null
@@ -1,76 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ASHMEM_H -#define CRAZY_LINKER_ASHMEM_H - -#include <unistd.h> - -namespace crazy { - -// Helper class to hold a scoped ashmem region file descriptor. -class AshmemRegion { - public: - AshmemRegion() : fd_(-1) {} - - ~AshmemRegion() { Reset(-1); } - - AshmemRegion(const AshmemRegion& other) = delete; - AshmemRegion& operator=(const AshmemRegion& other) = delete; - - AshmemRegion(AshmemRegion&& other) noexcept : fd_(other.fd_) { - other.fd_ = -1; - } - - AshmemRegion& operator=(AshmemRegion&& other) noexcept { - if (this != &other) { - fd_ = other.fd_; - other.fd_ = -1; - } - return *this; - } - - int fd() const { return fd_; } - - int Release() { - int ret = fd_; - fd_ = -1; - return ret; - } - - void Reset(int fd) { - if (fd_ != -1) { - ::close(fd_); - } - fd_ = fd; - } - - // Try to allocate a new ashmem region of |region_size| - // (page-aligned) bytes. |region_name| is optional, if not NULL - // it will be the name of the region (only used for debugging). - // Returns true on success, false otherwise. - bool Allocate(size_t region_size, const char* region_name); - - // Change the protection flags of the region. Returns true on success. - // On failure, check errno for an error code. - bool SetProtectionFlags(int prot_flags); - - // Check that the region tied to file descriptor |fd| is properly read-only: - // I.e. that it cannot be mapped writable, or that a read-only mapping cannot - // be mprotect()-ed into MAP_WRITE. On failure, return false and sets errno. - // - // See: - // http://www.cvedetails.com/cve/CVE-2011-1149/ - // And kernel patch at: - // https://android.googlesource.com/kernel/common.git/+/ - // 56f76fc68492af718fff88927bc296635d634b78%5E%21/ - static bool CheckFileDescriptorIsReadOnly(int fd); - - private: - int fd_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ASHMEM_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp deleted file mode 100644 index aeb586d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_ashmem_unittest.cpp +++ /dev/null
@@ -1,37 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_ashmem.h" - -#include <sys/mman.h> - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(AshmemRegion, Construction) { - AshmemRegion region; - EXPECT_EQ(-1, region.fd()); -} - -TEST(AshmemRegion, Allocate) { - AshmemRegion region; - const size_t kSize = 4096 * 10; - EXPECT_TRUE(region.Allocate(kSize, __FUNCTION__)); - void* map = ::mmap(NULL, - kSize, - PROT_READ | PROT_WRITE, - MAP_ANONYMOUS | MAP_SHARED, - region.fd(), - 0); - EXPECT_NE(MAP_FAILED, map); - - for (size_t n = 0; n < kSize; ++n) { - EXPECT_EQ(0, ((char*)map)[n]) << "Checking region[" << n << "]"; - } - - EXPECT_EQ(0, ::munmap(map, kSize)); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_debug.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_debug.cpp deleted file mode 100644 index 5d1ad03..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_debug.cpp +++ /dev/null
@@ -1,113 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_debug.h" - -#include <errno.h> -#include <string.h> - -#ifdef __ANDROID__ -#include <android/log.h> -#endif -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -namespace crazy { - -#if CRAZY_DEBUG - -namespace { - -struct LogBuffer { - LogBuffer() = default; - - void Append(const char* str) { - int avail = kSize - pos_; - int ret = snprintf(buffer_ + pos_, avail, "%s", str); - if (ret >= avail) { - pos_ = kSize - 1; - } else { - pos_ += ret; - } - } - - void AppendV(const char* fmt, va_list args) { - int avail = kSize - pos_; - int ret = vsnprintf(buffer_ + pos_, kSize - pos_, fmt, args); - if (ret >= avail) { - pos_ = kSize - 1; - } else { - pos_ += ret; - } - } - - void Print() { - // First, send to stderr. - fprintf(stderr, "%.*s\n", pos_, buffer_); - -#ifdef __ANDROID__ - // Then to the Android log. - __android_log_write(ANDROID_LOG_INFO, "crazy_linker", buffer_); -#endif - } - - private: - static constexpr int kSize = 4096; - int pos_ = 0; - char buffer_[kSize]; -}; - -} // namespace - -void Log(const char* location, const char* fmt, ...) { - int old_errno = errno; - va_list args; - va_start(args, fmt); - { - LogBuffer log; - log.Append(location); - log.Append(": "); - log.AppendV(fmt, args); - log.Print(); - } - va_end(args); - errno = old_errno; -} - -void LogErrno(const char* location, const char* fmt, ...) { - int old_errno = errno; - va_list args; - va_start(args, fmt); - { - LogBuffer log; - log.Append(location); - log.Append(": "); - log.AppendV(fmt, args); - log.Append(": "); - log.Append(strerror(old_errno)); - log.Print(); - } - va_end(args); - errno = old_errno; -} - -void AssertionFailure(const char* location, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - { - LogBuffer log; - log.Append(location); - log.Append(": "); - log.AppendV(fmt, args); - log.Print(); - } - va_end(args); - exit(1); -} - -#endif // CRAZY_DEBUG - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_debug.h b/third_party/android_crazy_linker/src/src/crazy_linker_debug.h deleted file mode 100644 index 2b2fd30..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_debug.h +++ /dev/null
@@ -1,74 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_DEBUG_H -#define CRAZY_LINKER_DEBUG_H - -// Set CRAZY_DEBUG on the command-line to 1 to enable debugging support. -// This really means adding traces that will be sent to both stderr -// and the logcat during execution. -#ifndef CRAZY_DEBUG -#define CRAZY_DEBUG 0 -#endif - -// Define COMPILE_ASSERT using the implementation described in: -// http://chromium.googlesource.com/chromium/src.git/+/539fc831/base/basictypes.h -#if __cplusplus >= 201103L - -#define COMPILE_ASSERT(expr, msg) static_assert(expr, #msg) - -#else - -template <bool> struct CompileAssert { }; -#define COMPILE_ASSERT(expr, msg) \ - typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] \ - __attribute__((unused)) - -#endif // __cplusplus >= 201103L - -namespace crazy { - -#if CRAZY_DEBUG - -void Log(const char* location, const char* fmt, ...); -void LogErrno(const char* location, const char* fmt, ...); -void AssertionFailure(const char* location, const char* fmt, ...); - -#define LOG(...) ::crazy::Log(__PRETTY_FUNCTION__, __VA_ARGS__) -#define LOG_ERRNO(...) ::crazy::LogErrno(__PRETTY_FUNCTION__, __VA_ARGS__) - -// NOTE: This form of ASSERT() that can be used within constexpr methods, inside -// a comma operation, as in: -// return ASSERT(cond), <result>; -// Which will be equivalent to: -// ASSERT(cond); -// return <result>; -#define ASSERT(cond, ...) \ - (!(cond) ? ::crazy::AssertionFailure(__PRETTY_FUNCTION__, __VA_ARGS__) \ - : (void)0) - -#else // !CRAZY_DEBUG - -#define LOG(...) ((void)0) -#define LOG_ERRNO(...) ((void)0) -#define ASSERT(cond, ...) ((void)(cond)) - -#endif // !CRAZY_DEBUG - -// Conditional logging. -#define LOG_IF(cond, ...) \ - do { \ - if ((cond)) \ - LOG(__VA_ARGS__); \ - } while (0) - -#define LOG_ERRNO_IF(cond, ...) \ - do { \ - if ((cond)) \ - LOG_ERRNO(__VA_ARGS__); \ - } while (0) - -} // namespace crazy - -#endif // CRAZY_LINKER_DEBUG_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_defines.h b/third_party/android_crazy_linker/src/src/crazy_linker_defines.h deleted file mode 100644 index 3a4561c69..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_defines.h +++ /dev/null
@@ -1,10 +0,0 @@ -// Copyright 2017 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Comes from bionic/linker/linker_common_types.h -// Android uses RELA for aarch64 and x86_64. mips64 still uses REL. -#if defined(__aarch64__) || defined(__x86_64__) -// USE_RELA means relocations have explicit addends. -#define USE_RELA 1 -#endif
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.cpp deleted file mode 100644 index 3f787f3..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.cpp +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_hash_table.h" - -#include <string.h> - -namespace crazy { - -// Compute the ELF hash of a given symbol. -static unsigned ElfHash(const char* name) { - const uint8_t* ptr = reinterpret_cast<const uint8_t*>(name); - unsigned h = 0; - while (*ptr) { - h = (h << 4) + *ptr++; - unsigned g = h & 0xf0000000; - h ^= g; - h ^= g >> 24; - } - return h; -} - -void ElfHashTable::Init(uintptr_t dt_elf_hash) { - const ELF::Word* data = reinterpret_cast<const ELF::Word*>(dt_elf_hash); - hash_bucket_size_ = data[0]; - hash_bucket_ = data + 2; - hash_chain_size_ = data[1]; - hash_chain_ = hash_bucket_ + hash_bucket_size_; -} - -bool ElfHashTable::IsValid() const { - return hash_bucket_size_ > 0; -} - -const ELF::Sym* ElfHashTable::LookupByName(const char* symbol_name, - const ELF::Sym* symbol_table, - const char* string_table) const { - unsigned hash = ElfHash(symbol_name); - - for (unsigned n = hash_bucket_[hash % hash_bucket_size_]; n != 0; - n = hash_chain_[n]) { - const ELF::Sym* symbol = &symbol_table[n]; - // Check that the symbol has the appropriate name. - if (!strcmp(string_table + symbol->st_name, symbol_name)) - return symbol; - } - return nullptr; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.h deleted file mode 100644 index 18bd830..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table.h +++ /dev/null
@@ -1,47 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_HASH_TABLE_H -#define CRAZY_LINKER_ELF_HASH_TABLE_H - -#include <stddef.h> -#include "elf_traits.h" - -namespace crazy { - -// Models the hash table used to map symbol names to symbol entries using -// the standard ELF format. -class ElfHashTable { - public: - // Initialize instance. |dt_elf_hash| should be the address that the - // DT_HASH entry points to in the input ELF dynamic section. Call IsValid() - // to determine whether the table was well-formed. - void Init(uintptr_t dt_elf_hash); - - // Returns true iff the content of the table is valid. - bool IsValid() const; - - // Index of the first dynamic symbol within the ELF symbol table. - size_t dyn_symbols_offset() const { return 1; } - - // Number of dynamic symbols in the ELF symbol table. - size_t dyn_symbols_count() const { return hash_chain_size_ - 1; } - - // Lookup |symbol_name| in the table. |symbol_table| should point to the - // ELF symbol table, and |string_table| to the start of its string table. - // Returns nullptr on failure. - const ELF::Sym* LookupByName(const char* symbol_name, - const ELF::Sym* symbol_table, - const char* string_table) const; - - private: - const ELF::Word* hash_bucket_ = nullptr; - size_t hash_bucket_size_ = 0; - const ELF::Word* hash_chain_ = nullptr; - size_t hash_chain_size_ = 0; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_HASH_TABLE_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_test_data.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_test_data.h deleted file mode 100644 index ed09a74..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_test_data.h +++ /dev/null
@@ -1,105 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_HASH_TABLE_TEST_DATA_H -#define CRAZY_LINKER_ELF_HASH_TABLE_TEST_DATA_H - -// clang-format off -// BEGIN_AUTO_GENERATED [generate_test_elf_hash_tables.py] DO NOT EDIT!! -// - -namespace crazy { -namespace testing { - -// SysV ELF hash table: num_buckets=4 num_chain=16 -// -// idx symbol hash bucket chain -// 0 <STN_UNDEF> -// 1 isnan 0070a47e 2 5 -// 2 freelocal 0bc334fc 0 4 -// 3 hcreate_ 0a8b8c4f 3 6 -// 4 getopt_long_onl 0f256dbc 0 12 -// 5 endrpcen 04b96f7e 2 7 -// 6 pthread_mutex_lock 0de6a18b 3 0 -// 7 isinf 0070a046 2 9 -// 8 setrlimi 0cb929a9 1 11 -// 9 getspen 0dcba6de 2 10 -// 10 umoun 007c46be 2 13 -// 11 strsigna 0b99fbe1 1 0 -// 12 listxatt 00abef84 0 15 -// 13 gettyen 0dcbbfde 2 14 -// 14 uselib 07c9c2f2 2 0 -// 15 cfsetispeed 0b63b274 0 0 -// -// Buckets: 2, 8, 1, 3 -// -static const char kTestElfStringTable[145] = { - '\0','i','s','n','a','n','\0','f','r','e','e','l','o','c','a','l','\0','h', - 'c','r','e','a','t','e','_','\0','g','e','t','o','p','t','_','l','o','n', - 'g','_','o','n','l','\0','e','n','d','r','p','c','e','n','\0','p','t','h', - 'r','e','a','d','_','m','u','t','e','x','_','l','o','c','k','\0','i','s', - 'i','n','f','\0','s','e','t','r','l','i','m','i','\0','g','e','t','s','p', - 'e','n','\0','u','m','o','u','n','\0','s','t','r','s','i','g','n','a','\0', - 'l','i','s','t','x','a','t','t','\0','g','e','t','t','y','e','n','\0','u', - 's','e','l','i','b','\0','c','f','s','e','t','i','s','p','e','e','d','\0', - '\0'}; - -// Auto-generated macro used to list all symbols -// XX must be a macro that takes the following parameters: -// name: symbol name (quoted). -// str_offset: symbol name offset in string table -// address: virtual address. -// size: size in bytes -#define LIST_ELF_SYMBOLS_TestElf(XX) \ - XX("isnan", 1, 0x10000, 16) \ - XX("freelocal", 7, 0x10020, 16) \ - XX("hcreate_", 17, 0x10040, 16) \ - XX("getopt_long_onl", 26, 0x10060, 16) \ - XX("endrpcen", 42, 0x10080, 16) \ - XX("pthread_mutex_lock", 51, 0x100a0, 16) \ - XX("isinf", 70, 0x100c0, 16) \ - XX("setrlimi", 76, 0x100e0, 16) \ - XX("getspen", 85, 0x10100, 16) \ - XX("umoun", 93, 0x10120, 16) \ - XX("strsigna", 99, 0x10140, 16) \ - XX("listxatt", 108, 0x10160, 16) \ - XX("gettyen", 117, 0x10180, 16) \ - XX("uselib", 125, 0x101a0, 16) \ - XX("cfsetispeed", 132, 0x101c0, 16) \ - // END OF LIST - -// NOTE: ELF32_Sym and ELF64_Sym have very different layout. -#if UINTPTR_MAX == UINT32_MAX // ELF32_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), (address), (size), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */ }, -#else // ELF64_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */, (address), (size) }, -#endif // !ELF64_Sym -static const ELF::Sym kTestElfSymbolTable[] = { - { 0 }, // ST_UNDEF - LIST_ELF_SYMBOLS_TestElf(DEFINE_ELF_SYMBOL) -}; -#undef DEFINE_ELF_SYMBOL - -static const uint32_t kTestElfHashTable[] = { - 4, // num_buckets - 16, // num_chain - // Buckets - 0x00000002, 0x00000008, 0x00000001, 0x00000003, - // Chain - 0x00000000, 0x00000005, 0x00000004, 0x00000006, 0x0000000c, 0x00000007, - 0x00000000, 0x00000009, 0x0000000b, 0x0000000a, 0x0000000d, 0x00000000, - 0x0000000f, 0x0000000e, 0x00000000, 0x00000000, -}; - -} // namespace testing -} // namespace crazy - -// END_AUTO_GENERATED_CODE [generate_test_elf_hash_tables.py] -// clang-format on - -#endif // CRAZY_LINKER_ELF_HASH_TABLE_TEST_DATA_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_unittest.cpp deleted file mode 100644 index ef97c8e..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_hash_table_unittest.cpp +++ /dev/null
@@ -1,53 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_hash_table.h" - -#include <gtest/gtest.h> -#include "crazy_linker_elf_hash_table_test_data.h" - -#include <stdint.h> - -namespace crazy { -namespace testing { - -TEST(ElfHashTable, LookupByName) { - ElfHashTable table; - table.Init(reinterpret_cast<uintptr_t>(&kTestElfHashTable)); - EXPECT_TRUE(table.IsValid()); - - const ELF::Sym* sym; - -#define CHECK_SYMBOL(name, offset, address, size) \ - sym = table.LookupByName(name, kTestElfSymbolTable, kTestElfStringTable); \ - EXPECT_TRUE(sym) << name; \ - EXPECT_EQ((address), sym->st_value) << name; \ - EXPECT_EQ((size), sym->st_size) << name; - - LIST_ELF_SYMBOLS_TestElf(CHECK_SYMBOL); - -#undef CHECK_SYMBOL - - // Check a few undefined symbols. - EXPECT_FALSE(table.LookupByName("ahahahahah", kTestElfSymbolTable, - kTestElfStringTable)); - EXPECT_FALSE( - table.LookupByName("strsign", kTestElfSymbolTable, kTestElfStringTable)); -} - -TEST(ElfHashTable, DynSymbols) { - ElfHashTable table; - table.Init(reinterpret_cast<uintptr_t>(&kTestElfHashTable)); - EXPECT_TRUE(table.IsValid()); - - const size_t kExpectedOffset = 1U; - const size_t kExpectedCount = - (sizeof(kTestElfSymbolTable) / sizeof(kTestElfSymbolTable[0])) - 1U; - - EXPECT_EQ(kExpectedOffset, table.dyn_symbols_offset()); - EXPECT_EQ(kExpectedCount, table.dyn_symbols_count()); -} - -} // namespace testing -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp deleted file mode 100644 index 604e3df..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.cpp +++ /dev/null
@@ -1,472 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_loader.h" - -#include <limits.h> // For PAGE_SIZE and PAGE_MASK - -#include "crazy_linker_debug.h" -#include "linker_phdr.h" - -#define PAGE_START(x) ((x) & PAGE_MASK) -#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK) -#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE - 1)) - -namespace crazy { - -#define MAYBE_MAP_FLAG(x, from, to) (((x) & (from)) ? (to) : 0) -#define PFLAGS_TO_PROT(x) \ - (MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \ - MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \ - MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE)) - -namespace { - -// A FileDescriptor sub-class that can also avoid closing the descriptor -// on scope exit if DontCloseOnExit() is called. -class LibraryFd : public FileDescriptor { - public: - LibraryFd() = default; - - explicit LibraryFd(int fd) : FileDescriptor(fd) {} - - explicit LibraryFd(const char* path) : FileDescriptor(path) {} - - ~LibraryFd() { - if (!close_on_exit_) - Release(); - } - - LibraryFd(LibraryFd&& other) = default; - LibraryFd& operator=(LibraryFd&& other) = default; - - // Ensure the file descriptor is not closed in the destructor. - void DontCloseOnExit() { close_on_exit_ = false; } - - private: - bool close_on_exit_ = true; -}; - -class InternalElfLoader { - public: - ~InternalElfLoader(); - - bool LoadAt(const LoadParams& params, Error* error); - - // Only call the following functions after a successful LoadAt() call. - - size_t phdr_count() { return phdr_num_; } - ELF::Addr load_start() { return reinterpret_cast<ELF::Addr>(load_start_); } - ELF::Addr load_size() { return load_size_; } - ELF::Addr load_bias() { return load_bias_; } - const ELF::Phdr* loaded_phdr() { return loaded_phdr_; } - - // Return the mapping object covering the reserved address space for this - // ELF object. Caller takes ownership. - MemoryMapping ReleaseMapping() { return std::move(reserved_map_); } - - private: - LibraryFd fd_; - const char* path_ = nullptr; - - ELF::Ehdr header_ = {}; - size_t phdr_num_ = 0; - - void* phdr_mmap_ = nullptr; // temporary copy of the program header. - ELF::Phdr* phdr_table_ = nullptr; - ELF::Addr phdr_size_ = 0; // and its size. - - off_t file_offset_ = 0; - void* load_start_ = nullptr; // First page of reserved address space. - ELF::Addr load_size_ = 0; // Size in bytes of reserved address space. - ELF::Addr load_bias_ = 0; // load_bias, add this value to all "vaddr" - // values in the library to get the corresponding - // memory address. - - const ELF::Phdr* loaded_phdr_ = - nullptr; // points to the loaded program header. - - MemoryMapping reserved_map_; - - // Individual steps used by ::LoadAt() - bool ReadElfHeader(Error* error); - bool ReadProgramHeader(Error* error); - bool ReserveAddressSpace(const LoadParams& params, Error* error); - bool LoadSegments(Error* error); - bool FindPhdr(Error* error); - bool CheckPhdr(ELF::Addr, Error* error); -}; - -InternalElfLoader::~InternalElfLoader() { - if (phdr_mmap_) { - // Deallocate the temporary program header copy. - munmap(phdr_mmap_, phdr_size_); - } -} - -bool InternalElfLoader::LoadAt(const LoadParams& params, Error* error) { - const char* lib_path = params.library_path.c_str(); - LOG("lib_path='%s', file_fd=%d, file_offset=%p, load_address=%lx " - "reserved_size=%lx reserved_load_fallback=%s", - lib_path, params.library_fd, params.library_offset, - static_cast<unsigned long>(params.wanted_address), - static_cast<unsigned long>(params.reserved_size), - params.reserved_load_fallback ? "true" : "false"); - - // Check that the load address is properly page-aligned. - uintptr_t wanted_address = params.wanted_address; - if (wanted_address != PAGE_START(wanted_address)) { - error->Format("Load address is not page aligned (%08x)", wanted_address); - return false; - } - - if (params.reserved_size != 0) { - if (!wanted_address) { - error->Format("Reserved size 0x%08lx has not reserved address", - static_cast<unsigned long>(params.reserved_size)); - return false; - } - } - - // Check that the file offset is also properly page-aligned. - // PAGE_START() can't be used here due to the compiler complaining about - // comparing signed (off_t) and unsigned (size_t) values. - off_t file_offset = params.library_offset; - if ((file_offset & static_cast<off_t>(PAGE_SIZE - 1)) != 0) { - error->Format("File offset is not page aligned (%08lx)", - static_cast<unsigned long>(file_offset)); - return false; - } - file_offset_ = file_offset; - - // Open the file. - if (params.library_fd >= 0) { - fd_ = LibraryFd(params.library_fd); - fd_.DontCloseOnExit(); - } else { - if (!fd_.OpenReadOnly(lib_path)) { - error->Format("Can't open file: %s", strerror(errno)); - return false; - } - } - - if (file_offset && fd_.SeekTo(file_offset) < 0) { - error->Format( - "Can't seek to file offset %08x: %s", file_offset, strerror(errno)); - return false; - } - - path_ = lib_path; - - if (!ReadElfHeader(error) || !ReadProgramHeader(error) || - !ReserveAddressSpace(params, error) || !LoadSegments(error) || - !FindPhdr(error)) { - reserved_map_.Deallocate(); - return false; - } - return true; -} - -bool InternalElfLoader::ReadElfHeader(Error* error) { - int ret = fd_.Read(&header_, sizeof(header_)); - if (ret < 0) { - error->Format("Can't read file: %s", strerror(errno)); - return false; - } - if (ret != static_cast<int>(sizeof(header_))) { - error->Set("File too small to be ELF"); - return false; - } - - if (memcmp(header_.e_ident, ELFMAG, SELFMAG) != 0) { - error->Set("Bad ELF magic"); - return false; - } - - if (header_.e_ident[EI_CLASS] != ELF::kElfClass) { - error->Format("Not a %d-bit class: %d", - ELF::kElfBits, - header_.e_ident[EI_CLASS]); - return false; - } - - if (header_.e_ident[EI_DATA] != ELFDATA2LSB) { - error->Format("Not little-endian class: %d", header_.e_ident[EI_DATA]); - return false; - } - - if (header_.e_type != ET_DYN) { - error->Format("Not a shared library type: %d", header_.e_type); - return false; - } - - if (header_.e_version != EV_CURRENT) { - error->Format("Unexpected ELF version: %d", header_.e_version); - return false; - } - - if (header_.e_machine != ELF_MACHINE) { - error->Format("Unexpected ELF machine type: %d", header_.e_machine); - return false; - } - - return true; -} - -// Loads the program header table from an ELF file into a read-only private -// anonymous mmap-ed block. -bool InternalElfLoader::ReadProgramHeader(Error* error) { - phdr_num_ = header_.e_phnum; - - // Like the kernel, only accept program header tables smaller than 64 KB. - if (phdr_num_ < 1 || phdr_num_ > 65536 / sizeof(ELF::Phdr)) { - error->Format("Invalid program header count: %d", phdr_num_); - return false; - } - - ELF::Addr page_min = PAGE_START(header_.e_phoff); - ELF::Addr page_max = - PAGE_END(header_.e_phoff + (phdr_num_ * sizeof(ELF::Phdr))); - ELF::Addr page_offset = PAGE_OFFSET(header_.e_phoff); - - phdr_size_ = page_max - page_min; - - void* mmap_result = fd_.Map( - NULL, phdr_size_, PROT_READ, MAP_PRIVATE, page_min + file_offset_); - if (!mmap_result) { - error->Format("Phdr mmap failed: %s", strerror(errno)); - return false; - } - - phdr_mmap_ = mmap_result; - phdr_table_ = reinterpret_cast<ELF::Phdr*>( - reinterpret_cast<char*>(mmap_result) + page_offset); - return true; -} - -// Reserve a virtual address range big enough to hold all loadable -// segments of a program header table. This is done by creating a -// private anonymous mmap() with PROT_NONE. -// -// This will use the wanted_load_address_ value. Fails if the requested -// address range cannot be reserved. Typically this would be because -// it overlaps an existing, possibly system, mapping. -bool InternalElfLoader::ReserveAddressSpace(const LoadParams& params, - Error* error) { - ELF::Addr min_vaddr; - load_size_ = - phdr_table_get_load_size(phdr_table_, phdr_num_, &min_vaddr, NULL); - if (load_size_ == 0) { - error->Set("No loadable segments"); - return false; - } - - void* addr = nullptr; - int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; - - // Support loading at a fixed address. - if (params.wanted_address) { - addr = reinterpret_cast<void*>(params.wanted_address); - if (!params.reserved_load_fallback) { - mmap_flags |= MAP_FIXED; - } - } - - void* start = reinterpret_cast<void*>(params.wanted_address); - size_t reserved_size = params.reserved_size; - - if (reserved_size > 0 && reserved_size < load_size_ && - params.reserved_load_fallback) { - LOG("Reserved size is too small (%ld < %ld), allocating new mapping!", - static_cast<unsigned long>(reserved_size), - static_cast<unsigned long>(load_size_)); - reserved_size = 0; - addr = nullptr; - mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; - } - - if (!reserved_size) { - // Reserve the area ourselves. - reserved_size = load_size_; - LOG("Trying to reserve memory address=%p size=%lu (0x%lx)", addr, - static_cast<unsigned long>(load_size_), - static_cast<unsigned long>(load_size_)); - - start = mmap(addr, reserved_size, PROT_NONE, mmap_flags, -1, 0); - if (start == MAP_FAILED) { - error->Format("Could not reserve %lu bytes of address space", - static_cast<unsigned long>(reserved_size)); - return false; - } - if (addr && start != addr) { - error->Format("Could not map at %p requested, backing out", addr); - munmap(start, reserved_size); - return false; - } - // Take ownership of the mapping here. - reserved_map_ = MemoryMapping(start, reserved_size); - } else if (reserved_size < load_size_) { - error->Format("Reserved map size is too small 0x%lx (0x%lx required)", - static_cast<unsigned long>(reserved_size), - static_cast<unsigned long>(load_size_)); - return false; - } else { - LOG("Using client-allocated mapping!"); - } - - load_start_ = start; - load_bias_ = reinterpret_cast<ELF::Addr>(load_start_) - min_vaddr; - - LOG("Reserved memory address=%p, size=%lu (0x%lx), bias=%lu (0x%lx)", - load_start_, static_cast<unsigned long>(load_size_), - static_cast<unsigned long>(load_size_), - static_cast<unsigned long>(load_bias_), - static_cast<unsigned long>(load_bias_)); - - return true; -} - -// Returns the address of the program header table as it appears in the loaded -// segments in memory. This is in contrast with 'phdr_table_' which -// is temporary and will be released before the library is relocated. -bool InternalElfLoader::FindPhdr(Error* error) { - const ELF::Phdr* phdr_limit = phdr_table_ + phdr_num_; - - // If there is a PT_PHDR, use it directly. - for (const ELF::Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { - if (phdr->p_type == PT_PHDR) { - return CheckPhdr(load_bias_ + phdr->p_vaddr, error); - } - } - - // Otherwise, check the first loadable segment. If its file offset - // is 0, it starts with the ELF header, and we can trivially find the - // loaded program header from it. - for (const ELF::Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { - if (phdr->p_type == PT_LOAD) { - if (phdr->p_offset == 0) { - ELF::Addr elf_addr = load_bias_ + phdr->p_vaddr; - const ELF::Ehdr* ehdr = (const ELF::Ehdr*)(void*)elf_addr; - ELF::Addr offset = ehdr->e_phoff; - return CheckPhdr((ELF::Addr)ehdr + offset, error); - } - break; - } - } - - error->Set("Can't find loaded program header"); - return false; -} - -// Ensures that our program header is actually within a loadable -// segment. This should help catch badly-formed ELF files that -// would cause the linker to crash later when trying to access it. -bool InternalElfLoader::CheckPhdr(ELF::Addr loaded, Error* error) { - const ELF::Phdr* phdr_limit = phdr_table_ + phdr_num_; - ELF::Addr loaded_end = loaded + (phdr_num_ * sizeof(ELF::Phdr)); - for (ELF::Phdr* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { - if (phdr->p_type != PT_LOAD) { - continue; - } - ELF::Addr seg_start = phdr->p_vaddr + load_bias_; - ELF::Addr seg_end = phdr->p_filesz + seg_start; - if (seg_start <= loaded && loaded_end <= seg_end) { - loaded_phdr_ = reinterpret_cast<const ELF::Phdr*>(loaded); - return true; - } - } - error->Format("Loaded program header %x not in loadable segment", loaded); - return false; -} - -// Map all loadable segments in process' address space. -// This assumes you already called phdr_table_reserve_memory to -// reserve the address space range for the library. -bool InternalElfLoader::LoadSegments(Error* error) { - for (size_t i = 0; i < phdr_num_; ++i) { - const ELF::Phdr* phdr = &phdr_table_[i]; - - if (phdr->p_type != PT_LOAD) { - continue; - } - - // Segment addresses in memory. - ELF::Addr seg_start = phdr->p_vaddr + load_bias_; - ELF::Addr seg_end = seg_start + phdr->p_memsz; - - ELF::Addr seg_page_start = PAGE_START(seg_start); - ELF::Addr seg_page_end = PAGE_END(seg_end); - - ELF::Addr seg_file_end = seg_start + phdr->p_filesz; - - // File offsets. - ELF::Addr file_start = phdr->p_offset; - ELF::Addr file_end = file_start + phdr->p_filesz; - - ELF::Addr file_page_start = PAGE_START(file_start); - ELF::Addr file_length = file_end - file_page_start; - - LOG("file_offset=%p file_length=%p start_address=%p end_address=%p", - file_offset_ + file_page_start, file_length, seg_page_start, - seg_page_start + PAGE_END(file_length)); - - if (file_length != 0) { - const int prot_flags = PFLAGS_TO_PROT(phdr->p_flags); - void* seg_addr = fd_.Map((void*)seg_page_start, - file_length, - prot_flags, - MAP_FIXED | MAP_PRIVATE, - file_page_start + file_offset_); - if (!seg_addr) { - error->Format("Could not map segment %d: %s", i, strerror(errno)); - return false; - } - } - - // if the segment is writable, and does not end on a page boundary, - // zero-fill it until the page limit. - if ((phdr->p_flags & PF_W) != 0 && PAGE_OFFSET(seg_file_end) > 0) { - memset((void*)seg_file_end, 0, PAGE_SIZE - PAGE_OFFSET(seg_file_end)); - } - - seg_file_end = PAGE_END(seg_file_end); - - // seg_file_end is now the first page address after the file - // content. If seg_end is larger, we need to zero anything - // between them. This is done by using a private anonymous - // map for all extra pages. - if (seg_page_end > seg_file_end) { - void* zeromap = mmap((void*)seg_file_end, - seg_page_end - seg_file_end, - PFLAGS_TO_PROT(phdr->p_flags), - MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, - -1, - 0); - if (zeromap == MAP_FAILED) { - error->Format("Could not zero-fill gap: %s", strerror(errno)); - return false; - } - } - } - return true; -} - -} // namespace - -// static -ElfLoader::Result ElfLoader::LoadAt(const LoadParams& params, Error* error) { - InternalElfLoader loader; - Result result; - if (loader.LoadAt(params, error)) { - result.load_start = reinterpret_cast<ELF::Addr>(loader.load_start()); - result.load_size = loader.load_size(); - result.load_bias = loader.load_bias(); - result.phdr = loader.loaded_phdr(); - result.phdr_count = loader.phdr_count(); - result.reserved_mapping = loader.ReleaseMapping(); - } - return result; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.h deleted file mode 100644 index 590045c..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_loader.h +++ /dev/null
@@ -1,44 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_LOADER_H -#define CRAZY_LINKER_ELF_LOADER_H - -#include "crazy_linker_error.h" -#include "crazy_linker_load_params.h" -#include "crazy_linker_memory_mapping.h" -#include "crazy_linker_system.h" // For ScopedFileDescriptor -#include "elf_traits.h" - -namespace crazy { - -// Helper class used to load an ELF binary in memory. -// -// Note that this doesn't not perform any relocation, the purpose -// of this class is strictly to map all loadable segments from the -// file to their correct location. -// -class ElfLoader { - public: - // Result of the LoadAt method. In case of failure, an invalid instance - // will be returned. - struct Result { - ELF::Addr load_start = 0; - ELF::Addr load_size = 0; - ELF::Addr load_bias = 0; - const ELF::Phdr* phdr = nullptr; - size_t phdr_count = 0; - MemoryMapping reserved_mapping; - - constexpr bool IsValid() const { return this->load_start != 0; } - }; - - // Try to load a library at a given address. On failure, return an - // invalid Result instance, and sets |*error|. - static Result LoadAt(const LoadParams& params, Error* error); -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_LOADER_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp deleted file mode 100644 index f4163736..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp +++ /dev/null
@@ -1,1086 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_relocations.h" - -#include <assert.h> -#include <errno.h> -#include <memory> - -#include "crazy_linker_debug.h" -#include "crazy_linker_elf_symbols.h" -#include "crazy_linker_elf_view.h" -#include "crazy_linker_error.h" -#include "crazy_linker_system.h" -#include "crazy_linker_util.h" -#include "linker_phdr.h" -#include "linker_reloc_iterators.h" -#include "linker_sleb128.h" - -#define DEBUG_RELOCATIONS 0 - -#define RLOG(...) LOG_IF(DEBUG_RELOCATIONS, __VA_ARGS__) -#define RLOG_ERRNO(...) LOG_ERRNO_IF(DEBUG_RELOCATIONS, __VA_ARGS__) - -#ifndef DF_SYMBOLIC -#define DF_SYMBOLIC 2 -#endif - -#ifndef DF_TEXTREL -#define DF_TEXTREL 4 -#endif - -#ifndef DT_FLAGS -#define DT_FLAGS 30 -#endif - -// Extension dynamic tags for Android packed relocations. -#ifndef DT_LOOS -#define DT_LOOS 0x6000000d -#endif -#ifndef DT_ANDROID_REL -#define DT_ANDROID_REL (DT_LOOS + 2) -#endif -#ifndef DT_ANDROID_RELSZ -#define DT_ANDROID_RELSZ (DT_LOOS + 3) -#endif -#ifndef DT_ANDROID_RELA -#define DT_ANDROID_RELA (DT_LOOS + 4) -#endif -#ifndef DT_ANDROID_RELASZ -#define DT_ANDROID_RELASZ (DT_LOOS + 5) -#endif - -// Careful: the Android <elf.h> defines these with value corresponding to -// DT_ANDROID_RELRxx below, so we undefine them, just in case. The DT_RELRxx -// values corresponds to what lld generates by default with -// '--pack-dyn-relocs=relr'. -// -// For more details, see https://reviews.llvm.org/D48247 -#undef DT_RELR -#define DT_RELR 0x24 -#undef DT_RELRSZ -#define DT_RELRSZ 0x23 -#undef DT_RELRENT -#define DT_RELRENT 0x25 - -// NOTE: The Android system linker only supports the DT_ANDROID_RELRxx entries -// but their content is exactly equivalent to the DT_RELRxx ones. One can tell -// lld to use the Android values with '--use-android-relr-tags'. -// -// The crazy linker supports both format, because it's essentially free :) -#ifndef DT_ANDROID_RELR -#define DT_ANDROID_RELR 0x6fffe000 -#endif -#ifndef DT_ANDROID_RELRSZ -#define DT_ANDROID_RELRSZ 0x6fffe001 -#endif -#ifndef DT_ANDROID_RELRENT -#define DT_ANDROID_RELRENT 0x6fffe003 -#endif - -// Processor-specific relocation types supported by the linker. -#ifdef __arm__ - -/* arm32 relocations */ -#define R_ARM_ABS32 2 -#define R_ARM_REL32 3 -#define R_ARM_GLOB_DAT 21 -#define R_ARM_JUMP_SLOT 22 -#define R_ARM_COPY 20 -#define R_ARM_RELATIVE 23 - -#define RELATIVE_RELOCATION_CODE R_ARM_RELATIVE - -#endif // __arm__ - -#ifdef __aarch64__ - -/* arm64 relocations */ -#define R_AARCH64_ABS64 257 -#define R_AARCH64_COPY 1024 -#define R_AARCH64_GLOB_DAT 1025 -#define R_AARCH64_JUMP_SLOT 1026 -#define R_AARCH64_RELATIVE 1027 - -#define RELATIVE_RELOCATION_CODE R_AARCH64_RELATIVE - -#endif // __aarch64__ - -#ifdef __i386__ - -/* i386 relocations */ -#define R_386_32 1 -#define R_386_PC32 2 -#define R_386_GLOB_DAT 6 -#define R_386_JMP_SLOT 7 -#define R_386_RELATIVE 8 - -#endif // __i386__ - -#ifdef __x86_64__ - -/* x86_64 relocations */ -#define R_X86_64_64 1 -#define R_X86_64_PC32 2 -#define R_X86_64_GLOB_DAT 6 -#define R_X86_64_JMP_SLOT 7 -#define R_X86_64_RELATIVE 8 - -#endif // __x86_64__ - -namespace crazy { - -namespace { - -// List of known relocation types the relocator knows about. -enum RelocationType { - RELOCATION_TYPE_UNKNOWN = 0, - RELOCATION_TYPE_ABSOLUTE = 1, - RELOCATION_TYPE_RELATIVE = 2, - RELOCATION_TYPE_PC_RELATIVE = 3, - RELOCATION_TYPE_COPY = 4, -}; - -// Convert an ELF relocation type info a RelocationType value. -RelocationType GetRelocationType(ELF::Word r_type) { - switch (r_type) { -#ifdef __arm__ - case R_ARM_JUMP_SLOT: - case R_ARM_GLOB_DAT: - case R_ARM_ABS32: - return RELOCATION_TYPE_ABSOLUTE; - - case R_ARM_REL32: - case R_ARM_RELATIVE: - return RELOCATION_TYPE_RELATIVE; - - case R_ARM_COPY: - return RELOCATION_TYPE_COPY; -#endif - -#ifdef __aarch64__ - case R_AARCH64_JUMP_SLOT: - case R_AARCH64_GLOB_DAT: - case R_AARCH64_ABS64: - return RELOCATION_TYPE_ABSOLUTE; - - case R_AARCH64_RELATIVE: - return RELOCATION_TYPE_RELATIVE; - - case R_AARCH64_COPY: - return RELOCATION_TYPE_COPY; -#endif - -#ifdef __i386__ - case R_386_JMP_SLOT: - case R_386_GLOB_DAT: - case R_386_32: - return RELOCATION_TYPE_ABSOLUTE; - - case R_386_RELATIVE: - return RELOCATION_TYPE_RELATIVE; - - case R_386_PC32: - return RELOCATION_TYPE_PC_RELATIVE; -#endif - -#ifdef __x86_64__ - case R_X86_64_JMP_SLOT: - case R_X86_64_GLOB_DAT: - case R_X86_64_64: - return RELOCATION_TYPE_ABSOLUTE; - - case R_X86_64_RELATIVE: - return RELOCATION_TYPE_RELATIVE; - - case R_X86_64_PC32: - return RELOCATION_TYPE_PC_RELATIVE; -#endif - -#ifdef __mips__ - case R_MIPS_REL32: - return RELOCATION_TYPE_RELATIVE; -#endif - - default: - return RELOCATION_TYPE_UNKNOWN; - } -} - -} // namespace - -ElfRelocations::ElfRelocations() = default; - -bool ElfRelocations::Init(const ElfView* view, Error* error) { - // Save these for later. - phdr_ = view->phdr(); - phdr_count_ = view->phdr_count(); - load_bias_ = view->load_bias(); - - // Parse the dynamic table. - ElfView::DynamicIterator dyn(view); - for (; dyn.HasNext(); dyn.GetNext()) { - ELF::Addr dyn_value = dyn.GetValue(); - uintptr_t dyn_addr = dyn.GetAddress(view->load_bias()); - - const ELF::Addr tag = dyn.GetTag(); - switch (tag) { -#if defined(USE_RELA) - case DT_REL: - case DT_RELSZ: - case DT_ANDROID_REL: - case DT_ANDROID_RELSZ: -#else - case DT_RELA: - case DT_RELASZ: - case DT_ANDROID_RELA: - case DT_ANDROID_RELASZ: -#endif - LOG("unsupported relocation type"); - *error = "Relocation for wrong architecture"; - return false; - case DT_PLTREL: - RLOG(" DT_PLTREL value=%d\n", dyn_value); -#if defined(USE_RELA) - if (dyn_value != DT_RELA) { - RLOG("unsupported DT_PLTREL in \"%s\"; expected DT_RELA"); - return false; - } -#else - if (dyn_value != DT_REL) { - RLOG("unsupported DT_PLTREL in \"%s\"; expected DT_REL"); - return false; - } -#endif - break; - case DT_JMPREL: - RLOG(" DT_JMPREL addr=%p\n", dyn_addr - load_bias_); - plt_relocations_ = dyn_addr; - break; - case DT_PLTRELSZ: - plt_relocations_size_ = dyn_value; - RLOG(" DT_PLTRELSZ size=%d\n", dyn_value); - break; -#if defined(USE_RELA) - case DT_RELA: -#else - case DT_REL: -#endif - RLOG(" %s addr=%p\n", (tag == DT_RELA) ? "DT_RELA" : "DT_REL", - dyn_addr - load_bias_); - if (relocations_) { - *error = "Unsupported DT_RELA/DT_REL combination in dynamic section"; - return false; - } - relocations_ = dyn_addr; - break; -#if defined(USE_RELA) - case DT_RELASZ: -#else - case DT_RELSZ: -#endif - RLOG(" %s size=%d\n", (tag == DT_RELASZ) ? "DT_RELASZ" : "DT_RELSZ", - dyn_value); - relocations_size_ = dyn_value; - break; -#if defined(USE_RELA) - case DT_ANDROID_RELA: -#else - case DT_ANDROID_REL: -#endif - RLOG(" %s addr=%p\n", - (tag == DT_ANDROID_REL) ? "DT_ANDROID_REL" : "DT_ANDROID_RELA", - dyn_addr - load_bias_); - if (android_relocations_) { - *error = "Multiple DT_ANDROID_* sections defined."; - return false; - } - android_relocations_ = reinterpret_cast<uint8_t*>(dyn_addr); - break; -#if defined(USE_RELA) - case DT_ANDROID_RELASZ: -#else - case DT_ANDROID_RELSZ: -#endif - RLOG(" %s size=%d\n", - (tag == DT_ANDROID_RELASZ) ? "DT_ANDROID_RELASZ" - : "DT_ANDROID_RELSZ", - dyn_value); - android_relocations_size_ = dyn_value; - break; - case DT_RELR: - case DT_ANDROID_RELR: - RLOG(" DT_RELR\n"); - relr_.SetAddress(dyn_addr); - break; - case DT_ANDROID_RELRSZ: - case DT_RELRSZ: - relr_.SetSize(dyn_value); - RLOG(" DT_RELSZ size=%d\n", dyn_value); - break; - case DT_RELRENT: - case DT_ANDROID_RELRENT: - if (dyn_value != sizeof(ELF::Relr)) { - RLOG("Invalid RELR entry size (%d, expected %d)", - static_cast<int>(dyn_value), - static_cast<int>(sizeof(ELF::Relr))); - *error = "Invalid DT_RELRENT value"; - return false; - } - break; - case DT_PLTGOT: - // Only used on MIPS currently. Could also be used on other platforms - // when lazy binding (i.e. RTLD_LAZY) is implemented. - RLOG(" DT_PLTGOT addr=%p\n", dyn_addr - load_bias_); - plt_got_ = reinterpret_cast<ELF::Addr*>(dyn_addr); - break; - case DT_TEXTREL: - RLOG(" DT_TEXTREL\n"); - has_text_relocations_ = true; - break; - case DT_SYMBOLIC: - RLOG(" DT_SYMBOLIC\n"); - has_symbolic_ = true; - break; - case DT_FLAGS: - if (dyn_value & DF_TEXTREL) - has_text_relocations_ = true; - if (dyn_value & DF_SYMBOLIC) - has_symbolic_ = true; - RLOG(" DT_FLAGS has_text_relocations=%s has_symbolic=%s\n", - has_text_relocations_ ? "true" : "false", - has_symbolic_ ? "true" : "false"); - break; -#if defined(__mips__) - case DT_MIPS_SYMTABNO: - RLOG(" DT_MIPS_SYMTABNO value=%d\n", dyn_value); - mips_symtab_count_ = dyn_value; - break; - - case DT_MIPS_LOCAL_GOTNO: - RLOG(" DT_MIPS_LOCAL_GOTNO value=%d\n", dyn_value); - mips_local_got_count_ = dyn_value; - break; - - case DT_MIPS_GOTSYM: - RLOG(" DT_MIPS_GOTSYM value=%d\n", dyn_value); - mips_gotsym_ = dyn_value; - break; -#endif - default: - ; - } - } - - return true; -} - -bool ElfRelocations::ApplyAll(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error) { - LOG("Enter"); - - if (has_text_relocations_) { - if (phdr_table_unprotect_segments(phdr_, phdr_count_, load_bias_) < 0) { - error->Format("Can't unprotect loadable segments: %s", strerror(errno)); - return false; - } - } - - if (!ApplyAndroidRelocations(symbols, resolver, error)) - return false; - - relr_.Apply(load_bias_); - - if (!ApplyRelocs(reinterpret_cast<rel_t*>(relocations_), - relocations_size_ / sizeof(rel_t), symbols, resolver, error)) - return false; - if (!ApplyRelocs(reinterpret_cast<rel_t*>(plt_relocations_), - plt_relocations_size_ / sizeof(rel_t), symbols, resolver, - error)) - return false; - -#ifdef __mips__ - if (!RelocateMipsGot(symbols, resolver, error)) - return false; -#endif - - if (has_text_relocations_) { - if (phdr_table_protect_segments(phdr_, phdr_count_, load_bias_) < 0) { - error->Format("Can't reprotect loadable segments: %s", strerror(errno)); - return false; - } - } - - LOG("Done"); - return true; -} - -// Helper class for Android packed relocations. Encapsulates the packing -// flags used by Android for packed relocation groups. -class AndroidPackedRelocationGroupFlags { - public: - explicit AndroidPackedRelocationGroupFlags(size_t flags) : flags_(flags) { } - - bool is_relocation_grouped_by_info() const { - return hasFlag(kRelocationGroupedByInfoFlag); - } - bool is_relocation_grouped_by_offset_delta() const { - return hasFlag(kRelocationGroupedByOffsetDeltaFlag); - } - bool is_relocation_grouped_by_addend() const { - return hasFlag(kRelocationGroupedByAddendFlag); - } - bool is_relocation_group_has_addend() const { - return hasFlag(kRelocationGroupHasAddendFlag); - } - - private: - bool hasFlag(size_t flag) const { return (flags_ & flag) != 0; } - - static const size_t kRelocationGroupedByInfoFlag = 1 << 0; - static const size_t kRelocationGroupedByOffsetDeltaFlag = 1 << 1; - static const size_t kRelocationGroupedByAddendFlag = 1 << 2; - static const size_t kRelocationGroupHasAddendFlag = 1 << 3; - - const size_t flags_; -}; - -template <typename ElfRelIteratorT> -bool ElfRelocations::ForEachAndroidRelocationHelper( - ElfRelIteratorT&& rel_iterator, - RelocationHandler handler, - void* opaque) { - size_t relocations_handled = 0; - while (rel_iterator.has_next()) { - const auto rel = rel_iterator.next(); - if (rel == nullptr) { - LOG("failed to parse relocation %d", relocations_handled); - return false; - } - // Pass the relocation to the supplied handler function. If the handler - // returns false we view this as failure and return false to our caller. - if (!handler(this, rel, opaque)) { - LOG("failed handling relocation %d", relocations_handled); - return false; - } - relocations_handled++; - } - LOG("relocations_handled=%d", relocations_handled); - return true; -} - -bool ElfRelocations::ForEachAndroidRelocation(RelocationHandler handler, - void* opaque) { - // Skip over the "APS2" signature. - const uint8_t* packed_relocs = android_relocations_ + 4; - const size_t packed_relocs_size = android_relocations_size_ - 4; - return ForEachAndroidRelocationHelper( - packed_reloc_iterator<sleb128_decoder>( - sleb128_decoder(packed_relocs, packed_relocs_size)), - handler, opaque); -} - -namespace { - -// Validate the Android packed relocations signature. -bool IsValidAndroidPackedRelocations(const uint8_t* android_relocations, - size_t android_relocations_size) { - if (android_relocations_size < 4) - return false; - - // Check for an initial APS2 Android packed relocations header. - return (android_relocations[0] == 'A' && - android_relocations[1] == 'P' && - android_relocations[2] == 'S' && - android_relocations[3] == '2'); -} - -} // namespace - -// Args for ApplyAndroidRelocation handler function. -struct ApplyAndroidRelocationArgs { - const ElfSymbols* symbols; - ElfRelocations::SymbolResolver* resolver; - Error* error; -}; - -// Static ForEachAndroidRelocation() handler. -bool ElfRelocations::ApplyAndroidRelocation(ElfRelocations* relocations, - const rel_t* relocation, - void* opaque) { - // Unpack args from opaque. - ApplyAndroidRelocationArgs* args = - reinterpret_cast<ApplyAndroidRelocationArgs*>(opaque); - const ElfSymbols* symbols = args->symbols; - ElfRelocations::SymbolResolver* resolver = args->resolver; - Error* error = args->error; - - return relocations->ApplyReloc(relocation, symbols, resolver, error); -} - -bool ElfRelocations::ApplyAndroidRelocations(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error) { - if (!android_relocations_) - return true; - - if (!IsValidAndroidPackedRelocations(android_relocations_, - android_relocations_size_)) - return false; - - ApplyAndroidRelocationArgs args; - args.symbols = symbols; - args.resolver = resolver; - args.error = error; - return ForEachAndroidRelocation(&ApplyAndroidRelocation, &args); -} - -#if defined(USE_RELA) -bool ElfRelocations::ApplyResolvedReloc(const ELF::Rela* rela, - ELF::Addr sym_addr, - bool resolved CRAZY_UNUSED, - Error* error) { - const ELF::Word rela_type = ELF_R_TYPE(rela->r_info); - const ELF::Word CRAZY_UNUSED rela_symbol = ELF_R_SYM(rela->r_info); - const ELF::Sword CRAZY_UNUSED addend = rela->r_addend; - - const ELF::Addr reloc = static_cast<ELF::Addr>(rela->r_offset + load_bias_); - - RLOG(" rela reloc=%p offset=%p type=%d addend=%p\n", - reloc, - rela->r_offset, - rela_type, - addend); - - // Apply the relocation. - ELF::Addr* CRAZY_UNUSED target = reinterpret_cast<ELF::Addr*>(reloc); - switch (rela_type) { -#ifdef __aarch64__ - case R_AARCH64_JUMP_SLOT: - RLOG(" R_AARCH64_JUMP_SLOT target=%p addr=%p\n", - target, - sym_addr + addend); - *target = sym_addr + addend; - break; - - case R_AARCH64_GLOB_DAT: - RLOG(" R_AARCH64_GLOB_DAT target=%p addr=%p\n", - target, - sym_addr + addend); - *target = sym_addr + addend; - break; - - case R_AARCH64_ABS64: - RLOG(" R_AARCH64_ABS64 target=%p (%p) addr=%p\n", - target, - *target, - sym_addr + addend); - *target += sym_addr + addend; - break; - - case R_AARCH64_RELATIVE: - RLOG(" R_AARCH64_RELATIVE target=%p (%p) bias=%p\n", - target, - *target, - load_bias_ + addend); - if (__builtin_expect(rela_symbol, 0)) { - *error = "Invalid relative relocation with symbol"; - return false; - } - *target = load_bias_ + addend; - break; - - case R_AARCH64_COPY: - // NOTE: These relocations are forbidden in shared libraries. - RLOG(" R_AARCH64_COPY\n"); - *error = "Invalid R_AARCH64_COPY relocation in shared library"; - return false; -#endif // __aarch64__ - -#ifdef __x86_64__ - case R_X86_64_JMP_SLOT: - *target = sym_addr + addend; - break; - - case R_X86_64_GLOB_DAT: - *target = sym_addr + addend; - break; - - case R_X86_64_RELATIVE: - if (rela_symbol) { - *error = "Invalid relative relocation with symbol"; - return false; - } - *target = load_bias_ + addend; - break; - - case R_X86_64_64: - *target = sym_addr + addend; - break; - - case R_X86_64_PC32: - *target = sym_addr + (addend - reloc); - break; -#endif // __x86_64__ - - default: - error->Format("Invalid relocation type (%d)", rela_type); - return false; - } - - return true; -} - -#else - -bool ElfRelocations::ApplyResolvedReloc(const ELF::Rel* rel, - ELF::Addr sym_addr, - bool resolved CRAZY_UNUSED, - Error* error) { - const ELF::Word rel_type = ELF_R_TYPE(rel->r_info); - const ELF::Word CRAZY_UNUSED rel_symbol = ELF_R_SYM(rel->r_info); - - const ELF::Addr reloc = static_cast<ELF::Addr>(rel->r_offset + load_bias_); - - RLOG(" rel reloc=%p offset=%p type=%d\n", reloc, rel->r_offset, rel_type); - - // Apply the relocation. - ELF::Addr* CRAZY_UNUSED target = reinterpret_cast<ELF::Addr*>(reloc); - switch (rel_type) { -#ifdef __arm__ - case R_ARM_JUMP_SLOT: - RLOG(" R_ARM_JUMP_SLOT target=%p addr=%p\n", target, sym_addr); - *target = sym_addr; - break; - - case R_ARM_GLOB_DAT: - RLOG(" R_ARM_GLOB_DAT target=%p addr=%p\n", target, sym_addr); - *target = sym_addr; - break; - - case R_ARM_ABS32: - RLOG(" R_ARM_ABS32 target=%p (%p) addr=%p\n", - target, - *target, - sym_addr); - *target += sym_addr; - break; - - case R_ARM_REL32: - RLOG(" R_ARM_REL32 target=%p (%p) addr=%p offset=%p\n", - target, - *target, - sym_addr, - rel->r_offset); - *target += sym_addr - rel->r_offset; - break; - - case R_ARM_RELATIVE: - RLOG(" R_ARM_RELATIVE target=%p (%p) bias=%p\n", - target, - *target, - load_bias_); - if (__builtin_expect(rel_symbol, 0)) { - *error = "Invalid relative relocation with symbol"; - return false; - } - *target += load_bias_; - break; - - case R_ARM_COPY: - // NOTE: These relocations are forbidden in shared libraries. - // The Android linker has special code to deal with this, which - // is not needed here. - RLOG(" R_ARM_COPY\n"); - *error = "Invalid R_ARM_COPY relocation in shared library"; - return false; -#endif // __arm__ - -#ifdef __i386__ - case R_386_JMP_SLOT: - *target = sym_addr; - break; - - case R_386_GLOB_DAT: - *target = sym_addr; - break; - - case R_386_RELATIVE: - if (rel_symbol) { - *error = "Invalid relative relocation with symbol"; - return false; - } - *target += load_bias_; - break; - - case R_386_32: - *target += sym_addr; - break; - - case R_386_PC32: - *target += (sym_addr - reloc); - break; -#endif // __i386__ - -#ifdef __mips__ - case R_MIPS_REL32: - if (resolved) - *target += sym_addr; - else - *target += load_bias_; - break; -#endif // __mips__ - - default: - error->Format("Invalid relocation type (%d)", rel_type); - return false; - } - - return true; -} -#endif // defined(USE_RELA) - -bool ElfRelocations::ResolveSymbol(ELF::Word rel_type, - ELF::Word rel_symbol, - const ElfSymbols* symbols, - SymbolResolver* resolver, - ELF::Addr reloc, - ELF::Addr* sym_addr, - Error* error) { - const char* sym_name = symbols->LookupNameById(rel_symbol); - RLOG(" symbol name='%s'\n", sym_name); - void* address = resolver->Lookup(sym_name); - - if (address) { - // The symbol was found, so compute its address. - RLOG("symbol %s resolved to %p", sym_name, address); - *sym_addr = reinterpret_cast<ELF::Addr>(address); - return true; - } - - // The symbol was not found. Normally this is an error except - // if this is a weak reference. - if (!symbols->IsWeakById(rel_symbol)) { - error->Format("Could not find symbol '%s'", sym_name); - return false; - } - - RLOG("weak reference to unresolved symbol %s", sym_name); - - // IHI0044C AAELF 4.5.1.1: - // Libraries are not searched to resolve weak references. - // It is not an error for a weak reference to remain - // unsatisfied. - // - // During linking, the value of an undefined weak reference is: - // - Zero if the relocation type is absolute - // - The address of the place if the relocation is pc-relative - // - The address of nominal base address if the relocation - // type is base-relative. - RelocationType r = GetRelocationType(rel_type); - if (r == RELOCATION_TYPE_ABSOLUTE || r == RELOCATION_TYPE_RELATIVE) { - *sym_addr = 0; - return true; - } - - if (r == RELOCATION_TYPE_PC_RELATIVE) { - *sym_addr = reloc; - return true; - } - - error->Format( - "Invalid weak relocation type (%d) for unknown symbol '%s'", - r, - sym_name); - return false; -} - -bool ElfRelocations::ApplyReloc(const rel_t* rel, - const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error) { - const ELF::Word rel_type = ELF_R_TYPE(rel->r_info); - const ELF::Word rel_symbol = ELF_R_SYM(rel->r_info); - - ELF::Addr sym_addr = 0; - ELF::Addr reloc = static_cast<ELF::Addr>(rel->r_offset + load_bias_); - RLOG(" offset=%p type=%d reloc=%p symbol=%d\n", rel->r_offset, rel_type, - reloc, rel_symbol); - - if (rel_type == 0) - return true; - - bool resolved = false; - - // If this is a symbolic relocation, compute the symbol's address. - if (__builtin_expect(rel_symbol != 0, 0)) { - if (!ResolveSymbol(rel_type, - rel_symbol, - symbols, - resolver, - reloc, - &sym_addr, - error)) { - return false; - } - resolved = true; - } - - return ApplyResolvedReloc(rel, sym_addr, resolved, error); -} - -bool ElfRelocations::ApplyRelocs(const rel_t* rel, - size_t rel_count, - const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error) { - RLOG("rel=%p rel_count=%d", rel, rel_count); - - if (!rel) - return true; - - for (size_t rel_n = 0; rel_n < rel_count; rel++, rel_n++) { - RLOG(" Relocation %d of %d:\n", rel_n + 1, rel_count); - - if (!ApplyReloc(rel, symbols, resolver, error)) - return false; - } - - return true; -} - -#ifdef __mips__ -bool ElfRelocations::RelocateMipsGot(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error) { - if (!plt_got_) - return true; - - // Handle the local GOT entries. - // This mimics what the system linker does. - // Note from the system linker: - // got[0]: lazy resolver function address. - // got[1]: may be used for a GNU extension. - // Set it to a recognizable address in case someone calls it - // (should be _rtld_bind_start). - ELF::Addr* got = plt_got_; - got[0] = 0xdeadbeef; - if (got[1] & 0x80000000) - got[1] = 0xdeadbeef; - - for (ELF::Addr n = 2; n < mips_local_got_count_; ++n) - got[n] += load_bias_; - - // Handle the global GOT entries. - got += mips_local_got_count_; - for (size_t idx = mips_gotsym_; idx < mips_symtab_count_; idx++, got++) { - const char* sym_name = symbols->LookupNameById(idx); - void* sym_addr = resolver->Lookup(sym_name); - if (sym_addr) { - // Found symbol, update GOT entry. - *got = reinterpret_cast<ELF::Addr>(sym_addr); - continue; - } - - if (symbols->IsWeakById(idx)) { - // Undefined symbols are only ok if this is a weak reference. - // Update GOT entry to 0 though. - *got = 0; - continue; - } - - error->Format("Cannot locate symbol %s", sym_name); - return false; - } - - return true; -} -#endif // __mips__ - -void ElfRelocations::AdjustRelocation(ELF::Word rel_type, - ELF::Addr src_reloc, - size_t dst_delta, - size_t map_delta) { - ELF::Addr* dst_ptr = reinterpret_cast<ELF::Addr*>(src_reloc + dst_delta); - - switch (rel_type) { -#ifdef __arm__ - case R_ARM_RELATIVE: - *dst_ptr += map_delta; - break; -#endif // __arm__ - -#ifdef __aarch64__ - case R_AARCH64_RELATIVE: - *dst_ptr += map_delta; - break; -#endif // __aarch64__ - -#ifdef __i386__ - case R_386_RELATIVE: - *dst_ptr += map_delta; - break; -#endif - -#ifdef __x86_64__ - case R_X86_64_RELATIVE: - *dst_ptr += map_delta; - break; -#endif - -#ifdef __mips__ - case R_MIPS_REL32: - *dst_ptr += map_delta; - break; -#endif - default: - ; - } -} - -void ElfRelocations::AdjustAndroidRelocation(const rel_t* relocation, - size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size) { - // Add this value to each source address to get the corresponding - // destination address. - const size_t dst_delta = dst_addr - src_addr; - const size_t map_delta = map_addr - src_addr; - - const ELF::Word rel_type = ELF_R_TYPE(relocation->r_info); - const ELF::Word rel_symbol = ELF_R_SYM(relocation->r_info); - ELF::Addr src_reloc = - static_cast<ELF::Addr>(relocation->r_offset + load_bias_); - - if (rel_type == 0 || rel_symbol != 0) { - // Ignore empty and symbolic relocations - return; - } - - if (src_reloc < src_addr || src_reloc >= src_addr + size) { - // Ignore entries that don't relocate addresses inside the source section. - return; - } - - AdjustRelocation(rel_type, src_reloc, dst_delta, map_delta); -} - -// Args for ApplyAndroidRelocation handler function. -struct RelocateAndroidRelocationArgs { - size_t src_addr; - size_t dst_addr; - size_t map_addr; - size_t size; -}; - -// Static ForEachAndroidRelocation() handler. -bool ElfRelocations::RelocateAndroidRelocation(ElfRelocations* relocations, - const rel_t* relocation, - void* opaque) { - // Unpack args from opaque, to obtain addrs and size; - RelocateAndroidRelocationArgs* args = - reinterpret_cast<RelocateAndroidRelocationArgs*>(opaque); - const size_t src_addr = args->src_addr; - const size_t dst_addr = args->dst_addr; - const size_t map_addr = args->map_addr; - const size_t size = args->size; - - relocations->AdjustAndroidRelocation(relocation, - src_addr, - dst_addr, - map_addr, - size); - return true; -} - -void ElfRelocations::RelocateAndroidRelocations(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size) { - if (!android_relocations_) - return; - - assert(IsValidAndroidPackedRelocations(android_relocations_, - android_relocations_size_)); - - RelocateAndroidRelocationArgs args; - args.src_addr = src_addr; - args.dst_addr = dst_addr; - args.map_addr = map_addr; - args.size = size; - ForEachAndroidRelocation(&RelocateAndroidRelocation, &args); -} - -void ElfRelocations::RelocateRelocations(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size) { - // Add this value to each source address to get the corresponding - // destination address. - const size_t dst_delta = dst_addr - src_addr; - const size_t map_delta = map_addr - src_addr; - - // Ignore PLT relocations, which all target symbols (ignored here). - const rel_t* rel = reinterpret_cast<rel_t*>(relocations_); - const size_t relocations_count = relocations_size_ / sizeof(rel_t); - const rel_t* rel_limit = rel + relocations_count; - - for (; rel < rel_limit; ++rel) { - const ELF::Word rel_type = ELF_R_TYPE(rel->r_info); - const ELF::Word rel_symbol = ELF_R_SYM(rel->r_info); - ELF::Addr src_reloc = static_cast<ELF::Addr>(rel->r_offset + load_bias_); - - if (rel_type == 0 || rel_symbol != 0) { - // Ignore empty and symbolic relocations - continue; - } - - if (src_reloc < src_addr || src_reloc >= src_addr + size) { - // Ignore entries that don't relocate addresses inside the source section. - continue; - } - - AdjustRelocation(rel_type, src_reloc, dst_delta, map_delta); - } -} - -void ElfRelocations::CopyAndRelocate(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size) { - // First, a straight copy. - ::memcpy(reinterpret_cast<void*>(dst_addr), - reinterpret_cast<void*>(src_addr), - size); - - // Relocate android relocations. - RelocateAndroidRelocations(src_addr, dst_addr, map_addr, size); - - // Relocate relocations. - RelocateRelocations(src_addr, dst_addr, map_addr, size); - -#ifdef __mips__ - // Add this value to each source address to get the corresponding - // destination address. - const size_t dst_delta = dst_addr - src_addr; - const size_t map_delta = map_addr - src_addr; - - // Only relocate local GOT entries. - ELF::Addr* got = plt_got_; - if (got) { - for (ELF::Addr n = 2; n < mips_local_got_count_; ++n) { - size_t got_addr = reinterpret_cast<size_t>(&got[n]); - if (got_addr < src_addr || got_addr >= src_addr + size) - continue; - ELF::Addr* dst_ptr = reinterpret_cast<ELF::Addr*>(got_addr + dst_delta); - *dst_ptr += map_delta; - } - } -#endif -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h deleted file mode 100644 index 43627fc..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h +++ /dev/null
@@ -1,170 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_RELOCATIONS_H -#define CRAZY_LINKER_ELF_RELOCATIONS_H - -#include <string.h> -#include <unistd.h> - -#include <link.h> - -#include "crazy_linker_defines.h" -#include "crazy_linker_relr_relocations.h" -#include "elf_traits.h" - -namespace crazy { - -class ElfSymbols; -class ElfView; -class Error; - -// An ElfRelocations instance holds information about relocations in a mapped -// ELF binary. -class ElfRelocations { -#if defined(USE_RELA) - typedef ELF::Rela rel_t; -#else - typedef ELF::Rel rel_t; -#endif - public: - ElfRelocations(); - ~ElfRelocations() {} - - bool Init(const ElfView* view, Error* error); - - // Abstract class used to resolve symbol names into addresses. - // Callers of ::ApplyAll() should pass the address of a derived class - // that properly implements the Lookup() method. - class SymbolResolver { - public: - SymbolResolver() {} - ~SymbolResolver() {} - virtual void* Lookup(const char* symbol_name) = 0; - }; - - // Apply all relocations to the target mapped ELF binary. Must be called - // after Init(). - // |symbols| maps to the symbol entries for the target library only. - // |resolver| can resolve symbols out of the current library. - // On error, return false and set |error| message. - bool ApplyAll(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error); - - // This function is used to adjust relocated addresses in a copy of an - // existing section of an ELF binary. I.e. |src_addr|...|src_addr + size| - // must be inside the mapped ELF binary, this function will first copy its - // content into |dst_addr|...|dst_addr + size|, then adjust all relocated - // addresses inside the destination section as if it was loaded/mapped - // at |map_addr|...|map_addr + size|. Only relative relocations are processed, - // symbolic ones are ignored. - void CopyAndRelocate(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size); - - private: - bool ResolveSymbol(unsigned rel_type, - unsigned rel_symbol, - const ElfSymbols* symbols, - SymbolResolver* resolver, - ELF::Addr reloc, - ELF::Addr* sym_addr, - Error* error); - bool ApplyResolvedReloc(const rel_t* rela, - ELF::Addr sym_addr, - bool resolved, - Error* error); - bool ApplyReloc(const rel_t* rela, - const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error); - bool ApplyRelocs(const rel_t* relocs, - size_t relocs_count, - const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error); - void AdjustRelocation(ELF::Word rel_type, - ELF::Addr src_reloc, - size_t dst_delta, - size_t map_delta); - void RelocateRelocations(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size); - void AdjustAndroidRelocation(const rel_t* relocation, - size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size); - - // Android packed relocations unpacker. Calls the given handler for - // each relocation in the unpacking stream. - typedef bool (*RelocationHandler)(ElfRelocations* relocations, - const rel_t* relocation, - void* opaque); - bool ForEachAndroidRelocation(RelocationHandler handler, - void* opaque); - template <typename ElfRelIteratorT> - bool ForEachAndroidRelocationHelper(ElfRelIteratorT&& rel_iterator, - ElfRelocations::RelocationHandler handler, - void* opaque); - - // Apply Android packed relocations. - // On error, return false and set |error| message. - // The static function is the ForEachAndroidRelocation() handler. - bool ApplyAndroidRelocations(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error); - static bool ApplyAndroidRelocation(ElfRelocations* relocations, - const rel_t* relocation, - void* opaque); - - // Relocate Android packed relocations. - // The static function is the ForEachAndroidRelocation() handler. - void RelocateAndroidRelocations(size_t src_addr, - size_t dst_addr, - size_t map_addr, - size_t size); - static bool RelocateAndroidRelocation(ElfRelocations* relocations, - const rel_t* relocation, - void* opaque); - -#if defined(__mips__) - bool RelocateMipsGot(const ElfSymbols* symbols, - SymbolResolver* resolver, - Error* error); -#endif - - const ELF::Phdr* phdr_ = nullptr; - size_t phdr_count_ = 0; - size_t load_bias_ = 0; - - ELF::Addr plt_relocations_ = 0; - size_t plt_relocations_size_ = 0; - ELF::Addr* plt_got_ = nullptr; - - ELF::Addr relocations_ = 0; - size_t relocations_size_ = 0; - - RelrRelocations relr_; - -#if defined(__mips__) - // MIPS-specific relocation fields. - ELF::Word mips_symtab_count_ = 0; - ELF::Word mips_local_got_count_ = 0; - ELF::Word mips_gotsym_ = 0; -#endif - - uint8_t* android_relocations_ = nullptr; - size_t android_relocations_size_ = 0; - - bool has_text_relocations_ = false; - bool has_symbolic_ = false; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_RELOCATIONS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.cpp deleted file mode 100644 index 6a47e23..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.cpp +++ /dev/null
@@ -1,221 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_relro.h" - -#include <errno.h> -#include <limits.h> -#include <stdlib.h> - -#include "crazy_linker_elf_relocations.h" -#include "crazy_linker_elf_view.h" -#include "crazy_linker_memory_mapping.h" -#include "crazy_linker_util.h" - -namespace crazy { - -namespace { - -inline bool PageEquals(const char* p1, const char* p2) { - return ::memcmp(p1, p2, PAGE_SIZE) == 0; -} - -// Swap pages between |addr| and |addr + size| with the bytes -// from the ashmem region identified by |fd|, starting from -// a given |offset|. On failure return false and set |error| message. -bool SwapPagesFromFd(void* addr, - size_t size, - int fd, - size_t offset, - Error* error) { - // Unmap current pages. - if (::munmap(addr, size) < 0) { - error->Format("%s: Could not unmap %p-%p: %s", - __FUNCTION__, - addr, - (char*)addr + size, - strerror(errno)); - return false; - } - - // Remap the fd pages at the same location now. - void* new_map = ::mmap(addr, - size, - PROT_READ, - MAP_FIXED | MAP_SHARED, - fd, - static_cast<off_t>(offset)); - if (new_map == MAP_FAILED) { - char* p = reinterpret_cast<char*>(addr); - error->Format("%s: Could not map %p-%p: %s", - __FUNCTION__, - p, - p + size, - strerror(errno)); - return false; - } - -// TODO(digit): Is this necessary? -#ifdef __arm__ - __clear_cache(addr, (char*)addr + size); -#endif - - // Done. - return true; -} - -} // namespace - -bool SharedRelro::Allocate(size_t relro_size, - const char* library_name, - Error* error) { - // Allocate a new ashmem region. - String name("RELRO:"); - name += library_name; - if (!ashmem_.Allocate(relro_size, name.c_str())) { - error->Format("Could not allocate RELRO ashmem region for %s: %s", - library_name, - strerror(errno)); - return false; - } - - start_ = 0; - size_ = relro_size; - return true; -} - -bool SharedRelro::CopyFrom(size_t relro_start, - size_t relro_size, - Error* error) { - // Map it in the process. - MemoryMapping map = MemoryMapping::Create( - nullptr, relro_size, MemoryMapping::CAN_WRITE, ashmem_.fd()); - if (!map.IsValid()) { - error->Format("Could not allocate RELRO mapping: %s", strerror(errno)); - return false; - } - - // Copy process' RELRO into it. - ::memcpy(map.address(), reinterpret_cast<void*>(relro_start), relro_size); - - // Unmap it. - map.Deallocate(); - - // Everything's good. - start_ = relro_start; - size_ = relro_size; - return true; -} - -bool SharedRelro::CopyFromRelocated(const ElfView* view, - size_t load_address, - size_t relro_start, - size_t relro_size, - Error* error) { - // Offset of RELRO section in current library. - size_t relro_offset = relro_start - view->load_address(); - - ElfRelocations relocations; - if (!relocations.Init(view, error)) - return false; - - // Map the region in memory (any address). - MemoryMapping map = MemoryMapping::Create( - nullptr, relro_size, MemoryMapping::CAN_READ_WRITE, ashmem_.fd()); - if (!map.IsValid()) { - error->Format("Could not allocate RELRO mapping for: %s", strerror(errno)); - return false; - } - - // Copy and relocate. - relocations.CopyAndRelocate(relro_start, - reinterpret_cast<size_t>(map.address()), - load_address + relro_offset, relro_size); - // Unmap it. - map.Deallocate(); - start_ = load_address + relro_offset; - size_ = relro_size; - return true; -} - -bool SharedRelro::ForceReadOnly(Error* error) { - // Ensure the ashmem region content isn't writable anymore. - if (!ashmem_.SetProtectionFlags(PROT_READ)) { - error->Format("Could not make RELRO ashmem region read-only: %s", - strerror(errno)); - return false; - } - return true; -} - -bool SharedRelro::InitFrom(size_t relro_start, - size_t relro_size, - int ashmem_fd, - Error* error) { - // Create temporary mapping of the ashmem region. - LOG("Entering addr=%p size=%p fd=%d", (void*)relro_start, (void*)relro_size, - ashmem_fd); - - // Sanity check: Ashmem file descriptor must be read-only. - if (!AshmemRegion::CheckFileDescriptorIsReadOnly(ashmem_fd)) { - error->Format("Ashmem file descriptor is not read-only: %s", - strerror(errno)); - return false; - } - - MemoryMapping fd_map = MemoryMapping::Create( - nullptr, relro_size, MemoryMapping::CAN_READ, ashmem_fd); - if (!fd_map.IsValid()) { - error->Format("Cannot map RELRO ashmem region as read-only: %s", - strerror(errno)); - return false; - } - - LOG("mapping allocated at %p", fd_map.address()); - - char* cur_page = reinterpret_cast<char*>(relro_start); - char* fd_page = static_cast<char*>(fd_map.address()); - size_t p = 0; - size_t size = relro_size; - size_t similar_size = 0; - - do { - // Skip over dissimilar pages. - while (p < size && !PageEquals(cur_page + p, fd_page + p)) { - p += PAGE_SIZE; - } - - // Count similar pages. - size_t p2 = p; - while (p2 < size && PageEquals(cur_page + p2, fd_page + p2)) { - p2 += PAGE_SIZE; - } - - if (p2 > p) { - // Swap pages between |pos| and |pos2|. - LOG("Swap pages at %p-%p", cur_page + p, cur_page + p2); - if (!SwapPagesFromFd(cur_page + p, p2 - p, ashmem_fd, p, error)) - return false; - - similar_size += (p2 - p); - } - - p = p2; - } while (p < size); - - LOG("Swapped %d pages over %d (%d %%, %d KB not shared)", - similar_size / PAGE_SIZE, size / PAGE_SIZE, similar_size * 100 / size, - (size - similar_size) / 4096); - - if (similar_size == 0) { - error->Format("No pages were swapped into RELRO ashmem"); - return false; - } - - start_ = relro_start; - size_ = relro_size; - return true; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.h deleted file mode 100644 index 57192217..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relro.h +++ /dev/null
@@ -1,83 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_RELRO_H -#define CRAZY_LINKER_ELF_RELRO_H - -#include "crazy_linker_ashmem.h" -#include "crazy_linker_memory_mapping.h" -#include "crazy_linker_system.h" -#include "elf_traits.h" - -namespace crazy { - -class ElfView; - -// A class used to model a shared RELRO section backed by an Ashmem region. -// The region is always owned by the SharedRelro, unless DetachFd() is called. -// The SharedRelro may or may not be mapped into the process. -class SharedRelro { - public: - // Create a new SharedRelro. Note that the object becomes the owner of - // |ashmem_fd|, unless DetachFd() is called after this. - SharedRelro() : start_(0), size_(0), ashmem_() {} - - ~SharedRelro() {} - - size_t start() const { return start_; } - size_t end() const { return start_ + size_; } - size_t size() const { return size_; } - int fd() const { return ashmem_.fd(); } - - // Return the ashmem region's file descriptor, and detach it from the object. - // After this call, fd() will always return -1. - int DetachFd() { return ashmem_.Release(); } - - // Allocate a new ashmem region of |relro_size| bytes for |library_name|. - // This operation doesn't change the process' mappings. On error, return - // false and set |error| message. - bool Allocate(size_t relro_size, const char* library_name, Error* error); - - // Copy the content of the current process' RELRO into the ashmem region. - // |relro_start| is the RELRO address (page-aligned). - // |relro_size| is the RELRO size in bytes (page-aligned), and must match - // the allocation size passed to Allocate(). - // On failure, return false and set |error| message. - bool CopyFrom(size_t relro_start, size_t relro_size, Error* error); - - // Copy the contents of the current process' RELRO into the ashmem region - // but adjust any relocation targets within it to correspond to a new - // |load_address|. |view| must point to a mapped ELF binary for the current - // library. |relro_start| corresponds to the address of the current - // process' RELRO, i.e. is not relocated. - bool CopyFromRelocated(const ElfView* view, - size_t load_address, - size_t relro_start, - size_t relro_size, - Error* error); - - // Force the section to be read-only. - bool ForceReadOnly(Error* error); - - // Map the ashmem region's pages into the current process, doing a comparison - // to avoid corrupting parts of the RELRO section that are different in this - // one (e.g. due to symbolic relocations to randomized system libraries). - // This operation is _not_ atomic, i.e. no other thread should try to execute - // code that reads from the RELRO region during this call. - // On failure, return false and set |error| message. - // This operation does not transfer ownership of |ashmem_fd| to the object. - bool InitFrom(size_t relro_start, - size_t relro_size, - int ashmem_fd, - Error* error); - - private: - size_t start_; - size_t size_; - AshmemRegion ashmem_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_RELRO_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.cpp deleted file mode 100644 index 525a4d2..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.cpp +++ /dev/null
@@ -1,141 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_symbols.h" - -#include "crazy_linker_debug.h" -#include "crazy_linker_elf_view.h" - -namespace crazy { - -ElfSymbols::ElfSymbols(const ELF::Sym* symbol_table, - const char* string_table, - uintptr_t dt_elf_hash, - uintptr_t dt_gnu_hash) - : symbol_table_(symbol_table), string_table_(string_table) { - if (dt_elf_hash) - elf_hash_.Init(dt_elf_hash); - if (dt_gnu_hash) - gnu_hash_.Init(dt_gnu_hash); -} - -bool ElfSymbols::IsValid() const { - return (symbol_table_ && string_table_ && - (gnu_hash_.IsValid() || elf_hash_.IsValid())); -} - -bool ElfSymbols::Init(const ElfView* view) { - LOG("Parsing dynamic table"); - ElfView::DynamicIterator dyn(view); - for (; dyn.HasNext(); dyn.GetNext()) { - uintptr_t dyn_addr = dyn.GetAddress(view->load_bias()); - switch (dyn.GetTag()) { - case DT_HASH: - LOG(" DT_HASH addr=%p", dyn_addr); - elf_hash_.Init(dyn_addr); - break; - case DT_GNU_HASH: - LOG(" DT_GNU_HASH addr=%p", dyn_addr); - gnu_hash_.Init(dyn_addr); - break; - case DT_STRTAB: - LOG(" DT_STRTAB addr=%p", dyn_addr); - string_table_ = reinterpret_cast<const char*>(dyn_addr); - break; - case DT_SYMTAB: - LOG(" DT_SYMTAB addr=%p", dyn_addr); - symbol_table_ = reinterpret_cast<const ELF::Sym*>(dyn_addr); - break; - default: - ; - } - } - return IsValid(); -} - -const ELF::Sym* ElfSymbols::LookupByAddress(void* address, - size_t load_bias) const { - ELF::Addr elf_addr = - reinterpret_cast<ELF::Addr>(address) - static_cast<ELF::Addr>(load_bias); - - for (const ELF::Sym& sym : GetDynSymbols()) { - if (sym.st_shndx != SHN_UNDEF && elf_addr >= sym.st_value && - elf_addr < sym.st_value + sym.st_size) { - return &sym; - } - } - return nullptr; -} - -bool ElfSymbols::LookupNearestByAddress(void* address, - size_t load_bias, - const char** sym_name, - void** sym_addr, - size_t* sym_size) const { - ELF::Addr elf_addr = - reinterpret_cast<ELF::Addr>(address) - static_cast<ELF::Addr>(load_bias); - - const ELF::Sym* nearest_sym = nullptr; - size_t nearest_diff = ~size_t(0); - - for (const ELF::Sym& sym : GetDynSymbols()) { - if (sym.st_shndx == SHN_UNDEF) - continue; - - if (elf_addr >= sym.st_value && elf_addr < sym.st_value + sym.st_size) { - // This is a perfect match. - nearest_sym = &sym; - break; - } - - // Otherwise, compute distance. - size_t diff; - if (elf_addr < sym.st_value) - diff = sym.st_value - elf_addr; - else - diff = elf_addr - sym.st_value - sym.st_size; - - if (diff < nearest_diff) { - nearest_sym = &sym; - nearest_diff = diff; - } - } - - if (!nearest_sym) - return false; - - *sym_name = string_table_ + nearest_sym->st_name; - *sym_addr = reinterpret_cast<void*>(nearest_sym->st_value + load_bias); - *sym_size = nearest_sym->st_size; - return true; -} - -const ELF::Sym* ElfSymbols::LookupByName(const char* symbol_name) const { - const ELF::Sym* sym = - gnu_hash_.IsValid() - ? gnu_hash_.LookupByName(symbol_name, symbol_table_, string_table_) - : elf_hash_.LookupByName(symbol_name, symbol_table_, string_table_); - - // Ignore undefined symbols or those that are not global or weak definitions. - if (!sym || sym->st_shndx == SHN_UNDEF) - return nullptr; - - uint8_t info = ELF_ST_BIND(sym->st_info); - if (info != STB_GLOBAL && info != STB_WEAK) - return nullptr; - - return sym; -} - -ElfSymbols::DynSymbols ElfSymbols::GetDynSymbols() const { - if (gnu_hash_.IsValid()) { - return {symbol_table_, gnu_hash_.dyn_symbols_offset(), - gnu_hash_.dyn_symbols_count()}; - } else { - return {symbol_table_, elf_hash_.dyn_symbols_offset(), - elf_hash_.dyn_symbols_count()}; - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.h deleted file mode 100644 index bb2c10c9..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols.h +++ /dev/null
@@ -1,111 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_SYMBOLS_H -#define CRAZY_LINKER_ELF_SYMBOLS_H - -#include "crazy_linker_elf_hash_table.h" -#include "crazy_linker_gnu_hash_table.h" -#include "elf_traits.h" - -#include <string.h> - -namespace crazy { - -class ElfView; - -// An ElfSymbols instance holds information about symbols in a mapped ELF -// binary. -class ElfSymbols { - public: - ElfSymbols() = default; - - // Constructor used for unit-testing. - ElfSymbols(const ELF::Sym* symbol_table, - const char* string_table, - uintptr_t dt_elf_hash, - uintptr_t dt_gnu_hash); - - // Returns true iff instance is valid. - bool IsValid() const; - - // Initializes instance from |view|. Returns true on success, or false if - // the ELF image is malformed. - bool Init(const ElfView* view); - - // Returns the symbol table entry associated with |symbol_name|, or nullptr. - const ELF::Sym* LookupByName(const char* symbol_name) const; - - // Returns the symbol table entry associated with |symbol_id|. - const ELF::Sym* LookupById(size_t symbol_id) const { - return &symbol_table_[symbol_id]; - } - - // Returns the symbol table entry corresponding to a given |address|. - // |load_bias| must be the ELF image's load bias. Return nullptr if not found. - const ELF::Sym* LookupByAddress(void* address, size_t load_bias) const; - - // Returns true iff symbol with id |symbol_id| is weak. - bool IsWeakById(size_t symbol_id) const { - return ELF_ST_BIND(symbol_table_[symbol_id].st_info) == STB_WEAK; - } - - // Returns the name of the symbol associated with |symbol_id|. - const char* LookupNameById(size_t symbol_id) const { - const ELF::Sym* sym = LookupById(symbol_id); - if (!sym) - return nullptr; - return string_table_ + sym->st_name; - } - - // Returns the address of the symbol identified by |symbol_name|. |load_bias| - // must be the ELF image's load bias. Return nullptr if not found. - void* LookupAddressByName(const char* symbol_name, size_t load_bias) const { - const ELF::Sym* sym = LookupByName(symbol_name); - if (!sym) - return nullptr; - return reinterpret_cast<void*>(load_bias + sym->st_value); - } - - // Lookups symbol information that is nearest to |address|, where |load_bias| - // is the ELF image load bias. On success, return true and set |*sym_name|, - // |*sym_addre| and |*sym_size|. On failure, return false. - bool LookupNearestByAddress(void* address, - size_t load_bias, - const char** sym_name, - void** sym_addr, - size_t* sym_size) const; - - // Returns string identified by |str_id|. - const char* GetStringById(size_t str_id) const { - return string_table_ + str_id; - } - - const char* string_table() const { return string_table_; } - - private: - // Simple range view for the dynamic symbols within |symbol_table_|. - // Provides begin() and end() to allow for-range loops. - class DynSymbols { - public: - DynSymbols(const ELF::Sym* symbols, size_t start, size_t count) - : begin_(symbols + start), end_(symbols + start + count) {} - const ELF::Sym* begin() const { return begin_; } - const ELF::Sym* end() const { return end_; } - - private: - const ELF::Sym* begin_; - const ELF::Sym* end_; - }; - DynSymbols GetDynSymbols() const; - - const ELF::Sym* symbol_table_ = nullptr; - const char* string_table_ = nullptr; - ElfHashTable elf_hash_ = {}; - GnuHashTable gnu_hash_ = {}; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_SYMBOLS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols_unittest.cpp deleted file mode 100644 index 5297eac..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_symbols_unittest.cpp +++ /dev/null
@@ -1,101 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_symbols.h" - -#include <gtest/gtest.h> -#include <memory> - -#include "crazy_linker_elf_hash_table_test_data.h" -#include "crazy_linker_gnu_hash_table_test_data.h" - -namespace crazy { -namespace testing { - -class ElfSymbolsTest : public ::testing::Test { - protected: - ElfSymbolsTest(const ELF::Sym* symbol_table, - const char* string_table, - uintptr_t dt_elf_hash, - uintptr_t dt_gnu_hash) - : symbols_(symbol_table, string_table, dt_elf_hash, dt_gnu_hash) {} - - ElfSymbols symbols_; -}; - -class ElfSymbolsElfHashTest : public ElfSymbolsTest { - public: - ElfSymbolsElfHashTest() - : ElfSymbolsTest(kTestElfSymbolTable, - kTestElfStringTable, - reinterpret_cast<uintptr_t>(kTestElfHashTable), - 0) {} -}; - -class ElfSymbolsGnuHashTest : public ElfSymbolsTest { - public: - ElfSymbolsGnuHashTest() - : ElfSymbolsTest(kTestGnuSymbolTable, - kTestGnuStringTable, - 0, - reinterpret_cast<uintptr_t>(kTestGnuHashTable)) {} -}; - -#define CHECK_SYMBOL_BY_NAME(name, offset, address, size) \ - sym = symbols_.LookupByName(name); \ - EXPECT_TRUE(sym) << name; \ - EXPECT_EQ((address), sym->st_value) << name; \ - EXPECT_EQ((size), sym->st_size) << name; - -#define CHECK_SYMBOL_BY_ADDRESS(name, offset, address, size) \ - sym = symbols_.LookupByAddress(reinterpret_cast<void*>(address), 0); \ - EXPECT_TRUE(sym) << name; \ - EXPECT_STREQ((name), symbols_.string_table() + sym->st_name) << name; \ - EXPECT_EQ((address), sym->st_value) << name; - -#define CHECK_SYMBOL_BY_NEAREST_ADDRESS(name, offset, address, size) \ - EXPECT_TRUE( \ - symbols_.LookupNearestByAddress(reinterpret_cast<void*>((address)-2), 0, \ - &sym_name, &sym_addr, &sym_size)) \ - << name; \ - EXPECT_STREQ((name), sym_name) << name; \ - EXPECT_EQ((address), reinterpret_cast<uintptr_t>(sym_addr)) << name; \ - EXPECT_EQ((size), sym_size) << name; - -TEST_F(ElfSymbolsElfHashTest, LookupByName) { - const ELF::Sym* sym; - LIST_ELF_SYMBOLS_TestElf(CHECK_SYMBOL_BY_NAME); -} - -TEST_F(ElfSymbolsElfHashTest, LookupByAddress) { - const ELF::Sym* sym; - LIST_ELF_SYMBOLS_TestElf(CHECK_SYMBOL_BY_ADDRESS); -} - -TEST_F(ElfSymbolsElfHashTest, LookupNearestByAddress) { - const char* sym_name; - void* sym_addr; - size_t sym_size; - LIST_ELF_SYMBOLS_TestElf(CHECK_SYMBOL_BY_NEAREST_ADDRESS); -} - -TEST_F(ElfSymbolsGnuHashTest, LookupByName) { - const ELF::Sym* sym; - LIST_ELF_SYMBOLS_TestGnu(CHECK_SYMBOL_BY_NAME); -} - -TEST_F(ElfSymbolsGnuHashTest, LookupByAddress) { - const ELF::Sym* sym; - LIST_ELF_SYMBOLS_TestGnu(CHECK_SYMBOL_BY_ADDRESS); -} - -TEST_F(ElfSymbolsGnuHashTest, LookupNearestByAddress) { - const char* sym_name; - void* sym_addr; - size_t sym_size; - LIST_ELF_SYMBOLS_TestGnu(CHECK_SYMBOL_BY_NEAREST_ADDRESS); -} - -} // namespace testing -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.cpp deleted file mode 100644 index 7f76154..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.cpp +++ /dev/null
@@ -1,118 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_elf_view.h" - -#include <errno.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_error.h" -#include "linker_phdr.h" - -namespace crazy { - -bool ElfView::InitUnmapped(ELF::Addr load_address, - const ELF::Phdr* phdr, - size_t phdr_count, - Error* error) { - // Compute load size and bias. - ELF::Addr min_vaddr = 0; - load_size_ = phdr_table_get_load_size(phdr, phdr_count, &min_vaddr, NULL); - if (load_size_ == 0) { - *error = "Invalid program header table"; - return false; - } - load_address_ = (load_address ? load_address : min_vaddr); - load_bias_ = load_address - min_vaddr; - - // Extract the dynamic table information. - phdr_table_get_dynamic_section(phdr, - phdr_count, - load_bias_, - &dynamic_, - &dynamic_count_, - &dynamic_flags_); - if (!dynamic_) { - *error = "No PT_DYNAMIC section!"; - return false; - } - - // Compute the program header table address relative to load_address. - // This is different from |phdr|..|phdr + phdr_count| which can actually - // be at a different location. - const ELF::Phdr* phdr0 = NULL; - - // First, if there is a PT_PHDR, use it directly. - for (size_t n = 0; n < phdr_count; ++n) { - const ELF::Phdr* entry = &phdr[n]; - if (entry->p_type == PT_PHDR) { - phdr0 = entry; - break; - } - } - - // Otherwise, check the first loadable segment. If its file offset - // is 0, it starts with the ELF header, and we can trivially find the - // loaded program header from it. - if (!phdr0) { - for (size_t n = 0; n < phdr_count; ++n) { - const ELF::Phdr* entry = &phdr[n]; - if (entry->p_type == PT_LOAD) { - if (entry->p_offset == 0) { - ELF::Addr elf_addr = load_bias_ + entry->p_vaddr; - const ELF::Ehdr* ehdr = reinterpret_cast<const ELF::Ehdr*>(elf_addr); - ELF::Addr offset = ehdr->e_phoff; - phdr0 = reinterpret_cast<const ELF::Phdr*>(elf_addr + offset); - } - break; - } - } - } - - // Check that the program header table is indeed in a loadable segment, - // this helps catching malformed ELF binaries. - if (phdr0) { - ELF::Addr phdr0_addr = reinterpret_cast<ELF::Addr>(phdr0); - ELF::Addr phdr0_limit = phdr0_addr + sizeof(ELF::Phdr) * phdr_count; - bool found = false; - for (size_t n = 0; n < phdr_count; ++n) { - size_t seg_start = load_bias_ + phdr[n].p_vaddr; - size_t seg_end = seg_start + phdr[n].p_filesz; - - if (seg_start <= phdr0_addr && phdr0_limit <= seg_end) { - found = true; - break; - } - } - - if (!found) - phdr0 = NULL; - } - - if (!phdr0) { - *error = "Malformed ELF binary"; - return false; - } - - phdr_ = phdr0; - phdr_count_ = phdr_count; - - LOG("New ELF view [load_address:%p, load_size:%p, load_bias:%p, phdr:%p, " - "phdr_count:%d, dynamic:%p, dynamic_count:%d, dynamic_flags:%d", - load_address_, load_size_, load_bias_, phdr_, phdr_count_, dynamic_, - dynamic_count_, dynamic_flags_); - return true; -} - -bool ElfView::ProtectRelroSection(Error* error) { - LOG("Enabling GNU RELRO protection"); - - if (phdr_table_protect_gnu_relro(phdr_, phdr_count_, load_bias_) < 0) { - error->Format("Can't enable GNU RELRO protection: %s", strerror(errno)); - return false; - } - return true; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.h deleted file mode 100644 index 7eddd94..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_view.h +++ /dev/null
@@ -1,121 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ELF_VIEW_H -#define CRAZY_LINKER_ELF_VIEW_H - -#include <string.h> - -#include "crazy_linker_error.h" -#include "elf_traits.h" - -namespace crazy { - -class Error; - -// An ElfView holds information describing a given ELF binary file for -// the crazy linker. This can be used to describe either system or crazy -// libraries. -class ElfView { - public: - ElfView() = default; - - // Initialize this ElfView from its load address and a copy of its program - // header table. - // |load_address| is the desired library load address. - // |phdr| is a pointer to the library's program header. Note that this can - // point to any memory location that contains a valid copy of the header. - // I.e. the library does not have to be mapped in the process. - // |phdr_count| number of entries in program header table. - // On failure, return false and set |error| message. - // On success, return true, and sets all fields of the ElfView to the - // appropriate values. Note that functions phdr() or dynamic() will always - // return an address relative to |load_address|, even if the binary was - // not loaded yet in the process. - bool InitUnmapped(ELF::Addr load_address, - const ELF::Phdr* phdr, - size_t phdr_count, - Error* error); - - const ELF::Phdr* phdr() const { return phdr_; } - size_t phdr_count() const { return phdr_count_; } - const ELF::Dyn* dynamic() const { return dynamic_; } - size_t dynamic_count() const { return dynamic_count_; } - size_t dynamic_flags() const { return dynamic_flags_; } - size_t load_address() const { return load_address_; } - size_t load_size() const { return load_size_; } - size_t load_bias() const { return load_bias_; } - - // Helper class to iterate over the dynamic table. - // Usage example: - // DynamicIterator iter; - // for ( ; iter.HasNext(); iter.SkipNext()) { - // if (iter.GetTag() == DT_SOME_TAG) { - // ... use iter.GetValue() - // ... or iter.GetAddress(load_address) - // } - // } - class DynamicIterator { - public: - DynamicIterator(const ElfView* view) { - dyn_ = view->dynamic(); - dyn_limit_ = dyn_ + view->dynamic_count(); - } - - ~DynamicIterator() {} - - bool HasNext() const { return dyn_ < dyn_limit_; } - void GetNext() { dyn_ += 1; } - - ELF::Addr GetTag() const { return dyn_->d_tag; } - - ELF::Addr GetValue() const { return dyn_->d_un.d_val; } - - ELF::Addr* GetValuePointer() const { - return const_cast<ELF::Addr*>(&dyn_->d_un.d_ptr); - } - - uintptr_t GetOffset() const { return dyn_->d_un.d_ptr; } - - uintptr_t GetAddress(size_t load_bias) const { - return load_bias + dyn_->d_un.d_ptr; - } - - private: - const ELF::Dyn* dyn_; - const ELF::Dyn* dyn_limit_; - }; - - // Ensure the RELRO section is read-only after relocations. Assume the - // ELF binary is mapped.On failure, return false and set |error| message. - bool ProtectRelroSection(Error* error); - -#if defined(__arm__) || defined(__aarch64__) - // Register packed relocations to apply. - // |packed_relocs| is a pointer to packed relocations data. - void RegisterPackedRelocations(uint8_t* packed_relocations) { - packed_relocations_ = packed_relocations; - } - - uint8_t* packed_relocations() const { return packed_relocations_; } -#endif - - protected: - const ELF::Phdr* phdr_ = nullptr; - size_t phdr_count_ = 0; - const ELF::Dyn* dynamic_ = nullptr; - size_t dynamic_count_ = 0; - ELF::Word dynamic_flags_ = 0; - ELF::Addr load_address_ = 0; - size_t load_size_ = 0; - size_t load_bias_ = 0; - -#if defined(__arm__) || defined(__aarch64__) - uint8_t* packed_relocations_; -#endif -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ELF_VIEW_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_error.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_error.cpp deleted file mode 100644 index a9f51a93..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_error.cpp +++ /dev/null
@@ -1,50 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_error.h" - -#include <stdarg.h> -#include <string.h> -#include <stdio.h> - -#include "crazy_linker_debug.h" - -namespace crazy { - -void Error::Set(const char* message) { - if (!message) - message = ""; - strlcpy(buff_, message, sizeof(buff_)); - - LOG("--- ERROR: %s", buff_); -} - -void Error::Append(const char* message) { - if (!message) - return; - strlcat(buff_, message, sizeof(buff_)); - - LOG("--- ERROR: %s", buff_); -} - -void Error::Format(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - vsnprintf(buff_, sizeof(buff_), fmt, args); - va_end(args); - - LOG("--- ERROR: %s", buff_); -} - -void Error::AppendFormat(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - size_t buff_len = strlen(buff_); - vsnprintf(buff_ + buff_len, sizeof(buff_) - buff_len, fmt, args); - va_end(args); - - LOG("--- ERROR: %s", buff_); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_error.h b/third_party/android_crazy_linker/src/src/crazy_linker_error.h deleted file mode 100644 index 973b7e5..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_error.h +++ /dev/null
@@ -1,45 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ERROR_H -#define CRAZY_LINKER_ERROR_H - -namespace crazy { - -// A class used to hold a fixed-size buffer to hold error messages -// as well as perform assignment and formatting. -// -// Usage examples: -// Error error; -// error = "Unimplemented feature"; -// error->Set("Unimplemented feature"); -// error->Format("Feature %s is not implemented", feature_name); -// error->Append(strerror(errno)); -// error->AppendFormat("Error: %s", strerror(errno)); -// -class Error { - public: - Error() { buff_[0] = '\0'; } - - Error(const char* message) { Set(message); } - - Error(const Error& other) { Set(other.buff_); } - - const char* c_str() const { return buff_; } - - void Set(const char* message); - - void Format(const char* fmt, ...); - - void Append(const char* message); - - void AppendFormat(const char* fmt, ...); - - private: - char buff_[512]; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_ERROR_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_error_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_error_unittest.cpp deleted file mode 100644 index 295f7b1..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_error_unittest.cpp +++ /dev/null
@@ -1,54 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_error.h" - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(Error, ConstructEmpty) { - Error error; - EXPECT_STREQ("", error.c_str()); -} - -TEST(Error, ConstructWithString) { - Error error("Foo Bar"); - EXPECT_STREQ("Foo Bar", error.c_str()); -} - -TEST(Error, CopyConstructor) { - Error error("FooFoo"); - Error error2(error); - - EXPECT_STREQ("FooFoo", error2.c_str()); -} - -TEST(Error, Set) { - Error error; - error.Set("BarFoo"); - EXPECT_STREQ("BarFoo", error.c_str()); - error.Set("FooBar"); - EXPECT_STREQ("FooBar", error.c_str()); -} - -TEST(Error, Append) { - Error error("Foo"); - error.Append("Bar"); - EXPECT_STREQ("FooBar", error.c_str()); -} - -TEST(Error, Format) { - Error error; - error.Format("%s %s!", "Hi", "Cowboy"); - EXPECT_STREQ("Hi Cowboy!", error.c_str()); -} - -TEST(Error, AppendFormat) { - Error error("Hi"); - error.AppendFormat(" there %s!", "Cowboy"); - EXPECT_STREQ("Hi there Cowboy!", error.c_str()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_expected.h b/third_party/android_crazy_linker/src/src/crazy_linker_expected.h deleted file mode 100644 index 9b3d19ae..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_expected.h +++ /dev/null
@@ -1,108 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_OUTCOME_H -#define CRAZY_LINKER_OUTCOME_H - -#include "crazy_linker_debug.h" -#include "crazy_linker_error.h" - -#include <utility> - -namespace crazy { - -// Handy template for an object that can be either a value of type T, or hold -// a non-owning pointer to a crazy::Error instance. The reason for this design -// is to keep each Expected<T> instance small, since each Error instance is -// pretty large (over 512 bytes), and generally allocated on the stack by the -// caller. Usage examples: -// -// Expected<int> getFoo() { return 42; } -// Expected<int> getBar(Error* error) { return Expected<int>(error); } -// Expected<int> getBar2(Error* error) { return error; } // equivalent! -template <class T> -struct Expected { - // No default constructor. - Expected() = delete; - - // Value constructor. - constexpr Expected(const T& value) : has_value_(true), value_(value) {} - Expected(T&& value) : has_value_(true), value_(std::move(value)) {} - - // Null-constructor, only valid if T can be constructed from nullptr. - constexpr Expected(nullptr_t) : has_value_(true), value_(nullptr) {} - - // Error constructor. - Expected(Error* error) : has_value_(false), error_(error) {} - - // Move constructor. - Expected(Expected&& other) noexcept : has_value_(other.has_value_) { - if (has_value_) { - value_ = std::move(other.value_); - } else { - error_ = other.error_; - } - } - - // Move assigment. - Expected& operator=(Expected&& other) noexcept { - if (this != &other) { - this->~Expected(); - *this = std::move(other); - } - return *this; - } - - // Destructor. - ~Expected() { - if (has_value_) { - value_.~T(); - } - } - - // Bool operator, to write: if (expected) { ... use value. } - constexpr explicit operator bool() const { return has_value_; } - - // Return reference to value. Assert if error. - constexpr const T& operator*() const { return value(); } - T& operator*() { return value(); } - - constexpr const T& value() const& { - return ASSERT(has_value_, "No value in Expected<> instance!"), value_; - } - - T& value() & { - return ASSERT(has_value_, "No value in Expected<> instance!"), value_; - } - - T&& value() && { - return ASSERT(has_value_, "No value in Expected<> instance!"), - std::move(value_); - } - - // Return reference to value, or a default value if it is an error. - constexpr const T& value_or(const T& default_value) const { - return has_value_ ? value_ : default_value; - } - - // Return reference to error. Assert if value. - constexpr const Error* error() const { - ASSERT(!has_value_, "No error in Expected<> instance!"); - return error_; - } - - constexpr bool has_value() const { return has_value_; } - constexpr bool has_error() const { return !has_value_; } - - private: - bool has_value_; - union { - T value_; - Error* error_; - }; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_OUTCOME_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_expected_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_expected_unittest.cpp deleted file mode 100644 index faefa9a..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_expected_unittest.cpp +++ /dev/null
@@ -1,66 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_expected.h" - -#include <gtest/gtest.h> - -#include <memory> -#include <new> - -namespace crazy { - -TEST(Expected, ValueConstructor) { - Expected<int> e{10}; - ASSERT_TRUE(e); - ASSERT_TRUE(e.has_value()); - ASSERT_FALSE(e.has_error()); - ASSERT_EQ(10, *e); - ASSERT_EQ(10, e.value()); - ASSERT_EQ(10, e.value_or(20)); -} - -TEST(Expected, ErrorConstructor) { - Error error; - Expected<int> e(&error); - ASSERT_FALSE(e); - ASSERT_FALSE(e.has_value()); - ASSERT_TRUE(e.has_error()); - ASSERT_EQ(10, e.value_or(10)); - ASSERT_EQ(20, e.value_or(20)); - ASSERT_EQ(&error, e.error()); - - int v = 10; - Expected<int*> e2(&v); - ASSERT_TRUE(e2); - ASSERT_EQ(&v, *e2); -} - -TEST(Expectde, ValueMovesRValue) { - auto create_value = [](int value) { - return Expected<std::unique_ptr<int>>(std::make_unique<int>(value)); - }; - - std::unique_ptr<int> ptr = create_value(10).value(); - ASSERT_TRUE(ptr); - ASSERT_EQ(10, *ptr); -} - -TEST(Expected, DeathInCaseOfInvalidUsage) { - Expected<int> e{10}; - ASSERT_TRUE(e); - ASSERT_TRUE(e.has_value()); - ASSERT_FALSE(e.has_error()); - ASSERT_DEATH(e.error(), "No error in Expected<> instance!"); - - Error error; - Expected<int> e2(&error); - ASSERT_FALSE(e2); - ASSERT_FALSE(e2.has_value()); - ASSERT_TRUE(e2.has_error()); - ASSERT_DEATH(*e2, "No value in Expected<> instance!"); - ASSERT_DEATH(e2.value(), "No value in Expected<> instance!"); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_globals.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_globals.cpp deleted file mode 100644 index 4407b67..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_globals.cpp +++ /dev/null
@@ -1,81 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_globals.h" - -#include <new> - -#include <pthread.h> - -namespace crazy { - -namespace { - -// Implement lazy-initialized static variable without a C++ constructor. -// Note that this is leaky, i.e. the instance is never destroyed, but -// this was also the case with the previous heap-based implementation. -pthread_once_t s_once = PTHREAD_ONCE_INIT; - -union Storage { - char dummy; - Globals globals; - - Storage() {} - ~Storage() {} -}; - -Storage s_storage; - -void InitGlobals() { - new (&s_storage.globals) Globals(); -} - -} // namespace - -Globals::Globals() { - // IMPORTANT: The global mutex must be recursive to allow for recursive - // dlopen() calls. See http://crbug.com/843804. - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&lock_, &attr); - pthread_mutexattr_destroy(&attr); - - search_paths_.ResetFromEnv("LD_LIBRARY_PATH"); -} - -Globals::~Globals() { - pthread_mutex_destroy(&lock_); -} - -void Globals::Lock() { - pthread_mutex_lock(&lock_); -} - -void Globals::Unlock() { - pthread_mutex_unlock(&lock_); -} - -// static -Globals* Globals::Get() { - pthread_once(&s_once, InitGlobals); - return &s_storage.globals; -} - -// TECHNICAL NOTE: The mutex below does not have to be recursive, unlike the -// other one, because it should be only operated on during the following -// operations: -// -// - Acquired before, and released after, calling one of the system linker's -// functions that may modify the global link-map. Note that these should -// never call back into the crazy linker. -// -// - Acquired and released when modifying the global link-map in -// crazy::RDebug::AddEntryImpl() and crazy::RDebug::DelEntryImpl(). These -// do not call the system linker, or make any kind of recursive calls. - -// static -pthread_mutex_t ScopedLinkMapLocker::s_lock_ = PTHREAD_MUTEX_INITIALIZER; - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_globals.h b/third_party/android_crazy_linker/src/src/crazy_linker_globals.h deleted file mode 100644 index 1480df68..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_globals.h +++ /dev/null
@@ -1,113 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_GLOBALS_H -#define CRAZY_LINKER_GLOBALS_H - -#include <pthread.h> - -#include "crazy_linker_library_list.h" -#include "crazy_linker_pointer_set.h" -#include "crazy_linker_rdebug.h" -#include "crazy_linker_search_path_list.h" - -// All crazy linker globals are declared in this header. - -namespace crazy { - -class Globals { - public: - // Get the single Globals instance for this process. - static Globals* Get(); - - // Default constructor. - Globals(); - - // Destructor. - ~Globals(); - - // Acquire and release the mutex that protects all other non-static members. - // ScopedLockedGlobals is recommended, to avoid using these directly. - void Lock(); - void Unlock(); - - // The list of libraries known to the crazy linker. - LibraryList* libraries() { return &libraries_; } - - // The RDebug instance for this process. - RDebug* rdebug() { return &rdebug_; } - - // Set of valid handles returned by the dlopen() wrapper. This is - // required to deal with rare cases where the wrapper is passed - // a handle that was opened with the system linker by mistake. - PointerSet* valid_handles() { return &valid_handles_; } - - // The current library search path list used by the dlopen() wrapper. - // Initialized from LD_LIBRARY_PATH when ::Get() creates the instance. - SearchPathList* search_path_list() { return &search_paths_; } - - // Save JavaVM instance pointer and minimum JNI version required by this - // client. If |java_vm| is not nullptr, it will be used to call JNI_OnLoad() - // on every library loaded through the crazy linker, if available, and - // JNI_UnLoad() when unloading them, respectively. - void InitJavaVm(void* java_vm, int min_jni_version) { - java_vm_ = java_vm; - min_jni_version_ = min_jni_version; - } - - // Return current JavaVM instance pointer. - void* java_vm() const { return java_vm_; } - - // Return current minimum JNI version number. - int minimum_jni_version() const { return min_jni_version_; } - - // Convenience function to get the global RDebug instance. - static RDebug* GetRDebug() { return Get()->rdebug(); } - - private: - pthread_mutex_t lock_; - void* java_vm_ = nullptr; - int min_jni_version_ = 0; - LibraryList libraries_; - SearchPathList search_paths_; - RDebug rdebug_; - PointerSet valid_handles_; -}; - -// Convenience class to retrieve the Globals instance and lock it at the same -// time on construction, then release it on destruction. Also dereference can -// be used to access global methods and members. -class ScopedLockedGlobals { - public: - // Default constructor acquires the lock on the global instance. - ScopedLockedGlobals() : globals_(Globals::Get()) { globals_->Lock(); } - - // Destructor releases the lock. - ~ScopedLockedGlobals() { globals_->Unlock(); } - - // Disallow copy operations. - ScopedLockedGlobals(const ScopedLockedGlobals&) = delete; - ScopedLockedGlobals& operator=(const ScopedLockedGlobals&) = delete; - - // Dereference operator. - Globals* operator->() { return globals_; } - - private: - Globals* globals_; -}; - -// Convenience class used to operate on a mutex used to synchronize access to -// the global _r_debug link map, at least from threads using the crazy linker. -class ScopedLinkMapLocker { - public: - ScopedLinkMapLocker() { pthread_mutex_lock(&s_lock_); } - ~ScopedLinkMapLocker() { pthread_mutex_unlock(&s_lock_); } - - private: - static pthread_mutex_t s_lock_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_GLOBALS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_globals_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_globals_unittest.cpp deleted file mode 100644 index cac3e591..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_globals_unittest.cpp +++ /dev/null
@@ -1,22 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_globals.h" - -#include <gtest/gtest.h> - -#include "crazy_linker_system_mock.h" - -namespace crazy { - -TEST(Globals, Get) { - SystemMock sys; - Globals* globals = Globals::Get(); - ASSERT_TRUE(globals); - ASSERT_TRUE(globals->libraries()); - ASSERT_TRUE(globals->search_path_list()); - ASSERT_TRUE(globals->rdebug()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.cpp deleted file mode 100644 index 45a1fb09..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.cpp +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_gnu_hash_table.h" - -#include <string.h> - -namespace crazy { - -// Compute the GNU hash of a given symbol. -static uint32_t GnuHash(const char* name) { - uint32_t h = 5381; - const uint8_t* ptr = reinterpret_cast<const uint8_t*>(name); - while (*ptr) { - h = h * 33 + *ptr++; - } - return h; -} - -void GnuHashTable::Init(uintptr_t dt_gnu_hash) { - sym_count_ = 0; - - const uint32_t* data = reinterpret_cast<const uint32_t*>(dt_gnu_hash); - num_buckets_ = data[0]; - sym_offset_ = data[1]; - - if (!num_buckets_) - return; - - const uint32_t bloom_size = data[2]; - if ((bloom_size & (bloom_size - 1U)) != 0) // must be a power of 2 - return; - - bloom_word_mask_ = bloom_size - 1U; - bloom_shift_ = data[3]; - bloom_filter_ = reinterpret_cast<const ELF::Addr*>(data + 4); - buckets_ = reinterpret_cast<const uint32_t*>(bloom_filter_ + bloom_size); - chain_ = buckets_ + num_buckets_; - - // Compute number of dynamic symbols by parsing the table. - if (num_buckets_ > 0) { - // First find the maximum index in the buckets table. - uint32_t max_index = buckets_[0]; - for (size_t n = 1; n < num_buckets_; ++n) { - uint32_t sym_index = buckets_[n]; - if (sym_index > max_index) - max_index = sym_index; - } - // Now start to look at the chain_ table from (max_index - sym_offset_) - // until there is a value with LSB set to 1, indicating the end of the - // last chain. - while ((chain_[max_index - sym_offset_] & 1) == 0) - max_index++; - - sym_count_ = (max_index - sym_offset_) + 1; - } -} - -bool GnuHashTable::IsValid() const { - return sym_count_ > 0; -} - -const ELF::Sym* GnuHashTable::LookupByName(const char* symbol_name, - const ELF::Sym* symbol_table, - const char* string_table) const { - uint32_t hash = GnuHash(symbol_name); - - // First, bloom filter test. - const unsigned kElfBits = ELF::kElfBits; - ELF::Addr word = bloom_filter_[(hash / kElfBits) & bloom_word_mask_]; - ELF::Addr mask = (ELF::Addr(1) << (hash % kElfBits)) | - (ELF::Addr(1) << ((hash >> bloom_shift_) % kElfBits)); - - if ((word & mask) != mask) - return nullptr; - - uint32_t sym_index = buckets_[hash % num_buckets_]; - if (sym_index < sym_offset_) - return nullptr; - - while (true) { - const ELF::Sym* sym = symbol_table + sym_index; - const uint32_t sym_hash = chain_[sym_index - sym_offset_]; - const char* sym_name = string_table + sym->st_name; - - if ((sym_hash | 1) == (hash | 1) && !strcmp(sym_name, symbol_name)) { - return sym; - } - - if (sym_hash & 1) - break; - - sym_index++; - } - - return nullptr; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.h b/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.h deleted file mode 100644 index 7deace54..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table.h +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_GNU_HASH_TABLE_H -#define CRAZY_LINKER_GNU_HASH_TABLE_H - -#include <stddef.h> -#include "elf_traits.h" - -namespace crazy { - -// Models the hash table used to map symbol names to symbol entries using -// the GNU format. This one is smaller and faster than the standard ELF one. -class GnuHashTable { - public: - // Initialize instance. |dt_gnu_hash| should be the address that the - // DT_GNU_HASH entry points to in the input ELF dynamic section. Call - // IsValid() to determine whether the table was well-formed. - void Init(uintptr_t dt_gnu_hash); - - // Returns true iff the content of the table is valid. - bool IsValid() const; - - // Return the index of the first dynamic symbol within the ELF symbol table. - size_t dyn_symbols_offset() const { return sym_offset_; }; - - // Number of dynamic symbols in the ELF symbol table. - size_t dyn_symbols_count() const { return sym_count_; } - - // Lookup |symbol_name| in the table. |symbol_table| should point to the - // ELF symbol table, and |string_table| to the start of its string table. - // Returns nullptr on failure. - const ELF::Sym* LookupByName(const char* symbol_name, - const ELF::Sym* symbol_table, - const char* string_table) const; - - private: - uint32_t num_buckets_ = 0; - uint32_t sym_offset_ = 0; - uint32_t sym_count_ = 0; - uint32_t bloom_word_mask_ = 0; - uint32_t bloom_shift_ = 0; - const ELF::Addr* bloom_filter_ = nullptr; - const uint32_t* buckets_ = nullptr; - const uint32_t* chain_ = nullptr; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_GNU_HASH_TABLE_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_test_data.h b/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_test_data.h deleted file mode 100644 index e286047..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_test_data.h +++ /dev/null
@@ -1,128 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H -#define CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H - -// clang-format off -// BEGIN_AUTO_GENERATED [generate_test_gnu_hash_tables.py] DO NOT EDIT!! -// - -namespace crazy { -namespace testing { - -// GNU hash table: num_buckets=4 bloom_size=2 bloom_shift=5 -// -// idx symbol hash bucket bloom32 bloom64 chain -// -// 0 ST_UNDEF -// 1 cfsetispeed 830acc54 0 0:20:02 1:20:34 830acc54 -// 2 strsigna 90f1e4b0 0 1:16:05 0:48:37 90f1e4b0 -// 3 hcreate_ 4c7e3240 0 0:00:18 1:00:18 4c7e3240 -// 4 endrpcen b6c44714 0 0:20:24 0:20:56 b6c44715 -// 5 uselib 2124d3e9 1 1:09:31 1:41:31 2124d3e8 -// 6 gettyen f07bdd25 1 1:05:09 0:37:41 f07bdd24 -// 7 umoun 1081e019 1 0:25:00 0:25:00 1081e019 -// 8 freelocal e3364372 2 1:18:27 1:50:27 e3364372 -// 9 listxatt ced3d862 2 1:02:03 1:34:03 ced3d862 -// 10 isnan 0fabfd7e 2 1:30:11 1:62:43 0fabfd7e -// 11 isinf 0fabe9de 2 0:30:14 1:30:14 0fabe9de -// 12 setrlimi 12e23bae 2 1:14:29 0:46:29 12e23baf -// 13 getspen f07b2a7b 3 1:27:19 1:59:19 f07b2a7a -// 14 pthread_mutex_lock 4f152227 3 1:07:17 0:39:17 4f152226 -// 15 getopt_long_onl 57b1584f 3 0:15:02 1:15:02 57b1584f -// -// Buckets: 1, 5, 8, 13 -// -// Bloom filter (32 bits): -// bit# 24 16 8 0 -// .x....xx ...x.x.. xx...... .....x.x -// xxx.x... ....xxxx .x..x.x. x.x.xx.. -// -// also as: 0x4314c005 0xe80f4aac -// -// Bloom filter (64 bits): -// bit# 56 48 40 32 24 16 8 0 -// .......x .......x .x....x. x.x..... ..x...x. ...x..x. ........ .......x -// .x..x... .....x.. ....x.x. .....x.. xx..x... ...xxx.. xx...... ....xx.x -// -// also as: 0x010142a022120001 0x48040a04c81cc00d -// -static const char kTestGnuStringTable[145] = { - '\0','c','f','s','e','t','i','s','p','e','e','d','\0','s','t','r','s','i', - 'g','n','a','\0','h','c','r','e','a','t','e','_','\0','e','n','d','r','p', - 'c','e','n','\0','u','s','e','l','i','b','\0','g','e','t','t','y','e','n', - '\0','u','m','o','u','n','\0','f','r','e','e','l','o','c','a','l','\0','l', - 'i','s','t','x','a','t','t','\0','i','s','n','a','n','\0','i','s','i','n', - 'f','\0','s','e','t','r','l','i','m','i','\0','g','e','t','s','p','e','n', - '\0','p','t','h','r','e','a','d','_','m','u','t','e','x','_','l','o','c', - 'k','\0','g','e','t','o','p','t','_','l','o','n','g','_','o','n','l','\0', - '\0'}; - -// Auto-generated macro used to list all symbols -// XX must be a macro that takes the following parameters: -// name: symbol name (quoted). -// str_offset: symbol name offset in string table -// address: virtual address. -// size: size in bytes -#define LIST_ELF_SYMBOLS_TestGnu(XX) \ - XX("cfsetispeed", 1, 0x10000, 16) \ - XX("strsigna", 13, 0x10020, 16) \ - XX("hcreate_", 22, 0x10040, 16) \ - XX("endrpcen", 31, 0x10060, 16) \ - XX("uselib", 40, 0x10080, 16) \ - XX("gettyen", 47, 0x100a0, 16) \ - XX("umoun", 55, 0x100c0, 16) \ - XX("freelocal", 61, 0x100e0, 16) \ - XX("listxatt", 71, 0x10100, 16) \ - XX("isnan", 80, 0x10120, 16) \ - XX("isinf", 86, 0x10140, 16) \ - XX("setrlimi", 92, 0x10160, 16) \ - XX("getspen", 101, 0x10180, 16) \ - XX("pthread_mutex_lock", 109, 0x101a0, 16) \ - XX("getopt_long_onl", 128, 0x101c0, 16) \ - // END OF LIST - -// NOTE: ELF32_Sym and ELF64_Sym have very different layout. -#if UINTPTR_MAX == UINT32_MAX // ELF32_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), (address), (size), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */ }, -#else // ELF64_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */, (address), (size) }, -#endif // !ELF64_Sym -static const ELF::Sym kTestGnuSymbolTable[] = { - { 0 }, // ST_UNDEF - LIST_ELF_SYMBOLS_TestGnu(DEFINE_ELF_SYMBOL) -}; -#undef DEFINE_ELF_SYMBOL - -static const uint32_t kTestGnuHashTable[] = { - 4, // num_buckets - 1, // sym_offset - 2, // bloom_size - 5, // bloom_shift - // Bloom filter words -#if UINTPTR_MAX == UINT32_MAX // 32-bit bloom filter words - 0x4314c005, 0xe80f4aac, -#else // 64-bits filter bloom words (assumes little-endianess) - 0x22120001, 0x010142a0, 0xc81cc00d, 0x48040a04, -#endif // bloom filter words - // Buckets - 0x00000001, 0x00000005, 0x00000008, 0x0000000d, - // Chain - 0x830acc54, 0x90f1e4b0, 0x4c7e3240, 0xb6c44715, 0x2124d3e8, 0xf07bdd24, - 0x1081e019, 0xe3364372, 0xced3d862, 0x0fabfd7e, 0x0fabe9de, 0x12e23baf, - 0xf07b2a7a, 0x4f152226, 0x57b1584f, -}; - -} // namespace testing -} // namespace crazy - -// END_AUTO_GENERATED_CODE [generate_test_gnu_hash_tables.py] -// clang-format on - -#endif // CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_unittest.cpp deleted file mode 100644 index a814630..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_gnu_hash_table_unittest.cpp +++ /dev/null
@@ -1,54 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_gnu_hash_table.h" - -#include <gtest/gtest.h> -#include "crazy_linker_gnu_hash_table_test_data.h" - -#include <stdint.h> - -namespace crazy { -namespace testing { - -TEST(GnuHashTable, LookupByName) { - GnuHashTable table; - table.Init(reinterpret_cast<uintptr_t>(&kTestGnuHashTable)); - EXPECT_TRUE(table.IsValid()); - - const ELF::Sym* sym; - -#define CHECK_SYMBOL(name, offset, address, size) \ - sym = table.LookupByName(name, kTestGnuSymbolTable, kTestGnuStringTable); \ - EXPECT_TRUE(sym) << name; \ - EXPECT_EQ((address), sym->st_value) << name; \ - EXPECT_EQ((size), sym->st_size) << name; - - LIST_ELF_SYMBOLS_TestGnu(CHECK_SYMBOL); - -#undef CHECK_SYMBOL - - // Check a few undefined symbols. - EXPECT_FALSE(table.LookupByName("ahahahahah", kTestGnuSymbolTable, - kTestGnuStringTable)); - EXPECT_FALSE( - table.LookupByName("strsign", kTestGnuSymbolTable, kTestGnuStringTable)); -} - -TEST(GnuHashTable, DynSymbols) { - GnuHashTable table; - table.Init(reinterpret_cast<uintptr_t>(&kTestGnuHashTable)); - EXPECT_TRUE(table.IsValid()); - - const size_t kExpectedOffset = kTestGnuHashTable[1]; - const size_t kExpectedCount = - (sizeof(kTestGnuSymbolTable) / sizeof(kTestGnuSymbolTable[0])) - - kExpectedOffset; - - EXPECT_EQ(kExpectedOffset, table.dyn_symbols_offset()); - EXPECT_EQ(kExpectedCount, table.dyn_symbols_count()); -} - -} // namespace testing -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp deleted file mode 100644 index 68f9de3..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.cpp +++ /dev/null
@@ -1,512 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_library_list.h" - -#include <assert.h> -#include <crazy_linker.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_library_view.h" -#include "crazy_linker_pointer_set.h" -#include "crazy_linker_rdebug.h" -#include "crazy_linker_shared_library.h" -#include "crazy_linker_system.h" -#include "crazy_linker_system_linker.h" -#include "crazy_linker_util.h" - -#ifdef __ANDROID__ -#include "crazy_linker_system_android.h" -#endif - -namespace crazy { - -namespace { - -// A helper struct used when looking up symbols in libraries. -struct SymbolLookupState { - void* found_addr = nullptr; - void* weak_addr = nullptr; - int weak_count = 0; - - // Check a symbol entry. - bool CheckSymbol(const char* symbol, const SharedLibrary* lib) { - const ELF::Sym* entry = lib->LookupSymbolEntry(symbol); - if (!entry) - return false; - - void* address = reinterpret_cast<void*>(lib->load_bias() + entry->st_value); - - // If this is a strong symbol, record it and return true. - if (ELF_ST_BIND(entry->st_info) == STB_GLOBAL) { - found_addr = address; - return true; - } - // If this is a weak symbol, record the first one and - // increment the weak_count. - if (++weak_count == 1) - weak_addr = address; - - return false; - } -}; - -// Checks that |params| is compatible with a system library load. -// On success return true. On failure, set |*error| and return false. -// |lib_name| is either the library name, or nullptr, in which case -// |params.library_path| will be used for the error message. -bool CheckSystemLibraryLoadParams(const char* lib_name, - const LoadParams& params, - Error* error) { - if (!lib_name) - lib_name = params.library_path.c_str(); - - if (params.library_fd >= 0) { - error->Format("Cannot load system library from fd %d: %s", - params.library_fd, lib_name); - return false; - } - if (params.library_offset != 0) { - error->Format("Cannot load system library from offset 0x%08lx: %s", - static_cast<unsigned long>(params.library_offset), lib_name); - return false; - } - if (params.wanted_address != 0) { - error->Format("Cannot load system library at address 0x%08lx: %s", - static_cast<unsigned long>(params.wanted_address), lib_name); - return false; - } - if (params.reserved_size != 0) { - error->Format("Cannot load system library in reserved memory map: %s", - lib_name); - } - return true; -} - -} // namespace - -LibraryList::LibraryList() { -#ifdef __ANDROID__ - const int sdk_build_version = GetAndroidDeviceApiLevel(); - - // If SDK version is Lollipop or earlier, we need to load anything - // listed in LD_PRELOAD explicitly, because dlsym() on the main executable - // fails to lookup in preloads on those releases. Also, when doing our - // symbol resolution we need to explicity search preloads *before* we - // search the main executable, to ensure that preloads override symbols - // correctly. Searching preloads before main is opposite to the way the - // system linker's ordering of these searches, but it is required here to - // work round the platform's dlsym() issue. - // - // If SDK version is Lollipop-mr1 or later then dlsym() will search - // preloads when invoked on the main executable, meaning that we do not - // want (or need) to load them here. The platform itself will take care - // of them for us, and so by not loading preloads here our preloads list - // remains empty, so that searching it for name lookups is a no-op. - // - // For more, see: - // https://code.google.com/p/android/issues/detail?id=74255 - if (sdk_build_version <= ANDROID_SDK_VERSION_CODE_LOLLIPOP) - LoadPreloads(); -#endif // __ANDROID__ -} - -LibraryList::~LibraryList() { - // Invalidate crazy library list. - head_ = nullptr; - - // Destroy all known libraries in reverse order. - while (!known_libraries_.IsEmpty()) { - LibraryView* view = known_libraries_.PopLast(); - delete view; - } -} - -void LibraryList::LoadPreloads() { - const char* ld_preload = GetEnv("LD_PRELOAD"); - if (!ld_preload) - return; - - LOG("Preloads list is: %s", ld_preload); - const char* current = ld_preload; - const char* end = ld_preload + strlen(ld_preload); - - // Iterate over library names listed in the environment. The separator - // here may be either space or colon. - while (current < end) { - const char* item = current; - const size_t item_length = strcspn(current, " :"); - if (item_length == 0) { - current += 1; - continue; - } - current = item + item_length + 1; - - String lib_name(item, item_length); - LOG("Attempting to preload %s", lib_name.c_str()); - - if (FindKnownLibrary(lib_name.c_str())) { - LOG("already loaded %s: ignoring", lib_name.c_str()); - continue; - } - - Error error; - LibraryView* preload = LoadLibraryWithSystemLinker( - lib_name.c_str(), RTLD_NOW | RTLD_GLOBAL, &error); - if (!preload) { - LOG("'%s' cannot be preloaded: ignored\n", lib_name.c_str()); - continue; - } - - preloaded_libraries_.PushBack(preload); - } - - if (CRAZY_DEBUG) { - LOG("Preloads loaded"); - for (const LibraryView* preload : preloaded_libraries_) - LOG(" ... %p %s\n", preload, preload->GetName()); - LOG(" preloads @%p\n", &preloaded_libraries_); - } -} - -LibraryView* LibraryList::FindLibraryByName(const char* lib_name) { - // Sanity check. - if (!lib_name) - return nullptr; - - for (LibraryView* view : known_libraries_) { - if (!strcmp(lib_name, view->GetName())) - return view; - } - return nullptr; -} - -void* LibraryList::FindSymbolFrom(const char* symbol_name, - const LibraryView* from) { - SymbolLookupState lookup_state; - - if (!from) - return nullptr; - - // Use a work-queue and a set to ensure to perform a breadth-first - // search. - Vector<const LibraryView*> work_queue; - PointerSet visited_set; - - work_queue.PushBack(from); - - while (!work_queue.IsEmpty()) { - const LibraryView* lib = work_queue.PopFirst(); - const SharedLibrary* crazy_lib = lib->GetCrazy(); - if (crazy_lib) { - if (lookup_state.CheckSymbol(symbol_name, crazy_lib)) - return lookup_state.found_addr; - } else if (lib->IsSystem()) { - LibraryView::SearchResult sym = lib->LookupSymbol(symbol_name); - if (sym.IsValid()) - return sym.address; - } - - // If this is a crazy library, add non-visited dependencies - // to the work queue. - if (crazy_lib) { - SharedLibrary::DependencyIterator iter(crazy_lib); - while (iter.GetNext()) { - LibraryView* dependency = FindKnownLibrary(iter.GetName()); - if (dependency && !visited_set.Has(dependency)) { - work_queue.PushBack(dependency); - visited_set.Add(dependency); - } - } - } - } - - if (lookup_state.weak_count >= 1) { - // There was at least a single weak symbol definition, so use - // the first one found in breadth-first search order. - return lookup_state.weak_addr; - } - - // There was no symbol definition. - return nullptr; -} - -LibraryView* LibraryList::FindLibraryForAddress(void* address) { - // Linearly scan all libraries, looking for one that contains - // a given address. NOTE: This doesn't check that this falls - // inside one of the mapped library segments. - for (LibraryView* view : known_libraries_) { - // TODO(digit): Search addresses inside system libraries. - if (view->IsCrazy()) { - SharedLibrary* lib = view->GetCrazy(); - if (lib->ContainsAddress(address)) - return view; - } - } - return nullptr; -} - -#ifdef __arm__ -_Unwind_Ptr LibraryList::FindArmExIdx(void* pc, int* count) { - for (SharedLibrary* lib = head_; lib; lib = lib->list_next_) { - if (lib->ContainsAddress(pc)) { - *count = static_cast<int>(lib->arm_exidx_count_); - return reinterpret_cast<_Unwind_Ptr>(lib->arm_exidx_); - } - } - *count = 0; - return static_cast<_Unwind_Ptr>(NULL); -} -#else // !__arm__ -int LibraryList::IteratePhdr(PhdrIterationCallback callback, void* data) { - int result = 0; - for (SharedLibrary* lib = head_; lib; lib = lib->list_next_) { - dl_phdr_info info; - info.dlpi_addr = lib->link_map_.l_addr; - info.dlpi_name = lib->link_map_.l_name; - info.dlpi_phdr = lib->phdr(); - info.dlpi_phnum = lib->phdr_count(); - result = callback(&info, sizeof(info), data); - if (result) - break; - } - return result; -} -#endif // !__arm__ - -void LibraryList::UnloadLibrary(LibraryView* wrap) { - // Sanity check. - LOG("for %s (ref_count=%d)", wrap->GetName(), wrap->ref_count()); - - if (!wrap->IsSystem() && !wrap->IsCrazy()) - return; - - if (!wrap->SafeDecrementRef()) - return; - - // If this is a crazy library, perform manual cleanup first. - SharedLibrary* lib = wrap->GetCrazy(); - if (lib) { - // Remove from internal list of crazy libraries. - if (lib->list_next_) - lib->list_next_->list_prev_ = lib->list_prev_; - if (lib->list_prev_) - lib->list_prev_->list_next_ = lib->list_next_; - if (lib == head_) - head_ = lib->list_next_; - - // Call JNI_OnUnload, if necessary, then the destructors. - LOG("Running JNI_OnUnload() for %s", wrap->GetName()); - lib->CallJniOnUnload(); - LOG("Running destructors for %s", wrap->GetName()); - lib->CallDestructors(); - - // Unload the dependencies recursively. - SharedLibrary::DependencyIterator iter(lib); - while (iter.GetNext()) { - LibraryView* dependency = FindKnownLibrary(iter.GetName()); - if (dependency) - UnloadLibrary(dependency); - } - - // Tell GDB of this removal. - Globals::GetRDebug()->DelEntry(&lib->link_map_); - } - - known_libraries_.Remove(wrap); - - // Delete the wrapper, which will delete the crazy library, or - // dlclose() the system one. - delete wrap; -} - -LibraryView* LibraryList::LoadLibraryWithSystemLinker(const char* lib_name, - int dlopen_mode, - Error* error) { - // First check whether a library with the same base name was - // already loaded. - ASSERT(!FindKnownLibrary(lib_name), - "System library already loaded: ", lib_name); - - void* system_lib = SystemLinker::Open(lib_name, dlopen_mode); - if (!system_lib) { - error->Format("Can't load system library %s: %s", lib_name, - SystemLinker::Error()); - return nullptr; - } - - // Can't really find the DT_SONAME of this library, assume if is its basename. - LibraryView* view = new LibraryView(system_lib, GetBaseNamePtr(lib_name)); - known_libraries_.PushBack(view); - - LOG("System library %s loaded at %p", lib_name, view); - return view; -} - -Expected<LibraryView*> LibraryList::FindAndCheckLoadedLibrary( - const char* lib_name, - const LoadParams& params, - Error* error) { - // First check whether a library with the same base name was already loaded. - LibraryView* view = FindKnownLibrary(lib_name); - if (!view) - return nullptr; - - if (view->IsSystem()) { - if (!CheckSystemLibraryLoadParams(lib_name, params, error)) - return error; - } else { - const SharedLibrary* crazy_lib = view->GetCrazy(); - ASSERT(crazy_lib != nullptr, "Not a crazy library"); - if (params.wanted_address) { - // Check that this is a crazy library and that is was loaded at - // the correct address. - uintptr_t actual_address = crazy_lib->load_address(); - if (actual_address != params.wanted_address) { - error->Format( - "Library already loaded at address 0x%08lx, can't load it at " - "0x%08lx: %s", - static_cast<unsigned long>(actual_address), - static_cast<unsigned long>(params.wanted_address), lib_name); - return error; - } - } - } - - view->AddRef(); - return view; -} - -// static -bool LibraryList::LocateLibraryFile(const char* lib_name, - const SearchPathList& search_path_list, - LoadParams* params, - Error* error) { - LOG("Looking through the search path list"); - SearchPathList::Result probe = search_path_list.FindFile(lib_name); - if (!probe.IsValid()) { - error->Format("Can't find library file %s", lib_name); - return false; - } - LOG("Found library: path %s @ 0x%x", probe.path.c_str(), probe.offset); - params->library_path = std::move(probe.path); - params->library_offset = probe.offset; - return true; -} - -LibraryView* LibraryList::LoadLibrary(const char* lib_name, - const LoadParams& params, - Error* error) { - Expected<LibraryView*> found = - FindAndCheckLoadedLibrary(lib_name, params, error); - if (!found.has_value()) - return nullptr; - if (found.value()) - return found.value(); - return LoadLibraryInternal(params, error); -} - -LibraryView* LibraryList::LoadLibraryInternal(const LoadParams& params, - Error* error) { - // Load the library with the system linker if necessary. - const char* lib_path = params.library_path.c_str(); - if (IsSystemLibraryPath(lib_path)) { - if (!CheckSystemLibraryLoadParams(lib_path, params, error)) - return nullptr; - return LoadLibraryWithSystemLinker(lib_path, RTLD_NOW, error); - } - - // Load the library with the crazy linker. - ScopedPtr<SharedLibrary> lib(new SharedLibrary()); - if (!lib->Load(params, error)) - return nullptr; - - // Load all dependendent libraries. - const char* base_name = GetBaseNamePtr(lib_path); - LOG("Loading dependencies of %s", base_name); - SharedLibrary::DependencyIterator iter(lib.Get()); - Vector<LibraryView*> dependencies; - while (iter.GetNext()) { - Error dep_error; - // TODO(digit): Better library dependency loading that isn't limited - // to system libraries. This would allow the linker to load anything - // without the caller having to load all dependencies before hand in - // reverse topological order. - const char* dependency_name = iter.GetName(); - LibraryView* dependency = FindKnownLibrary(dependency_name); - if (!dependency) { - dependency = - LoadLibraryWithSystemLinker(dependency_name, RTLD_NOW, &dep_error); - if (!dependency) { - error->Format("When loading %s: %s", base_name, dep_error.c_str()); - // TODO(digit): Unload all dependencies that were loaded so far. - return nullptr; - } - } - dependencies.PushBack(dependency); - } - if (CRAZY_DEBUG) { - LOG("Dependencies loaded for %s", base_name); - for (const LibraryView* dep : dependencies) - LOG(" ... %p %s", dep, dep->GetName()); - LOG(" dependencies @%p", &dependencies); - } - - // Relocate the library. - LOG("Relocating %s", base_name); - if (!lib->Relocate(this, &preloaded_libraries_, &dependencies, error)) - return nullptr; - - // Notify GDB of load. - lib->link_map_.l_addr = lib->load_bias(); - lib->link_map_.l_name = const_cast<char*>(lib->base_name_); - lib->link_map_.l_ld = reinterpret_cast<uintptr_t>(lib->view_.dynamic()); - Globals::GetRDebug()->AddEntry(&lib->link_map_); - - // The library was properly loaded, add it to the list of crazy - // libraries. IMPORTANT: Do this _before_ calling the constructors - // because these could call dlopen(). - lib->list_next_ = head_; - lib->list_prev_ = nullptr; - if (head_) - head_->list_prev_ = lib.Get(); - head_ = lib.Get(); - - // Then create a new LibraryView for it. - LibraryView* view = new LibraryView(lib.Release()); - known_libraries_.PushBack(view); - - LOG("Running constructors for %s", base_name); - // Now run the constructors. - view->GetCrazy()->CallConstructors(); - - // Then try to call JNI_OnLoad() if necessary. - LOG("Running JNI_OnLoad() for %s", base_name); - Globals* globals = Globals::Get(); - if (!view->GetCrazy()->CallJniOnLoad(globals->java_vm(), - globals->minimum_jni_version(), error)) { - LOG("Error on JNI_OnLoad(): %s", error->c_str()); - UnloadLibrary(view); - return nullptr; - } - - LOG("Done loading %s", base_name); - return view; -} - -void LibraryList::AddLibrary(LibraryView* wrap) { - known_libraries_.PushBack(wrap); -} - -LibraryView* LibraryList::FindKnownLibrary(const char* name) { - const char* base_name = GetBaseNamePtr(name); - for (LibraryView* view : known_libraries_) { - if (!strcmp(base_name, view->GetName())) - return view; - } - return nullptr; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.h b/third_party/android_crazy_linker/src/src/crazy_linker_library_list.h deleted file mode 100644 index ed8ca50..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_list.h +++ /dev/null
@@ -1,147 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_LIBRARY_LIST_H -#define CRAZY_LINKER_LIBRARY_LIST_H - -#include <link.h> - -#include "crazy_linker_error.h" -#include "crazy_linker_expected.h" -#include "crazy_linker_load_params.h" -#include "crazy_linker_search_path_list.h" -#include "elf_traits.h" - -// This header contains definitions related to the global list of -// library views maintained by the crazy linker. Each library view -// points to either a crazy library, or a system one. - -namespace crazy { - -class SharedLibrary; -class LibraryView; - -// The list of all shared libraries loaded by the crazy linker. -// IMPORTANT: This class is not thread-safe! -class LibraryList { - public: - LibraryList(); - ~LibraryList(); - - // Find a library in the list by its base name. - // |base_name| must not contain a directory separator. - LibraryView* FindLibraryByName(const char* base_name); - - // Lookup for a given |symbol_name|, starting from |from_lib| - // then through its dependencies in breadth-first search order. - // On failure, returns NULL. - void* FindSymbolFrom(const char* symbol_name, const LibraryView* from_lib); - - // Return the address of a visible given symbol. Used to implement - // the dlsym() wrapper. Returns NULL on failure. - void* FindAddressForSymbol(const char* symbol_name); - - // Find a SharedLibrary that contains a given address, or NULL if none - // could be found. This simply scans all libraries. - LibraryView* FindLibraryForAddress(void* address); - -#ifdef __arm__ - // Find the base address of the .ARM.exidx section corresponding - // to the address |pc|, as well as the number of 8-byte entries in - // the table into |*count|. Used to implement the wrapper for - // dl_unwind_find_exidx(). - _Unwind_Ptr FindArmExIdx(void* pc, int* count); -#else - typedef int (*PhdrIterationCallback)(dl_phdr_info* info, - size_t info_size, - void* data); - - // Loop over all loaded libraries and call the |cb| callback - // on each iteration. If the function returns 0, stop immediately - // and return its value. Used to implement the wrapper for - // dl_iterate_phdr(). - int IteratePhdr(PhdrIterationCallback callback, void* data); -#endif - - // Find whether a library identified by |name| has already been loaded. - // Note that |name| should correspond to the library's unique soname, which - // comes from its DT_SONAME entry, and typically, but not necessarily - // matches its base name. - LibraryView* FindKnownLibrary(const char* name); - - // Check whether |lib_path| matches an already loaded library, compatible - // with the content of |load_params| (except its |library_path| field). - // On failure, i.e. if the load parameters are incompatible, set |*error| - // and return its address. On success, return either nullptr (if the library - // was not previously loaded, or a LibraryView* pointer after incrementing - // its reference count). - Expected<LibraryView*> FindAndCheckLoadedLibrary( - const char* lib_path, - const LoadParams& load_params, - Error* error); - - // Locate library |lib_name| using |search_path_list|. On success, update - // |params->library_path| and |params->library_offset| and return true. On - // failure, set |*error| and return false. - static bool LocateLibraryFile(const char* lib_name, - const SearchPathList& search_path_list, - LoadParams* params, - Error* error); - - // Try to load a library, according to |load_params|. On failure, returns - // nullptr and sets the |error| message. - LibraryView* LoadLibrary(const char* lib_name, - const LoadParams& load_params, - Error* error); - - // Try to load a library, according to |load_params|. - // On failure, return nullptr and sets the |error| message. - // Note: this will fail if the library is already loaded. - LibraryView* LoadLibraryInternal(const LoadParams& load_params, Error* error); - - // Unload a given shared library. This really decrements the library's - // internal reference count. When it reaches zero, the library's - // destructors are run, its dependencies are unloaded, then the - // library is removed from memory. - void UnloadLibrary(LibraryView* lib); - - // Used internally by the wrappers only. - void AddLibrary(LibraryView* lib); - - private: - LibraryList(const LibraryList&); - LibraryList& operator=(const LibraryList&); - - // Preload any libraries that override symbols in later loads. - // Called once only, on library list construction. Libraries to preload - // are controlled by LD_PRELOAD. - void LoadPreloads(); - - // Load a library with the system linker and a specific set of flags. - // |lib_name| is the library name or path, |dlopen_flags| should be - // a set of RTLD_XXX flags. On success, return a new LibraryView pointer. - // On failure, set |*error| then return nullptr. - LibraryView* LoadLibraryWithSystemLinker(const char* lib_name, - int dlopen_flags, - Error* error); - - void ClearError(); - - // The list of all preloaded libraries. - Vector<LibraryView*> preloaded_libraries_; - - // The list of all known libraries. - Vector<LibraryView*> known_libraries_; - - // The list of all libraries loaded by the crazy linker. - // This does _not_ include system libraries present in known_libraries_. - SharedLibrary* head_ = nullptr; - - bool has_error_ = false; - char error_buffer_[512]; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_LIBRARY_LIST_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_view.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_library_view.cpp deleted file mode 100644 index 70601c1..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_view.cpp +++ /dev/null
@@ -1,60 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_library_view.h" - -#include "crazy_linker_debug.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_shared_library.h" -#include "crazy_linker_system_linker.h" - -namespace crazy { - -LibraryView::LibraryView(SharedLibrary* crazy_lib) - : type_(TYPE_CRAZY), crazy_(crazy_lib), name_(crazy_lib->soname()) {} - -LibraryView::~LibraryView() { - LOG("Destroying %s", name_.c_str()); - if (type_ == TYPE_SYSTEM) { - SystemLinker::Close(system_); - system_ = NULL; - } else if (type_ == TYPE_CRAZY) { - delete crazy_; - crazy_ = NULL; - } - type_ = TYPE_NONE; -} - -LibraryView::SearchResult LibraryView::LookupSymbol( - const char* symbol_name) const { - if (type_ == TYPE_SYSTEM) { - SystemLinker::SearchResult result = - SystemLinker::Resolve(system_, symbol_name); - if (result.IsValid()) { - return {result.address, this}; - } - } else if (type_ == TYPE_CRAZY) { - LibraryList* lib_list = Globals::Get()->libraries(); - void* address = lib_list->FindSymbolFrom(symbol_name, this); - if (address) { - return {address, this}; - } - } - return {}; -} - -bool LibraryView::GetInfo(size_t* load_address, - size_t* load_size, - size_t* relro_start, - size_t* relro_size, - Error* error) const { - if (type_ != TYPE_CRAZY) { - *error = "No RELRO sharing with system libraries"; - return false; - } - crazy_->GetInfo(load_address, load_size, relro_start, relro_size); - return true; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h b/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h deleted file mode 100644 index d071fcad..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_library_view.h +++ /dev/null
@@ -1,104 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_LIBRARY_VIEW_H -#define CRAZY_LINKER_LIBRARY_VIEW_H - -#include "crazy_linker_error.h" -#include "crazy_linker_util.h" - -namespace crazy { - -class SharedLibrary; - -// A LibraryView is a reference-counted handle to either a -// crazy::SharedLibrary object or a library handle returned by the system's -// dlopen() function. -// -// It has a name, which normally corresponds to the DT_SONAME entry in the -// dynamic table (i.e. the name embedded within the ELF file, which does not -// always matches its file path name). -class LibraryView { - public: - enum { - TYPE_NONE = 0xbaadbaad, - TYPE_SYSTEM = 0x2387cef, - TYPE_CRAZY = 0xcdef2387, - }; - - // Constructor for wrapping a system library handle. - // |system_lib| is the dlopen() handle, and |lib_name| should be the - // library soname for it. - LibraryView(void* system_handle, const char* lib_name) - : type_(TYPE_SYSTEM), system_(system_handle), name_(lib_name) {} - - // Constructor for warpping a crazy::SharedLibrary instance. - // This version takes the library name from the its soname() value. - LibraryView(SharedLibrary* crazy_lib); - - // Destructor, this will either dlclose() a system library, or delete - // a SharedLibrary instance. - ~LibraryView(); - - // Returns true iff this is a system library handle. - bool IsSystem() const { return type_ == TYPE_SYSTEM; } - - // Returns true iff this is a SharedLibrary instance. - bool IsCrazy() const { return type_ == TYPE_CRAZY; } - - // Returns the soname of the current library (or its base name if not - // available). - const char* GetName() const { return name_.c_str(); } - - // Returns SharedLibrary handle if valid, nullptr otherwise. - const SharedLibrary* GetCrazy() const { return IsCrazy() ? crazy_ : nullptr; } - SharedLibrary* GetCrazy() { return IsCrazy() ? crazy_ : nullptr; } - - // Returns system handle if valid, nullptr otherwise. - void* GetSystem() const { return IsSystem() ? system_ : NULL; } - - // Increment reference count for this LibraryView. - void AddRef() { ref_count_++; } - - // Decrement reference count. Returns true iff it reaches 0. - // This never destroys the object. - bool SafeDecrementRef() { return (--ref_count_ == 0); } - - // Result type for LookupSymbol() - struct SearchResult { - void* address = nullptr; - const LibraryView* library = nullptr; - - constexpr bool IsValid() const { return library != nullptr; } - }; - - // Lookup a symbol from this library. - // If this is a crazy library, only looks directly in the library (and none - // of its dependencies). For system libraries, this uses dlsym() which will - // perform a breadth-first-search. - SearchResult LookupSymbol(const char* symbol_name) const; - - // Retrieve library information. - bool GetInfo(size_t* load_address, - size_t* load_size, - size_t* relro_start, - size_t* relro_size, - Error* error) const; - - // Only used for debugging. - int ref_count() const { return ref_count_; } - - private: - uint32_t type_ = TYPE_NONE; - int ref_count_ = 1; - union { - SharedLibrary* crazy_ = nullptr; - void* system_; - }; - String name_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_LIBRARY_VIEW_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.cpp deleted file mode 100644 index acccb7b..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.cpp +++ /dev/null
@@ -1,102 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_line_reader.h" - -#include "crazy_linker_debug.h" - -// Set to 1 to enable debug logs here. -#define DEBUG_LINE_READER 0 - -#define LLOG(...) LOG_IF(DEBUG_LINE_READER, __VA_ARGS__) - -namespace crazy { - -LineReader::LineReader(const char* path, size_t capacity) - : fd_(path), - eof_(!fd_.IsOk()), - buff_capacity_(capacity), - buff_(static_cast<char*>(::malloc(capacity))) {} - -LineReader::~LineReader() { - ::free(buff_); -} - -bool LineReader::GetNextLine() { - // Eat previous line. - line_start_ += line_len_; - line_len_ = 0; - - for (;;) { - LLOG("LOOP line_start=%d buff_size=%d buff_capacity=%d", line_start_, - buff_size_, buff_capacity_); - - // Find the end of the current line in the current buffer. The result - // of memchr(_,_,0) is undefined, treated as not-found. - const char* line = buff_ + line_start_; - const size_t range = buff_size_ - line_start_; - const char* line_end; - if (range > 0) - line_end = reinterpret_cast<const char*>(::memchr(line, '\n', range)); - else - line_end = NULL; - if (line_end != NULL) { - // Found one, return it directly. - line_len_ = static_cast<size_t>(line_end + 1 - line); - LLOG("LINE line_start=%d line_len=%d '%.*s'\n", line_start_, line_len_, - line_len_, buff_ + line_start_); - return true; - } - - // Eat the start of the buffer - if (line_start_ > 0) { - ::memmove(buff_, buff_ + line_start_, buff_size_ - line_start_); - buff_size_ -= line_start_; - line_start_ = 0; - LLOG("MOVE buff_size=%d", buff_size_); - } - - // Handle end of input now. - if (eof_) { - // If there is a last line that isn't terminated by a newline, and - // there is room for it in the buffer. Manually add a \n and return - // the line. - if (buff_size_ > 0 && buff_size_ < buff_capacity_) { - buff_[buff_size_++] = '\n'; - line_len_ = buff_size_; - LLOG("EOF_LINE buff_size=%d '%.*s'\n", buff_size_, buff_size_, buff_); - return true; - } - // Otherwise, ignore the last line. - LLOG("EOF"); - return false; - } - - // Before reading more data, grow the buffer if needed. - if (buff_size_ == buff_capacity_) { - buff_capacity_ *= 2; - buff_ = static_cast<char*>(::realloc(buff_, buff_capacity_)); - - LLOG("GROW buff_size=%d buff_capacity=%d '%.*s'\n", buff_size_, - buff_capacity_, buff_size_, buff_); - } - - // Try to fill the rest of buffer after current content. - size_t avail = buff_capacity_ - buff_size_; - int ret = fd_.Read(buff_ + buff_size_, avail); - LLOG("READ buff_size=%d buff_capacity=%d avail=%d ret=%d\n", buff_size_, - buff_capacity_, avail, ret); - if (ret <= 0) { - eof_ = true; - ret = 0; - } - buff_size_ += static_cast<size_t>(ret); - } -} - -const char* LineReader::line() const { return buff_ + line_start_; } - -size_t LineReader::length() const { return line_len_; } - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.h b/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.h deleted file mode 100644 index 9ac784f..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader.h +++ /dev/null
@@ -1,58 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_LINE_READER_H -#define CRAZY_LINKER_LINE_READER_H - -#include <string.h> - -#include "crazy_linker_system.h" - -namespace crazy { - -// A class used to read text files line-by-line. -// Usage: -// LineReader reader("/path/to/file"); -// while (reader.GetNextLine()) { -// const char* line = reader.line(); -// size_t line_len = reader.length(); -// ... line is not necessarily zero-terminated. -// } - -class LineReader { - public: - // Construct new instance. |path| is the input file path, and - // |capacity| is the initial internal buffer capacity. Use a larger capacity - // if you expect the input file to be large, in order to speed up parsing. - // If opening the file fails, GetNextLine() will simply return false on - // the first call. - LineReader(const char* path, size_t capacity = 128); - - ~LineReader(); - - // Grab next line. Returns true on success, or false otherwise. - bool GetNextLine(); - - // Return the start of the current line, this is _not_ zero-terminated - // and always contains a final newline (\n). - // Only call this after a successful GetNextLine(). - const char* line() const; - - // Return the line length, this includes the final \n. - // Only call this after a successful GetNextLine(). - size_t length() const; - - private: - FileDescriptor fd_; - bool eof_ = false; - size_t line_start_ = 0; - size_t line_len_ = 0; - size_t buff_size_ = 0; - size_t buff_capacity_ = 0; - char* buff_ = nullptr; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_LINE_READER_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_line_reader_unittest.cpp deleted file mode 100644 index 0e821d8..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_line_reader_unittest.cpp +++ /dev/null
@@ -1,114 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_line_reader.h" - -#include <gtest/gtest.h> - -#include "crazy_linker_system_mock.h" - -namespace crazy { - -static const char kFilePath[] = "/tmp/foo.txt"; - -static ::testing::AssertionResult AssertMemEqual(const char* expr1, - const char* expr2, - const char* expr3, - const char* expr4, - const char* expected_str, - size_t expected_len, - const char* arg_str, - size_t arg_len) { - if (arg_len != expected_len) { - return ::testing::AssertionFailure() - << "Invalid value for '" << expr4 << "': " << arg_len - << " (expecting '" << expr2 << "' which is " << expected_len << ")"; - } - for (size_t n = 0; n < arg_len; ++n) { - if (arg_str[n] != expected_str[n]) { - return ::testing::AssertionFailure() - << "Invalid value " << (unsigned)arg_str[n] << " at index " << n - << "\nWhen comparing " << expr3 << " with expected " << expr1; - } - } - return ::testing::AssertionSuccess(); -} - -#define EXPECT_MEMEQ(expected_str, expected_len, arg_str, arg_len) \ - EXPECT_PRED_FORMAT4(AssertMemEqual, expected_str, expected_len, arg_str, \ - arg_len) - -TEST(LineReader, EmptyFile) { - SystemMock sys; - sys.AddRegularFile(kFilePath, "", 0); - - LineReader reader(kFilePath); - EXPECT_FALSE(reader.GetNextLine()); -} - -TEST(LineReader, SingleLineFile) { - SystemMock sys; - static const char kFile[] = "foo bar\n"; - static const size_t kFileSize = sizeof(kFile) - 1; - sys.AddRegularFile(kFilePath, kFile, kFileSize); - - LineReader reader(kFilePath); - EXPECT_TRUE(reader.GetNextLine()); - EXPECT_EQ(kFileSize, reader.length()); - EXPECT_MEMEQ(kFile, kFileSize, reader.line(), reader.length()); - EXPECT_FALSE(reader.GetNextLine()); -} - -TEST(LineReader, SingleLineFileUnterminated) { - SystemMock sys; - static const char kFile[] = "foo bar"; - static const size_t kFileSize = sizeof(kFile) - 1; - sys.AddRegularFile(kFilePath, kFile, kFileSize); - - LineReader reader(kFilePath); - EXPECT_TRUE(reader.GetNextLine()); - // The LineReader will add a newline to the last line. - EXPECT_EQ(kFileSize + 1, reader.length()); - EXPECT_MEMEQ(kFile, kFileSize, reader.line(), reader.length() - 1); - EXPECT_EQ('\n', reader.line()[reader.length() - 1]); - EXPECT_FALSE(reader.GetNextLine()); -} - -TEST(LineReader, MultiLineFile) { - SystemMock sys; - static const char kFile[] = - "This is a multi\n" - "line text file that to test the crazy::LineReader class implementation\n" - "And this is a very long text line to check that the class properly " - "handles them, through the help of dynamic allocation or something. " - "Yadda yadda yadda yadda. No newline"; - static const size_t kFileSize = sizeof(kFile) - 1; - sys.AddRegularFile(kFilePath, kFile, kFileSize); - - LineReader reader(kFilePath); - - EXPECT_TRUE(reader.GetNextLine()); - EXPECT_MEMEQ("This is a multi\n", 16, reader.line(), reader.length()); - - EXPECT_TRUE(reader.GetNextLine()); - EXPECT_MEMEQ( - "line text file that to test the crazy::LineReader class " - "implementation\n", - 88 - 17, - reader.line(), - reader.length()); - - EXPECT_TRUE(reader.GetNextLine()); - EXPECT_MEMEQ( - "And this is a very long text line to check that the class properly " - "handles them, through the help of dynamic allocation or something. " - "Yadda yadda yadda yadda. No newline\n", - 187 - 17, - reader.line(), - reader.length()); - - EXPECT_FALSE(reader.GetNextLine()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_load_params.h b/third_party/android_crazy_linker/src/src/crazy_linker_load_params.h deleted file mode 100644 index 9022313d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_load_params.h +++ /dev/null
@@ -1,42 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_LOAD_PARAMS_H -#define CRAZY_LINKER_LOAD_PARAMS_H - -#include <stddef.h> -#include <stdint.h> -#include <sys/types.h> - -#include "crazy_linker_util.h" - -namespace crazy { - -// A structure used to hold parameters related to loading an ELF library -// into the current process' address space. -// -// |library_path| is either the full library path. -// |library_fd| is a file descriptor. If >= 0, the |library_path| is ignored. -// |library_offset| is the page-aligned offset where the library starts in -// its input file (typically > 0 when reading from Android APKs). -// |wanted_address| is either 0, or the address where the library should -// be loaded. -// |reserved_size| is either 0, or a page-aligned size in bytes corresponding -// to a reserved memory area where to load the library, starting from -// |wanted_address|. -// |reserved_load_fallback| is ignored if |reserved_size| is 0. Otherwise, a -// value of true means that if the load fails at the reserved address range, -// the linker will try again at a different address. -struct LoadParams { - String library_path; - int library_fd = -1; - off_t library_offset = 0; - uintptr_t wanted_address = 0; - uintptr_t reserved_size = 0; - bool reserved_load_fallback = false; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_LOAD_PARAMS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_macros.h b/third_party/android_crazy_linker/src/src/crazy_linker_macros.h deleted file mode 100644 index 57f43e0..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_macros.h +++ /dev/null
@@ -1,26 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_MACROS_H -#define CRAZY_LINKER_MACROS_H - -// Use this inside a class declaration to disallow copy construction and -// assignment. -#define CRAZY_DISALLOW_COPY_OPERATIONS(Class) \ - Class(const Class&) = delete; \ - Class& operator=(const Class&) = delete; - -// Use this inside a class declaration to disallow move construction and -// assignment. -#define CRAZY_DISALLOW_MOVE_OPERATIONS(Class) \ - Class(Class&&) = delete; \ - Class& operator=(Class&&) = delete; - -// Use this inside a class declaration to disallow both copy and move -// construction and assignments. -#define CRAZY_DISALLOW_COPY_AND_MOVE_OPERATIONS(Class) \ - CRAZY_DISALLOW_COPY_OPERATIONS(Class) \ - CRAZY_DISALLOW_MOVE_OPERATIONS(Class) - -#endif // CRAZY_LINKER_MACROS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.cpp deleted file mode 100644 index 3e7f53ca..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.cpp +++ /dev/null
@@ -1,49 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_memory_mapping.h" - -namespace crazy { - -MemoryMapping::~MemoryMapping() { - Deallocate(); -} - -MemoryMapping& MemoryMapping::operator=(MemoryMapping&& other) noexcept { - if (this != &other) { - Deallocate(); - map_ = other.map_; - size_ = other.size_; - other.map_ = nullptr; - other.size_ = 0; - } - return *this; -} - -void MemoryMapping::Deallocate() { - if (map_) { - ::munmap(map_, size_); - map_ = nullptr; - size_ = 0; - } -} - -// static -MemoryMapping MemoryMapping::Create(void* address, - size_t size, - Protection prot, - int fd) { - int flags = (fd >= 0) ? MAP_SHARED : MAP_ANONYMOUS; - if (address) - flags |= MAP_FIXED; - - void* map = ::mmap(address, size, static_cast<int>(prot), flags, fd, 0); - if (map == MAP_FAILED) { - map = nullptr; - size = 0; - } - return {map, size}; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.h b/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.h deleted file mode 100644 index bbe630b..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_memory_mapping.h +++ /dev/null
@@ -1,99 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_MEMORY_MAPPING_H -#define CRAZY_LINKER_MEMORY_MAPPING_H - -#include <errno.h> -#include <sys/mman.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_error.h" - -namespace crazy { - -// Helper class for a scoped memory mapping. Usage is the following: -// -// 1) Call MemoryMapping::Allocate() to allocate a new memory mapping -// and use the IsValid() method on the result to determine success or -// failure. -// -// 2) Alternatively, use the constructor to take ownership of an existing -// memory map range. -// -// 3) Destructor will always unmap the memory range, unless Release() was -// called before. -// -class MemoryMapping { - public: - enum Protection { - CAN_READ = PROT_READ, - CAN_WRITE = PROT_WRITE, - CAN_READ_WRITE = PROT_READ | PROT_WRITE - }; - - // Construct an empty instance. - MemoryMapping() = default; - - // Construct an instance that takes ownership of an existing memory map. - MemoryMapping(void* address, size_t size) : map_(address), size_(size) {} - - // Destructor will unmap the memory if it wasn't deallocated or released. - ~MemoryMapping(); - - // Disallow copies. - MemoryMapping(const MemoryMapping&) = delete; - MemoryMapping& operator=(const MemoryMapping&) = delete; - - // Allow move operations. - MemoryMapping(MemoryMapping&& other) noexcept - : map_(other.map_), size_(other.size_) { - other.map_ = nullptr; - other.size_ = 0; - } - MemoryMapping& operator=(MemoryMapping&& other) noexcept; - - // Returns true iff the instance is valid, i.e. there is a mapped segment. - bool IsValid() const { return map_ != nullptr; } - - void* address() const { return map_; } - size_t size() const { return size_; } - - // Deallocate existing mapping, if any, now. - void Deallocate(); - - // Release the mapping from the instance. The caller is responsible for - // calling ::munmap() on the previous value of address(), using the previous - // value of size() as the second parameter. - void Release() { - map_ = nullptr; - size_ = 0; - } - - // Allocate a new mapping. - // |address| is either NULL or a fixed memory address. - // |size| is the page-aligned size, must be > 0. - // |prot| are the desired protection bit flags. - // |fd| is -1 (for anonymous mappings), or a valid file descriptor. - // Return a new valid instance on success. On failure, return an invalid - // instance and sets errno. - static MemoryMapping Create(void* address, - size_t size, - Protection prot, - int fd); - - // Change the protection flags of the mapping. - // On failure, return false and sets errno. - bool SetProtection(Protection prot) { - return (map_ && ::mprotect(map_, size_, static_cast<int>(prot)) == 0); - } - - protected: - void* map_ = nullptr; - size_t size_ = 0; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_MEMORY_MAPPING_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.cpp deleted file mode 100644 index 5c122bcd..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.cpp +++ /dev/null
@@ -1,50 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_pointer_set.h" - -namespace crazy { - -static SearchResult BinarySearch(const Vector<const void*>& items, - const void* key) { - auto key_val = reinterpret_cast<uintptr_t>(key); - size_t min = 0, max = items.GetCount(); - while (min < max) { - size_t mid = min + ((max - min) >> 1); - auto mid_val = reinterpret_cast<uintptr_t>(items[mid]); - if (mid_val == key_val) { - return {true, mid}; - } - if (mid_val < key_val) - min = mid + 1; - else - max = mid; - } - return {false, min}; -} - -bool PointerSet::Add(const void* item) { - SearchResult ret = BinarySearch(items_, item); - if (ret.found) - return true; - - items_.InsertAt(ret.pos, item); - return false; -} - -bool PointerSet::Remove(const void* item) { - SearchResult ret = BinarySearch(items_, item); - if (!ret.found) - return false; - - items_.RemoveAt(ret.pos); - return true; -} - -bool PointerSet::Has(const void* item) const { - SearchResult ret = BinarySearch(items_, item); - return ret.found; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.h b/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.h deleted file mode 100644 index 6995dba..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set.h +++ /dev/null
@@ -1,39 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_POINTER_SET_H -#define CRAZY_LINKER_POINTER_SET_H - -#include "crazy_linker_util.h" - -namespace crazy { - -// A small container for pointer values (addresses). -class PointerSet { - public: - PointerSet() = default; - - // Add a new value to the set. - bool Add(const void* item); - - // Remove value |item| from the set, if needed. Returns true if the value - // was previously in the set, false otherwise. - bool Remove(const void* item); - - // Returns true iff the set contains |item|, false otherwise. - bool Has(const void* item) const; - - // Return a reference to the values in the set, only for testing. - const Vector<const void*>& GetValuesForTesting() const { return items_; } - - private: - // TECHNICAL NOTE: The current implementation uses a simple sorted array, - // and thus should perform well for sets of a few hundred items, when - // insertions and removals are pretty rare, but lookups need to be fast. - Vector<const void*> items_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_POINTER_SET_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set_unittest.cpp deleted file mode 100644 index 634311c3..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_pointer_set_unittest.cpp +++ /dev/null
@@ -1,93 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_pointer_set.h" - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(PointerSet, DefaultIsEmpty) { - PointerSet set; - EXPECT_FALSE(set.Has(nullptr)); - - const Vector<const void*>& values = set.GetValuesForTesting(); - EXPECT_TRUE(values.IsEmpty()); -} - -TEST(PointerSet, Has) { - PointerSet set; - - // nullptr is a perfectly valid value in the set. - EXPECT_FALSE(set.Has(nullptr)); - EXPECT_FALSE(set.Add(nullptr)); - EXPECT_TRUE(set.Has(nullptr)); - - const Vector<const void*>& values = set.GetValuesForTesting(); - EXPECT_FALSE(values.IsEmpty()); - EXPECT_EQ(1U, values.GetCount()); - EXPECT_EQ(nullptr, values[0]); -} - -TEST(PointerSet, Add) { - PointerSet set; - - auto* kOne = reinterpret_cast<void*>(1); - auto* kTwo = reinterpret_cast<void*>(2); - auto* kTen = reinterpret_cast<void*>(10); - - EXPECT_FALSE(set.Add(kOne)); - EXPECT_TRUE(set.Add(kOne)); - EXPECT_FALSE(set.Add(kTen)); - - EXPECT_TRUE(set.Has(kOne)); - EXPECT_FALSE(set.Has(kTwo)); - EXPECT_TRUE(set.Has(kTen)); - - const Vector<const void*>& values = set.GetValuesForTesting(); - EXPECT_FALSE(values.IsEmpty()); - EXPECT_EQ(2U, values.GetCount()); - EXPECT_EQ(kOne, values[0]); - EXPECT_EQ(kTen, values[1]); -} - -TEST(PointerSet, Remove) { - PointerSet set; - - auto* kOne = reinterpret_cast<void*>(1); - auto* kTwo = reinterpret_cast<void*>(2); - auto* kTen = reinterpret_cast<void*>(10); - - EXPECT_FALSE(set.Add(kOne)); - EXPECT_FALSE(set.Add(kTwo)); - EXPECT_FALSE(set.Add(kTen)); - - EXPECT_TRUE(set.Has(kOne)); - EXPECT_TRUE(set.Has(kTwo)); - EXPECT_TRUE(set.Has(kTen)); - - const Vector<const void*>& values = set.GetValuesForTesting(); - EXPECT_FALSE(values.IsEmpty()); - EXPECT_EQ(3U, values.GetCount()); - - EXPECT_TRUE(set.Remove(kTwo)); - - EXPECT_TRUE(set.Has(kOne)); - EXPECT_FALSE(set.Has(kTwo)); - EXPECT_TRUE(set.Has(kTen)); - - EXPECT_FALSE(values.IsEmpty()); - EXPECT_EQ(2U, values.GetCount()); - - EXPECT_FALSE(set.Remove(kTwo)); - - EXPECT_FALSE(values.IsEmpty()); - EXPECT_EQ(2U, values.GetCount()); - - EXPECT_EQ(2U, values.GetCount()); - EXPECT_EQ(kOne, values[0]); - EXPECT_EQ(kTen, values[1]); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp deleted file mode 100644 index e9ecc5e8..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.cpp +++ /dev/null
@@ -1,244 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_proc_maps.h" - -#include <inttypes.h> -#include <limits.h> - -#include "elf_traits.h" -#include "crazy_linker_debug.h" -#include "crazy_linker_line_reader.h" -#include "crazy_linker_util.h" -#include "crazy_linker_system.h" - -namespace crazy { - -namespace { - -// Decompose the components of a /proc/$PID/maps file into multiple -// components. |line| should be the address of a zero-terminated line -// of input. On success, returns true and sets |*entry|, false otherwise. -// -// IMPORTANT: On success, |entry->path| will point into the input line, -// the caller will have to copy the string into a different location if -// it needs to persist it. -bool ParseProcMapsLine(const char* line, - const char* line_end, - ProcMaps::Entry* entry) { - // Example input lines on a 64-bit system, one cannot assume that - // everything is properly sized. - // - // 00400000-0040b000 r-xp 00000000 08:01 6570708 - // /bin/cat - // 0060a000-0060b000 r--p 0000a000 08:01 6570708 - // /bin/cat - // 0060b000-0060c000 rw-p 0000b000 08:01 6570708 - // /bin/cat - // 01dd0000-01df1000 rw-p 00000000 00:00 0 - // [heap] - // 7f4b8d4d7000-7f4b8e22a000 r--p 00000000 08:01 38666648 - // /usr/lib/locale/locale-archive - // 7f4b8e22a000-7f4b8e3df000 r-xp 00000000 08:01 28836281 - // /lib/x86_64-linux-gnu/libc-2.15.so - // 7f4b8e3df000-7f4b8e5de000 ---p 001b5000 08:01 28836281 - // /lib/x86_64-linux-gnu/libc-2.15.so - // 7f4b8e5de000-7f4b8e5e2000 r--p 001b4000 08:01 28836281 - // /lib/x86_64-linux-gnu/libc-2.15.so - // 7f4b8e5e2000-7f4b8e5e4000 rw-p 001b8000 08:01 28836281 - // /lib/x86_64-linux-gnu/libc-2.15.so - const char* p = line; - for (int token = 0; token < 7; ++token) { - char separator = (token == 0) ? '-' : ' '; - // skip leading token separators first. - while (p < line_end && *p == separator) - p++; - - // find start and end of current token, and compute start of - // next search. The result of memchr(_,_,0) is undefined, treated as - // not-found. - const char* tok_start = p; - const size_t range = line_end - p; - const char* tok_end; - if (range > 0) - tok_end = static_cast<const char*>(memchr(p, separator, range)); - else - tok_end = NULL; - if (!tok_end) { - tok_end = line_end; - p = line_end; - } else { - p = tok_end + 1; - } - - if (tok_end == tok_start) { - if (token == 6) { - // empty token can happen for index 6, when there is no path - // element on the line. This corresponds to anonymous memory - // mapped segments. - entry->path = NULL; - entry->path_len = 0; - break; - } - return false; - } - - switch (token) { - case 0: // vma_start - entry->vma_start = static_cast<size_t>(strtoumax(tok_start, NULL, 16)); - break; - - case 1: // vma_end - entry->vma_end = static_cast<size_t>(strtoumax(tok_start, NULL, 16)); - break; - - case 2: // protection bits - { - int flags = 0; - for (const char* t = tok_start; t < tok_end; ++t) { - if (*t == 'r') - flags |= PROT_READ; - if (*t == 'w') - flags |= PROT_WRITE; - if (*t == 'x') - flags |= PROT_EXEC; - } - entry->prot_flags = flags; - } break; - - case 3: // page offset - entry->load_offset = - static_cast<size_t>(strtoumax(tok_start, NULL, 16)) * PAGE_SIZE; - break; - - case 6: // path - // Get rid of trailing newlines, if any. - while (tok_end > tok_start && tok_end[-1] == '\n') - tok_end--; - entry->path = tok_start; - entry->path_len = tok_end - tok_start; - break; - - default: // ignore all other tokens. - ; - } - } - return true; -} - -} // namespace - -ProcMaps::ProcMaps() { - static const char kFilePath[] = "/proc/self/maps"; - // NOTE: On Android, /proc/self/maps can easily be more than 10 kiB due - // to the large number of shared libraries and memory mappings loaded or - // created by the framework. Use a large capacity to reduce the number - // of dynamic allocations during parsing. - const size_t kCapacity = 16000; - LineReader reader(kFilePath, kCapacity); - while (reader.GetNextLine()) { - Entry entry = {}; - if (!ParseProcMapsLine(reader.line(), reader.line() + reader.length(), - &entry)) { - // Ignore broken lines. - continue; - } - - // Reallocate path. - const char* old_path = entry.path; - if (old_path) { - char* new_path = static_cast<char*>(::malloc(entry.path_len + 1)); - ::memcpy(new_path, old_path, entry.path_len); - new_path[entry.path_len] = '\0'; - entry.path = const_cast<const char*>(new_path); - } - - entries_.PushBack(entry); - } -} - -ProcMaps::~ProcMaps() { - for (ProcMaps::Entry& entry : entries_) { - ::free(const_cast<char*>(entry.path)); - } - entries_.Resize(0); -} - -const ProcMaps::Entry* ProcMaps::FindEntryForAddress(void* address) const { - size_t vma_addr = reinterpret_cast<size_t>(address); - for (const Entry& entry : entries_) { - if (entry.vma_start <= vma_addr && vma_addr < entry.vma_end) - return &entry; - } - return nullptr; -} - -const ProcMaps::Entry* ProcMaps::FindEntryForFile(const char* file_name) const { - size_t file_name_len = strlen(file_name); - bool is_base_name = (strchr(file_name, '/') == NULL); - for (const Entry& entry : entries_) { - // Skip vDSO et al. - if (entry.path_len == 0 || entry.path[0] == '[') - continue; - - const char* entry_name = entry.path; - size_t entry_len = entry.path_len; - - if (is_base_name) { - const char* p = reinterpret_cast<const char*>( - ::memrchr(entry.path, '/', entry.path_len)); - if (p) { - entry_name = p + 1; - entry_len = entry.path_len - (p - entry.path) - 1; - } - } - - if (file_name_len == entry_len && - !memcmp(file_name, entry_name, entry_len)) { - return &entry; - } - } - return nullptr; -} - -bool FindElfBinaryForAddress(void* address, - uintptr_t* load_address, - char* path_buffer, - size_t path_buffer_len) { - ProcMaps self_maps; - - uintptr_t addr = reinterpret_cast<uintptr_t>(address); - - const ProcMaps::Entry* entry = self_maps.FindEntryForAddress(address); - if (!entry) { - return false; - } - *load_address = entry->vma_start; - if (!entry->path) { - LOG("Could not find ELF binary path!?"); - return false; - } - if (entry->path_len >= path_buffer_len) { - LOG("ELF binary path too long: '%.*s'", entry->path_len, entry->path); - return false; - } - ::memcpy(path_buffer, entry->path, entry->path_len); - path_buffer[entry->path_len] = '\0'; - return true; -} - -bool FindLoadAddressForFile(const char* file_name, - uintptr_t* load_address, - uintptr_t* load_offset) { - ProcMaps self_maps; - const ProcMaps::Entry* entry = self_maps.FindEntryForFile(file_name); - if (!entry) { - return false; - } - *load_address = entry->vma_start; - *load_offset = entry->load_offset; - return true; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.h b/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.h deleted file mode 100644 index f46d66d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps.h +++ /dev/null
@@ -1,76 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_PROC_MAPS_H -#define CRAZY_LINKER_PROC_MAPS_H - -// Helper classes and functions to extract useful information out of -// /proc/self/maps. - -#include "crazy_linker_util.h" - -#include <stdint.h> -#include <sys/mman.h> // for PROT_READ etc... - -namespace crazy { - -class ProcMapsInternal; - -class ProcMaps { - public: - // Create instance. This opens and parses /proc/self/maps. - // There is no error reporting. If the file can't be opened, then - // entries() will be empty. - ProcMaps(); - - ~ProcMaps(); - - // Small structure to model an entry. - struct Entry { - size_t vma_start; - size_t vma_end; - int prot_flags; - size_t load_offset; - const char* path; // can be NULL, not always zero-terminated. - size_t path_len; // 0 if |path| is NULL. - }; - - const Vector<Entry>& entries() const { return entries_; } - - // Find entry containing a given |address|, or return nullptr. - const Entry* FindEntryForAddress(void* address) const; - - // Find first entry matching a given |file_name|, or return nullptr. - // If |file_name| contains a slash, this will try to perform an - // exact match with the content of /proc/self/maps. Otherwise, - // it will be taken as a base name, and the load address of the first - // matching entry will be returned. - const Entry* FindEntryForFile(const char* file_name) const; - - private: - Vector<Entry> entries_; -}; - -// Find which loaded ELF binary contains |address|. -// On success, returns true and sets |*load_address| to its load address, -// and fills |path_buffer| with the path to the corresponding file. -bool FindElfBinaryForAddress(void* address, - uintptr_t* load_address, - char* path_buffer, - size_t path_buffer_len); - -// Return the load address of a given ELF binary. -// If |file_name| contains a slash, this will try to perform an -// exact match with the content of /proc/self/maps. Otherwise, -// it will be taken as a base name, and the load address of the first -// matching entry will be returned. -// On success, returns true and sets |*load_address| to the load address, -// and |*load_offset| to the load offset. -bool FindLoadAddressForFile(const char* file_name, - uintptr_t* load_address, - uintptr_t* load_offset); - -} // namespace crazy - -#endif // CRAZY_LINKER_PROC_MAPS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps_unittest.cpp deleted file mode 100644 index 35b7017..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_proc_maps_unittest.cpp +++ /dev/null
@@ -1,183 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_proc_maps.h" - -#include <gtest/gtest.h> -#include <limits.h> -#include "crazy_linker_system_mock.h" - -namespace crazy { - -namespace { - -const char kProcMaps0[] = - "4000b000-4000c000 r--p 00000000 00:00 0\n" - "4005c000-40081000 r-xp 00000000 b3:01 141 /system/bin/mksh\n" - "40082000-40083000 r--p 00025000 b3:01 141 /system/bin/mksh\n" - "40083000-40084000 rw-p 00026000 b3:01 141 /system/bin/mksh\n" - "40084000-40088000 rw-p 00000000 00:00 0\n" - "40088000-40090000 r--s 00000000 00:0b 1704 /dev/__properties__\n" - "400eb000-400ec000 r--p 00000000 00:00 0\n" - "40141000-40150000 r-xp 00000000 b3:01 126 /system/bin/linker\n" - "40150000-40151000 r--p 0000e000 b3:01 126 /system/bin/linker\n" - "40151000-40152000 rw-p 0000f000 b3:01 126 /system/bin/linker\n" - "40152000-40153000 rw-p 00000000 00:00 0\n" - "40231000-40277000 r-xp 00001000 b3:01 638 /system/lib/libc.so\n" - "40277000-40279000 r--p 00046000 b3:01 638 /system/lib/libc.so\n" - "40279000-4027b000 rw-p 00048000 b3:01 638 /system/lib/libc.so\n" - "4027b000-40289000 rw-p 00000000 00:00 0\n" - "41e6b000-41e72000 rw-p 00000000 00:00 0 [heap]\n" - "be91b000-be93c000 rw-p 00000000 00:00 0 [stack]\n" - "ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]\n"; - -class ScopedTestEnv { - public: - ScopedTestEnv() : sys_() { - sys_.AddRegularFile("/proc/self/maps", kProcMaps0, sizeof(kProcMaps0) - 1); - } - - ~ScopedTestEnv() {} - - private: - SystemMock sys_; -}; - -} // namespace - -TEST(ProcMaps, FindElfBinaryForAddress) { - ScopedTestEnv env; - char path[512]; - uintptr_t load_address; - - EXPECT_TRUE(FindElfBinaryForAddress( - reinterpret_cast<void*>(0x400694c2), &load_address, path, sizeof(path))); - EXPECT_EQ(0x4005c000, load_address); - EXPECT_STREQ("/system/bin/mksh", path); -} - -TEST(ProcMaps, FindElfBinaryForAddressWithBadAddress) { - ScopedTestEnv env; - char path[512]; - uintptr_t load_address; - - EXPECT_FALSE(FindElfBinaryForAddress( - reinterpret_cast<void*>(0x50000000), &load_address, path, sizeof(path))); -} - -TEST(ProcMaps, FindLoadAddressForFile) { - ScopedTestEnv env; - static const struct { - bool success; - uintptr_t address; - uintptr_t offset; - const char* name; - } kData[] = {{true, 0x4005c000, 0, "mksh"}, - {true, 0x40141000, 0, "/system/bin/linker"}, - {false, 0, 0, "[heap]"}, - {false, 0, 0, "bin/mksh"}, - {true, 0x4005c000, 0, "/system/bin/mksh"}, - {true, 0x40231000, 0x1000000, "libc.so"}, }; - for (auto const& data : kData) { - uintptr_t address, offset; - bool success = FindLoadAddressForFile(data.name, &address, &offset); - EXPECT_EQ(data.success, success) << "Checking " << data.name; - if (success) { - EXPECT_EQ(data.address, address) << "Checking " << data.name; - EXPECT_EQ(data.offset, offset) << "Checking " << data.name; - } - } -} - -TEST(ProcMaps, Entries) { - ScopedTestEnv env; - // "4000b000-4000c000 r--p 00000000 00:00 0\n" - // "4005c000-40081000 r-xp 00000000 b3:01 141 /system/bin/mksh\n" - // "40082000-40083000 r--p 00025000 b3:01 141 /system/bin/mksh\n" - // "40083000-40084000 rw-p 00026000 b3:01 141 /system/bin/mksh\n" - // "40084000-40088000 rw-p 00000000 00:00 0\n" - // "40088000-40090000 r--s 00000000 00:0b 1704 - // /dev/__properties__\n" - // "400eb000-400ec000 r--p 00000000 00:00 0\n" - // "40141000-40150000 r-xp 00000000 b3:01 126 /system/bin/linker\n" - // "40150000-40151000 r--p 0000e000 b3:01 126 /system/bin/linker\n" - // "40151000-40152000 rw-p 0000f000 b3:01 126 /system/bin/linker\n" - // "40152000-40153000 rw-p 00000000 00:00 0\n" - // "40231000-40277000 r-xp 00001000 b3:01 638 - // /system/lib/libc.so\n" - // "40277000-40279000 r--p 00046000 b3:01 638 - // /system/lib/libc.so\n" - // "40279000-4027b000 rw-p 00048000 b3:01 638 - // /system/lib/libc.so\n" - // "4027b000-40289000 rw-p 00000000 00:00 0\n" - // "41e6b000-41e72000 rw-p 00000000 00:00 0 [heap]\n" - // "be91b000-be93c000 rw-p 00000000 00:00 0 [stack]\n" - // "ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]\n" - static const struct { - size_t vma_start; - size_t vma_end; - int prot_flags; - size_t load_offset; - const char* path; - } kData[] = { - {0x4000b000, 0x4000c000, PROT_READ, 0, NULL}, - {0x4005c000, 0x40081000, PROT_READ | PROT_EXEC, 0, "/system/bin/mksh"}, - {0x40082000, 0x40083000, PROT_READ, - 0x25000 * PAGE_SIZE, "/system/bin/mksh"}, - {0x40083000, 0x40084000, PROT_READ | PROT_WRITE, - 0x26000 * PAGE_SIZE, "/system/bin/mksh"}, - {0x40084000, 0x40088000, PROT_READ | PROT_WRITE, 0, NULL}, - {0x40088000, 0x40090000, PROT_READ, 0, "/dev/__properties__"}, - {0x400eb000, 0x400ec000, PROT_READ, 0, NULL}, - {0x40141000, 0x40150000, PROT_READ | PROT_EXEC, - 0, "/system/bin/linker"}, - {0x40150000, 0x40151000, PROT_READ, - 0xe000 * PAGE_SIZE, "/system/bin/linker"}, - {0x40151000, 0x40152000, PROT_READ | PROT_WRITE, - 0xf000 * PAGE_SIZE, "/system/bin/linker"}, - {0x40152000, 0x40153000, PROT_READ | PROT_WRITE, 0, NULL}, - {0x40231000, 0x40277000, PROT_READ | PROT_EXEC, - 0x1000 * PAGE_SIZE, "/system/lib/libc.so"}, - {0x40277000, 0x40279000, PROT_READ, - 0x46000 * PAGE_SIZE, "/system/lib/libc.so"}, - {0x40279000, 0x4027b000, PROT_READ | PROT_WRITE, - 0x48000 * PAGE_SIZE, "/system/lib/libc.so"}, - {0x4027b000, 0x40289000, PROT_READ | PROT_WRITE, 0, NULL}, - {0x41e6b000, 0x41e72000, PROT_READ | PROT_WRITE, 0, "[heap]"}, - {0xbe91b000, 0xbe93c000, PROT_READ | PROT_WRITE, 0, "[stack]"}, - {0xffff0000, 0xffff1000, PROT_READ | PROT_EXEC, 0, "[vectors]"}, }; - - ProcMaps self_maps; - ProcMaps::Entry entry; - - const Vector<ProcMaps::Entry>& entries = self_maps.entries(); - - size_t count = 0; - for (const auto& data : kData) { - std::string text = "Checking entry #"; - text += std::to_string(++count); - text += " "; - text += std::to_string(data.vma_start); - text += "-"; - text += std::to_string(data.vma_end); - - EXPECT_LT(count - 1U, entries.GetCount()) << text; - - const ProcMaps::Entry& entry = entries[count - 1]; - EXPECT_EQ(data.vma_start, entry.vma_start) << text; - EXPECT_EQ(data.vma_end, entry.vma_end) << text; - EXPECT_EQ(data.prot_flags, entry.prot_flags) << text; - EXPECT_EQ(data.load_offset, entry.load_offset) << text; - - if (!data.path) { - EXPECT_FALSE(entry.path) << text; - } else { - EXPECT_EQ(std::string(data.path), std::string(entry.path, entry.path_len)) - << text; - } - } - EXPECT_EQ(count, entries.GetCount()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp deleted file mode 100644 index 09177af6..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.cpp +++ /dev/null
@@ -1,276 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_rdebug.h" - -#include <elf.h> -#include <inttypes.h> -#include <limits.h> -#include <sys/auxv.h> -#include <sys/mman.h> -#include <unistd.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_system.h" -#include "crazy_linker_util.h" -#include "elf_traits.h" - -namespace crazy { - -namespace { - -// The <sys/auxv.h> header only declares getauxval for API level >= 18. -// Declare the same function as a weak import here so we can detect at -// runtime that getauxval() is not provided, i.e. this is running on an -// older Android release. -extern "C" unsigned long getauxval(unsigned long) __attribute__((weak)); - -// Retrieve the address of the current process' dynamic section. -bool FindElfDynamicSection(size_t* dynamic_address, size_t* dynamic_size) { - // Sanity check. Prevents crashing when running on an Android release older - // than KitKat / API 18. The linker will still work, but debugging and - // stack crashes will not be supported. - if (!getauxval) { - LOG("Android API level 18 or higher is needed for stack trace support!"); - return false; - } - - // Use getauxval() to get the address and size of the executable's - // program table entry. Note: On Android, getauxval() is only available - // starting with API level 18. - const size_t phdr_num = static_cast<size_t>(getauxval(AT_PHNUM)); - const auto* phdr_table = reinterpret_cast<ELF::Phdr*>(getauxval(AT_PHDR)); - LOG("Found phdr table at %p, count=%d", phdr_table, phdr_num); - if (!phdr_table) { - LOG_ERRNO("Could not retrieve program header with AT_PHDR"); - return false; - } - - // NOTE: The program header table contains the following interesting entries: - // - A PT_PHDR entry corresponding to the program header table itself! - // - A PT_DYNAMIC entry corresponding to the dynamic section. - const ELF::Phdr* pt_phdr = nullptr; - const ELF::Phdr* pt_dynamic = nullptr; - for (size_t n = 0; n < phdr_num; ++n) { - const ELF::Phdr* phdr = &phdr_table[n]; - if (phdr->p_type == PT_PHDR && !pt_phdr) - pt_phdr = phdr; - else if (phdr->p_type == PT_DYNAMIC && !pt_dynamic) - pt_dynamic = phdr; - } - - if (!pt_phdr) { - LOG("Could not find PT_PHDR entry!?"); - return false; - } - if (!pt_dynamic) { - LOG("Could not find PT_DYNAMIC entry!?"); - return false; - } - - LOG("Found PT_PHDR [address=%p vaddr=%lu size=%lu] and " - "PT_DYNAMIC [vaddr=%lu, size=%lu]", - pt_phdr, static_cast<unsigned long>(pt_phdr->p_vaddr), - static_cast<unsigned long>(pt_phdr->p_memsz), - static_cast<unsigned long>(pt_dynamic->p_vaddr), - static_cast<unsigned long>(pt_dynamic->p_memsz)); - - auto pt_hdr_address = reinterpret_cast<ptrdiff_t>(pt_phdr); - auto load_bias = pt_hdr_address - static_cast<ptrdiff_t>(pt_phdr->p_vaddr); - - *dynamic_address = static_cast<size_t>(load_bias + pt_dynamic->p_vaddr); - *dynamic_size = static_cast<size_t>(pt_dynamic->p_memsz); - - LOG("Dynamic section addr=%p size=%p", (void*)*dynamic_address, - (void*)*dynamic_size); - return true; -} - -// Helper function for AddEntryImpl and DelEntryImpl. -// Sets *link_pointer to entry. link_pointer is either an 'l_prev' or an -// 'l_next' field in a neighbouring linkmap_t. If link_pointer is in a -// page that is mapped readonly, the page is remapped to be writable before -// assignment. -void WriteLinkMapField(link_map_t** link_pointer, link_map_t* entry) { - // We always mprotect the page containing link_pointer to read/write, - // then write the entry. The page may already be read/write, but on - // recent Android release is most likely readonly. Because of the way - // the system linker operates we cannot tell with certainty what its - // correct setting should be. - // - // Now, we always leave the page read/write. Here is why. If we set it - // back to readonly at the point between where the system linker sets - // it to read/write and where it writes to the address, this will cause - // the system linker to crash. Clearly that is undesirable. From - // observations this occurs most frequently on the gpu process. - // - // https://code.google.com/p/chromium/issues/detail?id=450659 - // https://code.google.com/p/chromium/issues/detail?id=458346 - const uintptr_t kPageSize = PAGE_SIZE; - const uintptr_t ptr_address = reinterpret_cast<uintptr_t>(link_pointer); - void* page = reinterpret_cast<void*>(ptr_address & ~(kPageSize - 1U)); - - LOG("Mapping page at %p read-write for pointer at %p", page, link_pointer); - const int prot = PROT_READ | PROT_WRITE; - const int ret = ::mprotect(page, kPageSize, prot); - if (ret < 0) { - // In case of error, return immediately to avoid crashing below when - // writing the new value. Note that there is still a tiny chance that the - // system linker remapped the page read-only just after mprotect() above - // returns, so this cannot be guaranteed 100% of the time. - LOG_ERRNO("Error mapping page %p read/write", page); - return; - } - *link_pointer = entry; -} - -} // namespace - -r_debug* RDebug::GetAddress() { - if (!init_) { - Init(); - } - return r_debug_; -} - -bool RDebug::Init() { - // The address of '_r_debug' is in the DT_DEBUG entry of the current - // executable. - init_ = true; - - size_t dynamic_addr = 0; - size_t dynamic_size = 0; - - if (!FindElfDynamicSection(&dynamic_addr, &dynamic_size)) { - return false; - } - - // Parse the dynamic table and find the DT_DEBUG entry. - const ELF::Dyn* dyn_section = reinterpret_cast<const ELF::Dyn*>(dynamic_addr); - - while (dynamic_size >= sizeof(*dyn_section)) { - if (dyn_section->d_tag == DT_DEBUG) { - // Found it! - LOG("Found DT_DEBUG entry at %p, pointing to %p", dyn_section, - dyn_section->d_un.d_ptr); - if (dyn_section->d_un.d_ptr) { - r_debug_ = reinterpret_cast<r_debug*>(dyn_section->d_un.d_ptr); - LOG("r_debug [r_version=%d r_map=%p r_brk=%p r_ldbase=%p]", - r_debug_->r_version, r_debug_->r_map, r_debug_->r_brk, - r_debug_->r_ldbase); - // Only version 1 of the struct is supported. - if (r_debug_->r_version != 1) { - LOG("r_debug.r_version is %d, 1 expected.", r_debug_->r_version); - r_debug_ = NULL; - } - return true; - } - } - dyn_section++; - dynamic_size -= sizeof(*dyn_section); - } - - LOG("There is no non-0 DT_DEBUG entry in this process"); - return false; -} - -void RDebug::CallRBrk(int state) { -#if !defined(CRAZY_DISABLE_R_BRK) - r_debug_->r_state = state; - r_debug_->r_brk(); -#endif // !CRAZY_DISABLE_R_BRK -} - -void RDebug::AddEntry(link_map_t* entry) { - LOG("Adding: %s", entry->l_name); - if (!init_) - Init(); - - if (!r_debug_) { - LOG("Nothing to do"); - return; - } - - // Ensure modifications to the global link map are synchronized. - ScopedLinkMapLocker locker; - - // IMPORTANT: GDB expects the first entry in the list to correspond - // to the executable. So add our new entry just after it. This is ok - // because by default, the linker is always the second entry, as in: - // - // [<executable>, /system/bin/linker, libc.so, libm.so, ...] - // - // By design, the first two entries should never be removed since they - // can't be unloaded from the process (they are loaded by the kernel - // when invoking the program). - // - // TODO(digit): Does GDB expect the linker to be the second entry? - // It doesn't seem so, but have a look at the GDB sources to confirm - // this. No problem appear experimentally. - // - // What happens for static binaries? They don't have an .interp section, - // and don't have a r_debug variable on Android, so GDB should not be - // able to debug shared libraries at all for them (assuming one - // statically links a linker into the executable). - if (!r_debug_->r_map || !r_debug_->r_map->l_next || - !r_debug_->r_map->l_next->l_next) { - // Sanity check: Must have at least two items in the list. - LOG("Malformed r_debug.r_map list"); - r_debug_ = NULL; - return; - } - - // Tell GDB the list is going to be modified. - CallRBrk(RT_ADD); - - link_map_t* before = r_debug_->r_map->l_next; - link_map_t* after = before->l_next; - - // Prepare the new entry. - entry->l_prev = before; - entry->l_next = after; - - // IMPORTANT: Before modifying the previous and next entries in the - // list, ensure that they are writable. This avoids crashing when - // updating the 'l_prev' or 'l_next' fields of a system linker entry, - // which are mapped read-only. - WriteLinkMapField(&before->l_next, entry); - WriteLinkMapField(&after->l_prev, entry); - - // Tell GDB the list modification has completed. - CallRBrk(RT_CONSISTENT); -} - -void RDebug::DelEntry(link_map_t* entry) { - if (!r_debug_) - return; - - LOG("Deleting: %s", entry->l_name); - - // Ensure modifications to the global link map are synchronized. - ScopedLinkMapLocker locker; - - // Tell GDB the list is going to be modified. - CallRBrk(RT_DELETE); - - // IMPORTANT: Before modifying the previous and next entries in the - // list, ensure that they are writable. See comment above for more - // details. - if (entry->l_prev) - WriteLinkMapField(&entry->l_prev->l_next, entry->l_next); - if (entry->l_next) - WriteLinkMapField(&entry->l_next->l_prev, entry->l_prev); - - if (r_debug_->r_map == entry) - r_debug_->r_map = entry->l_next; - - entry->l_prev = NULL; - entry->l_next = NULL; - - // Tell GDB the list modification has completed. - CallRBrk(RT_CONSISTENT); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.h b/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.h deleted file mode 100644 index b732ef5..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug.h +++ /dev/null
@@ -1,188 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_RDEBUG_H -#define CRAZY_LINKER_RDEBUG_H - -#include <stdint.h> - -// The system linker maintains two lists of libraries at runtime: -// -// - A list that is used by GDB and other tools to search for the -// binaries that are loaded in the process. -// -// This list is accessible by looking at the DT_DEBUG field of the -// dynamic section of any ELF binary loaded by the linker (including -// itself). The field contains the address of a global '_r_debug' -// variable. More on this later. -// -// - A list that is used internally to implement library and symbol -// lookup. The list head and tail are called 'solist' and 'sonext' -// in the linker sources, and their address is unknown (and randomized -// by ASLR), and there is no point trying to change it. -// -// This means that you cannot call the linker's dlsym() function to -// lookup symbols in libraries that are not loaded through it, i.e. -// any custom dynamic linker needs its own dlopen() / dlsym() and other -// related functions, and ensure the loaded code only uses its own version. -// (See support code in crazy_linker_wrappers.cpp) -// -// The global '_r_debug' variable is a r_debug structure, whose layout -// must be known by GDB, with the following fields: -// -// r_version -> version of the structure (must be 1) -// r_map -> head of a linked list of 'link_map_t' entries, -// one per ELF 'binary' in the process address space. -// r_brk -> pointer to a specific debugging function (see below). -// r_state -> state variable to be read in r_brk(). -// r_ldbase -> unused by the system linker, should be 0. (?) -// -// The 'r_brk' field points to an empty function in the system linker -// that is used to notify GDB of changes in the list of shared libraries, -// this works as follows: -// -// - When the linker wants to add a new shared library to the list, -// it first writes RT_ADD to 'r_state', then calls 'r_brk()'. -// -// It modifies the list, then writes RT_CONSISTENT to 'r_state' and -// calls 'r_brk()' again. -// -// - When unloading a library, RT_DELETE + RT_CONSISTENT are used -// instead. -// -// GDB will always place a breakpoint on the function pointed to by -// 'r_brk', and will be able to synchronize with the linker's -// modifications. -// -// The 'r_map' field is a list of nodes with the following structure -// describing each loaded shared library for GDB: -// -// l_addr -> Load address of the first PT_LOAD segment in a -// shared library. Note that this is 0 for the linker itself -// and the load-bias for an executable. -// l_name -> Name of the executable. This is _always_ a basename!! -// l_ld -> Address of the dynamic table for this binary. -// l_next -> Pointer to next item in 'r_map' list or NULL. -// l_prev -> Pointer to previous item in 'r_map' list. -// -// Note that the system linker ensures that there are always at least -// two items in this list: -// -// - The first item always describes the linker itself, the fields -// actually point to a specially crafted fake entry for it called -// 'libdl_info' in the linker sources. -// -// - The second item describes the executable that was started by -// the kernel. For Android applications, it will always be 'app_process' -// and completely uninteresting. -// -// - Eventually, another entry for VDSOs on platforms that support them. -// -// When implementing a custom linker, being able to debug the process -// unfortunately requires modifying the 'r_map' list to also account -// for libraries loading through it. -// -// One issue with this is that the linker also uses another internal -// variable, called '_r_debut_tail' that points to the last item in -// the list. And there is no way to access it directly. This can lead -// to problems when calling APIs that actually end up using the system's -// own dlopen(). Consider this example: -// -// 1/ Program loads crazy_linker -// -// 2/ Program uses crazy_linker to load libfoo.so, this adds -// a new entry at the end of the '_r_debug.r_map' list, but -// '_r_debug.tail' is unmodified. -// -// 3/ libfoo.so or the Java portion of the program calls a system API -// that ends up loading another library (e.g. libGLESv2_vendor.so), -// this calls the system dlopen(). -// -// 4/ The system dlopen() adds a new entry to the "_r_debug.r_map" -// list by updating the l_next / l_prev fields of the entry pointed -// to by '_r_debug_tail', and this removes 'libfoo.so' from the list! -// -// There is a simple work-around for this issue: Always insert our -// libraries at the _start_ of the 'r_map' list, instead of appending -// them to the end. The system linker doesn't know about custom-loaded -// libraries and thus will never try to unload them. -// -// Note that the linker never uses the 'r_map' list (except or updating -// it for GDB), it only uses 'solist / sonext' to actually perform its -// operations. That's ok if our custom linker completely wraps and -// re-implements these. -// -// The system linker expects to be the only item modifying the 'r_map' -// list, and as such it may set the pages that contain the list readonly -// outside of its own modifications. In threaded environments where the -// system linker and the crazy linker are operating simultaneously on -// different threads this may be a problem; we need these pages to be -// writable when we have to update the list. -// -// TECHNICAL NOTE: If CRAZY_DISABLE_R_BRK is defined at compile time, -// then the crazy linker will never try to call the r_brk() GDB Hook -// function. This can be useful to avoid runtime crashes on certain -// Android devices with x86 processors, running ARM binaries with -// a machine translator like Houdini. See http://crbug.com/796938 -// -namespace crazy { - -struct link_map_t { - uintptr_t l_addr; - char* l_name; - uintptr_t l_ld; - link_map_t* l_next; - link_map_t* l_prev; -}; - -// Values for r_debug->r_state -enum { - RT_CONSISTENT, - RT_ADD, - RT_DELETE -}; - -struct r_debug { - int32_t r_version; - link_map_t* r_map; - void (*r_brk)(void); - int32_t r_state; - uintptr_t r_ldbase; -}; - -class RDebug { - public: - RDebug() = default; - ~RDebug() = default; - - RDebug(const RDebug&) = delete; - RDebug& operator=(const RDebug&) = delete; - - // Add entries to and remove entries from the list. - void AddEntry(link_map_t* entry); - void DelEntry(link_map_t* entry); - - // Return address of current global _r_debug variable, or nullptr if not - // available. - r_debug* GetAddress(); - - private: - // Try to find the address of the global _r_debug variable, even - // though there is no symbol for it. Returns true on success. - bool Init(); - - // Call the debugger hook function |r_debug_->r_brk|. - // |state| is the value to write to |r_debug_->r_state| - // before that. This is done to coordinate with the - // debugger when modifications of the global |r_debug_| - // list are performed. - void CallRBrk(int state); - - r_debug* r_debug_ = nullptr; - bool init_ = false; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_REDUG_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_rdebug_unittest.cpp deleted file mode 100644 index 626c71d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_rdebug_unittest.cpp +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_rdebug.h" - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(RDebug, GetAddress) { - RDebug rdebug; - ASSERT_TRUE(rdebug.GetAddress()) << "Cannot find global |r_debug| address!"; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.cpp deleted file mode 100644 index d5b812d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.cpp +++ /dev/null
@@ -1,58 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_relr_relocations.h" - -#include <type_traits> - -namespace crazy { - -// Apply a single RELR relocation at virtual |offset| address, using -// the |load_bias| value. -static void ApplyRelrRelocation(ELF::Addr offset, size_t load_bias) { - offset += load_bias; - *reinterpret_cast<ELF::Addr*>(offset) += load_bias; -} - -void RelrRelocations::Apply(size_t load_bias) { - // Simple sanity checks. - if (!relocations_ || !relocations_size_) - return; - - const ELF::Relr* begin = relocations_; - const ELF::Relr* end = begin + (relocations_size_ / sizeof(ELF::Relr)); - const size_t word_size = sizeof(ELF::Addr); - - ELF::Addr base = 0; // current relocation address - while (begin < end) { - ELF::Relr entry = *begin++; - - if ((entry & 1) == 0) { - // An even value corresponds to the address of the next relocation. - ELF::Addr offset = static_cast<ELF::Addr>(entry); - ApplyRelrRelocation(offset, load_bias); - base = offset + word_size; - } else { - // An odd value corresponds to a bitmap of 31 or 63 words, based - // on the CPU bitness / word_size. - ELF::Addr offset = base; - - // Right shift of signed integers has undefined behaviour before C++20. - static_assert( - std::is_unsigned<decltype(entry)>::value, - "The ELF::Relr type should be unsigned to avoid undefined behaviour"); - - while (entry != 0) { - entry >>= 1; - if ((entry & 1) != 0) - ApplyRelrRelocation(offset, load_bias); - offset += word_size; - } - // Increment |base| by 31 or 63 words. - base += (8 * word_size - 1) * word_size; - } - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.h b/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.h deleted file mode 100644 index 4d6695c..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations.h +++ /dev/null
@@ -1,64 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_RELR_RELOCATIONS_H_ -#define CRAZY_LINKER_RELR_RELOCATIONS_H_ - -#include "elf_traits.h" - -namespace crazy { - -// Convenience struct to model a set of RELR relocations and apply them. -// For more information about their format, see: -// https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg -// -// In a nutshell, this looks like the following: -// -// - The relr table is just an array of ELF:Addr values (i.e. 32 or 64 bit -// words, depending on CPU bitness). -// -// - Each relr relocation corresponds to simply applying the load bias -// to a given memory location. I.e. applying one relocation at VIRTUAL -// ADDRESS |vaddr| looks like: -// -// *(reinterpret_cast<ELF::Addr*>(vaddr + load_bias)) += load_bias -// -// - Even entries in the table corresponds to target virtual addresses, -// where a RELR relocation should happen. Note that odd addresses are -// not supported at all. -// -// - Odd entries corresponds to bitmaps of 31 or 63 addresses following -// the previous one (either from an even entry, or a previous odd one). -// Each bit, after the lsb, that is set, means that the corresponding -// address should be RELR-relocated. -// -class RelrRelocations { - public: - // Default constructor. - RelrRelocations() = default; - - // Set the RELR address, |dt_relr| must be the DT_RELR entry from the - // dynamic table. - void SetAddress(uintptr_t dt_relr) { - relocations_ = - const_cast<const ELF::Relr*>(reinterpret_cast<ELF::Relr*>(dt_relr)); - } - - // Set the RELR size. |dt_relrsz| must be the DT_RELRSZ entry from the - // dynamic table. - void SetSize(ELF::Addr dt_relrsz) { relocations_size_ = dt_relrsz; } - - // Apply all relocations at once, where |load_bias| is the load load bias - // used to load the ELF file. This operation cannot fail, and doesn't do - // anything if there are no Relr relocations. - void Apply(size_t load_bias); - - private: - const ELF::Relr* relocations_ = nullptr; - ELF::Addr relocations_size_ = 0; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_RELR_RELOCATIONS_H_
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations_unittest.cpp deleted file mode 100644 index 60f2d8b..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_relr_relocations_unittest.cpp +++ /dev/null
@@ -1,101 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_relr_relocations.h" - -#include "elf_traits.h" - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(RelrRelocations, DefaultConstruction) { - RelrRelocations relr; - relr.Apply(0); -} - -TEST(RelrRelocations, ApplyWithSimpleAddressList) { - // Build a simple array of addresses initialized to pretty liberal values. - const size_t kDataSize = 128; - ELF::Addr data[kDataSize]; - for (size_t n = 0; n < kDataSize; ++n) - data[n] = ELF::Addr(0) + n; - - // Build an RELR table that lists every *even* item in data[] as a RELR - // relocation target. Offsets are relative to |data|, which thus must be - // the load bias when calling RelrRelocations::Apply() below. - const size_t kWordSize = sizeof(ELF::Addr); - const size_t kRelrSize = 8; - ELF::Relr relr_table[kRelrSize]; - for (size_t n = 0; n < kRelrSize; ++n) { - relr_table[n] = kWordSize * n * 2; - } - RelrRelocations relr; - relr.SetAddress(reinterpret_cast<uintptr_t>(relr_table)); - relr.SetSize(static_cast<ELF::Addr>(sizeof(relr_table))); - - // Build the expected data table here, it's easier to understand the - // comparison. - auto load_bias = reinterpret_cast<uintptr_t>(data); - ELF::Addr expected[kDataSize]; - for (size_t n = 0; n < kDataSize; ++n) { - if ((n < 2 * kRelrSize) && (n & 1) == 0) { - expected[n] = data[n] + load_bias; - } else { - expected[n] = data[n]; - } - } - - // Apply RELR relocations. - relr.Apply(load_bias); - - // Compare results. - for (size_t n = 0; n < kDataSize; ++n) { - EXPECT_EQ(expected[n], data[n]) << "# " << n; - } -} - -TEST(RelrRelocations, ApplyWithSimpleBitmaps) { - // Build a simple array of addresses initialized to pretty liberal values. - const size_t kDataSize = 128; - ELF::Addr data[kDataSize]; - for (size_t n = 0; n < kDataSize; ++n) - data[n] = ELF::Addr(0) + n; - - // Build an RELR table that lists every 3rd item in data[] as a RELR - // relocation target. Using only bitmaps. Base address is 0. - const size_t kWordSize = sizeof(ELF::Addr); - const size_t kBitsPerWord = (kWordSize * 8 - 1); - const size_t kRelrSize = (kDataSize + kBitsPerWord - 1) / kBitsPerWord; - ELF::Relr relr_table[kRelrSize] = {}; - for (size_t n = 0; n < kDataSize; ++n) { - if ((n % 3) == 0) - relr_table[n / kBitsPerWord] |= 1U | (ELF::Relr(2) << (n % kBitsPerWord)); - } - RelrRelocations relr; - relr.SetAddress(reinterpret_cast<uintptr_t>(relr_table)); - relr.SetSize(static_cast<ELF::Addr>(sizeof(relr_table))); - - // Build the expected data table here, it's easier to understand the - // comparison. - auto load_bias = reinterpret_cast<uintptr_t>(data); - ELF::Addr expected[kDataSize]; - for (size_t n = 0; n < kDataSize; ++n) { - if ((n % 3) == 0) { - expected[n] = data[n] + load_bias; - } else { - expected[n] = data[n]; - } - } - - // Apply RELR relocations. - relr.Apply(load_bias); - - // Compare results. - for (size_t n = 0; n < kDataSize; ++n) { - EXPECT_EQ(expected[n], data[n]) << "# " << n; - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.cpp deleted file mode 100644 index 0f6c5f2..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.cpp +++ /dev/null
@@ -1,192 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_search_path_list.h" - -#include "crazy_linker.h" -#include "crazy_linker_debug.h" -#include "crazy_linker_system.h" -#include "crazy_linker_zip.h" - -#include <utility> - -#include <string.h> - -namespace crazy { - -namespace { - -// Helper class used to parse over the items of two column-separated lists. -// Usage is the following: -// 1) Create new instance, passing the first and second list as parameters. -// 2) Call NextItem() in a loop until it returns false. Each call will -// return the current item. -// -// Items of the first list are returned in order before items of the second -// list. -class MultiListParser { - public: - // Constructor. - MultiListParser(const String& a_list, const String& b_list) - : p_(a_list.cbegin()), end_(a_list.cend()), b_list_(b_list) {} - - // Grab next item. On success return true and sets |*result|. On end of list, - // just return false. - bool NextItem(String* result) { - for (;;) { - if (p_ == end_) { - if (p_ != b_list_.cend()) { - p_ = b_list_.cbegin(); - end_ = b_list_.cend(); - continue; - } - return false; - } - // compute current list item, and next item start at the same time. - const char* item = p_; - const char* item_end = item; - while (item_end < end_ && item_end[0] != ':') - item_end++; - - p_ = item_end + (item_end < end_); - - if (item_end > item) { // Skip over empty entries. - result->Assign(item, item_end - item); - return true; - } - } - } - - private: - const char* p_; - const char* end_; - const String& b_list_; -}; - -// Look into zip archive at |zip_path| for a file named |file_name|. -// As a special convenience trick, this will also try to find a file with -// the same name with a 'crazy.' prefix. In other words, when looking for -// 'lib/libfoo.so', this will first look for 'lib/libfoo.so', then for -// 'lib/crazy.libfoo.so'. This allows storing uncompressed libraries inside -// Android APKs while preventing the system from extracting them at installation -// time (which will always happen before Android M). Note that these files -// should just be renamed, i.e. their internal soname should still be -// 'libfoo.so'. -// -// On success, return offset within zip archive, or CRAZY_OFFSET_FAILED -// if the library is not found. -int32_t FindLibFileInZipArchive(const char* zip_path, const char* file_name) { - // First attempt is direct lookup. - int32_t offset = FindStartOffsetOfFileInZipFile(zip_path, file_name); - if (offset != CRAZY_OFFSET_FAILED) { - LOG(" FOUND_IN_ZIP %s!%s @ 0x%x", zip_path, file_name, offset); - return offset; - } - - // Second attempt adding a crazy. prefix to the library name. - String crazy_name; - const char* pos = ::strrchr(file_name, '/'); - if (pos) { - crazy_name.Assign(file_name, (pos + 1 - file_name)); - file_name = pos + 1; - } - crazy_name.Append("crazy."); - crazy_name.Append(file_name); - - offset = FindStartOffsetOfFileInZipFile(zip_path, crazy_name.c_str()); - if (offset != CRAZY_OFFSET_FAILED) { - LOG(" FOUND IN ZIP %s!%s @ 0x%x", zip_path, crazy_name.c_str(), offset); - } - return offset; -} - -// Try to find the library file pointed by |path|. -// If |path| contains an exclamation mark, this is interpreted as a separator -// between a zip archive file path, and a file contained inside it. -// Also supports crazy. prefix for storing renamed libraries inside the zip -// archive (see comment for FindLibFileInZipArchive). -SearchPathList::Result FindLibFile(const char* path) { - // An exclamation mark in the file name indicates that one should look - // inside a zip archive. This is supported by the platform, see the - // "Opening shared libraries directly from an APK" in the following article: - // https://github.com/aosp-mirror/platform_bionic/blob/master/android-changes-for-ndk-developers.md - const char* bang = ::strchr(path, '!'); - if (bang) { - if (bang == path || bang[1] == '\0') { - // An initial or final '!' is always an error. - LOG(" INVALID_ZIP_PATH %s", path); - } else { - String zip_path = MakeAbsolutePathFrom(path, bang - path); - const char* file_name = bang + 1; - int32_t offset = FindLibFileInZipArchive(zip_path.c_str(), bang + 1); - if (offset != CRAZY_OFFSET_FAILED) { - return {std::move(zip_path), offset}; - } - } - } else { - // Regular file path. - String file_path = MakeAbsolutePathFrom(path); - if (PathIsFile(file_path.c_str())) { - LOG(" FOUND FILE %s", file_path.c_str()); - return {std::move(file_path), 0}; - } - } - - LOG(" skip %s", path); - return {}; -} - -} // namespace - -void SearchPathList::Reset() { - list_.Resize(0); - env_list_.Resize(0); -} - -void SearchPathList::ResetFromEnv(const char* var_name) { - Reset(); - const char* env = GetEnv(var_name); - if (env && *env) - env_list_ = env; -} - -void SearchPathList::AddPaths(const char* list, const char* list_end) { - // Append a column to the current list, if necessary - if (list_.size() > 0 && list_[list_.size() - 1] != ':') - list_ += ':'; - list_.Append(list, list_end - list); -} - -SearchPathList::Result SearchPathList::FindFile(const char* file_name) const { - LOG("Looking for %s", file_name); - - if (::strchr(file_name, '/') != nullptr || - ::strchr(file_name, '!') != nullptr) { - // This is an absolute or relative file path, so ignore the search list. - return FindLibFile(file_name); - } - - // Build full list by appending the env_list_ after the regular one. - MultiListParser parser(list_, env_list_); - String file_path; - Result result; - while (parser.NextItem(&file_path)) { - // Add trailing directory separator if needed. - if (file_path[file_path.size() - 1] != '/') - file_path += '/'; - - file_path += file_name; - - result = FindLibFile(file_path.c_str()); - if (result.IsValid()) { - return result; - } - LOG(" SKIPPED %s", file_path.c_str()); - } - - LOG(" MISSING %s", file_name); - return result; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.h b/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.h deleted file mode 100644 index e35604f..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list.h +++ /dev/null
@@ -1,102 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SEARCH_PATH_LIST_H -#define CRAZY_LINKER_SEARCH_PATH_LIST_H - -#include <stdint.h> -#include <string.h> - -#include "crazy_linker_util.h" // for String - -namespace crazy { - -// A simple class to model a list of search paths, and perform -// file system probing with it. -class SearchPathList { - public: - SearchPathList() = default; - - // Reset the list, i.e. make it empty. - void Reset(); - - // Reset the list from an environment variable value. - void ResetFromEnv(const char* var_name); - - // Add one or more paths to the list. - // |path_list| contains a list of paths separated by columns. - // |path_list_end| points after the list's last character. - // - // NOTE: Adding a zip archive to the list is supported by using an - // exclamation mark as a delimiter inside a path. For example, the value - // '/path/to/archive.zip!lib/armeabi-v7a', means looking for libraries - // inside the zip archive at '/path/to/archive.zip', that are stored - // as 'lib/armeabi-v7a/<libname>', or even 'lib/armeabi-v7a/crazy.<libname>'. - // Read the documentation for FindFile() below for more details. - void AddPaths(const char* path_list, const char* path_list_end); - - // Convenience function that takes a 0-terminated string. - void AddPaths(const char* path_list) { - AddPaths(path_list, path_list + ::strlen(path_list)); - } - - // The result of FindFile() below. - // |path| is the path to the file containing the library, or nullptr on error. - // |offset| is the byte offset within |path| where the library is located. - struct Result { - String path; - int32_t offset = 0; - - // Returns true iff this instance matches a valid file and offset. - inline bool IsValid() const { return !path.IsEmpty(); } - }; - - // Try to find a library file named |file_name| by probing the directories - // added through AddPaths(). This returns a (path, offset) tuple where - // |path| corresponds to the file path to load the library from, and - // |offset| to its offset inside the file. This allows loading libraries - // directly from zip archives, when they are uncompressed and page-aligned - // within them. - // - // In case of failure, the path will be empty, and the offset will be 0. - // - // Note that if |file_name| does not contain any directory separator or - // exclamation name, the corresponding file will be searched in the list - // of paths added through AddPaths(). Otherwise, this is considered a direct - // file path and the search list will be ignored. - // - // File paths, either given directly by |file_name| or created by prepending - // search list items to it, can contain an exclamation mark to indicate that - // the library should be looked into a zip archive. For a concrete example - // 'path/to/archive.zip!libs/libfoo.so' will look into the zip archive - // at 'path/to/archive.zip' for a file within it named 'libs/libfoo.so'. - // - // This matches the behaviour of the Android system linker, starting with M - // (i.e. API level 23), but can be used on previous Android releases too. - // - // Said libraries must be uncompressed and page-aligned for the linker - // to later be able to load them properly. - // - // NOTE: It is also possible to store library files with a 'crazy.' prefix - // inside zip archives. In the following example, the function will first - // look for 'libs/libfoo.so', and if not found, will also look for a file - // named 'libs/crazy.libfoo.so'. - // - // Using such a prefix is useful on Android: such libraries can still be - // loaded directly from the APK, but will not be extracted by the system - // at installation into the application data directory (at least before - // Android M). Note that said libraries should simply be renamed within - // the zip file (i.e. they should still use the same internal DT_SONAME - // of 'libfoo.so' for the linker to work properly). - // - Result FindFile(const char* file_name) const; - - private: - String list_; - String env_list_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_SEARCH_PATH_LIST_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list_unittest.cpp deleted file mode 100644 index 0fd94c4..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_search_path_list_unittest.cpp +++ /dev/null
@@ -1,236 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_search_path_list.h" - -#include <gtest/gtest.h> -#include "crazy_linker_system_mock.h" -#include "crazy_linker_zip_test_data.h" - -namespace crazy { - -namespace { - -// MAGIC CONSTANT WARNING: These offsets have been determined empirically. -// If you update the content of lib_archive_zip, you will have to adjust -// them for these tests to continue to run. -const int32_t kFooFileOffset = 80; -const int32_t kBarFileOffset = 197; - -class TestSystem { - public: - TestSystem() : sys_() { - sys_.AddRegularFile("/tmp/foo/bar", "BARBARBAR", 9); - sys_.AddRegularFile("/tmp/zoo", "ZOO", 3); - sys_.AddRegularFile("/foo", "Foo", 3); - sys_.AddEnvVariable("TEST_LIBRARY_PATH", "/tmp:/"); - } - - ~TestSystem() {} - - void AddFile(const char* path, const char* data, size_t len) { - sys_.AddRegularFile(path, data, len); - } - - void SetCurrentDir(const char* path) { sys_.SetCurrentDir(path); } - - private: - SystemMock sys_; -}; - -// A mock CPU ABI name used during testing. -// NOTE: This is hard-coded into the zip test tables, do not change it! -const char kTestAbi[] = "test-abi"; - -// Small structure used to store test data. -// |input_path| is an input file path. -// |expected_path| is either nullptr or an expected file path. -// |expected_offset| is the expected offset (or 0). -struct TestData { - const char* input_path; - const char* expected_path; - int32_t expected_offset; -}; - -// Perform one single check for the TestData instance |data|, using |list|. -void CheckData(const TestData& data, const SearchPathList& list) { - auto result = list.FindFile(data.input_path); - if (data.expected_path) { - EXPECT_STREQ(data.expected_path, result.path.c_str()) - << "For: " << data.input_path; - EXPECT_EQ(data.expected_offset, result.offset) - << "For: " << data.input_path; - } else { - EXPECT_STREQ("", result.path.c_str()) << "For: " << data.input_path; - } -} - -} // namespace - -TEST(SearchPathList, Empty) { - TestSystem sys; - SearchPathList list; - sys.SetCurrentDir("/tmp"); - static const TestData kData[] = { - // Paths without a directory separator should not work. - {"foo", nullptr, 0}, - // Relative paths should work. - {"foo/bar", "/tmp/foo/bar", 0}, - // Absolute paths should work - {"/foo", "/foo", 0}, - {"/tmp/zoo", "/tmp/zoo", 0}, - {"/tmp/foo/bar", "/tmp/foo/bar", 0}, - // File that do not exist should error. - {"/no-such-file", nullptr, 0}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -TEST(SearchPathList, OneItem) { - TestSystem sys; - SearchPathList list; - list.AddPaths("/tmp/foo"); - - static const TestData kData[] = { - {"bar", "/tmp/foo/bar", 0}, {"zoo", nullptr, 0}, {"foo", nullptr, 0}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -TEST(SearchPathList, Reset) { - TestSystem sys; - SearchPathList list; - list.AddPaths("/tmp/foo"); - - auto result = list.FindFile("bar"); - EXPECT_STREQ("/tmp/foo/bar", result.path.c_str()); - - list.Reset(); - result = list.FindFile("bar"); - EXPECT_STREQ("", result.path.c_str()); -} - -TEST(SearchPathList, ResetFromEnv) { - TestSystem sys; - SearchPathList list; - list.ResetFromEnv("TEST_LIBRARY_PATH"); - - static const TestData kData[] = { - // Find file name from env search list. - {"zoo", "/tmp/zoo", 0}, - {"foo", "/foo", 0}, - // Ignore search list if path contains a directory separator. - {"foo/bar", nullptr, 0}, - // Or an exclamation mark. - {"foo!bar", nullptr, 0}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -TEST(SearchPathList, ThreeItems) { - TestSystem sys; - SearchPathList list; - list.AddPaths("/tmp/foo:/tmp/"); - - static const TestData kData[] = { - // Relative path ignores search list. Current directory is /. - {"foo/bar", nullptr, 0}, - {"tmp/zoo", "/tmp/zoo", 0}, - // Base name uses search list, finds file in /tmp/. - {"zoo", "/tmp/zoo", 0}, - // Base name uses search list, doesn't find file in / which is no listed. - {"foo", nullptr, 0}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -TEST(SearchPathList, EnvPathsAfterAddedOnes) { - TestSystem sys; - sys.AddFile("/opt/foo", "FOO", 3); - SearchPathList list; - list.ResetFromEnv("TEST_LIBRARY_PATH"); - list.AddPaths("/opt"); - - // This checks that paths added with AddPaths() have priority over - // paths added with ResetFromEnv(). An invalid implementation would - // find '/tmp/foo' instead. - static const TestData data = {"foo", "/opt/foo", 0}; - CheckData(data, list); -} - -TEST(SearchPathList, FindDirectlyInsizeZipArchive) { - TestSystem sys; - sys.AddFile("/zips/archive.zip", - reinterpret_cast<const char*>(testing::lib_archive_zip), - testing::lib_archive_zip_len); - sys.SetCurrentDir("/zips"); - // Empty search path list. - SearchPathList list; - - static const TestData kData[] = { - // Lookup directly in archive. Full path. - {"/zips/archive.zip!lib/test-abi/libfoo.so", "/zips/archive.zip", - kFooFileOffset}, - - {"/zips/archive.zip!lib/test-abi/crazy.libbar.so", "/zips/archive.zip", - kBarFileOffset}, - - // Lookup directly in archive, from current directory. - {"archive.zip!lib/test-abi/libfoo.so", "/zips/archive.zip", - kFooFileOffset}, - - // Cannot find libraries if the zip archive is not in the search list. - {"libfoo.so", nullptr, 0}, - {"libbar.so", nullptr, 0}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -TEST(SearchPathList, FindInsideListedZipArchive) { - TestSystem sys; - sys.AddFile("/zips/archive.zip", - reinterpret_cast<const char*>(testing::lib_archive_zip), - testing::lib_archive_zip_len); - SearchPathList list; - list.AddPaths("/zips/archive.zip!lib/test-abi/"); - - // MAGIC CONSTANT WARNING: These offsets have been determined empirically. - // If you update the content of lib_archive_zip, you will have to adjust - // them for these tests to continue to run. - static const int32_t kFooFileOffset = 80; - static const int32_t kBarFileOffset = 197; - static const TestData kData[] = { - // Lookup directly in archive. Full path. - {"/zips/archive.zip!lib/test-abi/libfoo.so", "/zips/archive.zip", - kFooFileOffset}, - - {"/zips/archive.zip!lib/test-abi/crazy.libbar.so", "/zips/archive.zip", - kBarFileOffset}, - - // Same, but automatically handle crazy. storage prefix! - {"/zips/archive.zip!lib/test-abi/libbar.so", "/zips/archive.zip", - kBarFileOffset}, - - // Lookup in archive because it is in the search path. - {"libfoo.so", "/zips/archive.zip", kFooFileOffset}, - - // Same, but automatically handle crazy. storage prefix! - {"libbar.so", "/zips/archive.zip", kBarFileOffset}, - }; - for (const auto& data : kData) { - CheckData(data, list); - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp deleted file mode 100644 index 6d1d1228..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp +++ /dev/null
@@ -1,527 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_shared_library.h" - -#include <stdlib.h> -#include <sys/mman.h> -#include <elf.h> - -#include "crazy_linker_ashmem.h" -#include "crazy_linker_debug.h" -#include "crazy_linker_elf_loader.h" -#include "crazy_linker_elf_relocations.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_library_list.h" -#include "crazy_linker_library_view.h" -#include "crazy_linker_load_params.h" -#include "crazy_linker_memory_mapping.h" -#include "crazy_linker_system_linker.h" -#include "crazy_linker_thread_data.h" -#include "crazy_linker_util.h" -#include "crazy_linker_wrappers.h" -#include "linker_phdr.h" - -#ifndef DF_SYMBOLIC -#define DF_SYMBOLIC 2 -#endif - -#ifndef DF_TEXTREL -#define DF_TEXTREL 4 -#endif - -#ifndef DT_INIT_ARRAY -#define DT_INIT_ARRAY 25 -#endif - -#ifndef DT_INIT_ARRAYSZ -#define DT_INIT_ARRAYSZ 27 -#endif - -#ifndef DT_FINI_ARRAY -#define DT_FINI_ARRAY 26 -#endif - -#ifndef DT_FINI_ARRAYSZ -#define DT_FINI_ARRAYSZ 28 -#endif - -#ifndef DT_FLAGS -#define DT_FLAGS 30 -#endif - -#ifndef DT_PREINIT_ARRAY -#define DT_PREINIT_ARRAY 32 -#endif - -#ifndef DT_PREINIT_ARRAYSZ -#define DT_PREINIT_ARRAYSZ 33 -#endif - -namespace crazy { - -namespace { - -int local_isnanf(float x) { - uint32_t bits; - memcpy(&bits, &x, sizeof bits); - if ((bits & 0x7f800000) != 0x7f800000) - return 0; - return (bits & 0x7fffff) ? 1 : 0; -} - -typedef SharedLibrary::linker_function_t linker_function_t; -typedef int (*JNI_OnLoadFunctionPtr)(void* vm, void* reserved); -typedef void (*JNI_OnUnloadFunctionPtr)(void* vm, void* reserved); - -// Call a constructor or destructor function pointer. Ignore -// NULL and -1 values intentionally. They correspond to markers -// in the tables, or deleted values. -// |func_type| corresponds to the type of the function, and is only -// used for debugging (examples are "DT_INIT", "DT_INIT_ARRAY", etc...). -void CallFunction(linker_function_t func, const char* func_type) { - uintptr_t func_address = reinterpret_cast<uintptr_t>(func); - - LOG("%p %s", func, func_type); - if (func_address != 0 && func_address != uintptr_t(-1)) - func(); -} - -// An instance of ElfRelocations::SymbolResolver that can be used -// to resolve symbols in a shared library being loaded by -// LibraryList::LoadLibrary. -class SharedLibraryResolver : public ElfRelocations::SymbolResolver { - public: - SharedLibraryResolver(SharedLibrary* lib, - LibraryList* lib_list, - const Vector<LibraryView*>* preloads, - const Vector<LibraryView*>* dependencies) - : main_program_handle_(SystemLinker::Open(NULL, RTLD_NOW)), - lib_(lib), - preloads_(preloads), - dependencies_(dependencies) {} - - ~SharedLibraryResolver() { SystemLinker::Close(main_program_handle_); } - - virtual void* Lookup(const char* symbol_name) { - // IMPORTANT NOTE: This code is completely buggy, when relocating symbol - // a correct ELF linker should only consider libraries in the global scope, - // or other libraries in the same load group. - // - // The global scope is defined as the program executable, any of its - // direct dependencies, any preloads, as well as any library loaded later - // with the RTLD_GLOBAL flag. - // - // Normally, one can lookup symbols in it using dlsym(RTLD_DEFAULT, <name>) - // or using dlsym() with a handle created with dlopen(NULL, ...). However - // the Android system linker didn't always implement these cases properly. - - // TODO(digit): Fix this by totally changing the way libraries are loaded - // and relocated, and provide mock SystemLinker implementations that - // mimic the broken implementations of the Android linker for proper - // testing. - - // First, look inside the current library. - const ELF::Sym* entry = lib_->LookupSymbolEntry(symbol_name); - if (entry) - return reinterpret_cast<void*>(lib_->load_bias() + entry->st_value); - - // Special case: redirect the dynamic linker symbols to our wrappers. - // This ensures that loaded libraries can call dlopen() / dlsym() - // and transparently use the crazy linker to perform their duty. - void* address = WrapLinkerSymbol(symbol_name); - if (address) - return address; - - // Then look inside the preloads. - // - // Note that searching preloads *before* the main executable is opposite - // to the search ordering used by the system linker, but it is required - // to work round a dlsym() bug in some Android releases (on releases - // without this dlsym() bug preloads_ will be empty, making this preloads - // search a no-op). - // - // For more, see commentary in LibraryList(), and - // https://code.google.com/p/android/issues/detail?id=74255 - for (const LibraryView* preload : *preloads_) { - // LOG("Looking into preload %p (%s)", wrap, - // wrap->GetName()); - address = LookupIn(symbol_name, preload); - if (address) - return address; - } - - // Then lookup inside the global scope. - SystemLinker::SearchResult ret = - SystemLinker::Resolve(main_program_handle_, symbol_name); - if (ret.IsValid()) { - return ret.address; - } - - // Then look inside the dependencies. - for (const LibraryView* dep : *dependencies_) { - // LOG("Looking into dependency %p (%s)", dep, dep->GetName()); - address = LookupIn(symbol_name, dep); - if (address) - return address; - } - - // Nothing found here. - return nullptr; - } - - private: - // Lookup for |symbol_name| inside of |lib|, and return the corresponding - // address. For system libraries, this can also resolve missing "isnanf" - // or "__isnanf" symbols from libm.so to local_isnanf. For crazy libraries, - // this will look only within the library, not its dependencies. - virtual void* LookupIn(const char* symbol_name, const LibraryView* lib) { - if (lib->IsSystem()) { - LibraryView::SearchResult sym = lib->LookupSymbol(symbol_name); - // Android libm.so defines isnanf as weak. This means that its - // address cannot be found by dlsym(), which returns NULL for weak - // symbols prior to Android 5.0. However, libm.so contains the real - // isnanf as __isnanf. If we encounter isnanf and fail to resolve - // it in libm.so, retry with __isnanf. - // - // This occurs only in clang, which lacks __builtin_isnanf. The - // gcc compiler implements isnanf as a builtin, so the symbol - // isnanf never need be resolved in gcc builds. - // - // http://code.google.com/p/chromium/issues/detail?id=376828 - if (!sym.IsValid() && !strcmp(symbol_name, "isnanf") && - !strcmp(lib->GetName(), "libm.so")) { - sym = lib->LookupSymbol("__isnanf"); - if (!sym.IsValid()) { - // __isnanf only exists on Android 21+, so use a local fallback - // if that doesn't exist either. - sym.address = reinterpret_cast<void*>(&local_isnanf); - } - } - return sym.address; - } - - const SharedLibrary* crazy = lib->GetCrazy(); - if (crazy) { - const ELF::Sym* entry = crazy->LookupSymbolEntry(symbol_name); - if (entry) - return reinterpret_cast<void*>(crazy->load_bias() + entry->st_value); - } - - return nullptr; - } - - void* main_program_handle_; - SharedLibrary* lib_; - const Vector<LibraryView*>* preloads_; - const Vector<LibraryView*>* dependencies_; -}; - -} // namespace - -SharedLibrary::SharedLibrary() { - full_path_[0] = '\0'; -} - -SharedLibrary::~SharedLibrary() = default; - -bool SharedLibrary::Load(const LoadParams& params, Error* error) { - // First, record the path. - const char* full_path = params.library_path.c_str(); - if (params.library_fd >= 0) { - snprintf(full_path_, sizeof(full_path_), "fd(%d):%s", params.library_fd, - full_path); - } else { - size_t full_path_len = strlen(full_path); - if (full_path_len >= sizeof(full_path_)) { - error->Format("Path too long: %s", full_path); - return false; - } - strlcpy(full_path_, full_path, sizeof(full_path_)); - } - base_name_ = GetBaseNamePtr(full_path_); - LOG("full path '%s'", full_path_); - - // Default value of |soname_| will be |base_name_| unless overidden - // by a DT_SONAME entry. This helps deal with broken libraries that don't - // have one. Note that starting with Android N, the system linker requires - // every library to have a DT_SONAME, as these are used to uniquely identify - // libraries for dependency resolution (barring namespace isolation). - soname_ = base_name_; - - // Load the ELF binary in memory. - LOG("Loading ELF segments for %s", base_name_); - - { - ElfLoader::Result ret = ElfLoader::LoadAt(params, error); - if (!ret.IsValid() || - !view_.InitUnmapped(ret.load_start, ret.phdr, ret.phdr_count, error)) { - return false; - } - - if (!symbols_.Init(&view_)) { - *error = "Missing or malformed symbol table"; - return false; - } - - reserved_map_ = std::move(ret.reserved_mapping); - - LOG("Reserved mapping %p size=0x%lx", reserved_map_.address(), - static_cast<unsigned long>(reserved_map_.size())); - } - - if (phdr_table_get_relro_info(view_.phdr(), - view_.phdr_count(), - view_.load_bias(), - &relro_start_, - &relro_size_) < 0) { - relro_start_ = 0; - relro_size_ = 0; - } - -#ifdef __arm__ - LOG("Extracting ARM.exidx table for %s", base_name_); - (void)phdr_table_get_arm_exidx( - phdr(), phdr_count(), load_bias(), &arm_exidx_, &arm_exidx_count_); -#endif - - LOG("Parsing dynamic table for %s", base_name_); - ElfView::DynamicIterator dyn(&view_); - RDebug* rdebug = Globals::GetRDebug(); - for (; dyn.HasNext(); dyn.GetNext()) { - ELF::Addr dyn_value = dyn.GetValue(); - uintptr_t dyn_addr = dyn.GetAddress(load_bias()); - switch (dyn.GetTag()) { - case DT_DEBUG: - if (view_.dynamic_flags() & PF_W) { - *dyn.GetValuePointer() = - reinterpret_cast<uintptr_t>(rdebug->GetAddress()); - } - break; - case DT_INIT: - LOG(" DT_INIT addr=%p", dyn_addr); - init_func_ = reinterpret_cast<linker_function_t>(dyn_addr); - break; - case DT_FINI: - LOG(" DT_FINI addr=%p", dyn_addr); - fini_func_ = reinterpret_cast<linker_function_t>(dyn_addr); - break; - case DT_INIT_ARRAY: - LOG(" DT_INIT_ARRAY addr=%p", dyn_addr); - init_array_ = reinterpret_cast<linker_function_t*>(dyn_addr); - break; - case DT_INIT_ARRAYSZ: - init_array_count_ = dyn_value / sizeof(ELF::Addr); - LOG(" DT_INIT_ARRAYSZ value=%p count=%p", dyn_value, - init_array_count_); - break; - case DT_FINI_ARRAY: - LOG(" DT_FINI_ARRAY addr=%p", dyn_addr); - fini_array_ = reinterpret_cast<linker_function_t*>(dyn_addr); - break; - case DT_FINI_ARRAYSZ: - fini_array_count_ = dyn_value / sizeof(ELF::Addr); - LOG(" DT_FINI_ARRAYSZ value=%p count=%p", dyn_value, - fini_array_count_); - break; - case DT_PREINIT_ARRAY: - LOG(" DT_PREINIT_ARRAY addr=%p", dyn_addr); - preinit_array_ = reinterpret_cast<linker_function_t*>(dyn_addr); - break; - case DT_PREINIT_ARRAYSZ: - preinit_array_count_ = dyn_value / sizeof(ELF::Addr); - LOG(" DT_PREINIT_ARRAYSZ value=%p count=%p", dyn_value, - preinit_array_count_); - break; - case DT_SYMBOLIC: - LOG(" DT_SYMBOLIC"); - has_DT_SYMBOLIC_ = true; - break; - case DT_FLAGS: - if (dyn_value & DF_SYMBOLIC) - has_DT_SYMBOLIC_ = true; - break; -#if defined(__mips__) - case DT_MIPS_RLD_MAP: - *dyn.GetValuePointer() = - reinterpret_cast<ELF::Addr>(rdebug->GetAddress()); - break; -#endif - case DT_SONAME: - soname_ = symbols_.string_table() + dyn_value; - LOG(" DT_SONAME %s", soname_); - break; - - default: - ; - } - } - - LOG("Load complete for %s", base_name_); - return true; -} - -bool SharedLibrary::Relocate(LibraryList* lib_list, - const Vector<LibraryView*>* preloads, - const Vector<LibraryView*>* dependencies, - Error* error) { - // Apply relocations. - LOG("Applying relocations to %s", base_name_); - - ElfRelocations relocations; - - if (!relocations.Init(&view_, error)) - return false; - - SharedLibraryResolver resolver(this, lib_list, preloads, dependencies); - if (!relocations.ApplyAll(&symbols_, &resolver, error)) - return false; - - LOG("Relocations applied for %s", base_name_); - return true; -} - -const ELF::Sym* SharedLibrary::LookupSymbolEntry( - const char* symbol_name) const { - return symbols_.LookupByName(symbol_name); -} - -void* SharedLibrary::FindAddressForSymbol(const char* symbol_name) const { - return symbols_.LookupAddressByName(symbol_name, view_.load_bias()); -} - -bool SharedLibrary::CreateSharedRelro(size_t load_address, - size_t* relro_start, - size_t* relro_size, - int* relro_fd, - Error* error) { - SharedRelro relro; - - if (!relro.Allocate(relro_size_, base_name_, error)) - return false; - - if (load_address != 0 && load_address != this->load_address()) { - // Need to relocate the content of the ashmem region first to accomodate - // for the new load address. - if (!relro.CopyFromRelocated( - &view_, load_address, relro_start_, relro_size_, error)) - return false; - } else { - // Simply copy, no relocations. - if (!relro.CopyFrom(relro_start_, relro_size_, error)) - return false; - } - - // Enforce read-only mode for the region's content. - if (!relro.ForceReadOnly(error)) - return false; - - // All good. - *relro_start = relro.start(); - *relro_size = relro.size(); - *relro_fd = relro.DetachFd(); - return true; -} - -bool SharedLibrary::UseSharedRelro(size_t relro_start, - size_t relro_size, - int relro_fd, - Error* error) { - LOG("relro_start=%p relro_size=%p relro_fd=%d", (void*)relro_start, - (void*)relro_size, relro_fd); - - if (relro_fd < 0 || relro_size == 0) { - // Nothing to do here. - return true; - } - - // Sanity check: A shared RELRO is not already used. - if (relro_used_) { - *error = "Library already using shared RELRO section"; - return false; - } - - // Sanity check: RELRO addresses must match. - if (relro_start_ != relro_start || relro_size_ != relro_size) { - error->Format("RELRO mismatch addr=%p size=%p (wanted addr=%p size=%p)", - relro_start_, - relro_size_, - relro_start, - relro_size); - return false; - } - - // Everything's good, swap pages in this process's address space. - SharedRelro relro; - if (!relro.InitFrom(relro_start, relro_size, relro_fd, error)) - return false; - - relro_used_ = true; - return true; -} - -void SharedLibrary::CallConstructors() { - CallFunction(init_func_, "DT_INIT"); - for (size_t n = 0; n < init_array_count_; ++n) - CallFunction(init_array_[n], "DT_INIT_ARRAY"); -} - -void SharedLibrary::CallDestructors() { - for (size_t n = fini_array_count_; n > 0; --n) { - CallFunction(fini_array_[n - 1], "DT_FINI_ARRAY"); - } - CallFunction(fini_func_, "DT_FINI"); -} - -bool SharedLibrary::CallJniOnLoad(void* java_vm, - int minimum_jni_version, - Error* error) { - if (!java_vm) - return true; - - // Lookup for JNI_OnLoad, exit if it doesn't exist. - auto jni_onload = reinterpret_cast<JNI_OnLoadFunctionPtr>( - FindAddressForSymbol("JNI_OnLoad")); - if (!jni_onload) - return true; - - int jni_version = (*jni_onload)(java_vm, NULL); - if (jni_version < minimum_jni_version) { - error->Format("JNI_OnLoad() in %s returned %d, expected at least %d", - full_path_, - jni_version, - minimum_jni_version); - return false; - } - - // Save the JavaVM handle for unload time. - java_vm_ = java_vm; - return true; -} - -void SharedLibrary::CallJniOnUnload() { - if (!java_vm_) - return; - - JNI_OnUnloadFunctionPtr jni_on_unload = - reinterpret_cast<JNI_OnUnloadFunctionPtr>( - this->FindAddressForSymbol("JNI_OnUnload")); - - if (jni_on_unload) - (*jni_on_unload)(java_vm_, NULL); -} - -bool SharedLibrary::DependencyIterator::GetNext() { - dep_name_ = NULL; - for (; iter_.HasNext(); iter_.GetNext()) { - if (iter_.GetTag() == DT_NEEDED) { - dep_name_ = symbols_->GetStringById(iter_.GetValue()); - iter_.GetNext(); - return true; - } - } - return false; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.h b/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.h deleted file mode 100644 index 65c86911..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.h +++ /dev/null
@@ -1,218 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SHARED_LIBRARY_H -#define CRAZY_LINKER_SHARED_LIBRARY_H - -#include <link.h> - -#include <utility> - -#include "crazy_linker_elf_relro.h" -#include "crazy_linker_elf_symbols.h" -#include "crazy_linker_elf_view.h" -#include "crazy_linker_error.h" -#include "crazy_linker_load_params.h" -#include "crazy_linker_memory_mapping.h" -#include "crazy_linker_rdebug.h" -#include "crazy_linker_util.h" -#include "elf_traits.h" - -namespace crazy { - -class LibraryList; -class LibraryView; - -// A class that models a shared library loaded by the crazy linker. - -// Libraries have dependencies (which are listed in their dynamic section -// as DT_NEEDED entries). Circular dependencies are forbidden, so they -// form an ADG, where the root is the crazy linker itself, since all -// libraries that it loads will depend on it (to ensure their -// dlopen/dlsym/dlclose calls are properly wrapped). - -class SharedLibrary { - public: - SharedLibrary(); - ~SharedLibrary(); - - size_t load_address() const { return view_.load_address(); } - size_t load_size() const { return view_.load_size(); } - size_t load_bias() const { return view_.load_bias(); } - const ELF::Phdr* phdr() const { return view_.phdr(); } - size_t phdr_count() const { return view_.phdr_count(); } - const char* base_name() const { return base_name_; } - - // Return name of the library as found in DT_SONAME entry, or same - // as base_name() if not available. - const char* soname() const { return soname_; } - - // Load a library (without its dependents) from an ELF file. - // Note: This does not apply relocations, nor runs constructors. - // |full_path| if the file full path. - // |params| are the load parameters for this operation. - // On failure, return false and set |error| message. - // - // After this, the caller should load all library dependencies, - // Then call Relocate() and CallConstructors() to complete the - // operation. - bool Load(const LoadParams& params, Error* error); - - // Relocate this library, assuming all its dependencies are already - // loaded in |lib_list|. On failure, return false and set |error| - // message. - bool Relocate(LibraryList* lib_list, - const Vector<LibraryView*>* preloads, - const Vector<LibraryView*>* dependencies, - Error* error); - - void GetInfo(size_t* load_address, - size_t* load_size, - size_t* relro_start, - size_t* relro_size) { - *load_address = view_.load_address(); - *load_size = view_.load_size(); - *relro_start = relro_start_; - *relro_size = relro_size_; - } - - // Returns true iff a given library is mapped to a virtual address range - // that contains a given address. - bool ContainsAddress(void* address) const { - size_t addr = reinterpret_cast<size_t>(address); - return load_address() <= addr && addr <= load_address() + load_size(); - } - - // Call all constructors in the library. - void CallConstructors(); - - // Call all destructors in the library. - void CallDestructors(); - - // Return the ELF symbol entry for a given symbol, if defined by - // this library, or NULL otherwise. - const ELF::Sym* LookupSymbolEntry(const char* symbol_name) const; - - // Find the nearest symbol near a given |address|. On success, return - // true and set |*sym_name| to the symbol name, |*sym_addr| to its address - // in memory, and |*sym_size| to its size in bytes, if any. - bool FindNearestSymbolForAddress(void* address, - const char** sym_name, - void** sym_addr, - size_t* sym_size) const { - return symbols_.LookupNearestByAddress( - address, load_bias(), sym_name, sym_addr, sym_size); - } - - // Return the address of a given |symbol_name| if it is exported - // by the library, NULL otherwise. - void* FindAddressForSymbol(const char* symbol_name) const; - - // Create a new Ashmem region holding a copy of the library's RELRO section, - // potentially relocated for a new |load_address|. On success, return true - // and sets |*relro_start|, |*relro_size| and |*relro_fd|. Note that the - // RELRO start address is adjusted for |load_address|, and that the caller - // becomes the owner of |*relro_fd|. On failure, return false and set - // |error| message. - bool CreateSharedRelro(size_t load_address, - size_t* relro_start, - size_t* relro_size, - int* relro_fd, - Error* error); - - // Try to use a shared relro section from another process. - // On success, return true. On failure return false and - // sets |error| message. - bool UseSharedRelro(size_t relro_start, - size_t relro_size, - int relro_fd, - Error* error); - - // Look for a symbol named 'JNI_OnLoad' in this library, and if it - // exists, call it with |java_vm| as the first parameter. If the - // function result is less than |minimum_jni_version|, fail with - // a message in |error|. On success, return true, and record - // |java_vm| to call 'JNI_OnUnload' at unload time, if present. - bool CallJniOnLoad(void* java_vm, int minimum_jni_version, Error* error); - - // Call 'JNI_OnUnload()' is necessary, i.e. if there was a succesful call - // to CallJniOnLoad() before, or nothing otherwise. - void CallJniOnUnload(); - - // Release reserved memory mapping. Caller takes ownership. Used to delay - // the unmapping of the library segments in the case of delayed RDebug - // operations. - MemoryMapping ReleaseMapping() { return std::move(reserved_map_); } - - // Helper class to iterate over dependencies in a given SharedLibrary. - // Usage: - // SharedLibary::DependencyIterator iter(lib); - // while (iter.GetNext() { - // dependency_name = iter.GetName(); - // ... - // } - class DependencyIterator { - public: - explicit DependencyIterator(const SharedLibrary* lib) - : iter_(&lib->view_), symbols_(&lib->symbols_), dep_name_(NULL) {} - - bool GetNext(); - - const char* GetName() const { return dep_name_; } - - private: - DependencyIterator() = delete; - DependencyIterator(const DependencyIterator&) = delete; - DependencyIterator& operator=(const DependencyIterator&) = delete; - - ElfView::DynamicIterator iter_; - const ElfSymbols* symbols_; - const char* dep_name_; - }; - - typedef void (*linker_function_t)(); - - private: - friend class LibraryList; - - ElfView view_; - ElfSymbols symbols_; - MemoryMapping reserved_map_; - - ELF::Addr relro_start_ = 0; - ELF::Addr relro_size_ = 0; - bool relro_used_ = false; - - SharedLibrary* list_next_ = nullptr; - SharedLibrary* list_prev_ = nullptr; - unsigned flags_ = 0; - - linker_function_t* preinit_array_ = nullptr; - size_t preinit_array_count_ = 0; - linker_function_t* init_array_ = nullptr; - size_t init_array_count_ = 0; - linker_function_t* fini_array_ = nullptr; - size_t fini_array_count_ = 0; - linker_function_t init_func_ = nullptr; - linker_function_t fini_func_ = nullptr; -#ifdef __arm__ - // ARM EABI section used for stack unwinding. - unsigned* arm_exidx_ = nullptr; - size_t arm_exidx_count_ = 0; -#endif - - link_map_t link_map_ = {}; - - bool has_DT_SYMBOLIC_ = false; - - void* java_vm_ = nullptr; - - const char* soname_ = nullptr; - const char* base_name_ = nullptr; - char full_path_[512]; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_SHARED_LIBRARY_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_system.cpp deleted file mode 100644 index 28cd5f1..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system.cpp +++ /dev/null
@@ -1,259 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_system.h" - -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> - -#ifdef __ANDROID__ -#include <android/log.h> -#endif - -#include "crazy_linker_util.h" - -// Note: unit-testing support files are in crazy_linker_files_mock.cpp - -namespace crazy { - -String MakeDirectoryPath(const char* parent) { - return MakeDirectoryPath(parent, ::strlen(parent)); -} - -String MakeDirectoryPath(const char* parent, size_t parent_len) { - if (parent_len == 0) { - // Special case for empty inputs. - return String("./"); - } - String result(parent); - if (parent_len > 0 && parent[parent_len - 1] != '/') { - result += '/'; - } - return result; -} - -String MakeAbsolutePathFrom(const char* path) { - return MakeAbsolutePathFrom(path, ::strlen(path)); -} - -String MakeAbsolutePathFrom(const char* path, size_t path_len) { - if (path[0] == '/') { - return String(path, path_len); - } else { - String cur_dir = GetCurrentDirectory(); - String result = MakeDirectoryPath(cur_dir.c_str(), cur_dir.size()); - result.Append(path, path_len); - return result; - } -} - -bool IsSystemLibraryPath(const char* lib_path) { - static const char* kSystemPrefixes[] = { -#ifdef __ANDROID__ - // From recent Android linker sources ($AOSP/bionic/linker/linker.cpp). - "/system/lib64/", "/odm/lib64/", "/vendor/lib64/", - "/data/asan/system/lib64/", "/data/asan/odm/lib64/", - "/data/asan/vendor/lib64/", - // It's ok to mix 32-bit and 64-bit paths in the same list here. - "/system/lib/", "/odm/lib/", "/vendor/lib/", "/data/asan/system/lib/", - "/data/asan/odm/lib/", "/data/asan/vendor/lib/", -#else - // Typical system library directories for Linux systems. - "/lib/", "/lib32/", "/lib64/", - "/libx32/", "/usr/lib/", "/usr/lib32/", - "/usr/lib64/", "/usr/libx32/", "/usr/local/lib/", -#endif - }; - size_t lib_path_len = ::strlen(lib_path); - for (const char* prefix : kSystemPrefixes) { - size_t prefix_len = ::strlen(prefix); - if (prefix_len < lib_path_len && !::memcmp(prefix, lib_path, prefix_len)) - return true; - } - return false; -} - -FileDescriptor& FileDescriptor::operator=(FileDescriptor&& other) noexcept { - if (this != &other) { - if (fd_ != kEmptyFD) { - DoClose(fd_); - } - fd_ = other.fd_; - other.fd_ = kEmptyFD; - } - return *this; -} - -} // namespace crazy - -#ifndef UNIT_TEST - -namespace crazy { - -ssize_t FileDescriptor::Read(void* buffer, size_t buffer_size) { - return TEMP_FAILURE_RETRY(::read(fd_, buffer, buffer_size)); -} - -off_t FileDescriptor::SeekTo(off_t offset) { - return ::lseek(fd_, offset, SEEK_SET); -} - -void* FileDescriptor::Map(void* address, - size_t length, - int prot, - int flags, - off_t offset) { - void* mem = ::mmap(address, length, prot, flags, fd_, offset); - return (mem == MAP_FAILED) ? nullptr : mem; -} - -int64_t FileDescriptor::GetFileSize() const { - struct stat stat_buf; - if (fstat(fd_, &stat_buf) == -1) { - return -1; - } - // |st_size| is an off_t which is always signed, but can be 32-bit or - // 64-bit depending on the platform. Always convert to a signed 64-bit - // to ensure the client always deal properly with both cases. - return static_cast<int64_t>(stat_buf.st_size); -} - -// static -int FileDescriptor::DoOpenReadOnly(const char* path) { - return TEMP_FAILURE_RETRY(::open(path, O_RDONLY)); -} - -// static -int FileDescriptor::DoOpenReadWrite(const char* path) { - return TEMP_FAILURE_RETRY(::open(path, O_RDWR)); -} - -// static -void FileDescriptor::DoClose(int fd) { - int old_errno = errno; - // SUBTLE: Do not loop when close() returns EINTR. On Linux, this simply - // means that a corresponding flush operation failed, but the file - // descriptor will always be closed anyway. - // - // Other platforms have different behavior: e.g. on OS X, this could be - // the result of an interrupt, and there is no reliable way to know - // whether the fd was closed or not on exit :-( - (void)close(fd); - errno = old_errno; -} - -const char* GetEnv(const char* var_name) { return ::getenv(var_name); } - -String GetCurrentDirectory() { - String result; - size_t capacity = 128; - for (;;) { - result.Resize(capacity); - if (getcwd(&result[0], capacity)) - break; - capacity *= 2; - } - return result; -} - -bool PathExists(const char* path) { - struct stat st; - if (TEMP_FAILURE_RETRY(stat(path, &st)) < 0) - return false; - - return S_ISREG(st.st_mode) || S_ISDIR(st.st_mode); -} - -bool PathIsFile(const char* path) { - struct stat st; - if (TEMP_FAILURE_RETRY(stat(path, &st)) < 0) - return false; - - return S_ISREG(st.st_mode); -} - -} // namespace crazy - -#if !defined(CRAZY_LINKER_ENABLE_FUZZING) - -// Custom implementation of new and malloc, this prevents dragging -// the libc++ implementation, which drags exception-related machine -// code that is not needed here. This helps reduce the size of the -// final binary considerably. - -// IMPORTANT: These symbols are not exported by the crazy linker, thus this -// does not affect the libraries that it will load, only the -// linker binary itself! -// -void* operator new(size_t size) { - void* ptr = ::malloc(size); - if (ptr != nullptr) - return ptr; - - // Don't assume it is possible to call any C library function like - // snprintf() here, since it might allocate heap memory and crash at - // runtime. Hence our fatal message does not contain the number of - // bytes requested by the allocation. - static const char kFatalMessage[] = "Out of memory!"; -#ifdef __ANDROID__ - __android_log_write(ANDROID_LOG_FATAL, "crazy_linker", kFatalMessage); -#else - ::write(STDERR_FILENO, kFatalMessage, sizeof(kFatalMessage) - 1); -#endif - _exit(1); -#if defined(__GNUC__) - __builtin_unreachable(); -#endif - - // NOTE: Adding a 'return nullptr' here will make the compiler error - // with a message stating that 'operator new(size_t)' is not allowed - // to return nullptr. - // - // Indeed, an new expression like 'new T' shall never return nullptr, - // according to the C++ specification, and an optimizing compiler will gladly - // remove any null-checks after them (something the Fuschsia team had to - // learn the hard way when writing their kernel in C++). What is meant here - // is something like: - // - // Foo* foo = new Foo(10); - // if (!foo) { <-- entire check and branch - // ... Handle out-of-memory condition. <-- removed by an optimizing - // } <-- compiler. - // - // Note that some C++ library implementations (e.g. recent libc++) recognize - // when they are compiled with -fno-exceptions and provide a simpler version - // of operator new that can return nullptr. However, it is very hard to - // guarantee at build time that this code is linked against such a version - // of the runtime. Moreoever, technically disabling exceptions is completely - // out-of-spec regarding the C++ language, and what the compiler is allowed - // to do in this case is mostly implementation-defined, so better be safe - // than sorry here. - // - // C++ provides a non-throwing new expression that can return a nullptr - // value, but it must be written as 'new (std::nothrow) T' instead of - // 'new T', and thus nobody uses this. This ends up calling - // 'operator new(size_t, const std::nothrow_t&)' which is not implemented - // here. -} - -void* operator new[](size_t size) { - return operator new(size); -} - -void operator delete(void* ptr) { - // The compiler-generated code already checked that |ptr != nullptr| - // so don't to it a second time. - ::free(ptr); -} - -void operator delete[](void* ptr) { - ::free(ptr); -} - -#endif // !CRAZY_LINKER_ENABLE_FUZZING - -#endif // !UNIT_TEST
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system.h b/third_party/android_crazy_linker/src/src/crazy_linker_system.h deleted file mode 100644 index df17f5a..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system.h +++ /dev/null
@@ -1,172 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SYSTEM_H -#define CRAZY_LINKER_SYSTEM_H - -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/mman.h> -#include <unistd.h> - -#include "crazy_linker_macros.h" -#include "crazy_linker_util.h" // for String - -// System abstraction used by the crazy linker. -// This is used to make unit testing easier without using tons of -// dependency injection in the rest of the code base. -// -// In a nutshell: in a normal build, this will wrap normal open() / read() -// calls. During unit testing, everything is mocked, see -// crazy_linker_system_mock.cpp - -namespace crazy { - -enum FileOpenMode { - FILE_OPEN_READ_ONLY = 0, - FILE_OPEN_READ_WRITE, - FILE_OPEN_WRITE -}; - -// Scoping wrapper for a platform file descriptor. -// The descriptor is closed on destruction, unless Release() is called. -// -// IMPORTANT NOTE: The purpose of this file is only to provide a way to mock -// the file system during unit testing. There are simple cases where it is -// better to use direct syscalls (e.g. Ashmem region file descriptors require -// specific opening a non-mockable location (/dev/ashmem) as well as ioctl() -// calls not covered here). -class FileDescriptor { - public: - using HandleType = int; - - static constexpr HandleType kEmptyFD = -1; - - constexpr FileDescriptor() = default; - - FileDescriptor(const char* path) : fd_(DoOpenReadOnly(path)) {} - - ~FileDescriptor() { Close(); } - - CRAZY_DISALLOW_COPY_OPERATIONS(FileDescriptor) - - // Move operations are allowed. - FileDescriptor(FileDescriptor&& other) noexcept : fd_(other.fd_) { - other.fd_ = kEmptyFD; - } - - FileDescriptor& operator=(FileDescriptor&& other) noexcept; - - // Returns true if the descriptor is valid. - bool IsOk() const { return fd_ != kEmptyFD; } - - // Return the value of the platform file descriptor. - HandleType Get() const { return fd_; } - - // Close the current descriptor, and try to open a file read-only. - // Return true on success, false/errno on failure. - bool OpenReadOnly(const char* path) { - Close(); - fd_ = DoOpenReadOnly(path); - return IsOk(); - } - - // Close the current descriptor, then try to open a file read-write. - // Return true on success, false/errno on failure. - bool OpenReadWrite(const char* path) { - Close(); - fd_ = DoOpenReadWrite(path); - return IsOk(); - } - - // Try to read |buffer_size| bytes into |buffer|. On success, return the - // number of bytes that were read, or 0 for EOF, or -1/errno for I/O - // error. - ssize_t Read(void* buffer, size_t buffer_size); - - // Try to read exactly |buffer_size| bytes into |buffer|. Return true - // on success, false/errno on failure. - bool ReadFull(void* buffer, size_t buffer_size) { - ssize_t ret = Read(buffer, buffer_size); - return (ret >= 0 && static_cast<size_t>(ret) == buffer_size); - } - - // Seek to a specific offset of the file. Return |offset| on success, or - // -1/errno on error. - off_t SeekTo(off_t offset); - - // Map the file into memory. Parameters must match the ::mmap() system call. - // Return a new memory address on success, or nullptr on failure. - void* Map(void* address, - size_t length, - int prot_flags, - int flags, - off_t offset); - - // Return the size in bytes of the corresponding file, or -1/errno if the - // descriptor is invalid. - int64_t GetFileSize() const; - - // Close the file descriptor if needed. - void Close() { - if (fd_ != kEmptyFD) { - DoClose(fd_); - fd_ = kEmptyFD; - } - } - - // Release ownership of the file descriptor. The caller becomes responsible - // for closing the returned handle. - HandleType Release() { - HandleType ret = fd_; - fd_ = kEmptyFD; - return ret; - } - - protected: - explicit FileDescriptor(HandleType handle) : fd_(handle) {} - - static int DoOpenReadOnly(const char* path); - static int DoOpenReadWrite(const char* path); - static void DoClose(int fd); - - HandleType fd_ = kEmptyFD; -}; - -// Returns true iff a given file path exists. -bool PathExists(const char* path_name); - -// Returns true iff a given path is a regular file (or link to a regular -// file). -bool PathIsFile(const char* path_name); - -// Returns the current directory, as a string. -String GetCurrentDirectory(); - -// Convert |path| into a String, and appends a trailing directory separator -// if there isn't already one. NOTE: As a special case, if the input is empty, -// then "./" will be returned. -String MakeDirectoryPath(const char* path); -String MakeDirectoryPath(const char* path, size_t path_len); - -// Convert |path| into an absolute path if necessary, always returns a new -// String instance as well. -String MakeAbsolutePathFrom(const char* path); - -// Same, but for the [path..path + path_len) input string. -String MakeAbsolutePathFrom(const char* path, size_t path_len); - -// Returns the value of a given environment variable. -const char* GetEnv(const char* var_name); - -// Returns true iff |lib_path| corresponds to the path of a system library, -// which should always be loaded through the system linker, and not the -// crazy one. Note that |lib_path| must be an absolute path, not a relative -// one. -bool IsSystemLibraryPath(const char* lib_path); - -} // namespace crazy - -#endif // CRAZY_LINKER_SYSTEM_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_android.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_system_android.cpp deleted file mode 100644 index e816e32..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_android.cpp +++ /dev/null
@@ -1,63 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_system_android.h" - -#include "crazy_linker_debug.h" - -#ifndef __ANDROID__ -#error "This source file should only be compiled for Android." -#endif - -#include <stdlib.h> -#include <sys/system_properties.h> - -namespace crazy { - -// Technical note regarding reading system properties. -// -// Try to use the new __system_property_read_callback API that appeared in -// Android O / API level 26 when available. Otherwise use the deprecated -// __system_property_get function. -// -// For more technical details from an NDK maintainer, see: -// https://bugs.chromium.org/p/chromium/issues/detail?id=392191#c17 - -// Use a weak symbol import to resolve at runtime whether the function is -// available. -extern "C" void __system_property_read_callback( - const prop_info* info, - void (*callback)(void* cookie, - const char* name, - const char* value, - uint32_t serial), - void* cookie) __attribute__((weak)); - -static int GetSystemPropertyAsInt(const char* name) { - int result = 0; - if (__system_property_read_callback) { - const prop_info* info = __system_property_find(name); - if (info) { - auto callback = [](void* cookie, const char*, const char* value, - uint32_t) { *(int*)cookie = atoi(value); }; - __system_property_read_callback(info, callback, &result); - } - } else { - char value[PROP_VALUE_MAX] = {}; - if (__system_property_get(name, value) >= 1) - result = atoi(value); - } - return result; -} - -int GetAndroidDeviceApiLevel() { - static int s_api_level = -1; - if (s_api_level < 0) { - s_api_level = GetSystemPropertyAsInt("ro.build.version.sdk"); - LOG("Device API level: %d", s_api_level); - } - return s_api_level; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_android.h b/third_party/android_crazy_linker/src/src/crazy_linker_system_android.h deleted file mode 100644 index 3e2ef13c..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_android.h +++ /dev/null
@@ -1,19 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SYSTEM_ANDROID_H -#define CRAZY_LINKER_SYSTEM_ANDROID_H - -namespace crazy { - -// From android.os.Build.VERSION_CODES.LOLLIPOP. -// Using a macro since constexpr in headers are problematic in C++. -#define ANDROID_SDK_VERSION_CODE_LOLLIPOP 21 - -// Return the current Android device's API level. -int GetAndroidDeviceApiLevel(); - -} // namespace crazy - -#endif // CRAZY_LINKER_SYSTEM_ANDROID_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.cpp deleted file mode 100644 index 9385890..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.cpp +++ /dev/null
@@ -1,81 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_system_linker.h" - -#include "crazy_linker_globals.h" - -#include <dlfcn.h> - -namespace crazy { - -// <android/dlext.h> does not declare android_dlopen_ext() if __ANDROID_API__ -// is smaller than 21, so declare it here as a weak function. This will allow -// detecting its availability at runtime. For API level 21 or higher, the -// attribute is ignored due to the previous declaration. -extern "C" void* android_dlopen_ext(const char*, int, const android_dlextinfo*) - __attribute__((weak)); - -// static -void* SystemLinker::Open(const char* path, int mode) { - // NOTE: The system linker will likely modify the global _r_debug link map - // so ensure this doesn't conflict with other threads performing delayed - // updates on it. - ScopedLinkMapLocker locker; - return ::dlopen(path, mode); -} - -#ifdef __ANDROID__ -// static -bool SystemLinker::HasAndroidOpenExt() { - return android_dlopen_ext != nullptr; -} - -// static -void* SystemLinker::AndroidOpenExt(const char* path, - int mode, - const android_dlextinfo* info) { - // NOTE: The system linker will likely modify the global _r_debug link map - // so ensure this doesn't conflict with other threads performing delayed - // updates on it. - ScopedLinkMapLocker locker; - if (android_dlopen_ext != nullptr) { - return android_dlopen_ext(path, mode, info); - } - return nullptr; -} -#endif // __ANDROID__ - -// static -int SystemLinker::Close(void* handle) { - // Similarly, though unlikely, this operation may modify the global link map. - ScopedLinkMapLocker locker; - return ::dlclose(handle); -} - -// static -SystemLinker::SearchResult SystemLinker::Resolve(void* handle, - const char* symbol) { - // Just in case the system linker performs lazy symbol resolution - // that would modify the global link map. - ScopedLinkMapLocker locker; - void* address = ::dlsym(handle, symbol); - if (!address) { - // TODO(digit): Distinguish between missing symbols and weak symbols. - return {}; - } - return {address, handle}; -} - -// static -const char* SystemLinker::Error() { - return ::dlerror(); -} - -int SystemLinker::AddressInfo(void* address, Dl_info* info) { - ::dlerror(); - return ::dladdr(address, info); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.h b/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.h deleted file mode 100644 index 7ec287b..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_linker.h +++ /dev/null
@@ -1,59 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SYSTEM_LINKER_H -#define CRAZY_LINKER_SYSTEM_LINKER_H - -#ifdef __ANDROID__ -#include <android/dlext.h> -#endif - -#include <dlfcn.h> - -namespace crazy { - -// Convenience wrapper for the system linker functions. -// Also helps synchronize access to the global link map list. -// -// TODO(digit): Use this in the future to mock different versions/behaviours -// of the Android system linker for unit-testing purposes. -struct SystemLinker { - // Wrapper for dlopen(). - static void* Open(const char* path, int flags); - -#ifdef __ANDROID__ - // Returns true iff this system linker provides android_dlopen_ext(). - static bool HasAndroidOpenExt(); - - // Calls android_dlopen_ext() if available, returns nullptr if it is not - // available otherwise. - static void* AndroidOpenExt(const char* path, - int flags, - const android_dlextinfo* info); -#endif // __ANDROID__ - - // Wrapper for dlclose(). - static int Close(void* handle); - - // Result type for Resolve() below. - struct SearchResult { - void* address = nullptr; - void* library = nullptr; - - constexpr bool IsValid() const { return library != nullptr; } - }; - - // Wrapper for dlsym(). - static SearchResult Resolve(void* handle, const char* symbol); - - // Wrapper for dlerror(). - static const char* Error(); - - // Wrapper for dladdr(); - static int AddressInfo(void* addr, Dl_info* info); -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_SYSTEM_LINKER_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.cpp deleted file mode 100644 index 8d07d49..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.cpp +++ /dev/null
@@ -1,469 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_system_mock.h" - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> - -#include "crazy_linker_util.h" -#include "crazy_linker_system.h" - -// Unit-testing support code. This should never be compiled into -// the production code. - -namespace { - -using crazy::String; -using crazy::Vector; - -void Panic(const char* msg, ...) { - va_list args; - fprintf(stderr, "PANIC: "); - va_start(args, msg); - vfprintf(stderr, msg, args); - va_end(args); - fprintf(stderr, "\n"); - exit(1); -} - -// Models a simple list of pointers to objects, which are owned by the -// list itself. -template <class T> -class List { - public: - List() : entries_() {} - - ~List() { Reset(); } - - void Reset() { - for (size_t n = 0; n < entries_.GetCount(); ++n) { - T* entry = entries_[n]; - delete entry; - entries_[n] = NULL; - } - entries_.Resize(0); - } - - // Add an item to the list, transfer ownership to it. - void PushBack(T* item) { entries_.PushBack(item); } - - size_t GetCount() const { return entries_.GetCount(); } - - T* operator[](size_t index) { return entries_[index]; } - - private: - crazy::Vector<T*> entries_; -}; - -// Models a single file entry in a mock file system. -class MockFileEntry { - public: - MockFileEntry() : path_(), data_() {} - - ~MockFileEntry() {} - - const char* GetPath() const { return path_.c_str(); } - const char* GetData() const { return data_.c_str(); } - size_t GetDataSize() const { return data_.size(); } - - void SetPath(const char* path) { path_.Assign(path); } - - void SetData(const char* data, size_t data_size) { - data_.Assign(data, data_size); - } - - private: - crazy::String path_; - crazy::String data_; -}; - -// Models a single mock environment variable value. -class MockEnvEntry { - public: - MockEnvEntry(const char* var_name, const char* var_value) - : var_name_(var_name), var_value_(var_value) {} - - const String& GetName() const { return var_name_; } - const String& GetValue() const { return var_value_; } - - private: - crazy::String var_name_; - crazy::String var_value_; -}; - -class MockFileHandle { - public: - MockFileHandle(MockFileEntry* entry) : entry_(entry), offset_(0) {} - ~MockFileHandle() {} - - bool IsEof() const { return offset_ >= entry_->GetDataSize(); } - - bool GetString(char* buffer, size_t buffer_size) { - const char* data = entry_->GetData(); - size_t data_size = entry_->GetDataSize(); - - if (offset_ >= data_size || buffer_size == 0) - return false; - - while (buffer_size > 1) { - char ch = data[offset_++]; - *buffer++ = ch; - buffer_size--; - if (ch == '\n') - break; - } - *buffer = '\0'; - return true; - } - - ssize_t Read(void* buffer, size_t buffer_size) { - if (buffer_size == 0) - return 0; - - const char* data = entry_->GetData(); - size_t data_size = entry_->GetDataSize(); - - size_t avail = data_size - offset_; - if (avail == 0) - return 0; - - if (buffer_size > avail) - buffer_size = avail; - - ::memcpy(buffer, data + offset_, buffer_size); - offset_ += buffer_size; - - return static_cast<int>(buffer_size); - } - - off_t SeekTo(off_t offset) { - if (offset < 0) { - errno = EINVAL; - return -1; - } - - const char* data = entry_->GetData(); - size_t data_size = entry_->GetDataSize(); - - if (offset > static_cast<off_t>(data_size)) { - errno = EINVAL; - return -1; - } - - offset_ = static_cast<size_t>(offset); - return 0; - } - - void* Map(void* address, size_t length, int prot, int flags, off_t offset) { - const char* data = entry_->GetData(); - size_t data_size = entry_->GetDataSize(); - if (offset_ >= data_size) { - errno = EINVAL; - return nullptr; - } - - // Allocate an anonymous memory mapping, then copy the file contents - // into it. - void* map = - mmap(address, length, PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (map == MAP_FAILED) { - return nullptr; - } - - size_t avail = data_size - offset_; - if (avail > length) - avail = length; - - ::memcpy(map, data + offset_, avail); - - // Restore desired protection after the write. - mprotect(map, length, prot); - - // Done. - return map; - } - - int64_t GetFileSize() const { - return static_cast<int64_t>(entry_->GetDataSize()); - } - - private: - MockFileEntry* entry_; - size_t offset_; -}; - -// Convenience class for the table of all active file descriptors in the -// mock system. -class MockFileHandleTable { - public: - // Constructor. - MockFileHandleTable() = default; - - // Destructor. - ~MockFileHandleTable() { - for (size_t n = 0; n < handles_.GetCount(); ++n) { - delete handles_[n]; - } - } - - // Find the MockFileHandle corresponding to |fd|, or nullptr if this - // is an unknown value. - MockFileHandle* Find(int fd) const { - if (fd < 0 || static_cast<size_t>(fd) >= handles_.GetCount()) { - return nullptr; - } - return handles_[fd]; - } - - // Allocate a new file descriptor value associated with a MockFileHandle - // instance. This takes ownership of the instance. - int AllocateFd(MockFileHandle* handle) { - size_t n = 0; - for (; n < handles_.GetCount(); ++n) { - if (!handles_[n]) { - // Found a free descriptor in the table. - handles_[n] = handle; - return static_cast<int>(n); - } - } - // Allocate new descriptor value. - handles_.PushBack(handle); - return static_cast<int>(n); - } - - // Deallocate a file descriptor by value. - bool DeallocateFd(int fd) { - if (!Find(fd)) { - return false; - } - delete handles_[fd]; - handles_[fd] = nullptr; - return true; - } - - private: - Vector<MockFileHandle*> handles_; -}; - -class MockSystem { - public: - MockSystem() : files_(), environment_() {} - - ~MockSystem() { Reset(); } - - void SetCurrentDir(const char* path) { current_dir_ = path; } - - String GetCurrentDir() const { return current_dir_; } - - void AddFileEntry(MockFileEntry* entry) { files_.PushBack(entry); } - - void AddEnvEntry(MockEnvEntry* entry) { environment_.PushBack(entry); } - - MockFileEntry* FindFileEntry(const char* path) { - for (size_t n = 0; n < files_.GetCount(); ++n) { - MockFileEntry* entry = files_[n]; - if (entry->GetPath() && !strcmp(path, entry->GetPath())) - return entry; - } - return NULL; - } - - MockEnvEntry* FindEnvEntry(const char* var_name) { - for (size_t n = 0; n < environment_.GetCount(); ++n) { - MockEnvEntry* entry = environment_[n]; - if (!strcmp(entry->GetName().c_str(), var_name)) - return entry; - } - return NULL; - } - - int OpenFd(const char* path, crazy::FileOpenMode open_mode) { - // TODO(digit): Add write support. - if (open_mode != crazy::FILE_OPEN_READ_ONLY) - Panic("Unsupported open mode (%d): %s", open_mode, path); - - MockFileEntry* entry = FindFileEntry(path); - if (!entry) { - errno = ENOENT; - return -1; - } - - return handles_.AllocateFd(new MockFileHandle(entry)); - } - - MockFileHandle* FindFileHandle(int fd) const { return handles_.Find(fd); } - - void CloseFd(int fd) { - if (!handles_.DeallocateFd(fd)) { - Panic("Closing invalid file descriptor %d", fd); - } - } - - void Reset() { - files_.Reset(); - environment_.Reset(); - current_dir_ = "/"; - } - - void Check() { - if (!active_) - Panic("No mock file system setup!"); - } - - void Activate() { - if (active_) - Panic("Double mock file system activation!"); - - active_ = true; - } - - void Deactivate() { - if (!active_) - Panic("Double mock file system deactivation!"); - - active_ = false; - } - - private: - List<MockFileEntry> files_; - List<MockEnvEntry> environment_; - MockFileHandleTable handles_; - String current_dir_; - bool active_; -}; - -MockSystem s_mock_fs; - -} // namespace - -namespace crazy { - -#ifdef UNIT_TEST - -bool PathExists(const char* path) { - s_mock_fs.Check(); - return s_mock_fs.FindFileEntry(path) != NULL; -} - -bool PathIsFile(const char* path) { - // TODO(digit): Change this when support for mock directories is added. - return PathExists(path); -} - -String GetCurrentDirectory() { - s_mock_fs.Check(); - return s_mock_fs.GetCurrentDir(); -} - -const char* GetEnv(const char* var_name) { - s_mock_fs.Check(); - MockEnvEntry* entry = s_mock_fs.FindEnvEntry(var_name); - if (!entry) - return NULL; - else - return entry->GetValue().c_str(); -} - -ssize_t FileDescriptor::Read(void* buffer, size_t buffer_size) { - s_mock_fs.Check(); - MockFileHandle* handle = s_mock_fs.FindFileHandle(fd_); - if (!handle) { - errno = EBADF; - return -1; - } - return handle->Read(buffer, buffer_size); -} - -off_t FileDescriptor::SeekTo(off_t offset) { - s_mock_fs.Check(); - MockFileHandle* handle = s_mock_fs.FindFileHandle(fd_); - if (!handle) { - errno = EBADF; - return -1; - } - return handle->SeekTo(offset); -} - -void* FileDescriptor::Map(void* address, - size_t length, - int prot, - int flags, - off_t offset) { - s_mock_fs.Check(); - MockFileHandle* handle = s_mock_fs.FindFileHandle(fd_); - if (!handle) { - errno = EBADF; - return nullptr; - } - if ((offset & 4095) != 0) { - errno = EINVAL; - return nullptr; - } - return handle->Map(address, length, prot, flags, offset); -} - -int64_t FileDescriptor::GetFileSize() const { - s_mock_fs.Check(); - MockFileHandle* handle = s_mock_fs.FindFileHandle(fd_); - if (!handle) { - errno = EBADF; - return -1; - } - return handle->GetFileSize(); -} - -// static -int FileDescriptor::DoOpenReadOnly(const char* path) { - s_mock_fs.Check(); - return s_mock_fs.OpenFd(path, FILE_OPEN_READ_ONLY); -} - -// static -int FileDescriptor::DoOpenReadWrite(const char* path) { - s_mock_fs.Check(); - return s_mock_fs.OpenFd(path, FILE_OPEN_READ_WRITE); -} - -// static -void FileDescriptor::DoClose(int fd) { - s_mock_fs.Check(); - s_mock_fs.CloseFd(fd); -} - -SystemMock::SystemMock() { s_mock_fs.Activate(); } - -SystemMock::~SystemMock() { - s_mock_fs.Deactivate(); - s_mock_fs.Reset(); -} - -void SystemMock::AddRegularFile(const char* path, - const char* data, - size_t data_size) { - s_mock_fs.Check(); - - MockFileEntry* entry = new MockFileEntry(); - entry->SetPath(path); - entry->SetData(data, data_size); - - s_mock_fs.AddFileEntry(entry); -} - -void SystemMock::AddEnvVariable(const char* var_name, const char* var_value) { - s_mock_fs.Check(); - - MockEnvEntry* env = new MockEnvEntry(var_name, var_value); - s_mock_fs.AddEnvEntry(env); -} - -void SystemMock::SetCurrentDir(const char* path) { - s_mock_fs.Check(); - s_mock_fs.SetCurrentDir(path); -} - -#endif // UNIT_TEST - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.h b/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.h deleted file mode 100644 index 181c4c6..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_mock.h +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_SYSTEM_MOCK_H -#define CRAZY_LINKER_SYSTEM_MOCK_H - -#include <stdint.h> - -namespace crazy { - -class SystemMock { - public: - // Create a new mock system instance and make ScopedFileDescriptor use it. - // There can be only one mock system active at a given time. - SystemMock(); - - // Destroy a mock system instance. - ~SystemMock(); - - // Add a regular file to the mock file system. |path| is the entry's - // path, and |data| and |data_size| are the data there. The data must - // stay valid until the mock file system is destroyed. - void AddRegularFile(const char* path, const char* data, size_t data_size); - - void AddEnvVariable(const char* var_name, const char* var_value); - - void SetCurrentDir(const char* path); -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_SYSTEM_MOCK_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_system_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_system_unittest.cpp deleted file mode 100644 index 7f1edc0..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_system_unittest.cpp +++ /dev/null
@@ -1,122 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_system.h" - -#include <gtest/gtest.h> -#include <stdlib.h> -#include "crazy_linker_system_mock.h" - -namespace crazy { - -TEST(System, SingleFile) { - static const char kPath[] = "/tmp/foo/bar"; - - static const char kString[] = "Hello World"; - const size_t kStringLen = sizeof(kString) - 1; - - SystemMock sys; - sys.AddRegularFile(kPath, kString, kStringLen); - - char buff2[kStringLen + 10]; - FileDescriptor fd(kPath); - - EXPECT_EQ(kStringLen, fd.Read(buff2, sizeof(buff2))); - buff2[kStringLen] = '\0'; - EXPECT_STREQ(kString, buff2); -} - -TEST(System, MakeDirectoryPath) { - static const struct { - const char* input; - const char* expected; - } kData[] = { - {"", "./"}, {".", "./"}, {"..", "../"}, - {"./", "./"}, {"../", "../"}, {"foo", "foo/"}, - {"foo/", "foo/"}, {"/foo", "/foo/"}, {"foo/bar", "foo/bar/"}, - }; - for (const auto& data : kData) { - EXPECT_STREQ(data.expected, MakeDirectoryPath(data.input).c_str()) - << "For [" << data.input << "]"; - } -} - -TEST(System, MakeAbsolutePathFrom) { - SystemMock sys; - - static const struct { - const char* input; - const char* expected; - } kData[] = { - {"/foo", "/foo"}, - {"/foo/bar/", "/foo/bar/"}, - {"foo", "/home/foo"}, - {"foo/bar", "/home/foo/bar"}, - {"./foo", "/home/./foo"}, - {"../foo", "/home/../foo"}, - {"../../foo", "/home/../../foo"}, - }; - - sys.SetCurrentDir("/home"); - - for (const auto& data : kData) { - EXPECT_STREQ(data.expected, MakeAbsolutePathFrom(data.input).c_str()) - << "For [" << data.input << "]"; - } - - for (const auto& data : kData) { - EXPECT_STREQ(data.expected, - MakeAbsolutePathFrom(data.input, strlen(data.input)).c_str()) - << "For [" << data.input << "]"; - } - - sys.SetCurrentDir("/home/"); - - for (const auto& data : kData) { - EXPECT_STREQ(data.expected, MakeAbsolutePathFrom(data.input).c_str()) - << "For [" << data.input << "]"; - } - - for (const auto& data : kData) { - EXPECT_STREQ(data.expected, - MakeAbsolutePathFrom(data.input, strlen(data.input)).c_str()) - << "For [" << data.input << "]"; - } -} - -TEST(System, PathExists) { - SystemMock sys; - sys.AddRegularFile("/tmp/foo", "FOO", 3); - - EXPECT_TRUE(PathExists("/tmp/foo")); -} - -TEST(System, PathExistsWithBadPath) { - SystemMock sys; - EXPECT_FALSE(PathExists("/tmp/foo")); -} - -TEST(System, IsSystemLibraryPath) { - static const struct TestPath { - bool expected; - const char* path; - } kTestPaths[] = { -#ifdef __ANDROID__ - {true, "/system/lib/libfoo.so"}, - {true, "/system/lib64/libbar.so"}, - {true, "/system/lib/egl/libEGL_emulation.so"}, - {true, "/vendor/lib/egl/libEGL_swiftshader.so"}, - {true, "/vendor/lib64/libfirmware.so"}, - {false, "/system/app/Foo/lib/libfoo.so"}, - {false, "/system/app/Foo/Foo.apk!lib/x86/libfoo.so"}, -#else - {true, "/usr/lib/libfoo.so"}, {false, "/opt/foo/lib/libfoo.so"}, -#endif - }; - for (const TestPath& path : kTestPaths) { - EXPECT_EQ(path.expected, IsSystemLibraryPath(path.path)) << path.path; - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.cpp deleted file mode 100644 index cb3361d..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.cpp +++ /dev/null
@@ -1,85 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_thread_data.h" - -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <cstring> - -namespace { - -static pthread_key_t s_thread_key; -static pthread_once_t s_once = PTHREAD_ONCE_INIT; - -static void ThreadDataDestroy(void* data) { - free(data); -} - -static void InitThreadKey() { - pthread_key_create(&s_thread_key, ThreadDataDestroy); -} - -} // namespace - -namespace crazy { - -void ThreadData::Init() { - dlerror_ = dlerror_buffers_[0]; - dlerror_[0] = '\0'; -} - -void ThreadData::SwapErrorBuffers() { - if (dlerror_ == dlerror_buffers_[0]) - dlerror_ = dlerror_buffers_[1]; - else - dlerror_ = dlerror_buffers_[0]; - dlerror_[0] = '\0'; -} - -void ThreadData::SetErrorArgs(const char* fmt, va_list args) { - if (fmt == NULL) { - dlerror_[0] = '\0'; - return; - } - vsnprintf(dlerror_, kBufferSize, fmt, args); -} - -void ThreadData::AppendErrorArgs(const char* fmt, va_list args) { - if (fmt == NULL) - return; - size_t len = strlen(dlerror_); - vsnprintf(dlerror_ + len, kBufferSize - len, fmt, args); -} - -ThreadData* GetThreadDataFast() { - return reinterpret_cast<ThreadData*>(pthread_getspecific(s_thread_key)); -} - -ThreadData* GetThreadData() { - pthread_once(&s_once, InitThreadKey); - ThreadData* data = GetThreadDataFast(); - if (!data) { - data = reinterpret_cast<ThreadData*>(calloc(sizeof(*data), 1)); - data->Init(); - pthread_setspecific(s_thread_key, data); - } - return data; -} - -// Set the linker error string for the current thread. -void SetLinkerErrorString(const char* str) { - GetThreadData()->SetError(str); -} - -// Set the formatted linker error for the current thread. -void SetLinkerError(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - GetThreadData()->SetErrorArgs(fmt, args); - va_end(args); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.h b/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.h deleted file mode 100644 index 0156cc28..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data.h +++ /dev/null
@@ -1,80 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_THREAD_DATA_H -#define CRAZY_LINKER_THREAD_DATA_H - -#include <stdarg.h> -#include <stddef.h> - -namespace crazy { - -// Per-thread context used during crazy linker operations. -class ThreadData { - public: - ThreadData() {} - - // Init new ThreadData instance. - void Init(); - - // Return the current error message. This also clears the internal - // error message, which means that the next call to this method - // will return a pointer to an empty string unless AppendError() - // was called. - const char* GetError() const { return dlerror_; } - - // Swap the error buffers. - void SwapErrorBuffers(); - - // Set message string in current dlerror buffer. - void SetError(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - SetErrorArgs(fmt, args); - va_end(args); - } - - void SetErrorArgs(const char* fmt, va_list args); - - // Append message string to current dlerror buffer. - void AppendError(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - AppendErrorArgs(fmt, args); - va_end(args); - } - - void AppendErrorArgs(const char* fmt, va_list args); - - private: - // Pointer to the current dlerror buffer. This points to one - // of the dlerror_buffers[] arrays, swapped on each dlerror() - // call. - char* dlerror_; - - // Size of each dlerror message buffer size. - static const size_t kBufferSize = 512; - - // Two buffers used to store dlerror messages. - char dlerror_buffers_[2][kBufferSize]; -}; - -// Retrieves the ThreadData structure for the current thread. -// The first time this is called on a given thread, this creates -// a fresh new object, so this should never return NULL. -ThreadData* GetThreadData(); - -// Faster variant that should only be called when GetThreadData() was -// called at least once on the current thread. -ThreadData* GetThreadDataFast(); - -// Set the linker error string for the current thread. -void SetLinkerErrorString(const char* str); - -// Set the formatted linker error for the current thread. -void SetLinkerError(const char* fmt, ...); - -} // namespace crazy - -#endif // CRAZY_LINKER_THREAD_DATA_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_thread_data_unittest.cpp deleted file mode 100644 index 3d0ed5c..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_thread_data_unittest.cpp +++ /dev/null
@@ -1,122 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_thread_data.h" - -#include <gtest/gtest.h> - -namespace crazy { - -TEST(ThreadData, GetThreadData) { - ThreadData* data = GetThreadData(); - EXPECT_TRUE(data) << "Checking first GetThreadData() call"; - EXPECT_EQ(data, GetThreadData()); - EXPECT_EQ(data, GetThreadDataFast()); -} - -TEST(ThreadData, GetErrorEmpty) { - ThreadData* data = GetThreadData(); - const char* error = data->GetError(); - EXPECT_TRUE(error); - EXPECT_STREQ("", error); -} - -TEST(ThreadData, SetError) { - ThreadData* data = GetThreadData(); - data->SetError("Hello"); - data->SetError("World"); - EXPECT_STREQ("World", data->GetError()); -} - -TEST(ThreadData, SetErrorNull) { - ThreadData* data = GetThreadData(); - data->SetError("Hello"); - data->SetError(NULL); - EXPECT_STREQ("", data->GetError()); -} - -TEST(ThreadData, GetError) { - ThreadData* data = GetThreadData(); - data->SetError("Hello"); - - const char* error = data->GetError(); - EXPECT_STREQ("Hello", error); - - error = data->GetError(); - EXPECT_STREQ("Hello", error); -} - -TEST(ThreadData, SwapErrorBuffers) { - ThreadData* data = GetThreadData(); - data->SetError("Hello"); - EXPECT_STREQ("Hello", data->GetError()); - - data->SwapErrorBuffers(); - EXPECT_STREQ("", data->GetError()); - - data->SetError("World"); - EXPECT_STREQ("World", data->GetError()); - - data->SwapErrorBuffers(); - EXPECT_STREQ("", data->GetError()); -} - -TEST(ThreadData, AppendErrorTwice) { - ThreadData* data = GetThreadData(); - data->SetError(NULL); - data->AppendError("Hello"); - EXPECT_STREQ("Hello", data->GetError()); - - data->AppendError(" World"); - EXPECT_STREQ("Hello World", data->GetError()); -} - -TEST(ThreadData, AppendErrorFull) { - const size_t kMaxCount = 1000; - ThreadData* data = GetThreadData(); - data->SetError(NULL); - - for (size_t n = 0; n < kMaxCount; ++n) - data->AppendError("0123456789"); - - const char* error = data->GetError(); - size_t error_len = strlen(error); - - EXPECT_GT(error_len, 0U); - EXPECT_LT(error_len, kMaxCount * 10); - - for (size_t n = 0; n < error_len; ++n) { - EXPECT_EQ('0' + (n % 10), error[n]) << "Checking error[" << n << "]"; - } -} - -TEST(ThreadData, AppendErrorNull) { - ThreadData* data = GetThreadData(); - data->SetError("Hello"); - data->AppendError(NULL); - data->AppendError(" World"); - EXPECT_STREQ("Hello World", data->GetError()); -} - -TEST(ThreadData, SetLinkerErrorString) { - ThreadData* data = GetThreadData(); - - SetLinkerErrorString("Hello World"); - EXPECT_STREQ("Hello World", data->GetError()); - - SetLinkerErrorString(NULL); - EXPECT_STREQ("", data->GetError()); -} - -TEST(ThreadData, SetLinkerError) { - ThreadData* data = GetThreadData(); - - SetLinkerError("%s %s!", "Hi", "Captain"); - EXPECT_STREQ("Hi Captain!", data->GetError()); - - SetLinkerError("Woosh"); - EXPECT_STREQ("Woosh", data->GetError()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_util.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_util.cpp deleted file mode 100644 index 1f9303c4..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_util.cpp +++ /dev/null
@@ -1,208 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_util.h" - -#include <stdio.h> - -namespace crazy { - -// Return the base name from a file path. Important: this is a pointer -// into the original string. -// static -const char* GetBaseNamePtr(const char* path) { - const char* p = strrchr(path, '/'); - if (!p) - return path; - else - return p + 1; -} - -// static -const char String::kEmpty[] = ""; - -String::String() { Init(); } - -String::String(const String& other) { - InitFrom(other.ptr_, other.size_); -} - -String::String(String&& other) noexcept - : ptr_(other.ptr_), size_(other.size_), capacity_(other.capacity_) { - other.Init(); -} - -String::String(const char* str) { - InitFrom(str, ::strlen(str)); -} - -String::String(char ch) { - InitFrom(&ch, 1); -} - -String::~String() { - if (HasValidPointer()) { - free(ptr_); - ptr_ = const_cast<char*>(kEmpty); - } -} - -String::String(const char* str, size_t len) { - InitFrom(str, len); -} - -String& String::operator=(String&& other) noexcept { - if (this != &other) { - this->~String(); // Free pointer if needed. - ptr_ = other.ptr_; - size_ = other.size_; - capacity_ = other.capacity_; - other.Init(); - } - return *this; -} - -void String::Assign(const char* str, size_t len) { - Resize(len); - if (len > 0) { - memcpy(ptr_, str, len); - } -} - -void String::Append(const char* str, size_t len) { - if (len > 0) { - size_t old_size = size_; - Resize(size_ + len); - memcpy(ptr_ + old_size, str, len); - } -} - -void String::Resize(size_t new_size) { - if (new_size > capacity_) { - size_t new_capacity = capacity_; - while (new_capacity < new_size) { - new_capacity += (new_capacity >> 1) + 16; - } - Reserve(new_capacity); - } - - if (new_size > size_) - memset(ptr_ + size_, '\0', new_size - size_); - - size_ = new_size; - if (HasValidPointer()) { - ptr_[size_] = '\0'; - } -} - -void String::Reserve(size_t new_capacity) { - char* old_ptr = HasValidPointer() ? ptr_ : nullptr; - // Always allocate one more byte for the trailing \0 - ptr_ = reinterpret_cast<char*>(realloc(old_ptr, new_capacity + 1)); - ptr_[new_capacity] = '\0'; - capacity_ = new_capacity; - - if (size_ > new_capacity) - size_ = new_capacity; -} - -void String::InitFrom(const char* str, size_t len) { - Init(); - if (str != nullptr && len != 0) { - Resize(len); - memcpy(ptr_, str, len); - } -} - -bool String::operator==(const String& other) const { - return size_ == other.size_ && !::memcmp(ptr_, other.ptr_, size_); -} - -bool String::operator==(const char* str) const { - return !::strcmp(ptr_, str); -} - -VectorBase::~VectorBase() { - ::free(data_); -} - -VectorBase::VectorBase(VectorBase&& other) noexcept - : data_(other.data_), count_(other.count_), capacity_(other.capacity_) { - other.DoReset(); -} - -VectorBase& VectorBase::operator=(VectorBase&& other) noexcept { - if (&other != this) { - ::free(data_); - data_ = other.data_; - count_ = other.count_; - capacity_ = other.capacity_; - other.DoReset(); - } - return *this; -} - -void VectorBase::DoResize(size_t new_count, size_t item_size) { - if (new_count > capacity_) { - DoReserve(new_count, item_size); - } - if (new_count > count_) - ::memset(data_ + count_ * item_size, 0, (new_count - count_) * item_size); - - count_ = new_count; -} - -void VectorBase::DoReserve(size_t new_capacity, size_t item_size) { - data_ = static_cast<char*>(::realloc(data_, new_capacity * item_size)); - capacity_ = new_capacity; - if (count_ > capacity_) - count_ = capacity_; -} - -void* VectorBase::DoInsert(size_t pos, size_t item_size) { - return DoInsert(pos, 1, item_size); -} - -void* VectorBase::DoInsert(size_t pos, size_t count, size_t item_size) { - if (pos >= count_) - pos = count_; - - size_t new_count = count_ + count; - if (new_count > capacity_) { - size_t new_capacity = capacity_; - while (new_capacity < new_count) { - new_capacity += (new_capacity >> 2) + 4; - } - DoReserve(new_capacity, item_size); - } - - char* from_data = data_ + pos * item_size; - char* to_data = from_data + count * item_size; - - ::memmove(to_data, from_data, (count_ - pos) * item_size); - ::memset(from_data, 0, count * item_size); - - count_ = new_count; - return from_data; -} - -void VectorBase::DoRemove(size_t pos, size_t item_size) { - DoRemove(pos, 1, item_size); -} - -void VectorBase::DoRemove(size_t pos, size_t count, size_t item_size) { - if (pos >= count_) - return; - - if (count > count_ - pos) - count = count_ - pos; - - char* to_data = data_ + pos * item_size; - char* from_data = to_data + count * item_size; - - ::memmove(to_data, from_data, (count_ - pos - count) * item_size); - count_ -= count; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_util.h b/third_party/android_crazy_linker/src/src/crazy_linker_util.h deleted file mode 100644 index afdcee7..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_util.h +++ /dev/null
@@ -1,334 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_UTIL_H -#define CRAZY_LINKER_UTIL_H - -#include <fcntl.h> -#include <limits.h> -#include <stdarg.h> -#include <stdio.h> -#include <unistd.h> -#include <cstdlib> -#include <cstring> - -#include <type_traits> -#include <utility> - -namespace crazy { - -// Helper macro to loop around EINTR errors in syscalls. -#define HANDLE_EINTR(expr) TEMP_FAILURE_RETRY(expr) - -// Helper macro to tag unused variables. Use in the declaration, between -// the type and name, as in: -// int CRAZY_UNUSED my_var = 0; -#define CRAZY_UNUSED __attribute__((unused)) - -// Offset in a file indicating a failure. -#define CRAZY_OFFSET_FAILED (-1) - -// Helper scoped pointer class. -template <class T> -class ScopedPtr { - public: - ScopedPtr() : ptr_(NULL) {} - explicit ScopedPtr(T* ptr) : ptr_(ptr) {} - ~ScopedPtr() { Reset(NULL); } - - ScopedPtr(ScopedPtr&& other) noexcept : ptr_(other.ptr_) { - other.ptr_ = nullptr; - } - - ScopedPtr& operator=(ScopedPtr&& other) noexcept { - if (this != &other) { - delete ptr_; - ptr_ = other.ptr_; - other.ptr_ = nullptr; - } - return *this; - } - - T* Release() { - T* ret = ptr_; - ptr_ = NULL; - return ret; - } - - void Reset(T* ptr) { - delete ptr_; - ptr_ = ptr; - } - - T* Get() { return ptr_; } - T& operator*() { return *ptr_; } - T* operator->() { return ptr_; } - - private: - T* ptr_; -}; - -// Return the base name from a file path. Important: this is a pointer -// into the original string. -const char* GetBaseNamePtr(const char* path); - -// Helper class used to implement a string. Similar to std::string -// without all the crazy iterator / iostream stuff. -// -// Required because crazy linker should only link against the system -// libstdc++ that only provides new/delete. -// -class String { - public: - String(); - String(const char* str, size_t len); - String(const String& other); - String(String&& other) noexcept; - - explicit String(const char* str); - explicit String(char ch); - - ~String(); - - const char* c_str() const { return ptr_; } - char* ptr() { return ptr_; } - size_t size() const { return size_; } - size_t capacity() const { return capacity_; } - - const char* begin() const { return ptr_; } - const char* end() const { return ptr_ + size_; } - - char* begin() { return ptr_; } - char* end() { return ptr_ + size_; } - - const char* cbegin() const { return ptr_; } - const char* cend() const { return ptr_ + size_; } - - bool IsEmpty() const { return size_ == 0; } - - char& operator[](size_t index) { return ptr_[index]; } - - String& operator=(const String& other) { - Assign(other.ptr_, other.size_); - return *this; - } - - String& operator=(String&& other) noexcept; - - String& operator=(const char* str) { - Assign(str, strlen(str)); - return *this; - } - - String& operator=(char ch) { - Assign(&ch, 1); - return *this; - } - - String& operator+=(const String& other) { - Append(other); - return *this; - } - - String& operator+=(const char* str) { - Append(str, strlen(str)); - return *this; - } - - String& operator+=(char ch) { - Append(&ch, 1); - return *this; - } - - void Resize(size_t new_size); - - void Reserve(size_t new_capacity); - - void Assign(const char* str, size_t len); - - void Assign(const String& other) { Assign(other.ptr_, other.size_); } - - void Assign(const char* str) { Assign(str, strlen(str)); } - - void Append(const char* str, size_t len); - - void Append(const String& other) { Append(other.ptr_, other.size_); } - - void Append(const char* str) { Append(str, strlen(str)); } - - // Comparison operators. - bool operator==(const String& other) const; - bool operator==(const char* str) const; - - inline bool operator!=(const String& other) const { - return !(*this == other); - } - - inline bool operator!=(const char* str) const { return !(*this == str); } - - private: - inline void Init() { - ptr_ = const_cast<char*>(kEmpty); - size_ = 0; - capacity_ = 0; - } - - inline bool HasValidPointer() const { - return ptr_ != const_cast<char*>(kEmpty); - } - - void InitFrom(const char* str, size_t len); - - static const char kEmpty[]; - - char* ptr_; - size_t size_; - size_t capacity_; -}; - -// Base vector class used by all instantiations of Vector<> to reduce -// generated code size. -class VectorBase { - public: - VectorBase() = default; - ~VectorBase(); - - // Disallow copy operations. - VectorBase(const VectorBase&) = delete; - VectorBase& operator=(const VectorBase&) = delete; - - // Allow move operations. - VectorBase(VectorBase&& other) noexcept; - VectorBase& operator=(VectorBase&& other) noexcept; - - // Return true iff vector is empty. - constexpr bool IsEmpty() const { return count_ == 0U; } - - // Return number of items in container. - constexpr size_t GetCount() const { return count_; } - - protected: - // Reset container state. - void DoReset() { - data_ = nullptr; - count_ = 0; - capacity_ = 0; - } - - // Perform various operations on the array. - void DoResize(size_t new_count, size_t item_size); - void DoReserve(size_t new_capacity, size_t item_size); - void* DoInsert(size_t pos, size_t item_size); - void* DoInsert(size_t pos, size_t count, size_t item_size); - void DoRemove(size_t pos, size_t item_size); - void DoRemove(size_t pos, size_t count, size_t item_size); - - char* data_ = nullptr; - size_t count_ = 0; - size_t capacity_ = 0; -}; - -// Result type for a linear or binary search function. -// The packing generates smaller and faster machine code on ARM and x86. -struct SearchResult { - bool found : 1; - size_t pos : sizeof(size_t) * CHAR_BIT - 1; -}; - -// Helper template used to implement a simple vector of POD-struct items. -// I.e. this uses memmove() to move items during insertion / removal. -// -// Required because crazy linker should only link against the system -// libstdc++ which only provides new/delete. -// -template <class T> -class Vector : public VectorBase { - public: - Vector() { static_assert(std::is_pod<T>::value, "type T should be POD"); } - - ~Vector() = default; - - // Move operations are allowed. - Vector(Vector&& other) : VectorBase(std::move(other)) {} - - Vector& operator=(Vector&& other) { - if (this != &other) { - this->VectorBase::operator=(std::move(other)); - } - return *this; - } - - // Support for-range loops. - constexpr const T* cbegin() const { - return reinterpret_cast<const T*>(data_); - } - constexpr const T* cend() const { return cbegin() + count_; } - - constexpr const T* begin() const { return cbegin(); } - constexpr const T* end() const { return cend(); } - - T* begin() { return const_cast<T*>(cbegin()); } - T* end() { return const_cast<T*>(cend()); } - - // Array access operator. - constexpr const T& operator[](size_t index) const { return cbegin()[index]; } - T& operator[](size_t index) { return begin()[index]; } - - // Append one item at the end of the vector. - void PushBack(T item) { InsertAt(count_, item); } - - // Remove the first item from the vector and return it. - // Undefined behaviour if it is empty. - T PopFirst() { - T result = cbegin()[0]; - RemoveAt(0); - return result; - } - - // Remove the last item from the vector and return it. - // Undefined behaviour if the vector is empty. - T PopLast() { - T result = cend()[-1]; - DoResize(count_ - 1, sizeof(T)); - return result; - } - - // Remove a specific item from the vector, if it contains it. - void Remove(T item) { - SearchResult result = Find(item); - if (result.found) - RemoveAt(result.pos); - } - - // Insert a new |item| into a specific position |index|. - void InsertAt(size_t index, T item) { - auto* slot = reinterpret_cast<T*>(DoInsert(index, sizeof(T))); - *slot = item; - } - - // Remove the item at position |index|. - void RemoveAt(size_t index) { DoRemove(index, sizeof(T)); } - - // Try to find |item| in the vector. - SearchResult Find(T wanted) const { - for (size_t pos = 0; pos < count_; ++pos) { - if (cbegin()[pos] == wanted) - return {true, pos}; - } - return {false, 0}; - } - - // Returns true if vector contains |item|. - bool Has(T item) const { return Find(item).found; } - - // Resize vector. - void Resize(size_t new_count) { DoResize(new_count, sizeof(T)); } - - // Reset the vector's capacity to a new value. Truncate size if needed. - void Reserve(size_t new_capacity) { DoReserve(new_capacity, sizeof(T)); } -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_UTIL_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_util_threads.h b/third_party/android_crazy_linker/src/src/crazy_linker_util_threads.h deleted file mode 100644 index 98c01bc..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_util_threads.h +++ /dev/null
@@ -1,143 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_UTIL_THREADS_H -#define CRAZY_LINKER_UTIL_THREADS_H - -#include <pthread.h> - -#include "crazy_linker_macros.h" - -// Convenience classes for managing and synchronizing threads. -// Reminder: the crazy linker cannot use std::thread and other C++ library -// features at all. - -namespace crazy { - -// Small abstraction for simple (non-recursive) mutexes. -class Mutex { - public: - Mutex() = default; - ~Mutex() { pthread_mutex_destroy(&mutex_); } - void Lock() { pthread_mutex_lock(&mutex_); } - void Unlock() { pthread_mutex_unlock(&mutex_); } - - // Futexes cannot be copied or moved to different addresses. - CRAZY_DISALLOW_COPY_AND_MOVE_OPERATIONS(Mutex) - - private: - friend class Condition; - pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; -}; - -// Scoped auto-lock convenience class. -// Locks the mutex on construction, releases it on destruction unless -// Release() was called before. -class AutoLock { - public: - // Constructor takes pointer to Mutex instance and locks it. - AutoLock() = delete; - explicit AutoLock(Mutex* mutex) : mutex_(mutex) { mutex_->Lock(); } - // Destructor unlocks it if it wasn't released yet. - ~AutoLock() { - if (mutex_) - mutex_->Unlock(); - } - - CRAZY_DISALLOW_COPY_AND_MOVE_OPERATIONS(AutoLock); - - private: - Mutex* mutex_ = nullptr; -}; - -// Small abstraction for condition variables. -class Condition { - public: - // Constructor takes pointer to associated mutex. - Condition() = delete; - explicit Condition(Mutex* mutex) : mutex_(mutex) {} - ~Condition() { pthread_cond_destroy(&cond_); } - void Signal() { pthread_cond_signal(&cond_); } - void Wait() { pthread_cond_wait(&cond_, &mutex_->mutex_); } - - // Futexes cannot be copied or moved to different addresses. - CRAZY_DISALLOW_COPY_AND_MOVE_OPERATIONS(Condition); - - private: - Mutex* mutex_; - pthread_cond_t cond_ = PTHREAD_COND_INITIALIZER; -}; - -// Small waitable event to synchronize two threads. -class WaitableEvent { - public: - WaitableEvent() : mutex_(), cond_(&mutex_) {} - ~WaitableEvent() = default; - - // Returns true iff the event was signaled. - bool IsSignaled() const { - AutoLock lock(&mutex_); - return signaled_; - } - - // Signal event, it will be reset after Wait() is called. - // Can be called several times. - void Signal() { - AutoLock lock(&mutex_); - signaled_ = true; - cond_.Signal(); - } - - // Wait for the event being signaled. Always reset the event. - void Wait() { - AutoLock lock(&mutex_); - while (!signaled_) - cond_.Wait(); - signaled_ = false; - } - - private: - mutable Mutex mutex_; - Condition cond_; - bool signaled_ = false; -}; - -// Small abstract base thread class. Usage is the following: -// 1) Define derived class that implements the Main() method. -// 2) Create new instance of derived class, which starts the thread -// immediately. -// 3) Call Join() method to wait for thread exit. -// 4) Delete the instance. -class ThreadBase { - public: - // Constructor creates background thread, and starts it immediately. - ThreadBase() { - pthread_create( - &handle_, nullptr, - [](void* arg) -> void* { - reinterpret_cast<ThreadBase*>(arg)->Main(); - return nullptr; - }, - reinterpret_cast<void*>(this)); - } - - // Destructor. - virtual ~ThreadBase() = default; - - // Wait until the thread terminates. - void Join() { - void* dummy = nullptr; - pthread_join(handle_, &dummy); - } - - // Must be implemented by derived classes. - virtual void Main() = 0; - - private: - pthread_t handle_; -}; - -} // namespace crazy - -#endif // CRAZY_LINKER_UTIL_THREADS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_util_threads_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_util_threads_unittest.cpp deleted file mode 100644 index 7e69356..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_util_threads_unittest.cpp +++ /dev/null
@@ -1,135 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_util_threads.h" - -#include <gtest/gtest.h> - -#include <memory> - -#include <sched.h> - -namespace crazy { - -TEST(ThreadBase, SimpleThread) { - // Create a test thread class that simply sets a flag to true in its - // main body and exits immediately. - class SimpleThread : public ThreadBase { - public: - SimpleThread(bool* flag_ptr) : flag_ptr_(flag_ptr) {} - - private: - void Main() override { *flag_ptr_ = true; } - bool* flag_ptr_; - }; - - bool flag = false; - SimpleThread thread(&flag); - thread.Join(); - ASSERT_TRUE(flag); -} - -TEST(Mutex, SimpleLockUnlock) { - Mutex m; - m.Lock(); - m.Unlock(); -} - -TEST(Mutex, ThreadSynchronization) { - // State shared by all threads, i.e. a mutex-protected counter. - struct SharedState { - Mutex mutex; - int counter = 0; - }; - // Create kMaxThreads that will use a common lock to increment a counter - // in succession. Each thread has a numerical id, and will loop until - // the counter reaches before incrementing it then exiting. - class TestThread : public ThreadBase { - public: - TestThread(SharedState* state, int id) : state_(state), id_(id) {} - - private: - void Main() override { - bool quit = false; - while (!quit) { - state_->mutex.Lock(); - if (state_->counter == id_) { - state_->counter += 1; - quit = true; - } else { - sched_yield(); - } - state_->mutex.Unlock(); - } - } - - SharedState* state_; - int id_; - }; - - SharedState state; - const int kMaxThreads = 100; - std::unique_ptr<TestThread> threads[kMaxThreads]; - - // Launch all threads - for (int n = kMaxThreads; n > 0; n--) { - threads[n - 1].reset(new TestThread(&state, n - 1)); - } - - // Join the last thread, this should only return when all other threads - // have completed. - threads[kMaxThreads - 1]->Join(); - - ASSERT_EQ(kMaxThreads, state.counter); - for (int n = 0; n < kMaxThreads - 1; n++) - threads[n]->Join(); -} - -TEST(Condition, ThreadSynchonization) { - // A TestThread class which will wait until Start() is called to increment - // a given integer counter then exiting. - class TestThread : public ThreadBase { - public: - TestThread(int* counter_ptr) : counter_ptr_(counter_ptr), cond_(&mutex_) {} - - void Start() { - mutex_.Lock(); - started_ = true; - cond_.Signal(); - mutex_.Unlock(); - } - - private: - void Main() override { - mutex_.Lock(); - while (!started_) - cond_.Wait(); - - *counter_ptr_ += 1; - mutex_.Unlock(); - } - - int* counter_ptr_; - Mutex mutex_; - Condition cond_; - bool started_ = false; - }; - - int counter = 0; - const int kMaxThreads = 100; - std::unique_ptr<TestThread> threads[kMaxThreads]; - - for (int n = 0; n < kMaxThreads; ++n) { - threads[n].reset(new TestThread(&counter)); - } - - ASSERT_EQ(0, counter); - for (int n = 0; n < kMaxThreads; ++n) { - threads[n]->Start(); - threads[n]->Join(); - ASSERT_EQ(n + 1, counter); - } -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_util_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_util_unittest.cpp deleted file mode 100644 index e7729a14..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_util_unittest.cpp +++ /dev/null
@@ -1,296 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_util.h" - -#include <gtest/gtest.h> - -#include <utility> - -namespace crazy { - -TEST(GetBaseNamePtr, Test) { - const char kString[] = "/tmp/foo"; - EXPECT_EQ(kString + 5, GetBaseNamePtr(kString)); -} - -TEST(String, Empty) { - String s; - EXPECT_TRUE(s.IsEmpty()); - EXPECT_EQ(0u, s.size()); - EXPECT_EQ('\0', s.c_str()[0]); -} - -TEST(String, CStringConstructor) { - String s("Simple"); - EXPECT_STREQ("Simple", s.c_str()); - EXPECT_EQ(6U, s.size()); -} - -TEST(String, CStringConstructorWithLength) { - String s2("Simple", 3); - EXPECT_STREQ("Sim", s2.c_str()); - EXPECT_EQ(3U, s2.size()); -} - -TEST(String, CopyConstructor) { - String s1("Simple"); - String s2(s1); - - EXPECT_EQ(6U, s2.size()); - EXPECT_STREQ(s2.c_str(), s1.c_str()); -} - -TEST(String, MoveConstructor) { - String s1("Source"); - String s2(std::move(s1)); - - EXPECT_TRUE(s1.IsEmpty()); - EXPECT_EQ(6U, s2.size()); - EXPECT_STREQ(s2.c_str(), "Source"); -} - -TEST(String, CharConstructor) { - String s('H'); - EXPECT_EQ(1U, s.size()); - EXPECT_STREQ("H", s.c_str()); -} - -TEST(String, CopyAssign) { - String s1("Source"); - String s2("Destination"); - - s1 = s2; - EXPECT_STREQ(s1.c_str(), s2.c_str()); -} - -TEST(String, MoveAssign) { - String s1("Source"); - String s2("Destination"); - - s2 = std::move(s1); - - EXPECT_TRUE(s1.IsEmpty()); - EXPECT_STREQ("Source", s2.c_str()); -} - -TEST(String, AppendCString) { - String s("Foo"); - s += "Bar"; - EXPECT_STREQ("FooBar", s.c_str()); - s += "Zoo"; - EXPECT_STREQ("FooBarZoo", s.c_str()); -} - -TEST(String, AppendOther) { - String s("Foo"); - String s2("Bar"); - s += s2; - EXPECT_STREQ("FooBar", s.c_str()); -} - -TEST(String, ArrayAccess) { - String s("FooBar"); - EXPECT_EQ('F', s[0]); - EXPECT_EQ('o', s[1]); - EXPECT_EQ('o', s[2]); - EXPECT_EQ('B', s[3]); - EXPECT_EQ('a', s[4]); - EXPECT_EQ('r', s[5]); - EXPECT_EQ('\0', s[6]); -} - -TEST(String, EqualityOperators) { - String a("Foo"); - String b("Bar"); - - EXPECT_TRUE(a == String("Foo")); - EXPECT_TRUE(a == "Foo"); - - EXPECT_TRUE(b != String("Foo")); - EXPECT_TRUE(b != "Foo"); - - EXPECT_TRUE(a != b); - - EXPECT_TRUE(b == String("Bar")); - EXPECT_TRUE(b == "Bar"); - - EXPECT_FALSE(a == "Foo "); - EXPECT_FALSE(b == " Bar"); - EXPECT_FALSE(a == "foo"); - - EXPECT_TRUE(a != "Foo "); - EXPECT_TRUE(b != " Bar"); - EXPECT_TRUE(a != "foo"); -} - -TEST(String, Resize) { - String s("A very long string to have fun"); - s.Resize(10); - EXPECT_EQ(10U, s.size()); - EXPECT_STREQ("A very lon", s.c_str()); -} - -TEST(String, ResizeToZero) { - String s("Long string to force a dynamic allocation"); - s.Resize(0); - EXPECT_EQ(0U, s.size()); - EXPECT_STREQ("", s.c_str()); -} - -TEST(Vector, IsEmpty) { - Vector<void*> v; - EXPECT_TRUE(v.IsEmpty()); -} - -TEST(Vector, PushBack) { - Vector<int> v; - v.PushBack(12345); - EXPECT_FALSE(v.IsEmpty()); - EXPECT_EQ(1U, v.GetCount()); - EXPECT_EQ(12345, v[0]); -} - -TEST(Vector, PushBack2) { - const int kMaxCount = 500; - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - EXPECT_FALSE(v.IsEmpty()); - EXPECT_EQ(static_cast<size_t>(kMaxCount), v.GetCount()); -} - -TEST(Vector, MoveConstructor) { - const int kMaxCount = 500; - Vector<int> v1; - for (int n = 0; n < kMaxCount; ++n) - v1.PushBack(n * 100); - - Vector<int> v2(std::move(v1)); - - EXPECT_TRUE(v1.IsEmpty()); - EXPECT_FALSE(v2.IsEmpty()); - - EXPECT_EQ(static_cast<size_t>(kMaxCount), v2.GetCount()); - for (int n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(n * 100, v2[n]) << "Checking v[" << n << "]"; - } -} - -TEST(Vector, MoveAssign) { - const int kMaxCount = 500; - Vector<int> v1; - for (int n = 0; n < kMaxCount; ++n) - v1.PushBack(n * 100); - - Vector<int> v2; - - v2 = std::move(v1); - - EXPECT_TRUE(v1.IsEmpty()); - EXPECT_FALSE(v2.IsEmpty()); - - EXPECT_EQ(static_cast<size_t>(kMaxCount), v2.GetCount()); - for (int n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(n * 100, v2[n]) << "Checking v[" << n << "]"; - } -} - -TEST(Vector, At) { - const int kMaxCount = 500; - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - for (int n = 0; n < kMaxCount; ++n) { - EXPECT_EQ(n * 100, v[n]) << "Checking v[" << n << "]"; - } -} - -TEST(Vector, Find) { - const int kMaxCount = 500; - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - for (int n = 0; n < kMaxCount; ++n) { - SearchResult r = v.Find(n * 100); - EXPECT_TRUE(r.found) << "Looking for " << n * 100; - EXPECT_EQ(n, r.pos) << "Looking for " << n * 100; - } -} - -TEST(Vector, ForRangeLoop) { - const int kMaxCount = 500; - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - int n = 0; - for (const int& value : v) { - EXPECT_EQ(n * 100, value) << "Checking v[" << n << "]"; - n++; - } -} - -TEST(Vector, InsertAt) { - const int kMaxCount = 500; - - for (size_t k = 0; k < kMaxCount; ++k) { - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - v.InsertAt(k, -1000); - - EXPECT_EQ(kMaxCount + 1, v.GetCount()); - for (int n = 0; n < v.GetCount(); ++n) { - int expected; - if (n < k) - expected = n * 100; - else if (n == k) - expected = -1000; - else - expected = (n - 1) * 100; - EXPECT_EQ(expected, v[n]) << "Checking v[" << n << "]"; - } - } -} - -TEST(Vector, RemoveAt) { - const int kMaxCount = 500; - - for (size_t k = 0; k < kMaxCount; ++k) { - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - v.RemoveAt(k); - - EXPECT_EQ(kMaxCount - 1, v.GetCount()); - for (int n = 0; n < kMaxCount - 1; ++n) { - int expected = (n < k) ? (n * 100) : ((n + 1) * 100); - EXPECT_EQ(expected, v[n]) << "Checking v[" << n << "]"; - } - } -} - -TEST(Vector, PopFirst) { - const int kMaxCount = 500; - Vector<int> v; - for (int n = 0; n < kMaxCount; ++n) - v.PushBack(n * 100); - - for (int n = 0; n < kMaxCount; ++n) { - int first = v.PopFirst(); - EXPECT_EQ(n * 100, first) << "Checking " << n << "-th PopFirst()"; - EXPECT_EQ(kMaxCount - 1 - n, v.GetCount()) - << "Checking " << n << "-th PopFirst()"; - } - EXPECT_EQ(0u, v.GetCount()); - EXPECT_TRUE(v.IsEmpty()); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.cpp deleted file mode 100644 index 94f959f..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.cpp +++ /dev/null
@@ -1,410 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_wrappers.h" - -#include <link.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_globals.h" -#include "crazy_linker_library_list.h" -#include "crazy_linker_library_view.h" -#include "crazy_linker_shared_library.h" -#include "crazy_linker_system_linker.h" -#include "crazy_linker_thread_data.h" -#include "crazy_linker_util.h" - -#ifdef __ANDROID__ -#include <android/dlext.h> -#endif - -#ifdef __arm__ -// On ARM, this function is exported by the dynamic linker but never -// declared in any official header. It is used at runtime to -// find the base address of the .ARM.exidx section for the -// shared library containing the instruction at |pc|, as well as -// the number of 8-byte entries in that section, written into |*pcount| -extern "C" _Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr, int*); -#else -// On other architectures, this function is exported by the dynamic linker -// but never declared in any official header. It is used at runtime to -// iterate over all loaded libraries and call the |cb|. When the function -// returns non-0, the iteration returns and the function returns its -// value. -extern "C" int dl_iterate_phdr(int (*cb)(dl_phdr_info* info, - size_t size, - void* data), - void* data); -#endif - -namespace crazy { - -namespace { - -#ifndef UNIT_TEST -// LLVM's demangler is large, and we have no need of it. Overriding it with -// our own stub version here stops a lot of code being pulled in from libc++. -// This reduces the on-disk footprint of the crazy linker library by more than -// 70%, down from over 290kb to under 85kb on ARM. -// -// For details, see: -// https://code.google.com/p/chromium/issues/detail?id=502299 -// https://llvm.org/svn/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp -extern "C" char* __cxa_demangle(const char* mangled_name, - char* buf, - size_t* n, - int* status) { - static const int kMemoryAllocFailure = -1; // LLVM's memory_alloc_failure. - if (status) - *status = kMemoryAllocFailure; - return NULL; -} -#endif // UNIT_TEST - -#ifdef __arm__ -extern "C" int __cxa_atexit(void (*)(void*), void*, void*); - -// On ARM, this function is defined as a weak symbol by libc.so. -// Unfortunately its address cannot be found through dlsym(), which will -// always return NULL. To work-around this, define a copy here that does -// exactly the same thing. The ARM EABI mandates the function's behaviour. -// __cxa_atexit() is implemented by the C library, but not declared by -// any official header. It's part of the low-level C++ support runtime. -int __aeabi_atexit(void* object, void (*destructor)(void*), void* dso_handle) { - return __cxa_atexit(destructor, object, dso_handle); -} -#endif - -// Used to save the system dlerror() into our thread-specific data. -void SaveSystemError() { - ThreadData* data = GetThreadData(); - data->SetError(SystemLinker::Error()); -} - -char* WrapDlerror() { - ThreadData* data = GetThreadData(); - const char* error = data->GetError(); - data->SwapErrorBuffers(); - // dlerror() returns a 'char*', but no sane client code should ever - // try to write to this location. - return const_cast<char*>(error); -} - -void* WrapDlopen(const char* path, int mode) { - ScopedLockedGlobals globals; - LibraryList* libs = globals->libraries(); - - // NOTE: If |path| is NULL, the wrapper should return a handle - // corresponding to the current executable. This can't be a crazy - // library, so don't try to handle it with the crazy linker. - if (path) { - LibraryView* view = libs->FindKnownLibrary(path); - if (!view) { - Error error; - LoadParams params; - if (libs->LocateLibraryFile(path, *globals->search_path_list(), ¶ms, - &error)) { - view = libs->LoadLibraryInternal(params, &error); - if (!view) { - SetLinkerError("%s: %s", "dlopen", error.c_str()); - return nullptr; - } - globals->valid_handles()->Add(view); - return view; - } - } - } - - // Try to load the executable with the system dlopen() instead. - void* system_lib = SystemLinker::Open(path, mode); - if (system_lib == NULL) { - SaveSystemError(); - return nullptr; - } - - auto* view = new LibraryView(system_lib, path ? path : "<executable>"); - libs->AddLibrary(view); - globals->valid_handles()->Add(view); - return view; -} - -#ifdef __ANDROID__ -// Prepare LoadParams according to |path| and |info|. -static LoadParams PrepareLoadParamsFrom(const char* path, - const android_dlextinfo* info) { - LoadParams params; - if (info->flags & ANDROID_DLEXT_USE_LIBRARY_FD) { - params.library_fd = info->library_fd; - if (info->flags & ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET) - params.library_offset = info->library_fd_offset; - } else { - params.library_path = path; - } - if (info->flags & ANDROID_DLEXT_RESERVED_ADDRESS) { - params.wanted_address = reinterpret_cast<uintptr_t>(info->reserved_addr); - params.reserved_size = info->reserved_size; - } - if (info->flags & ANDROID_DLEXT_RESERVED_ADDRESS_HINT) - params.reserved_load_fallback = true; - - return params; -} - -void* WrapAndroidDlopenExt(const char* path, - int mode, - const android_dlextinfo* info) { - if (!info) - return WrapDlopen(path, mode); - - ScopedLockedGlobals globals; - - const uint64_t kSupportedFlags = - ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET | - ANDROID_DLEXT_RESERVED_ADDRESS | ANDROID_DLEXT_RESERVED_ADDRESS_HINT; - const uint64_t unsupported_flags = (info->flags & ~kSupportedFlags); - if (unsupported_flags) { - SetLinkerError("%s", "unsupported android_dlextinfo flags %08llx", - "android_dlopen_ext", - static_cast<unsigned long long>(unsupported_flags)); - return nullptr; - } - - if (!path && !(info->flags & ANDROID_DLEXT_USE_LIBRARY_FD)) { - SetLinkerError("%s: missing path or file descriptor.", - "android_dlopen_ext"); - return nullptr; - } - Error error; - LibraryView* view = globals->libraries()->LoadLibraryInternal( - PrepareLoadParamsFrom(path, info), &error); - if (!view) { - SetLinkerError("%s: %s", "android_dlopen_ext", error.c_str()); - return nullptr; - } - globals->valid_handles()->Add(view); - return view; -} -#endif // __ANDROID__ - -void* WrapDlsym(void* lib_handle, const char* symbol_name) { - if (!symbol_name) { - SetLinkerError("dlsym: NULL symbol name"); - return NULL; - } - - if (!lib_handle) { - SetLinkerError("dlsym: NULL library handle"); - return NULL; - } - - // TODO(digit): Handle RTLD_DEFAULT / RTLD_NEXT - if (lib_handle == RTLD_DEFAULT || lib_handle == RTLD_NEXT) { - SetLinkerError("dlsym: RTLD_DEFAULT/RTLD_NEXT are not implemented!"); - return NULL; - } - - // NOTE: The Android dlsym() only looks inside the target library, - // while the GNU one will perform a breadth-first search into its - // dependency tree. - - // This implementation performs a correct breadth-first search - // when |lib_handle| corresponds to a crazy library, except that - // it stops at system libraries that it depends on. - - ScopedLockedGlobals globals; - if (!globals->valid_handles()->Has(lib_handle)) { - // Note: the handle was not opened with the crazy linker, so fall back - // to the system linker. That can happen in rare cases. - SystemLinker::SearchResult sym = - SystemLinker::Resolve(lib_handle, symbol_name); - if (!sym.IsValid()) { - SaveSystemError(); - LOG("Could not find symbol '%s' from foreign library [%s]", symbol_name, - GetThreadData()->GetError()); - } - return sym.address; - } - - auto* wrap_lib = reinterpret_cast<LibraryView*>(lib_handle); - if (wrap_lib->IsSystem()) { - LibraryView::SearchResult sym = wrap_lib->LookupSymbol(symbol_name); - if (!sym.IsValid()) { - SaveSystemError(); - LOG("Could not find symbol '%s' from system library %s [%s]", symbol_name, - wrap_lib->GetName(), GetThreadData()->GetError()); - } - return sym.address; - } - - if (wrap_lib->IsCrazy()) { - void* addr = globals->libraries()->FindSymbolFrom(symbol_name, wrap_lib); - if (addr) - return addr; - - SetLinkerError("dlsym: Could not find '%s' from library '%s'", - symbol_name, - wrap_lib->GetName()); - return NULL; - } - - SetLinkerError("dlsym: Invalid library handle %p looking for '%s'", - lib_handle, - symbol_name); - return NULL; -} - -int WrapDladdr(void* address, Dl_info* info) { - // First, perform search in crazy libraries. - { - ScopedLockedGlobals globals; - const LibraryView* wrap = - globals->libraries()->FindLibraryForAddress(address); - if (wrap && wrap->IsCrazy()) { - size_t sym_size = 0; - - const SharedLibrary* lib = wrap->GetCrazy(); - ::memset(info, 0, sizeof(*info)); - info->dli_fname = lib->base_name(); - info->dli_fbase = reinterpret_cast<void*>(lib->load_address()); - - // Determine if any symbol in the library contains the specified address. - (void)lib->FindNearestSymbolForAddress( - address, &info->dli_sname, &info->dli_saddr, &sym_size); - return 0; - } - } - // Otherwise, use system version. - int ret = SystemLinker::AddressInfo(address, info); - if (ret != 0) - SaveSystemError(); - return ret; -} - -int WrapDlclose(void* lib_handle) { - if (!lib_handle) { - SetLinkerError("NULL library handle"); - return -1; - } - - ScopedLockedGlobals globals; - if (!globals->valid_handles()->Remove(lib_handle)) { - // This is a foreign handle that was not created by the crazy linker. - // Fall-back to the system in this case. - if (SystemLinker::Close(lib_handle) != 0) { - SaveSystemError(); - LOG("Could not close foreign library handle %p\n%s", lib_handle, - GetThreadData()->GetError()); - return -1; - } - return 0; - } - - LibraryView* wrap_lib = reinterpret_cast<LibraryView*>(lib_handle); - if (wrap_lib->IsSystem() || wrap_lib->IsCrazy()) { - globals->libraries()->UnloadLibrary(wrap_lib); - return 0; - } - - // Invalid library handle!! - SetLinkerError("Invalid library handle %p", lib_handle); - return -1; -} - -#ifdef __arm__ -_Unwind_Ptr WrapDl_unwind_find_exidx(_Unwind_Ptr pc, int* pcount) { - // First lookup in crazy libraries. - { - ScopedLockedGlobals globals; - _Unwind_Ptr result = - globals->libraries()->FindArmExIdx(reinterpret_cast<void*>(pc), pcount); - if (result) - return result; - } - // Lookup in system libraries. - return ::dl_unwind_find_exidx(pc, pcount); -} -#else // !__arm__ -int WrapDl_iterate_phdr(int (*cb)(dl_phdr_info*, size_t, void*), void* data) { - // First, iterate over crazy libraries. - { - ScopedLockedGlobals globals; - int result = globals->libraries()->IteratePhdr(cb, data); - if (result) - return result; - } - // Then lookup through system ones. - return ::dl_iterate_phdr(cb, data); -} -#endif // !__arm__ - -} // namespace - -// This method should only be called from testing code. It is used by -// one integration test to check that wrapping works correctly within -// libraries loaded through the crazy-linker. -void* GetDlCloseWrapperAddressForTesting() { - return reinterpret_cast<void*>(&WrapDlclose); -} - -// This method should only be called from testing code. It is used to return -// the list of valid dlopen() handles created by the crazy-linker. This returns -// the address of a heap-allocated array of pointers, which must be explicitly -// free()-ed by the caller. This returns nullptr is the array is empty. -// On exit, sets |*p_count| to the number of items in the array. -const void** GetValidDlopenHandlesForTesting(size_t* p_count) { - ScopedLockedGlobals globals; - const Vector<const void*>& handles = - globals->valid_handles()->GetValuesForTesting(); - *p_count = handles.GetCount(); - if (handles.IsEmpty()) - return nullptr; - - auto* ptr = reinterpret_cast<const void**>( - malloc(handles.GetCount() * sizeof(void*))); - for (size_t n = 0; n < handles.GetCount(); ++n) { - ptr[n] = handles[n]; - } - return ptr; -} - -void* WrapLinkerSymbol(const char* name) { - // Shortcut, since all names begin with 'dl' - // Take care of __aeabi_atexit on ARM though. - if (name[0] != 'd' || name[1] != 'l') { -#ifdef __arm__ - if (name[0] == '_' && !strcmp("__aeabi_atexit", name)) - return reinterpret_cast<void*>(&__aeabi_atexit); -#endif -#ifdef __ANDROID__ - if (name[0] == 'a' && !strcmp("android_dlopen_ext", name)) - return reinterpret_cast<void*>(&WrapAndroidDlopenExt); -#endif - return NULL; - } - - static const struct { - const char* name; - void* address; - } kSymbols[] = { - {"dlopen", reinterpret_cast<void*>(&WrapDlopen)}, - {"dlclose", reinterpret_cast<void*>(&WrapDlclose)}, - {"dlerror", reinterpret_cast<void*>(&WrapDlerror)}, - {"dlsym", reinterpret_cast<void*>(&WrapDlsym)}, - {"dladdr", reinterpret_cast<void*>(&WrapDladdr)}, -#ifdef __arm__ - {"dl_unwind_find_exidx", - reinterpret_cast<void*>(&WrapDl_unwind_find_exidx)}, -#else - {"dl_iterate_phdr", reinterpret_cast<void*>(&WrapDl_iterate_phdr)}, -#endif - }; - static const size_t kCount = sizeof(kSymbols) / sizeof(kSymbols[0]); - for (size_t n = 0; n < kCount; ++n) { - if (!strcmp(kSymbols[n].name, name)) - return kSymbols[n].address; - } - return NULL; -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.h b/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.h deleted file mode 100644 index 72c0b10..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_wrappers.h +++ /dev/null
@@ -1,17 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_WRAPPERS_H -#define CRAZY_LINKER_WRAPPERS_H - -namespace crazy { - -// If |symbol_name| is the name of a linker-specific symbol name, like -// 'dlopen' or 'dlsym', return the address of the corresponding wrapper. -// Return NULL otherwise. -void* WrapLinkerSymbol(const char* symbol_name); - -} // namespace crazy - -#endif // CRAZY_LINKER_WRAPPERS_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_zip.cpp deleted file mode 100644 index b0dc217..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip.cpp +++ /dev/null
@@ -1,261 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_zip.h" - -#include <assert.h> -#include <fcntl.h> -#include <inttypes.h> -#include <string.h> -#include <sys/mman.h> -#include <unistd.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_system.h" -#include "crazy_linker_util.h" -#include "crazy_linker_zip_archive.h" - -namespace crazy { -namespace { - -// RAII pattern for unmapping and closing the mapped file. -class ScopedMMap { - public: - ScopedMMap(void* mem, uint32_t len) : mem_(mem), len_(len) {} - ~ScopedMMap() { - if (::munmap(mem_, len_) == -1) { - LOG_ERRNO("munmap failed when trying to unmap zip file"); - } - } - private: - void* mem_; - uint32_t len_; -}; - -// Convenience class to safely read values from a specific memory range of -// bytes. Typical usage: -// -// 1) Create instance, providing an address in memory and a size in bytes. -// -// 2) Call CheckRange() method to verify that an (offset,size) tuple -// describes a valid sub-range of the parent one. -// -// 3) Call AsRecordOf<TYPE>() to convert an offset into a pointer to -// a TYPE instance within the parent range, or nullptr if the offset -// is too large. -// -// 4) Use DataAt() to retrieve the address of data at a specific offset, -// or nullptr if it is too large. -// -class MemoryRangeReader { - public: - // Constructor, creates a new instance that covers all memory in - // |[memory, memory + size)|. - constexpr MemoryRangeReader(const void* memory, size_t size) - : base_(static_cast<const uint8_t*>(memory)), size_(size) {} - - // Returns true iff sub-range |[range_start, range_start + range_size)| - // is fully contained within the bounds of this reader. - constexpr bool CheckRange(size_t range_start, size_t range_size) const { - return (range_start <= size_ && range_size <= size_ - range_start); - } - - // Returns a pointer to the data at |[pos, pos + size)| if it is fully - // contained within the range, or nullptr otherwise. NOTE: This always - // return nullptr is |size| is 0. - constexpr const uint8_t* DataAt(size_t pos, size_t size) const { - return (size > 0 && CheckRange(pos, size)) ? base_ + pos : nullptr; - } - - // Return a pointer to a record of type RECORD_TYPE from offset |pos| - // in the current reader. This will return nullptr if |pos| is not valid - // position for the record or if the range is too small to hold a record of - // sizeof(RECORD_TYPE). - template <typename RECORD_TYPE> - constexpr const RECORD_TYPE* AsRecordOf(size_t pos) const { - const size_t record_size = sizeof(RECORD_TYPE); - return reinterpret_cast<const RECORD_TYPE*>(DataAt(pos, record_size)); - } - - private: - const uint8_t* const base_ = nullptr; - const size_t size_ = 0; -}; - -// Find the offset of |filename| within |zip_file|. -// |file_data| and |file_size| are the file's bytes and size. -// On success, return the offset. On failure return CRAZY_OFFSET_FAILED (-1) -int32_t FindFileOffsetInZipFile(const char* filename, - const char* zip_file, - const uint8_t* file_data, - size_t file_size) { - // First, find the end of central directory record from the end of the file. - if (file_size < sizeof(ZipEndOfCentralDirectory)) { - LOG("The size of %s (%zu) is too small for a zip file", zip_file, - file_size); - return CRAZY_OFFSET_FAILED; - } - - // NOTE: Safe due to check above. - size_t end_offset = file_size - sizeof(ZipEndOfCentralDirectory); - - MemoryRangeReader file_reader(file_data, file_size); - const ZipEndOfCentralDirectory* end_record; - for (;;) { - // Find end of central directory record from the end of the file. - end_record = file_reader.AsRecordOf<ZipEndOfCentralDirectory>(end_offset); - if (!end_record) { - // NOTE: Should not happen, since |end_offset| is smaller than - // |file_size - sizeof(ZipEndOfCentralDirectory)|. But better be safe - // than sorry. - return CRAZY_OFFSET_FAILED; - } - if (end_record->signature == end_record->kExpectedSignature) - break; - - if (end_offset == 0) { - LOG("Missing end of central directory in zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - end_offset--; - } - - const uint16_t num_entries = end_record->num_central_directory_entries; - const uint32_t central_dir_length = end_record->central_directory_length; - const uint32_t central_dir_start = end_record->central_directory_start; - - if (!file_reader.CheckRange(central_dir_start, central_dir_length)) { - LOG("Found malformed central directory offset/length in %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - MemoryRangeReader central_dir_reader(file_data + central_dir_start, - central_dir_length); - - // Parse all entries in the central directory until the entry for the - // relevant file is found. - const size_t expected_filename_len = strlen(filename); - size_t local_header_offset = 0; - size_t entry_offset = 0; - for (size_t n = 0;;) { - if (n >= num_entries) { - LOG("Could not find entry for file '%s' in %s", filename, zip_file); - return CRAZY_OFFSET_FAILED; - } - - const auto* entry = - central_dir_reader.AsRecordOf<ZipCentralDirHeader>(entry_offset); - if (!entry || entry->signature != entry->kExpectedSignature) { - LOG("Malformed central directory entry in %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - const uint16_t file_name_length = entry->file_name_length; - const uint8_t* filename_bytes = central_dir_reader.DataAt( - entry_offset + sizeof(*entry), file_name_length); - if (!filename_bytes) { - LOG("Malformed central directory file entry in zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - if (file_name_length == expected_filename_len && - !::memcmp(filename_bytes, filename, expected_filename_len)) { - // Found it! - local_header_offset = entry->relative_offset_of_local_header; - break; - } - - // NOTE: Cannot overflow since all quantities are 16-bit values. - const size_t entry_length = sizeof(*entry) + file_name_length + - entry->extra_field_length + - entry->file_comment_length; - // Continue to next file. - entry_offset += entry_length; - n++; - } - - // Now read the local header and compute the start offset. - const auto* local_header = - file_reader.AsRecordOf<ZipLocalFileHeader>(local_header_offset); - if (!local_header || - local_header->signature != local_header->kExpectedSignature) { - LOG("Invalid local file header offset %zu (max %zu) in zip file %s", - local_header_offset, file_size - sizeof(*local_header), zip_file); - return CRAZY_OFFSET_FAILED; - } - - const uint16_t compression_method = local_header->compression_method; - if (compression_method != local_header->kCompressionMethodStored) { - LOG("%s is compressed within %s (found compression method %u, expected %u)", - filename, zip_file, compression_method, - local_header->kCompressionMethodStored); - return CRAZY_OFFSET_FAILED; - } - - const uint16_t file_name_length = local_header->file_name_length; - const uint16_t extra_field_length = local_header->extra_field_length; - - // NOTE: Cannot overflow since all values are 16-bit. - const uint32_t header_length = - sizeof(*local_header) + file_name_length + extra_field_length; - - if (!file_reader.CheckRange(local_header_offset, header_length)) { - LOG("Invalid local file header entry in zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - // NOTE: Cannot overflow due to above check, since the file length - // fits in a signed 32-bit integer, so does the offset. - return static_cast<int32_t>(local_header_offset + header_length); -} - -} // unnamed namespace - -int32_t FindStartOffsetOfFileInZipFile(const char* zip_file, - const char* filename) { - // Open the file - FileDescriptor fd; - if (!fd.OpenReadOnly(zip_file)) { - LOG_ERRNO("open failed trying to open zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - // Find the length of the file. - int64_t file_size64 = fd.GetFileSize(); - if (file_size64 < 0) { - LOG_ERRNO("stat failed trying to stat zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - if (file_size64 > (int64_t(1) << 31)) { - LOG("Zip archive too large (%" PRId64 " bytes): %s", file_size64, zip_file); - return CRAZY_OFFSET_FAILED; - } - // NOTE: This cannot fail due to the check above. - size_t file_size = static_cast<size_t>(file_size64); - if (file_size == 0) { - LOG("Empty zip archive: %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - - // Map the file into memory. - void* mem = fd.Map(NULL, file_size, PROT_READ, MAP_PRIVATE, 0); - if (mem == MAP_FAILED || mem == NULL) { - LOG_ERRNO("mmap failed trying to mmap zip file %s", zip_file); - return CRAZY_OFFSET_FAILED; - } - ScopedMMap scoped_mmap(mem, file_size); - - return FindFileOffsetInZipFile(filename, zip_file, static_cast<uint8_t*>(mem), - file_size); -} - -} // crazy namespace - -// Define this macro when compiling this source file for fuzzing. -#if defined(CRAZY_LINKER_ENABLE_FUZZING) -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - crazy::FindFileOffsetInZipFile("dummy-file.txt", "dummy.zip", data, size); - return 0; -} -#endif // CRAZY_LINKER_ENABLE_FUZZING
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip.h b/third_party/android_crazy_linker/src/src/crazy_linker_zip.h deleted file mode 100644 index e6eecf9..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip.h +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ZIP_H -#define CRAZY_LINKER_ZIP_H - -#include "crazy_linker_util.h" // For CRAZY_OFFSET_FAILED - -// Definitions related to supporting loading libraries from zip files. -#include <cstdint> - -namespace crazy { - -// Find "filename" in the specified "zip_file" and return the offset -// in the file of the start of the data for the file. Return -// CRAZY_OFFSET_FAILED on error or if the file is compressed. This routine -// replaces code which used the minizip library, but is about 150 times faster, -// locating the offset in less than 0.5ms on a Nexus 4. -int32_t FindStartOffsetOfFileInZipFile(const char* zip_file, - const char* filename); -} - -#endif // CRAZY_LINKER_ZIP_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip_archive.h b/third_party/android_crazy_linker/src/src/crazy_linker_zip_archive.h deleted file mode 100644 index f237a9d3..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip_archive.h +++ /dev/null
@@ -1,207 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ZIP_ARCHIVE_H -#define CRAZY_LINKER_ZIP_ARCHIVE_H - -// Type definitions related to the ZIP archive format. Placed in their -// own header to make them available to unit-test sources. - -#include <stdint.h> - -namespace crazy { - -// Template function used to verify that |TYPE| has a size of |EXPECTED_SIZE| -// bytes and also has an alignment of 1. Do not call directly, use -// CHECK_UNALIGNED_RECORD_TYPE below to perform compile-time checks. -template <typename TYPE, size_t EXPECTED_SIZE> -constexpr bool CheckUnalignedRecordType() { - static_assert(sizeof(TYPE) == EXPECTED_SIZE, "invalid record definition"); - static_assert(alignof(TYPE) == 1, "invalid record alignment"); - return true; -} - -// Check at compile type that |type_name| has |expected_size| bytes and -// and alignment of 1. This is required for all zip record definitions below. -#define CHECK_UNALIGNED_RECORD_TYPE(type_name, expected_size) \ - static_assert(CheckUnalignedRecordType<type_name, expected_size>(), \ - "Incorrect " #type_name " definition") - -// Values in the ZIP records are not necessarily aligned, so define -// zip_uint16_t and zip_uint32_t to have the same size as uint16_t and -// uint32_t respectively, but use an alignment of 1. Conversions operators are -// provided to read the values directly from memory. -struct zip_uint16_t { - constexpr operator uint16_t() const { - return static_cast<uint16_t>(data_[0]) | - (static_cast<uint16_t>(data_[1]) << 8); - } - - inline zip_uint16_t& operator=(uint16_t value) { - data_[0] = static_cast<uint8_t>(value); - data_[1] = static_cast<uint8_t>(value >> 8); - return *this; - } - - uint8_t data_[2] = {}; -}; -CHECK_UNALIGNED_RECORD_TYPE(zip_uint16_t, 2); - -struct zip_uint32_t { - constexpr operator uint32_t() const { - return static_cast<uint32_t>(data_[0]) | - (static_cast<uint32_t>(data_[1]) << 8) | - (static_cast<uint32_t>(data_[2]) << 16) | - (static_cast<uint32_t>(data_[3]) << 24); - } - - inline zip_uint32_t& operator=(uint32_t value) { - data_[0] = static_cast<uint8_t>(value); - data_[1] = static_cast<uint8_t>(value >> 8); - data_[2] = static_cast<uint8_t>(value >> 16); - data_[3] = static_cast<uint8_t>(value >> 24); - return *this; - } - - uint8_t data_[4] = {}; -}; -CHECK_UNALIGNED_RECORD_TYPE(zip_uint32_t, 4); - -// For an overview of the ZIP archive format, see -// http://www.pkware.com/documents/casestudies/APPNOTE.TXT -// - -// 4.3.16 End of central directory record. -// -// end of central dir signature 4 bytes (0x06054b50) -// number of this disk 2 bytes -// number of the disk with the -// start of the central directory 2 bytes -// total number of entries in the -// central directory on this disk 2 bytes -// total number of entries in -// the central directory 2 bytes -// size of the central directory 4 bytes -// offset of start of central -// directory with respect to -// the starting disk number 4 bytes -// .ZIP file comment length 2 bytes -// .ZIP file comment (variable size) - -struct ZipEndOfCentralDirectory { - zip_uint32_t signature; - zip_uint16_t ignored_disk_number; - zip_uint16_t ignored_start_disk_number; - zip_uint16_t ignored_num_disk_central_directory_entries; - zip_uint16_t num_central_directory_entries; - zip_uint32_t central_directory_length; - zip_uint32_t central_directory_start; - zip_uint16_t ignored_comment_length; - - static constexpr uint32_t kExpectedSignature = 0x06054b50; -}; -CHECK_UNALIGNED_RECORD_TYPE(ZipEndOfCentralDirectory, - 4 + 2 + 2 + 2 + 2 + 4 + 4 + 2); - -// 4.3.12 Central directory structure: -// -// [central directory header 1] -// . -// . -// . -// [central directory header n] -// [digital signature] -// -// File header: -// -// central file header signature 4 bytes (0x02014b50) -// version made by 2 bytes -// version needed to extract 2 bytes -// general purpose bit flag 2 bytes -// compression method 2 bytes -// last mod file time 2 bytes -// last mod file date 2 bytes -// crc-32 4 bytes -// compressed size 4 bytes -// uncompressed size 4 bytes -// file name length 2 bytes -// extra field length 2 bytes -// file comment length 2 bytes -// disk number start 2 bytes -// internal file attributes 2 bytes -// external file attributes 4 bytes -// relative offset of local header 4 bytes -// -// file name (variable size) -// extra field (variable size) -// file comment (variable size) - -struct ZipCentralDirHeader { - zip_uint32_t signature; - zip_uint16_t ignored_version_made_by; - zip_uint16_t ignored_version_extract; - zip_uint16_t ignored_flags; - zip_uint16_t ignored_compression_method; - zip_uint16_t ignored_last_mod_file_time; - zip_uint16_t ignored_last_mod_file_date; - zip_uint32_t ignored_crc32; - zip_uint32_t ignored_compressed_size; - zip_uint32_t ignored_uncompressed_size; - zip_uint16_t file_name_length; - zip_uint16_t extra_field_length; - zip_uint16_t file_comment_length; - zip_uint16_t ignored_disk_number_start; - zip_uint16_t ignored_internal_file_attributes; - zip_uint32_t ignored_external_file_attributes; - zip_uint32_t relative_offset_of_local_header; - - static constexpr uint32_t kExpectedSignature = 0x2014b50U; -}; -CHECK_UNALIGNED_RECORD_TYPE(ZipCentralDirHeader, - 4 + 2 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2 + 2 + - 2 + 2 + 4 + 4); - -// 4.3.7 Local file header: -// -// local file header signature 4 bytes (0x04034b50) -// version needed to extract 2 bytes -// general purpose bit flag 2 bytes -// compression method 2 bytes -// last mod file time 2 bytes -// last mod file date 2 bytes -// crc-32 4 bytes -// compressed size 4 bytes -// uncompressed size 4 bytes -// file name length 2 bytes -// extra field length 2 bytes -// -// file name (variable size) -// extra field (variable size) - -struct ZipLocalFileHeader { - zip_uint32_t signature; - zip_uint16_t ignored_version_extract; - zip_uint16_t ignored_flags; - zip_uint16_t compression_method; - zip_uint16_t ignored_last_mod_file_time; - zip_uint16_t ignored_last_mod_file_date; - zip_uint32_t ignored_crc32; - zip_uint32_t ignored_compressed_size; - zip_uint32_t ignored_uncompressed_size; - zip_uint16_t file_name_length; - zip_uint16_t extra_field_length; - - static constexpr uint32_t kExpectedSignature = 0x04034b50; - - // Value for |compression_method| indicating the file is stored - // without compression. - static constexpr uint16_t kCompressionMethodStored = 0; -}; - -CHECK_UNALIGNED_RECORD_TYPE(ZipLocalFileHeader, - 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 2 + 2); - -} // namespace crazy - -#endif // CRAZY_LINKER_ZIP_ARCHIVE_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.cpp deleted file mode 100644 index 523d33d7e..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.cpp +++ /dev/null
@@ -1,107 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// AUTO-GENERATED BY generate_zip_test_tables.sh - DO NOT EDIT!! - -#include "crazy_linker_zip_test_data.h" - -namespace crazy { -namespace testing { - -// An empty zip archive -const unsigned char empty_archive_zip[] = { - 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const unsigned int empty_archive_zip_len = 22; - -// A zip archive with a single file named 'hello_world.txt' that -// contains the bytes for 'Hello World Hello World\n' without -// compression. -const unsigned char hello_zip[] = { - 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86, - 0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, - 0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, - 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09, - 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, - 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, - 0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, - 0x20, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, - 0x0a, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x68, - 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, - 0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75, - 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, - 0x01, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00}; -const unsigned int hello_zip_len = 204; - -// The same zip archive, but with the file stored compressed. -const unsigned char hello_compressed_zip[] = { - 0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0xd4, 0x86, - 0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00, - 0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, - 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09, - 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, - 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, - 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49, - 0x51, 0xf0, 0x40, 0xb0, 0xb9, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, - 0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xfd, 0x95, - 0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x81, - 0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f, - 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03, - 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, - 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x5a, - 0x00, 0x00, 0x00, 0x00, 0x00}; -const unsigned int hello_compressed_zip_len = 197; - -// A zip archive with two uncompressed files under lib/test-abi/ -// named 'libfoo.so' and 'crazy.libbar.so', with the following data: -// - first lib: 'This is the first test library!' -// - second lib: 'This is the second test library!' -const unsigned char lib_archive_zip[] = { - 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86, - 0xa3, 0x4c, 0x84, 0x92, 0x26, 0x8e, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00, - 0x00, 0x00, 0x16, 0x00, 0x1c, 0x00, 0x6c, 0x69, 0x62, 0x2f, 0x74, 0x65, - 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x6c, 0x69, 0x62, 0x66, 0x6f, - 0x6f, 0x2e, 0x73, 0x6f, 0x55, 0x54, 0x09, 0x00, 0x03, 0xb0, 0x22, 0xeb, - 0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, - 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x54, 0x68, 0x69, 0x73, - 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73, - 0x74, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, - 0x72, 0x79, 0x21, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xa0, 0xb1, 0x85, 0x09, 0x20, 0x00, 0x00, - 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x6c, 0x69, 0x62, - 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x63, 0x72, - 0x61, 0x7a, 0x79, 0x2e, 0x6c, 0x69, 0x62, 0x62, 0x61, 0x72, 0x2e, 0x73, - 0x6f, 0x55, 0x54, 0x09, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22, - 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, - 0x04, 0x53, 0x5f, 0x01, 0x00, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, - 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, - 0x21, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xd4, 0x86, 0xa3, 0x4c, 0x84, 0x92, 0x26, 0x8e, 0x1f, 0x00, 0x00, - 0x00, 0x1f, 0x00, 0x00, 0x00, 0x16, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x6c, - 0x69, 0x62, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, - 0x6c, 0x69, 0x62, 0x66, 0x6f, 0x6f, 0x2e, 0x73, 0x6f, 0x55, 0x54, 0x05, - 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, - 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50, 0x4b, 0x01, - 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86, 0xa3, - 0x4c, 0xa0, 0xb1, 0x85, 0x09, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x1c, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0xa4, 0x81, 0x6f, 0x00, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x2f, 0x74, - 0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x63, 0x72, 0x61, 0x7a, - 0x79, 0x2e, 0x6c, 0x69, 0x62, 0x62, 0x61, 0x72, 0x2e, 0x73, 0x6f, 0x55, - 0x54, 0x05, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, - 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50, - 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0xbe, - 0x00, 0x00, 0x00, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00}; -const unsigned int lib_archive_zip_len = 441; - -} // namespace testing -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.h b/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.h deleted file mode 100644 index 10134e1..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip_test_data.h +++ /dev/null
@@ -1,26 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CRAZY_LINKER_ZIP_TEST_DATA_H -#define CRAZY_LINKER_ZIP_TEST_DATA_H - -namespace crazy { -namespace testing { - -extern const unsigned char empty_archive_zip[]; -extern const unsigned int empty_archive_zip_len; - -extern const unsigned char hello_zip[]; -extern const unsigned int hello_zip_len; - -extern const unsigned char hello_compressed_zip[]; -extern const unsigned int hello_compressed_zip_len; - -extern const unsigned char lib_archive_zip[]; -extern const unsigned int lib_archive_zip_len; - -} // namespace testing -} // namespace crazy - -#endif // CRAZY_LINKER_ZIP_TEST_DATA_H
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_zip_unittest.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_zip_unittest.cpp deleted file mode 100644 index 920d510..0000000 --- a/third_party/android_crazy_linker/src/src/crazy_linker_zip_unittest.cpp +++ /dev/null
@@ -1,266 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "crazy_linker_zip.h" - -#include "crazy_linker_system_mock.h" - -#include "crazy_linker_util.h" // FOR CRAZY_OFFSET_FAILED? -#include "crazy_linker_zip_archive.h" -#include "crazy_linker_zip_test_data.h" - -#include <gtest/gtest.h> - -namespace crazy { - -using namespace crazy::testing; - -namespace { - -// Convenience function to add a file to the mock filesystem from the -// data tables above. -void AddZipArchiveBytes(crazy::SystemMock* sys, - const char* file_name, - const unsigned char* data, - unsigned int data_size) { - sys->AddRegularFile(file_name, reinterpret_cast<const char*>(data), - static_cast<size_t>(data_size)); -} - -// Find the EndOfCentralDirectory in a mutable byte array. -// Return nullptr if not found or if the array is too small. -ZipEndOfCentralDirectory* LocateEndOfCentralHeader(unsigned char* data, - size_t data_size) { - if (data_size < sizeof(ZipEndOfCentralDirectory)) - return nullptr; - - size_t offset = data_size - sizeof(ZipEndOfCentralDirectory); - for (;;) { - auto* ptr = reinterpret_cast<ZipEndOfCentralDirectory*>(data + offset); - if (ptr->signature == ptr->kExpectedSignature) { - return ptr; - } - if (offset == 0) - return nullptr; - - offset--; - } -} - -// Find the first central directory entry in a mutable byte array. -// On success, return pointer to the first entry, and sets |*directory_size| -// to the size of the directory in bytes. -ZipCentralDirHeader* LocateCentralDirectory(unsigned char* data, - size_t data_size, - size_t* directory_size) { - ZipEndOfCentralDirectory* end_record = - LocateEndOfCentralHeader(data, data_size); - - EXPECT_TRUE(end_record); - *directory_size = end_record->central_directory_length; - return reinterpret_cast<ZipCentralDirHeader*>( - data + end_record->central_directory_start); -} - -// Find the local file header of the first central directory entry. -ZipLocalFileHeader* LocateLocalFileHeader(unsigned char* data, - size_t data_size) { - size_t directory_size = 0; - ZipCentralDirHeader* entry = - LocateCentralDirectory(data, data_size, &directory_size); - EXPECT_TRUE(entry); - return reinterpret_cast<ZipLocalFileHeader*>( - data + entry->relative_offset_of_local_header); -} - -// Find the offset of the file 'hello_world.txt' in the zip archive -// stored at |data| with |data_size| bytes. Return CRAZY_OFFSET_FAILED if -// not found. -int32_t FindHelloWorldZipFileOffset(const unsigned char* data, - size_t data_size) { - SystemMock sys; - AddZipArchiveBytes(&sys, "hello.zip", data, data_size); - return FindStartOffsetOfFileInZipFile("hello.zip", "hello_world.txt"); -} - -} // namespace - -TEST(ZipParser, EmptyFile) { - SystemMock sys; - static const char kFilePath[] = "empty-file"; - sys.AddRegularFile(kFilePath, "", 0); - - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindStartOffsetOfFileInZipFile(kFilePath, "hello")); -} - -TEST(ZipParser, EmptyArchive) { - SystemMock sys; - static const char kFilePath[] = "empty.zip"; - AddZipArchiveBytes(&sys, kFilePath, empty_archive_zip, empty_archive_zip_len); - - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindStartOffsetOfFileInZipFile(kFilePath, "hello")); -} - -TEST(ZipParse, SimpleArchive) { - SystemMock sys; - static const char kFilePath[] = "hello.zip"; - AddZipArchiveBytes(&sys, kFilePath, hello_zip, hello_zip_len); - - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindStartOffsetOfFileInZipFile(kFilePath, "hello")); - - int off = FindStartOffsetOfFileInZipFile(kFilePath, "hello_world.txt"); - EXPECT_GT(off, 0); - EXPECT_LT(off, static_cast<int>(hello_zip_len)); - - static const char kExpected[] = "Hello World Hello World\n"; - const size_t kExpectedSize = sizeof(kExpected) - 1; - - ASSERT_LT(kExpectedSize, static_cast<size_t>(hello_zip_len)); - EXPECT_LT(off, static_cast<int>(hello_zip_len - kExpectedSize)); -} - -TEST(ZipParse, SimpleArchiveWithCompressedFile) { - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_compressed_zip, - hello_compressed_zip_len)); -} - -TEST(ZipParse, CorruptedEndOfCentralHeader) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the end-of-central-directory record, then corrupt its signature. - ZipEndOfCentralDirectory* end_record = - LocateEndOfCentralHeader(hello_data, hello_zip_len); - ASSERT_TRUE(end_record); - end_record->signature = 0xdeadbeef; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedCentralDirectoryOffset) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the end-of-central-directory record, then corrupt the - // central directory offset. - ZipEndOfCentralDirectory* end_record = - LocateEndOfCentralHeader(hello_data, hello_zip_len); - ASSERT_TRUE(end_record); - end_record->central_directory_start = hello_zip_len; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedCentralDirectoryLength) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the end-of-central-directory record, then corrupt the - // central directory length by making it far too large. - ZipEndOfCentralDirectory* end_record = - LocateEndOfCentralHeader(hello_data, hello_zip_len); - ASSERT_TRUE(end_record); - end_record->central_directory_length = hello_zip_len; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedCentralDirectoryLength2) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the end-of-central-directory record, then corrupt the - // central directory length, this time by making it too small. - ZipEndOfCentralDirectory* end_record = - LocateEndOfCentralHeader(hello_data, hello_zip_len); - ASSERT_TRUE(end_record); - end_record->central_directory_length = sizeof(ZipCentralDirHeader) - 2; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedCentralDirectoryEntry) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the central directory start, then corrupt the signature of the - // first entry!. - size_t directory_size = 0; - ZipCentralDirHeader* central_directory = - LocateCentralDirectory(hello_data, hello_zip_len, &directory_size); - ASSERT_TRUE(central_directory); - ASSERT_GT(directory_size, sizeof(ZipCentralDirHeader)); - central_directory->signature = 0xdeadbeef; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedLocalFileHeaderOffset) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the central directory start, then corrupt the signature of the - // first entry!. - size_t directory_size = 0; - ZipCentralDirHeader* central_directory = - LocateCentralDirectory(hello_data, hello_zip_len, &directory_size); - ASSERT_TRUE(central_directory); - ASSERT_GT(directory_size, sizeof(ZipCentralDirHeader)); - central_directory->relative_offset_of_local_header = hello_zip_len - 8; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedLocalFileHeaderSignature) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the local file header, then corrupt its signature. - ZipLocalFileHeader* header = LocateLocalFileHeader(hello_data, hello_zip_len); - header->signature = 0xdeadbeef; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -TEST(ZipParse, CorruptedLocalFileHeaderSize) { - // Copy hello.zip into buffer. - unsigned char hello_data[hello_zip_len]; - memcpy(hello_data, hello_zip, hello_zip_len); - - // Locate the local file header, then corrupt its size to overflow - // over the whole file. - ZipLocalFileHeader* header = LocateLocalFileHeader(hello_data, hello_zip_len); - header->extra_field_length = hello_zip_len; - - // Now ensure it doesn't parse correctly anymore. - EXPECT_EQ(CRAZY_OFFSET_FAILED, - FindHelloWorldZipFileOffset(hello_data, hello_zip_len)); -} - -} // namespace crazy
diff --git a/third_party/android_crazy_linker/src/src/elf_traits.h b/third_party/android_crazy_linker/src/src/elf_traits.h deleted file mode 100644 index ff04d18..0000000 --- a/third_party/android_crazy_linker/src/src/elf_traits.h +++ /dev/null
@@ -1,98 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef _ELF_TRAITS_H_ -#define _ELF_TRAITS_H_ - -// NOTE: <stdint.h> is required here before <elf.h>. This is a NDK header bug. -#include <stdint.h> -#include <elf.h> - -// ELF is a traits structure used to provide convenient aliases for -// 32/64 bit Elf types, depending on the target CPU bitness. -#if __SIZEOF_POINTER__ == 4 -struct ELF { - typedef Elf32_Ehdr Ehdr; - typedef Elf32_Phdr Phdr; - typedef Elf32_Word Word; - typedef Elf32_Sword Sword; - // TODO(simonb): Elf32_Sxword missing from the NDK. - typedef int64_t Sxword; - typedef Elf32_Addr Addr; - typedef Elf32_Dyn Dyn; - typedef Elf32_Sym Sym; - typedef Elf32_Rel Rel; - typedef Elf32_Rela Rela; - typedef Elf32_Word Relr; - typedef Elf32_auxv_t auxv_t; - - enum { kElfClass = ELFCLASS32 }; - enum { kElfBits = 32 }; - -# ifndef ELF_R_TYPE -# define ELF_R_TYPE ELF32_R_TYPE -# endif - -# ifndef ELF_R_SYM -# define ELF_R_SYM ELF32_R_SYM -# endif - -# ifndef ELF_R_INFO -# define ELF_R_INFO ELF32_R_INFO -# endif -}; -#elif __SIZEOF_POINTER__ == 8 -struct ELF { - typedef Elf64_Ehdr Ehdr; - typedef Elf64_Phdr Phdr; - typedef Elf64_Word Word; - typedef Elf64_Sword Sword; - typedef Elf64_Sxword Sxword; - typedef Elf64_Addr Addr; - typedef Elf64_Dyn Dyn; - typedef Elf64_Sym Sym; - typedef Elf64_Rel Rel; - typedef Elf64_Rela Rela; - typedef Elf64_Xword Relr; - typedef Elf64_auxv_t auxv_t; - - enum { kElfClass = ELFCLASS64 }; - enum { kElfBits = 64 }; - -# ifndef ELF_R_TYPE -# define ELF_R_TYPE ELF64_R_TYPE -# endif - -# ifndef ELF_R_SYM -# define ELF_R_SYM ELF64_R_SYM -# endif - -// TODO(simonb): ELF64_R_INFO missing from the NDK. -# ifndef ELF64_R_INFO -# define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) -# endif - -# ifndef ELF_R_INFO -# define ELF_R_INFO ELF64_R_INFO -# endif -}; -#else -#error "Unsupported target CPU bitness" -#endif - -#ifdef __arm__ -#define ELF_MACHINE EM_ARM -#elif defined(__i386__) -#define ELF_MACHINE EM_386 -#elif defined(__x86_64__) -#define ELF_MACHINE EM_X86_64 -#elif defined(__mips__) && !defined(__LP64__) // mips64el defines __mips__ too -#define ELF_MACHINE EM_MIPS -#elif defined(__aarch64__) -#define ELF_MACHINE EM_AARCH64 -#else -#error "Unsupported target CPU architecture" -#endif - -#endif // _ELF_TRAITS_H_
diff --git a/third_party/android_crazy_linker/src/src/linker_phdr.cpp b/third_party/android_crazy_linker/src/src/linker_phdr.cpp deleted file mode 100644 index d32a73e..0000000 --- a/third_party/android_crazy_linker/src/src/linker_phdr.cpp +++ /dev/null
@@ -1,407 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/* - * Copyright (C) 2012 The Android Open Source Project - * 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. - * - * 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 "linker_phdr.h" - -#include <errno.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <unistd.h> - -#define PAGE_START(x) ((x) & PAGE_MASK) -#define PAGE_OFFSET(x) ((x) & ~PAGE_MASK) -#define PAGE_END(x) PAGE_START((x) + (PAGE_SIZE - 1)) - -// Missing exec_elf.h definitions. -#ifndef PT_GNU_RELRO -#define PT_GNU_RELRO 0x6474e552 -#endif - -/** - TECHNICAL NOTE ON ELF LOADING. - - An ELF file's program header table contains one or more PT_LOAD - segments, which corresponds to portions of the file that need to - be mapped into the process' address space. - - Each loadable segment has the following important properties: - - p_offset -> segment file offset - p_filesz -> segment file size - p_memsz -> segment memory size (always >= p_filesz) - p_vaddr -> segment's virtual address - p_flags -> segment flags (e.g. readable, writable, executable) - - We will ignore the p_paddr and p_align fields of ELF::Phdr for now. - - The loadable segments can be seen as a list of [p_vaddr ... p_vaddr+p_memsz) - ranges of virtual addresses. A few rules apply: - - - the virtual address ranges should not overlap. - - - if a segment's p_filesz is smaller than its p_memsz, the extra bytes - between them should always be initialized to 0. - - - ranges do not necessarily start or end at page boundaries. Two distinct - segments can have their start and end on the same page. In this case, the - page inherits the mapping flags of the latter segment. - - Finally, the real load addrs of each segment is not p_vaddr. Instead the - loader decides where to load the first segment, then will load all others - relative to the first one to respect the initial range layout. - - For example, consider the following list: - - [ offset:0, filesz:0x4000, memsz:0x4000, vaddr:0x30000 ], - [ offset:0x4000, filesz:0x2000, memsz:0x8000, vaddr:0x40000 ], - - This corresponds to two segments that cover these virtual address ranges: - - 0x30000...0x34000 - 0x40000...0x48000 - - If the loader decides to load the first segment at address 0xa0000000 - then the segments' load address ranges will be: - - 0xa0030000...0xa0034000 - 0xa0040000...0xa0048000 - - In other words, all segments must be loaded at an address that has the same - constant offset from their p_vaddr value. This offset is computed as the - difference between the first segment's load address, and its p_vaddr value. - - However, in practice, segments do _not_ start at page boundaries. Since we - can only memory-map at page boundaries, this means that the bias is - computed as: - - load_bias = phdr0_load_address - PAGE_START(phdr0->p_vaddr) - - (NOTE: The value must be used as a 32-bit unsigned integer, to deal with - possible wrap around UINT32_MAX for possible large p_vaddr values). - - And that the phdr0_load_address must start at a page boundary, with - the segment's real content starting at: - - phdr0_load_address + PAGE_OFFSET(phdr0->p_vaddr) - - Note that ELF requires the following condition to make the mmap()-ing work: - - PAGE_OFFSET(phdr0->p_vaddr) == PAGE_OFFSET(phdr0->p_offset) - - The load_bias must be added to any p_vaddr value read from the ELF file to - determine the corresponding memory address. - - **/ - -#define MAYBE_MAP_FLAG(x, from, to) (((x) & (from)) ? (to) : 0) -#define PFLAGS_TO_PROT(x) \ - (MAYBE_MAP_FLAG((x), PF_X, PROT_EXEC) | \ - MAYBE_MAP_FLAG((x), PF_R, PROT_READ) | \ - MAYBE_MAP_FLAG((x), PF_W, PROT_WRITE)) - -/* Returns the size of the extent of all the possibly non-contiguous - * loadable segments in an ELF program header table. This corresponds - * to the page-aligned size in bytes that needs to be reserved in the - * process' address space. If there are no loadable segments, 0 is - * returned. - * - * If out_min_vaddr or out_max_vaddr are non-NULL, they will be - * set to the minimum and maximum addresses of pages to be reserved, - * or 0 if there is nothing to load. - */ -size_t phdr_table_get_load_size(const ELF::Phdr* phdr_table, - size_t phdr_count, - ELF::Addr* out_min_vaddr, - ELF::Addr* out_max_vaddr) { - ELF::Addr min_vaddr = ~static_cast<ELF::Addr>(0); - ELF::Addr max_vaddr = 0x00000000U; - - bool found_pt_load = false; - for (size_t i = 0; i < phdr_count; ++i) { - const ELF::Phdr* phdr = &phdr_table[i]; - - if (phdr->p_type != PT_LOAD) { - continue; - } - found_pt_load = true; - - if (phdr->p_vaddr < min_vaddr) { - min_vaddr = phdr->p_vaddr; - } - - if (phdr->p_vaddr + phdr->p_memsz > max_vaddr) { - max_vaddr = phdr->p_vaddr + phdr->p_memsz; - } - } - if (!found_pt_load) { - min_vaddr = 0x00000000U; - } - - min_vaddr = PAGE_START(min_vaddr); - max_vaddr = PAGE_END(max_vaddr); - - if (out_min_vaddr != NULL) { - *out_min_vaddr = min_vaddr; - } - if (out_max_vaddr != NULL) { - *out_max_vaddr = max_vaddr; - } - return max_vaddr - min_vaddr; -} - -/* Used internally. Used to set the protection bits of all loaded segments - * with optional extra flags (i.e. really PROT_WRITE). Used by - * phdr_table_protect_segments and phdr_table_unprotect_segments. - */ -static int _phdr_table_set_load_prot(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - int extra_prot_flags) { - const ELF::Phdr* phdr = phdr_table; - const ELF::Phdr* phdr_limit = phdr + phdr_count; - - for (; phdr < phdr_limit; phdr++) { - if (phdr->p_type != PT_LOAD || (phdr->p_flags & PF_W) != 0) - continue; - - ELF::Addr seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias; - ELF::Addr seg_page_end = - PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias; - - int ret = mprotect((void*)seg_page_start, - seg_page_end - seg_page_start, - PFLAGS_TO_PROT(phdr->p_flags) | extra_prot_flags); - if (ret < 0) { - return -1; - } - } - return 0; -} - -/* Restore the original protection modes for all loadable segments. - * You should only call this after phdr_table_unprotect_segments and - * applying all relocations. - * - * Input: - * phdr_table -> program header table - * phdr_count -> number of entries in tables - * load_bias -> load bias - * Return: - * 0 on error, -1 on failure (error code in errno). - */ -int phdr_table_protect_segments(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias) { - return _phdr_table_set_load_prot(phdr_table, phdr_count, load_bias, 0); -} - -/* Change the protection of all loaded segments in memory to writable. - * This is useful before performing relocations. Once completed, you - * will have to call phdr_table_protect_segments to restore the original - * protection flags on all segments. - * - * Note that some writable segments can also have their content turned - * to read-only by calling phdr_table_protect_gnu_relro. This is no - * performed here. - * - * Input: - * phdr_table -> program header table - * phdr_count -> number of entries in tables - * load_bias -> load bias - * Return: - * 0 on error, -1 on failure (error code in errno). - */ -int phdr_table_unprotect_segments(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias) { - return _phdr_table_set_load_prot( - phdr_table, phdr_count, load_bias, PROT_WRITE); -} - -/* Return the extend of the GNU RELRO segment in a program header. - * On success, return 0 and sets |*relro_start| and |*relro_end| - * to the page-aligned extents of the RELRO section. - * On failure, return -1. - * - * NOTE: This assumes there is a single PT_GNU_RELRO segment in the - * program header, i.e. it will return the extents of the first entry. - */ -int phdr_table_get_relro_info(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - ELF::Addr* relro_start, - ELF::Addr* relro_size) { - const ELF::Phdr* phdr; - const ELF::Phdr* phdr_limit = phdr_table + phdr_count; - - for (phdr = phdr_table; phdr < phdr_limit; ++phdr) { - if (phdr->p_type != PT_GNU_RELRO) - continue; - - /* Tricky: what happens when the relro segment does not start - * or end at page boundaries?. We're going to be over-protective - * here and put every page touched by the segment as read-only. - * - * This seems to match Ian Lance Taylor's description of the - * feature at http://www.airs.com/blog/archives/189. - * - * Extract: - * Note that the current dynamic linker code will only work - * correctly if the PT_GNU_RELRO segment starts on a page - * boundary. This is because the dynamic linker rounds the - * p_vaddr field down to the previous page boundary. If - * there is anything on the page which should not be read-only, - * the program is likely to fail at runtime. So in effect the - * linker must only emit a PT_GNU_RELRO segment if it ensures - * that it starts on a page boundary. - */ - *relro_start = PAGE_START(phdr->p_vaddr) + load_bias; - *relro_size = - PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias - *relro_start; - return 0; - } - - return -1; -} - -/* Apply GNU relro protection if specified by the program header. This will - * turn some of the pages of a writable PT_LOAD segment to read-only, as - * specified by one or more PT_GNU_RELRO segments. This must be always - * performed after relocations. - * - * The areas typically covered are .got and .data.rel.ro, these are - * read-only from the program's POV, but contain absolute addresses - * that need to be relocated before use. - * - * Input: - * phdr_table -> program header table - * phdr_count -> number of entries in tables - * load_bias -> load bias - * Return: - * 0 on error, -1 on failure (error code in errno). - */ -int phdr_table_protect_gnu_relro(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias) { - ELF::Addr relro_start, relro_size; - - if (phdr_table_get_relro_info( - phdr_table, phdr_count, load_bias, &relro_start, &relro_size) < 0) { - return -1; - } - - return mprotect((void*)relro_start, relro_size, PROT_READ); -} - -#ifdef __arm__ - -#ifndef PT_ARM_EXIDX -#define PT_ARM_EXIDX 0x70000001 /* .ARM.exidx segment */ -#endif - -/* Return the address and size of the .ARM.exidx section in memory, - * if present. - * - * Input: - * phdr_table -> program header table - * phdr_count -> number of entries in tables - * load_bias -> load bias - * Output: - * arm_exidx -> address of table in memory (NULL on failure). - * arm_exidx_count -> number of items in table (0 on failure). - * Return: - * 0 on error, -1 on failure (_no_ error code in errno) - */ -int phdr_table_get_arm_exidx(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - ELF::Addr** arm_exidx, - unsigned* arm_exidx_count) { - const ELF::Phdr* phdr = phdr_table; - const ELF::Phdr* phdr_limit = phdr + phdr_count; - - for (phdr = phdr_table; phdr < phdr_limit; phdr++) { - if (phdr->p_type != PT_ARM_EXIDX) - continue; - - *arm_exidx = (ELF::Addr*)(load_bias + phdr->p_vaddr); - *arm_exidx_count = (unsigned)(phdr->p_memsz / 8); - return 0; - } - *arm_exidx = NULL; - *arm_exidx_count = 0; - return -1; -} -#endif // __arm__ - -/* Return the address and size of the ELF file's .dynamic section in memory, - * or NULL if missing. - * - * Input: - * phdr_table -> program header table - * phdr_count -> number of entries in tables - * load_bias -> load bias - * Output: - * dynamic -> address of table in memory (NULL on failure). - * dynamic_count -> number of items in table (0 on failure). - * dynamic_flags -> protection flags for section (unset on failure) - * Return: - * void - */ -void phdr_table_get_dynamic_section(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - const ELF::Dyn** dynamic, - size_t* dynamic_count, - ELF::Word* dynamic_flags) { - const ELF::Phdr* phdr = phdr_table; - const ELF::Phdr* phdr_limit = phdr + phdr_count; - - for (phdr = phdr_table; phdr < phdr_limit; phdr++) { - if (phdr->p_type != PT_DYNAMIC) { - continue; - } - - *dynamic = reinterpret_cast<const ELF::Dyn*>(load_bias + phdr->p_vaddr); - if (dynamic_count) { - *dynamic_count = (unsigned)(phdr->p_memsz / sizeof(ELF::Dyn)); - } - if (dynamic_flags) { - *dynamic_flags = phdr->p_flags; - } - return; - } - *dynamic = NULL; - if (dynamic_count) { - *dynamic_count = 0; - } -}
diff --git a/third_party/android_crazy_linker/src/src/linker_phdr.h b/third_party/android_crazy_linker/src/src/linker_phdr.h deleted file mode 100644 index 7ad61872..0000000 --- a/third_party/android_crazy_linker/src/src/linker_phdr.h +++ /dev/null
@@ -1,82 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/* - * Copyright (C) 2012 The Android Open Source Project - * 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. - * - * 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 LINKER_PHDR_H -#define LINKER_PHDR_H - -/* Declarations related to the ELF program header table and segments. - * - * The design goal is to provide an API that is as close as possible - * to the ELF spec, and does not depend on linker-specific data - * structures (e.g. the exact layout of struct soinfo). - */ - -#include "elf_traits.h" - -size_t phdr_table_get_load_size(const ELF::Phdr* phdr_table, - size_t phdr_count, - ELF::Addr* min_vaddr = NULL, - ELF::Addr* max_vaddr = NULL); - -int phdr_table_protect_segments(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias); - -int phdr_table_unprotect_segments(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias); - -int phdr_table_get_relro_info(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - ELF::Addr* relro_start, - ELF::Addr* relro_size); - -int phdr_table_protect_gnu_relro(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias); - -#ifdef __arm__ -int phdr_table_get_arm_exidx(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - ELF::Addr** arm_exidx, - unsigned* arm_exidix_count); -#endif - -void phdr_table_get_dynamic_section(const ELF::Phdr* phdr_table, - int phdr_count, - ELF::Addr load_bias, - const ELF::Dyn** dynamic, - size_t* dynamic_count, - ELF::Word* dynamic_flags); - -#endif /* LINKER_PHDR_H */
diff --git a/third_party/android_crazy_linker/src/src/linker_reloc_iterators.h b/third_party/android_crazy_linker/src/src/linker_reloc_iterators.h deleted file mode 100644 index 08a67fc..0000000 --- a/third_party/android_crazy_linker/src/src/linker_reloc_iterators.h +++ /dev/null
@@ -1,173 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * 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. - * - * 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 __LINKER_RELOC_ITERATORS_H -#define __LINKER_RELOC_ITERATORS_H - -#include <string.h> - -#include <link.h> - -#include "crazy_linker_debug.h" -#include "crazy_linker_defines.h" - -const size_t RELOCATION_GROUPED_BY_INFO_FLAG = 1; -const size_t RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG = 2; -const size_t RELOCATION_GROUPED_BY_ADDEND_FLAG = 4; -const size_t RELOCATION_GROUP_HAS_ADDEND_FLAG = 8; - -class plain_reloc_iterator { -#if defined(USE_RELA) - typedef ElfW(Rela) rel_t; -#else - typedef ElfW(Rel) rel_t; -#endif - public: - plain_reloc_iterator(rel_t* rel_array, size_t count) - : begin_(rel_array), end_(begin_ + count), current_(begin_) {} - - bool has_next() { return current_ < end_; } - - rel_t* next() { return current_++; } - - private: - rel_t* const begin_; - rel_t* const end_; - rel_t* current_; -}; - -template <typename decoder_t> -class packed_reloc_iterator { -#if defined(USE_RELA) - typedef ElfW(Rela) rel_t; -#else - typedef ElfW(Rel) rel_t; -#endif - public: - explicit packed_reloc_iterator(decoder_t&& decoder) : decoder_(decoder) { - // initialize fields - memset(&reloc_, 0, sizeof(reloc_)); - relocation_count_ = decoder_.pop_front(); - reloc_.r_offset = decoder_.pop_front(); - relocation_index_ = 0; - relocation_group_index_ = 0; - group_size_ = 0; - } - - bool has_next() const { return relocation_index_ < relocation_count_; } - - rel_t* next() { - if (relocation_group_index_ == group_size_) { - if (!read_group_fields()) { - // Iterator is inconsistent state; it should not be called again - // but in case it is let's make sure has_next() returns false. - relocation_index_ = relocation_count_ = 0; - return nullptr; - } - } - - if (is_relocation_grouped_by_offset_delta()) { - reloc_.r_offset += group_r_offset_delta_; - } else { - reloc_.r_offset += decoder_.pop_front(); - } - - if (!is_relocation_grouped_by_info()) { - reloc_.r_info = decoder_.pop_front(); - } - -#if defined(USE_RELA) - if (is_relocation_group_has_addend() && - !is_relocation_grouped_by_addend()) { - reloc_.r_addend += decoder_.pop_front(); - } -#endif - - relocation_index_++; - relocation_group_index_++; - - return &reloc_; - } - - private: - bool read_group_fields() { - group_size_ = decoder_.pop_front(); - group_flags_ = decoder_.pop_front(); - - if (is_relocation_grouped_by_offset_delta()) { - group_r_offset_delta_ = decoder_.pop_front(); - } - - if (is_relocation_grouped_by_info()) { - reloc_.r_info = decoder_.pop_front(); - } - - if (is_relocation_group_has_addend() && is_relocation_grouped_by_addend()) { -#if !defined(USE_RELA) - // This platform does not support rela, and yet we have it encoded in - // android_rel section. - LOG("unexpected r_addend in android.rel section"); - return false; -#else - reloc_.r_addend += decoder_.pop_front(); - } else if (!is_relocation_group_has_addend()) { - reloc_.r_addend = 0; -#endif - } - - relocation_group_index_ = 0; - return true; - } - - bool is_relocation_grouped_by_info() { - return (group_flags_ & RELOCATION_GROUPED_BY_INFO_FLAG) != 0; - } - - bool is_relocation_grouped_by_offset_delta() { - return (group_flags_ & RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG) != 0; - } - - bool is_relocation_grouped_by_addend() { - return (group_flags_ & RELOCATION_GROUPED_BY_ADDEND_FLAG) != 0; - } - - bool is_relocation_group_has_addend() { - return (group_flags_ & RELOCATION_GROUP_HAS_ADDEND_FLAG) != 0; - } - - decoder_t decoder_; - size_t relocation_count_; - size_t group_size_; - size_t group_flags_; - size_t group_r_offset_delta_; - size_t relocation_index_; - size_t relocation_group_index_; - rel_t reloc_; -}; - -#endif // __LINKER_RELOC_ITERATORS_H
diff --git a/third_party/android_crazy_linker/src/src/linker_sleb128.h b/third_party/android_crazy_linker/src/src/linker_sleb128.h deleted file mode 100644 index cceaa1c..0000000 --- a/third_party/android_crazy_linker/src/src/linker_sleb128.h +++ /dev/null
@@ -1,76 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * 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. - * - * 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 _LINKER_SLEB128_H -#define _LINKER_SLEB128_H - -#include <assert.h> -#include <stdint.h> - -// Helper classes for decoding LEB128, used in packed relocation data. -// http://en.wikipedia.org/wiki/LEB128 - -class sleb128_decoder { - public: - sleb128_decoder(const uint8_t* buffer, size_t count) - : current_(buffer) -#ifndef NDEBUG - , - end_(buffer + count) -#endif - { - } - size_t pop_front() { - size_t value = 0; - static const size_t size = CHAR_BIT * sizeof(value); - - size_t shift = 0; - uint8_t byte; - - do { - assert(current_ < end_); - byte = *current_++; - value |= (static_cast<size_t>(byte & 127) << shift); - shift += 7; - } while (byte & 128); - - if (shift < size && (byte & 64)) { - value |= -(static_cast<size_t>(1) << shift); - } - - return value; - } - - private: - const uint8_t* current_; -#ifndef NDEBUG - const uint8_t* const end_; -#endif -}; - -#endif // __LINKER_SLEB128_H
diff --git a/third_party/android_crazy_linker/src/tests/Android.mk b/third_party/android_crazy_linker/src/tests/Android.mk deleted file mode 100644 index c333ac00c..0000000 --- a/third_party/android_crazy_linker/src/tests/Android.mk +++ /dev/null
@@ -1,126 +0,0 @@ -# Copyright 2014 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := libfoo -LOCAL_SRC_FILES := foo.cpp -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libfoo2 -LOCAL_SRC_FILES := foo2.cpp -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libfoo_with_static_constructor -LOCAL_SRC_FILES := foo_with_static_constructor.cpp -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libfoo_with_relro -LOCAL_SRC_FILES := foo_with_relro.cpp -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - - -include $(CLEAR_VARS) -LOCAL_MODULE := libbar -LOCAL_SRC_FILES := bar.cpp -LOCAL_SHARED_LIBRARIES := libfoo -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libbar_with_relro -LOCAL_SRC_FILES := bar_with_relro.cpp -LOCAL_SHARED_LIBRARIES := libfoo_with_relro -LOCAL_LDLIBS := -llog -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libzoo -LOCAL_SRC_FILES := zoo.cpp -LOCAL_LDLIBS := -ldl -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := libjni_lib -LOCAL_SRC_FILES := jni_lib.cpp -include $(BUILD_SHARED_LIBRARY) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_load_library -LOCAL_SRC_FILES := test_load_library.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_load_library_depends -LOCAL_SRC_FILES := test_load_library_depends.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_load_library_callbacks -LOCAL_SRC_FILES := test_load_library_callbacks.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_dl_wrappers -LOCAL_SRC_FILES := test_dl_wrappers.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_constructors_destructors -LOCAL_SRC_FILES := test_constructors_destructors.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_shared_relro -LOCAL_SRC_FILES := test_shared_relro.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_relocated_shared_relro -LOCAL_SRC_FILES := test_relocated_shared_relro.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_two_shared_relros -LOCAL_SRC_FILES := test_two_shared_relros.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_search_path_list -LOCAL_SRC_FILES := test_search_path_list.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - -include $(CLEAR_VARS) -LOCAL_MODULE := test_jni_hooks -LOCAL_SRC_FILES := test_jni_hooks.cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) - - -ifneq (,$(strip $(CRAZY_BENCH))) -include $(CLEAR_VARS) -LOCAL_MODULE := bench_load_library -LOCAL_SRC_FILES := $(LOCAL_MODULE).cpp -LOCAL_STATIC_LIBRARIES := crazy_linker -include $(BUILD_EXECUTABLE) -endif - -include $(LOCAL_PATH)/../Android.mk
diff --git a/third_party/android_crazy_linker/src/tests/bar.cpp b/third_party/android_crazy_linker/src/tests/bar.cpp deleted file mode 100644 index 83cc344..0000000 --- a/third_party/android_crazy_linker/src/tests/bar.cpp +++ /dev/null
@@ -1,19 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <stdio.h> - -extern "C" void Foo(); - -extern "C" void Bar() { - printf("%s: Entering\n", __FUNCTION__); - __android_log_print(ANDROID_LOG_INFO, "bar", "Hi There!"); - fprintf(stderr, "Hi There! from Bar\n"); - - printf("%s: Calling Foo()\n", __FUNCTION__); - Foo(); - - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/bar_with_relro.cpp b/third_party/android_crazy_linker/src/tests/bar_with_relro.cpp deleted file mode 100644 index aaf26f2..0000000 --- a/third_party/android_crazy_linker/src/tests/bar_with_relro.cpp +++ /dev/null
@@ -1,43 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -// A variant of bar.cpp that also includes a large RELRO section. -// Used to test RELRO sharing with two different libraries at the -// same time. - -// This is a large table that contains pointers to ensure that it -// gets put inside the RELRO section. -#define LINE "another example string", -#define LINE8 LINE LINE LINE LINE LINE LINE LINE LINE -#define LINE64 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 -#define LINE512 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 -#define LINE4096 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 - -const char* const kStrings[] = {LINE4096 LINE4096 LINE4096 LINE4096}; - -extern "C" void Foo(); - -extern "C" void Bar() { - printf("%s: Entering\n", __FUNCTION__); - __android_log_print(ANDROID_LOG_INFO, "bar", "Hi There!"); - fprintf(stderr, "Hi There! from Bar\n"); - - for (size_t n = 0; n < sizeof(kStrings) / sizeof(kStrings[0]); ++n) { - const char* ptr = kStrings[n]; - if (strcmp(ptr, "another example string")) { - printf("%s: Bad string at offset=%zu\n", __FUNCTION__, n); - exit(1); - } - } - - printf("%s: Calling Foo()\n", __FUNCTION__); - Foo(); - - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/bar_with_two_dlopens.cpp b/third_party/android_crazy_linker/src/tests/bar_with_two_dlopens.cpp deleted file mode 100644 index c37cd3e..0000000 --- a/third_party/android_crazy_linker/src/tests/bar_with_two_dlopens.cpp +++ /dev/null
@@ -1,189 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <dlfcn.h> -#include <stdio.h> -#include <stdlib.h> - -#include <initializer_list> - -// This defines a function Bar() which will perform the following: -// -// - Load a first library (libfoo) with dlopen, and find the 'Foo' -// function pointer in it. -// -// - Load a second library (libfoo2) with dlopen, and fint the 'Foo2' -// function pointer in it. -// -// - Check that the list of valid dlopen handles managed by the crazy -// linker contains the handles for the two libraries above. Note that -// this is done by calling crazy::GetValidDlopenHandleForTesting. -// Since this function is linked into the test executable that calls -// this function, but not the shared library that implements it, its -// address must be passed as the first parameter to Bar()! -// -// - Call the 'Foo' and 'Foo2' functions. -// -// - Close the second library handle. -// -// - Check that the list of valid dlopen handles only contains the -// handle for libfoo now. -// -// - Close the first library handle. -// -// - Check that the list of valid dlopen handles is empty now. -// -// - Return true on success, false otherwise. - -#define LIB1_NAME "libcrazy_linker_tests_libfoo.so" -#define LIB2_NAME "libcrazy_linker_tests_libfoo2.so" - -// The type of the crazy::GetValidDlopenHandleForTesting() function -using GetValidHandlesFunction = void**(size_t*); - -// The type of the 'Foo' and 'Foo2' functions in the two libraries -// loaded by Bar() below. -using FooFunc = void(void); - -// Convenience class for a library handle, calls dlclose() on destruction -// unless Close() was called before that. -class ScopedLibHandle { - public: - ScopedLibHandle(void* handle) : handle_(handle) {} - ~ScopedLibHandle() { - if (handle_) - dlclose(handle_); - } - void* Get() const { return handle_; } - void Close() { - if (handle_) { - dlclose(handle_); - handle_ = nullptr; - } - } - - private: - void* handle_; -}; - -// Convenience class for the list of handles returned by -// crazy::GetValidDlOpenHandleForTesting(). -class ScopedHandleList { - public: - ScopedHandleList(GetValidHandlesFunction* get_handles_func) { - handles_ = (*get_handles_func)(&count_); - } - ~ScopedHandleList() { free(handles_); } - - size_t count() const { return count_; } - void** begin() const { return handles_; } - void** end() const { return handles_ + count_; } - - private: - size_t count_; - void** handles_; -}; - -// Convenience macro for printing errors to stderr with a file:line prefix. -#define ERROR(...) \ - do { \ - fprintf(stderr, "TEST_ERROR:%s:%d: ", __FUNCTION__, __LINE__); \ - fprintf(stderr, __VA_ARGS__); \ - } while (0) - -// The Bar() function in all of its glory. -extern "C" bool Bar(GetValidHandlesFunction* get_valid_handles) { - printf("%s: Entering\n", __FUNCTION__); - __android_log_print(ANDROID_LOG_INFO, "bar", "Hi There!"); - fprintf(stderr, "Hi There! from Bar\n"); - - ScopedLibHandle lib1_handle(dlopen(LIB1_NAME, RTLD_NOW)); - if (!lib1_handle.Get()) { - ERROR("Could not find 1st library: %s\n", dlerror()); - return false; - } - - auto* func1 = - reinterpret_cast<void (*)(void)>(dlsym(lib1_handle.Get(), "Foo")); - if (!func1) { - ERROR("Could not find 'Foo' symbol in 1st library\n"); - return false; - } - - printf("OK: Found Foo() at %p in %s\n", func1, LIB1_NAME); - - ScopedLibHandle lib2_handle(dlopen(LIB2_NAME, RTLD_NOW)); - if (!lib2_handle.Get()) { - ERROR("Could not find 2nd library: %s\n", dlerror()); - return false; - } - - auto* func2 = - reinterpret_cast<void (*)(void)>(dlsym(lib2_handle.Get(), "Foo2")); - if (!func2) { - ERROR("Could not find 'Foo2' symbol in 2nd library\n"); - return false; - } - - printf("OK: Found Foo2() at %p in %s\n", func2, LIB2_NAME); - - { - ScopedHandleList handles(get_valid_handles); - if (handles.count() != 2) { - ERROR("Invalid dlopen handle count (%zd expected 2)\n", handles.count()); - return false; - } - bool failure = false; - int n = 1; - for (void* handle : handles) { - if (handle != lib1_handle.Get() && handle != lib2_handle.Get()) { - ERROR("Invalid handle value #%d (%p expected %p or %p)\n", n, handle, - lib1_handle.Get(), lib2_handle.Get()); - failure = true; - } - n++; - } - if (failure) - return false; - } - - printf("OK: Checked valid handle list, closing 2nd library\n"); - - lib2_handle.Close(); - - { - ScopedHandleList handles(get_valid_handles); - if (handles.count() != 1) { - ERROR("Invalid dlopen handle count (%zd expected 1)\n", handles.count()); - return false; - } - int n = 1; - for (void* handle : handles) { - if (handle != lib1_handle.Get()) { - ERROR("Invalid handle value #%d (%p expected %p)\n", n, handle, - lib1_handle.Get()); - return false; - } - n++; - } - } - - printf("OK: Checked valid handle list, closing 1st library\n"); - - lib1_handle.Close(); - - { - ScopedHandleList handles(get_valid_handles); - if (handles.count() != 0) { - ERROR("Invalid dlopen handle count (%zd expected 0)\n", handles.count()); - return false; - } - } - - printf("OK: Checked valid handle list is empty\n"); - - printf("%s: Exiting\n", __FUNCTION__); - return true; -}
diff --git a/third_party/android_crazy_linker/src/tests/bench_load_library.cpp b/third_party/android_crazy_linker/src/tests/bench_load_library.cpp deleted file mode 100644 index 144b478..0000000 --- a/third_party/android_crazy_linker/src/tests/bench_load_library.cpp +++ /dev/null
@@ -1,155 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libfoo.so) with the linker. -// - Find the address of the "Foo" function in it. -// - Call the function. -// - Close the library. - -#include <crazy_linker.h> - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <time.h> -#include <unistd.h> -#include <fcntl.h> - -static void Panic(const char* fmt, ...) { - va_list args; - fprintf(stderr, "PANIC: "); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - exit(1); -} - -static double now_ms() { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return (ts.tv_sec * 1000.) + (ts.tv_nsec / 1000000.); -} - -static void drop_caches() { - int fd = open("/proc/sys/vm/drop_caches", O_RDWR); - if (fd < 0) { - fprintf(stderr, - "Could not drop caches! Please run this program as root!\n"); - return; - } - write(fd, "3\n", 2); - close(fd); -} - -class ScopedTimer { - public: - ScopedTimer(const char* name) { - name_ = name; - start_ms_ = now_ms(); - } - - ~ScopedTimer() { - double elapsed_ms = now_ms() - start_ms_; - printf("Timer %s: %.1f\n", name_, elapsed_ms); - } - - private: - const char* name_; - double start_ms_; -}; - -int main(int argc, char** argv) { - const char* library_path = "libcrazy_linker_tests_libfoo.so"; - if (argc >= 2) - library_path = argv[1]; - - { ScopedTimer null_timer("empty"); } - - // Load the library with dlopen(). - void* lib; - drop_caches(); - { - ScopedTimer timer("dlopen"); - lib = dlopen(library_path, RTLD_NOW); - } - if (!lib) - Panic("Could not load library with dlopen(): %s\n", dlerror()); - - dlclose(lib); - - crazy_library_t* library; - crazy_context_t* context = crazy_context_create(); - - // Ensure the program looks in its own directory too. - crazy_add_search_path_for_address(reinterpret_cast<void*>(&main)); - - // Load the library with the crazy linker. - drop_caches(); - { - ScopedTimer timer("crazy_linker"); - // Load libfoo.so - if (!crazy_library_open(&library, library_path, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - } - crazy_library_close(library); - - // Load the library with the crazy linker. Preload libOpenSLES.so - drop_caches(); - void* sles_lib = dlopen("libOpenSLES.so", RTLD_NOW); - { - ScopedTimer timer("crazy_linker (preload libOpenSLES.so)"); - // Load libfoo.so - if (!crazy_library_open(&library, library_path, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - } - crazy_library_close(library); - dlclose(sles_lib); - - // Load the library with the crazy linker. Preload libOpenSLES.so - { - drop_caches(); - void* sys1_lib = dlopen("libandroid.so", RTLD_NOW); - void* sys2_lib = dlopen("libjnigraphics.so", RTLD_NOW); - void* sys3_lib = dlopen("libOpenSLES.so", RTLD_NOW); - { - ScopedTimer timer("crazy_linker (preload 3 system libs)"); - // Load libfoo.so - if (!crazy_library_open(&library, library_path, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - } - crazy_library_close(library); - dlclose(sys3_lib); - dlclose(sys2_lib); - dlclose(sys1_lib); - } - - // Load the library with the crazy linker. Create a shared RELRO as well. - drop_caches(); - { - ScopedTimer timer("crazy_linker (with RELRO)"); - // Load libfoo.so - if (!crazy_library_open(&library, library_path, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - size_t relro_start = 0; - size_t relro_size = 0; - int relro_fd = -1; - if (!crazy_library_create_shared_relro(library, context, - 0 /* load_address */, &relro_start, - &relro_size, &relro_fd)) { - Panic("Could not create shared RELRO: %s\n", - crazy_context_get_error(context)); - } - close(relro_fd); - } - crazy_library_close(library); - - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/foo.cpp b/third_party/android_crazy_linker/src/tests/foo.cpp deleted file mode 100644 index 9f34646..0000000 --- a/third_party/android_crazy_linker/src/tests/foo.cpp +++ /dev/null
@@ -1,13 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <stdio.h> - -extern "C" void Foo() { - printf("%s: Entering\n", __FUNCTION__); - __android_log_write(ANDROID_LOG_INFO, "foo", "Hello World!"); - fprintf(stderr, "Hello World from Foo!\n"); - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/foo2.cpp b/third_party/android_crazy_linker/src/tests/foo2.cpp deleted file mode 100644 index 71fd426..0000000 --- a/third_party/android_crazy_linker/src/tests/foo2.cpp +++ /dev/null
@@ -1,15 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <stdio.h> - -// Same as foo.cpp, byt exposes Foo2() instead of Foo(). - -extern "C" void Foo2() { - printf("%s: Entering\n", __FUNCTION__); - __android_log_write(ANDROID_LOG_INFO, "foo", "Hello World!"); - fprintf(stderr, "Hello World from Foo!\n"); - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/foo_with_relro.cpp b/third_party/android_crazy_linker/src/tests/foo_with_relro.cpp deleted file mode 100644 index 9b6e1d6..0000000 --- a/third_party/android_crazy_linker/src/tests/foo_with_relro.cpp +++ /dev/null
@@ -1,30 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <android/log.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -// This is a large table that contains pointers to ensure that it -// gets put inside the RELRO section. -#define LINE "some example string", -#define LINE8 LINE LINE LINE LINE LINE LINE LINE LINE -#define LINE64 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 LINE8 -#define LINE512 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 LINE64 -#define LINE4096 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 LINE512 - -const char* const kStrings[] = {LINE4096 LINE4096 LINE4096 LINE4096}; - -extern "C" void Foo() { - printf("%s: Entering\n", __FUNCTION__); - for (size_t n = 0; n < sizeof(kStrings) / sizeof(kStrings[0]); ++n) { - const char* ptr = kStrings[n]; - if (strcmp(ptr, "some example string")) { - printf("%s: Bad string at offset=%zu\n", __FUNCTION__, n); - exit(1); - } - } - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp b/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp deleted file mode 100644 index 4673c3f..0000000 --- a/third_party/android_crazy_linker/src/tests/foo_with_static_constructor.cpp +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This source file must contain a static destructor to check that -// the crazy linker can resolve weak symbols from the C library, -// like __aeabi_atexit(), which are not normally returned by -// a call to dlsym(). - -// Libc is not required to copy strings passed to putenv(). If it does -// not then env pointers become invalid when rodata is unmapped on -// library unload. To guard against this, putenv() strings are first -// strdup()'ed. This is a mild memory leak. - -#include <stdlib.h> -#include <string.h> - -#ifdef __arm__ -extern "C" void __aeabi_atexit(void*); -#endif - -class A { - public: - A() { - x_ = rand(); - const char* env = getenv("TEST_VAR"); - if (!env || strcmp(env, "INIT")) - putenv(strdup("TEST_VAR=LOAD_ERROR")); - else - putenv(strdup("TEST_VAR=LOADED")); - } - - ~A() { - const char* env = getenv("TEST_VAR"); - if (!env || strcmp(env, "LOADED")) - putenv(strdup("TEST_VAR=UNLOAD_ERROR")); - else - putenv(strdup("TEST_VAR=UNLOADED")); - } - - int Get() const { return x_; } - - private: - int x_; -}; - -A s_a; - -extern "C" int Foo() { - return s_a.Get(); -}
diff --git a/third_party/android_crazy_linker/src/tests/generate_test_elf_hash_tables.py b/third_party/android_crazy_linker/src/tests/generate_test_elf_hash_tables.py deleted file mode 100755 index 3027642..0000000 --- a/third_party/android_crazy_linker/src/tests/generate_test_elf_hash_tables.py +++ /dev/null
@@ -1,129 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Simple script used to generate the SysV ELF hash table test data""" - -import collections -import os - -from pylib import source_utils -from pylib import elf_utils - -script_name = os.path.basename(__file__) - - -def ElfHash(name): - """Compute the ELF hash of a given input string.""" - h = 0 - for c in name: - h = (h << 4) + ord(c) - g = h & 0xf0000000 - h ^= g - h ^= g >> 24 - return h & 0xffffffff - - -class ElfHashTable(object): - def __init__(self, num_buckets, symbol_names): - """Initialize a new SysV ELF hash table instance. - - Args: - num_buckets: Number of hash buckets, must be > 0. - symbol_names: List of symbol names. - """ - self.num_buckets_ = num_buckets - self.num_chain_ = len(symbol_names) + 1 - - self.symbols_ = symbol_names - self.hashes_ = [ElfHash(t) for t in symbol_names] - - # Build bucket and chain arrays. - buckets = [0] * num_buckets - chain = [0] * self.num_chain_ - - for n, symbol in enumerate(self.symbols_): - elf_hash = self.hashes_[n] - bucket_index = elf_hash % num_buckets - idx = buckets[bucket_index] - if idx == 0: - buckets[bucket_index] = n + 1 - else: - while chain[idx] != 0: - idx = chain[idx] - chain[idx] = n + 1 - - self.buckets_ = buckets - self.chain_ = chain - - # Generate final string table and symbol offsets. - self.string_table_, self.symbol_offsets_ = \ - elf_utils.GenerateStringTable(self.symbols_) - - def __str__(self): - """Dump human-friendly text description for this table.""" - out = 'SysV ELF hash table: num_buckets=%d num_chain=%d\n\n' % ( - self.num_buckets_, self.num_chain_) - - out += 'idx symbol hash bucket chain\n' - out += ' 0 <STN_UNDEF>\n' - for n, symbol in enumerate(self.symbols_): - elf_hash = self.hashes_[n] - bucket_index = elf_hash % self.num_buckets_ - out += '%3d %-20s %08x %-3d %d\n' % ( - n + 1, symbol, elf_hash, bucket_index, self.chain_[n + 1]) - - out += '\nBuckets: ' - comma = '' - for b in self.buckets_: - out += '%s%d' % (comma, b) - comma = ', ' - - out += '\n' - return out - - def AsCSource(self, variable_prefix, guard_macro_name): - """Dump the content of this instance.""" - out = source_utils.CSourceBeginAutoGeneratedHeader(script_name, - guard_macro_name) - out += source_utils.CSourceForComments(str(self)) - out += source_utils.CSourceForConstCharArray( - self.string_table_, 'k%sStringTable' % variable_prefix) - out += '\n' - out += elf_utils.CSourceForElfSymbolListMacro(variable_prefix, - self.symbols_, - self.symbol_offsets_) - out += '\n' - out += elf_utils.CSourceForElfSymbolTable(variable_prefix, - self.symbols_, - self.symbol_offsets_) - - out += '\nstatic const uint32_t k%sHashTable[] = {\n' % variable_prefix - out += ' %d, // num_buckets\n' % self.num_buckets_ - out += ' %d, // num_chain\n' % self.num_chain_ - out += ' // Buckets\n' - out += source_utils.CSourceForIntegerHexArray(self.buckets_, 32) - out += ' // Chain\n' - out += source_utils.CSourceForIntegerHexArray(self.chain_, 32) - out += '};\n' - out += source_utils.CSourceEndAutoGeneratedHeader(script_name, - guard_macro_name) - return out - -def main(): - # Same data as the one found on the following web page: - # - # https://flapenguin.me/2017/04/24/elf-lookup-dt-hash/ - # - # NOTE: The hash values on that page are incorrect, so results differs!! - # - table = ElfHashTable(4, [ - 'isnan', 'freelocal', 'hcreate_', 'getopt_long_onl', 'endrpcen', - 'pthread_mutex_lock', 'isinf', 'setrlimi', 'getspen', 'umoun', - 'strsigna', 'listxatt', 'gettyen', 'uselib', 'cfsetispeed']) - print table.AsCSource('TestElf', 'CRAZY_LINKER_ELF_HASH_TABLE_TEST_DATA_H') - -if __name__ == "__main__": - main()
diff --git a/third_party/android_crazy_linker/src/tests/generate_test_gnu_hash_tables.py b/third_party/android_crazy_linker/src/tests/generate_test_gnu_hash_tables.py deleted file mode 100755 index 1660f8f..0000000 --- a/third_party/android_crazy_linker/src/tests/generate_test_gnu_hash_tables.py +++ /dev/null
@@ -1,243 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Simple script used to generate the GNU hash table test data""" - -import collections -import os - -from pylib import source_utils -from pylib import elf_utils - -script_name = os.path.basename(__file__) - - -def GnuHash(name): - """Compute the GNU hash of a given input string.""" - h = 5381 - for c in name: - h = (h * 33 + ord(c)) & 0xffffffff - return h - - -class BloomFilter(object): - """A class used to model the bloom filter used in GNU hash tables. - - Usage is the following: - 1) Create new instance. - 2) Call Add() repeatedly to add new entries for each symbol hash value. - 3) Call AsCSourceUint32Array() to generate a C source fragment - corresponding to the content of an array of 32-bit words for the - filter. - 4) Also use __str__() to print a human-friendly representation of the - filter to check everything if needed. - """ - def __init__(self, bloom_size, bloom_shift, bloom_bits): - """Create instance. - - Args: - bloom_size: number of words in the bloom filter. - bloom_shift: bloom bit shift to use for secondary bit. - bloom_bits: number of bits in each filter word (32 or 64). - """ - self.bloom_size_ = bloom_size - self.bloom_shift_ = bloom_shift - self.bloom_bits_ = bloom_bits - self.bloom_filter_ = [0] * bloom_size - - def GetBits(self, gnu_hash): - """Return (index, bit0, bit1) tuple corresponding to a given hash.""" - bloom_index = (gnu_hash / self.bloom_bits_) % self.bloom_size_ - bloom_bit0 = (gnu_hash % self.bloom_bits_) - bloom_bit1 = ((gnu_hash >> self.bloom_shift_) % self.bloom_bits_) - return bloom_index, bloom_bit0, bloom_bit1 - - def Add(self, gnu_hash): - """Add a new entry to the filter.""" - word, bit0, bit1 = self.GetBits(gnu_hash) - self.bloom_filter_[word] |= (1 << bit0) | (1 << bit1) - - def AsCSourceUint32Array(self): - """Generate C source fragment for 32-bit uint array data.""" - if self.bloom_bits_ == 64: - # Convert to array of 32-bit values first. Assume little-endianess. - values = [] - for bloom in self.bloom_filter_: - values += [bloom & 0xffffffff, (bloom >> 32) % 0xffffffff] - else: - values = self.bloom_filter_ - return source_utils.CSourceForIntegerHexArray(values, 32) - - def __str__(self): - """Convert bloom filter instance to human-friendly representation.""" - out = 'Bloom filter (%d bits):\n' % self.bloom_bits_ - out += 'bit#' - if self.bloom_bits_ == 64: - out += ' 56 48 40 32' - out += ' 24 16 8 0' - for bloom in self.bloom_filter_: - for n in range(self.bloom_bits_): - if (n % 8) == 0: - if n > 0: - out += ' ' - else: - out += '\n ' - - if ((bloom & (1 << (self.bloom_bits_ - n - 1))) != 0): - out += 'x' - else: - out += '.' - out += '\n\n also as: ' - for bloom in self.bloom_filter_: - if self.bloom_bits_ == 64: - out += ' 0x%016x' % bloom - else: - out += ' 0x%08x' % bloom - out += '\n' - return out - - -class GnuHashTable(object): - def __init__(self, sym_offset, num_buckets, bloom_size, bloom_shift, - bloom_bits, symbol_names): - """Initialize a new GNU hash table instance. - - Args: - sym_offset: Dynamic symbols offset, must be > 0. - num_buckets: Number of hash buckets, must be > 0. - bloom_size: Bloom filter size in words of |bloom_bits| bits. - bloom_shift: Bloom filter shift. - bloom_bits: Either 32 or 64, size of bloom filter words. - symbol_names: List of symbol names. - """ - self.num_buckets_ = num_buckets - self.sym_offset_ = sym_offset - self.bloom_size_ = bloom_size - self.bloom_shift_ = bloom_shift - - # Create a list of (symbol, hash) values, sorted by increasing bucket index - sorted_symbols = sorted([(x, GnuHash(x)) for x in symbol_names], - key=lambda t: t[1] % num_buckets) - - self.symbols_ = [t[0] for t in sorted_symbols] - self.hashes_ = [t[1] for t in sorted_symbols] - - # Build bucket and chain arrays. - buckets = [0] * num_buckets - chain = [0] * len(sorted_symbols) - - last_bucket_index = -1 - for n, symbol in enumerate(sorted_symbols): - gnu_hash = self.hashes_[n] - bucket_index = gnu_hash % num_buckets - if bucket_index != last_bucket_index: - buckets[bucket_index] = n + sym_offset - last_bucket_index = bucket_index - if n > 0: chain[n - 1] |= 1 - chain[n] = gnu_hash & ~1 - - if chain: chain[-1] |= 1 - - self.buckets_ = buckets - self.chain_ = chain - - # Generate bloom filters for both 32 and 64 bits. - self.bloom_filter32_ = self._GenerateBloomFilter(32) - self.bloom_filter64_ = self._GenerateBloomFilter(64) - - # Generate final string table and symbol offsets. - self.string_table_, self.symbol_offsets_ = \ - elf_utils.GenerateStringTable(self.symbols_) - - def _GenerateBloomFilter(self, bloom_bits): - """Generate bloom filter array for a specific bitness.""" - bloom = BloomFilter(self.bloom_size_, self.bloom_shift_, bloom_bits) - for gnu_hash in self.hashes_: - bloom.Add(gnu_hash) - return bloom - - def __str__(self): - """Human friendly text description for this table.""" - out = 'GNU hash table: num_buckets=%d bloom_size=%d bloom_shift=%d\n\n' % ( - self.num_buckets_, self.bloom_size_, self.bloom_shift_) - - out += 'idx symbol hash bucket bloom32 bloom64 chain\n\n' - out += ' 0 ST_UNDEF\n' - for n, symbol in enumerate(self.symbols_): - gnu_hash = self.hashes_[n] - bucket_index = gnu_hash % self.num_buckets_ - bloom32_index, bloom32_bit0, bloom32_bit1 = self.bloom_filter32_.GetBits(gnu_hash) - bloom64_index, bloom64_bit0, bloom64_bit1 = self.bloom_filter64_.GetBits(gnu_hash) - out += '%3d %-20s %08x %-3d %d:%02d:%02d %d:%02d:%02d %08x\n' % ( - n + 1, symbol, gnu_hash, bucket_index, bloom32_index, bloom32_bit0, - bloom32_bit1, bloom64_index, bloom64_bit0, bloom64_bit1, - self.chain_[n]) - - out += '\nBuckets: ' - comma = '' - for b in self.buckets_: - out += '%s%d' % (comma, b) - comma = ', ' - - out += '\n\n%s\n%s' % (self.bloom_filter32_, self.bloom_filter64_) - return out - - def AsCSource(self, variable_prefix, guard_macro_name): - """Dump the content of this instance.""" - out = source_utils.CSourceBeginAutoGeneratedHeader(script_name, - guard_macro_name) - - out += source_utils.CSourceForComments(str(self)) - - out += source_utils.CSourceForConstCharArray( - self.string_table_, 'k%sStringTable' % variable_prefix) - - out += '\n' - out += elf_utils.CSourceForElfSymbolListMacro(variable_prefix, - self.symbols_, - self.symbol_offsets_) - out += '\n' - out += elf_utils.CSourceForElfSymbolTable(variable_prefix, - self.symbols_, - self.symbol_offsets_) - - out += '\nstatic const uint32_t k%sHashTable[] = {\n' % variable_prefix - out += ' %d, // num_buckets\n' % self.num_buckets_ - out += ' %d, // sym_offset\n' % self.sym_offset_ - out += ' %d, // bloom_size\n' % self.bloom_size_ - out += ' %d, // bloom_shift\n' % self.bloom_shift_ - out += ' // Bloom filter words\n' - out += '#if UINTPTR_MAX == UINT32_MAX // 32-bit bloom filter words\n' - out += self.bloom_filter32_.AsCSourceUint32Array() - out += '#else // 64-bits filter bloom words (assumes little-endianess)\n' - out += self.bloom_filter64_.AsCSourceUint32Array() - out += '#endif // bloom filter words\n' - out += ' // Buckets\n' - out += source_utils.CSourceForIntegerHexArray(self.buckets_, 32) - out += ' // Chain\n' - out += source_utils.CSourceForIntegerHexArray(self.chain_, 32) - out += '};\n' - out += source_utils.CSourceEndAutoGeneratedHeader(script_name, - guard_macro_name) - return out - -def main(): - # Same data as the one found on the following web page, to ease verification: - # - # https://flapenguin.me/2017/05/10/elf-lookup-dt-gnu-hash/ - # - # NOTE: The bloom filter values and bitmaps on that page are widely incorrect - # but the bloom word and bit indices are ok though! - # - table = GnuHashTable(1, 4, 2, 5, 64, [ - 'cfsetispeed', 'strsigna', 'hcreate_', 'endrpcen', 'uselib', - 'gettyen', 'umoun', 'freelocal', 'listxatt', 'isnan', 'isinf', - 'setrlimi', 'getspen', 'pthread_mutex_lock', 'getopt_long_onl', - ]) - print table.AsCSource('TestGnu', 'CRAZY_LINKER_GNU_HASH_TABLE_TEST_DATA_H') - -if __name__ == "__main__": - main()
diff --git a/third_party/android_crazy_linker/src/tests/generate_zip_test_tables.sh b/third_party/android_crazy_linker/src/tests/generate_zip_test_tables.sh deleted file mode 100755 index bd02fb4..0000000 --- a/third_party/android_crazy_linker/src/tests/generate_zip_test_tables.sh +++ /dev/null
@@ -1,93 +0,0 @@ -#!/bin/sh - -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Simple script used to regenerate zip files used for unit-testing the -# crazy linker zip parser. This outputs a fragment of C code through 'xdd' -# on Linux that can be copied into crazy_linker_zip_test_data.cpp directly. - -set -e - -PROGNAME=$(basename "$0") - -die () { - echo "ERROR: $@" - exit 1 -} - -TMP_DIR=/tmp/zip-files-tmp-$$ -OUTPUT_DIR=/tmp/zip-files - -generate_c_source () { - # Turn generated table const, it's cleaner. - # Also indent with 4 spaces (Chromium style). - xxd -i $1 | \ - sed -e 's/^unsigned/const unsigned/g' | \ - sed -e 's/^ 0x/ 0x/g' -} - -# Preparing temporary directory. -mkdir -p $TMP_DIR -rm -rf $TMP_DIR/* -cd $TMP_DIR - -cat <<EOF -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// AUTO-GENERATED BY $PROGNAME - DO NOT EDIT!! - -#include "crazy_linker_zip_test_data.h" - -namespace crazy { -namespace testing { - -EOF - -printf "// An empty zip archive\n" -touch empty_file -zip -q empty_archive empty_file -zip -q -d empty_archive empty_file 2>/dev/null -generate_c_source empty_archive.zip -printf "\n" - -printf "// A zip archive with a single file named 'hello_world.txt' that\n" -printf "// contains the bytes for 'Hello World Hello World\\\n' without\n" -printf "// compression.\n" -echo "Hello World Hello World" > hello_world.txt -zip -q -0 hello.zip hello_world.txt -generate_c_source hello.zip -printf "\n" - -printf "// The same zip archive, but with the file stored compressed.\n" -zip -q -9 hello_compressed.zip hello_world.txt -generate_c_source hello_compressed.zip -printf "\n" - -LIB_SUBDIR=lib/test-abi -LIB1_NAME=libfoo.so -LIB2_NAME=crazy.libbar.so -LIB1_TEXT="This is the first test library!" -LIB2_TEXT="This is the second test library!" -cat <<EOF -// A zip archive with two uncompressed files under $LIB_SUBDIR/ -// named '$LIB1_NAME' and '$LIB2_NAME', with the following data: -// - first lib: '$LIB1_TEXT' -// - second lib: '$LIB2_TEXT' -EOF -mkdir -p $LIB_SUBDIR -printf "This is the first test library!" > $LIB_SUBDIR/$LIB1_NAME -printf "This is the second test library!" > $LIB_SUBDIR/$LIB2_NAME -zip -q -0 lib_archive.zip $LIB_SUBDIR/$LIB1_NAME $LIB_SUBDIR/$LIB2_NAME -generate_c_source lib_archive.zip - -cat <<EOF - -} // namespace testing -} // namespace crazy -EOF - -rm -rf $TMP_DIR
diff --git a/third_party/android_crazy_linker/src/tests/jni_lib.cpp b/third_party/android_crazy_linker/src/tests/jni_lib.cpp deleted file mode 100644 index bcbdbe49..0000000 --- a/third_party/android_crazy_linker/src/tests/jni_lib.cpp +++ /dev/null
@@ -1,44 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A simple library that provides JNI_OnLoad() and JNI_OnUnload() hooks. -// Used by test_java_vm.cpp - -#include <jni.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#define VARNAME "TEST_VAR" - -extern "C" int JNI_OnLoad(JavaVM* vm, void* reserved) { - printf("%s: Entering\n", __FUNCTION__); - const char* env = getenv(VARNAME); - if (!env || strcmp(env, "INIT")) { - fprintf(stderr, - "%s: Env variable %s has invalid value: %s (expected INIT)\n", - __FUNCTION__, - VARNAME, - env); - exit(1); - } - setenv(VARNAME, "LOADED", 1); - printf("%s: Exiting\n", __FUNCTION__); - return JNI_VERSION_1_4; -} - -extern "C" void JNI_OnUnload(JavaVM* vm, void* reserved) { - printf("%s: Entering\n", __FUNCTION__); - const char* env = getenv(VARNAME); - if (!env || strcmp(env, "LOADED")) { - fprintf(stderr, - "%s: Env variable %s has invalid value: %s (expected LOADED)\n", - __FUNCTION__, - VARNAME, - env); - exit(1); - } - setenv(VARNAME, "UNLOADED", 1); - printf("%s: Exiting\n", __FUNCTION__); -}
diff --git a/third_party/android_crazy_linker/src/tests/pylib/__init__.py b/third_party/android_crazy_linker/src/tests/pylib/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/third_party/android_crazy_linker/src/tests/pylib/__init__.py +++ /dev/null
diff --git a/third_party/android_crazy_linker/src/tests/pylib/elf_utils.py b/third_party/android_crazy_linker/src/tests/pylib/elf_utils.py deleted file mode 100644 index edc097cc..0000000 --- a/third_party/android_crazy_linker/src/tests/pylib/elf_utils.py +++ /dev/null
@@ -1,91 +0,0 @@ -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Common ELF related routines.""" - -def GenerateStringTable(symbol_names): - """Generate the string table that corresponds to a list of symbol names. - - Args: - symbol_names: List of input symbol names. - Returns: - A (string_table, symbol_offsets) tuple, where |string_table| is the - actual string table (terminated by two '\0' chars), and |symbol_offsets| - is a list of starting offsets for each symbol inside the table. - """ - symbol_offsets = [] - string_table = "\0" - next_offset = 1 - for symbol in symbol_names: - symbol_offsets.append(next_offset) - string_table += symbol - string_table += "\0" - next_offset += len(symbol) + 1 - - string_table += "\0" - return string_table, symbol_offsets - - -def CSourceForElfSymbolTable(variable_prefix, names, str_offsets): - """Generate C source definition for an ELF symbol table. - - Args: - variable_prefix: variable name prefix - names: List of symbol names. - str_offsets: List of symbol name offsets in string table. - Returns: - String containing C source fragment. - """ - out = ( -r'''// NOTE: ELF32_Sym and ELF64_Sym have very different layout. -#if UINTPTR_MAX == UINT32_MAX // ELF32_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), (address), (size), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */ }, -#else // ELF64_Sym -# define DEFINE_ELF_SYMBOL(name, name_offset, address, size) \ - { (name_offset), ELF_ST_INFO(STB_GLOBAL, STT_FUNC), \ - 0 /* other */, 1 /* shndx */, (address), (size) }, -#endif // !ELF64_Sym -''') - - out += 'static const ELF::Sym k%sSymbolTable[] = {\n' % variable_prefix - out += ' { 0 }, // ST_UNDEF\n' - out += ' LIST_ELF_SYMBOLS_%s(DEFINE_ELF_SYMBOL)\n' % variable_prefix - out += '};\n' - out += '#undef DEFINE_ELF_SYMBOL\n' - return out - - -def CSourceForElfSymbolListMacro(variable_prefix, names, name_offsets, - base_address=0x10000, symbol_size=16, - spacing_size=16): - """Generate C source definition for a macro listing ELF symbols. - - Args: - macro_suffix: Macro name suffix. - names: List of symbol names. - name_offsets: List of symbol offsets. - base_address: Base starting address for symbols, - symbol_size: Symbol size in bytes (all have the same size). - spacing_size: Additionnal bytes between symbols. - Returns: - String containing C source fragment. - """ - out = ( -r'''// Auto-generated macro used to list all symbols -// XX must be a macro that takes the following parameters: -// name: symbol name (quoted). -// str_offset: symbol name offset in string table -// address: virtual address. -// size: size in bytes -''') - out += '#define LIST_ELF_SYMBOLS_%s(XX) \\\n' % variable_prefix - address = base_address - for sym, offset in zip(names, name_offsets): - out += ' XX("%s", %d, 0x%x, %d) \\\n' % ( - sym, offset, address, symbol_size) - address += symbol_size + spacing_size - out += ' // END OF LIST\n' - return out
diff --git a/third_party/android_crazy_linker/src/tests/pylib/source_utils.py b/third_party/android_crazy_linker/src/tests/pylib/source_utils.py deleted file mode 100644 index 8864d35..0000000 --- a/third_party/android_crazy_linker/src/tests/pylib/source_utils.py +++ /dev/null
@@ -1,137 +0,0 @@ -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Common utility functions to generate C++ source fragments.""" - -_AUTO_GENERATED_HEADER_BEGIN_TEMPLATE = ( -r'''// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef {guard_macro_name} -#define {guard_macro_name} - -// clang-format off -// BEGIN_AUTO_GENERATED [{script_name}] DO NOT EDIT!! -// - -namespace crazy {{ -namespace testing {{ - -''') - -_AUTO_GENERATED_HEADER_END_TEMPLATE = ( -r''' -}} // namespace testing -}} // namespace crazy - -// END_AUTO_GENERATED_CODE [{script_name}] -// clang-format on - -#endif // {guard_macro_name}''' -) - -def CSourceForArrayData(values, formatter, margin=4, width=80): - """Turn an array of values into a C source array data definition. - - Args: - values: Array of input values. - formatter: Formatting function, applied to each input value to get a - C-source description of the value. - margin: Left-side margin / indentation level. - width: Maximum line width. - Returns: - A string containing the data definition as a C source fragment. - """ - read_pos = 0 - read_len = len(values) - write_pos = margin - line_start = ' ' * margin - # Account for the margin + one final comma. - max_width = width - margin - 1 - out = '' - while read_pos < read_len: - out += line_start - write_pos = 0 - comma = '' - while read_pos < read_len: - item = comma + formatter(values[read_pos]) - if write_pos + len(item) > max_width: - break # Too long, break line before this item. - out += item - read_pos += 1 - write_pos += len(item) - comma = ',' - if read_pos == read_len: - break - out += ',\n' - return out - - -def CSourceForIntegerHexArray(values, num_bits, margin=4, width=80): - """Turn an array of integers into a C source array data definition. - - Args: - values: An array of integers. - num_bits: The number of bits of said integers (i.e. 8, 16, 32 or 64). - margin: Left-side margin / indentation level (must be > 0). - width: Maximum line width. - Returns: - A string containing the data definition as a C source fragment. - """ - chars_per_word = num_bits / 4 - format_str = ' 0x%%0%dx' % chars_per_word - out = CSourceForArrayData(values, lambda x: format_str % x, - margin - 1, width) - out += ',\n' - return out - - -def _FormatChar(ch): - """Convert a character into its C source description.""" - code = ord(ch) - if code < 32 or code > 127: - return "'\\%d'" % code - else: - return "'%s'" % ch - - -def CSourceForConstCharArray(chars, variable_name, margin=4, width=80): - """Return C source fragment for static const char C array. - - Args: - chars: An array or string containing all the characters for array. - variable_name: Name of the array variable. - Returns: - A new string holding a C source fragment for the array definition. - """ - out = 'static const char %s[%d] = {\n' % (variable_name, len(chars)) - out += CSourceForArrayData(chars, _FormatChar, margin, width) - out += '};\n' - return out - - -def CSourceForComments(lines): - """Wrap the content of |lines| instead into C++ comments.""" - out = '' - for line in lines.split('\n'): - line = line.rstrip() - if line: - out += '// %s\n' % line - else: - out += '//\n' - - return out - - -def CSourceBeginAutoGeneratedHeader(script_name, guard_macro_name): - return _AUTO_GENERATED_HEADER_BEGIN_TEMPLATE.format( - script_name=script_name, - guard_macro_name=guard_macro_name) - - -def CSourceEndAutoGeneratedHeader(script_name, guard_macro_name): - return _AUTO_GENERATED_HEADER_END_TEMPLATE.format( - script_name=script_name, - guard_macro_name=guard_macro_name)
diff --git a/third_party/android_crazy_linker/src/tests/test_constructors_destructors.cpp b/third_party/android_crazy_linker/src/tests/test_constructors_destructors.cpp deleted file mode 100644 index e58767a..0000000 --- a/third_party/android_crazy_linker/src/tests/test_constructors_destructors.cpp +++ /dev/null
@@ -1,69 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libcrazy_linker_tests_libfoo_with_static_constructor.so) -// with the linker.\ -// -// - This shall execute a static constructor that will change the value -// of the TEST_VAR environment variable to "LOADED'. -// -// - Close the library, this shall execute a static destructor that will -// change the value of TEST_VAR to "UNLOADED'. - -#include <stdio.h> -#include <stdlib.h> - -#include <crazy_linker.h> - -#include "test_util.h" - -#define LIB_NAME "libcrazy_linker_tests_libfoo_with_static_constructor.so" - -typedef void (*FunctionPtr)(); - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - setenv("TEST_VAR", "INIT", 1); - - // DEBUG - crazy_context_set_load_address(context, 0x20000000); - - // Load libfoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - const char* env = getenv("TEST_VAR"); - if (!env || strcmp(env, "LOADED")) - Panic("Constructors not run when loading " LIB_NAME "\n"); - - printf("Constructors called when loading the library\n"); - - // Find the "Foo" symbol. - FunctionPtr foo_func; - if (!crazy_library_find_symbol( - library, "Foo", reinterpret_cast<void**>(&foo_func))) { - Panic("Could not find 'Foo' in " LIB_NAME "\n"); - } - - // Call it. - (*foo_func)(); - - // Close the library. - crazy_library_close(library); - - env = getenv("TEST_VAR"); - if (!env || strcmp(env, "UNLOADED")) - Panic("Destructors not run when unloading " LIB_NAME "\n"); - - printf("Destructors called when unloading the library\n"); - - crazy_context_destroy(context); - printf("OK\n"); - - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_dl_wrappers.cpp b/third_party/android_crazy_linker/src/tests/test_dl_wrappers.cpp deleted file mode 100644 index a2791949..0000000 --- a/third_party/android_crazy_linker/src/tests/test_dl_wrappers.cpp +++ /dev/null
@@ -1,52 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libzoo.so) with the linker. -// - Find the address of the "Zoo" function in libzoo.so. -// - Call the Zoo() function, which will use dlopen() / dlsym() to -// find libbar.so (which depends on libfoo.so). -// - Close the library. - -// This tests the dlopen/dlsym/dlclose wrappers provided by the crazy -// linker to loaded libraries. - -#include <stdio.h> -#include <crazy_linker.h> - -#include "test_util.h" - -typedef bool (*FunctionPtr)(); - -#define LIB_NAME "libcrazy_linker_tests_libzoo.so" - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Load libzoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Zoo" symbol. - FunctionPtr zoo_func; - if (!crazy_library_find_symbol( - library, "Zoo", reinterpret_cast<void**>(&zoo_func))) { - Panic("Could not find 'Zoo' in " LIB_NAME "\n"); - } - - // Call it. - bool ret = (*zoo_func)(); - if (!ret) - Panic("'Zoo' function failed!"); - - // Close the library. - printf("Closing " LIB_NAME "\n"); - crazy_library_close(library); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_recursive.cpp b/third_party/android_crazy_linker/src/tests/test_dl_wrappers_recursive.cpp deleted file mode 100644 index cc31cbc..0000000 --- a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_recursive.cpp +++ /dev/null
@@ -1,104 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libzoo.so) with the linker. -// - Find the address of the "Zoo" function in libzoo.so. -// - Call the Zoo() function, which will use dlopen() / dlsym() to -// find libbar.so (which depends on libfoo.so). -// - Close the library. - -// This tests the dlopen/dlsym/dlclose wrappers provided by the crazy -// linker to loaded libraries. - -#include <crazy_linker.h> -#include <stdio.h> - -#include "test_util.h" - -typedef bool (*FunctionPtr)(); - -#define LIB_NAME "libcrazy_linker_tests_libzoo_dlopen_in_initializer.so" - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Load library. Its ELF initializer will call dlopen() to open another - // library, the use dlsym() to find and invoke a function inside it. - // - // Said function will actually also call dlopen() to load another library - // and invoke another function in another library, i.e.: - // - // exe: crazy_library_open("libA.so") - // linker: load and relocate libA.so - // linker: call ELF initializers in libA.so - // libA.so: call dlopen("libB.so") - // linker: crazy::WrapDlOpen("libB.so") gets called. - // linker: load and relocate libB.so - // linker: run ELF initializer in libB.so - // libB.so: call dlopen() to load library C - // linker: crazy::WrapDlOpen("libC.so") gets called. - // linker: load and relocate libC.so - // libB.so: call dlsym() to locate C entry point - // libB.so: call C entry point. - // libC.so: call dlopen() to load library D - // linker: crazy::WrapDlOpen("libD.so") gets called. - // linker: load and relocate libD.so - // libC.so: call dlsym() to locate D entry point. - // libC.so: call D entry point - // libD.so: execute function and return. - // libC.so: call dlclose() to unload libD.so. - // libC.so: return from function - // libB.so: return from initializer - // linker: libB.so has finished loading. - // libA.so: call dlsym() to locate B entry point. - // libA.so: call B entry point. - // libB.so: execute function and return - // libA.so: call dlclose() to unload libB.so - // libA.so: return from initializer. - // linker: libA.so has finished loading. - // exe: crazy_library_find_symbol() to find A entry point - // libA.so: execute A function and return. - // exe: crazy_library_close() to unload libA.so - // linker: call ELF finalizers in libA.so - // libA.so: call dlclose() to unload libB.so - // linker: crazy::WrapDlClose() gets called. - // linker: run ELF finalizers in libB.so - // libB.so: call dlclose() to unload libC.so. - // linker: crazy::WrapDlClose() gets called. - // linker: unload libC.so (no finalizers). - // libB.so: return from finalizer. - // linker: libB.so has finished unloading. - // libA.so: return from finalizer. - // linker: libA.so has finished unloaded. - // exe: program continues and exits. - // - // Actual names for this test: - // libA.so: libcrazy_linker_tests_libzoo_dlopen_in_initializer.so - // libB.so: libcrazy_linker_tests_libzoo_dlopen_in_initializer_inner.so - // libC.so: libcrazy_linker_tests_libzoo.so - // libD.so: libcrazy_linker_tests_libbar.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Zoo" symbol. - FunctionPtr zoo_func; - if (!crazy_library_find_symbol(library, "Zoo", - reinterpret_cast<void**>(&zoo_func))) { - Panic("Could not find 'Zoo' in " LIB_NAME "\n"); - } - - // Call it - (*zoo_func)(); - - // Close the library. - printf("Closing " LIB_NAME "\n"); - crazy_library_close(library); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_valid_handles.cpp b/third_party/android_crazy_linker/src/tests/test_dl_wrappers_valid_handles.cpp deleted file mode 100644 index 2e6bace..0000000 --- a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_valid_handles.cpp +++ /dev/null
@@ -1,52 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Check that the list of valid dlopen handles managed by the crazy linker -// wrappers is maintained properly. -#include <crazy_linker.h> -#include <dlfcn.h> -#include <stdio.h> - -#include "test_util.h" - -namespace crazy { -extern void** GetValidDlopenHandlesForTesting(size_t*); -} // namespace crazy - -#define LIB_NAME "libcrazy_linker_tests_libbar_with_two_dlopens.so" - -// The type of crazy::GetValidDlopenHandlesForTesting() -using GetValidHandlesFunction = void**(size_t*); - -// The type of the Bar() function inside libbar. -using BarFunction = bool(GetValidHandlesFunction*); - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Load libzoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Bar" symbol. - BarFunction* bar_func; - if (!crazy_library_find_symbol(library, "Bar", - reinterpret_cast<void**>(&bar_func))) { - Panic("Could not find 'Bar' in %s\n", LIB_NAME); - } - - // Call the 'Bar' function, passing the address of our test function - // which is linked against the test executable, but not libbar. - if (!(*bar_func)(&crazy::GetValidDlopenHandlesForTesting)) - return 127; - - // Close the 1st library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - crazy_context_destroy(context); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_android_dlopen_ext.cpp b/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_android_dlopen_ext.cpp deleted file mode 100644 index 9cbc1eb..0000000 --- a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_android_dlopen_ext.cpp +++ /dev/null
@@ -1,142 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (LIB_NAME) with the linker. -// - Find the address of the "OpenExtFindRunClose" function in LIB_NAME. -// - Call the OpenExtFindRunClose() function, which will use -// android_dlopen_ext() / -// dlsym() to find libbar.so (which depends on libfoo.so). -// - Close the library. - -// This tests the android_dlopen_ext/dlsym/dlclose wrappers provided by the -// crazy linker to loaded libraries. - -#include <crazy_linker.h> -#include <fcntl.h> -#include <stdio.h> -#include <sys/mman.h> - -#ifdef __ANDROID__ -#include <android/dlext.h> -#else -#error "This source file only compiles for Android!" -#endif - -#include "test_util.h" - -typedef bool (*OpenExtFindRunCloseFunctionPtr)(const char* lib_name, - const char* func_name, - const android_dlextinfo* info); - -#define LIB_NAME "libcrazy_linker_tests_libzoo_with_android_dlopen_ext.so" -#define FUNC_NAME "OpenExtFindRunClose" - -#define LIB2_NAME "libcrazy_linker_tests_libbar.so" -#define FUNC2_NAME "Bar" - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Load LIB_NAME - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "OpenExtFindRunClose" symbol from LIB_NAME - OpenExtFindRunCloseFunctionPtr lib_func; - if (!crazy_library_find_symbol(library, "OpenExtFindRunClose", - reinterpret_cast<void**>(&lib_func))) { - Panic("Could not find '" FUNC_NAME "' in " LIB_NAME "\n"); - } - - bool ret; - // Call it, without dlext info. - printf("////////////////////////// FIRST CALL WITHOUT DLEXT INFO\n"); - ret = (*lib_func)(LIB2_NAME, FUNC2_NAME, nullptr); - if (!ret) - Panic("'" FUNC_NAME "' function failed!"); - - // Call it again, this time load the library from a file descriptor. - printf("////////////////////////// SECOND CALL WITH LIBRARY FD\n"); - { - android_dlextinfo info = {}; - info.flags = ANDROID_DLEXT_USE_LIBRARY_FD; - info.library_fd = ::open(LIB2_NAME, O_RDONLY | O_CLOEXEC); - if (info.library_fd < 0) - PanicErrno("Could not open library file directly"); - - ret = (*lib_func)(nullptr, FUNC2_NAME, &info); - if (!ret) - Panic("'" FUNC_NAME "' function failed with file descriptor!"); - - close(info.library_fd); - } - - fflush(stdout); - printf("////////////////////////// THIRD CALL WITH RESERVED MAP\n"); - { - android_dlextinfo info = {}; - info.flags = ANDROID_DLEXT_RESERVED_ADDRESS; - info.reserved_size = 64 * 4096; - info.reserved_addr = ::mmap(nullptr, info.reserved_size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (info.reserved_addr == MAP_FAILED) - PanicErrno("Could not reserve address map region"); - - ret = (*lib_func)(LIB2_NAME, FUNC2_NAME, &info); - if (!ret) - Panic("'" FUNC_NAME "' function failed with reserved map!"); - - ::munmap(info.reserved_addr, info.reserved_size); - } - - fflush(stdout); - printf("////////////////////////// FOURTH CALL WITH TINY RESERVED MAP\n"); - { - android_dlextinfo info = {}; - info.flags = ANDROID_DLEXT_RESERVED_ADDRESS; - info.reserved_size = 1 * 4096; - info.reserved_addr = ::mmap(nullptr, info.reserved_size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (info.reserved_addr == MAP_FAILED) - PanicErrno("Could not reserve address map region"); - - ret = (*lib_func)(LIB2_NAME, FUNC2_NAME, &info); - if (ret) - Panic("'" FUNC_NAME "' function succeeded with tiny reserved map!"); - - ::munmap(info.reserved_addr, info.reserved_size); - } - - fflush(stdout); - printf("////////////////////////// FIFTH CALL WITH RESERVED MAP + HINT\n"); - { - android_dlextinfo info = {}; - info.flags = - ANDROID_DLEXT_RESERVED_ADDRESS | ANDROID_DLEXT_RESERVED_ADDRESS_HINT; - info.reserved_size = 1 * 4096; - info.reserved_addr = ::mmap(nullptr, info.reserved_size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (info.reserved_addr == MAP_FAILED) - PanicErrno("Could not reserve address map region"); - - ret = (*lib_func)(LIB2_NAME, FUNC2_NAME, &info); - if (!ret) - Panic("'" FUNC_NAME "' failed with tiny reserved map and hint!"); - - ::munmap(info.reserved_addr, info.reserved_size); - } - - fflush(stdout); - printf("//////////////////////////\n"); - // Close the library. - printf("Closing " LIB_NAME "\n"); - crazy_library_close(library); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_system_handle.cpp b/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_system_handle.cpp deleted file mode 100644 index a248b2e..0000000 --- a/third_party/android_crazy_linker/src/tests/test_dl_wrappers_with_system_handle.cpp +++ /dev/null
@@ -1,91 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libzoo) with the crazy linker. -// - Find the address of the "Zoo" function in libzoo. -// - Load a library (libbar) with the *system* linker. -// - Call the Zoo() function, passing the handle for libbar to it. -// -// Zoo() will call the crazy wrapper for dlsym() with a system handle. -// The wrapper is supposed to recognize the handle as not one of its -// own and fall-back to the system dlsym(). -// -// This will allow the function to find "Bar" within libbar() -// then call it. After that, Zoo() wll call the crazy wrapper for -// dlclose() with the same handle. The wrapper should recognize -// this and close bar as well. -// -// Finally, Zoo() will return the address of dlclose() as it -// sees it, which should be the address of the crazy wrapper for -// it, as checked by this program at the end of main(). - -#include <crazy_linker.h> -#include <dlfcn.h> -#include <stdio.h> - -#include "test_util.h" - -using dlclose_func_t = int(void*); -using zoo_func_t = dlclose_func_t*(void*); - -namespace crazy { -extern void* GetDlCloseWrapperAddressForTesting(); -} // namespace crazy - -#define LIB_NAME "libcrazy_linker_tests_libzoo_with_dlopen_handle.so" -#define LIB2_NAME "libcrazy_linker_tests_libbar.so" - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Load libzoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Zoo" symbol. - zoo_func_t* zoo_func; - if (!crazy_library_find_symbol(library, "Zoo", - reinterpret_cast<void**>(&zoo_func))) { - Panic("Could not find 'Zoo' in %s\n", LIB_NAME); - } - printf("OK: Found 'Zoo' at %p in %s\n", zoo_func, LIB_NAME); - - // Open the 2nd library with the system linker. - void* bar_lib = ::dlopen(LIB2_NAME, RTLD_NOW); - if (!bar_lib) { - Panic("Could not open %s: %s\n", LIB2_NAME, dlerror()); - } - - printf("OK: Loaded libbar @%p with system linker\n", bar_lib); - - // Call Zoo(), passing the system handle to the second library. - dlclose_func_t* ret = (*zoo_func)(bar_lib); - if (!ret) - Panic("'Zoo' function failed (returned nullptr)!\n"); - - auto* expected_ret = reinterpret_cast<dlclose_func_t*>( - crazy::GetDlCloseWrapperAddressForTesting()); - - if (ret == &::dlclose) { - Panic("'Zoo' returned system dlclose() @%p, expected wrapper @%p\n", - &::dlclose, expected_ret); - } - if (ret != expected_ret) { - Panic("'Zoo' returned unknown address %p, expected wrapper @%p\n", ret, - expected_ret); - } - - printf("OK: Returned address was dlclose wrapper\n"); - - // Close the 1st library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - crazy_context_destroy(context); - - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_jni_hooks.cpp b/third_party/android_crazy_linker/src/tests/test_jni_hooks.cpp deleted file mode 100644 index 019720ea..0000000 --- a/third_party/android_crazy_linker/src/tests/test_jni_hooks.cpp +++ /dev/null
@@ -1,72 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to test crazy_context_set_java_vm(). - -#include <jni.h> -#include <stdio.h> -#include <stdlib.h> -#include <crazy_linker.h> - -#include "test_util.h" - -#define VARNAME "TEST_VAR" - -static const char kJniLibName[] = "libcrazy_linker_tests_libjni_lib.so"; -static void* kJavaVM = (void*)0xdeadcafe; - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Expect to find the library in the same directory than this executable. - crazy_add_search_path_for_address((void*)&main); - - crazy_set_java_vm(kJavaVM, JNI_VERSION_1_2); - - // Load libjni_lib.so, this should invoke its JNI_OnLoad() function - // automatically. - setenv(VARNAME, "INIT", 1); - if (!crazy_library_open(&library, kJniLibName, context)) - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - - const char* env = getenv(VARNAME); - if (strcmp(env, "LOADED")) - Panic("JNI_OnLoad() hook was not called! %s is %s\n", VARNAME, env); - - crazy_library_close(library); - env = getenv(VARNAME); - if (strcmp(env, "UNLOADED")) - Panic("JNI_OnUnload() hook was not called! %s is %s\n", VARNAME, env); - - // Now, change the minimum JNI version to JNI_VERSION_1_6, which should - // prevent loading the library properly, since it only supports 1.2. - crazy_set_java_vm(kJavaVM, JNI_VERSION_1_6); - - setenv(VARNAME, "INIT", 1); - if (crazy_library_open(&library, kJniLibName, context)) - Panic("Could load the library with JNI_VERSION_1_6 > JNI_VERSION_1_2."); - - // Disable the feature, this shall load the library, but not call the - // JNI_OnLoad() hook. - crazy_set_java_vm(nullptr, 0); - - setenv(VARNAME, "INIT", 1); - if (!crazy_library_open(&library, kJniLibName, context)) - Panic("Could not load the library without a JavaVM handle !?\n"); - - env = getenv(VARNAME); - if (strcmp(env, "INIT")) - Panic("JNI_OnLoad() was called, %s is %s (expected INIT)\n", VARNAME, env); - - crazy_library_close(library); - env = getenv(VARNAME); - if (strcmp(env, "INIT")) - Panic( - "JNI_OnUnload() was called, %s is %s (expected INIT)\n", VARNAME, env); - - crazy_context_destroy(context); - - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_load_library.cpp b/third_party/android_crazy_linker/src/tests/test_load_library.cpp deleted file mode 100644 index abea6ac66..0000000 --- a/third_party/android_crazy_linker/src/tests/test_load_library.cpp +++ /dev/null
@@ -1,51 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libfoo.so) with the linker. -// - Find the address of the "Foo" function in it. -// - Call the function. -// - Close the library. - -#include <stdio.h> -#include <crazy_linker.h> - -#include "test_util.h" - -typedef void (*FunctionPtr)(); - -#ifndef LIB_NAME -#define LIB_NAME "libcrazy_linker_tests_libfoo.so" -#endif - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // DEBUG - crazy_context_set_load_address(context, 0x20000000); - - // Load libfoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Foo" symbol. - FunctionPtr foo_func; - if (!crazy_library_find_symbol( - library, "Foo", reinterpret_cast<void**>(&foo_func))) { - Panic("Could not find 'Foo' in %s\n", LIB_NAME); - } - - // Call it. - (*foo_func)(); - - // Close the library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_load_library_depends.cpp b/third_party/android_crazy_linker/src/tests/test_load_library_depends.cpp deleted file mode 100644 index f3e3cc1..0000000 --- a/third_party/android_crazy_linker/src/tests/test_load_library_depends.cpp +++ /dev/null
@@ -1,57 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libbar.so) with the linker, which depends on -// another library (libfoo.so) -// - Find the address of the "Bar" function in libbar.so. -// - Call the Bar() function, which ends up calling Foo() in libfoo.so -// - Close the library. - -#include <stdio.h> -#include <crazy_linker.h> - -#include "test_util.h" - -#define LIB_NAME "libcrazy_linker_tests_libbar.so" - -typedef void (*FunctionPtr)(); - -int main() { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // DEBUG - crazy_context_set_load_address(context, 0x20000000); - - // Load libbar.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Bar" symbol. - FunctionPtr bar_func; - if (!crazy_library_find_symbol( - library, "Bar", reinterpret_cast<void**>(&bar_func))) { - Panic("Could not find 'Bar' in %s\n", LIB_NAME); - } - - // Call it. - (*bar_func)(); - - // Find the "Foo" symbol from libbar.so - FunctionPtr foo_func; - if (!crazy_library_find_symbol( - library, "Foo", reinterpret_cast<void**>(&foo_func))) { - Panic("Could not find 'Foo' from %s\n", LIB_NAME); - } - - // Close the library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_load_library_with_fd.cpp b/third_party/android_crazy_linker/src/tests/test_load_library_with_fd.cpp deleted file mode 100644 index 61b6eb9..0000000 --- a/third_party/android_crazy_linker/src/tests/test_load_library_with_fd.cpp +++ /dev/null
@@ -1,91 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libfoo.so) with the linker. -// - Find the address of the "Foo" function in it. -// - Call the function. -// - Close the library. -#include <crazy_linker.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include <string> - -#include "test_util.h" - -typedef void (*FunctionPtr)(); - -#ifndef LIB_NAME -#define LIB_NAME "libcrazy_linker_tests_libfoo.so" -#endif - -std::string GetProgramDirectory(const char* argv0) { - const char* sep = strrchr(argv0, '/'); - if (!sep) { - return "."; - } - return std::string(argv0, sep - argv0); -} - -int main(int argc, const char** argv) { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // DEBUG - crazy_context_set_load_address(context, 0x20000000); - - // Assume library file is in the same directory as this executable. - std::string program_dir = GetProgramDirectory(argv[0]); - std::string lib_path = program_dir + "/" LIB_NAME; - int fd = open(lib_path.c_str(), O_RDONLY | O_CLOEXEC); - if (fd < 0) { - Panic("Could not find library file %s: %s\n", LIB_NAME, strerror(errno)); - } - - crazy_context_set_library_fd(context, fd); - - int context_fd = crazy_context_get_library_fd(context); - if (context_fd != fd) - Panic("Invalid context fd %d (expected %d)\n", context_fd, fd); - - // Load libfoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Foo" symbol. - FunctionPtr foo_func; - if (!crazy_library_find_symbol(library, "Foo", - reinterpret_cast<void**>(&foo_func))) { - Panic("Could not find 'Foo' in %s\n", LIB_NAME); - } - - // Call it. - (*foo_func)(); - - // Close the library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - // Check that the descriptor is not closed, by trying to read from it. - char header[4]; - if (TEMP_FAILURE_RETRY(lseek(fd, 0, SEEK_SET)) < 0 || - TEMP_FAILURE_RETRY(read(fd, header, 4)) < 0) { - Panic("Could not read from file descriptor after library close!: %s", - strerror(errno)); - } - close(fd); - - context_fd = crazy_context_get_library_fd(context); - if (context_fd != -1) - Panic("Invalid context fd after library load %d (expected -1)", context_fd); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_load_library_with_reserved_map.cpp b/third_party/android_crazy_linker/src/tests/test_load_library_with_reserved_map.cpp deleted file mode 100644 index 8cc09f73..0000000 --- a/third_party/android_crazy_linker/src/tests/test_load_library_with_reserved_map.cpp +++ /dev/null
@@ -1,98 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libfoo.so) with the linker. -// - Find the address of the "Foo" function in it. -// - Call the function. -// - Close the library. -#include <crazy_linker.h> -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#include <string> - -#include "test_util.h" - -typedef void (*FunctionPtr)(); - -#ifndef LIB_NAME -#define LIB_NAME "libcrazy_linker_tests_libfoo.so" -#endif - -std::string GetProgramDirectory(const char* argv0) { - const char* sep = strrchr(argv0, '/'); - if (!sep) { - return "."; - } - return std::string(argv0, sep - argv0); -} - -int main(int argc, const char** argv) { - crazy_context_t* context = crazy_context_create(); - crazy_library_t* library; - - // Allocate a memory map range large enough for our library. - const size_t kMapSize = 1024 * 1024; // 1 MiB should be enough. - void* reserved_map = - mmap(nullptr, kMapSize, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (reserved_map == MAP_FAILED) - Panic("mmap() failed: %s", strerror(errno)); - - crazy_context_set_reserved_map( - context, reinterpret_cast<uintptr_t>(reserved_map), kMapSize, false); - - // Load libfoo.so - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not open library: %s\n", crazy_context_get_error(context)); - } - - // Find the "Foo" symbol. - FunctionPtr foo_func; - if (!crazy_library_find_symbol(library, "Foo", - reinterpret_cast<void**>(&foo_func))) { - Panic("Could not find 'Foo' in %s\n", LIB_NAME); - } - - // Call it. - (*foo_func)(); - - // Close the library. - printf("Closing %s\n", LIB_NAME); - crazy_library_close(library); - - // Check that the memory map is still there by writing to it. - printf("Erasing memory map\n"); - if (mprotect(reserved_map, kMapSize, PROT_WRITE) < 0) - Panic("Could not mprotect() range: %s", strerror(errno)); - memset(reserved_map, 1, kMapSize); - - printf("Trying to reload inside smaller reserved map (no fallback).\n"); - // Try to load the library again at the same address, without a reserved - // size. This should fail. - crazy_context_set_reserved_map( - context, reinterpret_cast<uintptr_t>(reserved_map), 4096, false); - - if (crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could unexpectedly load library in small mapping!"); - } - - printf("Trying to reload inside smaller reserved map (with fallback)\n."); - if (!crazy_library_open(&library, LIB_NAME, context)) { - Panic("Could not reload library with fallback in small mapping!"); - } - crazy_library_close(library); - - printf("Unmapping reserved mapping.\n"); - if (munmap(reserved_map, kMapSize) < 0) - Panic("Could not unmap reserved mapping: %s", strerror(errno)); - - crazy_context_destroy(context); - printf("OK\n"); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_relocated_shared_relro.cpp b/third_party/android_crazy_linker/src/tests/test_relocated_shared_relro.cpp deleted file mode 100644 index 9aeb803..0000000 --- a/third_party/android_crazy_linker/src/tests/test_relocated_shared_relro.cpp +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <errno.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/wait.h> -#include <unistd.h> - -#include <crazy_linker.h> - -#include "test_util.h" - -#define PARENT_ADDRESS 0x20000000 -#define CHILD_ADDRESS 0x20134000 - -#define LIB_NAME "libcrazy_linker_tests_libfoo_with_relro.so" - -typedef void (*FunctionPtr)(); - -int main() { - crazy_context_t* context = crazy_context_create(); - - RelroLibrary foo; - - int pipes[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipes) < 0) - Panic("Could not create socket pair: %s", strerror(errno)); - - pid_t child = fork(); - if (child < 0) - Panic("Could not fork test program!"); - - if (child == 0) { - // In the child. - crazy_context_set_load_address(context, CHILD_ADDRESS); - foo.Init(LIB_NAME, context); - - printf("Child waiting for foo relro fd\n"); - - foo.ReceiveRelroInfo(pipes[0]); - foo.UseSharedRelro(context); - - printf("RELRO used in child process\n"); - - CheckRelroMaps(1); - - FunctionPtr foo_func; - if (!crazy_library_find_symbol( - foo.library, "Foo", reinterpret_cast<void**>(&foo_func))) - Panic("Could not find 'Foo' in library"); - - printf("Calling Foo()\n"); - (*foo_func)(); - - printf("Foo called, exiting\n"); - - exit(0); - - } else { - // In the parent. - - // Load at fixed address to simplify testing. - crazy_context_set_load_address(context, PARENT_ADDRESS); - foo.Init(LIB_NAME, context); - - printf("Library loaded\n"); - - printf("Parent enabling foo RELRO sharing\n"); - - foo.CreateSharedRelro(context, CHILD_ADDRESS); - foo.SendRelroInfo(pipes[1]); - - printf("Relocated RELRO sent to child\n"); - - CheckRelroMaps(0); - - printf("Parent waiting for child\n"); - - // Wait for child to complete. - int status; - waitpid(child, &status, 0); - - if (WIFSIGNALED(status)) - Panic("Child terminated by signal!!\n"); - else if (WIFEXITED(status)) { - int child_status = WEXITSTATUS(status); - if (child_status != 0) - Panic("Child terminated with status=%d\n", child_status); - } else - Panic("Child exited for unknown reason!!\n"); - } - - crazy_context_destroy(context); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_search_path_list.cpp b/third_party/android_crazy_linker/src/tests/test_search_path_list.cpp deleted file mode 100644 index d5626b8..0000000 --- a/third_party/android_crazy_linker/src/tests/test_search_path_list.cpp +++ /dev/null
@@ -1,136 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to check that paths added with -// crazy_context_add_search_path() or -// crazy_context_add_search_path_from_address() -// have higher priority than the default ones (from LD_LIBRARY_PATH). -// -// This requires creating two temporary directories and placing there libraries -// with the same name, but different content -// -// $TMPDIR1/libfoo.so -> a copy of libfoo.so that contains the 'Foo' symbol. -// $TMPDIR2/libfoo.so -> a copy of libfoo2.so that contains the 'Foo2' -// symbol. -// - -#include <crazy_linker.h> - -#include "test_util.h" - -namespace { - -void CheckLibraryCantLoad(const char* library_name, crazy_context_t* context) { - crazy_library_t* library; - - if (crazy_library_open(&library, library_name, context)) - Panic("Could load library %s, expected this not to be possible\n", - library_name); -} - -// Loads a library named |library_name| and checks that it contains -// the symbols listed in |wanted_symbols|, and none of the symbols -// listed in |unwanted_symbols|. After that, close the library and exit. -// -// Both |wanted_symbols| and |unwanted_symbols| are NULL-terminated -// arrays of strings. -void CheckLibrary(const char* library_name, - const char* const* wanted_symbols, - const char* const* unwanted_symbols, - crazy_context_t* context) { - crazy_library_t* library; - - if (!crazy_library_open(&library, library_name, context)) - Panic("Could not open library %s: %s\n", crazy_context_get_error(context)); - - size_t failures = 0; - - if (wanted_symbols) { - for (; *wanted_symbols; ++wanted_symbols) { - const char* symbol_name = *wanted_symbols; - void* symbol_addr; - if (!crazy_library_find_symbol(library, symbol_name, &symbol_addr)) { - fprintf(stderr, - "Could not find symbol '%s' in library '%s'!\n", - symbol_name, - library_name); - failures += 1; - } - } - } - - if (unwanted_symbols) { - for (; *unwanted_symbols; ++unwanted_symbols) { - const char* symbol_name = *unwanted_symbols; - void* symbol_addr; - if (crazy_library_find_symbol(library, symbol_name, &symbol_addr)) { - fprintf(stderr, - "Found symbol '%s' in library '%s', none expected!\n", - symbol_name, - library_name); - failures += 1; - } - } - } - - if (failures > 0) - Panic("Found %d symbol failures in library %s\n", failures, library_name); - - crazy_library_close(library); -} - -} // namespace - -#define LIB_NAME "libcrazy_linker_tests_libfoo.so" -#define LIB2_NAME "libcrazy_linker_tests_libfoo2.so" - -int main() { - String exe_path = GetCurrentExecutableDirectory(); - - TempDirectory temp_dir_1; - TempDirectory temp_dir_2; - - // List of symbols in original libfoo.so and libfoo2.so, respectively. - static const char* const kFooSymbols[] = {"Foo", NULL}; - static const char* const kFoo2Symbols[] = {"Foo2", NULL}; - - // Copy libfoo.so to $TMPDIR1/libfoo.so - CopyFile(LIB_NAME, exe_path.c_str(), LIB_NAME, temp_dir_1.path()); - - // Copy libfoo2.so to $TMPDIR2/libfoo.so - CopyFile(LIB2_NAME, exe_path.c_str(), LIB_NAME, temp_dir_2.path()); - - // Create a new context object. - crazy_context_t* context = crazy_context_create(); - - // Reset search paths to a non-existing directory. Check that the library - // can't be loaded. - setenv("LD_LIBRARY_PATH", "/this-directory-does-not-exist", 1); - crazy_reset_search_paths(); - CheckLibraryCantLoad(LIB_NAME, context); - - // Add the search path to the current executable, this should load the - // original - // libfoo.so. - crazy_add_search_path_for_address((void*)&main); - CheckLibrary(LIB_NAME, kFooSymbols, kFoo2Symbols, context); - - // Reset search paths to use $TMPDIR2 then $TMPDIR1 - setenv("LD_LIBRARY_PATH", temp_dir_1.path(), 1); - crazy_reset_search_paths(); - crazy_add_search_path(temp_dir_2.path()); - - // Check that the copy of libfoo2.so is loaded. - CheckLibrary(LIB_NAME, kFoo2Symbols, kFooSymbols, context); - - // Reset search paths to use only $TMPDIR1 - crazy_reset_search_paths(); - - // Check that the copy of libfoo.so is loaded. - CheckLibrary(LIB_NAME, kFooSymbols, kFoo2Symbols, context); - - crazy_context_destroy(context); - - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_shared_relro.cpp b/third_party/android_crazy_linker/src/tests/test_shared_relro.cpp deleted file mode 100644 index 3fe34c1..0000000 --- a/third_party/android_crazy_linker/src/tests/test_shared_relro.cpp +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A crazy linker test to: -// - Load a library (libfoo.so) with the linker. -// - Find the address of the "Foo" function in it. -// - Call the function. -// - Close the library. - -#include <errno.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/wait.h> -#include <unistd.h> - -#include <crazy_linker.h> - -#include "test_util.h" - -typedef void (*FunctionPtr)(); - -#define LIB_NAME "libcrazy_linker_tests_libfoo_with_relro.so" - -int main() { - crazy_context_t* context = crazy_context_create(); - - RelroLibrary foo; - - // Load at fixed address to simplify testing. - crazy_context_set_load_address(context, 0x20000000); - foo.Init(LIB_NAME, context); - - printf("Library loaded\n"); - - int pipes[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipes) < 0) - Panic("Could not create socket pair: %s", strerror(errno)); - - pid_t child = fork(); - if (child < 0) - Panic("Could not fork test program!"); - - if (child == 0) { - // In the child. - printf("Child waiting for foo relro fd\n"); - - foo.ReceiveRelroInfo(pipes[0]); - foo.UseSharedRelro(context); - - printf("RELRO used in child process\n"); - - CheckRelroMaps(1); - - FunctionPtr foo_func; - if (!crazy_library_find_symbol( - foo.library, "Foo", reinterpret_cast<void**>(&foo_func))) - Panic("Could not find 'Foo' in library"); - - printf("Calling Foo()\n"); - (*foo_func)(); - - printf("Foo called, exiting\n"); - - exit(0); - - } else { - // In the parent. - - printf("Parent enabling foo RELRO sharing\n"); - - foo.EnableSharedRelro(context); - foo.SendRelroInfo(pipes[1]); - - printf("RELRO enabled and sent to child\n"); - - CheckRelroMaps(1); - - printf("Parent waiting for child\n"); - - // Wait for child to complete. - int status; - waitpid(child, &status, 0); - - if (WIFSIGNALED(status)) - Panic("Child terminated by signal!!\n"); - else if (WIFEXITED(status)) { - int child_status = WEXITSTATUS(status); - if (child_status != 0) - Panic("Child terminated with status=%d\n", child_status); - } else - Panic("Child exited for unknown reason!!\n"); - } - - crazy_context_destroy(context); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_two_shared_relros.cpp b/third_party/android_crazy_linker/src/tests/test_two_shared_relros.cpp deleted file mode 100644 index 68afb8a..0000000 --- a/third_party/android_crazy_linker/src/tests/test_two_shared_relros.cpp +++ /dev/null
@@ -1,119 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Same as test_relro_sharing.cpp, but uses two libraries at the same -// time (libfoo_with_relro.so and libbar_with_relro.so), each one of -// them gets its own shared RELRO. - -#include <errno.h> -#include <pthread.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <sys/socket.h> -#include <sys/uio.h> -#include <sys/wait.h> -#include <unistd.h> - -#include <crazy_linker.h> - -#include "test_util.h" - -typedef void (*FunctionPtr)(); - -#define LIB_NAME "libcrazy_linker_tests_libfoo_with_relro.so" -#define LIB2_NAME "libcrazy_linker_tests_libbar_with_relro.so" - -int main() { - crazy_context_t* context = crazy_context_create(); - - RelroLibrary foo; - RelroLibrary bar; - - crazy_add_search_path_for_address((void*)&main); - - // Load libfoo_with_relro.so - crazy_context_set_load_address(context, 0x20000000); - foo.Init(LIB_NAME, context); - - crazy_context_set_load_address(context, 0x20800000); - bar.Init(LIB2_NAME, context); - - printf("Libraries loaded\n"); - - int pipes[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, 0, pipes) < 0) - Panic("Could not create socket pair: %s", strerror(errno)); - - pid_t child = fork(); - if (child < 0) - Panic("Could not fork test program!"); - - if (child == 0) { - // In the child. - printf("Child waiting for foo relro fd\n"); - - foo.ReceiveRelroInfo(pipes[0]); - foo.UseSharedRelro(context); - - printf("Child waiting for bar relro fd\n"); - bar.ReceiveRelroInfo(pipes[0]); - bar.UseSharedRelro(context); - - printf("RELROs used in child process\n"); - - CheckRelroMaps(2); - - FunctionPtr bar_func; - if (!crazy_library_find_symbol( - bar.library, "Bar", reinterpret_cast<void**>(&bar_func))) - Panic("Could not find 'Bar' in library"); - - printf("Calling Bar()\n"); - (*bar_func)(); - - printf("Bar() called, exiting\n"); - - exit(0); - - } else { - // In the parent. - - printf("Parent enabling foo RELRO sharing\n"); - - foo.EnableSharedRelro(context); - foo.SendRelroInfo(pipes[1]); - - printf("Parent enabling bar RELRO sharing\n"); - - bar.EnableSharedRelro(context); - bar.SendRelroInfo(pipes[1]); - - printf("RELROs enabled and sent to child\n"); - - CheckRelroMaps(2); - - printf("Parent waiting for child\n"); - - // Wait for child to complete. - int status; - waitpid(child, &status, 0); - - if (WIFSIGNALED(status)) - Panic("Child terminated by signal!!\n"); - else if (WIFEXITED(status)) { - int child_status = WEXITSTATUS(status); - if (child_status != 0) - Panic("Child terminated with status=%d\n", child_status); - } else - Panic("Child exited for unknown reason!!\n"); - } - - printf("Closing libraries\n"); - bar.Close(); - foo.Close(); - - crazy_context_destroy(context); - return 0; -}
diff --git a/third_party/android_crazy_linker/src/tests/test_util.h b/third_party/android_crazy_linker/src/tests/test_util.h deleted file mode 100644 index 1dcd46cd..0000000 --- a/third_party/android_crazy_linker/src/tests/test_util.h +++ /dev/null
@@ -1,469 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// A set of common helper functions used by crazy_linker tests. -// IMPORTANT: ALL FUNCTIONS HERE ARE INLINED. This avoids adding a -// dependency on another source file for all tests that include this -// header. - -#ifndef TEST_UTIL_H -#define TEST_UTIL_H - -#include <crazy_linker.h> - -#include <dirent.h> -#include <errno.h> -#include <limits.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/mman.h> -#include <sys/socket.h> -#include <sys/stat.h> -#include <sys/uio.h> -#include <unistd.h> -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS // to get PRI and SCN in 32-bit inttypes.h -#endif -#include <inttypes.h> - -namespace { - -// Print an error message and exit the process. -// Message must be terminated by a newline. -inline void Panic(const char* fmt, ...) { - va_list args; - fprintf(stderr, "PANIC: "); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - exit(1); -} - -// Print an error message, the errno message, then exit the process. -// Message must not be terminated by a newline. -inline void PanicErrno(const char* fmt, ...) { - int old_errno = errno; - va_list args; - fprintf(stderr, "PANIC: "); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - fprintf(stderr, ": %s\n", strerror(old_errno)); - exit(1); -} - -// Simple string class. -class String { - public: - String() : str_(NULL), len_(0) {} - - String(const String& other) { String(other.str_, other.len_); } - - String(const char* str) { String(str, strlen(str)); } - - String(const char* str, size_t len) : str_(NULL), len_(0) { - Append(str, len); - } - - ~String() { - if (str_) { - free(str_); - str_ = NULL; - } - } - - String& operator+=(const char* str) { - Append(str, strlen(str)); - return *this; - } - - String& operator+=(const String& other) { - Append(other.str_, other.len_); - return *this; - } - - String& operator+=(char ch) { - Append(&ch, 1); - return *this; - } - - const char* c_str() const { return len_ ? str_ : ""; } - char* ptr() { return str_; } - size_t size() const { return len_; } - - void Append(const char* str, size_t len) { - size_t old_len = len_; - Resize(len_ + len); - memcpy(str_ + old_len, str, len); - } - - void Resize(size_t len) { - str_ = reinterpret_cast<char*>(realloc(str_, len + 1)); - if (len > len_) - memset(str_ + len_, '\0', len - len_); - str_[len] = '\0'; - len_ = len; - } - - void Format(const char* fmt, ...) { - va_list args; - va_start(args, fmt); - Resize(128); - for (;;) { - va_list args2; - va_copy(args2, args); - int ret = vsnprintf(str_, len_ + 1, fmt, args2); - va_end(args2); - if (ret < static_cast<int>(len_ + 1)) - break; - - Resize(len_ * 2); - } - } - - private: - char* str_; - size_t len_; -}; - -// Helper class to create a temporary directory that gets deleted on scope exit, -// as well as all regular files it contains. -class TempDirectory { - public: - TempDirectory() { - snprintf(path_, sizeof path_, "/data/local/tmp/temp-XXXXXX"); - if (!mkdtemp(path_)) - Panic("Could not create temporary directory name: %s\n", strerror(errno)); - } - - ~TempDirectory() { - // Remove any file in this directory. - DIR* d = opendir(path_); - if (!d) - Panic("Could not open directory %s: %s\n", strerror(errno)); - - struct dirent* entry; - while ((entry = readdir(d)) != NULL) { - if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) - continue; - String file_path; - file_path.Format("%s/%s", path_, entry->d_name); - if (unlink(file_path.c_str()) < 0) - Panic("Could not remove %s: %s\n", file_path.c_str(), strerror(errno)); - } - closedir(d); - - if (rmdir(path_) < 0) - Panic("Could not remove dir %s: %s\n", path_, strerror(errno)); - } - - const char* path() const { return path_; } - - private: - char path_[PATH_MAX]; -}; - -// Scoped FILE* class. Always closed on destruction. -class ScopedFILE { - public: - ScopedFILE() : file_(NULL) {} - - ~ScopedFILE() { - if (file_) { - fclose(file_); - file_ = NULL; - } - } - - void Open(const char* path, const char* mode) { - file_ = fopen(path, mode); - if (!file_) - Panic("Could not open file for reading: %s: %s\n", path, strerror(errno)); - } - - FILE* file() const { return file_; } - - private: - FILE* file_; -}; - -// Retrieve current executable path as a String. -inline String GetCurrentExecutable() { - String path; - path.Resize(PATH_MAX); - ssize_t ret = - TEMP_FAILURE_RETRY(readlink("/proc/self/exe", path.ptr(), path.size())); - if (ret < 0) - Panic("Could not read /proc/self/exe: %s\n", strerror(errno)); - - return path; -} - -// Retrieve current executable directory as a String. -inline String GetCurrentExecutableDirectory() { - String path = GetCurrentExecutable(); - // Find basename. - const char* p = reinterpret_cast<const char*>(strrchr(path.c_str(), '/')); - if (p == NULL) - Panic("Current executable does not have directory root?: %s\n", - path.c_str()); - - path.Resize(p - path.c_str()); - return path; -} - -// Copy a file named |src_file_name| in directory |src_file_dir| into -// a file named |dst_file_name| in directory |dst_file_dir|. Panics on error. -inline void CopyFile(const char* src_file_name, - const char* src_file_dir, - const char* dst_file_name, - const char* dst_file_dir) { - String src_path; - src_path.Format("%s/%s", src_file_dir, src_file_name); - - ScopedFILE src_file; - src_file.Open(src_path.c_str(), "rb"); - - String dst_path; - dst_path.Format("%s/%s", dst_file_dir, dst_file_name); - ScopedFILE dst_file; - dst_file.Open(dst_path.c_str(), "wb"); - - char buffer[8192]; - for (;;) { - size_t read = fread(buffer, 1, sizeof buffer, src_file.file()); - if (read > 0) { - size_t written = fwrite(buffer, 1, read, dst_file.file()); - if (written != read) - Panic("Wrote %d bytes instead of %d into %s\n", - written, - read, - dst_path.c_str()); - } - if (read < sizeof buffer) - break; - } -} - -// Send a file descriptor |fd| through |socket|. -// Return 0 on success, -1/errno on failure. -inline int SendFd(int socket, int fd) { - struct iovec iov; - - char buffer[1]; - buffer[0] = 0; - - iov.iov_base = buffer; - iov.iov_len = 1; - - struct msghdr msg; - struct cmsghdr* cmsg; - char cms[CMSG_SPACE(sizeof(int))]; - - ::memset(&msg, 0, sizeof(msg)); - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_control = reinterpret_cast<caddr_t>(cms); - msg.msg_controllen = CMSG_LEN(sizeof(int)); - - cmsg = CMSG_FIRSTHDR(&msg); - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - ::memcpy(CMSG_DATA(cmsg), &fd, sizeof(int)); - - int ret = sendmsg(socket, &msg, 0); - if (ret < 0) - return -1; - - if (ret != (int)iov.iov_len) { - errno = EIO; - return -1; - } - - return 0; -} - -inline int ReceiveFd(int socket, int* fd) { - char buffer[1]; - struct iovec iov; - - iov.iov_base = buffer; - iov.iov_len = 1; - - struct msghdr msg; - struct cmsghdr* cmsg; - char cms[CMSG_SPACE(sizeof(int))]; - - ::memset(&msg, 0, sizeof msg); - msg.msg_name = 0; - msg.msg_namelen = 0; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - - msg.msg_control = reinterpret_cast<caddr_t>(cms); - msg.msg_controllen = sizeof(cms); - - int ret = recvmsg(socket, &msg, 0); - if (ret < 0) - return -1; - if (ret == 0) { - errno = EIO; - return -1; - } - - cmsg = CMSG_FIRSTHDR(&msg); - ::memcpy(fd, CMSG_DATA(cmsg), sizeof(int)); - return 0; -} - -// Check that there are exactly |expected_count| memory mappings in -// /proc/self/maps that point to a RELRO ashmem region. -inline void CheckRelroMaps(int expected_count) { - printf("Checking for %d RELROs in /proc/self/maps\n", expected_count); - - FILE* file = fopen("/proc/self/maps", "rb"); - if (!file) - Panic("Could not open /proc/self/maps (pid %d): %s\n", - getpid(), - strerror(errno)); - - char line[512]; - int count_relros = 0; - printf("proc/%d/maps:\n", getpid()); - while (fgets(line, sizeof line, file)) { - if (strstr(line, "with_relro")) { - // The supported library names are "lib<name>_with_relro.so". - printf("%s", line); - if (strstr(line, "/dev/ashmem/RELRO:")) { - count_relros++; - // Check that they are read-only mappings. - if (!strstr(line, " r--")) - Panic("Shared RELRO mapping is not readonly!\n"); - // Check that they can't be remapped read-write. - uint64_t vma_start, vma_end; - if (sscanf(line, "%" SCNx64 "-%" SCNx64, &vma_start, &vma_end) != 2) - Panic("Could not parse VM address range!\n"); - int ret = ::mprotect( - (void*)vma_start, vma_end - vma_start, PROT_READ | PROT_WRITE); - if (ret == 0) - Panic("Could remap shared RELRO as writable, should not happen!\n"); - - if (errno != EACCES) - Panic("remapping shared RELRO to writable failed with: %s\n", - strerror(errno)); - } - } - } - fclose(file); - - if (count_relros != expected_count) - Panic( - "Invalid shared RELRO sections in /proc/self/maps: %d" - " (expected %d)\n", - count_relros, - expected_count); - - printf("RELRO count check ok!\n"); -} - -struct RelroInfo { - size_t start; - size_t size; - int fd; -}; - -struct RelroLibrary { - const char* name; - crazy_library_t* library; - RelroInfo relro; - - void Init(const char* name_str, crazy_context_t* context) { - printf("Loading %s\n", name_str); - name = name_str; - if (!crazy_library_open(&this->library, name_str, context)) { - Panic("Could not open %s: %s\n", name_str, - crazy_context_get_error(context)); - } - } - - void Close() { crazy_library_close(this->library); } - - void CreateSharedRelro(crazy_context_t* context, size_t load_address) { - if (!crazy_library_create_shared_relro(this->library, - context, - load_address, - &this->relro.start, - &this->relro.size, - &this->relro.fd)) { - Panic("Could not create shared RELRO for %s: %s", - this->name, - crazy_context_get_error(context)); - } - - printf("Parent %s relro info relro_start=%p relro_size=%p relro_fd=%d\n", - this->name, - (void*)this->relro.start, - (void*)this->relro.size, - this->relro.fd); - } - - void EnableSharedRelro(crazy_context_t* context) { - CreateSharedRelro(context, 0); - UseSharedRelro(context); - } - - void SendRelroInfo(int fd) { - if (SendFd(fd, this->relro.fd) < 0) { - Panic("Could not send %s RELRO fd: %s", this->name, strerror(errno)); - } - - int ret = - TEMP_FAILURE_RETRY(::write(fd, &this->relro, sizeof(this->relro))); - if (ret != static_cast<int>(sizeof(this->relro))) { - Panic("Parent could not send %s RELRO info: %s", - this->name, - strerror(errno)); - } - } - - void ReceiveRelroInfo(int fd) { - // Receive relro information from parent. - int relro_fd = -1; - if (ReceiveFd(fd, &relro_fd) < 0) { - Panic("Could not receive %s relro descriptor from parent", this->name); - } - - printf("Child received %s relro fd %d\n", this->name, relro_fd); - - int ret = TEMP_FAILURE_RETRY(::read(fd, &this->relro, sizeof(this->relro))); - if (ret != static_cast<int>(sizeof(this->relro))) { - Panic("Could not receive %s relro information from parent", this->name); - } - - this->relro.fd = relro_fd; - printf("Child received %s relro start=%p size=%p\n", - this->name, - (void*)this->relro.start, - (void*)this->relro.size); - } - - void UseSharedRelro(crazy_context_t* context) { - if (!crazy_library_use_shared_relro(this->library, - context, - this->relro.start, - this->relro.size, - this->relro.fd)) { - Panic("Could not use %s shared RELRO: %s\n", - this->name, - crazy_context_get_error(context)); - } - } -}; - -} // namespace - -#endif // TEST_UTIL_H
diff --git a/third_party/android_crazy_linker/src/tests/zoo.cpp b/third_party/android_crazy_linker/src/tests/zoo.cpp deleted file mode 100644 index 81fcf64..0000000 --- a/third_party/android_crazy_linker/src/tests/zoo.cpp +++ /dev/null
@@ -1,37 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <dlfcn.h> -#include <stdio.h> - -#define LIB_NAME "libcrazy_linker_tests_libbar.so" - -extern "C" bool Zoo() { - printf("%s: Entering\n", __FUNCTION__); - void* bar_lib = dlopen(LIB_NAME, RTLD_NOW); - if (!bar_lib) { - fprintf(stderr, "Could not open %s: %s\n", LIB_NAME, dlerror()); - return false; - } - printf("%s: Opened %s @%p\n", __FUNCTION__, LIB_NAME, bar_lib); - - void (*bar_func)(); - - bar_func = reinterpret_cast<void (*)()>(dlsym(bar_lib, "Bar")); - if (!bar_func) { - fprintf(stderr, "Could not find 'Bar' symbol in %s\n", LIB_NAME); - return false; - } - printf("%s: Found 'Bar' symbol at @%p\n", __FUNCTION__, bar_func); - - // Call it. - printf("%s: Calling Bar()\n", __FUNCTION__); - (*bar_func)(); - - printf("%s: Closing %s\n", __FUNCTION__, LIB_NAME); - dlclose(bar_lib); - - printf("%s: Exiting\n", __FUNCTION__); - return true; -}
diff --git a/third_party/android_crazy_linker/src/tests/zoo_with_android_dlopen_ext.cpp b/third_party/android_crazy_linker/src/tests/zoo_with_android_dlopen_ext.cpp deleted file mode 100644 index 044fec2d..0000000 --- a/third_party/android_crazy_linker/src/tests/zoo_with_android_dlopen_ext.cpp +++ /dev/null
@@ -1,75 +0,0 @@ -// Copyright 2019 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <dlfcn.h> -#include <stdio.h> - -// This source file is used to exercise the dlopen()/dlsym() wrappers -// inside a library that was loaded by the crazy linker. It should be compiled -// into a standalone library (e.g. libzoo.so) that is loaded with the crazy -// linker. - -#ifdef __ANDROID__ -#include <android/dlext.h> - -// <android/dlext.h> does not declare android_dlopen_ext() if __ANDROID_API__ -// is smaller than 21, so declare it here as a weak function. This will allow -// detecting its availability at runtime. For API level 21 or higher, the -// attribute is ignored due to the previous declaration. - -// NOTE: The crazy linker always provides android_dlopen_ext(), even on older -// platforms, this is required to compile this source, and will allow -// us to check that the crazy linker resolves weak symbol imports -// to itself properly. -extern "C" void* android_dlopen_ext(const char*, int, const android_dlextinfo*) - __attribute__((weak)); - -#else -#error "This source file can only build for Android." -#endif - -// Try to load library |lib_name| with android_dlopen_ext(), then locate -// function |func_name| in it to run it, then close the library. -// Return true in case of success, false otherwise. -extern "C" bool OpenExtFindRunClose(const char* lib_name, - const char* func_name, - const android_dlextinfo* android_info) { - printf("%s: Entering\n", __FUNCTION__); - if (!android_dlopen_ext) { - fprintf(stderr, "Cannot find android_dlopen_ext symbol!"); - return false; - } - - void* lib_handle = android_dlopen_ext(lib_name, RTLD_NOW, android_info); - if (!lib_handle) { - fprintf(stderr, "Could not open %s: %s\n", lib_name ? lib_name : "(NULL)", - dlerror()); - return false; - } - if (!lib_name) - lib_name = "(FROM_FD)"; - - printf("%s: Opened %s @%p\n", __FUNCTION__, lib_name, lib_handle); - - auto* func_ptr = reinterpret_cast<void (*)()>(dlsym(lib_handle, func_name)); - if (!func_ptr) { - fprintf(stderr, "Could not find 'Bar' symbol in %s: %s\n", lib_name, - dlerror()); - return false; - } - printf("%s: Found '%s' symbol at @%p\n", __FUNCTION__, func_name, func_ptr); - - // Call it. - printf("%s: Calling %s\n", __FUNCTION__, func_name); - (*func_ptr)(); - - printf("%s: Closing %s\n", __FUNCTION__, lib_name); - int ret = dlclose(lib_handle); - if (ret != 0) { - printf("ERROR: Failed to close library: %s\n", dlerror()); - return false; - } - printf("%s: Exiting\n", __FUNCTION__); - return true; -}
diff --git a/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_handle.cpp b/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_handle.cpp deleted file mode 100644 index 786b8f67..0000000 --- a/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_handle.cpp +++ /dev/null
@@ -1,33 +0,0 @@ -// Copyright 2014 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <dlfcn.h> -#include <stdio.h> - -using dlclose_func_t = int(void*); - -extern "C" dlclose_func_t* Zoo(void* bar_lib) { - printf("%s: Entering, library_handle=%p\n", __FUNCTION__, bar_lib); - auto* bar_func = reinterpret_cast<void (*)()>(::dlsym(bar_lib, "Bar")); - if (!bar_func) { - fprintf(stderr, "ERROR: Could not find 'Bar' symbol in library\n"); - return nullptr; - } - printf("OK: Found 'Bar' symbol at @%p\n", bar_func); - - printf("OK: Closing library\n"); - int ret = dlclose(bar_lib); - if (ret != 0) { - printf("ERROR: Failed to close library: %s\n", dlerror()); - return nullptr; - } - - dlclose_func_t* result = &::dlclose; - printf("%s: Exiting, address of dlclose=%p\n", __FUNCTION__, result); - - // If the library is loaded with the crazy linker, this should return the - // address of the wrapper function, not of the system dlclose one. This - // will be checked by the caller. - return result; -}
diff --git a/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_in_elf_initializer.cpp b/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_in_elf_initializer.cpp deleted file mode 100644 index 3e8a850..0000000 --- a/third_party/android_crazy_linker/src/tests/zoo_with_dlopen_in_elf_initializer.cpp +++ /dev/null
@@ -1,82 +0,0 @@ -// Copyright 2018 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <dlfcn.h> -#include <stdio.h> - -// A version of the zoo test library that loads and unloads LIB_NAME -// in an ELF initializer / finalizer, respectively, while performing -// the dlsym() inside of Zoo(). - -// The point of this is to check that recursive dlopen(), are supported -// by the crazy linker. - -// Name of the library that contains this code. -#ifndef THIS_LIB_NAME -#error THIS_LIB_NAME should be defined! -#endif - -// Name of the library to load / unload. -#ifndef LIB_NAME -#define LIB_NAME "libcrazy_linker_tests_libzoo.so" -#endif - -// Name of the entry point to find and call in the loaded library. -#ifndef LIB_SYMBOL -#define LIB_SYMBOL "Zoo" -#endif - -static void* sLib = NULL; -static char sError[512] = {}; - -// Declare initializer and finalize functions. -static void RunOnLoad() __attribute__((constructor)); -static void RunOnUnload() __attribute__((destructor)); - -// Define them. -void RunOnLoad() { - printf("%s:%s: Entering\n", THIS_LIB_NAME, __FUNCTION__); - sLib = dlopen(LIB_NAME, RTLD_NOW); - if (!sLib) { - fprintf(stderr, "%s:%s: Could not open %s: %s", THIS_LIB_NAME, __FUNCTION__, - LIB_NAME, dlerror()); - return; - } - printf("%s:%s: Found '%s' handle %p\n", THIS_LIB_NAME, __FUNCTION__, LIB_NAME, - sLib); - -#if defined(LIB_SYMBOL) - auto* lib_func = reinterpret_cast<void (*)()>(dlsym(sLib, LIB_SYMBOL)); - if (!lib_func) { - fprintf(stderr, "%s:%s: Could not find '%s' symbol in %s", THIS_LIB_NAME, - __FUNCTION__, LIB_SYMBOL, LIB_NAME); - return; - } - printf("%s:%s: Found '%s' symbol at @%p\n", THIS_LIB_NAME, __FUNCTION__, - LIB_SYMBOL, lib_func); - - // Call it. - (*lib_func)(); -#endif // LIB_SYMBOL - - printf("%s:%s: Exiting\n", THIS_LIB_NAME, __FUNCTION__); -} - -void RunOnUnload() { - printf("%s:%s: Entering\n", THIS_LIB_NAME, __FUNCTION__); - if (sLib) { - int ret = dlclose(sLib); - if (ret != 0) { - fprintf(stderr, "%s:%s: Could not close library: %s", THIS_LIB_NAME, - __FUNCTION__, dlerror()); - } - sLib = NULL; - } - printf("%s:%s: Exiting\n", THIS_LIB_NAME, __FUNCTION__); -} - -extern "C" bool Zoo() { - printf("%s:%s:sLib=%s @ %p\n", THIS_LIB_NAME, __FUNCTION__, LIB_NAME, sLib); - return sLib != NULL; -}
diff --git a/third_party/android_crazy_linker/src/update_auto_generated_sources.sh b/third_party/android_crazy_linker/src/update_auto_generated_sources.sh deleted file mode 100755 index 5726503..0000000 --- a/third_party/android_crazy_linker/src/update_auto_generated_sources.sh +++ /dev/null
@@ -1,27 +0,0 @@ -#!/bin/sh -# Copyright 2018 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# A simple script used to regenerate all sources that are normally -# auto-generated from scripts located under tests/ - -set -e -export LANG=C -export LC_ALL=C - -PROGDIR=$(dirname "$0") -cd "$PROGDIR" - -# Do not run this every time for now, because the script hard-codes the current -# date in each generated archive, making the content change on every call. -# TODO(digit): Fix this. -# tests/generate_zip_test_tables.sh > src/crazy_linker_zip_test_data.cpp - -tests/generate_test_elf_hash_tables.py > \ - src/crazy_linker_elf_hash_table_test_data.h - -tests/generate_test_gnu_hash_tables.py > \ - src/crazy_linker_gnu_hash_table_test_data.h - -echo "Done"
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc index e03ce6b..51cef9c 100644 --- a/third_party/blink/common/features.cc +++ b/third_party/blink/common/features.cc
@@ -892,10 +892,6 @@ "SendCnameAliasesToSubresourceFilterFromRenderer", base::FEATURE_DISABLED_BY_DEFAULT); -BASE_FEATURE(kDisableDocumentDomainByDefault, - "DisableDocumentDomainByDefault", - base::FEATURE_DISABLED_BY_DEFAULT); - // Scopes the memory cache to a fetcher i.e. document/frame. Any resource cached // in the blink cache will only be reused if the most recent fetcher that // fetched it was the same as the current document.
diff --git a/third_party/blink/public/BUILD.gn b/third_party/blink/public/BUILD.gn index 487076c..a681b014 100644 --- a/third_party/blink/public/BUILD.gn +++ b/third_party/blink/public/BUILD.gn
@@ -279,7 +279,6 @@ "platform/websocket_handshake_throttle_provider.h", "web/blink.h", "web/modules/autofill/web_form_element_observer.h", - "web/modules/autofill_assistant/node_signals.h", "web/modules/canvas/canvas_test_utils.h", "web/modules/credentialmanagement/throttle_helper.h", "web/modules/media/audio/audio_device_factory.h",
diff --git a/third_party/blink/public/common/features.h b/third_party/blink/public/common/features.h index 4408bfd..cf59ec74 100644 --- a/third_party/blink/public/common/features.h +++ b/third_party/blink/public/common/features.h
@@ -372,8 +372,6 @@ BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE( kSendCnameAliasesToSubresourceFilterFromRenderer); -BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kDisableDocumentDomainByDefault); - BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kScopeMemoryCachePerContext); BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kEnablePenetratingImageSelection);
diff --git a/third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom b/third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom index 8c8c85419..53561fdb 100644 --- a/third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom +++ b/third_party/blink/public/mojom/permissions_policy/document_policy_feature.mojom
@@ -36,8 +36,8 @@ kJSProfiling = 11, // Controls use of synchronous XMLHTTPRequest API. kSyncXHR = 12, - // Controls access to document.domain attribute. - kDocumentDomain = 13, + // Slot 13 (kDocumentDomain) was removed. Do not re-use its number. + // Don't change assigned numbers of any item, and don't reuse removed slots. // Add new features at the end of the enum. // Also, run update_document_policy_enum.py in
diff --git a/third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom b/third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom index 32643ba..80a0a9d 100644 --- a/third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom +++ b/third_party/blink/public/mojom/permissions_policy/permissions_policy_feature.mojom
@@ -31,8 +31,6 @@ kMidiFeature = 7, // Controls access to PaymentRequest interface. kPayment = 8, - // Controls access to document.domain attribute. - kDocumentDomain = 11, // Controls use of synchronous XMLHTTPRequest API. kSyncXHR = 13, // Controls access to the WebUSB API.
diff --git a/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom b/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom index b22da7d..23ffbef 100644 --- a/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom +++ b/third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom
@@ -3740,6 +3740,8 @@ kV8DocumentPictureInPictureEvent_Window_AttributeGetter = 4399, kDocumentPictureInPictureEnterEvent = 4400, kSoftNavigationHeuristics = 4401, + kMathMLMathElement = 4402, + kMathMLMathElementInDocument = 4403, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/third_party/blink/public/web/modules/autofill_assistant/DIR_METADATA b/third_party/blink/public/web/modules/autofill_assistant/DIR_METADATA deleted file mode 100644 index 2c84cedc..0000000 --- a/third_party/blink/public/web/modules/autofill_assistant/DIR_METADATA +++ /dev/null
@@ -1,3 +0,0 @@ -monorail { - component: "UI>Browser>Autofill>Assistant" -}
diff --git a/third_party/blink/public/web/modules/autofill_assistant/OWNERS b/third_party/blink/public/web/modules/autofill_assistant/OWNERS deleted file mode 100644 index ed6d5f0..0000000 --- a/third_party/blink/public/web/modules/autofill_assistant/OWNERS +++ /dev/null
@@ -1 +0,0 @@ -file://components/autofill_assistant/OWNERS
diff --git a/third_party/blink/public/web/modules/autofill_assistant/README.md b/third_party/blink/public/web/modules/autofill_assistant/README.md deleted file mode 100644 index ef08de4..0000000 --- a/third_party/blink/public/web/modules/autofill_assistant/README.md +++ /dev/null
@@ -1,13 +0,0 @@ -# Node Signals for Autofill Assistant - -## Overview -Autofill Assistant is an execution engine to run user journes on websites -given a set of actions. These actions include clicking on buttons or filling -in a form. - -To provide information for form filling, Autofill Assistant collects node -signals that will be analyzed to understand the node. - -## Contact -The bug component is [UI>Browser>Autofill>Assistant](https://bugs.chromium.org/p/chromium/issues/list?q=component:UI%3EBrowser%3EAutofill%3EAssistant) -and the team email `autofill_assistant@google.com`.
diff --git a/third_party/blink/public/web/modules/autofill_assistant/node_signals.h b/third_party/blink/public/web/modules/autofill_assistant/node_signals.h deleted file mode 100644 index fbc6d43e..0000000 --- a/third_party/blink/public/web/modules/autofill_assistant/node_signals.h +++ /dev/null
@@ -1,64 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_AUTOFILL_ASSISTANT_NODE_SIGNALS_H_ -#define THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_AUTOFILL_ASSISTANT_NODE_SIGNALS_H_ - -#include "third_party/blink/public/platform/web_common.h" -#include "third_party/blink/public/platform/web_string.h" -#include "third_party/blink/public/platform/web_vector.h" -#include "third_party/blink/public/web/web_document.h" - -namespace blink { - -// Features extracted directly from the DOM node of interest. -struct BLINK_MODULES_EXPORT AutofillAssistantNodeFeatures { - // Inner text and other text that is attached to the node and available to - // the user, e.g. input placeholders or select options. - WebVector<WebString> text; - // Aria label, descriptions and placeholders - joined with ' '. Representation - // of this dom element to users with disabilities. This is a strong signal - // that this dom element is relevant to the user. - WebString aria; - // Tag of the dom element. - WebString html_tag; - // Value of the "type" attribute. Only populated for <input> elements. - WebString type; - // Text from the computed attributes "id", "name", "title", "content" and - // "label" - joined with ' '. - WebString invisible_attributes; -}; - -// Features extracted from labels that are directly related to the DOM node of -// interest. -struct BLINK_MODULES_EXPORT AutofillAssistantLabelFeatures { - // Text of the label. - WebVector<WebString> text; -}; - -// Features extracted from DOM nodes that are loosely related to the DOM node -// of interest, e.g. headers. -struct BLINK_MODULES_EXPORT AutofillAssistantContextFeatures { - // Text of headers. - WebVector<WebString> header_text; - // Form the element is part of. - WebString form_type; -}; - -struct BLINK_MODULES_EXPORT AutofillAssistantNodeSignals { - AutofillAssistantNodeFeatures node_features; - AutofillAssistantLabelFeatures label_features; - AutofillAssistantContextFeatures context_features; - - // Stable ID for this element. This is the DOMNodeIds assigned to this node - // which corresponds to the BackendNodeId in DevTools. - int32_t backend_node_id; -}; - -BLINK_MODULES_EXPORT WebVector<AutofillAssistantNodeSignals> -GetAutofillAssistantNodeSignals(const WebDocument& web_document); - -} // namespace blink - -#endif // THIRD_PARTY_BLINK_PUBLIC_WEB_MODULES_AUTOFILL_ASSISTANT_NODE_SIGNALS_H_
diff --git a/third_party/blink/renderer/bindings/bindings.gni b/third_party/blink/renderer/bindings/bindings.gni index 7bc66f82..e6ed65d 100644 --- a/third_party/blink/renderer/bindings/bindings.gni +++ b/third_party/blink/renderer/bindings/bindings.gni
@@ -128,17 +128,19 @@ "core/v8/serialization/v8_script_value_deserializer.h", "core/v8/serialization/v8_script_value_serializer.cc", "core/v8/serialization/v8_script_value_serializer.h", + "core/v8/shadow_realm_context.cc", + "core/v8/shadow_realm_context.h", "core/v8/to_v8_for_core.h", "core/v8/to_v8_traits.h", "core/v8/use_counter_callback.cc", "core/v8/use_counter_callback.h", "core/v8/v8_binding_for_core.cc", "core/v8/v8_binding_for_core.h", - "core/v8/v8_ctype_traits.h", "core/v8/v8_code_cache.cc", "core/v8/v8_code_cache.h", "core/v8/v8_context_snapshot.cc", "core/v8/v8_context_snapshot.h", + "core/v8/v8_ctype_traits.h", "core/v8/v8_embedder_graph_builder.cc", "core/v8/v8_embedder_graph_builder.h", "core/v8/v8_event_listener_info.h", @@ -190,12 +192,12 @@ "modules/v8/module_bindings_initializer.h", "modules/v8/serialization/serialized_script_value_for_modules_factory.cc", "modules/v8/serialization/serialized_script_value_for_modules_factory.h", + "modules/v8/serialization/serialized_track_params.cc", + "modules/v8/serialization/serialized_track_params.h", "modules/v8/serialization/v8_script_value_deserializer_for_modules.cc", "modules/v8/serialization/v8_script_value_deserializer_for_modules.h", "modules/v8/serialization/v8_script_value_serializer_for_modules.cc", "modules/v8/serialization/v8_script_value_serializer_for_modules.h", - "modules/v8/serialization/serialized_track_params.cc", - "modules/v8/serialization/serialized_track_params.h", "modules/v8/to_v8_for_modules.h", "modules/v8/v8_binding_for_modules.cc", "modules/v8/v8_binding_for_modules.h", @@ -210,11 +212,11 @@ [ "core/v8/activity_logger_test.cc", "core/v8/binding_security_test.cc", + "core/v8/boxed_v8_module_test.cc", "core/v8/dictionary_test.cc", "core/v8/dom_wrapper_world_test.cc", "core/v8/idl_types_test.cc", "core/v8/module_record_test.cc", - "core/v8/boxed_v8_module_test.cc", "core/v8/native_value_traits_impl_test.cc", "core/v8/native_value_traits_test.cc", "core/v8/no_alloc_direct_call_host_test.cc", @@ -224,24 +226,24 @@ "core/v8/script_promise_resolver_test.cc", "core/v8/script_promise_result_tracker_test.cc", "core/v8/script_promise_test.cc", + "core/v8/script_promise_tester.cc", + "core/v8/script_promise_tester.h", "core/v8/script_streamer_test.cc", "core/v8/script_wrappable_v8_gc_integration_test.cc", - "core/v8/to_v8_test.cc", - "core/v8/to_v8_traits_test.cc", - "core/v8/trace_wrapper_v8_reference_test.cc", - "core/v8/v8_binding_for_testing.cc", - "core/v8/v8_binding_for_testing.h", - "core/v8/window_proxy_test.cc", - "core/v8/world_safe_v8_reference_test.cc", - "core/v8/v8_object_builder_test.cc", - "core/v8/v8_script_runner_test.cc", "core/v8/serialization/serialized_script_value_test.cc", "core/v8/serialization/serialized_script_value_threaded_test.cc", "core/v8/serialization/trailer_reader_test.cc", "core/v8/serialization/trailer_writer_test.cc", "core/v8/serialization/v8_script_value_serializer_test.cc", - "core/v8/script_promise_tester.cc", - "core/v8/script_promise_tester.h", + "core/v8/to_v8_test.cc", + "core/v8/to_v8_traits_test.cc", + "core/v8/trace_wrapper_v8_reference_test.cc", + "core/v8/v8_binding_for_testing.cc", + "core/v8/v8_binding_for_testing.h", + "core/v8/v8_object_builder_test.cc", + "core/v8/v8_script_runner_test.cc", + "core/v8/window_proxy_test.cc", + "core/v8/world_safe_v8_reference_test.cc", "modules/v8/serialization/v8_script_value_serializer_for_modules_test.cc", "modules/v8/v8_binding_for_modules_test.cc", "modules/v8/v8_element_test.cc",
diff --git a/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.cc b/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.cc new file mode 100644 index 0000000..83e2fca --- /dev/null +++ b/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.cc
@@ -0,0 +1,65 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/bindings/core/v8/shadow_realm_context.h" + +#include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h" +#include "third_party/blink/renderer/platform/bindings/script_state.h" +#include "third_party/blink/renderer/platform/bindings/v8_dom_wrapper.h" +#include "third_party/blink/renderer/platform/bindings/v8_per_context_data.h" +#include "v8/include/v8-context.h" + +namespace blink { + +v8::MaybeLocal<v8::Context> OnCreateShadowRealmV8Context( + v8::Local<v8::Context> initiator_context) { + ExecutionContext* initiator_execution_context = + ExecutionContext::From(initiator_context); + DCHECK(initiator_execution_context); + v8::Isolate* isolate = initiator_context->GetIsolate(); + scoped_refptr<DOMWrapperWorld> world = DOMWrapperWorld::Create( + isolate, DOMWrapperWorld::WorldType::kShadowRealm); + CHECK(world); // Not yet run out of the world id. + + // Create a new ShadowRealmGlobalScope. + ShadowRealmGlobalScope* shadow_realm_global_scope = + MakeGarbageCollected<ShadowRealmGlobalScope>(initiator_execution_context); + const WrapperTypeInfo* wrapper_type_info = + shadow_realm_global_scope->GetWrapperTypeInfo(); + + // Create a new v8::Context. + v8::ExtensionConfiguration* extension_configuration = nullptr; + v8::Local<v8::ObjectTemplate> global_template = + wrapper_type_info->GetV8ClassTemplate(isolate, *world) + .As<v8::FunctionTemplate>() + ->InstanceTemplate(); + v8::Local<v8::Object> global_proxy; // Will request a new global proxy. + v8::Local<v8::Context> context = + v8::Context::New(isolate, extension_configuration, global_template, + global_proxy, v8::DeserializeInternalFieldsCallback(), + initiator_execution_context->GetMicrotaskQueue()); + context->UseDefaultSecurityToken(); + + // Associate the Blink object with the v8::Context. + ScriptState* script_state = MakeGarbageCollected<ScriptState>( + context, world, shadow_realm_global_scope); + + // Associate the Blink object with the v8::Objects. + global_proxy = context->Global(); + V8DOMWrapper::SetNativeInfo(isolate, global_proxy, wrapper_type_info, + shadow_realm_global_scope); + v8::Local<v8::Object> global_object = + global_proxy->GetPrototype().As<v8::Object>(); + V8DOMWrapper::SetNativeInfo(isolate, global_object, wrapper_type_info, + shadow_realm_global_scope); + + // Install context-dependent properties. + std::ignore = + script_state->PerContextData()->ConstructorForType(wrapper_type_info); + + return context; +} + +} // namespace blink
diff --git a/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.h b/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.h new file mode 100644 index 0000000..a98ebe8 --- /dev/null +++ b/third_party/blink/renderer/bindings/core/v8/shadow_realm_context.h
@@ -0,0 +1,21 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SHADOW_REALM_CONTEXT_H_ +#define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SHADOW_REALM_CONTEXT_H_ + +#include "v8/include/v8-forward.h" + +namespace blink { + +// The callback function to be registered to a v8::Isolate via +// v8::Isolate::SetHostCreateShadowRealmContextCallback. This callback function +// is called at each time when JS code runs "new ShadowRealm()". +// `initiator_context` is the v8::Context which runs "new ShadowRealm()". +v8::MaybeLocal<v8::Context> OnCreateShadowRealmV8Context( + v8::Local<v8::Context> initiator_context); + +} // namespace blink + +#endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_SHADOW_REALM_CONTEXT_H_
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.cc b/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.cc index 938c111..8b933d9 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.cc
@@ -41,8 +41,6 @@ #include "third_party/blink/renderer/bindings/core/v8/v8_object_builder.h" #include "third_party/blink/renderer/bindings/core/v8/v8_script_runner.h" #include "third_party/blink/renderer/bindings/core/v8/v8_window.h" -#include "third_party/blink/renderer/bindings/core/v8/v8_worker_global_scope.h" -#include "third_party/blink/renderer/bindings/core/v8/v8_worklet_global_scope.h" #include "third_party/blink/renderer/bindings/core/v8/v8_xpath_ns_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/window_proxy.h" #include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h" @@ -55,6 +53,7 @@ #include "third_party/blink/renderer/core/frame/settings.h" #include "third_party/blink/renderer/core/inspector/inspector_trace_events.h" #include "third_party/blink/renderer/core/loader/frame_loader.h" +#include "third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h" #include "third_party/blink/renderer/core/typed_arrays/flexible_array_buffer_view.h" #include "third_party/blink/renderer/core/workers/worker_global_scope.h" #include "third_party/blink/renderer/core/workers/worker_or_worklet_global_scope.h" @@ -696,13 +695,15 @@ if (global_proxy->InternalFieldCount() == 0) return nullptr; - const WrapperTypeInfo* wrapper_type_info = ToWrapperTypeInfo(global_proxy); - if (wrapper_type_info->Equals(V8Window::GetWrapperTypeInfo())) - return V8Window::ToImpl(global_proxy)->GetExecutionContext(); - if (wrapper_type_info->IsSubclass(V8WorkerGlobalScope::GetWrapperTypeInfo())) - return V8WorkerGlobalScope::ToImpl(global_proxy)->GetExecutionContext(); - if (wrapper_type_info->IsSubclass(V8WorkletGlobalScope::GetWrapperTypeInfo())) - return V8WorkletGlobalScope::ToImpl(global_proxy)->GetExecutionContext(); + ScriptWrappable::TypeDispatcher dispatcher(ToScriptWrappable(global_proxy)); + if (auto* x = dispatcher.ToMostDerived<DOMWindow>()) + return x->GetExecutionContext(); + if (auto* x = dispatcher.DowncastTo<WorkerGlobalScope>()) + return x->GetExecutionContext(); + if (auto* x = dispatcher.DowncastTo<WorkletGlobalScope>()) + return x->GetExecutionContext(); + if (auto* x = dispatcher.ToMostDerived<ShadowRealmGlobalScope>()) + return x->GetExecutionContext(); NOTREACHED(); return nullptr;
diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc index c796f63..a2138e7b 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc
@@ -46,6 +46,7 @@ #include "third_party/blink/renderer/bindings/core/v8/script_controller.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/bindings/core/v8/script_value.h" +#include "third_party/blink/renderer/bindings/core/v8/shadow_realm_context.h" #include "third_party/blink/renderer/bindings/core/v8/use_counter_callback.h" #include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h" #include "third_party/blink/renderer/bindings/core/v8/v8_context_snapshot.h" @@ -874,6 +875,9 @@ // is enabled. For that reason, the partition can only be initialized after V8 // has been initialized. WTF::Partitions::InitializeArrayBufferPartition(); + + isolate->SetHostCreateShadowRealmContextCallback( + OnCreateShadowRealmV8Context); } // Stack size for workers is limited to 500KB because default stack size for
diff --git a/third_party/blink/renderer/bindings/generated_in_core.gni b/third_party/blink/renderer/bindings/generated_in_core.gni index c74e88d..7597d834 100644 --- a/third_party/blink/renderer/bindings/generated_in_core.gni +++ b/third_party/blink/renderer/bindings/generated_in_core.gni
@@ -1253,6 +1253,8 @@ "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_selection.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_selector_directive.cc", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_selector_directive.h", + "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_shadow_realm_global_scope.cc", + "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_shadow_realm_global_scope.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_shadow_root.cc", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_shadow_root.h", "$root_gen_dir/third_party/blink/renderer/bindings/core/v8/v8_shared_worker.cc",
diff --git a/third_party/blink/renderer/bindings/idl_in_core.gni b/third_party/blink/renderer/bindings/idl_in_core.gni index af3ddc5..92bc534 100644 --- a/third_party/blink/renderer/bindings/idl_in_core.gni +++ b/third_party/blink/renderer/bindings/idl_in_core.gni
@@ -532,6 +532,7 @@ "//third_party/blink/renderer/core/resize_observer/resize_observer_entry.idl", "//third_party/blink/renderer/core/resize_observer/resize_observer_options.idl", "//third_party/blink/renderer/core/resize_observer/resize_observer_size.idl", + "//third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.idl", "//third_party/blink/renderer/core/streams/byte_length_queuing_strategy.idl", "//third_party/blink/renderer/core/streams/count_queuing_strategy.idl", "//third_party/blink/renderer/core/streams/queuing_strategy_init.idl",
diff --git a/third_party/blink/renderer/controller/performance_manager/renderer_resource_coordinator_impl.cc b/third_party/blink/renderer/controller/performance_manager/renderer_resource_coordinator_impl.cc index d1f49c2..1e01e62 100644 --- a/third_party/blink/renderer/controller/performance_manager/renderer_resource_coordinator_impl.cc +++ b/third_party/blink/renderer/controller/performance_manager/renderer_resource_coordinator_impl.cc
@@ -172,6 +172,9 @@ case DOMWrapperWorld::WorldType::kWorker: { v8_desc->world_type = V8ContextWorldType::kWorkerOrWorklet; } break; + case DOMWrapperWorld::WorldType::kShadowRealm: { + v8_desc->world_type = V8ContextWorldType::kShadowRealm; + } break; } if (execution_context) {
diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn index 2a958f9..f16b64b 100644 --- a/third_party/blink/renderer/core/BUILD.gn +++ b/third_party/blink/renderer/core/BUILD.gn
@@ -1356,6 +1356,7 @@ "intersection_observer") sources += rebase_path(blink_core_tests_layout, "", "layout") sources += rebase_path(blink_core_tests_loader, "", "loader") + sources += rebase_path(blink_core_tests_mathml, "", "mathml") sources += rebase_path(blink_core_tests_messaging, "", "messaging") sources += rebase_path(blink_core_tests_mobile_metrics, "", "mobile_metrics") sources += rebase_path(blink_core_tests_navigation_api, "", "navigation_api")
diff --git a/third_party/blink/renderer/core/animation/css/css_animations.cc b/third_party/blink/renderer/core/animation/css/css_animations.cc index c05c7468..08b0c2b 100644 --- a/third_party/blink/renderer/core/animation/css/css_animations.cc +++ b/third_party/blink/renderer/core/animation/css/css_animations.cc
@@ -70,6 +70,7 @@ #include "third_party/blink/renderer/core/css/style_engine.h" #include "third_party/blink/renderer/core/dom/element.h" #include "third_party/blink/renderer/core/dom/events/event_path.h" +#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h" #include "third_party/blink/renderer/core/dom/node_computed_style.h" #include "third_party/blink/renderer/core/dom/pseudo_element.h" #include "third_party/blink/renderer/core/dom/shadow_root.h" @@ -617,9 +618,11 @@ if (ScrollTimeline* timeline = FindTimelineForNode(name, node, update)) return timeline; - // TODO(crbug.com/1356098): Use flat-tree siblings. - for (Node* prev = node->previousSibling(); prev; - prev = prev->previousSibling()) { + // We use LayoutTreeBuilderTraversal to skip siblings which are not in the + // flat tree, because they don't have a ComputedStyle (and therefore can't + // provide any timelines). + for (Node* prev = LayoutTreeBuilderTraversal::PreviousSibling(*node); prev; + prev = LayoutTreeBuilderTraversal::PreviousSibling(*prev)) { if (ScrollTimeline* timeline = FindTimelineForNode(name, prev, GetPendingAnimationUpdate(*prev))) { return timeline;
diff --git a/third_party/blink/renderer/core/css/parser/font_variant_alternates_parser.cc b/third_party/blink/renderer/core/css/parser/font_variant_alternates_parser.cc index fdc6a0f..7c55358 100644 --- a/third_party/blink/renderer/core/css/parser/font_variant_alternates_parser.cc +++ b/third_party/blink/renderer/core/css/parser/font_variant_alternates_parser.cc
@@ -59,6 +59,8 @@ if (!value_to_set) return false; + bool multiple_idents_allowed = + peek == CSSValueID::kStyleset || peek == CSSValueID::kCharacterVariant; CSSFunctionValue* function_value = MakeGarbageCollected<CSSFunctionValue>(peek); CSSParserTokenRange range_copy = range; @@ -67,6 +69,9 @@ ConsumeCommaSeparatedList(ConsumeCustomIdent, inner, context); if (!inner.AtEnd()) return false; + if (aliases->length() > 1 && !multiple_idents_allowed) { + return false; + } range = range_copy; *value_to_set = MakeGarbageCollected<cssvalue::CSSAlternateValue>( *function_value, *aliases);
diff --git a/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc b/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc index faf19bc..28f6296 100644 --- a/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc +++ b/third_party/blink/renderer/core/css/resolver/scoped_style_resolver.cc
@@ -288,9 +288,6 @@ } void ScopedStyleResolver::AddPositionFallbackRules(const RuleSet& rule_set) { - // TODO(crbug.com/1381623): Support @position-fallback rules in shadow DOM. - if (!GetTreeScope().RootNode().IsDocumentNode()) - return; // TODO(crbug.com/1309178): Reorder @position-fallback rules according to // cascade layers. for (StyleRulePositionFallback* rule : rule_set.PositionFallbackRules())
diff --git a/third_party/blink/renderer/core/css/resolver/style_resolver.cc b/third_party/blink/renderer/core/css/resolver/style_resolver.cc index eab74803..23cf4f07 100644 --- a/third_party/blink/renderer/core/css/resolver/style_resolver.cc +++ b/third_party/blink/renderer/core/css/resolver/style_resolver.cc
@@ -2643,31 +2643,39 @@ Element& element, unsigned index) { const ComputedStyle& base_style = element.ComputedStyleRef(); - // TODO(crbug.com/1309178): Support tree-scoped fallback name lookup. - DCHECK(base_style.PositionFallback()); - StyleRulePositionFallback* position_fallback_rule = - GetDocument().GetScopedStyleResolver()->PositionFallbackForName( - base_style.PositionFallback()->GetName()); - if (!position_fallback_rule || - index >= position_fallback_rule->TryRules().size()) - return nullptr; - StyleRuleTry* try_rule = position_fallback_rule->TryRules()[index]; - StyleResolverState state(GetDocument(), element); - state.SetStyle(ComputedStyle::Clone(base_style)); - const CSSPropertyValueSet& properties = try_rule->Properties(); + const ScopedCSSName* position_fallback = base_style.PositionFallback(); + DCHECK(position_fallback); - STACK_UNINITIALIZED StyleCascade cascade(state); - cascade.MutableMatchResult().FinishAddingUARules(); - cascade.MutableMatchResult().FinishAddingUserRules(); - cascade.MutableMatchResult().FinishAddingPresentationalHints(); - cascade.MutableMatchResult().AddMatchedProperties(&properties); - // TODO(crbug.com/1381623): Pass proper TreeScope here once @position-fallback - // is supported in ShadowDOM. - cascade.MutableMatchResult().FinishAddingAuthorRulesForTreeScope( - GetDocument()); - cascade.Apply(); + const TreeScope* tree_scope = position_fallback->GetTreeScope(); + if (!tree_scope) + tree_scope = &GetDocument(); - return state.TakeStyle(); + for (; tree_scope; tree_scope = tree_scope->ParentTreeScope()) { + if (ScopedStyleResolver* resolver = tree_scope->GetScopedStyleResolver()) { + StyleRulePositionFallback* position_fallback_rule = + resolver->PositionFallbackForName(position_fallback->GetName()); + if (!position_fallback_rule) + continue; + if (index >= position_fallback_rule->TryRules().size()) + return nullptr; + StyleRuleTry* try_rule = position_fallback_rule->TryRules()[index]; + StyleResolverState state(GetDocument(), element); + state.SetStyle(ComputedStyle::Clone(base_style)); + const CSSPropertyValueSet& properties = try_rule->Properties(); + + STACK_UNINITIALIZED StyleCascade cascade(state); + cascade.MutableMatchResult().FinishAddingUARules(); + cascade.MutableMatchResult().FinishAddingUserRules(); + cascade.MutableMatchResult().FinishAddingPresentationalHints(); + cascade.MutableMatchResult().AddMatchedProperties(&properties); + cascade.MutableMatchResult().FinishAddingAuthorRulesForTreeScope( + *tree_scope); + cascade.Apply(); + + return state.TakeStyle(); + } + } + return nullptr; } } // namespace blink
diff --git a/third_party/blink/renderer/core/css/style_engine_test.cc b/third_party/blink/renderer/core/css/style_engine_test.cc index 3afd929..89ee10f9 100644 --- a/third_party/blink/renderer/core/css/style_engine_test.cc +++ b/third_party/blink/renderer/core/css/style_engine_test.cc
@@ -6130,4 +6130,42 @@ checkBorderWidth(1.0f); } +TEST_F(StyleEngineTest, SubsequentSiblingRecalcFlatTree) { + GetDocument() + .documentElement() + ->setInnerHTMLWithDeclarativeShadowDOMForTesting(R"HTML( + <div id="host"> + <template shadowroot=open> + <slot name=a></slot> + </template> + <div slot=a id=target></div> + <div></div> + <div></div> + <div></div> + <div></div> + <div slot=a></div> + <div></div> + <div></div> + <div></div> + <div></div> + <div slot=a></div> + </div> + )HTML"); + + UpdateAllLifecyclePhasesForTest(); + + unsigned before_count = GetStyleEngine().StyleForElementCount(); + + Element* target = GetElementById("target"); + ASSERT_TRUE(target); + + target->SetInlineStyleProperty(CSSPropertyID::kScrollTimelineName, "foo"); + UpdateAllLifecyclePhasesForTest(); + + unsigned after_count = GetStyleEngine().StyleForElementCount(); + + // Only the slotted elements should get style recalc. + EXPECT_EQ(3u, after_count - before_count); +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/dom/container_node.cc b/third_party/blink/renderer/core/dom/container_node.cc index 00994f3..32c67de1d 100644 --- a/third_party/blink/renderer/core/dom/container_node.cc +++ b/third_party/blink/renderer/core/dom/container_node.cc
@@ -33,6 +33,7 @@ #include "third_party/blink/renderer/core/dom/element_traversal.h" #include "third_party/blink/renderer/core/dom/events/event_dispatch_forbidden_scope.h" #include "third_party/blink/renderer/core/dom/events/scoped_event_queue.h" +#include "third_party/blink/renderer/core/dom/layout_tree_builder_traversal.h" #include "third_party/blink/renderer/core/dom/name_node_list.h" #include "third_party/blink/renderer/core/dom/node_child_removal_tracker.h" #include "third_party/blink/renderer/core/dom/node_computed_style.h" @@ -1394,9 +1395,11 @@ DCHECK(GetDocument().InStyleRecalc()); DCHECK(!NeedsStyleRecalc()); - // TODO(crbug.com/1356098): Use flat-tree siblings. - for (Node* sibling = nextSibling(); sibling; - sibling = sibling->nextSibling()) { + // We use LayoutTreeBuilderTraversal to skip siblings which are not in the + // flat tree, because they don't have a ComputedStyle (and are therefore not + // affected by any change on this node). + for (Node* sibling = LayoutTreeBuilderTraversal::NextSibling(*this); sibling; + sibling = LayoutTreeBuilderTraversal::NextSibling(*sibling)) { if (auto* sibling_element = DynamicTo<Element>(sibling)) { sibling_element->RecalcStyle(change, style_recalc_context); }
diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc index 01799db..3de90d3 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc
@@ -5868,23 +5868,6 @@ return; } - const String permissions_policy_error = - "Setting `document.domain` is disabled by permissions policy."; - if (!dom_window_->IsFeatureEnabled( - mojom::blink::PermissionsPolicyFeature::kDocumentDomain, - ReportOptions::kReportOnFailure, permissions_policy_error)) { - exception_state.ThrowSecurityError(permissions_policy_error); - return; - } - - const String document_policy_error = - "Setting `document.domain` is disabled by document policy."; - if (!dom_window_->IsFeatureEnabled( - mojom::blink::DocumentPolicyFeature::kDocumentDomain, - ReportOptions::kReportOnFailure, document_policy_error)) { - return; - } - if (SchemeRegistry::IsDomainRelaxationForbiddenForURLScheme( dom_window_->GetSecurityOrigin()->Protocol())) { exception_state.ThrowSecurityError(
diff --git a/third_party/blink/renderer/core/dom/element.cc b/third_party/blink/renderer/core/dom/element.cc index 3c66539..5dfdab5 100644 --- a/third_party/blink/renderer/core/dom/element.cc +++ b/third_party/blink/renderer/core/dom/element.cc
@@ -3136,6 +3136,9 @@ DCHECK(!GetDocument().Lifecycle().InDetach()); DCHECK(!GetForceReattachLayoutTree() || GetComputedStyle()) << "No need to force a layout tree reattach if we had no computed style"; + DCHECK(LayoutTreeBuilderTraversal::ParentElement(*this) || + this == GetDocument().documentElement()) + << "No recalc for Elements outside flat tree"; DisplayLockStyleScope display_lock_style_scope(this); if (HasCustomStyleCallbacks())
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc index ff099e53..7aab5f3 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_model_object.cc
@@ -46,7 +46,7 @@ bool LayoutSVGModelObject::IsChildAllowed(LayoutObject* child, const ComputedStyle&) const { NOT_DESTROYED(); - return child->IsSVG() && !(child->IsSVGInline() || child->IsSVGInlineText()); + return SVGContentContainer::IsChildAllowed(*child); } void LayoutSVGModelObject::MapLocalToAncestor(
diff --git a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc index e3732cc..52cf32e 100644 --- a/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc +++ b/third_party/blink/renderer/core/layout/svg/layout_svg_root.cc
@@ -384,7 +384,7 @@ bool LayoutSVGRoot::IsChildAllowed(LayoutObject* child, const ComputedStyle&) const { NOT_DESTROYED(); - return child->IsSVG() && !(child->IsSVGInline() || child->IsSVGInlineText()); + return SVGContentContainer::IsChildAllowed(*child); } void LayoutSVGRoot::AddChild(LayoutObject* child, LayoutObject* before_child) {
diff --git a/third_party/blink/renderer/core/layout/svg/svg_content_container.cc b/third_party/blink/renderer/core/layout/svg/svg_content_container.cc index 1efeb09..2c64d744 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_content_container.cc +++ b/third_party/blink/renderer/core/layout/svg/svg_content_container.cc
@@ -33,6 +33,27 @@ marker->LayoutIfNeeded(); } +// static +bool SVGContentContainer::IsChildAllowed(const LayoutObject& child) { + // https://svgwg.org/svg2-draft/struct.html#ForeignNamespaces + // the SVG user agent must include the unknown foreign-namespaced elements + // in the DOM but will ignore and exclude them for rendering purposes. + if (!child.IsSVG()) + return false; + if (child.IsSVGInline() || child.IsSVGInlineText()) + return false; + // The above IsSVG() check is not enough for foreign elements with + // `display: contents`. We ignore SVG descendants in a foreign element. + if (RuntimeEnabledFeatures:: + SvgContainersRejectSvgInDisplayContentsEnabled()) { + if (const Node* node = child.GetNode()) { + if (const Element* parent_element = node->parentElement()) + return parent_element->IsSVGElement(); + } + } + return true; +} + void SVGContentContainer::Layout(const SVGContainerLayoutInfo& layout_info) { for (LayoutObject* child = children_.FirstChild(); child; child = child->NextSibling()) { @@ -83,6 +104,7 @@ if (child->IsSVGResourceContainer()) { child->LayoutIfNeeded(); } else { + DCHECK(!child->IsSVGRoot()); SubtreeLayoutScope layout_scope(*child); if (force_child_layout) { layout_scope.SetNeedsLayout(child,
diff --git a/third_party/blink/renderer/core/layout/svg/svg_content_container.h b/third_party/blink/renderer/core/layout/svg/svg_content_container.h index 9fc4529..bca495b 100644 --- a/third_party/blink/renderer/core/layout/svg/svg_content_container.h +++ b/third_party/blink/renderer/core/layout/svg/svg_content_container.h
@@ -28,6 +28,7 @@ DISALLOW_NEW(); public: + static bool IsChildAllowed(const LayoutObject& child); void Layout(const SVGContainerLayoutInfo&); bool HitTest(HitTestResult&, const HitTestLocation&, HitTestPhase) const;
diff --git a/third_party/blink/renderer/core/mathml/build.gni b/third_party/blink/renderer/core/mathml/build.gni index 3e6d403..96d10c61 100644 --- a/third_party/blink/renderer/core/mathml/build.gni +++ b/third_party/blink/renderer/core/mathml/build.gni
@@ -24,3 +24,5 @@ "mathml_under_over_element.cc", "mathml_under_over_element.h", ] + +blink_core_tests_mathml = [ "mathml_use_counters_test.cc" ]
diff --git a/third_party/blink/renderer/core/mathml/mathml_row_element.cc b/third_party/blink/renderer/core/mathml/mathml_row_element.cc index 51bfeeb..c335d7f 100644 --- a/third_party/blink/renderer/core/mathml/mathml_row_element.cc +++ b/third_party/blink/renderer/core/mathml/mathml_row_element.cc
@@ -5,6 +5,7 @@ #include "third_party/blink/renderer/core/mathml/mathml_row_element.h" #include "third_party/blink/renderer/core/dom/element_traversal.h" +#include "third_party/blink/renderer/core/frame/web_feature.h" #include "third_party/blink/renderer/core/layout/ng/mathml/layout_ng_mathml_block.h" #include "third_party/blink/renderer/core/mathml/mathml_operator_element.h" #include "third_party/blink/renderer/platform/runtime_enabled_features.h" @@ -13,7 +14,11 @@ MathMLRowElement::MathMLRowElement(const QualifiedName& tagName, Document& document) - : MathMLElement(tagName, document) {} + : MathMLElement(tagName, document) { + if (HasTagName(mathml_names::kMathTag)) { + UseCounter::Count(document, WebFeature::kMathMLMathElement); + } +} LayoutObject* MathMLRowElement::CreateLayoutObject(const ComputedStyle& style, LegacyLayout legacy) { @@ -34,4 +39,12 @@ MathMLElement::ChildrenChanged(change); } +Node::InsertionNotificationRequest MathMLRowElement::InsertedInto( + ContainerNode& root_parent) { + if (HasTagName(mathml_names::kMathTag) && root_parent.isConnected()) { + UseCounter::Count(GetDocument(), WebFeature::kMathMLMathElementInDocument); + } + return MathMLElement::InsertedInto(root_parent); +} + } // namespace blink
diff --git a/third_party/blink/renderer/core/mathml/mathml_row_element.h b/third_party/blink/renderer/core/mathml/mathml_row_element.h index d7a9396..1a3c493 100644 --- a/third_party/blink/renderer/core/mathml/mathml_row_element.h +++ b/third_party/blink/renderer/core/mathml/mathml_row_element.h
@@ -22,6 +22,7 @@ private: LayoutObject* CreateLayoutObject(const ComputedStyle&, LegacyLayout legacy) override; + InsertionNotificationRequest InsertedInto(ContainerNode&) final; bool IsGroupingElement() const override { return true; } };
diff --git a/third_party/blink/renderer/core/mathml/mathml_use_counters_test.cc b/third_party/blink/renderer/core/mathml/mathml_use_counters_test.cc new file mode 100644 index 0000000..3d0c48e --- /dev/null +++ b/third_party/blink/renderer/core/mathml/mathml_use_counters_test.cc
@@ -0,0 +1,95 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#include "build/build_config.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/core/dom/element.h" +#include "third_party/blink/renderer/core/testing/page_test_base.h" +#include "third_party/blink/renderer/core/testing/sim/sim_compositor.h" +#include "third_party/blink/renderer/core/testing/sim/sim_request.h" +#include "third_party/blink/renderer/core/testing/sim/sim_test.h" +#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" +#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" + +namespace blink { + +class MathMLUseCountersTest : public SimTest { + public: + MathMLUseCountersTest() = default; + + protected: + void LoadPage(const String& source) { + SimRequest main_resource("https://example.com/", "text/html"); + LoadURL("https://example.com/"); + main_resource.Complete(source); + Compositor().BeginFrame(); + test::RunPendingTasks(); + } + + void LoadPageWithDynamicMathML(const String& tagName, bool insertInBody) { + StringBuilder source; + source.Append( + "<body>" + "<script>" + "let element = document.createElementNS(" + "'http://www.w3.org/1998/Math/MathML', '"); + source.Append(tagName); + source.Append("');"); + if (insertInBody) { + source.Append("document.body.appendChild(element);"); + } + source.Append( + "</script>" + "</body>"); + LoadPage(source.ToString()); + } +}; + +TEST_F(MathMLUseCountersTest, MathMLUseCountersTest_NoMath) { + // kMathML* counters not set for pages without MathML content. + LoadPage("<body>Hello World!</body>"); + ASSERT_FALSE(GetDocument().IsUseCounted(WebFeature::kMathMLMathElement)); + ASSERT_FALSE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); +} + +TEST_F(MathMLUseCountersTest, MathMLUseCountersTest_MinimalMath) { + // kMathMLMath* counters set for a minimal page containing an empty math tag. + LoadPage("<math></math>"); + ASSERT_TRUE(GetDocument().IsUseCounted(WebFeature::kMathMLMathElement)); + ASSERT_TRUE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); +} + +TEST_F(MathMLUseCountersTest, MathMLUseCountersTest_HTMLAndBasicMath) { + // kMathMLMath* counters set for a HTML page with some basic MathML formula. + LoadPage( + "<!DOCTYPE>" + "<body>" + "<p>" + "<math><mfrac><msqrt><mn>2</mn></msqrt><mi>x</mi></mfrac></math>" + "</p>" + "</body>"); + ASSERT_TRUE(GetDocument().IsUseCounted(WebFeature::kMathMLMathElement)); + ASSERT_TRUE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); +} + +TEST_F(MathMLUseCountersTest, MathMLUseCountersTest_DynamicMath) { + // kMathMLMath* counters not set for a MathML element other that <math>. + LoadPageWithDynamicMathML("mrow", true /* insertInBody */); + ASSERT_FALSE(GetDocument().IsUseCounted(WebFeature::kMathMLMathElement)); + ASSERT_FALSE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); + + // Distinguish kMathMLMathElement and kMathMLMathElementInDocument + LoadPageWithDynamicMathML("math", false /* insertInBody */); + ASSERT_TRUE(GetDocument().IsUseCounted(WebFeature::kMathMLMathElement)); + ASSERT_FALSE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); + LoadPageWithDynamicMathML("math", true /* insertInBody */); + ASSERT_TRUE( + GetDocument().IsUseCounted(WebFeature::kMathMLMathElementInDocument)); +} + +} // namespace blink
diff --git a/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc b/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc index 3e73b94..cae93c4 100644 --- a/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc +++ b/third_party/blink/renderer/core/paint/cull_rect_updater_test.cc
@@ -595,7 +595,7 @@ GetDocument().getElementById("div")); // This should not crash. UpdateAllLifecyclePhasesForTest(); - EXPECT_TRUE(GetCullRect("svg1").Rect().IsEmpty()); + EXPECT_FALSE(GetLayoutObjectByElementId("svg1")); } TEST_P(CullRectUpdaterTest, PerspectiveDescendants) {
diff --git a/third_party/blink/renderer/core/paint/old_cull_rect_updater_test.cc b/third_party/blink/renderer/core/paint/old_cull_rect_updater_test.cc index a5f066f..368634b 100644 --- a/third_party/blink/renderer/core/paint/old_cull_rect_updater_test.cc +++ b/third_party/blink/renderer/core/paint/old_cull_rect_updater_test.cc
@@ -223,7 +223,7 @@ GetDocument().getElementById("div")); // This should not crash. UpdateAllLifecyclePhasesForTest(); - EXPECT_TRUE(GetCullRect("svg1").Rect().IsEmpty()); + EXPECT_FALSE(GetLayoutObjectByElementId("svg1")); } TEST_P(OldCullRectUpdaterTest, PerspectiveDescendants) {
diff --git a/third_party/blink/renderer/core/permissions_policy/document_policy_features.json5 b/third_party/blink/renderer/core/permissions_policy/document_policy_features.json5 index 372d64d..9947f0d 100644 --- a/third_party/blink/renderer/core/permissions_policy/document_policy_features.json5 +++ b/third_party/blink/renderer/core/permissions_policy/document_policy_features.json5
@@ -141,16 +141,6 @@ value_type: "Bool", default_value: "true", depends_on: ["DocumentPolicySyncXHR"], - }, - { - name: "DocumentDomain", - document_policy_name: "document-domain", - value_type: "Bool", - default_value: "true", - depends_on: ["DocumentPolicyDocumentDomain"], - default_value_behind_flag: [ - ["DisableDocumentDomainByDefault", "false"], - ], } ], }
diff --git a/third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5 b/third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5 index 3ca24e7..afa13c2 100644 --- a/third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5 +++ b/third_party/blink/renderer/core/permissions_policy/permissions_policy_features.json5
@@ -219,11 +219,6 @@ permissions_policy_name: "display-capture", }, { - name: "DocumentDomain", - permissions_policy_name: "document-domain", - feature_default: "EnableForAll", - }, - { name: "EncryptedMedia", permissions_policy_name: "encrypted-media", },
diff --git a/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h b/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h index 34134ba..4bb4c5b 100644 --- a/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h +++ b/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.h
@@ -14,6 +14,8 @@ class CORE_EXPORT ShadowRealmGlobalScope final : public EventTargetWithInlineData, public ExecutionContext { + DEFINE_WRAPPERTYPEINFO(); + public: explicit ShadowRealmGlobalScope( ExecutionContext* initiator_execution_context);
diff --git a/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.idl b/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.idl new file mode 100644 index 0000000..7f017c2 --- /dev/null +++ b/third_party/blink/renderer/core/shadow_realm/shadow_realm_global_scope.idl
@@ -0,0 +1,7 @@ +// Copyright 2022 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// https://github.com/tc39/proposal-shadowrealm + +interface ShadowRealmGlobalScope {};
diff --git a/third_party/blink/renderer/core/svg/svg_element.cc b/third_party/blink/renderer/core/svg/svg_element.cc index e96bcef..400388e 100644 --- a/third_party/blink/renderer/core/svg/svg_element.cc +++ b/third_party/blink/renderer/core/svg/svg_element.cc
@@ -369,7 +369,6 @@ corresponding_element->RemoveInstance(this); SvgRareData()->SetCorrespondingElement(nullptr); } - RebuildAllIncomingReferences(); RemoveAllIncomingReferences(); } @@ -962,7 +961,6 @@ Element::AttributeChanged(params); if (params.name == html_names::kIdAttr) { - RebuildAllIncomingReferences(); InvalidateInstances(); return; } @@ -1302,28 +1300,6 @@ return *invalidating_dependencies; } -void SVGElement::RebuildAllIncomingReferences() { - if (!HasSVGRareData()) - return; - - const SVGElementSet& incoming_references = - SvgRareData()->IncomingReferences(); - - // Iterate on a snapshot as |incoming_references| may be altered inside loop. - HeapVector<Member<SVGElement>> incoming_references_snapshot( - incoming_references); - - // Force rebuilding the |source_element| so it knows about this change. - const SvgAttributeChangedParams params( - svg_names::kHrefAttr, AttributeModificationReason::kDirectly); - for (SVGElement* source_element : incoming_references_snapshot) { - // Before rebuilding |source_element| ensure it was not removed from under - // us. - if (incoming_references.Contains(source_element)) - source_element->SvgAttributeChanged(params); - } -} - void SVGElement::RemoveAllIncomingReferences() { if (!HasSVGRareData()) return;
diff --git a/third_party/blink/renderer/core/svg/svg_element.h b/third_party/blink/renderer/core/svg/svg_element.h index 4f27437..a83fe242 100644 --- a/third_party/blink/renderer/core/svg/svg_element.h +++ b/third_party/blink/renderer/core/svg/svg_element.h
@@ -190,7 +190,6 @@ void AddReferenceTo(SVGElement*); template <typename InvalidationFunction> void NotifyIncomingReferences(InvalidationFunction&&); - void RebuildAllIncomingReferences(); void RemoveAllIncomingReferences(); void RemoveAllOutgoingReferences();
diff --git a/third_party/blink/renderer/core/view_transition/view_transition.cc b/third_party/blink/renderer/core/view_transition/view_transition.cc index 8cce4b5..03591e3 100644 --- a/third_party/blink/renderer/core/view_transition/view_transition.cc +++ b/third_party/blink/renderer/core/view_transition/view_transition.cc
@@ -35,7 +35,7 @@ #include "third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h" #include "third_party/blink/renderer/platform/graphics/compositor_element_id.h" #include "third_party/blink/renderer/platform/graphics/paint/clip_paint_property_node.h" -#include "third_party/blink/renderer/platform/heap/cross_thread_persistent.h" +#include "third_party/blink/renderer/platform/heap/cross_thread_handle.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" #include "third_party/blink/renderer/platform/scheduler/public/event_loop.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" @@ -514,7 +514,7 @@ style_tracker_->TakeCaptureResourceIds(), ConvertToBaseOnceCallback( CrossThreadBindOnce(&ViewTransition::NotifyCaptureFinished, - WrapCrossThreadWeakPersistent(this))))); + MakeUnwrappingCrossThreadHandle(this))))); if (document_->GetFrame()->IsLocalRoot()) { document_->GetPage()->GetChromeClient().StopDeferringCommits(
diff --git a/third_party/blink/renderer/modules/BUILD.gn b/third_party/blink/renderer/modules/BUILD.gn index e37a216..97b5dc8 100644 --- a/third_party/blink/renderer/modules/BUILD.gn +++ b/third_party/blink/renderer/modules/BUILD.gn
@@ -56,7 +56,6 @@ "//third_party/blink/renderer/modules/animationworklet", "//third_party/blink/renderer/modules/app_banner", "//third_party/blink/renderer/modules/audio_output_devices", - "//third_party/blink/renderer/modules/autofill_assistant", "//third_party/blink/renderer/modules/background_fetch", "//third_party/blink/renderer/modules/background_sync", "//third_party/blink/renderer/modules/badging", @@ -429,7 +428,6 @@ "animationworklet/animation_worklet_global_scope_test.cc", "animationworklet/animation_worklet_proxy_client_test.cc", "animationworklet/worklet_animation_test.cc", - "autofill_assistant/node_signals_test.cc", "background_fetch/background_fetch_icon_loader_test.cc", "background_fetch/background_fetch_manager_test.cc", "broadcastchannel/broadcast_channel_unittest.cc",
diff --git a/third_party/blink/renderer/modules/autofill_assistant/BUILD.gn b/third_party/blink/renderer/modules/autofill_assistant/BUILD.gn deleted file mode 100644 index c23d342..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/BUILD.gn +++ /dev/null
@@ -1,11 +0,0 @@ -# Copyright 2021 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import("//third_party/blink/renderer/modules/modules.gni") - -blink_modules_sources("autofill_assistant") { - sources = [ "node_signals.cc" ] - - deps = [] -}
diff --git a/third_party/blink/renderer/modules/autofill_assistant/DIR_METADATA b/third_party/blink/renderer/modules/autofill_assistant/DIR_METADATA deleted file mode 100644 index 2c84cedc..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/DIR_METADATA +++ /dev/null
@@ -1,3 +0,0 @@ -monorail { - component: "UI>Browser>Autofill>Assistant" -}
diff --git a/third_party/blink/renderer/modules/autofill_assistant/OWNERS b/third_party/blink/renderer/modules/autofill_assistant/OWNERS deleted file mode 100644 index ed6d5f0..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/OWNERS +++ /dev/null
@@ -1 +0,0 @@ -file://components/autofill_assistant/OWNERS
diff --git a/third_party/blink/renderer/modules/autofill_assistant/README.md b/third_party/blink/renderer/modules/autofill_assistant/README.md deleted file mode 100644 index ef08de4..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/README.md +++ /dev/null
@@ -1,13 +0,0 @@ -# Node Signals for Autofill Assistant - -## Overview -Autofill Assistant is an execution engine to run user journes on websites -given a set of actions. These actions include clicking on buttons or filling -in a form. - -To provide information for form filling, Autofill Assistant collects node -signals that will be analyzed to understand the node. - -## Contact -The bug component is [UI>Browser>Autofill>Assistant](https://bugs.chromium.org/p/chromium/issues/list?q=component:UI%3EBrowser%3EAutofill%3EAssistant) -and the team email `autofill_assistant@google.com`.
diff --git a/third_party/blink/renderer/modules/autofill_assistant/node_signals.cc b/third_party/blink/renderer/modules/autofill_assistant/node_signals.cc deleted file mode 100644 index e41fd06..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/node_signals.cc +++ /dev/null
@@ -1,562 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" - -#include <string> - -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "third_party/blink/public/platform/web_string.h" -#include "third_party/blink/public/platform/web_vector.h" -#include "third_party/blink/public/web/web_document.h" -#include "third_party/blink/renderer/core/dom/document.h" -#include "third_party/blink/renderer/core/dom/dom_node_ids.h" -#include "third_party/blink/renderer/core/dom/element.h" -#include "third_party/blink/renderer/core/dom/element_traversal.h" -#include "third_party/blink/renderer/core/dom/node.h" -#include "third_party/blink/renderer/core/dom/node_computed_style.h" -#include "third_party/blink/renderer/core/dom/node_traversal.h" -#include "third_party/blink/renderer/core/dom/qualified_name.h" -#include "third_party/blink/renderer/core/dom/shadow_root.h" -#include "third_party/blink/renderer/core/dom/space_split_string.h" -#include "third_party/blink/renderer/core/dom/text.h" -#include "third_party/blink/renderer/core/html/html_element.h" -#include "third_party/blink/renderer/core/html_names.h" -#include "third_party/blink/renderer/core/layout/geometry/physical_rect.h" -#include "third_party/blink/renderer/core/style/computed_style.h" -#include "third_party/blink/renderer/core/style/computed_style_base_constants.h" -#include "third_party/blink/renderer/platform/wtf/hash_map.h" -#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" -#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" -#include "third_party/blink/renderer/platform/wtf/text/string_impl.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" - -namespace blink { -namespace { - -constexpr int kMaxAncestorLevelForGeometry = 5; -constexpr double kToleranceForGeometry = 1e-5; -constexpr int kMaxCSSPixelDistance = 30; - -constexpr char kShippingFormType[] = "SHIPPING"; -constexpr char kBillingFormType[] = "BILLING"; -constexpr char kAfterLabel[] = "AFTRLBL"; - -WebString JoinStrings(const WebVector<WebString>& strings, - const char* separator) { - StringBuilder builder; - for (wtf_size_t i = 0; i < strings.size(); ++i) { - if (i > 0) { - builder.Append(separator); - } - builder.Append(String::FromUTF8(strings[i].Utf8())); - } - return WebString::FromUTF8(builder.ToString().StripWhiteSpace().Utf8()); -} - -bool IsVisible(const Element& element) { - const ComputedStyle* computed_style = element.GetComputedStyle(); - if (computed_style && computed_style->Visibility() != EVisibility::kVisible) { - return false; - } - - return !element.BoundingBox().IsEmpty(); -} - -WebString GetAttributes(const Element& element, - const WebVector<QualifiedName>& attributes) { - WebVector<WebString> values; - for (const QualifiedName& attribute : attributes) { - const auto& attribute_value = element.getAttribute(attribute); - if (!attribute_value.IsNull() && !attribute_value.empty()) { - values.push_back(attribute_value); - } - } - return JoinStrings(values, " "); -} - -bool AddAtomicIfNotNullOrEmpty(const AtomicString& atomic, - WebVector<WebString>* text) { - if (atomic.IsNull() || atomic.empty()) { - return false; - } - - text->emplace_back(WebString(atomic)); - return true; -} - -bool AddStringIfNotNullOrEmpty(const WebString& web_string, - WebVector<WebString>* text) { - if (web_string.IsNull() || web_string.IsEmpty()) { - return false; - } - - text->emplace_back(web_string); - return true; -} - -absl::optional<WebVector<Element*>> ListOptions(const Element& element) { - // TODO(sandromaggi): Handle radio buttons. - - if (!element.HasTagName(html_names::kSelectTag)) { - return absl::nullopt; - } - - WebVector<Element*> options; - for (Element& child : ElementTraversal::DescendantsOf(element)) { - if (!child.HasTagName(html_names::kOptionTag)) { - continue; - } - options.emplace_back(&child); - } - - return options; -} - -WebString GetType(const Element& element) { - if (!element.HasTagName(html_names::kInputTag)) { - return WebString(); - } - return WebString(element.getAttribute(html_names::kTypeAttr)); -} - -bool IsSupportedByClient(const Element& element) { - if (element.HasTagName(html_names::kInputTag)) { - const String input_type = String{GetType(element)}.LowerASCII(); - return input_type != "checkbox" && input_type != "radio" && - input_type != "submit" && input_type != "button" && - input_type != "hidden"; - } - return element.HasTagName(html_names::kTextareaTag) || - element.HasTagName(html_names::kSelectTag); -} - -WebString GetAria(const Element& element) { - WebVector<QualifiedName> attributes; - attributes.emplace_back(html_names::kAriaLabelAttr); - attributes.emplace_back(html_names::kAriaDescriptionAttr); - attributes.emplace_back(html_names::kAriaPlaceholderAttr); - return GetAttributes(element, attributes); -} - -WebString GetInvisibleAttributes(const Element& element) { - WebVector<QualifiedName> attributes; - attributes.emplace_back(html_names::kNameAttr); - attributes.emplace_back(html_names::kTitleAttr); - attributes.emplace_back(html_names::kLabelAttr); - attributes.emplace_back(html_names::kPatternAttr); - return GetAttributes(element, attributes); -} - -void GetUserFacingText(const Element& element, - const absl::optional<WebVector<Element*>> options, - WebVector<WebString>* text) { - AddAtomicIfNotNullOrEmpty(element.getAttribute(html_names::kPlaceholderAttr), - text); - - // The "value" attribute is treated as user-facing only for text inputs that - // are "readonly". - if (element.HasTagName(html_names::kInputTag) && - element.hasAttribute(html_names::kReadonlyAttr)) { - AddAtomicIfNotNullOrEmpty(element.getAttribute(html_names::kValueAttr), - text); - } - - if (options) { - for (Element* option : *options) { - AddStringIfNotNullOrEmpty(option->innerText(), text); - } - } -} - -void CollectNodeFeatures(const Element& element, - AutofillAssistantNodeFeatures* features) { - features->html_tag = element.tagName(); - GetUserFacingText(element, ListOptions(element), &features->text); - features->aria = GetAria(element); - features->invisible_attributes = GetInvisibleAttributes(element); - features->type = GetType(element); -} - -// Add label name based on ancestors. -// Example: <label>Label <input></label> -WebString GetLabelRelatedChild(const Element& element) { - Node* node = element.parentNode(); - while (node) { - if (node->HasTagName(html_names::kLabelTag)) { - Element* label = DynamicTo<Element>(node); - if (!IsVisible(*label)) { - return WebString(); - } else { - return label->innerText(); - } - } - node = node->parentNode(); - } - return WebString(); -} - -// Add label based on attribute "for". -// Example: <label for="someid">Label</label><input id="someid"> -WebString GetLabelRelatedAttribute( - const Element& element, - const HashMap<AtomicString, Member<Element>>& labels) { - AtomicString id = element.getAttribute(html_names::kIdAttr); - if (id.IsNull() || id.empty()) { - return WebString(); - } - - const auto it = labels.find(id); - if (it == labels.end() || !it->value) { - return WebString(); - } - return it->value->innerText(); -} - -// Get labels using the aria-labelledby attribute. -// Example: <div id="label">Label</div><input aria-labelledby="label"> -bool AddLabelRelatedAriaLabelledby(const Element& element, - WebVector<WebString>* text) { - // TODO(b/204839535): Find out if we need html_names::kAriaLabeledbyAttr. - AtomicString labelledby = - element.getAttribute(html_names::kAriaLabelledbyAttr); - if (labelledby.IsNull() || labelledby.empty()) { - return false; - } - - bool added_label = false; - const Document& owner = element.GetDocument(); - - SpaceSplitString split(labelledby); - for (wtf_size_t i = 0u; i < split.size(); ++i) { - Element* label = owner.getElementById(split[i]); - if (!label || !IsVisible(*label)) { - continue; - } - added_label = - AddStringIfNotNullOrEmpty(label->innerText(), text) || added_label; - } - return added_label; -} - -double Distance(const PhysicalRect& a, const PhysicalRect& b) { - // There are only three ways rectangles can be positioned on each axis. For - // the y-axis we have: - // - // 1. b is above a then the y-axis distance is the y coordinate of - // b.y() - a.bottom() - // 2. b is below a then the y-axis distance is the y coordinate of - // a.y() - b.bottom() - // 3. b and a intersect in the y-axis (i.e. their projection on the y-axis - // intersect), then the distance on the y-axis is zero. - // - // The max defines what is the current situation. - double delta_y = std::max( - {(b.Y() - a.Bottom()).ToDouble(), (a.Y() - b.Bottom()).ToDouble(), 0.0}); - double delta_x = std::max( - {(b.X() - a.Right()).ToDouble(), (a.X() - b.Right()).ToDouble(), 0.0}); - return std::sqrt(delta_x * delta_x + delta_y * delta_y); -} - -// Add label based on geometric position. -// Example: <label>my_label</label><input> -WebString GetLabelFromGeometry(const Element& element) { - const PhysicalRect& element_rect = element.BoundingBox(); - - const Document* root = element.ownerDocument(); - int step = 0; - const Node* ancestor = &element; - while (ancestor != root && step < kMaxAncestorLevelForGeometry) { - ancestor = ancestor->parentNode(); - if (!ancestor) { - return WebString(); - } - ++step; - } - - WebVector<std::pair<double, WebString>> distance_and_text; - double closest_distance = std::numeric_limits<double>::max(); - for (Node& node : NodeTraversal::DescendantsOf(*ancestor)) { - if (!node.IsTextNode()) { - continue; - } - const PhysicalRect& rect = node.BoundingBox(); - if (rect.Y() > 0.5 * (element_rect.Y() + element_rect.Bottom()) && - !element_rect.Contains(rect)) { - continue; - } - double distance = Distance(rect, element_rect); - if (distance > kMaxCSSPixelDistance || - distance > closest_distance + kToleranceForGeometry) { - // No need to check text if element is far away. - continue; - } - - WebString text(DynamicTo<Text>(node)->wholeText()); - // Skip source formatting text nodes like "\n " and empty strings. - if (!text.IsNull() && !text.IsEmpty() && - !String(text).ContainsOnlyWhitespaceOrEmpty()) { - distance_and_text.push_back({distance, text}); - if (distance < closest_distance) { - closest_distance = distance; - } - } - } - - if (closest_distance > kMaxCSSPixelDistance) { - return WebString(); - } - WebVector<WebString> best_text; - for (const auto& entry : distance_and_text) { - if (entry.first <= closest_distance + kToleranceForGeometry) { - best_text.push_back(entry.second); - } - } - return JoinStrings(best_text, " "); -} - -void CollectLabelFeatures(Element& element, - const HashMap<AtomicString, Member<Element>>& labels, - AutofillAssistantLabelFeatures* features) { - if (AddStringIfNotNullOrEmpty(GetLabelRelatedChild(element), - &features->text)) { - return; - } - if (AddStringIfNotNullOrEmpty(GetLabelRelatedAttribute(element, labels), - &features->text)) { - return; - } - if (AddLabelRelatedAriaLabelledby(element, &features->text)) { - return; - } - AddStringIfNotNullOrEmpty(GetLabelFromGeometry(element), &features->text); -} - -void AddFirstLegendOfFieldset(Node* node, WebVector<WebString>* header_text) { - Element* fieldset = DynamicTo<Element>(node); - if (!IsVisible(*fieldset)) { - return; - } - for (Element& legend : ElementTraversal::DescendantsOf(*fieldset)) { - // Add the first legend only. - if (legend.HasTagName(html_names::kLegendTag) && - AddStringIfNotNullOrEmpty(legend.innerText(), header_text)) { - return; - } - } -} - -// Add text signals when the |element| is a descendant of one or more -// fieldset(s). -// Example: <fieldset><legend>Legend</legend><input/><fieldset> -void GetFieldsetLegends(const Element& element, - AutofillAssistantContextFeatures* features) { - Node* node = element.parentNode(); - while (node) { - if (node->HasTagName(html_names::kFormTag)) { - break; - } - if (node->HasTagName(html_names::kFieldsetTag)) { - AddFirstLegendOfFieldset(node, &features->header_text); - } - node = node->parentNode(); - } -} - -bool IsHeader(const Element& element) { - return element.HasTagName(html_names::kH1Tag) || - element.HasTagName(html_names::kH2Tag) || - element.HasTagName(html_names::kH3Tag) || - element.HasTagName(html_names::kH4Tag) || - element.HasTagName(html_names::kH4Tag) || - element.HasTagName(html_names::kH5Tag); -} - -void AddHeaders(const Element& element, - AutofillAssistantContextFeatures* features) { - WebVector<Element*> headers_before; - for (Element& node : - ElementTraversal::DescendantsOf(*element.ownerDocument())) { - if (&node == &element) { - break; - } - if (IsHeader(node) && IsVisible(node)) { - headers_before.emplace_back(&node); - } - } - for (int i = static_cast<int>(headers_before.size()) - 1; i >= 0; --i) { - Element* header = headers_before[i]; - // Demand header to be above the element or to have an overlap in - // y-coordinates. I.e. top (Y) of header must be higher (<) than bottom - // of element. - if (header->BoundingBox().Y() >= element.BoundingBox().Bottom()) { - continue; - } - // Only use the header which is the lowest in hierarchy. - if (AddStringIfNotNullOrEmpty(header->innerText(), - &features->header_text)) { - break; - } - } -} - -bool HasVisibleParent(const Node& node) { - if (!node.parentNode() || !node.parentNode()->IsElementNode()) { - return false; - } - - return IsVisible(*DynamicTo<Element>(*node.parentNode())); -} - -bool IsShippingFormObjective(const AtomicString& text) { - return text.Contains("ship", kTextCaseUnicodeInsensitive) || - text.Contains("deliver", kTextCaseUnicodeInsensitive); -} - -bool IsBillingFormObjective(const AtomicString& text) { - return text.Contains("billing", kTextCaseUnicodeInsensitive) || - text.Contains("payment", kTextCaseUnicodeInsensitive); -} - -WebVector<WebString> GetObjectivesFromAtomicString(const AtomicString& text) { - WebVector<WebString> objectives; - if (IsShippingFormObjective(text)) { - objectives.push_back(WebString::FromUTF8(kShippingFormType)); - } - if (IsBillingFormObjective(text)) { - objectives.push_back(WebString::FromUTF8(kBillingFormType)); - } - return objectives; -} - -WebVector<WebString> GetObjectivesFromTextNode(const Node& node) { - return GetObjectivesFromAtomicString( - AtomicString(DynamicTo<Text>(node)->wholeText())); -} - -WebVector<WebString> GetObjectivesFromElementNode(const Node& node) { - const Element* element = DynamicTo<Element>(node); - return GetObjectivesFromAtomicString(AtomicString( - String::FromUTF8(element->getAttribute(html_names::kIdAttr).Utf8() + " " + - element->getAttribute(html_names::kNameAttr).Utf8()))); -} - -bool HasLabelAncestor(const Node& node) { - const Node* iter = &node; - while (iter) { - if (iter->HasTagName(html_names::kLabelTag)) { - return true; - } - iter = iter->parentNode(); - } - return false; -} - -void AddFormTypeForContext(const Element& element, - AutofillAssistantContextFeatures* features) { - WebVector<WebString> best_objectives; - // First attempt: Look at text nodes. - // |after_label| captures the presence of a label between the header and the - // input, typically a checkbox "billing same as shipping". - bool after_label = false; - for (Node& node : NodeTraversal::DescendantsOf(*element.ownerDocument())) { - if (&node == &element) { - break; - } - if (!node.IsTextNode() || !HasVisibleParent(node)) { - continue; - } - - WebVector<WebString> objectives = GetObjectivesFromTextNode(node); - if (objectives.empty()) { - continue; - } - - if (HasLabelAncestor(node)) { - after_label = true; - } else { - after_label = false; - best_objectives = objectives; - } - } - - if (best_objectives.empty()) { - // Second attempt: Try with id and names of ancestor nodes. - after_label = false; - Node* iter = element.parentNode(); - while (iter && !iter->IsDocumentNode()) { - if (iter->IsElementNode()) { - WebVector<WebString> objectives = GetObjectivesFromElementNode(*iter); - if (!objectives.empty()) { - best_objectives = objectives; - } - } - iter = iter->parentNode(); - } - } - - if (best_objectives.empty()) { - return; - } - - WebVector<WebString> form_type; - if (after_label) { - form_type.push_back(kAfterLabel); - } - for (const WebString& objective : best_objectives) { - form_type.push_back(objective); - } - features->form_type = JoinStrings(form_type, " "); -} - -void CollectContextFeatures(const Element& element, - AutofillAssistantContextFeatures* features) { - GetFieldsetLegends(element, features); - AddHeaders(element, features); - AddFormTypeForContext(element, features); -} - -void CollectSignalsForNode( - const Node& node, - WebVector<AutofillAssistantNodeSignals>* node_signals) { - // Pre-process elements for this Node. - HashMap<AtomicString, Member<Element>> labels; - for (Element& element : ElementTraversal::DescendantsOf(node)) { - if (element.HasTagName(html_names::kLabelTag) && - element.hasAttribute(html_names::kForAttr)) { - labels.insert(element.getAttribute(html_names::kForAttr), &element); - } - } - - // Note: This does not pierce documents like ShadowDom. - for (Element& element : ElementTraversal::DescendantsOf(node)) { - ShadowRoot* shadow_root = element.GetShadowRoot(); - if (shadow_root && shadow_root->GetType() != ShadowRootType::kUserAgent) { - CollectSignalsForNode(*shadow_root, node_signals); - } - - if (!IsSupportedByClient(element) || !IsVisible(element)) { - continue; - } - - AutofillAssistantNodeSignals signals; - signals.backend_node_id = static_cast<int>(DOMNodeIds::IdForNode(&element)); - CollectNodeFeatures(element, &signals.node_features); - CollectLabelFeatures(element, labels, &signals.label_features); - CollectContextFeatures(element, &signals.context_features); - node_signals->push_back(std::move(signals)); - } -} - -} // namespace - -WebVector<AutofillAssistantNodeSignals> GetAutofillAssistantNodeSignals( - const WebDocument& web_document) { - WebVector<AutofillAssistantNodeSignals> node_signals; - Document* document = web_document; - CollectSignalsForNode(*document, &node_signals); - return node_signals; -} - -} // namespace blink
diff --git a/third_party/blink/renderer/modules/autofill_assistant/node_signals_test.cc b/third_party/blink/renderer/modules/autofill_assistant/node_signals_test.cc deleted file mode 100644 index d24e6be..0000000 --- a/third_party/blink/renderer/modules/autofill_assistant/node_signals_test.cc +++ /dev/null
@@ -1,584 +0,0 @@ -// Copyright 2021 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "third_party/blink/public/web/modules/autofill_assistant/node_signals.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/blink/public/web/web_document.h" -#include "third_party/blink/renderer/core/dom/document.h" -#include "third_party/blink/renderer/core/dom/dom_node_ids.h" -#include "third_party/blink/renderer/core/dom/node.h" -#include "third_party/blink/renderer/core/dom/shadow_root.h" -#include "third_party/blink/renderer/core/frame/local_frame_view.h" -#include "third_party/blink/renderer/core/testing/page_test_base.h" -#include "third_party/blink/renderer/platform/bindings/exception_state.h" -#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" -#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" - -namespace blink { -namespace { - -void SetShadowContent(const Document& document, - const char* host, - const char* shadow_content, - ShadowRootType type) { - ShadowRoot& shadow_root = - document.getElementById(AtomicString::FromUTF8(host)) - ->AttachShadowRootInternal(type); - shadow_root.setInnerHTML(String::FromUTF8(shadow_content), - ASSERT_NO_EXCEPTION); - document.View()->UpdateAllLifecyclePhasesForTest(); -} - -} // namespace - -using NodeSignalsTest = PageTestBase; - -TEST_F(NodeSignalsTest, GetNodeIdForInput) { - SetBodyContent(R"(<input id="a">)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - Node* a = GetDocument().getElementById("a"); - DOMNodeId id_a = DOMNodeIds::IdForNode(a); - EXPECT_EQ(results[0].backend_node_id, static_cast<int32_t>(id_a)); -} - -TEST_F(NodeSignalsTest, GetNodeIdsForAllInputs) { - SetBodyContent( - R"(<input id="a"><select id="b"></select><textarea id="c"></textarea>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - EXPECT_EQ(results.size(), 3u); -} - -TEST_F(NodeSignalsTest, PiercesOpenShadowDom) { - SetBodyContent(R"(<div id="host"></div>)"); - SetShadowContent(GetDocument(), "host", R"(<input id="a"/>)", - ShadowRootType::kOpen); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - EXPECT_EQ(results.size(), 1u); -} - -TEST_F(NodeSignalsTest, PiercesClosedShadowDom) { - SetBodyContent(R"(<div id="host"></div>)"); - SetShadowContent(GetDocument(), "host", R"(<input id="a"/>)", - ShadowRootType::kClosed); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - EXPECT_EQ(results.size(), 1u); -} - -TEST_F(NodeSignalsTest, AssignsTagNames) { - SetBodyContent(R"(<input><select></select><textarea></textarea>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 3u); - - EXPECT_EQ(results[0].node_features.html_tag, "INPUT"); - EXPECT_EQ(results[1].node_features.html_tag, "SELECT"); - EXPECT_EQ(results[2].node_features.html_tag, "TEXTAREA"); -} - -TEST_F(NodeSignalsTest, IgnoresNonVisibleElements) { - SetBodyContent(R"(<input style="display: none;">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input style="visibility: hidden;">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"( - <input style="height: 0; line-height: 0; padding: 0; border: none;">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - // An element outside of the visible viewport should still be returned. - SetBodyContent( - R"(<input style="position: absolute; left: -1000px; top: -1000px;">)"); - EXPECT_EQ(GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).size(), - 1u); -} - -TEST_F(NodeSignalsTest, CollectsAriaAttributes) { - SetBodyContent(R"( - <input aria-label="label" aria-description="description" - aria-placeholder="placeholder"> - <input>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 2u); - - EXPECT_EQ(results[0].node_features.aria, "label description placeholder"); - EXPECT_EQ(results[1].node_features.aria, ""); -} - -TEST_F(NodeSignalsTest, CollectsInvisibleAttributes) { - SetBodyContent(R"( - <input name="name" title="title" label="label" pattern="pattern"> - <input>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 2u); - - EXPECT_EQ(results[0].node_features.invisible_attributes, - "name title label pattern"); - EXPECT_EQ(results[1].node_features.invisible_attributes, ""); -} - -TEST_F(NodeSignalsTest, AssignsType) { - SetBodyContent(R"(<input type="text">)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].node_features.type, "text"); -} - -TEST_F(NodeSignalsTest, CollectInnerText) { - SetBodyContent(R"( - <input placeholder="placeholder"> - <input readonly value="value"> - <input value="value"> - <select><option>A</option><option>B</option></select>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 4u); - - ASSERT_EQ(results[0].node_features.text.size(), 1u); - EXPECT_EQ(results[0].node_features.text[0], "placeholder"); - - ASSERT_EQ(results[1].node_features.text.size(), 1u); - EXPECT_EQ(results[1].node_features.text[0], "value"); - - EXPECT_TRUE(results[2].node_features.text.empty()); - - ASSERT_EQ(results[3].node_features.text.size(), 2u); - EXPECT_EQ(results[3].node_features.text[0], "A"); - EXPECT_EQ(results[3].node_features.text[1], "B"); -} - -TEST_F(NodeSignalsTest, GetLabelFromParentElement) { - SetBodyContent(R"(<label>Name<input></label><input>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 2u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Name"); - - EXPECT_TRUE(results[1].label_features.text.empty()); -} - -TEST_F(NodeSignalsTest, GetLabelByForAttribute) { - SetBodyContent(R"( - <label for="id">Name</label><input id="id"><input id="other">)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 2u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Name"); - - EXPECT_TRUE(results[1].label_features.text.empty()); -} - -TEST_F(NodeSignalsTest, GetLabelByForAttributeWithCollision) { - SetBodyContent(R"( - <label for="id">Name</label><input id="id"> - <label for="id">Other</label><input id="id">)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 2u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Name"); - - ASSERT_EQ(results[1].label_features.text.size(), 1u); - ASSERT_EQ(results[1].label_features.text[0], "Name"); -} - -TEST_F(NodeSignalsTest, GetLabelByAriaElements) { - SetBodyContent(R"( - <div id="form">Billing</div> - <div> - <div id="input">Name</div> - <input aria-labelledby="form input"> - </div>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].label_features.text.size(), 2u); - EXPECT_EQ(results[0].label_features.text[0], "Billing"); - EXPECT_EQ(results[0].label_features.text[1], "Name"); // From Aria -} - -TEST_F(NodeSignalsTest, GetLabelFromGeometryWithNestedElements) { - // Make sure nested elements don't get added multiple times. - // Make sure elements that are not "pure text" get added. - SetBodyContent(R"( - <div><div>Label <i class="icon"></i></div></div> - <div><input></div>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Label"); -} - -TEST_F(NodeSignalsTest, - GetLabelFromGeometryWithNestedElementsClosestLabelOnly) { - // Make sure for nested elements only the "closest" gets added. - SetBodyContent(R"( - <div>Label <div>Sublabel</div></div> - <div><input></div>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Sublabel"); -} - -TEST_F(NodeSignalsTest, GetLabelFromGeometryAddInlineElements) { - SetBodyContent(R"( - <div>Name <i>First</i></div> - <div><input></div>)"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].label_features.text.size(), 1u); - EXPECT_EQ(results[0].label_features.text[0], "Name First"); -} - -TEST_F(NodeSignalsTest, AddFieldsetLegendInsideForm) { - SetBodyContent(R"( - <fieldset> - <legend>Outside</legend> - <form> - <fieldset> - <legend>Inside</legend> - <input> - </fieldset> - </form> - </fieldset> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 1u); - EXPECT_EQ(results[0].context_features.header_text[0], "Inside"); -} - -TEST_F(NodeSignalsTest, AddFieldsetLegendFromParentNodesOnly) { - SetBodyContent(R"( - <fieldset> - <legend>Unrelated</legend> - </fieldset> - <fieldset> - <legend>Related</legend> - <input> - </fieldset> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 1u); - EXPECT_EQ(results[0].context_features.header_text[0], "Related"); -} - -TEST_F(NodeSignalsTest, AddFieldsetLegendFromAllParentalFieldsets) { - SetBodyContent(R"( - <fieldset> - <legend>Outer</legend> - <fieldset> - <legend>Inner</legend> - <input> - </fieldset> - </fieldset> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 2u); - EXPECT_EQ(results[0].context_features.header_text[0], "Inner"); - EXPECT_EQ(results[0].context_features.header_text[1], "Outer"); -} - -TEST_F(NodeSignalsTest, AddFieldsetLegendFirstLabelOnly) { - SetBodyContent(R"( - <fieldset> - <legend>A</legend> - <legend>B</legend> - <input> - </fieldset> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 1u); - EXPECT_EQ(results[0].context_features.header_text[0], "A"); -} - -TEST_F(NodeSignalsTest, AddHeadersDeepestOnly) { - SetBodyContent(R"( - <div> - <h1>A</h1> - <div> - <h2>B</h2> - <div> - <input> - </div> - </div> - </div> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 1u); - EXPECT_EQ(results[0].context_features.header_text[0], "B"); -} - -TEST_F(NodeSignalsTest, AddHeadersOnlyIfAboveInHierarchy) { - SetBodyContent(R"( - <h1>A</h1> - <input style="position: absolute; top: 200px;"> - <h1>B</h1> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - ASSERT_EQ(results[0].context_features.header_text.size(), 1u); - EXPECT_EQ(results[0].context_features.header_text[0], "A"); -} - -TEST_F(NodeSignalsTest, DoNotAddEmptyHeaders) { - SetBodyContent(R"( - <h1></h1> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_TRUE(results[0].context_features.header_text.empty()); -} - -TEST_F(NodeSignalsTest, AddHeadersOnlyIfAboveVisually) { - SetBodyContent(R"( - <h1 style="position: absolute; top: 100px;">Header</h1> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_TRUE(results[0].context_features.header_text.empty()); -} - -TEST_F(NodeSignalsTest, GetShippingFormTypeFromText) { - SetBodyContent(R"( - <div>Shipping</div> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "SHIPPING"); -} - -TEST_F(NodeSignalsTest, GetBillingFormTypeFromText) { - SetBodyContent(R"( - <div>Billing</div> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "BILLING"); -} - -TEST_F(NodeSignalsTest, DoNotGetFormTypeFromUnrelatedText) { - SetBodyContent(R"( - <div>Enter Address</div> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_TRUE(results[0].context_features.form_type.IsEmpty()); -} - -TEST_F(NodeSignalsTest, DoNotGetFormTypeFromTextBelow) { - SetBodyContent(R"( - <input> - <div>Shipping</div> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_TRUE(results[0].context_features.form_type.IsEmpty()); -} - -TEST_F(NodeSignalsTest, GetFormTypeFromAncestorId) { - SetBodyContent(R"( - <div id="shipping_address"> - <input> - </div> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "SHIPPING"); -} - -TEST_F(NodeSignalsTest, GetFormTypeFromAncestorName) { - SetBodyContent(R"( - <div name="shipping_address"> - <input> - </div> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "SHIPPING"); -} - -TEST_F(NodeSignalsTest, GetFormTypeFromTextOverAncestor) { - SetBodyContent(R"( - <div name="shipping_address"> - <div>Billing</div> - <input> - </div> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "BILLING"); -} - -TEST_F(NodeSignalsTest, DoNotGetFormTypeFromLabel) { - SetBodyContent(R"( - <label>Shipping</label> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_TRUE(results[0].context_features.form_type.IsEmpty()); -} - -TEST_F(NodeSignalsTest, GetFormTypeAfterLabel) { - SetBodyContent(R"( - <div>Billing</div> - <label>Shipping address is the same</label> - <input> - )"); - - WebVector<AutofillAssistantNodeSignals> results = - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())); - ASSERT_EQ(results.size(), 1u); - - EXPECT_EQ(results[0].context_features.form_type, "AFTRLBL BILLING"); -} - -TEST_F(NodeSignalsTest, IsSupportedByClient) { - SetBodyContent(R"(<input type="text">)"); - EXPECT_EQ(GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).size(), - 1u); - - SetBodyContent(R"(<input>)"); - EXPECT_EQ(GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).size(), - 1u); - - SetBodyContent(R"(<input type="checkbox">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input type="Radio">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input type="radio">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input type="submit">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input type="button">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<input type="hidden">)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); - - SetBodyContent(R"(<select>)"); - EXPECT_EQ(GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).size(), - 1u); - - SetBodyContent(R"(<textarea>)"); - EXPECT_EQ(GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).size(), - 1u); - - SetBodyContent(R"(<div>)"); - EXPECT_TRUE( - GetAutofillAssistantNodeSignals(WebDocument(&GetDocument())).empty()); -} - -} // namespace blink
diff --git a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.cc b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.cc index 939f64e..5751a8a 100644 --- a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.cc +++ b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.cc
@@ -9,12 +9,12 @@ #include "third_party/blink/renderer/bindings/core/v8/callback_promise_adapter.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" -#include "third_party/blink/renderer/core/dom/dom_exception.h" #include "third_party/blink/renderer/core/execution_context/execution_context.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/frame/navigator.h" #include "third_party/blink/renderer/modules/installedapp/installed_app_controller.h" +#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/heap/garbage_collected.h" @@ -22,26 +22,27 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps( ScriptState* script_state, - Navigator& navigator) { + Navigator& navigator, + ExceptionState& exception_state) { // [SecureContext] from the IDL ensures this. DCHECK(ExecutionContext::From(script_state)->IsSecureContext()); auto* resolver = MakeGarbageCollected<ScriptPromiseResolver>(script_state); ScriptPromise promise = resolver->Promise(); if (!navigator.DomWindow()) { - auto* exception = MakeGarbageCollected<DOMException>( + exception_state.ThrowDOMException( DOMExceptionCode::kInvalidStateError, "The object is no longer associated to a document."); - resolver->Reject(exception); + resolver->Reject(exception_state); return promise; } if (!navigator.DomWindow()->GetFrame()->IsOutermostMainFrame()) { - auto* exception = MakeGarbageCollected<DOMException>( + exception_state.ThrowDOMException( DOMExceptionCode::kInvalidStateError, "getInstalledRelatedApps() is only supported in " "top-level browsing contexts."); - resolver->Reject(exception); + resolver->Reject(exception_state); return promise; }
diff --git a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.h b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.h index 40f3f93..7914b4f 100644 --- a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.h +++ b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.h
@@ -9,6 +9,7 @@ namespace blink { +class ExceptionState; class Navigator; class ScriptPromise; class ScriptState; @@ -17,7 +18,9 @@ STATIC_ONLY(NavigatorInstalledApp); public: - static ScriptPromise getInstalledRelatedApps(ScriptState*, Navigator&); + static ScriptPromise getInstalledRelatedApps(ScriptState*, + Navigator&, + ExceptionState& exception_state); }; } // namespace blink
diff --git a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.idl b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.idl index 6557b72f..077919a 100644 --- a/third_party/blink/renderer/modules/installedapp/navigator_installed_app.idl +++ b/third_party/blink/renderer/modules/installedapp/navigator_installed_app.idl
@@ -9,5 +9,5 @@ ImplementedAs=NavigatorInstalledApp, RuntimeEnabled=InstalledApp ] partial interface Navigator { - [CallWith=ScriptState, Measure, SecureContext] Promise<sequence<RelatedApplication>> getInstalledRelatedApps(); + [CallWith=ScriptState, Measure, SecureContext, RaisesException] Promise<sequence<RelatedApplication>> getInstalledRelatedApps(); };
diff --git a/third_party/blink/renderer/platform/bindings/dom_wrapper_world.cc b/third_party/blink/renderer/platform/bindings/dom_wrapper_world.cc index 8916cf30..02a6836 100644 --- a/third_party/blink/renderer/platform/bindings/dom_wrapper_world.cc +++ b/third_party/blink/renderer/platform/bindings/dom_wrapper_world.cc
@@ -92,7 +92,8 @@ case WorldType::kInspectorIsolated: case WorldType::kRegExp: case WorldType::kForV8ContextSnapshotNonMain: - case WorldType::kWorker: { + case WorldType::kWorker: + case WorldType::kShadowRealm: { WorldMap& map = GetWorldMap(); DCHECK(!map.Contains(world_id_)); map.insert(world_id_, this); @@ -276,10 +277,12 @@ case WorldType::kRegExp: case WorldType::kForV8ContextSnapshotNonMain: case WorldType::kWorker: + case WorldType::kShadowRealm: { int32_t world_id = *next_world_id; CHECK_GE(world_id, WorldId::kUnspecifiedWorldIdStart); *next_world_id = world_id + 1; return world_id; + } } NOTREACHED(); return kInvalidWorldId;
diff --git a/third_party/blink/renderer/platform/bindings/dom_wrapper_world.h b/third_party/blink/renderer/platform/bindings/dom_wrapper_world.h index 2eb86f0..797def3a 100644 --- a/third_party/blink/renderer/platform/bindings/dom_wrapper_world.h +++ b/third_party/blink/renderer/platform/bindings/dom_wrapper_world.h
@@ -89,6 +89,12 @@ kRegExp, kForV8ContextSnapshotNonMain, kWorker, + // Shadow realms do not have a corresponding Frame nor DOMWindow so they're + // very different from the main world. Shadow realms are not workers nor + // worklets obviously, nor Chrome extensions' content scripts. So, we use + // a distinguishable world type. Shadow realms can be created not only in + // the main isolate but also in worker isolates and other isolates. + kShadowRealm, }; static bool IsIsolatedWorldId(int32_t world_id) { @@ -151,6 +157,9 @@ bool IsMainWorld() const { return world_type_ == WorldType::kMain; } bool IsWorkerWorld() const { return world_type_ == WorldType::kWorker; } + bool IsShadowRealmWorld() const { + return world_type_ == WorldType::kShadowRealm; + } bool IsIsolatedWorld() const { return world_type_ == WorldType::kIsolated || world_type_ == WorldType::kInspectorIsolated;
diff --git a/third_party/blink/renderer/platform/runtime_enabled_features.json5 b/third_party/blink/renderer/platform/runtime_enabled_features.json5 index e8777eb0..4e7553b 100644 --- a/third_party/blink/renderer/platform/runtime_enabled_features.json5 +++ b/third_party/blink/renderer/platform/runtime_enabled_features.json5
@@ -2676,6 +2676,12 @@ status: "stable", }, { + // crbug.com/1393223 + name: "SvgContainersRejectSvgInDisplayContents", + status: "stable", + base_feature: "SvgContainersRejectSvgInDisplayContents", + }, + { name: "SVGTextNG", depends_on: ["LayoutNG"], status: "stable"
diff --git a/third_party/blink/web_tests/FlagExpectations/disable-layout-ng b/third_party/blink/web_tests/FlagExpectations/disable-layout-ng index a799495b..29799b2 100644 --- a/third_party/blink/web_tests/FlagExpectations/disable-layout-ng +++ b/third_party/blink/web_tests/FlagExpectations/disable-layout-ng
@@ -11,6 +11,10 @@ # Tests that fail in legacy but pass in NG # ====== New tests from wpt-importer added here ====== +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html [ Timeout ] crbug.com/626703 external/wpt/bluetooth/adapter/adapter-absent-getAvailability.https.window.html [ Crash ] crbug.com/626703 external/wpt/bluetooth/adapter/adapter-added-getAvailability.https.window.html [ Crash ] crbug.com/626703 external/wpt/bluetooth/adapter/adapter-powered-off-getAvailability.https.window.html [ Crash ]
diff --git a/third_party/blink/web_tests/FlagExpectations/disable-site-isolation-trials b/third_party/blink/web_tests/FlagExpectations/disable-site-isolation-trials index 1e59701b..0761869d 100644 --- a/third_party/blink/web_tests/FlagExpectations/disable-site-isolation-trials +++ b/third_party/blink/web_tests/FlagExpectations/disable-site-isolation-trials
@@ -79,6 +79,10 @@ crbug.com/1209223 external/wpt/html/browsers/browsing-the-web/navigating-across-documents/javascript-url-security-check-same-origin-domain.sub.html [ Failure ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html [ Timeout ] crbug.com/626703 external/wpt/dom/events/scrolling/scrollend-event-handler-content-attributes.html [ Timeout ] crbug.com/626703 external/wpt/screen-orientation/active-lock.html [ Timeout ] crbug.com/626703 external/wpt/css/selectors/media/media-loading-state.html [ Timeout ]
diff --git a/third_party/blink/web_tests/SmokeTests/Mac.txt b/third_party/blink/web_tests/SmokeTests/Mac.txt index ce9ae04e..c03eed6 100644 --- a/third_party/blink/web_tests/SmokeTests/Mac.txt +++ b/third_party/blink/web_tests/SmokeTests/Mac.txt
@@ -1420,7 +1420,6 @@ virtual/disable-ua-client-hint/external/wpt/client-hints/http-equiv-accept-ch-non-secure.http.html virtual/disable-ua-client-hint/external/wpt/client-hints/service-workers/new-request-critical.https.window.html virtual/disable-ua-client-hint/wpt_internal/client-hints/accept_ch_feature_policy_allow_legacy_hints.tentative.sub.https.html -virtual/document-domain-disabled-by-default/external/wpt/document-policy/experimental-features/document-domain/document-domain.tentative.sub.html virtual/view-transition/external/wpt/css/css-view-transitions/new-content-container-writing-modes.html virtual/view-transition/external/wpt/css/css-view-transitions/one-element-two-targets.html virtual/elastic-overscroll/fixed-elements-dont-overscroll.html
diff --git a/third_party/blink/web_tests/SmokeTests/highdpi b/third_party/blink/web_tests/SmokeTests/highdpi index e524386..c62be95 100644 --- a/third_party/blink/web_tests/SmokeTests/highdpi +++ b/third_party/blink/web_tests/SmokeTests/highdpi
@@ -606,7 +606,6 @@ external/wpt/delegated-ink/exception-thrown-bad-color.tentative.html external/wpt/density-size-correction/srcset-cross-origin.sub.html external/wpt/direct-sockets/open-securecontext.http.html -external/wpt/document-policy/experimental-features/document-domain/document-domain.tentative.sub.html external/wpt/document-policy/font-display/reporting-blank.tentative.html external/wpt/document-policy/reporting/lossy-images-max-bpp-reporting-tentative.html external/wpt/document-policy/required-policy/document-policy.html
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 6f619a4..b6b9e83 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -3022,6 +3022,10 @@ crbug.com/626703 [ Win ] virtual/partitioned-cookies/http/tests/inspector-protocol/network/disabled-cache-navigation.js [ Failure ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html [ Timeout ] +crbug.com/626703 external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/bluetooth/adapter/adapter-absent-getAvailability.https.window.html [ Crash ] crbug.com/626703 [ Linux ] external/wpt/bluetooth/adapter/adapter-added-getAvailability.https.window.html [ Crash ] crbug.com/626703 [ Linux ] external/wpt/bluetooth/adapter/adapter-powered-off-getAvailability.https.window.html [ Crash ] @@ -3307,9 +3311,6 @@ crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/depth_sensing_notEnabled.https.html [ Timeout ] -crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html [ Timeout ] -crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html [ Timeout ] -crbug.com/626703 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/webxr/dom-overlay/ar_dom_overlay.https.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/webxr/dom-overlay/ar_dom_overlay_hit_test.https.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/webxr/dom-overlay/nested_fullscreen.https.html [ Timeout ] @@ -4278,6 +4279,7 @@ crbug.com/626703 external/wpt/css/css-writing-modes/forms/textarea-appearance-none-horizontal.optional.html [ Failure ] crbug.com/626703 external/wpt/css/css-writing-modes/forms/textarea-appearance-none-vlr.optional.html [ Failure ] crbug.com/626703 external/wpt/css/css-writing-modes/forms/textarea-appearance-none-vrl.optional.html [ Failure ] +crbug.com/1393567 [ Mac ] external/wpt/screen-orientation/hidden_document.html [ Failure Pass ] crbug.com/626703 [ Win11 ] external/wpt/screen-orientation/hidden_document.html [ Failure Timeout ] crbug.com/626703 external/wpt/css/css-writing-modes/forms/color-input-appearance-native-horizontal.optional.html [ Failure ] crbug.com/626703 external/wpt/css/css-writing-modes/forms/color-input-appearance-native-vertical.optional.html [ Failure ] @@ -6091,13 +6093,16 @@ crbug.com/1179461 [ Fuchsia ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html [ Failure ] crbug.com/1179461 [ Mac ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html [ Failure ] crbug.com/1179461 [ Win ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html [ Failure ] +crbug.com/1179461 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html [ Failure ] crbug.com/1179461 external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_inactiveFrame.https.html [ Failure ] crbug.com/1179461 [ Fuchsia ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html [ Failure ] crbug.com/1179461 [ Mac ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html [ Failure ] crbug.com/1179461 [ Win ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html [ Failure ] +crbug.com/1179461 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html [ Failure ] crbug.com/1179461 [ Fuchsia ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html [ Failure ] crbug.com/1179461 [ Mac ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html [ Failure ] crbug.com/1179461 [ Win ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html [ Failure ] +crbug.com/1179461 [ Linux ] external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html [ Failure ] # Sheriff 2021-02-17 crbug.com/1179117 [ Linux ] http/tests/devtools/a11y-axe-core/sources/scope-pane-a11y-test.js [ Pass Timeout ] @@ -8167,3 +8172,10 @@ # Temporarily disable test to land CPU-backed canvas switching change crbug.com/1385633 [ Linux ] virtual/oopr-canvas2d/fast/canvas/check-stale-putImageData.html [ Failure ] + +# Sheriff 2022-11-25 +crbug.com/1393474 [ Linux ] wpt_internal/geolocation-api/notimer-after-unload.https.html [ Failure ] +crbug.com/1393474 [ Linux ] wpt_internal/geolocation-api/timeout-clear-watch.https.html [ Failure ] +crbug.com/1393474 [ Linux ] wpt_internal/geolocation-api/timeout-negative.https.html [ Failure ] +crbug.com/1393474 [ Linux ] wpt_internal/geolocation-api/timeout-zero.https.html [ Failure ] +crbug.com/1393474 [ Linux ] wpt_internal/geolocation-api/timeout.https.html [ Failure ]
diff --git a/third_party/blink/web_tests/VirtualTestSuites b/third_party/blink/web_tests/VirtualTestSuites index 44c5f39..db562049 100644 --- a/third_party/blink/web_tests/VirtualTestSuites +++ b/third_party/blink/web_tests/VirtualTestSuites
@@ -934,15 +934,6 @@ "expires": "Jul 1, 2023" }, { - "prefix": "document-domain-disabled-by-default", - "platforms": ["Linux", "Mac", "Win"], - "bases": [ - "external/wpt/document-policy/experimental-features/document-domain" - ], - "args": [ "--enable-features=DisableDocumentDomainByDefault" ], - "expires": "Jul 1, 2023" - }, - { "prefix": "backface-visibility-interop", "platforms": ["Linux"], "bases": [ "external/wpt/css/css-transforms" ],
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json index a349bb8..c9ae081 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
@@ -226582,6 +226582,32 @@ {} ] ], + "range-input-vertical-ltr-painting.html": [ + "03e02b10a3f475502bac428a4cf15bf74cd5b66f", + [ + null, + [ + [ + "/css/css-writing-modes/forms/range-input-painting-ref.html", + "==" + ] + ], + {} + ] + ], + "range-input-vertical-rtl-painting.html": [ + "8c7d234db5c913eab3ea14649d81a1714f3b1028", + [ + null, + [ + [ + "/css/css-writing-modes/forms/range-input-painting-ref.html", + "==" + ] + ], + {} + ] + ], "select-multiple-appearance-native-horizontal.optional.html": [ "57b84109a823a0e1781f56a5241c5b1394309820", [ @@ -254728,6 +254754,19 @@ {} ] ], + "nested-svg-through-display-contents.svg": [ + "f5440303502c7b268480a949f0433e078ca80b1a", + [ + null, + [ + [ + "/svg/struct/reftests/reference/nested-svg-through-display-contents-ref.svg", + "==" + ] + ], + {} + ] + ], "requiredextensions-empty-string.svg": [ "28f5da4a3e4358821d907a2883b6ef8fa40eeaa4", [ @@ -264792,10 +264831,6 @@ "14fa5353a94d6e817867131b3d39e97aacdb670f", [] ], - "idlharness.window-expected.txt": [ - "a997488813c197db7ef450a03c2827554a6d5575", - [] - ], "idlharness.window.js.ini": [ "5db26da0f4df3f4b9cc528382ddeaf28d9f20fc6", [] @@ -274150,6 +274185,10 @@ "ff88b1e74a951b77458340de03b91d177302543e", [] ], + "position-fallback-tree-scoped-expected.txt": [ + "789f12eac0eae063422bcad9ab237705e0ebb214", + [] + ], "reference": { "anchor-scroll-fixedpos-ref.html": [ "e73354df72dac33f7a94eaef445e80ec61e3976a", @@ -317763,6 +317802,10 @@ ] } }, + "range-input-painting-ref.html": [ + "650a8139ca6cc13403957c2b68e8ef954cd80058", + [] + ], "select-multiple-scrolling.optional-expected.txt": [ "464cdd671865d23e588523f9b2e8e4195b965eb6", [] @@ -320123,7 +320166,7 @@ [] ], "cssom-getPropertyValue-common-checks-expected.txt": [ - "7dc527c588063c123b96d477780303c91cd70d48", + "5e91a7e28c5626806fa4f72abcac33263fe3987d", [] ], "cssstyledeclaration-cssfontrule.tentative-expected.txt": [ @@ -323291,17 +323334,9 @@ "57ba808a2e4b1f787988967817391d9ecc397418", [] ], - "idlharness.any-expected.txt": [ - "3dbd47f9045602410f957505b875fe2d5f215ee2", - [] - ], "idlharness.any.js.ini": [ "0701fef0fd23cf00220cc3751538784cc2381f81", [] - ], - "idlharness.any.worker-expected.txt": [ - "3dbd47f9045602410f957505b875fe2d5f215ee2", - [] ] }, "device-memory": { @@ -328952,10 +328987,6 @@ "59652e2e7ae0056a6cc4be7f004b6d0151fb9d44", [] ], - "feature-policy-geolocation.html": [ - "81943845447e6c6b7962b3961996e45c12e04cd4", - [] - ], "feature-policy-nested-subframe-policy.https.sub.html": [ "30525d8a3cda45b5ca63777c582a74e677f27031", [] @@ -333353,14 +333384,14 @@ "5c49de21a3b53dfe928d30a36400469d8238bb1d", [] ], - "disabled-by-feature-policy.https.sub.html.headers": [ - "7e75481ea6d71080aaef8b43e774f5da9c9741e5", - [] - ], "disabled-by-feature-policy.https.sub.html.ini": [ "bb53fa465504b317f5f9cb499eb43f2f1162319f", [] ], + "disabled-by-permissions-policy.https.sub.html.headers": [ + "26bfbc2496488e113641a8d015b7b03494ac4c83", + [] + ], "enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html.ini": [ "6c598aef3e06a70005fc8fa18f4c5f090b4ab8cb", [] @@ -333369,22 +333400,22 @@ "6fc81afb38d960d7d4bcaf373dd9050085f0b4b1", [] ], - "enabled-by-feature-policy.https.sub.html.headers": [ - "40e9bc16ff98867d0d048fe3a48237a8189ee317", - [] - ], "enabled-by-feature-policy.https.sub.html.ini": [ "3a3889b44d6b25670424cad8606570a732df1e0b", [] ], - "enabled-on-self-origin-by-feature-policy.https.sub.html.headers": [ - "b83264eee76491342a6328ca2ae82b7fb777cc37", + "enabled-by-permissions-policy.https.sub.html.headers": [ + "774f4819e9b6cd9c5d4847bef043791720844b3e", [] ], "enabled-on-self-origin-by-feature-policy.https.sub.html.ini": [ "f9f3d511c9e60e985005723ecb829b4261abe550", [] ], + "enabled-on-self-origin-by-permissions-policy.https.sub.html.headers": [ + "9fa0a4ac9a8a161aa01a9f9f70d70499f606a25a", + [] + ], "getCurrentPosition_IDL.https-expected.txt": [ "8781bccd59718f81b29112d2efbfe6407f697e52", [] @@ -355297,17 +355328,9 @@ "b738239a16f9110ac148b4d3c0bcfecb7eca25bd", [] ], - "idlharness.any-expected.txt": [ - "2d65b553a346f7dcddc870151210bcb7b90142cf", - [] - ], "idlharness.any.js.ini": [ "fc52caadf8afe7a699eac99eb7d50bc99ee367ea", [] - ], - "idlharness.any.worker-expected.txt": [ - "2d65b553a346f7dcddc870151210bcb7b90142cf", - [] ] }, "is-input-pending": { @@ -360720,7 +360743,7 @@ ] }, "idlharness.window-expected.txt": [ - "2f84795ce9dce1094959571183759ad9a2752a30", + "bb8b0850e28119512ed3d4cad69a5e35c3280f47", [] ], "idlharness.window.js.ini": [ @@ -361074,6 +361097,10 @@ "59652e2e7ae0056a6cc4be7f004b6d0151fb9d44", [] ], + "permissions-policy-geolocation.html": [ + "c9ae680ff2d2297781b386fbde2c71c6354cc180", + [] + ], "permissions-policy-idle-detection-worker.html": [ "5bcc3980390bbb4cc223998d0af5118d943a69f8", [] @@ -363917,18 +363944,10 @@ "7167d54d8388fc3aa5bd57ee598e4ab48f88b396", [] ], - "idlharness.any-expected.txt": [ - "55ab8a9bd30bc2473b9faa72c0baf27e7dfdf298", - [] - ], "idlharness.any.js.ini": [ "0f79ee948676eeea626580a5914953af3a6a3f23", [] ], - "idlharness.any.worker-expected.txt": [ - "55ab8a9bd30bc2473b9faa72c0baf27e7dfdf298", - [] - ], "idlharness.window-expected.txt": [ "2852fc5895a9b4e8fccf5c53619cdb79fb399587", [] @@ -372427,6 +372446,10 @@ "green-100x100.svg": [ "120941444a4898197d6b6001f9908a6cd48b62ba", [] + ], + "nested-svg-through-display-contents-ref.svg": [ + "622978f37881a4d40440595962b84bdb4c00dd91", + [] ] }, "support": { @@ -419028,6 +419051,13 @@ null, {} ] + ], + "position-fallback-tree-scoped.html": [ + "5b5c25f1030113bc6a8aaf68d4e977170e0b899f", + [ + null, + {} + ] ] }, "css-animations": { @@ -446749,7 +446779,7 @@ ] ], "cssom-getPropertyValue-common-checks.html": [ - "29ca39a88a659bc5a60b3464617235dd30e9d42d", + "27d802cd3df622f80bce890d2422791c8b81fcd3", [ null, {} @@ -487511,8 +487541,8 @@ {} ] ], - "disabled-by-feature-policy.https.sub.html": [ - "26fa7218a6d32a36ee4f99439580bcd19ddd7639", + "disabled-by-permissions-policy.https.sub.html": [ + "9b603982b99ab9c070031f30cce5846eb8940292", [ null, { @@ -487520,22 +487550,22 @@ } ] ], - "enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html": [ - "30de411cb7a342d105e2c6e0ae21c4d64c8f05dd", + "enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html": [ + "864fb5e76139ed9e6158c08278dca0790f126c7b", [ null, {} ] ], - "enabled-by-feature-policy-attribute.https.sub.html": [ - "49a6d777d66fa09df8d9ec38543f1097b95b6ffc", + "enabled-by-permission-policy-attribute.https.sub.html": [ + "018409b82902672f66894b03a711bb708cad262c", [ null, {} ] ], - "enabled-by-feature-policy.https.sub.html": [ - "955ed10632e84f52f231a4a0beeedb1ae5a7fc35", + "enabled-by-permissions-policy.https.sub.html": [ + "007f79ab9c4256fbebae51f54d34144843020982", [ null, { @@ -487543,8 +487573,8 @@ } ] ], - "enabled-on-self-origin-by-feature-policy.https.sub.html": [ - "12ff86fa4e554dc02524877ffb534e4c9cc11c5c", + "enabled-on-self-origin-by-permissions-policy.https.sub.html": [ + "d879c1c5432bb884af89f0f9fc24e328f8a3eae5", [ null, { @@ -487560,7 +487590,7 @@ ] ], "getCurrentPosition_permission_allow.https.html": [ - "102b8b4d11ea6d609de4e6f5e7be4b6ae370a425", + "c7fa970e086fe0efdd545f0c3cd7da5218b7bed8", [ null, { @@ -555294,7 +555324,7 @@ ] ], "fcp-document-opacity-image.html": [ - "7f211324761b4f63995ee00f40c0af0a7dc27488", + "e407f687086b9c8d9fecf96d6234e57c66d6183c", [ null, {} @@ -556411,6 +556441,13 @@ {} ] ], + "cross-origin-non-tao-image.sub.html": [ + "210f4e1fa3e8afdf4ac6a97671829bf52d223df1", + [ + null, + {} + ] + ], "droppedentriescount.any.js": [ "4de816bdc42bd8f73defcb07cb694a5fddfe058b", [
diff --git a/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped-expected.txt b/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped-expected.txt deleted file mode 100644 index 789f12e..0000000 --- a/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped-expected.txt +++ /dev/null
@@ -1,12 +0,0 @@ -This is a testharness.js-based test. -PASS Document position-fallback matches @position-fallback in document scope -PASS Document position-fallback does not match @position-fallback in #outer_host scope -PASS Document position-fallback does not match @position-fallback in #inner_host scope -PASS Outer position-fallback matches @position-fallback in document scope -FAIL Outer position-fallback matches @position-fallback in #outer_host scope assert_equals: expected 200 but got 0 -PASS Outer position-fallback does not match @position-fallback in #inner_host scope -PASS Inner position-fallback matches @position-fallback in document scope -FAIL Inner position-fallback matches @position-fallback in #outer_host scope assert_equals: expected 200 but got 0 -FAIL Inner position-fallback matches @position-fallback in #inner_host scope assert_equals: expected 300 but got 0 -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped.html b/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped.html index 5b5c25f..955c3a7c 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped.html +++ b/third_party/blink/web_tests/external/wpt/css/css-anchor-position/position-fallback-tree-scoped.html
@@ -1,6 +1,7 @@ <!DOCTYPE html> <title>CSS Anchor Positioning Test: @position-fallback - tree scoped names</title> <link rel="help" href="https://drafts.csswg.org/css-anchor-1/#fallback-rule"> +<link rel="help" href="https://drafts.csswg.org/css-scoping/#shadow-names"> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/resources/declarative-shadow-dom-polyfill.js"></script> @@ -65,9 +66,44 @@ </template> </div> + +<style> + @position-fallback --host-slot-part { + @try { + left: 1px; + } + } + #host_slotted_part::part(part) { + position-fallback: --host-slot-part; + } +</style> +<div id="host_slotted_part"> + <template shadowroot="open"> + <style> + @position-fallback --host-slot-part { + @try { + left: 2px; + } + } + ::slotted(#slotted), :host { + position: absolute; + position-fallback: --host-slot-part; + } + #part { + position: absolute; + } + </style> + <div id="part" part="part"></div> + <slot></slot> + </template> + <div id="slotted"></div> +</div> + + <script> setup(() => { polyfill_declarative_shadow_dom(outer_host); + polyfill_declarative_shadow_dom(host_slotted_part); }); test(() => { @@ -109,4 +145,15 @@ assert_equals(inner_root.querySelector("#inner_pf_inner").offsetLeft, 300); }, "Inner position-fallback matches @position-fallback in #inner_host scope"); + test(() => { + assert_equals(host_slotted_part.offsetLeft, 2); + }, "@position-fallback from same scope as :host rule"); + + test(() => { + assert_equals(slotted.offsetLeft, 2); + }, "@position-fallback from same scope as ::slotted() rule"); + + test(() => { + assert_equals(host_slotted_part.shadowRoot.querySelector("#part").offsetLeft, 1); + }, "@position-fallback from same scope as ::part() rule"); </script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-invalid.html b/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-invalid.html new file mode 100644 index 0000000..baf35ac --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-invalid.html
@@ -0,0 +1,56 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title> + CSS Fonts Module Level 4: parsing font-variant-alternates with invalid values + </title> + <link + rel="help" + href="https://drafts.csswg.org/css-fonts-4/#propdef-font-variant-alternates" + /> + <meta + name="assert" + content="font-variant-alternates supports only the grammar normal | [ stylistic(<feature-value-name>) || historical-forms || styleset(<feature-value-name>#) || character-variant(<feature-value-name>#) || swash(<feature-value-name>) || ornaments(<feature-value-name>) || annotation(<feature-value-name>) ]" + /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/css/support/parsing-testcommon.js"></script> + </head> + <body> + <script> + test_invalid_value( + "font-variant-alternates", + "swash(several,different,aliases)" + ); + test_invalid_value("font-variant-alternates", "stylistic(more,than,one)"); + test_invalid_value("font-variant-alternates", "ornaments(more,than,one)"); + test_invalid_value("font-variant-alternates", "swash(more,than,one)"); + test_invalid_value( + "font-variant-alternates", + "annotation(more,than,one)" + ); + test_invalid_value( + "font-variant-alternates", + "historical-forms(argument)" + ); + test_invalid_value("font-variant-alternates", "annotation"); + test_invalid_value("font-variant-alternates", "swash"); + test_invalid_value("font-variant-alternates", "ornaments stylistic"); + test_invalid_value("font-variant-alternates", "swash(one) swash(two)"); + test_invalid_value( + "font-variant-alternates", + "unkown(one) myfunction(two)" + ); + test_invalid_value( + "font-variant-alternates", + "styleset(thisone) styleset(something,else)" + ); + test_invalid_value( + "font-variant-alternates", + "swash(foo) swash(bar)" + ); + test_invalid_value("font-variant-alternates", "ornaments(one historical-forms"); + </script> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-valid.html b/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-valid.html new file mode 100644 index 0000000..43cc6f52 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-fonts/parsing/font-variant-alternates-valid.html
@@ -0,0 +1,34 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title> + CSS Fonts Module Level 4: parsing font-variant-alternates with valid + values + </title> + <link + rel="help" + href="https://drafts.csswg.org/css-fonts-4/#propdef-font-variant-alternates" + /> + <meta + name="assert" + content="font-variant-alternates supports only the grammar normal | [ stylistic(<feature-value-name>) || historical-forms || styleset(<feature-value-name>#) || character-variant(<feature-value-name>#) || swash(<feature-value-name>) || ornaments(<feature-value-name>) || annotation(<feature-value-name>) ]" + /> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/css/support/parsing-testcommon.js"></script> + </head> + <body> + <script> + test_valid_value( + "font-variant-alternates", + "character-variant(more, than, one)" + ); + test_valid_value("font-variant-alternates", "styleset(more, than, one)"); + test_valid_value( + "font-variant-alternates", + "styleset(more, than, one) character-variant(more, than, one)" + ); + </script> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-painting-ref.html b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-painting-ref.html new file mode 100644 index 0000000..650a813 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-painting-ref.html
@@ -0,0 +1,3 @@ +<!DOCTYPE html> +<title>Reference: painting of input[type=range] does not happen outside of its bounds</title> +<p>The range input below should be fully covered.</p>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-ltr-painting.html b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-ltr-painting.html new file mode 100644 index 0000000..03e02b10a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-ltr-painting.html
@@ -0,0 +1,37 @@ +<!DOCTYPE html> +<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m"> +<link rel="help" href="https://html.spec.whatwg.org/#range-state-(type=range)"> +<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#block-flow"> +<title>Test that painting of input[type=range] does not happen outside of its bounds</title> +<meta charset="utf-8"> +<link rel="match" href="range-input-painting-ref.html"> + +<style> + #container { + position: relative; + } + #cover { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: red; + } + @supports (writing-mode: vertical-lr) { + #cover { + background-color: Canvas; + } + } + input { + appearance: none; + writing-mode: vertical-lr; + } +</style> + +<p>The range input below should be fully covered.</p> + +<div id="container"> + <input type="range"> + <div id="cover"></div> +</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-rtl-painting.html b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-rtl-painting.html new file mode 100644 index 0000000..8c7d234 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-writing-modes/forms/range-input-vertical-rtl-painting.html
@@ -0,0 +1,39 @@ +<!DOCTYPE html> +<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m"> +<link rel="help" href="https://html.spec.whatwg.org/#range-state-(type=range)"> +<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#block-flow"> +<title>Test that painting of input[type=range] does not happen outside of its bounds</title> +<meta charset="utf-8"> +<link rel="match" href="range-input-painting-ref.html"> + +<style> + #container { + position: relative; + } + #cover { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: red; + } + @supports (writing-mode: vertical-lr) and (direction: rtl) { + #cover { + background-color: Canvas; + } + } + input { + appearance: none; + writing-mode: vertical-lr; + direction: rtl; + } +</style> + +<p>The range input below should be fully covered.</p> + +<div id="container"> + <input type="range"> + <div id="cover"></div> +</div> +
diff --git a/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks-expected.txt b/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks-expected.txt index 7dc527c..5e91a7e2 100644 --- a/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks-expected.txt +++ b/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks-expected.txt
@@ -1,9 +1,9 @@ This is a testharness.js-based test. PASS All properties can serialize 'initial' -FAIL All properties (except 'all') can serialize their initial value (computed) assert_array_equals: lengths differ, expected array ["all"] length 1, got ["all", ["background-repeat-x", ""], ["background-repeat-y", ""], ["grid", "none / none / none / row / auto / auto"], ["grid-template", "none / none / none"], ["page-orientation", ""], ["size", ""], ["view-timeline", ""]] length 8 +FAIL All properties (except 'all') can serialize their initial value (computed) assert_array_equals: lengths differ, expected array [] length 0, got [["background-repeat-x", ""], ["background-repeat-y", ""], ["grid", "none / none / none / row / auto / auto"], ["grid-template", "none / none / none"], ["page-orientation", ""], ["size", ""], ["view-timeline", ""]] length 7 FAIL All properties (except 'all') can serialize their initial value (specified) assert_array_equals: lengths differ, expected array [] length 0, got [["grid-column-gap", "normal", ""], ["grid-gap", "normal normal", ""], ["grid-row-gap", "normal", ""]] length 3 PASS All shorthands can serialize their longhands set to 'initial' -FAIL All shorthands can serialize their longhands set to their initial value assert_array_equals: lengths differ, expected array [] length 0, got [["border", ""], ["grid-gap", ""]] length 2 +FAIL All shorthands (except 'all') can serialize their longhands set to their initial value assert_array_equals: lengths differ, expected array [] length 0, got [["border", ""], ["grid-gap", ""]] length 2 PASS All aliases can serialize target property set to 'initial' FAIL All aliases can serialize target property set to its initial value assert_array_equals: lengths differ, expected array [] length 0, got [["grid-column-gap", ""], ["grid-row-gap", ""]] length 2 PASS Can't serialize shorthand when longhands are set to different css-wide keywords
diff --git a/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks.html b/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks.html index 29ca39a8..27d802c 100644 --- a/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks.html +++ b/third_party/blink/web_tests/external/wpt/css/cssom/cssom-getPropertyValue-common-checks.html
@@ -72,13 +72,11 @@ const result = computedStyle.getPropertyValue(property); if (CSS.supports(property, result)) { initialValues.set(property, result); - } else if (property === "all") { - bad.push("all"); - } else { + } else if (property !== "all") { bad.push([property, result]); } } - assert_array_equals(bad, ["all"]); + assert_array_equals(bad, []); }, "All properties (except 'all') can serialize their initial value (computed)"); test(function() { @@ -87,7 +85,7 @@ style.cssText = ""; style.setProperty(property, value); const result = style.getPropertyValue(property); - if (!CSS.supports(property, result)) { + if (!CSS.supports(property, result) && property !== "all") { bad.push([property, value, result]); } } @@ -121,12 +119,12 @@ style.setProperty(longhand, initialValues.get(longhand)); } const result = style.getPropertyValue(shorthand); - if (!CSS.supports(shorthand, result)) { + if (!CSS.supports(shorthand, result) && shorthand !== "all") { bad.push([shorthand, result]); } } assert_array_equals(bad, []); -}, "All shorthands can serialize their longhands set to their initial value"); +}, "All shorthands (except 'all') can serialize their longhands set to their initial value"); test(function() { const bad = [];
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/document-domain.tentative.sub.html b/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/document-domain.tentative.sub.html deleted file mode 100644 index 65de95c..0000000 --- a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/document-domain.tentative.sub.html +++ /dev/null
@@ -1,52 +0,0 @@ -<!DOCTYPE html> - -<body> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - - <script> - document.domain = "{{host}}"; - - async_test(t => { - const iframe = document.createElement('iframe'); - iframe.src = "//{{domains[www1]}}:{{location[port]}}/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html"; - iframe.onload = () => { - iframe.contentWindow.postMessage({ - type: "set document.domain", - newValue: "{{host}}" - }, "*"); - }; - - window.addEventListener('message', t.step_func(e => { - if (e.source == iframe.contentWindow) { - assert_equals(e.data.oldDomain, "{{domains[www1]}}"); - assert_equals(e.data.newDomain, "{{host}}"); - t.done(); - } - })); - - document.body.appendChild(iframe); - }, 'document.domain should be enabled in subframe.'); - - async_test(t => { - const iframe = document.createElement('iframe'); - iframe.src = "//{{domains[www1]}}:{{location[port]}}/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html"; - iframe.onload = () => { - iframe.contentWindow.postMessage({ - type: "set document.domain", - newValue: "{{host}}" - }, "*"); - }; - - window.addEventListener('message', t.step_func(e => { - if (e.source == iframe.contentWindow) { - assert_equals(e.data.oldDomain, "{{domains[www1]}}"); - assert_equals(e.data.newDomain, "{{domains[www1]}}"); - t.done(); - } - })); - - document.body.appendChild(iframe); - }, 'document.domain should be disabled in subframe.'); - </script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html b/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html deleted file mode 100644 index 124ee14..0000000 --- a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html +++ /dev/null
@@ -1,15 +0,0 @@ -<!DOCTYPE html> -<body> - <script> - window.onmessage = e => { - if (e.data.type === "set document.domain") { - oldDomain = document.domain; - document.domain = e.data.newValue; - e.source.postMessage({ - oldDomain, - newDomain: document.domain - }, "*"); - } - }; - </script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html.headers deleted file mode 100644 index 57b46a60..0000000 --- a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-disabled.html.headers +++ /dev/null
@@ -1 +0,0 @@ -Document-Policy: document-domain=?0 \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html b/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html deleted file mode 100644 index fe03af0..0000000 --- a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html +++ /dev/null
@@ -1,16 +0,0 @@ -<!DOCTYPE html> -<body> - <script> - window.onmessage = e => { - if (e.data.type === "set document.domain") { - oldDomain = document.domain; - document.domain = e.data.newValue; - e.source.postMessage({ - oldDomain, - newDomain: document.domain - }, "*"); - } - }; - </script> -</body> -
diff --git a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html.headers b/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html.headers deleted file mode 100644 index 89ccbe7..0000000 --- a/third_party/blink/web_tests/external/wpt/document-policy/experimental-features/document-domain/resources/document-domain-enabled.html.headers +++ /dev/null
@@ -1 +0,0 @@ -Document-Policy: document-domain \ No newline at end of file
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html.headers deleted file mode 100644 index 7e75481..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html.headers +++ /dev/null
@@ -1 +0,0 @@ -Feature-Policy: geolocation 'none'
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html similarity index 79% rename from third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html rename to third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html index 26fa721..9b603982 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-feature-policy.https.sub.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html
@@ -5,14 +5,14 @@ <script src="/resources/testharnessreport.js"></script> <script src="/resources/testdriver.js"></script> <script src="/resources/testdriver-vendor.js"></script> - <script src="/feature-policy/resources/featurepolicy.js"></script> + <script src="/permissions-policy/resources/permissions-policy.js"></script> <script> "use strict"; const same_origin_src = - "/feature-policy/resources/feature-policy-geolocation.html"; + "/permissions-policy/resources/permissions-policy-geolocation.html"; const cross_origin_src = - "https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src; + "https://{{hosts[][]}}:{{ports[https][0]}}" + same_origin_src; promise_test(async (t) => { await test_driver.set_permission( @@ -48,7 +48,7 @@ GeolocationPositionError.prototype.PERMISSION_DENIED, "Expected PERMISSION_DENIED" ); - }, "Feature-Policy header geolocation : 'none' disallows the top-level document."); + }, "Permissions-Policy header geolocation=() disallows the top-level document."); async_test((t) => { test_feature_availability( @@ -57,7 +57,7 @@ same_origin_src, expect_feature_unavailable_default ); - }, "Feature-Policy header geolocation : 'none' disallows same-origin iframes."); + }, "Permissions-Policy header geolocation=() disallows same-origin iframes."); async_test((t) => { test_feature_availability( @@ -66,6 +66,6 @@ cross_origin_src, expect_feature_unavailable_default ); - }, "Feature-Policy header geolocation 'none' disallows cross-origin iframes."); + }, "Permissions-Policy header geolocation=() disallows cross-origin iframes."); </script> </body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000..26bfbc2 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/disabled-by-permissions-policy.https.sub.html.headers
@@ -0,0 +1 @@ +Permissions-Policy: geolocation=()
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html deleted file mode 100644 index 30de411..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute-redirect-on-load.https.sub.html +++ /dev/null
@@ -1,36 +0,0 @@ -<!DOCTYPE html> -<body> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="/feature-policy/resources/featurepolicy.js"></script> -<script> - "use strict"; - - const relative_path = "/feature-policy/resources/feature-policy-geolocation.html"; - const base_src = "/feature-policy/resources/redirect-on-load.html#"; - const same_origin_src = base_src + relative_path; - const cross_origin_src = - base_src + "https://{{domains[www]}}:{{ports[https][0]}}" + relative_path; - - async_test(t => { - test_feature_availability( - 'geolocation', - t, - same_origin_src, - expect_feature_available_default, - "geolocation" - ); - }, 'Feature-Policy allow="geolocation" allows same-origin relocation'); - - async_test(t => { - test_feature_availability( - 'geolocation', - t, - cross_origin_src, - expect_feature_unavailable_default, - "geolocation" - ); - }, 'Feature-Policy allow="geolocation" disallows cross-origin relocation'); - -</script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute.https.sub.html deleted file mode 100644 index 49a6d77..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy-attribute.https.sub.html +++ /dev/null
@@ -1,34 +0,0 @@ -<!DOCTYPE html> -<body> -<script src="/resources/testharness.js"></script> -<script src="/resources/testharnessreport.js"></script> -<script src="/feature-policy/resources/featurepolicy.js"></script> -<script> - "use strict"; - - const same_origin_src = - "/feature-policy/resources/feature-policy-geolocation.html"; - const cross_origin_src = - "https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src; - - async_test(t => { - test_feature_availability( - "geolocation", - t, - same_origin_src, - expect_feature_available_default, - "geolocation" - ); - }, 'Feature policy "geolocation" can be enabled in same-origin iframe using allow="geolocation" attribute'); - - async_test(t => { - test_feature_availability( - "geolocation", - t, - cross_origin_src, - expect_feature_available_default, - "geolocation" - ); - }, 'Feature policy "geolocation" can be enabled in cross-origin iframe using allow="geolocation" attribute'); -</script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html.headers deleted file mode 100644 index 40e9bc1..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html.headers +++ /dev/null
@@ -1 +0,0 @@ -Feature-Policy: geolocation *
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html new file mode 100644 index 0000000..864fb5e --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute-redirect-on-load.https.sub.html
@@ -0,0 +1,36 @@ +<!DOCTYPE html> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/permissions-policy/resources/permissions-policy.js"></script> +<script> + "use strict"; + + const relative_path = "/permissions-policy/resources/permissions-policy-geolocation.html"; + const base_src = "/permissions-policy/resources/redirect-on-load.html#"; + const same_origin_src = base_src + relative_path; + const cross_origin_src = + `${base_src}https://{{hosts[][]}}:{{ports[https][0]}}${relative_path}`; + + async_test(t => { + test_feature_availability( + 'geolocation', + t, + same_origin_src, + expect_feature_available_default, + "geolocation" + ); + }, 'Permissions-Policy allow="geolocation" allows same-origin relocation'); + + async_test(t => { + test_feature_availability( + 'geolocation', + t, + cross_origin_src, + expect_feature_available_default, + "geolocation" + ); + }, 'Permissions-Policy allow="geolocation" allows cross-origin relocation'); + +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html new file mode 100644 index 0000000..018409b --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permission-policy-attribute.https.sub.html
@@ -0,0 +1,34 @@ +<!DOCTYPE html> +<body> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/permissions-policy/resources/permissions-policy.js"></script> +<script> + "use strict"; + + const same_origin_src = + "/permissions-policy/resources/permissions-policy-geolocation.html"; + const cross_origin_src = + "https://{{hosts[][]}}:{{ports[https][0]}}" + same_origin_src; + + async_test(t => { + test_feature_availability( + "geolocation", + t, + same_origin_src, + expect_feature_available_default, + "geolocation" + ); + }, 'Permissions policy "geolocation" can be enabled in same-origin iframe using allow="geolocation" attribute'); + + async_test(t => { + test_feature_availability( + "geolocation", + t, + cross_origin_src, + expect_feature_available_default, + "geolocation" + ); + }, 'Permissions policy "geolocation" can be enabled in cross-origin iframe using allow="geolocation" attribute'); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html similarity index 63% rename from third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html rename to third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html index 955ed10..007f79ab 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-feature-policy.https.sub.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html
@@ -5,21 +5,15 @@ <script src="/resources/testharnessreport.js"></script> <script src="/resources/testdriver.js"></script> <script src="/resources/testdriver-vendor.js"></script> - <script src="/feature-policy/resources/featurepolicy.js"></script> + <script src="/permissions-policy/resources/permissions-policy.js"></script> <script> const same_origin_src = - "/feature-policy/resources/feature-policy-geolocation.html"; + "/permissions-policy/resources/permissions-policy-geolocation.html"; const cross_origin_src = - "https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src; + "https://{{hosts[][]}}:{{ports[https][0]}}" + same_origin_src; promise_test(async (t) => { - - await test_driver.set_permission( - { name: "geolocation" }, - "granted", - false - ); - + await test_driver.set_permission({ name: "geolocation" }, "granted"); const result = await new Promise((resolve, reject) => { navigator.geolocation.getCurrentPosition(resolve, reject); }); @@ -28,7 +22,7 @@ result instanceof GeolocationPosition, "Expected a GeolocationPosition" ); - }, "Feature-Policy header geolocation: * allows the top-level document."); + }, "Permissions-Policy header geolocation=* allows the top-level document."); async_test((t) => { test_feature_availability( @@ -37,7 +31,7 @@ same_origin_src, expect_feature_available_default ); - }, "Feature-Policy header geolocation: * allows same-origin iframes."); + }, "Permissions-Policy header geolocation=* allows same-origin iframes."); async_test((t) => { test_feature_availability( @@ -46,6 +40,6 @@ cross_origin_src, expect_feature_available_default ); - }, "Feature-Policy header geolocation: * allows cross-origin iframes."); + }, "Permissions-Policy header geolocation=* allows cross-origin iframes."); </script> </body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000..774f481 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-by-permissions-policy.https.sub.html.headers
@@ -0,0 +1 @@ +Permissions-Policy: geolocation=*
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html deleted file mode 100644 index 12ff86f..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html +++ /dev/null
@@ -1,46 +0,0 @@ -<!DOCTYPE html> -<body> - <script src="/resources/testharness.js"></script> - <script src="/resources/testharnessreport.js"></script> - <script src="/resources/testdriver.js"></script> - <script src="/resources/testdriver-vendor.js"></script> - <script src="/feature-policy/resources/featurepolicy.js"></script> - - <script> - "use strict"; - - const same_origin_src = - "/feature-policy/resources/feature-policy-geolocation.html"; - const cross_origin_src = - "https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src; - - promise_test(async (t) => { - await test_driver.set_permission( - { name: "geolocation" }, - "granted", - false - ); - await new Promise(resolve => { - navigator.geolocation.getCurrentPosition(resolve); - }) - }, 'Feature-Policy header geolocation "self" allows the top-level document.'); - - async_test((t) => { - test_feature_availability( - "geolocation", - t, - same_origin_src, - expect_feature_available_default - ); - }, 'Feature-Policy header geolocation "self" allows same-origin iframes.'); - - async_test((t) => { - test_feature_availability( - "geolocation", - t, - cross_origin_src, - expect_feature_unavailable_default - ); - }, 'Feature-Policy header geolocation "self" disallows cross-origin iframes.'); - </script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html.headers deleted file mode 100644 index b83264e..0000000 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-feature-policy.https.sub.html.headers +++ /dev/null
@@ -1 +0,0 @@ -Feature-Policy: geolocation 'self'
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html new file mode 100644 index 0000000..d879c1c5 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html
@@ -0,0 +1,42 @@ +<!DOCTYPE html> +<body> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-vendor.js"></script> + <script src="/permissions-policy/resources/permissions-policy.js"></script> + + <script> + "use strict"; + + const same_origin_src = + "/permissions-policy/resources/permissions-policy-geolocation.html"; + const cross_origin_src = + "https://{{hosts[][]}}:{{ports[https][0]}}" + same_origin_src; + + promise_test(async (t) => { + await test_driver.set_permission({ name: "geolocation" }, "granted"); + await new Promise((resolve, reject) => { + navigator.geolocation.getCurrentPosition(resolve, reject); + }); + }, "Permissions-Policy header geolocation=(self) allows the top-level document."); + + async_test((t) => { + test_feature_availability( + "geolocation", + t, + same_origin_src, + expect_feature_available_default + ); + }, "Permissions-Policy header geolocation=(self) allows same-origin iframes."); + + async_test((t) => { + test_feature_availability( + "geolocation", + t, + cross_origin_src, + expect_feature_unavailable_default + ); + }, "Permissions-Policy header geolocation=(self) disallows cross-origin iframes."); + </script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html.headers b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html.headers new file mode 100644 index 0000000..9fa0a4a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/enabled-on-self-origin-by-permissions-policy.https.sub.html.headers
@@ -0,0 +1 @@ +Permissions-Policy: geolocation=(self)
diff --git a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html index 102b8b4..c7fa970e 100644 --- a/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html +++ b/third_party/blink/web_tests/external/wpt/geolocation-API/getCurrentPosition_permission_allow.https.html
@@ -19,7 +19,10 @@ let calledAsync = false; navigator.geolocation.getCurrentPosition( t.step_func((position) => { - assert_true(calledAsync, "Expected callback to be called asynchronously") + assert_true( + calledAsync, + "Expected callback to be called asynchronously" + ); resolve(position); }), reject
diff --git a/third_party/blink/web_tests/external/wpt/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_feature_policy.tentative.sub.html b/third_party/blink/web_tests/external/wpt/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_feature_policy.tentative.sub.html deleted file mode 100644 index e50e5e1..0000000 --- a/third_party/blink/web_tests/external/wpt/html/browsers/origin/relaxing-the-same-origin-restriction/document_domain_feature_policy.tentative.sub.html +++ /dev/null
@@ -1,22 +0,0 @@ -<!DOCTYPE html> -<body> - <script src=/resources/testharness.js></script> - <script src=/resources/testharnessreport.js></script> - <script src=/feature-policy/resources/featurepolicy.js></script> - <script> - run_all_fp_tests_allow_all( - 'http://{{domains[www]}}:{{ports[http][0]}}', - 'document-domain', - 'SecurityError', - () => { - return new Promise((resolve, reject) => { - try { - document.domain = "{{domains[]}}"; - resolve(); - } catch(e) { - reject(e); - } - }); - }); - </script> -</body>
diff --git a/third_party/blink/web_tests/external/wpt/feature-policy/resources/feature-policy-geolocation.html b/third_party/blink/web_tests/external/wpt/permissions-policy/resources/permissions-policy-geolocation.html similarity index 71% rename from third_party/blink/web_tests/external/wpt/feature-policy/resources/feature-policy-geolocation.html rename to third_party/blink/web_tests/external/wpt/permissions-policy/resources/permissions-policy-geolocation.html index 8194384..c9ae680 100644 --- a/third_party/blink/web_tests/external/wpt/feature-policy/resources/feature-policy-geolocation.html +++ b/third_party/blink/web_tests/external/wpt/permissions-policy/resources/permissions-policy-geolocation.html
@@ -4,18 +4,20 @@ "use strict"; Promise.resolve().then(async () => { + test_driver.set_test_context(window.parent); await test_driver.set_permission( { name: "geolocation" }, "granted", false ); + let enabled = true; try { await new Promise((resolve, reject) => { navigator.geolocation.getCurrentPosition(resolve, reject); }); - window.parent.postMessage({ enabled: true }, "*"); } catch (e) { - window.parent.postMessage({ enabled: false }, "*"); + enabled = false; } + window.parent.postMessage({ type: "availability-result", enabled }, "*"); }); </script>
diff --git a/third_party/blink/web_tests/external/wpt/svg/struct/reftests/nested-svg-through-display-contents.svg b/third_party/blink/web_tests/external/wpt/svg/struct/reftests/nested-svg-through-display-contents.svg new file mode 100644 index 0000000..f544030 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/svg/struct/reftests/nested-svg-through-display-contents.svg
@@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<svg viewBox="0 0 400 400" width="400" height="400" stroke="none" id="s1" + xmlns="http://www.w3.org/2000/svg" + xmlns:h="http://www.w3.org/1999/xhtml"> + <h:link rel="match" href="reference/nested-svg-through-display-contents-ref.svg"/> + <h:link rel="help" href="https://svgwg.org/svg2-draft/struct.html#ForeignNamespaces"/> + <rect x="90" y="100" width="300" height="100" fill="rgba(255,0,0,0.5)"></rect> + <script><![CDATA[ +const SVG_NS = 'http://www.w3.org/2000/svg'; +const XHTML_NS = 'http://www.w3.org/1999/xhtml'; + +const div1 = document.createElementNS(XHTML_NS, 'div'); +div1.style.display = 'contents'; +div1.innerHTML = `<svg xmlns="${SVG_NS}" width="70%" height="70%"> + <rect x="50" y="50" width="300" height="100" fill="rgba(0,0,255,0.5)"></rect> +</svg>`; + +const div2 = document.createElementNS(XHTML_NS, 'div'); +div2.style.display = 'contents'; +div2.innerHTML = `<svg xmlns="${SVG_NS}" width="300" height="200"> + <rect x="70" y="75" width="300" height="100" fill="rgba(0,255,0,0.5)"></rect> +</svg>`; + +document.documentElement.insertBefore(div2, document.documentElement.firstChild); +document.documentElement.insertBefore(div1, div2); +]]></script> +</svg>
diff --git a/third_party/blink/web_tests/external/wpt/svg/struct/reftests/reference/nested-svg-through-display-contents-ref.svg b/third_party/blink/web_tests/external/wpt/svg/struct/reftests/reference/nested-svg-through-display-contents-ref.svg new file mode 100644 index 0000000..622978f --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/svg/struct/reftests/reference/nested-svg-through-display-contents-ref.svg
@@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<svg viewBox="0 0 400 400" width="400" height="400" stroke="none" xmlns="http://www.w3.org/2000/svg"> + <rect x="90" y="100" width="300" height="100" fill="rgba(255,0,0,0.5)"></rect> +</svg>
diff --git a/third_party/blink/web_tests/flag-specific/disable-layout-ng/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt new file mode 100644 index 0000000..c06afed --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +PASS FaceDetector.detect() can process uint16 storage format ImageData +PASS BarcodeDetector.detect() can process uint16 storage format ImageData +PASS TextDetector.detect() can process uint16 storage format ImageData +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt new file mode 100644 index 0000000..492e3bd3 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS geolocation callbacks are not invoked after page unload +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt similarity index 69% rename from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt rename to third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt index 3fce3f3..bfad7c4 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when a watch times out and is cleared from the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-negative.https-expected.txt similarity index 64% rename from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt rename to third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-negative.https-expected.txt index bb7bda22..ec1f1b4 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-negative.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when timeout is negative (and maximumAge is too), the error callback is called immediately with code TIMEOUT. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-zero.https-expected.txt similarity index 64% rename from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt rename to third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-zero.https-expected.txt index ca5e2e8..4f97b9d 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout-zero.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when timeout is zero (and maximumAge is too), the error callback is called immediately with code TIMEOUT. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout.https-expected.txt new file mode 100644 index 0000000..e11f094 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-layout-ng/wpt_internal/geolocation-api/timeout.https-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Tests that when timeout is non-zero, the success callback is called as expected. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt new file mode 100644 index 0000000..c06afed --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt
@@ -0,0 +1,6 @@ +This is a testharness.js-based test. +PASS FaceDetector.detect() can process uint16 storage format ImageData +PASS BarcodeDetector.detect() can process uint16 storage format ImageData +PASS TextDetector.detect() can process uint16 storage format ImageData +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt new file mode 100644 index 0000000..492e3bd3 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS geolocation callbacks are not invoked after page unload +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt similarity index 69% copy from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt copy to third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt index 3fce3f3..bfad7c4 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-clear-watch.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when a watch times out and is cleared from the error callback, there is no crash. This a regression test for https://bugs.webkit.org/show_bug.cgi?id=32111. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-negative.https-expected.txt similarity index 64% copy from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt copy to third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-negative.https-expected.txt index bb7bda22..ec1f1b4 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-negative.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-negative.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when timeout is negative (and maximumAge is too), the error callback is called immediately with code TIMEOUT. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-zero.https-expected.txt similarity index 64% copy from third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt copy to third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-zero.https-expected.txt index ca5e2e8..4f97b9d 100644 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout-zero.https-expected.txt +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout-zero.https-expected.txt
@@ -1,5 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message PASS Tests that when timeout is zero (and maximumAge is too), the error callback is called immediately with code TIMEOUT. Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout.https-expected.txt b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout.https-expected.txt new file mode 100644 index 0000000..e11f094 --- /dev/null +++ b/third_party/blink/web_tests/flag-specific/disable-site-isolation-trials/wpt_internal/geolocation-api/timeout.https-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +PASS Tests that when timeout is non-zero, the success callback is called as expected. +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test-expected.txt new file mode 100644 index 0000000..2f00ef1 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility of AppManifestView on application panel. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test.js new file mode 100644 index 0000000..5ee82a32 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/app-manifest-view-a11y-test.js
@@ -0,0 +1,29 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + + TestRunner.addResult('Tests accessibility of AppManifestView on application panel.'); + const manifest = `{ + "name": "TestManifest", + "short_name": "TestManifest", + "display": "standalone", + "start_url": ".", + "background_color": "#fff123", + "theme_color": "#123fff", + "description": "A test manifest.", + "icons": [{ + "src": "icon.png", + "sizes": "256x256", + "type": "image/png" + }] + }`; + + await TestRunner.showPanel('resources'); + const manifestView = UI.panels.resources.visibleView; + await manifestView.renderManifest('test_manifest', manifest, [], []); + await AxeCoreTestRunner.runValidation(manifestView.contentElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test-expected.txt new file mode 100644 index 0000000..2c5936f3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Tests accessibility in the Storage view using the axe-core linter. +Storage view is visible: true +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test.js new file mode 100644 index 0000000..c61e3d4 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/clear-storage-a11y-test.js
@@ -0,0 +1,32 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +(async function() { + TestRunner.addResult('Tests accessibility in the Storage view using the axe-core linter.'); + await TestRunner.loadTestModule('application_test_runner'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await ApplicationTestRunner.resetState(); + await TestRunner.showPanel('resources'); + await UI.viewManager.showView('resources'); + + const parent = UI.panels.resources.sidebar.applicationTreeElement; + const storageElement = parent.children().find(child => child.title === 'Storage'); + storageElement.select(); + const storageView = UI.panels.resources.visibleView; + TestRunner.addResult('Storage view is visible: ' + ApplicationTestRunner.isStorageView(storageView)); + + async function writeArray() { + const array = Array(1).fill(0); + const mainFrameId = TestRunner.resourceTreeModel.mainFrame.id; + await new Promise(resolve => ApplicationTestRunner.createDatabase(mainFrameId, 'Database1', resolve)); + await new Promise( + resolve => ApplicationTestRunner.createObjectStore(mainFrameId, 'Database1', 'Store1', 'id', true, resolve)); + await new Promise( + resolve => + ApplicationTestRunner.addIDBValue(mainFrameId, 'Database1', 'Store1', {key: 1, value: array}, '', resolve)); + } + + await writeArray(); + await AxeCoreTestRunner.runValidation(storageView.contentElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test-expected.txt new file mode 100644 index 0000000..101ff944 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility of ServiceWorkersView on application panel. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test.js new file mode 100644 index 0000000..1ed4a836 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/application-panel/service-worker-view-a11y-test.js
@@ -0,0 +1,25 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility of ServiceWorkersView on application panel.'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('application_test_runner'); + await ApplicationTestRunner.resetState(); + + await TestRunner.showPanel('resources'); + + const scriptURL = 'http://127.0.0.1:8000/devtools/service-workers/resources/service-worker-empty.js'; + const scope1 = 'http://127.0.0.1:8000/devtools/service-workers/resources/scope1/'; + const scope2 = 'http://127.0.0.1:8000/devtools/service-workers/resources/scope2/'; + Resources.ServiceWorkersView.setThrottleDisabledForDebugging = true; + + UI.panels.resources.sidebar.serviceWorkersTreeElement.select(); + ApplicationTestRunner.registerServiceWorker(scriptURL, scope1); + ApplicationTestRunner.registerServiceWorker(scriptURL, scope2); + const element = UI.panels.resources.visibleView.contentElement; + + await AxeCoreTestRunner.runValidation(element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt new file mode 100644 index 0000000..5a83a893 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test-expected.txt
@@ -0,0 +1,10 @@ +Tests accessibility in the elements.domProperties view using the axe-core linter. +aXe violations: [] + +Tests accessibility in the performance.monitor view using the axe-core linter. +aXe violations: [] + +Tests accessibility in the sensors view using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js new file mode 100644 index 0000000..3066405 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/basic-a11y-test.js
@@ -0,0 +1,35 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + const locationsToTest = + [ + // elements + 'elements.domProperties', + // Performance Monitor + 'performance.monitor', + // Sensors + 'sensors', + ]; + + // TODO(crbug.com/1004940): exclude scrollable-region-focusable for performance.monitor only + const NO_SCROLLABLE_REGION_FOCUSABLE_RULESET = { + 'scrollable-region-focusable': { enabled: false, }, + }; + + for (const location of locationsToTest) { + await loadViewAndTestElementViolations(location); + } + + TestRunner.completeTest(); + + async function loadViewAndTestElementViolations(view) { + TestRunner.addResult(`Tests accessibility in the ${view} view using the axe-core linter.`); + await UI.viewManager.showView(view); + const widget = await UI.viewManager.view(view).widget(); + const ruleset = view === 'performance.monitor' ? NO_SCROLLABLE_REGION_FOCUSABLE_RULESET : {}; + await AxeCoreTestRunner.runValidation(widget.element, ruleset); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test-expected.txt new file mode 100644 index 0000000..e9e2853 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test-expected.txt
@@ -0,0 +1,6 @@ +Tests accessibility in the Changes drawer. +Showing the Changes drawer. +Running aXe on the Changes drawer. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test.js new file mode 100644 index 0000000..acce8ed --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/changes/changes-a11y-test.js
@@ -0,0 +1,26 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Changes drawer.'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadLegacyModule('changes'); + + const diff = [ + {0: Diff.Diff.Operation.Insert, 1: ['line 1 inserted']}, + {0: Diff.Diff.Operation.Delete, 1: ['line 2 deleted']}, + ]; + const uiSourceCodeMock = {mimeType: () => {}}; + + TestRunner.addResult('Showing the Changes drawer.'); + await UI.viewManager.showView('changes.changes'); + const changesWidget = await UI.viewManager.view('changes.changes').widget(); + changesWidget.selectedUISourceCode = uiSourceCodeMock; + changesWidget.renderDiffRows(diff); + + TestRunner.addResult('Running aXe on the Changes drawer.'); + await AxeCoreTestRunner.runValidation(changesWidget.contentElement); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test-expected.txt new file mode 100644 index 0000000..41fdf3b --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in the console using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test.js new file mode 100644 index 0000000..0ac4fce --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/console-a11y-test.js
@@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + TestRunner.addResult( + 'Tests accessibility in the console using the axe-core linter.'); + + await UI.viewManager.showView('console'); + const widget = await UI.viewManager.view('console').widget(); + + await AxeCoreTestRunner.runValidation(widget.element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test-expected.txt new file mode 100644 index 0000000..b8e402c --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Tests accessibility in DOM breakpoints using the axe-core linter. +Test DOM breakpoint container with multiple breakpoints. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test.js new file mode 100644 index 0000000..d9a80fff --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/dom-breakpoints-a11y-test.js
@@ -0,0 +1,27 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +(async function() { + TestRunner.addResult( + 'Tests accessibility in DOM breakpoints using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('elements_test_runner'); + await TestRunner.showPanel('elements'); + UI.panels.elements.sidebarPaneView.tabbedPane().selectTab('elements.domBreakpoints', true); + + await TestRunner.navigatePromise( + '../../sources/debugger-breakpoints/resources/dom-breakpoints.html'); + + const rootElement = await ElementsTestRunner.nodeWithIdPromise('rootElement'); + + // Add Dom breakpoints and then test + TestRunner.domDebuggerModel.setDOMBreakpoint(rootElement, Protocol.DOMDebugger.DOMBreakpointType.SubtreeModified); + TestRunner.domDebuggerModel.setDOMBreakpoint(rootElement, Protocol.DOMDebugger.DOMBreakpointType.AttributeModified); + TestRunner.addResult( + 'Test DOM breakpoint container with multiple breakpoints.'); + + const widget = UI.panels.elements.sidebarPaneView.tabbedPane().visibleView; + await AxeCoreTestRunner.runValidation(widget.element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test-expected.txt new file mode 100644 index 0000000..715189b --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test-expected.txt
@@ -0,0 +1,8 @@ +Tests accessibility in DOM eventlistener pane using axe-core linter. +Running the axe-core linter on tree element. +aXe violations: [] + +Running the axe-core linter on toolbar. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test.js new file mode 100644 index 0000000..a7c7645 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/event-listeners-a11y-test.js
@@ -0,0 +1,33 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + const DEFAULT_RULESET = { }; + + TestRunner.addResult( + 'Tests accessibility in DOM eventlistener pane using axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + const view = 'elements.eventListeners'; + const widget = await UI.viewManager.view(view).widget(); + await UI.viewManager.showView(view); + + const treeElement = widget.element; + TestRunner.addResult('Running the axe-core linter on tree element.'); + await AxeCoreTestRunner.runValidation(treeElement, NO_REQUIRED_CHILDREN_RULESET); + + const toolbarElement = treeElement.parentElement.querySelector('.toolbar'); + TestRunner.addResult('Running the axe-core linter on toolbar.'); + await AxeCoreTestRunner.runValidation(toolbarElement, DEFAULT_RULESET); + + TestRunner.completeTest(); + })();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test-expected.txt new file mode 100644 index 0000000..ef007ce --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test-expected.txt
@@ -0,0 +1,21 @@ + +Running: testElementsDomTree +Tests accessibility in the DOM tree using the axe-core linter +aXe violations: [] + + +Running: testElementsDomBreadcrumbs +Tests accessibility in the DOM breadcrumbs using the axe-core linter +aXe violations: [] + + +Running: testElementsStylesPane +Tests accessibility of the Styles pane using the axe-core linter +aXe violations: [] + + +Running: testElementsComputedStylesPane +Tests accessibility in the Computed Styles pane using the axe-core linter +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test.js new file mode 100644 index 0000000..b90b592 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/elements/main-tool-test.js
@@ -0,0 +1,63 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + const DEFAULT_RULESET = {}; + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('elements_test_runner'); + const tests = [ + testElementsDomTree, + testElementsDomBreadcrumbs, + testElementsStylesPane, + testElementsComputedStylesPane, + ]; + + async function testElementsDomTree() { + TestRunner.addResult('Tests accessibility in the DOM tree using the axe-core linter'); + const view = 'elements'; + await UI.viewManager.showView(view); + const widget = await UI.viewManager.view(view).widget(); + const element = widget.element.querySelector('#elements-content'); + + await AxeCoreTestRunner.runValidation(element, NO_REQUIRED_CHILDREN_RULESET); + } + + async function testElementsDomBreadcrumbs() { + TestRunner.addResult('Tests accessibility in the DOM breadcrumbs using the axe-core linter'); + const view = 'elements'; + await UI.viewManager.showView(view); + const widget = await UI.viewManager.view(view).widget(); + const element = widget.element.querySelector('#elements-crumbs'); + + await AxeCoreTestRunner.runValidation(element, DEFAULT_RULESET); + } + + async function testElementsStylesPane() { + TestRunner.addResult('Tests accessibility of the Styles pane using the axe-core linter'); + await UI.viewManager.showView('elements'); + const panel = Elements.ElementsPanel.instance(); + const element = panel.stylesWidget.element; + + await AxeCoreTestRunner.runValidation(element, NO_REQUIRED_CHILDREN_RULESET); + } + + async function testElementsComputedStylesPane() { + TestRunner.addResult('Tests accessibility in the Computed Styles pane using the axe-core linter'); + await UI.viewManager.showView('elements'); + await ElementsTestRunner.showComputedStyles(); + const panel = Elements.ElementsPanel.instance(); + const element = panel.computedStyleWidget.element; + + await AxeCoreTestRunner.runValidation(element, DEFAULT_RULESET); + } + + TestRunner.runAsyncTestSuite(tests); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test-expected.txt new file mode 100644 index 0000000..0e7c18f --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Tests accessibility in the lighthouse start view using the axe-core linter. + +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test.js new file mode 100644 index 0000000..f0714fe --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/lighthouse-start-view-a11y-test.js
@@ -0,0 +1,14 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the lighthouse start view using the axe-core linter.\n'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.showPanel('lighthouse'); + + const widget = await UI.viewManager.view('lighthouse').widget(); + await AxeCoreTestRunner.runValidation(widget.contentElement); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test-expected.txt new file mode 100644 index 0000000..f7b1929 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in heap profiler using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test.js new file mode 100644 index 0000000..a61c987 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/memory/heap-profiler-a11y-test.js
@@ -0,0 +1,42 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in heap profiler using the axe-core linter.'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('heap_profiler_test_runner'); + await TestRunner.showPanel('heap_profiler'); + await TestRunner.evaluateInPagePromise(` + class MyTestClass { + constructor() { + this.z = new Uint32Array(10000); // Pull the class to top. + this.myFunction = () => 42; + } + }; + function* myGenerator() { + yield 1; + } + class MyTestClass2 {} + window.myTestClass = new MyTestClass(); + window.myTestGenerator = myGenerator(); + window.myTestClass2 = new MyTestClass2();`); + + await HeapProfilerTestRunner.startSamplingHeapProfiler(); + await TestRunner.evaluateInPagePromise(` + function pageFunction() { + (function () { + window.holder = []; + // Allocate few MBs of data. + for (var i = 0; i < 1000; ++i) + window.holder.push(new Array(1000).fill(42)); + })(); + } + pageFunction();`); + HeapProfilerTestRunner.stopSamplingHeapProfiler(); + + await UI.viewManager.showView('heap_profiler'); + const widget = await UI.viewManager.view('heap_profiler').widget(); + await AxeCoreTestRunner.runValidation(widget.element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test-expected.txt new file mode 100644 index 0000000..ad4b8a2 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in Network conditions view using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test.js new file mode 100644 index 0000000..ab0128a --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/network/network-condition-a11y-test.js
@@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in Network conditions view using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + const view = 'network.config'; + await UI.viewManager.showView(view); + const widget = await UI.viewManager.view(view).widget(); + await AxeCoreTestRunner.runValidation(widget.element); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test-expected.txt new file mode 100644 index 0000000..eebd1e4 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in Performance landing page using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test.js new file mode 100644 index 0000000..cdf1a3d --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/landing-page-a11y-test.js
@@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in Performance landing page using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + const view = 'timeline'; + await UI.viewManager.showView(view); + const widget = await UI.viewManager.view(view).widget(); + await AxeCoreTestRunner.runValidation(widget.element); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test-expected.txt new file mode 100644 index 0000000..8864297 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test-expected.txt
@@ -0,0 +1,16 @@ + +Running: testDetailsView +Tests accessibility in performance Details view using the axe-core linter +aXe violations: [] + + +Running: testBottomUpView +Tests accessibility in performance BottomUp view using the axe-core linter +aXe violations: [] + + +Running: testCallTreeView +Tests accessibility in performance CallTree view using the axe-core linter +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test.js new file mode 100644 index 0000000..9c4ebd8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance-pane-a11y-test.js
@@ -0,0 +1,85 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('performance_test_runner'); + await TestRunner.showPanel('timeline'); + + const testData = [ + { + 'name': 'top level event name', + 'ts': 1000000, + 'ph': 'B', + 'tid': 1, + 'pid': 100, + 'cat': 'toplevel', + 'args': {'data': {'message': 'AAA'}} + }, + { + 'name': 'TimeStamp', + 'ts': 1010000, + 'ph': 'B', + 'tid': 1, + 'pid': 100, + 'cat': 'toplevel', + 'args': {'data': {'message': 'BBB'}} + }, + { + 'name': 'TimeStamp', + 'ts': 1020000, + 'ph': 'B', + 'tid': 1, + 'pid': 100, + 'cat': 'toplevel', + 'args': {'data': {'message': 'CCC'}} + }, + ]; + + // create dummy data for test + const model = await PerformanceTestRunner.createPerformanceModelWithEvents(testData); + + const detailsView = UI.panels.timeline.flameChart.detailsView; + + async function testDetailsView() { + TestRunner.addResult('Tests accessibility in performance Details view using the axe-core linter'); + + // Details pane gets data from the parent TimelineDetails view + detailsView.setModel(model, PerformanceTestRunner.mainTrack()); + + const tabbedPane = detailsView.tabbedPane; + tabbedPane.selectTab(Timeline.TimelineDetailsView.Tab.Details); + const detailsTab = tabbedPane.visibleView; + + await AxeCoreTestRunner.runValidation(detailsTab.element); + } + + async function testViewWithName(tab) { + TestRunner.addResult(`Tests accessibility in performance ${tab} view using the axe-core linter`); + const tabbedPane = detailsView.tabbedPane; + tabbedPane.selectTab(tab); + const detailsTab = tabbedPane.visibleView; + + // update child views with the same test data + detailsTab.setModel(model, PerformanceTestRunner.mainTrack()); + detailsTab.updateContents(Timeline.TimelineSelection.fromRange( + model.timelineModel().minimumRecordTime(), + model.timelineModel().maximumRecordTime())); + + await AxeCoreTestRunner.runValidation(detailsTab.element); + } + + function testBottomUpView() { + return testViewWithName(Timeline.TimelineDetailsView.Tab.BottomUp); + } + + function testCallTreeView() { + return testViewWithName(Timeline.TimelineDetailsView.Tab.CallTree); + } + + TestRunner.runAsyncTestSuite([ + testDetailsView, + testBottomUpView, + testCallTreeView, + ]); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test-expected.txt new file mode 100644 index 0000000..a2064d8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test-expected.txt
@@ -0,0 +1,6 @@ +Performance panel loaded. +Loading a performance model. +Running aXe on the event log pane. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test.js new file mode 100644 index 0000000..deb0db3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/performance/performance_event_log_a11y_test.js
@@ -0,0 +1,25 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('performance_test_runner'); + + await TestRunner.showPanel('timeline'); + TestRunner.addResult('Performance panel loaded.'); + + const tabbedPane = UI.panels.timeline.flameChart.detailsView.tabbedPane; + tabbedPane.selectTab(Timeline.TimelineDetailsView.Tab.EventLog); + + TestRunner.addResult('Loading a performance model.'); + const view = tabbedPane.visibleView; + const model = await PerformanceTestRunner.createPerformanceModelWithEvents([{}]); + view.setModel(model, PerformanceTestRunner.mainTrack()); + view.updateContents(Timeline.TimelineSelection.fromRange( + model.timelineModel().minimumRecordTime(), model.timelineModel().maximumRecordTime())); + + TestRunner.addResult('Running aXe on the event log pane.'); + await AxeCoreTestRunner.runValidation(view.contentElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test-expected.txt new file mode 100644 index 0000000..5f14437 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Test accessibility in Quick Open dialog + +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test.js new file mode 100644 index 0000000..273ecb6 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/quick-open-a11y-test.js
@@ -0,0 +1,18 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Test accessibility in Quick Open dialog\n'); + await TestRunner.loadLegacyModule('quick_open'); + await TestRunner.loadTestModule('axe_core_test_runner'); + + QuickOpen.QuickOpen.show(''); + + const dialogWidget = UI.Dialog.instance.widget(); + const filteredListWidget = dialogWidget.defaultFocusedChild; + TestRunner.assertTrue(filteredListWidget instanceof QuickOpen.FilteredListWidget); + + await AxeCoreTestRunner.runValidation(filteredListWidget.contentElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test-expected.txt new file mode 100644 index 0000000..e6ab923 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in the rendering view using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test.js new file mode 100644 index 0000000..b42c457c --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/rendering/basic-rendering-a11y-test.js
@@ -0,0 +1,14 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + + TestRunner.addResult('Tests accessibility in the rendering view using the axe-core linter.'); + await UI.viewManager.showView('rendering'); + const renderingView = await UI.viewManager.view('rendering').widget(); + await AxeCoreTestRunner.runValidation(renderingView.element); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test-expected.txt new file mode 100644 index 0000000..ee9ecd3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test-expected.txt
@@ -0,0 +1,3 @@ +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test.js new file mode 100644 index 0000000..f7ea02f --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-origin-a11y-test.js
@@ -0,0 +1,36 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('security_test_runner'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.showPanel('security'); + + const request1 = new SDK.NetworkRequest(0, 'https://foo.test/', 'https://foo.test', 0, 0, null); + request1.setSecurityState(Protocol.Security.SecurityState.Secure); + const securityDetails = { + protocol : 'TLS 1.2', + keyExchange : 'Key_Exchange', + keyExchangeGroup : '', + cipher : 'Cypher', + mac : 'Mac', + subjectName : 'foo.test', + sanList : ['foo.test', '*.test'], + issuer : 'Super CA', + validFrom : 1490000000, + validTo : 2000000000, + CertificateId : 0, + signedCertificateTimestampList : [], + certificateTransparencyCompliance : Protocol.Network.CertificateTransparencyCompliance.Compliant + }; + + request1.setSecurityDetails(securityDetails); + SecurityTestRunner.dispatchRequestFinished(request1); + const securityPanel = Security.SecurityPanel.instance(); + + securityPanel.showOrigin('https://foo.test'); + await AxeCoreTestRunner.runValidation(securityPanel.contentElement); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test-expected.txt new file mode 100644 index 0000000..ee9ecd3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test-expected.txt
@@ -0,0 +1,3 @@ +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test.js new file mode 100644 index 0000000..493e488 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/security/security-overview-a11y-test.js
@@ -0,0 +1,23 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('security_test_runner'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.showPanel('security'); + + const pageVisibleSecurityState = new Security.PageVisibleSecurityState( + Protocol.Security.SecurityState.Secure, /* certificateSecurityState= */ null, + /* safetyTipsInfo= */ null, /* securityStateIssueIds= */ []); + TestRunner.mainTarget.model(Security.SecurityModel).dispatchEventToListeners( + Security.SecurityModel.Events.VisibleSecurityStateChanged, pageVisibleSecurityState); + const request = new SDK.NetworkRequest(0, 'http://foo.test', 'https://foo.test', 0, 0, null); + request.setBlockedReason(Protocol.Network.BlockedReason.MixedContent); + request.mixedContentType = 'blockable'; + SecurityTestRunner.dispatchRequestFinished(request); + const securityPanel = Security.SecurityPanel.instance(); + await AxeCoreTestRunner.runValidation(securityPanel.mainView.contentElement); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test-expected.txt new file mode 100644 index 0000000..d65a09a7 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test-expected.txt
@@ -0,0 +1,17 @@ +Tests accessibility in IgnoreList view using the axe-core linter. + +Running: testAddPattern +Opened input box: true +aXe violations: [] + + +Running: testPatternList +Added a pattern in the list: test* +aXe violations: [] + + +Running: testPatternError +Error message: Pattern cannot be empty +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test.js new file mode 100644 index 0000000..d8e0fb3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/blackbox-a11y-test.js
@@ -0,0 +1,42 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in IgnoreList view using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + await UI.viewManager.showView('blackbox'); + const ignoreListWidget = await UI.viewManager.view('blackbox').widget(); + + async function testAddPattern() { + const addPatternButton = ignoreListWidget.defaultFocusedElement; + // Make add pattern editor visible + addPatternButton.click(); + + const ignoreListInputs = ignoreListWidget.list.editor.controls; + TestRunner.addResult(`Opened input box: ${Boolean(ignoreListInputs)}`); + + await AxeCoreTestRunner.runValidation(ignoreListWidget.contentElement); + } + + async function testPatternList() { + ignoreListWidget.list.appendItem('test*', true); + TestRunner.addResult(`Added a pattern in the list: ${ignoreListWidget.list.items}`); + await AxeCoreTestRunner.runValidation(ignoreListWidget.contentElement); + } + + async function testPatternError() { + const ignoreListEditor = ignoreListWidget.list.editor; + const patternInput = ignoreListEditor.controls[0]; + // Blur patternInput to run validator + patternInput.blur(); + + const errorMessage = ignoreListEditor.errorMessageContainer.textContent; + TestRunner.addResult(`Error message: ${errorMessage}`); + + await AxeCoreTestRunner.runValidation(ignoreListWidget.contentElement); + } + + TestRunner.runAsyncTestSuite([testAddPattern, testPatternList, testPatternError]); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test-expected.txt new file mode 100644 index 0000000..d08f9b7 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test-expected.txt
@@ -0,0 +1,6 @@ +Test error message in the settings tool Emulated Device pane + +Running: testNewDeviceError +Invalidating the device pixel ratio +Error message: Device pixel ratio must be a number or blank. +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test.js new file mode 100644 index 0000000..ad44abd --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/emulated-device-a11y-test.js
@@ -0,0 +1,31 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Test error message in the settings tool Emulated Device pane'); + await UI.viewManager.showView('devices'); + const devicesWidget = await UI.viewManager.view('devices').widget(); + + async function testNewDeviceError() { + const addDeviceButton = devicesWidget.defaultFocusedElement; + addDeviceButton.click(); + + TestRunner.addResult('Invalidating the device pixel ratio'); + const editor = devicesWidget.list.editor; + const title = editor.control('title'); + const width = editor.control('width'); + const height = editor.control('height'); + const scale = editor.control('scale'); + title.value = 'Device'; + width.value = 700; + height.value = 400; + scale.value = ' zzz.213213'; + + scale.dispatchEvent(new Event('input')); + const errorMessage = devicesWidget.list.editor.errorMessageContainer.textContent; + TestRunner.addResult(`Error message: ${errorMessage}`); + } + + TestRunner.runAsyncTestSuite([testNewDeviceError]); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test-expected.txt new file mode 100644 index 0000000..626067a2e6 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test-expected.txt
@@ -0,0 +1,17 @@ +Tests accessibility in the settings tool locations pane using the axe-core linter. + +Running: testAddLocation +Opened input box: true +aXe violations: [] + + +Running: testNewLocationError +Invalidating the Location name input +Error message: Location name cannot be empty +Invalidating the Latitude input +Error message: Latitude must be a number +Invalidating the Longitude input +Error message: Longitude must be a number +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test.js new file mode 100644 index 0000000..fcebbc1 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/locations-a11y-test.js
@@ -0,0 +1,53 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the settings tool locations pane using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + await UI.viewManager.showView('emulation-locations'); + const locationsWidget = await UI.viewManager.view('emulation-locations').widget(); + + async function testAddLocation() { + const addLocationButton = locationsWidget.defaultFocusedElement; + addLocationButton.click(); + + const newLocationInputs = locationsWidget.list.editor.controls; + TestRunner.addResult(`Opened input box: ${Boolean(newLocationInputs)}`); + + await AxeCoreTestRunner.runValidation(locationsWidget.contentElement); + } + + async function testNewLocationError() { + const locationsEditor = locationsWidget.list.editor; + const newLocationInputs = locationsEditor.controls; + const nameInput = newLocationInputs[0]; + const latitudeInput = newLocationInputs[1]; + const longitudeInput = newLocationInputs[2]; + let errorMessage; + + TestRunner.addResult(`Invalidating the ${nameInput.getAttribute('aria-label')} input`); + nameInput.blur(); + errorMessage = locationsEditor.errorMessageContainer.textContent; + TestRunner.addResult(`Error message: ${errorMessage}`); + + TestRunner.addResult(`Invalidating the ${latitudeInput.getAttribute('aria-label')} input`); + nameInput.value = 'location'; + latitudeInput.value = 'a.a'; + latitudeInput.dispatchEvent(new Event('input')); + errorMessage = locationsEditor.errorMessageContainer.textContent; + TestRunner.addResult(`Error message: ${errorMessage}`); + + TestRunner.addResult(`Invalidating the ${longitudeInput.getAttribute('aria-label')} input`); + latitudeInput.value = '1.1'; + longitudeInput.value = '1a.1'; + longitudeInput.dispatchEvent(new Event('input')); + errorMessage = locationsEditor.errorMessageContainer.textContent; + TestRunner.addResult(`Error message: ${errorMessage}`); + + await AxeCoreTestRunner.runValidation(locationsWidget.contentElement); + } + + TestRunner.runAsyncTestSuite([testAddLocation, testNewLocationError]); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test-expected.txt new file mode 100644 index 0000000..b63e760 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in the settings menu using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test.js new file mode 100644 index 0000000..9139d45d --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/menu-a11y-test.js
@@ -0,0 +1,21 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult( + 'Tests accessibility in the settings menu using the axe-core linter.'); + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadLegacyModule('settings'); + + await UI.actionRegistry.action('settings.show').execute(); + + const tabbedPane = Settings.SettingsScreen.instance().tabbedLocation.tabbedPane(); + + // force tabs to update + tabbedPane.innerUpdateTabElements(); + + await AxeCoreTestRunner.runValidation([tabbedPane.headerElement, tabbedPane.tabsElement]); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test-expected.txt new file mode 100644 index 0000000..9aed357 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test-expected.txt
@@ -0,0 +1,6 @@ +Tests accessibility in the settings tool shortcuts pane using the axe-core linter. + +Running: testShortcuts +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test.js new file mode 100644 index 0000000..5176c154 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/shortcuts-a11y-test.js
@@ -0,0 +1,22 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the settings tool shortcuts pane using the axe-core linter.'); + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadLegacyModule('settings'); + + async function testShortcuts() { + // Open a view that supports context menu action to open shortcuts panel + await UI.viewManager.showView('sources'); + + // Open Shortcuts pane using context menu action + await UI.actionRegistry.action('settings.shortcuts').execute(); + + const settingsPaneElement = Settings.SettingsScreen.instance().tabbedLocation.tabbedPane().contentElement; + await AxeCoreTestRunner.runValidation(settingsPaneElement); + } + + TestRunner.runAsyncTestSuite([testShortcuts]); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test-expected.txt new file mode 100644 index 0000000..43c2233 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in the settings workspace view using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test.js new file mode 100644 index 0000000..53b6d330 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/settings/workspace-a11y-test.js
@@ -0,0 +1,20 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('bindings_test_runner'); + + TestRunner.addResult( + 'Tests accessibility in the settings workspace view using the axe-core linter.'); + + const fs = new BindingsTestRunner.TestFileSystem('file:///this/is/a/test'); + await fs.reportCreatedPromise(); + + await UI.viewManager.showView('workspace'); + const workspaceWidget = await UI.viewManager.view('workspace').widget(); + + await AxeCoreTestRunner.runValidation(workspaceWidget.element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test-expected.txt new file mode 100644 index 0000000..bb05b12 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test-expected.txt
@@ -0,0 +1,7 @@ +Testing accessibility in the call stack sidebar pane. +Set timer for test function. +Call stack pane content: Show ignore-listed framesNot pausedSome call frames have warnings(anonymous)test.js:21callWithAsyncStacktest.js:14call1wrapper.js:1setTimeout (async)scheduleTestFunctionVM:3(anonymous)VM:1Show more +Running the axe-core linter on the call stack sidebar pane. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test.js new file mode 100644 index 0000000..2654c01 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/call-stack-a11y-test.js
@@ -0,0 +1,37 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + await TestRunner.showPanel('sources'); + + TestRunner.addResult('Testing accessibility in the call stack sidebar pane.'); + await TestRunner.evaluateInPagePromise(` + function callWithAsyncStack(f, depth) { + if (depth === 0) { + f(); + return; + } + wrapper = eval('(function call' + depth + '() { callWithAsyncStack(f, depth - 1) }) //# sourceURL=wrapper.js'); + queueMicrotask(wrapper); + } + function testFunction() { + callWithAsyncStack(() => {debugger}, 5); + } + //# sourceURL=test.js + `); + + await SourcesTestRunner.startDebuggerTestPromise(/* quiet */ true); + await SourcesTestRunner.runTestFunctionAndWaitUntilPausedPromise(); + await TestRunner.addSnifferPromise(Sources.CallStackSidebarPane.prototype, 'updatedForTest'); + + const callStackPane = Sources.CallStackSidebarPane.instance(); + const callStackElement = callStackPane.contentElement; + TestRunner.addResult(`Call stack pane content: ${TestRunner.clearSpecificInfoFromStackFrames(callStackElement.deepTextContent())}`); + TestRunner.addResult('Running the axe-core linter on the call stack sidebar pane.'); + await AxeCoreTestRunner.runValidation(callStackElement); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test-expected.txt new file mode 100644 index 0000000..0780fd05 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test-expected.txt
@@ -0,0 +1,10 @@ +Testing accessibility in the DOM breakpoints pane. +Setting DOM breakpoints. +DOM breakpoints container text content: DOM BreakpointsNo breakpointsSubtree modifiedNode removed +DOM breakpoints container ARIA descriptions: checked,unchecked +DOM breakpoints pane text content: No breakpointsSubtree modifiedNode removed +DOM breakpoints pane ARIA descriptions: checked,unchecked +Running the axe-core linter on the DOM breakpoints pane. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test.js new file mode 100644 index 0000000..6f266278 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/dom-breakpoints-pane-a11y-test.js
@@ -0,0 +1,55 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('elements_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + await TestRunner.showPanel('elements'); + await TestRunner.showPanel('sources'); + await TestRunner.navigatePromise( + '../../sources/debugger-breakpoints/resources/dom-breakpoints.html'); + + TestRunner.addResult('Testing accessibility in the DOM breakpoints pane.'); + + // Expand the DOM Breakpoints container + const domBreakpointContainer = UI.panels.sources.sidebarPaneStack.expandableContainers.get('sources.domBreakpoints'); + await domBreakpointContainer.expand(); + + TestRunner.addResult('Setting DOM breakpoints.'); + const rootElement = await ElementsTestRunner.nodeWithIdPromise('rootElement'); + TestRunner.domDebuggerModel.setDOMBreakpoint(rootElement, Protocol.DOMDebugger.DOMBreakpointType.SubtreeModified); + + const hostElement = await ElementsTestRunner.nodeWithIdPromise('hostElement'); + const breakpoint = + TestRunner.domDebuggerModel.setDOMBreakpoint(hostElement, Protocol.DOMDebugger.DOMBreakpointType.NodeRemoved); + TestRunner.domDebuggerModel.toggleDOMBreakpoint(breakpoint, false); + + const domBreakpointsPane = BrowserDebugger.DOMBreakpointsSidebarPane.instance(); + + TestRunner.addResult(`DOM breakpoints container text content: ${domBreakpointContainer.contentElement.deepTextContent()}`); + TestRunner.addResult( + `DOM breakpoints container ARIA descriptions: ${getDeepARIADescriptions(domBreakpointContainer.contentElement)}`); + TestRunner.addResult(`DOM breakpoints pane text content: ${domBreakpointsPane.contentElement.deepTextContent()}`); + TestRunner.addResult( + `DOM breakpoints pane ARIA descriptions: ${getDeepARIADescriptions(domBreakpointsPane.contentElement)}`); + + TestRunner.addResult( + 'Running the axe-core linter on the DOM breakpoints pane.'); + + await AxeCoreTestRunner.runValidation(domBreakpointContainer.element); + TestRunner.completeTest(); + + function getDeepARIADescriptions(root) { + let node = root; + const descriptions = []; + while (node) { + if (node.nodeType === node.ELEMENT_NODE && node.hasAttribute('aria-description')) { + descriptions.push(node.getAttribute('aria-description')); + } + node = node.traverseNextNode(root); + } + return descriptions.join(); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test-expected.txt new file mode 100644 index 0000000..016cd8e --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test-expected.txt
@@ -0,0 +1,14 @@ +Adding global listener. +Dumping event listeners view: + +======== touchstart ======== +== Raw +[expanded] WindowRemoveToggle Passiveglobal-listeners-sidebar-a11y-test.js:13 + useCapture: false + passive: true + once: false + handler: () => console.log +Running the axe-core linter on the global listeners pane. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test.js new file mode 100644 index 0000000..c1cc0c8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/global-listeners-sidebar-a11y-test.js
@@ -0,0 +1,23 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('elements_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + await TestRunner.showPanel('sources'); + await TestRunner.navigatePromise('../sources/debugger-breakpoints/resources/dom-breakpoints.html'); + + TestRunner.addResult('Adding global listener.'); + await TestRunner.evaluateInPagePromise('window.addEventListener(\'touchstart\', () => console.log);'); + await UI.viewManager.showView('sources.globalListeners'); + const globalListenersPane = BrowserDebugger.ObjectEventListenersSidebarPane.instance(); + const eventListenersView = globalListenersPane.eventListenersView; + + TestRunner.addResult('Dumping event listeners view:'); + await ElementsTestRunner.expandAndDumpEventListenersPromise(eventListenersView); + TestRunner.addResult('Running the axe-core linter on the global listeners pane.'); + await AxeCoreTestRunner.runValidation(globalListenersPane.contentElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test-expected.txt new file mode 100644 index 0000000..954800b --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test-expected.txt
@@ -0,0 +1,7 @@ +Tests accessibility in the Sources panel Navigator pane Contentscripts tab using axe-core. +top + content-script-context + contentScript1.js +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test.js new file mode 100644 index 0000000..05b5998 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-contentscripts-a11y-test.js
@@ -0,0 +1,45 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Sources panel Navigator pane Contentscripts tab using axe-core.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sdk_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + + await UI.viewManager.showView('sources'); + await setup(); + + await testA11yForView(NO_REQUIRED_CHILDREN_RULESET); + + TestRunner.completeTest(); + + async function setup() { + // Add content scripts + const pageMock = new SDKTestRunner.PageMock('http://example.com'); + pageMock.connectAsMainTarget('page-target'); + const url = 'contentScript1.js'; + pageMock.evalScript(url, 'var script', true /* isContentScript */); + await TestRunner.waitForUISourceCode(url); + } + + async function testA11yForView(ruleSet) { + await UI.viewManager.showView('navigator-contentScripts'); + const sourcesNavigatorView = new Sources.ContentScriptsNavigatorView(); + + sourcesNavigatorView.show(UI.inspectorView.element); + SourcesTestRunner.dumpNavigatorView(sourcesNavigatorView); + const element = UI.panels.sources.navigatorTabbedLocation.tabbedPane().element; + await AxeCoreTestRunner.runValidation(element, ruleSet); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test-expected.txt new file mode 100644 index 0000000..7b62f2e --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Tests accessibility in the Sources panel Navigator pane FileSystem tab using axe-core. +www3 [dimmed] +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test.js new file mode 100644 index 0000000..fc21ade --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-filesystem-a11y-test.js
@@ -0,0 +1,42 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Sources panel Navigator pane FileSystem tab using axe-core.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('bindings_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + + await UI.viewManager.showView('sources'); + await setup(); + + await testA11yForView(NO_REQUIRED_CHILDREN_RULESET); + + TestRunner.completeTest(); + + async function setup() { + // Add a filesystem folder + const testFileSystem = new BindingsTestRunner.TestFileSystem('file:///var/www3'); + await testFileSystem.reportCreatedPromise(); + } + + async function testA11yForView(ruleSet) { + await UI.viewManager.showView('navigator-files'); + const sourcesNavigatorView = new Sources.FilesNavigatorView(); + + sourcesNavigatorView.show(UI.inspectorView.element); + SourcesTestRunner.dumpNavigatorView(sourcesNavigatorView); + const element = UI.panels.sources.navigatorTabbedLocation.tabbedPane().element; + await AxeCoreTestRunner.runValidation(element, ruleSet); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test-expected.txt new file mode 100644 index 0000000..591b14e --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test-expected.txt
@@ -0,0 +1,8 @@ +Tests accessibility in the Sources panel Navigator pane Network tab using axe-core. +top + 127.0.0.1:8000 + devtools/resources + inspected-page.html +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test.js new file mode 100644 index 0000000..6dd44d8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-network-a11y-test.js
@@ -0,0 +1,33 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Sources panel Navigator pane Network tab using axe-core.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + + await UI.viewManager.showView('sources'); + await testA11yForView(NO_REQUIRED_CHILDREN_RULESET); + + TestRunner.completeTest(); + + async function testA11yForView(ruleSet) { + await UI.viewManager.showView('navigator-network'); + const sourcesNavigatorView = new Sources.NetworkNavigatorView(); + + sourcesNavigatorView.show(UI.inspectorView.element); + SourcesTestRunner.dumpNavigatorView(sourcesNavigatorView); + const element = UI.panels.sources.navigatorTabbedLocation.tabbedPane().element; + await AxeCoreTestRunner.runValidation(element, ruleSet); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test-expected.txt new file mode 100644 index 0000000..9a9d5f0f --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Tests accessibility in the Sources panel Navigator pane Overrides tab using axe-core. +tmp/ [dimmed] +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test.js new file mode 100644 index 0000000..d2f6dba8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-overrides-a11y-test.js
@@ -0,0 +1,41 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Sources panel Navigator pane Overrides tab using axe-core.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('bindings_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + + await UI.viewManager.showView('sources'); + + await setup(); + await testA11yForView(NO_REQUIRED_CHILDREN_RULESET); + + TestRunner.completeTest(); + + async function setup() { + // Add an overrides folder + await BindingsTestRunner.createOverrideProject('file:///tmp/'); + } + + async function testA11yForView(ruleSet) { + await UI.viewManager.showView('navigator-overrides'); + const sourcesNavigatorView = new Sources.OverridesNavigatorView(); + + sourcesNavigatorView.show(UI.inspectorView.element); + SourcesTestRunner.dumpNavigatorView(sourcesNavigatorView); + const element = UI.panels.sources.navigatorTabbedLocation.tabbedPane().element; + await AxeCoreTestRunner.runValidation(element, ruleSet); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test-expected.txt new file mode 100644 index 0000000..4f508a6 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test-expected.txt
@@ -0,0 +1,6 @@ +Tests accessibility in the Sources panel Navigator pane Snippets tab using axe-core. +Script snippet #1 +Script snippet #2 +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test.js new file mode 100644 index 0000000..56585302 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/source-navigator-snippets-a11y-test.js
@@ -0,0 +1,42 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the Sources panel Navigator pane Snippets tab using axe-core.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + }, + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + await TestRunner.loadLegacyModule('snippets'); + + await UI.viewManager.showView('sources'); + + await setup(); + await testA11yForView(NO_REQUIRED_CHILDREN_RULESET); + + TestRunner.completeTest(); + + async function setup() { + // Add snippets + await Snippets.ScriptSnippetFileSystem.findSnippetsProject().createFile('s1', null, ''); + await Snippets.ScriptSnippetFileSystem.findSnippetsProject().createFile('s2', null, ''); + } + + async function testA11yForView(ruleSet) { + await UI.viewManager.showView('navigator-snippets'); + const sourcesNavigatorView = new Sources.SnippetsNavigatorView(); + + sourcesNavigatorView.show(UI.inspectorView.element); + SourcesTestRunner.dumpNavigatorView(sourcesNavigatorView); + const element = UI.panels.sources.navigatorTabbedLocation.tabbedPane().element; + await AxeCoreTestRunner.runValidation(element, ruleSet); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test-expected.txt new file mode 100644 index 0000000..e2a9bdd8 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test-expected.txt
@@ -0,0 +1,9 @@ +Tests accessibility in the editor pane in sources panel using the axe-core linter. +All tabs: +Script snippet #1 +Script snippet #2 + + +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test.js new file mode 100644 index 0000000..9477602 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/sources-editor-pane-a11y-test.js
@@ -0,0 +1,58 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests accessibility in the editor pane in sources panel using the axe-core linter.'); + + // axe-core issue #1444 -- role="tree" requires children with role="treeitem", + // but it is reasonable to have trees with no leaves. + // Ignore 'aria-required-children' rule for tablist because it doesn't accommodate empty tablist. + const NO_REQUIRED_CHILDREN_RULESET = { + 'aria-required-children': { + enabled: false, + selector: ':not(.tabbed-pane-header-tabs)' + }, + 'aria-allowed-attr': { + enabled: false, + selector: '.cm-content' + } + }; + + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + + await UI.viewManager.showView('sources'); + + await setup(); + await runTest(); + + TestRunner.completeTest(); + + async function setup() { + const projects = Workspace.workspace.projectsForType(Workspace.projectTypes.FileSystem); + const snippetsProject = projects.find( + project => Persistence.FileSystemWorkspaceBinding.fileSystemType(project) === 'snippets'); + const uiSourceCode1 = await snippetsProject.createFile(''); + await Common.Revealer.reveal(uiSourceCode1); + const uiSourceCode2 = await snippetsProject.createFile(''); + await Common.Revealer.reveal(uiSourceCode2); + } + + async function runTest() { + // Verify contents of the TabHeader to make sure files are open + const tabbedPane = UI.panels.sources.sourcesView().editorContainer.tabbedPane; + const tabs = tabbedPane.tabs; + TestRunner.addResult('All tabs:'); + tabs.forEach(tab => TestRunner.addResult(tab.title)); + TestRunner.addResult('\n'); + + await runA11yTest(); + } + + async function runA11yTest() { + await UI.viewManager.showView('sources'); + const element = UI.panels.sources.sourcesView().contentElement; + await AxeCoreTestRunner.runValidation(element, NO_REQUIRED_CHILDREN_RULESET); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test-expected.txt new file mode 100644 index 0000000..c7dc0ad --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test-expected.txt
@@ -0,0 +1,9 @@ +Adding watch expression. +Running the axe-core linter on the empty watch pane. +aXe violations: [] + +Watch expression text content: 2 + 2 === 5: false +Running the axe-core linter on the watch expression. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test.js new file mode 100644 index 0000000..308c0ab --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/watch-expression-a11y-test.js
@@ -0,0 +1,27 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.loadTestModule('elements_test_runner'); + await TestRunner.loadTestModule('sources_test_runner'); + await TestRunner.showPanel('sources'); + await TestRunner.navigatePromise('../sources/debugger-breakpoints/resources/dom-breakpoints.html'); + + await UI.viewManager.showView('sources.watch'); + TestRunner.addResult('Adding watch expression.'); + const watchPane = Sources.WatchExpressionsSidebarPane.instance(); + watchPane.doUpdate(); + TestRunner.addResult('Running the axe-core linter on the empty watch pane.'); + await AxeCoreTestRunner.runValidation(watchPane.contentElement); + + const watchExpression = watchPane.createWatchExpression('2 + 2 === 5'); + await TestRunner.addSnifferPromise(Sources.WatchExpression.prototype, 'createWatchExpression'); + + const watchExpressionElement = watchExpression.treeElement().listItemElement; + TestRunner.addResult(`Watch expression text content: ${watchExpressionElement.deepTextContent()}`); + TestRunner.addResult('Running the axe-core linter on the watch expression.'); + await AxeCoreTestRunner.runValidation(watchExpressionElement); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test-expected.txt new file mode 100644 index 0000000..7855e5c --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test-expected.txt
@@ -0,0 +1,5 @@ +Adding XHR breakpoint. +Running axe on the XHR breakpoints pane. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test.js new file mode 100644 index 0000000..22d71f3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/sources/xhr-breakpoints-sidebar-a11y-test.js
@@ -0,0 +1,22 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + await TestRunner.showPanel('sources'); + await TestRunner.loadLegacyModule('browser_debugger'); + + // this rule causes false negatives due to axe not handling the shadow DOM properly + const noRequiredParent = {'aria-required-parent': {enabled: false}}; + + await UI.viewManager.showView('sources.xhrBreakpoints'); + TestRunner.addResult('Adding XHR breakpoint.'); + const xhrBreakpointsPane = BrowserDebugger.XHRBreakpointsSidebarPane.instance(); + xhrBreakpointsPane.setBreakpoint('test xhr breakpoint', true); + TestRunner.addResult('Running axe on the XHR breakpoints pane.'); + + await AxeCoreTestRunner.runValidation(xhrBreakpointsPane.contentElement, noRequiredParent); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test-expected.txt b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test-expected.txt new file mode 100644 index 0000000..681d06f --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test-expected.txt
@@ -0,0 +1,4 @@ +Tests accessibility in the web audio tool using the axe-core linter. +aXe violations: [] + +
diff --git a/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test.js b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test.js new file mode 100644 index 0000000..ff3fe65 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/a11y-axe-core/web-audio-a11y-test.js
@@ -0,0 +1,15 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + await TestRunner.loadTestModule('axe_core_test_runner'); + TestRunner.addResult( + 'Tests accessibility in the web audio tool using the axe-core linter.'); + + await UI.viewManager.showView('web-audio'); + const widget = await UI.viewManager.view('web-audio').widget(); + + await AxeCoreTestRunner.runValidation(widget.element); + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode-expected.txt b/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode-expected.txt new file mode 100644 index 0000000..dc6f6ac --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode-expected.txt
@@ -0,0 +1,5 @@ +Tests that console inputs are evaluated in REPL mode + +Called RuntimeAgent.invoke_evaluate +Value of 'replMode': true +
diff --git a/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode.js b/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode.js new file mode 100644 index 0000000..e22c6e3 --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/console/console-eval-uses-repl-mode.js
@@ -0,0 +1,21 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests that console inputs are evaluated in REPL mode\n'); + + await TestRunner.loadTestModule('console_test_runner'); + await TestRunner.showPanel('console'); + + TestRunner.addSniffer(TestRunner.RuntimeAgent, 'invoke_evaluate', function(args) { + TestRunner.addResult('Called RuntimeAgent.invoke_evaluate'); + TestRunner.addResult("Value of 'replMode': " + args.replMode); + }); + + ConsoleTestRunner.evaluateInConsole('let a = 1; let a = 2;', step2); + + function step2() { + TestRunner.completeTest(); + } +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode-expected.txt b/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode-expected.txt new file mode 100644 index 0000000..5862849d --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode-expected.txt
@@ -0,0 +1,5 @@ +Tests that snippet scripts are evaluated in REPL mode + +Called RuntimeAgent.invoke_evaluate +Value of 'replMode': true +
diff --git a/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode.js b/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode.js new file mode 100644 index 0000000..c486c7e --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/sources/snippet-eval-uses-repl-mode.js
@@ -0,0 +1,23 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests that snippet scripts are evaluated in REPL mode\n'); + + await TestRunner.loadLegacyModule('snippets'); + await TestRunner.showPanel('sources'); + + TestRunner.addSniffer(TestRunner.RuntimeAgent, 'invoke_evaluate', function(args) { + TestRunner.addResult('Called RuntimeAgent.invoke_evaluate'); + TestRunner.addResult('Value of \'replMode\': ' + args.replMode); + }); + + const uiSourceCode = await Snippets.ScriptSnippetFileSystem.findSnippetsProject().createFile('', null, ''); + await uiSourceCode.rename('Snippet1'); + uiSourceCode.setWorkingCopy('let a = 1; let a = 2;'); + + await Snippets.evaluateScriptSnippet(uiSourceCode); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs-expected.txt b/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs-expected.txt new file mode 100644 index 0000000..fda2325a --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs-expected.txt
@@ -0,0 +1,10 @@ +Tests the test runner shows assertions in the logs + +Passing assert should not show up + +Failing assert should show up +ASSERTION FAILURE: This is a failing assertion. + +Failing assert with multiple arguments +ASSERTION FAILURE: This is a failing assertion. +
diff --git a/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs.js b/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs.js new file mode 100644 index 0000000..9d7e6afa --- /dev/null +++ b/third_party/blink/web_tests/http/tests/devtools/test_runner/assertions-show-up-in-logs.js
@@ -0,0 +1,20 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +(async function() { + TestRunner.addResult('Tests the test runner shows assertions in the logs\n'); + + TestRunner.addResult('Passing assert should not show up'); + console.assert(true, 'This is a passing assertion.'); + TestRunner.addResult(''); + + TestRunner.addResult('Failing assert should show up'); + console.assert(false, 'This is a failing assertion.'); + TestRunner.addResult(''); + + TestRunner.addResult('Failing assert with multiple arguments'); + console.assert(false, 'This is ', 'a ', 'failing assertion.'); + + TestRunner.completeTest(); +})();
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-frame-policy-in-xsl.html b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-frame-policy-in-xsl.html index c302c69a..aec15819f 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-frame-policy-in-xsl.html +++ b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-frame-policy-in-xsl.html
@@ -3,12 +3,12 @@ <script src="../resources/testharnessreport.js"></script> <script> const iframe = document.createElement('iframe'); - iframe.allow = "document-domain 'none'"; + iframe.allow = "geolocation 'none'"; iframe.src = "resources/permissions-policy-iframe.xml"; async_test(t => { window.addEventListener('message', t.step_func_done(event => { - assert_equals(event.data, 'document-domain disallowed'); + assert_equals(event.data, 'geolocation disallowed'); }), {once: true}); });
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-in-xsl.php b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-in-xsl.php index 5e418ba7..b07bda7 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-in-xsl.php +++ b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-in-xsl.php
@@ -1,5 +1,5 @@ <?php -header("Permissions-Policy: document-domain=()"); +header("Permissions-Policy: geolocation=()"); header("Content-Type: application/xml"); echo '<?xml version="1.0"?>
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-javascript-navigation.php b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-javascript-navigation.php index f97a0e5..56e361c3 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-javascript-navigation.php +++ b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-javascript-navigation.php
@@ -1,5 +1,5 @@ <?php -header("Permissions-Policy: document-domain=()"); +header("Permissions-Policy: geolocation=()"); ?> <!DOCTYPE html> @@ -16,16 +16,12 @@ <${script} src="/resources/testharness.js"></${script}> <${script} src="/resources/testharnessreport.js"></${script}> <${script}> - test(() => { - let feature_allowed; - try { - document.domain = document.domain; - feature_allowed = true; - } catch(e) { - feature_allowed = false; - } - - assert_false(feature_allowed, "Feature(Document Domain) should not be allowed by permissions policy."); + test(t => { + navigator.geolocation.getCurrentPosition( + t.step_func_done(), + t.unreached_func( + "Feature(Geolocation) should not be allowed by permissions policy.") + ); }); </${script}> </head>
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-report-only-in-xsl.php b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-report-only-in-xsl.php index 01a3d76..87761d4 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-report-only-in-xsl.php +++ b/third_party/blink/web_tests/http/tests/permissions-policy/permissions-policy-report-only-in-xsl.php
@@ -1,5 +1,5 @@ <?php -header("Permissions-Policy-Report-Only: document-domain=()"); +header("Permissions-Policy-Report-Only: geolocation=()"); header("Content-Type: application/xml"); echo '<?xml version="1.0"?>
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-iframe.xslt b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-iframe.xslt index 62e7fd9..5728115 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-iframe.xslt +++ b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-iframe.xslt
@@ -8,15 +8,10 @@ <title> Test XSLT </title> <script> window.onload = () => { - let message; - try { - document.domain = document.domain; - message = 'document-domain allowed'; - } catch (_) { - message = 'document-domain disallowed'; - } - - parent.postMessage(message, '*'); + navigator.geolocation.getCurrentPosition( + () => { parent.postMessage('geolocation allowed', '*'); }, + () => { parent.postMessage('geolocation disallowed', '*'); } + ); }; </script> </head>
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-in-xsl.xslt b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-in-xsl.xslt index f0cee19..279adfe5 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-in-xsl.xslt +++ b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-in-xsl.xslt
@@ -9,16 +9,12 @@ <script src="../../resources/testharness.js"></script> <script src="../../resources/testharnessreport.js"></script> <script> - test(() => { - let feature_allowed; - try { - document.domain = document.domain; - feature_allowed = true; - } catch(e) { - feature_allowed = false; - } - - assert_false(feature_allowed, "Feature(Document Domain) should not be allowed by permissions policy."); + test(t => { + navigator.geolocation.getCurrentPosition( + t.step_func_done(), + t.unreached_func( + "Feature(geolocation) should not be allowed by permissions policy.") + ); }); </script> </head>
diff --git a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-report-only-in-xsl.xslt b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-report-only-in-xsl.xslt index abce1c68..4d2a249 100644 --- a/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-report-only-in-xsl.xslt +++ b/third_party/blink/web_tests/http/tests/permissions-policy/resources/permissions-policy-report-only-in-xsl.xslt
@@ -9,7 +9,7 @@ <script src="../../resources/testharness.js"></script> <script src="../../resources/testharnessreport.js"></script> <script> - // 'document-domain' is enabled in the page but is disabled + // 'geolocation' is enabled in the page but is disabled // in Permissions-Policy-Report-Only header. // A permissions-policy-violation report is expected. @@ -18,12 +18,11 @@ assert_equals(reports.length, 1); const report = reports[0]; assert_equals(report.type, 'permissions-policy-violation'); - assert_equals(report.body.featureId, 'document-domain'); + assert_equals(report.body.featureId, 'geolocation'); assert_equals(report.body.disposition, 'report'); }), {types: ['permissions-policy-violation']}).observe(); }); - - document.domain = document.domain; + navigator.geolocation.getCurrentPosition(_ => {}); </script> </head> <body bgcolor="#ffffff">
diff --git a/third_party/blink/web_tests/platform/linux/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt b/third_party/blink/web_tests/platform/linux/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt deleted file mode 100644 index 84b943a..0000000 --- a/third_party/blink/web_tests/platform/linux/external/wpt/shape-detection/detection-ImageDataUint16StorageFormat.https.window-expected.txt +++ /dev/null
@@ -1,4 +0,0 @@ -This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https-expected.txt b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https-expected.txt new file mode 100644 index 0000000..4dff6102 --- /dev/null +++ b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https-expected.txt
@@ -0,0 +1,5 @@ +This is a testharness.js-based test. +FAIL Ensures depth data is not available when cleared in the controller, `gpu-optimized` - webgl promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"],\"depthSensingData\":{\"depthData\":{\"0\":1,\"1\":0,\"2\":1,\"3\":0,\"4\":1,\"5\":0,\"6\":1,\"7\":0,\"8\":1,\"9\":0,\"10\":1,\"11\":0,\"12\":1,\"13\":0,\"14\":1,\"15\":0,\"16\":2,\"17\":0,\"18\":3,\"19\":0,\"20\":4,\"21\":0,\"22\":5,\"23\":0,\"24\":6,\"25\":0,\"26\":7,\"27\":0,\"28\":1,\"29\":0,\"30\":4,\"31\":0,\"32\":9,\"33\":0,\"34\":16,\"35\":0,\"36\":25,\"37\":0,\"38\":36,\"39\":0,\"40\":49,\"41\":0,\"42\":1,\"43\":0,\"44\":8,\"45\":0,\"46\":27,\"47\":0,\"48\":64,\"49\":0,\"50\":125,\"51\":0,\"52\":216,\"53\":0,\"54\":87,\"55\":1,\"56\":1,\"57\":0,\"58\":16,\"59\":0,\"60\":81,\"61\":0,\"62\":0,\"63\":1,\"64\":113,\"65\":2,\"66\":16,\"67\":5,\"68\":97,\"69\":9},\"width\":7,\"height\":5,\"normDepthBufferFromNormView\":{\"position\":[1,1,0],\"orientation\":[0,0,1,0]},\"rawValueToMeters\":0.01}} with error: NotSupportedError: The specified session configuration is not supported." +FAIL Ensures depth data is not available when cleared in the controller, `gpu-optimized` - webgl2 promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"],\"depthSensingData\":{\"depthData\":{\"0\":1,\"1\":0,\"2\":1,\"3\":0,\"4\":1,\"5\":0,\"6\":1,\"7\":0,\"8\":1,\"9\":0,\"10\":1,\"11\":0,\"12\":1,\"13\":0,\"14\":1,\"15\":0,\"16\":2,\"17\":0,\"18\":3,\"19\":0,\"20\":4,\"21\":0,\"22\":5,\"23\":0,\"24\":6,\"25\":0,\"26\":7,\"27\":0,\"28\":1,\"29\":0,\"30\":4,\"31\":0,\"32\":9,\"33\":0,\"34\":16,\"35\":0,\"36\":25,\"37\":0,\"38\":36,\"39\":0,\"40\":49,\"41\":0,\"42\":1,\"43\":0,\"44\":8,\"45\":0,\"46\":27,\"47\":0,\"48\":64,\"49\":0,\"50\":125,\"51\":0,\"52\":216,\"53\":0,\"54\":87,\"55\":1,\"56\":1,\"57\":0,\"58\":16,\"59\":0,\"60\":81,\"61\":0,\"62\":0,\"63\":1,\"64\":113,\"65\":2,\"66\":16,\"67\":5,\"68\":97,\"69\":9},\"width\":7,\"height\":5,\"normDepthBufferFromNormView\":{\"position\":[1,1,0],\"orientation\":[0,0,1,0]},\"rawValueToMeters\":0.01}} with error: NotSupportedError: The specified session configuration is not supported." +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https-expected.txt b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https-expected.txt new file mode 100644 index 0000000..8f04f56 --- /dev/null +++ b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https-expected.txt
@@ -0,0 +1,5 @@ +This is a testharness.js-based test. +FAIL Ensures XRCPUDepthInformation is not obtainable in `gpu-optimized` usage mode - webgl promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"]} with error: NotSupportedError: The specified session configuration is not supported." +FAIL Ensures XRCPUDepthInformation is not obtainable in `gpu-optimized` usage mode - webgl2 promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"]} with error: NotSupportedError: The specified session configuration is not supported." +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https-expected.txt b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https-expected.txt new file mode 100644 index 0000000..108fa086 --- /dev/null +++ b/third_party/blink/web_tests/platform/linux/external/wpt/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https-expected.txt
@@ -0,0 +1,5 @@ +This is a testharness.js-based test. +FAIL Ensures getDepthInformation() throws when not run with stale XRView, `gpu-optimized` - webgl promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"]} with error: NotSupportedError: The specified session configuration is not supported." +FAIL Ensures getDepthInformation() throws when not run with stale XRView, `gpu-optimized` - webgl2 promise_test: Unhandled rejection with value: "Session with params \"immersive-ar\" was rejected on device {\"supportedModes\":[\"immersive-ar\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\",\"depth-sensing\",\"secondary-views\",\"camera-access\"]} with error: NotSupportedError: The specified session configuration is not supported." +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt b/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt deleted file mode 100644 index da5e58d3..0000000 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/notimer-after-unload.https-expected.txt +++ /dev/null
@@ -1,4 +0,0 @@ -This is a testharness.js-based test. -FAIL geolocation callbacks are not invoked after page unload promise_test: Unhandled rejection with value: "Geolocation callback invoked after page unload" -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout.https-expected.txt b/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout.https-expected.txt deleted file mode 100644 index 92ff9d7..0000000 --- a/third_party/blink/web_tests/platform/linux/wpt_internal/geolocation-api/timeout.https-expected.txt +++ /dev/null
@@ -1,5 +0,0 @@ -This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: Received unknown message -FAIL Tests that when timeout is non-zero, the success callback is called as expected. promise_test: Unhandled rejection with value: "Error callback invoked unexpectedly" -Harness: the test ran to completion. -
diff --git a/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/README.md b/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/README.md deleted file mode 100644 index ece541a2..0000000 --- a/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/README.md +++ /dev/null
@@ -1 +0,0 @@ -This suite runs tests with --enable-features=DisableDocumentDomainByDefault \ No newline at end of file
diff --git a/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/http/tests/document-policy/document-domain/README.txt b/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/http/tests/document-policy/document-domain/README.txt deleted file mode 100644 index f6fb66d..0000000 --- a/third_party/blink/web_tests/virtual/document-domain-disabled-by-default/http/tests/document-policy/document-domain/README.txt +++ /dev/null
@@ -1 +0,0 @@ -# This suite runs tests with --enable-features=DisableDocumentDomainByDefault \ No newline at end of file
diff --git a/third_party/blink/web_tests/virtual/stable/webexposed/feature-policy-features-expected.txt b/third_party/blink/web_tests/virtual/stable/webexposed/feature-policy-features-expected.txt index 9112eb01..867dda7c 100644 --- a/third_party/blink/web_tests/virtual/stable/webexposed/feature-policy-features-expected.txt +++ b/third_party/blink/web_tests/virtual/stable/webexposed/feature-policy-features-expected.txt
@@ -29,7 +29,6 @@ clipboard-write cross-origin-isolated display-capture -document-domain encrypted-media fullscreen gamepad
diff --git a/third_party/blink/web_tests/webexposed/feature-policy-features-expected.txt b/third_party/blink/web_tests/webexposed/feature-policy-features-expected.txt index 978da44..fc11d96 100644 --- a/third_party/blink/web_tests/webexposed/feature-policy-features-expected.txt +++ b/third_party/blink/web_tests/webexposed/feature-policy-features-expected.txt
@@ -33,7 +33,6 @@ cross-origin-isolated direct-sockets display-capture -document-domain encrypted-media execution-while-not-rendered execution-while-out-of-viewport
diff --git a/tools/binary_size/libsupersize/dex_parser.py b/tools/binary_size/libsupersize/dex_parser.py index 4811a0e..cfc70420 100755 --- a/tools/binary_size/libsupersize/dex_parser.py +++ b/tools/binary_size/libsupersize/dex_parser.py
@@ -72,7 +72,8 @@ ','.join(t[0] for t in _DEX_HEADER_FMT)) # Simple memory items. -_StringDataItem = collections.namedtuple('StringDataItem', 'utf16_size,data') +_StringDataItem = collections.namedtuple('StringDataItem', + 'utf16_size,data,byte_size') _TypeIdItem = collections.namedtuple('TypeIdItem', 'descriptor_idx') _ProtoIdItem = collections.namedtuple( 'ProtoIdItem', 'shorty_idx,return_type_idx,parameters_off') @@ -239,9 +240,11 @@ string_data_item_offsets = iter([reader.NextUInt() for _ in range(size)]) def factory(x): - x.Seek(next(string_data_item_offsets)) + start_pos = next(string_data_item_offsets) + x.Seek(start_pos) string = x.NextString() - return _StringDataItem(len(string), string) + byte_size = x.Tell() - start_pos + return _StringDataItem(len(string), string, byte_size) super().__init__(reader, offset, size, factory) @@ -412,19 +415,23 @@ self.class_data_item_list = _ClassDataItemList(self.reader, class_data_item.offset, class_data_item.size) - self._class_data_item_by_offset = { - class_data_item.offset: class_data_item - for class_data_item in self.class_data_item_list - } + else: + self.class_data_item_list = [] + self._class_data_item_by_offset = { + class_data_item.offset: class_data_item + for class_data_item in self.class_data_item_list + } code_item = self.map_list.get(_TYPE_CODE_ITEM) if code_item: self.code_item_list = _CodeItemList(self.reader, code_item.offset, code_item.size) - self._code_item_by_offset = { - code_item.offset: code_item - for code_item in self.code_item_list - } + else: + self.code_item_list = [] + self._code_item_by_offset = { + code_item.offset: code_item + for code_item in self.code_item_list + } def GetString(self, string_idx): string_data_item = self.string_data_item_list[string_idx]
diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml index eb29743..0b83593 100644 --- a/tools/metrics/actions/actions.xml +++ b/tools/metrics/actions/actions.xml
@@ -18462,6 +18462,14 @@ </description> </action> +<action name="MobileKeyCommandCloseAll"> + <owner>lpromero@google.com</owner> + <owner>alionadangla@google.com</owner> + <description> + The user has performed the key command to close all tabs. + </description> +</action> + <action name="MobileKeyCommandCloseTab"> <owner>lpromero@google.com</owner> <owner>alionadangla@google.com</owner> @@ -18759,6 +18767,15 @@ </description> </action> +<action name="MobileKeyCommandUndo"> + <owner>lpromero@google.com</owner> + <owner>alionadangla@google.com</owner> + <description> + The user has performed the key command to undo the command which closes all + tabs. + </description> +</action> + <action name="MobileKeyCommandVoiceSearch"> <owner>lpromero@google.com</owner> <owner>alionadangla@google.com</owner>
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 7318cd5..a040a5a 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -41654,6 +41654,8 @@ label="V8DocumentPictureInPictureEvent_Window_AttributeGetter"/> <int value="4400" label="DocumentPictureInPictureEnterEvent"/> <int value="4401" label="SoftNavigationHeuristics"/> + <int value="4402" label="MathMLMathElement"/> + <int value="4403" label="MathMLMathElementInDocument"/> </enum> <enum name="FeaturePolicyAllowlistType"> @@ -101017,6 +101019,7 @@ <int value="10" label="Safety Check"/> <int value="11" label="Password Check"/> <int value="12" label="Browsing Data"/> + <int value="13" label="Privacy Guide"/> </enum> <enum name="TrustTokenRequestHelperFactoryOutcome">
diff --git a/tools/metrics/histograms/metadata/autofill/histograms.xml b/tools/metrics/histograms/metadata/autofill/histograms.xml index fe645f2..7dc3f42 100644 --- a/tools/metrics/histograms/metadata/autofill/histograms.xml +++ b/tools/metrics/histograms/metadata/autofill/histograms.xml
@@ -3997,6 +3997,9 @@ <histogram name="Autofill.UnmaskPrompt.Events" enum="AutofillUnmaskPromptEvent" expires_after="2023-03-19"> + <obsolete> + Deprecated in M109. Subsumed by Autofill.UnmaskPrompt.{CardType}.Events. + </obsolete> <owner>jsaul@google.com</owner> <owner>siyua@chromium.org</owner> <summary> @@ -4092,6 +4095,18 @@ <token key="Result" variants="Autofill.PaymentsRpcResult"/> </histogram> +<histogram name="Autofill.UnmaskPrompt.{CardType}.Events" + enum="AutofillUnmaskPromptEvent" expires_after="2023-11-01"> + <owner>vinnypersky@google.com</owner> + <owner>payments-autofill-team@google.com</owner> + <summary> + Events tracking the usage of the unmasking prompt, recorded for {CardType}. + This prompt is triggered when a user selects a masked card in a autofill + dropdown. + </summary> + <token key="CardType" variants="Autofill.PaymentsRpcCardType"/> +</histogram> + <histogram name="Autofill.Upload.BackoffDelay" units="ms" expires_after="never"> <!-- expires-never: https://crbug.com/915888 -->
diff --git a/tools/metrics/histograms/metadata/dev/histograms.xml b/tools/metrics/histograms/metadata/dev/histograms.xml index 4273b6f..aa18a00c8 100644 --- a/tools/metrics/histograms/metadata/dev/histograms.xml +++ b/tools/metrics/histograms/metadata/dev/histograms.xml
@@ -170,7 +170,7 @@ </summary> </histogram> -<histogram name="DevTools.InspectElement" units="ms" expires_after="2022-12-01"> +<histogram name="DevTools.InspectElement" units="ms" expires_after="2023-12-01"> <owner>yangguo@chromium.org</owner> <owner>bmeurer@chromium.org</owner> <summary>
diff --git a/tools/metrics/histograms/metadata/enterprise/histograms.xml b/tools/metrics/histograms/metadata/enterprise/histograms.xml index da74913..32c3fe1 100644 --- a/tools/metrics/histograms/metadata/enterprise/histograms.xml +++ b/tools/metrics/histograms/metadata/enterprise/histograms.xml
@@ -1031,6 +1031,7 @@ <variant name="Common.WithCache" summary="Common (with cache)"/> <variant name="Context" summary="Context"/> <variant name="Full" summary="full set of"/> + <variant name="Win" summary="Windows"/> </token> </histogram>
diff --git a/tools/metrics/histograms/metadata/profile/histograms.xml b/tools/metrics/histograms/metadata/profile/histograms.xml index 0662d1a..5e0bde3 100644 --- a/tools/metrics/histograms/metadata/profile/histograms.xml +++ b/tools/metrics/histograms/metadata/profile/histograms.xml
@@ -263,7 +263,7 @@ </histogram> <histogram name="Profile.Incognito.ResumedAfterReportedDuration" - units="minutes" expires_after="2023-01-01"> + units="minutes" expires_after="2023-07-01"> <owner>rhalavati@chromium.org</owner> <owner>chrome-incognito@google.com</owner> <summary>
diff --git a/tools/perf/core/perfetto_binary_roller/binary_deps.json b/tools/perf/core/perfetto_binary_roller/binary_deps.json index 5fbb1522..1d3d860 100644 --- a/tools/perf/core/perfetto_binary_roller/binary_deps.json +++ b/tools/perf/core/perfetto_binary_roller/binary_deps.json
@@ -5,8 +5,8 @@ "full_remote_path": "perfetto-luci-artifacts/v31.0/linux-arm64/trace_processor_shell" }, "win": { - "hash": "560bd7a695d8638142726a65b5123ad754753b80", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/c194bc190ded8849d9d6be943220c5f8f72cc022/trace_processor_shell.exe" + "hash": "ec6600d94b2797d27bb940d9601b41101232ed5e", + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/win/be5960bcdfae8925d83807b3ec5df72c25f98939/trace_processor_shell.exe" }, "linux_arm": { "hash": "6373f26144aad58f230d11d6a91efda5a09c9873", @@ -21,8 +21,8 @@ "full_remote_path": "perfetto-luci-artifacts/v31.0/mac-arm64/trace_processor_shell" }, "linux": { - "hash": "1852fab01717fef0d88914b065a2721385398103", - "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/c194bc190ded8849d9d6be943220c5f8f72cc022/trace_processor_shell" + "hash": "8730e3af6f34daee71bd8cead5070dda50668233", + "full_remote_path": "chromium-telemetry/perfetto_binaries/trace_processor_shell/linux/be5960bcdfae8925d83807b3ec5df72c25f98939/trace_processor_shell" } }, "power_profile.sql": {
diff --git a/ui/display/screen.h b/ui/display/screen.h index 360a1d2a..71f50d32 100644 --- a/ui/display/screen.h +++ b/ui/display/screen.h
@@ -52,7 +52,8 @@ // Retrieves the single Screen object; this may be null if it's not already // created, except for IOS where it creates a native screen instance - // automatically. + // automatically. On ChromeOS ash the return value is only null on startup. + static Screen* GetScreen(); // Returns whether a Screen singleton exists or not.
diff --git a/ui/ozone/platform/wayland/host/wayland_output_unittest.cc b/ui/ozone/platform/wayland/host/wayland_output_unittest.cc index 8f512fa..c5137ec 100644 --- a/ui/ozone/platform/wayland/host/wayland_output_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_output_unittest.cc
@@ -13,11 +13,11 @@ namespace ui { -using WaylandOutputTest = WaylandTest; +using WaylandOutputTest = WaylandTestSimple; // Tests that name and description fall back to ones in the WaylandOutput if // XDGOutput is not created. -TEST_P(WaylandOutputTest, NameAndDescriptionFallback) { +TEST_F(WaylandOutputTest, NameAndDescriptionFallback) { constexpr char kWlOutputName[] = "kWlOutputName"; constexpr char kWlOutputDescription[] = "kWlOutputDescription"; constexpr char kXDGOutputName[] = "kXDGOutputName"; @@ -47,14 +47,4 @@ EXPECT_EQ(wl_output->description(), kWlOutputDescription); } -INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest, - WaylandOutputTest, - Values(wl::ServerConfig{})); - -INSTANTIATE_TEST_SUITE_P( - XdgVersionStableTestWithAuraShell, - WaylandOutputTest, - Values(wl::ServerConfig{ - .enable_aura_shell = wl::EnableAuraShellProtocol::kEnabled})); - } // namespace ui
diff --git a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc index df61457..4d4b879 100644 --- a/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
@@ -1321,4 +1321,10 @@ LazilyConfiguredScreenTest, Values(wl::ServerConfig{})); +INSTANTIATE_TEST_SUITE_P( + XdgVersionStableTestWithAuraShell, + LazilyConfiguredScreenTest, + Values(wl::ServerConfig{ + .enable_aura_shell = wl::EnableAuraShellProtocol::kEnabled})); + } // namespace ui
diff --git a/ui/ozone/platform/wayland/host/wayland_zaura_output_unittest.cc b/ui/ozone/platform/wayland/host/wayland_zaura_output_unittest.cc index 315a3b0..828146e 100644 --- a/ui/ozone/platform/wayland/host/wayland_zaura_output_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_zaura_output_unittest.cc
@@ -18,7 +18,7 @@ namespace ui { -class WaylandZAuraOutputTest : public WaylandTest { +class WaylandZAuraOutputTest : public WaylandTestSimpleWithAuraShell { public: WaylandZAuraOutputTest() = default; WaylandZAuraOutputTest(const WaylandZAuraOutputTest&) = delete; @@ -26,7 +26,7 @@ ~WaylandZAuraOutputTest() override = default; void SetUp() override { - WaylandTest::SetUp(); + WaylandTestSimpleWithAuraShell::SetUp(); // Set default values for the output. PostToServerAndWait([](wl::TestWaylandServerThread* server) { @@ -51,7 +51,7 @@ std::unique_ptr<WaylandScreen> platform_screen_; }; -TEST_P(WaylandZAuraOutputTest, HandleInsets) { +TEST_F(WaylandZAuraOutputTest, HandleInsets) { WaylandOutput* wayland_output = output_manager_->GetPrimaryOutput(); ASSERT_TRUE(wayland_output); EXPECT_TRUE(wayland_output->IsReady()); @@ -78,7 +78,7 @@ EXPECT_EQ(wayland_output->insets(), insets); } -TEST_P(WaylandZAuraOutputTest, HandleLogicalTransform) { +TEST_F(WaylandZAuraOutputTest, HandleLogicalTransform) { WaylandOutput* wayland_output = output_manager_->GetPrimaryOutput(); ASSERT_TRUE(wayland_output); EXPECT_TRUE(wayland_output->IsReady()); @@ -97,7 +97,7 @@ } // Test edge case display ids are converted correctly. -TEST_P(WaylandZAuraOutputTest, DisplayIdConversions) { +TEST_F(WaylandZAuraOutputTest, DisplayIdConversions) { const int64_t kTestIds[] = { std::numeric_limits<int64_t>::min(), std::numeric_limits<int64_t>::min() + 1, @@ -122,10 +122,4 @@ } } -INSTANTIATE_TEST_SUITE_P( - XdgVersionStableTest, - WaylandZAuraOutputTest, - Values(wl::ServerConfig{ - .enable_aura_shell = wl::EnableAuraShellProtocol::kEnabled})); - } // namespace ui
diff --git a/ui/ozone/platform/wayland/host/wayland_zaura_shell_unittest.cc b/ui/ozone/platform/wayland/host/wayland_zaura_shell_unittest.cc index d08e28a..447932e 100644 --- a/ui/ozone/platform/wayland/host/wayland_zaura_shell_unittest.cc +++ b/ui/ozone/platform/wayland/host/wayland_zaura_shell_unittest.cc
@@ -13,9 +13,9 @@ namespace ui { -using WaylandZAuraShellTest = WaylandTest; +using WaylandZAuraShellTest = WaylandTestSimpleWithAuraShell; -TEST_P(WaylandZAuraShellTest, BugFix) { +TEST_F(WaylandZAuraShellTest, BugFix) { PostToServerAndWait([](wl::TestWaylandServerThread* server) { auto* const zaura_shell = server->zaura_shell()->resource(); zaura_shell_send_bug_fix(zaura_shell, 1); @@ -27,10 +27,4 @@ ASSERT_FALSE(connection_->zaura_shell()->HasBugFix(2)); } -INSTANTIATE_TEST_SUITE_P( - XdgVersionStableTest, - WaylandZAuraShellTest, - Values(wl::ServerConfig{ - .enable_aura_shell = wl::EnableAuraShellProtocol::kEnabled})); - } // namespace ui
diff --git a/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc b/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc index e3cceaa..4093a6b 100644 --- a/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc +++ b/ui/ozone/platform/wayland/test/wayland_drag_drop_test.cc
@@ -53,9 +53,9 @@ PostToServerAndWait( [surface_id, location](wl::TestWaylandServerThread* server) { auto* origin = server->GetObject<wl::MockSurface>(surface_id); - DCHECK(origin); + ASSERT_TRUE(origin); auto* data_device = server->data_device_manager()->data_device(); - DCHECK(data_device); + ASSERT_TRUE(data_device); data_device->SendOfferAndEnter(origin, location); }); } @@ -129,9 +129,9 @@ const uint32_t surface_id = window->root_surface()->get_surface_id(); PostToServerAndWait([surface_id](wl::TestWaylandServerThread* server) { auto* surface = server->GetObject<wl::MockSurface>(surface_id); - DCHECK(surface); + ASSERT_TRUE(surface); auto* pointer = server->seat()->pointer(); - DCHECK(pointer); + ASSERT_TRUE(pointer); wl_pointer_send_enter(pointer->resource(), server->GetNextSerial(), surface->resource(), 0, 0); wl_pointer_send_frame(pointer->resource()); @@ -144,9 +144,9 @@ const uint32_t surface_id = window->root_surface()->get_surface_id(); PostToServerAndWait([surface_id](wl::TestWaylandServerThread* server) { auto* surface = server->GetObject<wl::MockSurface>(surface_id); - DCHECK(surface); + ASSERT_TRUE(surface); auto* pointer = server->seat()->pointer(); - DCHECK(pointer); + ASSERT_TRUE(pointer); wl_pointer_send_leave(pointer->resource(), server->GetNextSerial(), surface->resource()); wl_pointer_send_frame(pointer->resource()); @@ -162,7 +162,7 @@ uint32_t state = pressed ? WL_POINTER_BUTTON_STATE_PRESSED : WL_POINTER_BUTTON_STATE_RELEASED; auto* pointer = server->seat()->pointer(); - DCHECK(pointer); + ASSERT_TRUE(pointer); wl_pointer_send_button(pointer->resource(), server->GetNextSerial(), server->GetNextTime(), button, state); wl_pointer_send_frame(pointer->resource()); @@ -177,9 +177,9 @@ PostToServerAndWait( [surface_id, id, location](wl::TestWaylandServerThread* server) { auto* surface = server->GetObject<wl::MockSurface>(surface_id); - DCHECK(surface); + ASSERT_TRUE(surface); auto* touch = server->seat()->touch(); - DCHECK(touch); + ASSERT_TRUE(touch); wl_touch_send_down(touch->resource(), server->GetNextSerial(), server->GetNextTime(), surface->resource(), id, wl_fixed_from_double(location.x()), @@ -191,7 +191,7 @@ void WaylandDragDropTest::SendTouchUp(int id) { PostToServerAndWait([id](wl::TestWaylandServerThread* server) { auto* touch = server->seat()->touch(); - DCHECK(touch); + ASSERT_TRUE(touch); wl_touch_send_up(touch->resource(), server->GetNextSerial(), server->GetNextTime(), id); wl_touch_send_frame(touch->resource()); @@ -204,7 +204,7 @@ const gfx::Point& location) { PostToServerAndWait([id, location](wl::TestWaylandServerThread* server) { auto* touch = server->seat()->touch(); - DCHECK(touch); + ASSERT_TRUE(touch); wl_touch_send_motion(touch->resource(), server->GetNextSerial(), id, wl_fixed_from_double(location.x()), wl_fixed_from_double(location.y())); @@ -248,7 +248,7 @@ } void WaylandDragDropTest::RunTestTask(base::OnceClosure test_task) { - DCHECK(is_task_running_); + ASSERT_TRUE(is_task_running_); std::move(test_task).Run(); is_task_running_ = false; MaybeRunScheduledTasks();
diff --git a/ui/ozone/platform/wayland/test/wayland_test.cc b/ui/ozone/platform/wayland/test/wayland_test.cc index e75e03c..fe27ff7 100644 --- a/ui/ozone/platform/wayland/test/wayland_test.cc +++ b/ui/ozone/platform/wayland/test/wayland_test.cc
@@ -257,4 +257,18 @@ WaylandTestBase::TearDown(); } +WaylandTestSimpleWithAuraShell::WaylandTestSimpleWithAuraShell() + : WaylandTestBase( + {.enable_aura_shell = wl::EnableAuraShellProtocol::kEnabled}) {} + +WaylandTestSimpleWithAuraShell::~WaylandTestSimpleWithAuraShell() = default; + +void WaylandTestSimpleWithAuraShell::SetUp() { + WaylandTestBase::SetUp(); +} + +void WaylandTestSimpleWithAuraShell ::TearDown() { + WaylandTestBase::TearDown(); +} + } // namespace ui
diff --git a/ui/ozone/platform/wayland/test/wayland_test.h b/ui/ozone/platform/wayland/test/wayland_test.h index 2cea082..7f4b967 100644 --- a/ui/ozone/platform/wayland/test/wayland_test.h +++ b/ui/ozone/platform/wayland/test/wayland_test.h
@@ -153,6 +153,20 @@ void TearDown() override; }; +// Version of WaylandTest that uses simple test fixtures (TEST_F) and +// aura_shell enabled. +class WaylandTestSimpleWithAuraShell : public WaylandTestBase, + public ::testing::Test { + public: + WaylandTestSimpleWithAuraShell(); + WaylandTestSimpleWithAuraShell(const WaylandTestSimple&) = delete; + WaylandTestSimpleWithAuraShell& operator=(const WaylandTestSimple&) = delete; + ~WaylandTestSimpleWithAuraShell() override; + + void SetUp() override; + void TearDown() override; +}; + } // namespace ui #endif // UI_OZONE_PLATFORM_WAYLAND_TEST_WAYLAND_TEST_H_