diff --git a/DEPS b/DEPS index aeb42d22..f77f08e6 100644 --- a/DEPS +++ b/DEPS
@@ -168,11 +168,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling Skia # and whatever else without interference from each other. - 'skia_revision': 'eab1e281fa5e9ade35f25ef0d3a69ffc5a2b7457', + 'skia_revision': 'ad21d47cfa8d9adb2145216c5e514d978d649096', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling V8 # and whatever else without interference from each other. - 'v8_revision': '5a2bf4dc93b903eb71336802c03b5d2f9668495d', + 'v8_revision': 'e8fc00fb9ea3d8e5e4fa7193d45afee764165a0e', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling swarming_client # and whatever else without interference from each other. @@ -180,15 +180,15 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': 'f18ff947360d24edea57ba58b28b1f25c5d99d03', + 'angle_revision': '867f8c92ed1ac207f1ee99121eb44d48505ccaae', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling SwiftShader # and whatever else without interference from each other. - 'swiftshader_revision': '3c4707d608f269ccd8ce90fa333f8ac22cd0e1a6', + 'swiftshader_revision': '9da287fd0264892a8997426a2d7d154aae560de4', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling PDFium # and whatever else without interference from each other. - 'pdfium_revision': '5eb17d38f7f7021a08c13cf986f68a363a4d82f2', + 'pdfium_revision': 'c85c137c5de6aed6db4914ca5375d100bd29d0c8', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling BoringSSL # and whatever else without interference from each other. @@ -287,7 +287,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. - 'spv_tools_revision': '3e4abc9ac382b6fc7a88316a700652404b6fb9f7', + 'spv_tools_revision': '12e54dae167c8ea2c194447805ac6f96f09448f6', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -299,11 +299,11 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'shaderc_revision': 'f4cf10c66fbfeeba95e71d672d33b83da9ec95aa', + 'shaderc_revision': 'c9d5be6b01708bf7d8a8401a7edb98bf3ab82f17', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. - 'dawn_revision': '3c086a0c2e1dc3e2e14aaa3d78c052c7e07274b4', + 'dawn_revision': 'cfc9c6e322f48f9abf66985e5480ae4ea3296fe6', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling feed # and whatever else without interference from each other. @@ -867,7 +867,7 @@ # Build tools for Chrome OS. Note: This depends on third_party/pyelftools. 'src/third_party/chromite': { - 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + 'fc903818f3013dfa9465f47ae359a8445c9254b6', + 'url': Var('chromium_git') + '/chromiumos/chromite.git' + '@' + '92ac890fc48d4ccb19b871cbc7a0d53005289868', 'condition': 'checkout_linux', }, @@ -892,7 +892,7 @@ }, 'src/third_party/depot_tools': - Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + 'ea1884b651e69975e897b15cf2063f36317538a4', + Var('chromium_git') + '/chromium/tools/depot_tools.git' + '@' + '79d4f9950680c588d4c3a2cc8595179f3adc90d4', 'src/third_party/devtools-frontend/src': Var('chromium_git') + '/devtools/devtools-frontend' + '@' + Var('devtools_frontend_revision'), @@ -1294,7 +1294,7 @@ }, 'src/third_party/perfetto': - Var('android_git') + '/platform/external/perfetto.git' + '@' + '51516f076308f8142fd43f911d5e01178017f35d', + Var('android_git') + '/platform/external/perfetto.git' + '@' + '7980e5ea3e3474de2c7476b995c3842857d2f749', 'src/third_party/perl': { 'url': Var('chromium_git') + '/chromium/deps/perl.git' + '@' + '6f3e5028eb65d0b4c5fdd792106ac4c84eee1eb3', @@ -1484,7 +1484,7 @@ Var('chromium_git') + '/external/khronosgroup/webgl.git' + '@' + 'dd55f3ca8f2ea716ca917a4aaf36f0729fe902b1', 'src/third_party/webrtc': - Var('webrtc_git') + '/src.git' + '@' + '64e07f445a1009d82238e43df89c0d6bd5e15a4f', + Var('webrtc_git') + '/src.git' + '@' + '229035db8cc676bb382f8734f9174df844e6a079', # 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. @@ -1551,7 +1551,7 @@ Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'), 'src-internal': { - 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@1d3b6135c44d96d25ec992654be7249e5455c408', + 'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@ed16d1d29e2f891c14764d138dd019b68cf5f96e', 'condition': 'checkout_src_internal', }, @@ -1733,6 +1733,17 @@ 'dep_type': 'cipd', }, + 'src/third_party/android_deps/libs/androidx_concurrent_concurrent_futures': { + 'packages': [ + { + 'package': 'chromium/third_party/android_deps/libs/androidx_concurrent_concurrent_futures', + 'version': 'version:1.0.0-cr0', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + 'src/third_party/android_deps/libs/androidx_coordinatorlayout_coordinatorlayout': { 'packages': [ { @@ -2965,6 +2976,17 @@ 'dep_type': 'cipd', }, + 'src/third_party/android_deps/libs/com_google_guava_listenablefuture': { + 'packages': [ + { + 'package': 'chromium/third_party/android_deps/libs/com_google_guava_listenablefuture', + 'version': 'version:1.0-cr0', + }, + ], + 'condition': 'checkout_android', + 'dep_type': 'cipd', + }, + 'src/third_party/android_deps/libs/com_google_j2objc_j2objc_annotations': { 'packages': [ {
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 9da44927..371bf1e 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py
@@ -60,6 +60,8 @@ r'mojo[\\/]examples[\\/].*', # Launcher for running iOS tests on the simulator. r'testing[\\/]iossim[\\/]iossim\.mm$', + # EarlGrey app side code for tests. + r'ios[\\/].*_app_interface\.mm$', ) _THIRD_PARTY_EXCEPT_BLINK = 'third_party/(?!blink/)'
diff --git a/ash/BUILD.gn b/ash/BUILD.gn index 809308e..000541aa 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn
@@ -117,7 +117,6 @@ "accelerators/pre_target_accelerator_handler.h", "accelerators/spoken_feedback_toggler.cc", "accelerators/spoken_feedback_toggler.h", - "accelerometer/accelerometer_constants.h", "accelerometer/accelerometer_reader.cc", "accelerometer/accelerometer_reader.h", "accelerometer/accelerometer_types.cc",
diff --git a/ash/accelerometer/accelerometer_constants.h b/ash/accelerometer/accelerometer_constants.h deleted file mode 100644 index 3e7d672..0000000 --- a/ash/accelerometer/accelerometer_constants.h +++ /dev/null
@@ -1,15 +0,0 @@ -// 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. - -#ifndef ASH_ACCELEROMETER_ACCELEROMETER_CONSTANTS_H_ -#define ASH_ACCELEROMETER_ACCELEROMETER_CONSTANTS_H_ - -namespace ash { - -// The mean acceleration due to gravity on Earth in m/s^2. -constexpr float kMeanGravity = 9.80665f; - -} // namespace ash - -#endif // ASH_ACCELEROMETER_ACCELEROMETER_CONSTANTS_H_
diff --git a/ash/accelerometer/accelerometer_reader.cc b/ash/accelerometer/accelerometer_reader.cc index 9630188..00c5acd 100644 --- a/ash/accelerometer/accelerometer_reader.cc +++ b/ash/accelerometer/accelerometer_reader.cc
@@ -3,7 +3,6 @@ // found in the LICENSE file. #include "ash/accelerometer/accelerometer_reader.h" -#include "ash/accelerometer/accelerometer_constants.h" #include <stddef.h> #include <stdint.h> @@ -19,6 +18,7 @@ #include "base/files/file_util.h" #include "base/location.h" #include "base/memory/singleton.h" +#include "base/numerics/math_constants.h" #include "base/observer_list_threadsafe.h" #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" @@ -643,7 +643,7 @@ configuration_.has[i] = true; for (size_t j = 0; j < base::size(kLegacyAccelerometerAxes); ++j) { - configuration_.scale[i][j] = kMeanGravity / scale_divisor; + configuration_.scale[i][j] = base::kMeanGravityFloat / scale_divisor; std::string accelerometer_index_path = base::StringPrintf( kLegacyAccelerometerScanIndexPathFormatString, kLegacyAccelerometerAxes[j], kAccelerometerNames[i]);
diff --git a/ash/accelerometer/accelerometer_types.cc b/ash/accelerometer/accelerometer_types.cc index 28ab864..4f3bc267 100644 --- a/ash/accelerometer/accelerometer_types.cc +++ b/ash/accelerometer/accelerometer_types.cc
@@ -3,8 +3,8 @@ // found in the LICENSE file. #include "ash/accelerometer/accelerometer_types.h" -#include "ash/accelerometer/accelerometer_constants.h" +#include "base/numerics/math_constants.h" #include "ui/gfx/geometry/vector3d_f.h" namespace ash { @@ -34,7 +34,7 @@ if (!has(source)) return false; - return std::abs(GetVector(source).Length() - kMeanGravity) <= + return std::abs(GetVector(source).Length() - base::kMeanGravityFloat) <= kDeviationFromGravityThreshold; }
diff --git a/ash/app_list/app_list_controller_impl.cc b/ash/app_list/app_list_controller_impl.cc index 3bc79e22..e72f320 100644 --- a/ash/app_list/app_list_controller_impl.cc +++ b/ash/app_list/app_list_controller_impl.cc
@@ -616,7 +616,7 @@ void AppListControllerImpl::OnOverviewModeStarting() { if (IsTabletMode()) { const int64_t display_id = last_visible_display_id_; - OnHomeLauncherTargetPositionChanged(false /* showing */, display_id); + OnHomeLauncherPositionChanged(false /* showing */, display_id); OnVisibilityWillChange(false /* visible */, display_id); } else { DismissAppList(); @@ -635,9 +635,9 @@ return; const int64_t display_id = last_visible_display_id_; bool target_visibility = GetTargetVisibility(); - if (home_launcher_animation_state_ == HomeLauncherAnimationState::kFinished) + if (home_launcher_transition_state_ == HomeLauncherTransitionState::kFinished) target_visibility &= !HasVisibleWindows(); - OnHomeLauncherTargetPositionChanged(target_visibility, display_id); + OnHomeLauncherPositionChanged(target_visibility, display_id); OnVisibilityWillChange(target_visibility, display_id); } @@ -789,7 +789,7 @@ void AppListControllerImpl::OnHomeLauncherAnimationComplete( bool shown, int64_t display_id) { - home_launcher_animation_state_ = HomeLauncherAnimationState::kFinished; + home_launcher_transition_state_ = HomeLauncherTransitionState::kFinished; CloseAssistantUi(shown ? AssistantExitPoint::kLauncherOpen : AssistantExitPoint::kLauncherClose); // Animations can be reversed (e.g. in a drag). Let's ensure the target @@ -801,12 +801,13 @@ home_launcher_animation_callback_.Run(shown); } -void AppListControllerImpl::OnHomeLauncherTargetPositionChanged( - bool showing, - int64_t display_id) { - home_launcher_animation_state_ = showing - ? HomeLauncherAnimationState::kShowing - : HomeLauncherAnimationState::kHiding; +void AppListControllerImpl::OnHomeLauncherPositionChanged(bool showing, + int64_t display_id) { + // TODO(manucornet): Make these depend on how far into the animation or drag + // we are. + home_launcher_transition_state_ = + showing ? HomeLauncherTransitionState::kMostlyShown + : HomeLauncherTransitionState::kMostlyHidden; OnVisibilityWillChange(showing, display_id); } @@ -1339,8 +1340,8 @@ // HomeLauncher is only visible when no other app windows are visible, // unless we are in the process of animating to (or dragging) the home // launcher. - if (IsTabletMode() && - home_launcher_animation_state_ == HomeLauncherAnimationState::kFinished) { + if (IsTabletMode() && home_launcher_transition_state_ == + HomeLauncherTransitionState::kFinished) { real_visibility &= !HasVisibleWindows(); } @@ -1380,8 +1381,8 @@ // HomeLauncher is only visible when no other app windows are visible, // unless we are in the process of animating to (or dragging) the home // launcher. - if (IsTabletMode() && - home_launcher_animation_state_ == HomeLauncherAnimationState::kFinished) { + if (IsTabletMode() && home_launcher_transition_state_ == + HomeLauncherTransitionState::kFinished) { real_target_visibility &= !HasVisibleWindows(); }
diff --git a/ash/app_list/app_list_controller_impl.h b/ash/app_list/app_list_controller_impl.h index f207c1f..8d2839a1 100644 --- a/ash/app_list/app_list_controller_impl.h +++ b/ash/app_list/app_list_controller_impl.h
@@ -68,10 +68,10 @@ AppListControllerImpl(); ~AppListControllerImpl() override; - enum HomeLauncherAnimationState { - kFinished, - kShowing, - kHiding, + enum HomeLauncherTransitionState { + kFinished, // No drag or animation is in progress + kMostlyShown, // The home launcher occupies more than half of the screen + kMostlyHidden, // The home launcher occupies less than half of the screen }; static void RegisterProfilePrefs(PrefRegistrySimple* registry); @@ -285,16 +285,15 @@ UpdateAnimationSettingsCallback callback) override; base::Optional<base::TimeDelta> GetOptionalAnimationDuration() override; void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) override; - void OnHomeLauncherTargetPositionChanged(bool showing, - int64_t display_id) override; + void OnHomeLauncherPositionChanged(bool showing, int64_t display_id) override; bool IsHomeScreenVisible() override; gfx::Rect GetInitialAppListItemScreenBoundsForWindow( aura::Window* window) override; bool onscreen_keyboard_shown() const { return onscreen_keyboard_shown_; } - HomeLauncherAnimationState home_launcher_animation_state() const { - return home_launcher_animation_state_; + HomeLauncherTransitionState home_launcher_transition_state() const { + return home_launcher_transition_state_; } // Performs the 'back' action for the active page. @@ -389,7 +388,7 @@ // information given by "showing" versus "hiding" is the starting point of // the drag and the assumed final state (which won't be accurate if the // gesture is reversed). - HomeLauncherAnimationState home_launcher_animation_state_ = kFinished; + HomeLauncherTransitionState home_launcher_transition_state_ = kFinished; AppListClient* client_ = nullptr;
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index d88cc4a..408eddb 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc
@@ -5,7 +5,6 @@ #include "ui/display/manager/display_manager.h" #include "ash/accelerators/accelerator_commands.h" -#include "ash/accelerometer/accelerometer_constants.h" #include "ash/accelerometer/accelerometer_reader.h" #include "ash/accelerometer/accelerometer_types.h" #include "ash/app_list/app_list_controller_impl.h" @@ -31,6 +30,7 @@ #include "ash/wm/window_util.h" #include "base/command_line.h" #include "base/format_macros.h" +#include "base/numerics/math_constants.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" @@ -3555,11 +3555,11 @@ void SetUp() override { DisplayManagerTest::SetUp(); portrait_primary->Set(ACCELEROMETER_SOURCE_SCREEN, false, - -kMeanGravity, 0.f, 0.f); + -base::kMeanGravityFloat, 0.f, 0.f); portrait_secondary->Set(ACCELEROMETER_SOURCE_SCREEN, false, - kMeanGravity, 0.f, 0.f); - landscape_primary->Set(ACCELEROMETER_SOURCE_SCREEN, false, - 0, -kMeanGravity, 0.f); + base::kMeanGravityFloat, 0.f, 0.f); + landscape_primary->Set(ACCELEROMETER_SOURCE_SCREEN, false, 0, + -base::kMeanGravityFloat, 0.f); } protected:
diff --git a/ash/display/display_prefs_unittest.cc b/ash/display/display_prefs_unittest.cc index 3257e5d..5d6af550 100644 --- a/ash/display/display_prefs_unittest.cc +++ b/ash/display/display_prefs_unittest.cc
@@ -11,7 +11,6 @@ #include <utility> #include <vector> -#include "ash/accelerometer/accelerometer_constants.h" #include "ash/display/display_configuration_observer.h" #include "ash/display/display_util.h" #include "ash/display/resolution_notification_controller.h" @@ -27,6 +26,7 @@ #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/ref_counted.h" +#include "base/numerics/math_constants.h" #include "base/strings/string_number_conversions.h" #include "base/test/scoped_feature_list.h" #include "base/values.h" @@ -849,17 +849,19 @@ // Open up 270 degrees to trigger tablet mode scoped_refptr<AccelerometerUpdate> update(new AccelerometerUpdate()); update->Set(ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, false, 0.0f, 0.0f, - -kMeanGravity); - update->Set(ACCELEROMETER_SOURCE_SCREEN, false, 0.0f, kMeanGravity, 0.0f); + -base::kMeanGravityFloat); + update->Set(ACCELEROMETER_SOURCE_SCREEN, false, 0.0f, base::kMeanGravityFloat, + 0.0f); ash::TabletModeController* controller = ash::Shell::Get()->tablet_mode_controller(); controller->OnAccelerometerUpdated(update); EXPECT_TRUE(controller->InTabletMode()); // Trigger 90 degree rotation - update->Set(ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, false, kMeanGravity, 0.0f, + update->Set(ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, false, + base::kMeanGravityFloat, 0.0f, 0.0f); + update->Set(ACCELEROMETER_SOURCE_SCREEN, false, base::kMeanGravityFloat, 0.0f, 0.0f); - update->Set(ACCELEROMETER_SOURCE_SCREEN, false, kMeanGravity, 0.0f, 0.0f); controller->OnAccelerometerUpdated(update); shell->screen_orientation_controller()->OnAccelerometerUpdated(update); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); @@ -998,8 +1000,9 @@ // Open up 270 degrees to trigger tablet mode scoped_refptr<AccelerometerUpdate> update(new AccelerometerUpdate()); update->Set(ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, false, 0.0f, 0.0f, - -kMeanGravity); - update->Set(ACCELEROMETER_SOURCE_SCREEN, false, 0.0f, kMeanGravity, 0.0f); + -base::kMeanGravityFloat); + update->Set(ACCELEROMETER_SOURCE_SCREEN, false, 0.0f, base::kMeanGravityFloat, + 0.0f); ash::TabletModeController* tablet_mode_controller = ash::Shell::Get()->tablet_mode_controller(); tablet_mode_controller->OnAccelerometerUpdated(update);
diff --git a/ash/display/screen_orientation_controller_unittest.cc b/ash/display/screen_orientation_controller_unittest.cc index 61f2910..17a51c86 100644 --- a/ash/display/screen_orientation_controller_unittest.cc +++ b/ash/display/screen_orientation_controller_unittest.cc
@@ -7,7 +7,6 @@ #include <memory> #include <vector> -#include "ash/accelerometer/accelerometer_constants.h" #include "ash/accelerometer/accelerometer_reader.h" #include "ash/accelerometer/accelerometer_types.h" #include "ash/display/screen_orientation_controller.h" @@ -27,6 +26,7 @@ #include "ash/wm/window_state.h" #include "base/command_line.h" #include "base/macros.h" +#include "base/numerics/math_constants.h" #include "base/test/scoped_feature_list.h" #include "ui/aura/client/aura_constants.h" #include "ui/aura/window.h" @@ -42,6 +42,8 @@ namespace ash { namespace { +using base::kMeanGravityFloat; + const float kDegreesToRadians = 3.1415926f / 180.0f; display::ManagedDisplayInfo CreateDisplayInfo(int64_t id, @@ -366,13 +368,13 @@ EnableTabletMode(true); // Now test rotating in all directions. - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(-kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); } @@ -381,15 +383,15 @@ TEST_F(ScreenOrientationControllerTest, RotationIgnoresLowAngles) { EnableTabletMode(true); - TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravityFloat, kMeanGravityFloat)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, kMeanGravityFloat)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, kMeanGravityFloat)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, kMeanGravityFloat)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, kMeanGravityFloat)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); } @@ -398,30 +400,30 @@ TEST_F(ScreenOrientationControllerTest, RotationSticky) { EnableTabletMode(true); - gfx::Vector3dF gravity(0.0f, kMeanGravity, 0.0f); + gfx::Vector3dF gravity(0.0f, kMeanGravityFloat, 0.0f); TriggerLidUpdate(gravity); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); // Turn past half-way point to next direction and rotation should remain // the same. float degrees = 50.0; - gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravity); - gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravity); + gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravityFloat); + gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravityFloat); TriggerLidUpdate(gravity); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); // Turn more and the screen should rotate. degrees = 70.0; - gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravity); - gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravity); + gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravityFloat); + gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravityFloat); TriggerLidUpdate(gravity); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); // Turn back just beyond the half-way point and the new rotation should // still be in effect. degrees = 40.0; - gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravity); - gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravity); + gravity.set_x(-sin(degrees * kDegreesToRadians) * -kMeanGravityFloat); + gravity.set_y(-cos(degrees * kDegreesToRadians) * -kMeanGravityFloat); TriggerLidUpdate(gravity); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); } @@ -434,8 +436,8 @@ // Turn past the threshold for rotation. float degrees = 90.0; - gfx::Vector3dF gravity(-sin(degrees * kDegreesToRadians) * -kMeanGravity, - -cos(degrees * kDegreesToRadians) * -kMeanGravity, + gfx::Vector3dF gravity(-sin(degrees * kDegreesToRadians) * -kMeanGravityFloat, + -cos(degrees * kDegreesToRadians) * -kMeanGravityFloat, 0.0f); TriggerLidUpdate(gravity); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); @@ -485,7 +487,7 @@ // via the accelerometer while in tablet mode // Rotate the screen 90 degrees ASSERT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); ASSERT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); EXPECT_EQ(0u, message_center->NotificationCount()); EXPECT_FALSE(message_center->HasPopupNotifications()); @@ -516,7 +518,7 @@ SetInternalDisplayRotation(display::Display::ROTATE_90); EnableTabletMode(true); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); EnableTabletMode(false); @@ -549,13 +551,13 @@ EXPECT_TRUE(RotationLocked()); // Inverse of orientation is allowed - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); // Display rotations between are not allowed - TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(-kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); } @@ -572,13 +574,13 @@ EXPECT_TRUE(RotationLocked()); // Inverse of orientation is allowed - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); // Display rotations between are not allowed - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); } @@ -595,11 +597,11 @@ EXPECT_TRUE(RotationLocked()); // Rotation does not change. - TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(-kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); } @@ -619,7 +621,7 @@ EXPECT_TRUE(UserRotationLocked()); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); } @@ -768,14 +770,14 @@ TabletModeControllerTestApi tablet_mode_controller_test_api; EXPECT_FALSE(tablet_mode_controller_test_api.IsInPhysicalTabletState()); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); // Once the device goes into tablet mode, it becomes possible to auto-rotate. tablet_mode_controller_test_api.OpenLidToAngle(270); EXPECT_TRUE(tablet_mode_controller_test_api.IsInPhysicalTabletState()); EXPECT_TRUE(tablet_mode_controller_test_api.IsTabletModeStarted()); - TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); // Hooking an external pointing device will exits tablet UI mode, but the @@ -784,7 +786,7 @@ tablet_mode_controller_test_api.AttachExternalMouse(); EXPECT_TRUE(tablet_mode_controller_test_api.IsInPhysicalTabletState()); EXPECT_FALSE(tablet_mode_controller_test_api.IsTabletModeStarted()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); }
diff --git a/ash/home_screen/drag_window_from_shelf_controller_unittest.cc b/ash/home_screen/drag_window_from_shelf_controller_unittest.cc index 838a612..3999704 100644 --- a/ash/home_screen/drag_window_from_shelf_controller_unittest.cc +++ b/ash/home_screen/drag_window_from_shelf_controller_unittest.cc
@@ -35,6 +35,13 @@ base::RunLoop().RunUntilIdle(); } + void TearDown() override { + // Destroy |window_drag_controller_| so that its scheduled task won't get + // run after the test environment is gone. + window_drag_controller_.reset(); + AshTestBase::TearDown(); + } + void StartDrag(aura::Window* window, const gfx::Point& location_in_screen, HotseatState hotseat_state) {
diff --git a/ash/home_screen/home_launcher_gesture_handler.cc b/ash/home_screen/home_launcher_gesture_handler.cc index c48538a..32835a0 100644 --- a/ash/home_screen/home_launcher_gesture_handler.cc +++ b/ash/home_screen/home_launcher_gesture_handler.cc
@@ -401,11 +401,10 @@ return mode_ != Mode::kNone; } -void HomeLauncherGestureHandler::NotifyHomeLauncherTargetPositionChanged( +void HomeLauncherGestureHandler::NotifyHomeLauncherPositionChanged( bool showing, int64_t display_id) { - GetHomeScreenDelegate()->OnHomeLauncherTargetPositionChanged(showing, - display_id); + GetHomeScreenDelegate()->OnHomeLauncherPositionChanged(showing, display_id); } void HomeLauncherGestureHandler::NotifyHomeLauncherAnimationComplete( @@ -561,11 +560,11 @@ trigger /**animation_trigger*/); if (!is_final_state_show && mode_ == Mode::kSlideDownToHide) { - NotifyHomeLauncherTargetPositionChanged(false /*showing*/, display_.id()); + NotifyHomeLauncherPositionChanged(false /*showing*/, display_.id()); base::RecordAction( base::UserMetricsAction("AppList_HomeLauncherToMRUWindow")); } else if (is_final_state_show && mode_ == Mode::kSlideUpToShow) { - NotifyHomeLauncherTargetPositionChanged(true /*showing*/, display_.id()); + NotifyHomeLauncherPositionChanged(true /*showing*/, display_.id()); base::RecordAction( base::UserMetricsAction("AppList_CurrentWindowToHomeLauncher")); } @@ -917,8 +916,8 @@ swipe_home_to_overview_controller_ = std::make_unique<SwipeHomeToOverviewController>(display_.id()); } else { - NotifyHomeLauncherTargetPositionChanged( - mode_ == Mode::kSlideUpToShow /*showing*/, display_.id()); + NotifyHomeLauncherPositionChanged(mode_ == Mode::kSlideUpToShow /*showing*/, + display_.id()); HomeScreenDelegate* home_screen_delegate = GetHomeScreenDelegate(); DCHECK(home_screen_delegate);
diff --git a/ash/home_screen/home_launcher_gesture_handler.h b/ash/home_screen/home_launcher_gesture_handler.h index a2cc973..42ada676 100644 --- a/ash/home_screen/home_launcher_gesture_handler.h +++ b/ash/home_screen/home_launcher_gesture_handler.h
@@ -80,8 +80,7 @@ bool IsDragInProgress() const; - void NotifyHomeLauncherTargetPositionChanged(bool showing, - int64_t display_id); + void NotifyHomeLauncherPositionChanged(bool showing, int64_t display_id); void NotifyHomeLauncherAnimationComplete(bool shown, int64_t display_id); // TODO(sammiequon): Investigate if it is needed to observe potential window
diff --git a/ash/home_screen/home_screen_controller.cc b/ash/home_screen/home_screen_controller.cc index ca56b44..16889d0cc 100644 --- a/ash/home_screen/home_screen_controller.cc +++ b/ash/home_screen/home_screen_controller.cc
@@ -169,7 +169,7 @@ if (!active_windows.empty()) { { // Disable window animations before updating home launcher target - // position. Calling OnHomeLauncherTargetPositionChanged() can cause + // position. Calling OnHomeLauncherPositionChanged() can cause // display work area update, and resulting cross-fade window bounds change // animation can interfere with WindowTransformToHomeScreenAnimation // visuals. @@ -182,8 +182,7 @@ std::make_unique<ScopedAnimationDisabler>(window)); } - delegate_->OnHomeLauncherTargetPositionChanged(true /* showing */, - display_id); + delegate_->OnHomeLauncherPositionChanged(true /* showing */, display_id); } base::RepeatingClosure window_transforms_callback = base::BarrierClosure(
diff --git a/ash/home_screen/home_screen_delegate.h b/ash/home_screen/home_screen_delegate.h index 683284e..e4172cda 100644 --- a/ash/home_screen/home_screen_delegate.h +++ b/ash/home_screen/home_screen_delegate.h
@@ -113,10 +113,10 @@ virtual void OnHomeLauncherDragInProgress() {} virtual void OnHomeLauncherDragEnd() {} - // Called when the HomeLauncher has started to be dragged, or a positional - // animation has begun. - virtual void OnHomeLauncherTargetPositionChanged(bool showing, - int64_t display_id) {} + // Called when the HomeLauncher has changed its position on the screen, + // during either an animation or a drag. + virtual void OnHomeLauncherPositionChanged(bool showing, int64_t display_id) { + } // Called when the HomeLauncher positional animation has completed. virtual void OnHomeLauncherAnimationComplete(bool shown, int64_t display_id) {
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc index 104710a..8cc20ad 100644 --- a/ash/shelf/shelf_layout_manager.cc +++ b/ash/shelf/shelf_layout_manager.cc
@@ -703,8 +703,8 @@ // If the home launcher is shown, being animated, or dragged, show the // default background. if (app_list_is_visible || - Shell::Get()->app_list_controller()->home_launcher_animation_state() != - AppListControllerImpl::HomeLauncherAnimationState::kFinished) + Shell::Get()->app_list_controller()->home_launcher_transition_state() != + AppListControllerImpl::HomeLauncherTransitionState::kFinished) return SHELF_BACKGROUND_DEFAULT; } else if (app_list_is_visible) { return maximized ? SHELF_BACKGROUND_MAXIMIZED_WITH_APP_LIST @@ -1102,12 +1102,12 @@ switch (drag_status_) { case kDragNone: case kDragHomeToOverviewInProgress: { - switch (app_list_controller->home_launcher_animation_state()) { - case AppListControllerImpl::HomeLauncherAnimationState::kShowing: + switch (app_list_controller->home_launcher_transition_state()) { + case AppListControllerImpl::HomeLauncherTransitionState::kMostlyShown: return HotseatState::kShown; - case AppListControllerImpl::HomeLauncherAnimationState::kHiding: + case AppListControllerImpl::HomeLauncherTransitionState::kMostlyHidden: return in_overview ? HotseatState::kExtended : HotseatState::kHidden; - case AppListControllerImpl::HomeLauncherAnimationState::kFinished: + case AppListControllerImpl::HomeLauncherTransitionState::kFinished: // Consider the AppList visible if it is beginning to show. Also // detect the case where the last window is being minimized. if (app_list_visible) @@ -1436,8 +1436,8 @@ if (state.IsShelfAutoHidden()) { shelf_in_screen_portion = - Shell::Get()->app_list_controller()->home_launcher_animation_state() == - AppListControllerImpl::HomeLauncherAnimationState::kShowing + Shell::Get()->app_list_controller()->home_launcher_transition_state() == + AppListControllerImpl::HomeLauncherTransitionState::kMostlyShown ? shelf_size : ShelfConfig::Get()->hidden_shelf_in_screen_portion(); } else if (state.visibility_state == SHELF_HIDDEN || @@ -1892,8 +1892,8 @@ // The shelf should not become transparent during the animation to or from // HomeLauncher. if (chromeos::switches::ShouldShowShelfHotseat() && IsTabletModeEnabled() && - Shell::Get()->app_list_controller()->home_launcher_animation_state() != - AppListControllerImpl::HomeLauncherAnimationState::kFinished) { + Shell::Get()->app_list_controller()->home_launcher_transition_state() != + AppListControllerImpl::HomeLauncherTransitionState::kFinished) { return 1.0f; }
diff --git a/ash/wm/tablet_mode/tablet_mode_controller_test_api.cc b/ash/wm/tablet_mode/tablet_mode_controller_test_api.cc index aaead46..6e68feb 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller_test_api.cc +++ b/ash/wm/tablet_mode/tablet_mode_controller_test_api.cc
@@ -7,6 +7,7 @@ #include "ash/public/cpp/ash_switches.h" #include "ash/shell.h" #include "base/command_line.h" +#include "base/numerics/math_constants.h" #include "base/run_loop.h" #include "base/time/default_tick_clock.h" #include "ui/events/devices/device_data_manager_test_api.h" @@ -84,9 +85,9 @@ DCHECK(degrees <= 360.0f); float radians = degrees * kDegreesToRadians; - gfx::Vector3dF base_vector(0.0f, -kMeanGravity, 0.0f); - gfx::Vector3dF lid_vector(0.0f, kMeanGravity * cos(radians), - kMeanGravity * sin(radians)); + gfx::Vector3dF base_vector(0.0f, -base::kMeanGravityFloat, 0.0f); + gfx::Vector3dF lid_vector(0.0f, base::kMeanGravityFloat * cos(radians), + base::kMeanGravityFloat * sin(radians)); TriggerBaseAndLidUpdate(base_vector, lid_vector); }
diff --git a/ash/wm/tablet_mode/tablet_mode_controller_test_api.h b/ash/wm/tablet_mode/tablet_mode_controller_test_api.h index 3ddfdf71..0c0b426 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller_test_api.h +++ b/ash/wm/tablet_mode/tablet_mode_controller_test_api.h
@@ -7,7 +7,6 @@ #include <memory> -#include "ash/accelerometer/accelerometer_constants.h" #include "ash/wm/tablet_mode/internal_input_devices_event_blocker.h" #include "ash/wm/tablet_mode/tablet_mode_controller.h" #include "base/macros.h"
diff --git a/ash/wm/tablet_mode/tablet_mode_controller_unittest.cc b/ash/wm/tablet_mode/tablet_mode_controller_unittest.cc index 0d70d58..9348412 100644 --- a/ash/wm/tablet_mode/tablet_mode_controller_unittest.cc +++ b/ash/wm/tablet_mode/tablet_mode_controller_unittest.cc
@@ -9,7 +9,6 @@ #include <utility> #include <vector> -#include "ash/accelerometer/accelerometer_constants.h" #include "ash/accelerometer/accelerometer_reader.h" #include "ash/accelerometer/accelerometer_types.h" #include "ash/app_list/app_list_controller_impl.h" @@ -35,6 +34,7 @@ #include "ash/wm/window_util.h" #include "ash/wm/wm_event.h" #include "base/command_line.h" +#include "base/numerics/math_constants.h" #include "base/run_loop.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/metrics/user_action_tester.h" @@ -60,9 +60,10 @@ #include "ui/wm/core/window_util.h" namespace ash { - namespace { +using base::kMeanGravityFloat; + // The strings are "Touchview" as they're already used in metrics. constexpr char kTabletModeInitiallyDisabled[] = "Touchview_Initially_Disabled"; constexpr char kTabletModeEnabled[] = "Touchview_Enabled"; @@ -353,14 +354,14 @@ // rely on the tablet mode switch. TEST_P(TabletModeControllerTest, TabletModeTransitionNoKeyboardAccelerometer) { ASSERT_FALSE(IsTabletModeStarted()); - TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravityFloat)); ASSERT_FALSE(IsTabletModeStarted()); SetTabletMode(true); EXPECT_TRUE(IsTabletModeStarted()); // Single sensor reading should not change mode. - TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravityFloat)); EXPECT_TRUE(IsTabletModeStarted()); // With a single sensor we should exit immediately on the tablet mode switch @@ -453,29 +454,29 @@ // persists as the computed angle is highly inaccurate in this orientation. TEST_P(TabletModeControllerTest, HingeAligned) { // Laptop in normal orientation lid open 90 degrees. - TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), - gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravityFloat), + gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); EXPECT_FALSE(IsTabletModeStarted()); // Completely vertical. - TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f), - gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f), + gfx::Vector3dF(kMeanGravityFloat, 0.0f, 0.0f)); EXPECT_FALSE(IsTabletModeStarted()); // Close to vertical but with hinge appearing to be open 270 degrees. - TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, -0.1f), - gfx::Vector3dF(kMeanGravity, 0.1f, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, -0.1f), + gfx::Vector3dF(kMeanGravityFloat, 0.1f, 0.0f)); EXPECT_FALSE(IsTabletModeStarted()); // Flat and open 270 degrees should start tablet mode. - TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), - gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravityFloat), + gfx::Vector3dF(0.0f, kMeanGravityFloat, 0.0f)); EXPECT_TRUE(IsTabletModeStarted()); // Normal 90 degree orientation but near vertical should stay in maximize // mode. - TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, -0.1f), - gfx::Vector3dF(kMeanGravity, -0.1f, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(kMeanGravityFloat, 0.0f, -0.1f), + gfx::Vector3dF(kMeanGravityFloat, -0.1f, 0.0f)); EXPECT_TRUE(IsTabletModeStarted()); } @@ -489,11 +490,11 @@ gfx::Vector3dF base(-kAccelerometerLaptopModeTestData[i * 6 + 1], -kAccelerometerLaptopModeTestData[i * 6], -kAccelerometerLaptopModeTestData[i * 6 + 2]); - base.Scale(kMeanGravity); + base.Scale(kMeanGravityFloat); gfx::Vector3dF lid(-kAccelerometerLaptopModeTestData[i * 6 + 4], kAccelerometerLaptopModeTestData[i * 6 + 3], kAccelerometerLaptopModeTestData[i * 6 + 5]); - lid.Scale(kMeanGravity); + lid.Scale(kMeanGravityFloat); TriggerBaseAndLidUpdate(base, lid); // There are a lot of samples, so ASSERT rather than EXPECT to only generate // one failure rather than potentially hundreds. @@ -503,8 +504,8 @@ TEST_P(TabletModeControllerTest, TabletModeTest) { // Trigger tablet mode by opening to 270 to begin the test in tablet mode. - TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), - gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravityFloat), + gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); ASSERT_TRUE(IsTabletModeStarted()); // Feeds in sample accelerometer data and verifies that there are no @@ -516,11 +517,11 @@ gfx::Vector3dF base(-kAccelerometerFullyOpenTestData[i * 6 + 1], -kAccelerometerFullyOpenTestData[i * 6], -kAccelerometerFullyOpenTestData[i * 6 + 2]); - base.Scale(kMeanGravity); + base.Scale(kMeanGravityFloat); gfx::Vector3dF lid(-kAccelerometerFullyOpenTestData[i * 6 + 4], kAccelerometerFullyOpenTestData[i * 6 + 3], kAccelerometerFullyOpenTestData[i * 6 + 5]); - lid.Scale(kMeanGravity); + lid.Scale(kMeanGravityFloat); TriggerBaseAndLidUpdate(base, lid); // There are a lot of samples, so ASSERT rather than EXPECT to only generate // one failure rather than potentially hundreds. @@ -645,8 +646,8 @@ // angles when hinge is nearly vertical TEST_P(TabletModeControllerTest, VerticalHingeUnstableAnglesTest) { // Trigger tablet mode by opening to 270 to begin the test in tablet mode. - TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), - gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); + TriggerBaseAndLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravityFloat), + gfx::Vector3dF(0.0f, -kMeanGravityFloat, 0.0f)); ASSERT_TRUE(IsTabletModeStarted()); // Feeds in sample accelerometer data and verifies that there are no @@ -742,7 +743,7 @@ // The timer should be stopped in response to a lid-only update since we can // no longer compute an angle. - TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity)); + TriggerLidUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravityFloat)); EXPECT_FALSE( tablet_mode_controller()->TriggerRecordLidAngleTimerForTesting()); histogram_tester.ExpectTotalCount(
diff --git a/base/allocator/partition_allocator/oom.h b/base/allocator/partition_allocator/oom.h index 6623a01..8d3fe08 100644 --- a/base/allocator/partition_allocator/oom.h +++ b/base/allocator/partition_allocator/oom.h
@@ -7,34 +7,33 @@ #include "base/allocator/partition_allocator/oom_callback.h" #include "base/logging.h" +#include "base/process/memory.h" +#include "build/build_config.h" #if defined(OS_WIN) #include <windows.h> #endif -// Do not want trivial entry points just calling OOM_CRASH() to be -// commoned up by linker icf/comdat folding. -#define OOM_CRASH_PREVENT_ICF() \ - volatile int oom_crash_inhibit_icf = __LINE__; \ - ALLOW_UNUSED_LOCAL(oom_crash_inhibit_icf) +namespace { +// The crash is generated in a NOINLINE function so that we can classify the +// crash as an OOM solely by analyzing the stack trace. +NOINLINE void OnNoMemory() { + base::internal::RunPartitionAllocOomCallback(); +#if defined(OS_WIN) + ::RaiseException(base::win::kOomExceptionCode, EXCEPTION_NONCONTINUABLE, 0, + nullptr); +#endif + IMMEDIATE_CRASH(); +} +} // namespace // OOM_CRASH() - Specialization of IMMEDIATE_CRASH which will raise a custom // exception on Windows to signal this is OOM and not a normal assert. -#if defined(OS_WIN) -#define OOM_CRASH() \ - do { \ - OOM_CRASH_PREVENT_ICF(); \ - base::internal::RunPartitionAllocOomCallback(); \ - ::RaiseException(0xE0000008, EXCEPTION_NONCONTINUABLE, 0, nullptr); \ - IMMEDIATE_CRASH(); \ +// OOM_CRASH() is called by users of PageAllocator (including PartitionAlloc) to +// signify an allocation failure from the platform. +#define OOM_CRASH() \ + do { \ + OnNoMemory(); \ } while (0) -#else -#define OOM_CRASH() \ - do { \ - base::internal::RunPartitionAllocOomCallback(); \ - OOM_CRASH_PREVENT_ICF(); \ - IMMEDIATE_CRASH(); \ - } while (0) -#endif #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_OOM_H_
diff --git a/base/android/java/src/org/chromium/base/LifetimeAssert.java b/base/android/java/src/org/chromium/base/LifetimeAssert.java index c85d22be..5967b577 100644 --- a/base/android/java/src/org/chromium/base/LifetimeAssert.java +++ b/base/android/java/src/org/chromium/base/LifetimeAssert.java
@@ -58,6 +58,8 @@ @VisibleForTesting final WrappedReference mWrapper; + private final Object mTarget; + @VisibleForTesting static class WrappedReference extends PhantomReference<Object> { boolean mSafeToGc; @@ -114,28 +116,39 @@ } } - private LifetimeAssert(WrappedReference wrapper) { + private LifetimeAssert(WrappedReference wrapper, Object target) { mWrapper = wrapper; + mTarget = target; } public static LifetimeAssert create(Object target) { if (!BuildConfig.DCHECK_IS_ON) { return null; } - return new LifetimeAssert(new WrappedReference(target, new CreationException(), false)); + return new LifetimeAssert( + new WrappedReference(target, new CreationException(), false), target); } public static LifetimeAssert create(Object target, boolean safeToGc) { if (!BuildConfig.DCHECK_IS_ON) { return null; } - return new LifetimeAssert(new WrappedReference(target, new CreationException(), safeToGc)); + return new LifetimeAssert( + new WrappedReference(target, new CreationException(), safeToGc), target); } public static void setSafeToGc(LifetimeAssert asserter, boolean value) { if (BuildConfig.DCHECK_IS_ON) { - // asserter is never null when DCHECK_IS_ON. - asserter.mWrapper.mSafeToGc = value; + // This guaratees that the target object is reachable until after mSafeToGc value + // is updated here. See comment on Reference.reachabilityFence and review comments + // on https://chromium-review.googlesource.com/c/chromium/src/+/1887151 for a + // problematic example. This synchronized is used instead of calling + // reachabilityFence because robolectric has problems mocking out that method, + // and this should work for all Android versions. + synchronized (asserter.mTarget) { + // asserter is never null when DCHECK_IS_ON. + asserter.mWrapper.mSafeToGc = value; + } } }
diff --git a/base/numerics/math_constants.h b/base/numerics/math_constants.h index 9a5b8ef..862af2a 100644 --- a/base/numerics/math_constants.h +++ b/base/numerics/math_constants.h
@@ -10,6 +10,10 @@ constexpr double kPiDouble = 3.14159265358979323846; constexpr float kPiFloat = 3.14159265358979323846f; +// The mean acceleration due to gravity on Earth in m/s^2. +constexpr double kMeanGravityDouble = 9.80665; +constexpr float kMeanGravityFloat = 9.80665f; + } // namespace base #endif // BASE_NUMERICS_MATH_CONSTANTS_H_
diff --git a/base/task/promise/dependent_list.h b/base/task/promise/dependent_list.h index 3245c1c..eb7323e 100644 --- a/base/task/promise/dependent_list.h +++ b/base/task/promise/dependent_list.h
@@ -6,10 +6,12 @@ #define BASE_TASK_PROMISE_DEPENDENT_LIST_H_ #include <atomic> +#include <cstddef> #include <cstdint> #include <type_traits> #include "base/base_export.h" +#include "base/compiler_specific.h" #include "base/logging.h" #include "base/macros.h" #include "base/memory/scoped_refptr.h" @@ -57,8 +59,6 @@ FAIL_PROMISE_CANCELED, }; - // Align Node on an 8-byte boundary to ensure the first 3 bits are 0 and can - // be used to store additional state (see static_asserts below). class BASE_EXPORT ALIGNAS(8) Node { public: Node(); @@ -245,10 +245,24 @@ NextPowerOfTwo(static_cast<uintptr_t>(State::kLastValue)) - 1; static constexpr uintptr_t kAllowInsertsBitMask = kStateMask + 1; static constexpr uintptr_t kHeadMask = ~(kAllowInsertsBitMask | kStateMask); + static constexpr uintptr_t kRequiredNodeAlignment = ~kHeadMask + 1; + // It is really important that Node instances get aligned so that we can store + // state in the lower bits of pointers. + // + // Allocators are required to return memory aligned at least as strictly as + // std::max_align_t but not more, so we can not ask for a bigger alignment + // here otherwise we risk not getting proper alignment from heap allocations. + // Also, to make sure that stack allocations also get properly aligned (used + // currently in tests) we need the ALIGNAS(8) attribute, which is ignored by + // allocators. Thus we need the two following static_asserts. static_assert( - std::alignment_of<Node>() > kAllowInsertsBitMask, + std::alignment_of<Node>() >= kRequiredNodeAlignment, "Will not be able to hold the Node* and all the state in a uintptr_t"); + static_assert( + std::alignment_of<std::max_align_t>() >= std::alignment_of<Node>(), + "malloc (et al.) will not return memory propery aligned to be able to " + "hold the Node* and all the state in a uintptr_t"); static State ExtractState(uintptr_t data) { return static_cast<State>(data & kStateMask);
diff --git a/base/task/task_features.cc b/base/task/task_features.cc index 55bba7e3..f934b4e 100644 --- a/base/task/task_features.cc +++ b/base/task/task_features.cc
@@ -31,4 +31,7 @@ const Feature kUseFiveMinutesThreadReclaimTime = { "UseFiveMinutesThreadReclaimTime", base::FEATURE_DISABLED_BY_DEFAULT}; +const Feature kNoPriorityInheritanceFromThreadPool{ + "NoPriorityInheritanceFromThreadPool", base::FEATURE_DISABLED_BY_DEFAULT}; + } // namespace base
diff --git a/base/task/task_features.h b/base/task/task_features.h index be1f70a5..3986326d 100644 --- a/base/task/task_features.h +++ b/base/task/task_features.h
@@ -41,6 +41,12 @@ // minutes, instead of 30 seconds. extern const BASE_EXPORT Feature kUseFiveMinutesThreadReclaimTime; +// Under this feature, the current default of inheriting priority when posting +// from the ThreadPool is disabled. +// Details @ +// https://docs.google.com/document/d/13PIBPuSPJbrgHAgyRbY22EWAfH2narnxpa_CgBmZbSY +extern const BASE_EXPORT Feature kNoPriorityInheritanceFromThreadPool; + } // namespace base #endif // BASE_TASK_TASK_FEATURES_H_
diff --git a/base/task/task_traits.cc b/base/task/task_traits.cc index 4ebb87a7..472d437 100644 --- a/base/task/task_traits.cc +++ b/base/task/task_traits.cc
@@ -12,6 +12,17 @@ namespace base { +// The state of |FeatureList::IsEnabled(kNoPriorityInheritanceFromThreadPool)| +// as controlled by intenal::SetNoPriorityInheritanceFromThreadPool(). +bool g_no_priority_inheritance_from_thread_pool = false; + +void TaskTraits::InheritPriority(TaskPriority priority) { + if (priority_set_explicitly() || g_no_priority_inheritance_from_thread_pool) + return; + + priority_ = static_cast<uint8_t>(priority); +} + const char* TaskPriorityToString(TaskPriority task_priority) { switch (task_priority) { case TaskPriority::BEST_EFFORT: @@ -50,4 +61,10 @@ return os; } +namespace internal { +void SetNoPriorityInheritanceFromThreadPool() { + g_no_priority_inheritance_from_thread_pool = true; +} +} // namespace internal + } // namespace base
diff --git a/base/task/task_traits.h b/base/task/task_traits.h index 03abf17..2b9fc13 100644 --- a/base/task/task_traits.h +++ b/base/task/task_traits.h
@@ -304,11 +304,7 @@ } // Sets the priority to |priority| if it wasn't explicitly set before. - void InheritPriority(TaskPriority priority) { - if (priority_set_explicitly()) - return; - priority_ = static_cast<uint8_t>(priority); - } + void InheritPriority(TaskPriority priority); // Returns true if the priority was set explicitly. constexpr bool priority_set_explicitly() const { @@ -418,6 +414,13 @@ std::ostream& os, const TaskShutdownBehavior& shutdown_behavior); +namespace internal { +// Enables the kNoPriorityInheritanceFromThreadPool experimental feature. Must +// be done statically when the ThreadPoolImpl is initialized because it's racy +// to check the state later. +void SetNoPriorityInheritanceFromThreadPool(); +} // namespace internal + } // namespace base #endif // BASE_TASK_TASK_TRAITS_H_
diff --git a/base/task/thread_pool/thread_pool_impl.cc b/base/task/thread_pool/thread_pool_impl.cc index e49c754..473fa40f 100644 --- a/base/task/thread_pool/thread_pool_impl.cc +++ b/base/task/thread_pool/thread_pool_impl.cc
@@ -123,6 +123,9 @@ internal::InitializeThreadPrioritiesFeature(); + if (FeatureList::IsEnabled(kNoPriorityInheritanceFromThreadPool)) + internal::SetNoPriorityInheritanceFromThreadPool(); + // The max number of concurrent BEST_EFFORT tasks is |kMaxBestEffortTasks|, // unless the max number of foreground threads is lower. const int max_best_effort_tasks =
diff --git a/build/config/fuchsia/BUILD.gn b/build/config/fuchsia/BUILD.gn index e6abcc3..56d79f41 100644 --- a/build/config/fuchsia/BUILD.gn +++ b/build/config/fuchsia/BUILD.gn
@@ -49,6 +49,14 @@ # Add SDK lib dir for -lfdio above. lib_dirs = [ "${fuchsia_sdk}/arch/${current_cpu}/lib" ] + # TODO(crbug.com/821951): Clang enables SafeStack by default when targeting + # Fuchsia, but it breaks some tests, notably in V8. + # Force the toolchain to use shadow-call-stack instead, until that is default. + cflags += [ + "-fno-sanitize=safe-stack", + "-fsanitize=shadow-call-stack", + ] + libs = [ "zircon" ] }
diff --git a/build/config/sanitizers/BUILD.gn b/build/config/sanitizers/BUILD.gn index e2f4cfa..f58b79c 100644 --- a/build/config/sanitizers/BUILD.gn +++ b/build/config/sanitizers/BUILD.gn
@@ -486,9 +486,9 @@ rebase_path("//tools/ubsan/blacklist.txt", root_build_dir) } cflags += [ - # Yasm dies with an "Illegal instruction" error when bounds checking is - # enabled. See http://crbug.com/489901 - # "-fsanitize=bounds", + "-fsanitize=bool", + "-fsanitize=bounds", + "-fsanitize=builtin", "-fsanitize=float-divide-by-zero", "-fsanitize=integer-divide-by-zero", "-fsanitize=null", @@ -500,7 +500,6 @@ "-fsanitize=signed-integer-overflow", "-fsanitize=unreachable", "-fsanitize=vla-bound", - "-fsanitize=bool", "-fsanitize-blacklist=$ubsan_blacklist_path", ]
diff --git a/build/fuchsia/linux.sdk.sha1 b/build/fuchsia/linux.sdk.sha1 index 2797cee..70de93e 100644 --- a/build/fuchsia/linux.sdk.sha1 +++ b/build/fuchsia/linux.sdk.sha1
@@ -1 +1 @@ -8897091697641008928 \ No newline at end of file +8897026043691226544 \ No newline at end of file
diff --git a/build/fuchsia/mac.sdk.sha1 b/build/fuchsia/mac.sdk.sha1 index 7717cab..aa6aac8 100644 --- a/build/fuchsia/mac.sdk.sha1 +++ b/build/fuchsia/mac.sdk.sha1
@@ -1 +1 @@ -8897090257456483296 \ No newline at end of file +8897031009896432096 \ No newline at end of file
diff --git a/cc/input/layer_selection_bound.cc b/cc/input/layer_selection_bound.cc index 55f2e3a..81af0bf 100644 --- a/cc/input/layer_selection_bound.cc +++ b/cc/input/layer_selection_bound.cc
@@ -15,7 +15,7 @@ bool LayerSelectionBound::operator==(const LayerSelectionBound& other) const { return type == other.type && layer_id == other.layer_id && - edge_top == other.edge_top && edge_bottom == other.edge_bottom && + edge_start == other.edge_start && edge_end == other.edge_end && hidden == other.hidden; } @@ -25,8 +25,8 @@ std::string LayerSelectionBound::ToString() const { return base::StringPrintf("LayerSelectionBound(%s, %s, %d)", - edge_top.ToString().c_str(), - edge_bottom.ToString().c_str(), hidden); + edge_start.ToString().c_str(), + edge_end.ToString().c_str(), hidden); } } // namespace cc
diff --git a/cc/input/layer_selection_bound.h b/cc/input/layer_selection_bound.h index a2a2583..43561075 100644 --- a/cc/input/layer_selection_bound.h +++ b/cc/input/layer_selection_bound.h
@@ -19,8 +19,8 @@ ~LayerSelectionBound(); gfx::SelectionBound::Type type; - gfx::Point edge_top; - gfx::Point edge_bottom; + gfx::Point edge_start; + gfx::Point edge_end; int layer_id; // Whether this bound is hidden (clipped out/occluded) within the painted // content of the layer (as opposed to being outside of the layer's bounds).
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc index f64c500..76407824 100644 --- a/cc/layers/layer.cc +++ b/cc/layers/layer.cc
@@ -977,6 +977,13 @@ property_trees.transform_tree.set_needs_update(true); } +void Layer::SetDidScrollCallback( + base::RepeatingCallback<void(const gfx::ScrollOffset&, const ElementId&)> + callback) { + DCHECK(!layer_tree_host_ || !layer_tree_host_->IsUsingLayerLists()); + inputs_.did_scroll_callback = std::move(callback); +} + void Layer::SetScrollable(const gfx::Size& bounds) { DCHECK(IsPropertyChangeAllowed()); if (inputs_.scrollable && inputs_.scroll_container_bounds == bounds) @@ -1366,13 +1373,7 @@ if (needs_show_scrollbars_) layer->set_needs_show_scrollbars(true); - // If the main thread commits multiple times before the impl thread actually - // draws, then damage tracking will become incorrect if we simply clobber the - // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. - // union) any update changes that have occurred on the main thread. - inputs_.update_rect.Union(layer->update_rect()); - layer->SetUpdateRect(inputs_.update_rect); - + layer->UnionUpdateRect(inputs_.update_rect); layer->SetHasWillChangeTransformHint(has_will_change_transform_hint()); layer->SetNeedsPushProperties(); @@ -1456,11 +1457,6 @@ SetNeedsPushProperties(); } -void Layer::SetScrollbarsHiddenFromImplSide(bool hidden) { - if (inputs_.client) - inputs_.client->DidChangeScrollbarsHiddenIfOverlay(hidden); -} - // On<Property>Animated is called due to an ongoing accelerated animation. // Since this animation is also being run on the compositor thread, there // is no need to request a commit to push this value over, so the value is
diff --git a/cc/layers/layer.h b/cc/layers/layer.h index 57458bed1..0d1c10b 100644 --- a/cc/layers/layer.h +++ b/cc/layers/layer.h
@@ -393,12 +393,10 @@ // asked to prepare content with Update(), if the scroll offset for the layer // was changed by the InputHandlerClient, on the compositor thread (or on the // main thread in single-thread mode). It may be set to a null callback, in - // which case nothing is called. - void set_did_scroll_callback( - base::RepeatingCallback<void(const gfx::ScrollOffset&, const ElementId&)> - callback) { - inputs_.did_scroll_callback = std::move(callback); - } + // which case nothing is called. This is for layer tree mode only. Should use + // ScrollTree::SetScrollCallbacks() in layer list mode. + void SetDidScrollCallback(base::RepeatingCallback< + void(const gfx::ScrollOffset&, const ElementId&)>); // Set or get if the layer and its subtree should be cached as a texture in // the display compositor. This is used as an optimization when it is known @@ -603,11 +601,6 @@ // was called before it. void SetNeedsPushProperties(); - // Internal method to call the LayerClient, if there is one, to inform it when - // overlay scrollbars have been completely hidden (due to lack of scrolling by - // the user). - void SetScrollbarsHiddenFromImplSide(bool hidden); - // Internal to property tree construction. A generation number for the // property trees, to verify the layer's indices are pointers into the trees // currently held by the LayerTreeHost. The number is updated when property @@ -872,6 +865,7 @@ base::WeakPtr<LayerClient> client; std::unique_ptr<base::trace_event::TracedValue> debug_info; + // These for for layer tree mode (ui compositor) only. base::RepeatingCallback<void(const gfx::ScrollOffset&, const ElementId&)> did_scroll_callback; std::vector<std::unique_ptr<viz::CopyOutputRequest>> copy_requests;
diff --git a/cc/layers/layer_client.h b/cc/layers/layer_client.h index 75aeff13..672caeb4 100644 --- a/cc/layers/layer_client.h +++ b/cc/layers/layer_client.h
@@ -34,8 +34,6 @@ virtual std::string LayerDebugName(const Layer* layer) const = 0; - virtual void DidChangeScrollbarsHiddenIfOverlay(bool) = 0; - protected: virtual ~LayerClient() {} };
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc index 6653d2cf..c95493b 100644 --- a/cc/layers/layer_impl.cc +++ b/cc/layers/layer_impl.cc
@@ -392,22 +392,14 @@ layer->set_is_scrollbar(is_scrollbar_); - // If the main thread commits multiple times before the impl thread actually - // draws, then damage tracking will become incorrect if we simply clobber the - // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. - // union) any update changes that have occurred on the main thread. - update_rect_.Union(layer->update_rect()); - layer->SetUpdateRect(update_rect_); + layer->UnionUpdateRect(update_rect_); if (owned_debug_info_) layer->SetDebugInfo(std::move(owned_debug_info_)); // Reset any state that should be cleared for the next update. needs_show_scrollbars_ = false; - layer_property_changed_not_from_property_trees_ = false; - layer_property_changed_from_property_trees_ = false; - needs_push_properties_ = false; - update_rect_ = gfx::Rect(); + ResetChangeTracking(); } bool LayerImpl::IsAffectedByPageScale() const { @@ -641,8 +633,8 @@ mirror_count_ = mirror_count; } -void LayerImpl::SetUpdateRect(const gfx::Rect& update_rect) { - update_rect_ = update_rect; +void LayerImpl::UnionUpdateRect(const gfx::Rect& update_rect) { + update_rect_.Union(update_rect); } gfx::Rect LayerImpl::GetDamageRect() const {
diff --git a/cc/layers/layer_impl.h b/cc/layers/layer_impl.h index b054f7f..7148191 100644 --- a/cc/layers/layer_impl.h +++ b/cc/layers/layer_impl.h
@@ -300,8 +300,11 @@ return wheel_event_handler_region_; } + // The main thread may commit multiple times before the impl thread actually + // draws, so we need to accumulate (i.e. union) any update changes that have + // occurred on the main thread until we draw. // Note this rect is in layer space (not content space). - void SetUpdateRect(const gfx::Rect& update_rect); + void UnionUpdateRect(const gfx::Rect& update_rect); const gfx::Rect& update_rect() const { return update_rect_; } // Denotes an area that is damaged and needs redraw. This is in the layer's
diff --git a/cc/layers/layer_impl_unittest.cc b/cc/layers/layer_impl_unittest.cc index 8de7247..3bc3298 100644 --- a/cc/layers/layer_impl_unittest.cc +++ b/cc/layers/layer_impl_unittest.cc
@@ -119,7 +119,7 @@ // These properties are internal, and should not be considered "change" when // they are used. EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE( - root->SetUpdateRect(arbitrary_rect)); + root->UnionUpdateRect(arbitrary_rect)); EXECUTE_AND_VERIFY_ONLY_LAYER_CHANGED(root->SetBounds(arbitrary_size)); UpdatePendingTreeDrawProperties();
diff --git a/cc/layers/picture_layer_impl.cc b/cc/layers/picture_layer_impl.cc index e88484b4..e4c8eb9 100644 --- a/cc/layers/picture_layer_impl.cc +++ b/cc/layers/picture_layer_impl.cc
@@ -758,7 +758,7 @@ gfx::Rect bounds_rect(bounds()); invalidation_ = Region(bounds_rect); tilings_->Invalidate(invalidation_); - SetUpdateRect(bounds_rect); + UnionUpdateRect(bounds_rect); return true; } @@ -1584,14 +1584,9 @@ if (invalidation.IsEmpty()) return ImageInvalidationResult::kNoInvalidation; - // Make sure to union the rect from this invalidation with the update_rect - // instead of over-writing it. We don't want to reset the update that came - // from the main thread. // Note: We can use a rect here since this is only used to track damage for a // frame and not raster invalidation. - gfx::Rect new_update_rect = invalidation.bounds(); - new_update_rect.Union(update_rect()); - SetUpdateRect(new_update_rect); + UnionUpdateRect(invalidation.bounds()); invalidation_.Union(invalidation); tilings_->Invalidate(invalidation);
diff --git a/cc/layers/video_layer_impl.cc b/cc/layers/video_layer_impl.cc index b76baeb..905a0a5a 100644 --- a/cc/layers/video_layer_impl.cc +++ b/cc/layers/video_layer_impl.cc
@@ -188,7 +188,7 @@ } void VideoLayerImpl::SetNeedsRedraw() { - SetUpdateRect(gfx::UnionRects(update_rect(), gfx::Rect(bounds()))); + UnionUpdateRect(gfx::Rect(bounds())); layer_tree_impl()->SetNeedsRedraw(); }
diff --git a/cc/trees/damage_tracker_unittest.cc b/cc/trees/damage_tracker_unittest.cc index d2636625..42d0fe8 100644 --- a/cc/trees/damage_tracker_unittest.cc +++ b/cc/trees/damage_tracker_unittest.cc
@@ -63,6 +63,7 @@ for (auto* layer : *root->layer_tree_impl()) { if (GetRenderSurface(layer)) GetRenderSurface(layer)->damage_tracker()->DidDrawDamagedArea(); + layer->ResetChangeTracking(); } } @@ -254,7 +255,7 @@ // CASE 1: Setting the update rect should cause the corresponding damage to // the surface. ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); + child->UnionUpdateRect(gfx::Rect(10, 11, 12, 13)); EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (10, 11) @@ -268,7 +269,7 @@ // CASE 2: The same update rect twice in a row still produces the same // damage. ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); + child->UnionUpdateRect(gfx::Rect(10, 11, 12, 13)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -278,7 +279,7 @@ // CASE 3: Setting a different update rect should cause damage on the new // update region, but no additional exposed old region. ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); + child->UnionUpdateRect(gfx::Rect(20, 25, 1, 2)); EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (20, 25) @@ -355,7 +356,7 @@ // corresponding damage to the surface. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(5, 6, 12, 13)); - child->SetUpdateRect(gfx::Rect(15, 16, 14, 10)); + child->UnionUpdateRect(gfx::Rect(15, 16, 14, 10)); EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of unified layer @@ -370,7 +371,7 @@ // produces the same damage. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(10, 11, 12, 13)); - child->SetUpdateRect(gfx::Rect(10, 11, 14, 15)); + child->UnionUpdateRect(gfx::Rect(10, 11, 14, 15)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect)); @@ -380,7 +381,7 @@ // damage on the new damaged region, but no additional exposed old region. ClearDamageForAllSurfaces(root); child->AddDamageRect(gfx::Rect(20, 25, 2, 3)); - child->SetUpdateRect(gfx::Rect(5, 10, 7, 8)); + child->UnionUpdateRect(gfx::Rect(5, 10, 7, 8)); EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of unified layer damage @@ -402,7 +403,7 @@ CreateEffectNode(child).render_surface_reason = RenderSurfaceReason::kTest; EmulateDrawingOneFrame(root); ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); + child->UnionUpdateRect(gfx::Rect(10, 11, 12, 13)); root->layer_tree_impl()->SetOpacityMutated(child->element_id(), 0.5f); EmulateDrawingOneFrame(root); @@ -560,7 +561,7 @@ child1_->SetDrawsContent(true); ClearDamageForAllSurfaces(root); child1_->AddDamageRect(gfx::Rect(105, 106, 12, 15)); - child1_->SetUpdateRect(gfx::Rect(115, 116, 12, 15)); + child1_->UnionUpdateRect(gfx::Rect(115, 116, 12, 15)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() @@ -573,7 +574,7 @@ // corresponding damage to the surface. ClearDamageForAllSurfaces(root); child2_->AddDamageRect(gfx::Rect(11, 11, 12, 15)); - child2_->SetUpdateRect(gfx::Rect(12, 12, 12, 15)); + child2_->UnionUpdateRect(gfx::Rect(12, 12, 12, 15)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() @@ -586,7 +587,7 @@ // the corresponding damage to the surface. ClearDamageForAllSurfaces(root); grand_child1_->AddDamageRect(gfx::Rect(1, 0, 2, 5)); - grand_child1_->SetUpdateRect(gfx::Rect(2, 1, 2, 5)); + grand_child1_->UnionUpdateRect(gfx::Rect(2, 1, 2, 5)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root) ->damage_tracker() @@ -762,7 +763,7 @@ // Setting the update rect should cause the corresponding damage to the // surface, blurred based on the size of the blur filter. ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); + child->UnionUpdateRect(gfx::Rect(1, 2, 3, 4)); EmulateDrawingOneFrame(root); // Damage position on the surface should be: position of update_rect (1, 2) @@ -822,7 +823,7 @@ // CASE 1: Setting the update rect should damage the whole surface (for now) ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(1, 1)); + child->UnionUpdateRect(gfx::Rect(1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -911,7 +912,7 @@ // Setting the update rect should damage the whole surface (for now) ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(30, 30)); + child->UnionUpdateRect(gfx::Rect(30, 30)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -970,7 +971,7 @@ // Setting the update rect should damage only the affected area (original, // outset by 3 * blur sigma * DSF). ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(30, 30)); + child->UnionUpdateRect(gfx::Rect(30, 30)); EmulateDrawingOneFrame(root, device_scale_factor); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1002,7 +1003,7 @@ // blur filter. Note that child1_'s render surface has a size of // 206x208 due to contributions from grand_child1_ and grand_child2_. ClearDamageForAllSurfaces(root); - root->SetUpdateRect(gfx::Rect(297, 297, 2, 2)); + root->UnionUpdateRect(gfx::Rect(297, 297, 2, 2)); EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; @@ -1022,7 +1023,7 @@ // blur filter. Since the damage extends to the right/bottom outside // of the blurred layer, only the left/top should end up expanded. ClearDamageForAllSurfaces(root); - root->SetUpdateRect(gfx::Rect(297, 297, 30, 30)); + root->UnionUpdateRect(gfx::Rect(297, 297, 30, 30)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1039,7 +1040,7 @@ // CASE 3: Setting this update rect outside the blurred content_bounds of the // blurred child1_ will not cause it to be expanded. ClearDamageForAllSurfaces(root); - root->SetUpdateRect(gfx::Rect(30, 30, 2, 2)); + root->UnionUpdateRect(gfx::Rect(30, 30, 2, 2)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1054,7 +1055,7 @@ // outside the original content_bounds of the blurred child1_ will // cause it to be expanded. ClearDamageForAllSurfaces(root); - root->SetUpdateRect(gfx::Rect(99, 99, 1, 1)); + root->UnionUpdateRect(gfx::Rect(99, 99, 1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1070,7 +1071,7 @@ // CASE 5: Setting the update rect on child2_, which is above child1_, will // not get blurred by child1_, so it does not need to get expanded. ClearDamageForAllSurfaces(root); - child2_->SetUpdateRect(gfx::Rect(1, 1)); + child2_->UnionUpdateRect(gfx::Rect(1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1085,7 +1086,7 @@ // that any pixels needed for the blur are redrawn in the current // frame. ClearDamageForAllSurfaces(root); - child1_->SetUpdateRect(gfx::Rect(1, 1)); + child1_->UnionUpdateRect(gfx::Rect(1, 1)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1235,8 +1236,8 @@ // - child1_ update rect in surface space: gfx::Rect(100, 100, 1, 2); // - child2_ update rect in surface space: gfx::Rect(400, 380, 3, 4); ClearDamageForAllSurfaces(root); - child1->SetUpdateRect(gfx::Rect(1, 2)); - child2->SetUpdateRect(gfx::Rect(3, 4)); + child1->UnionUpdateRect(gfx::Rect(1, 2)); + child2->UnionUpdateRect(gfx::Rect(3, 4)); EmulateDrawingOneFrame(root); gfx::Rect root_damage_rect; EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( @@ -1536,7 +1537,7 @@ // In our specific tree, the update rect of child1_ should not cause any // damage to any surface because it does not actually draw content. ClearDamageForAllSurfaces(root); - child1_->SetUpdateRect(gfx::Rect(1, 2)); + child1_->UnionUpdateRect(gfx::Rect(1, 2)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(child1_)->damage_tracker()->GetDamageRectIfValid( &child_damage_rect)); @@ -1589,7 +1590,7 @@ // CASE 1: the update_rect on a mask layer should damage the rect. ClearDamageForAllSurfaces(root); - mask_layer->SetUpdateRect(gfx::Rect(1, 2, 3, 4)); + mask_layer->UnionUpdateRect(gfx::Rect(1, 2, 3, 4)); EmulateDrawingOneFrame(root); gfx::Rect child_damage_rect; EXPECT_TRUE(GetRenderSurface(child)->damage_tracker()->GetDamageRectIfValid( @@ -1676,7 +1677,7 @@ // it is included with any other partial damage. // ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(10, 11, 12, 13)); + child->UnionUpdateRect(gfx::Rect(10, 11, 12, 13)); GetRenderSurface(root)->damage_tracker()->AddDamageNextUpdate( gfx::Rect(15, 16, 32, 33)); EmulateDrawingOneFrame(root); @@ -1732,7 +1733,7 @@ LayerImpl* child = child_layers_[0]; ClearDamageForAllSurfaces(root); - child->SetUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); + child->UnionUpdateRect(gfx::Rect(10.f, 11.f, 1.f, 2.f)); EmulateDrawingOneFrame(root); // Sanity check damage after the first frame; this isnt the actual test yet. @@ -1746,7 +1747,7 @@ // New damage, without having cleared the previous damage, should be unioned // to the previous one. - child->SetUpdateRect(gfx::Rect(20, 25, 1, 2)); + child->UnionUpdateRect(gfx::Rect(20, 25, 1, 2)); EmulateDrawingOneFrame(root); EXPECT_TRUE(GetRenderSurface(root)->damage_tracker()->GetDamageRectIfValid( &root_damage_rect));
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc index 0eca5ea7..e278548 100644 --- a/cc/trees/layer_tree_host.cc +++ b/cc/trees/layer_tree_host.cc
@@ -882,6 +882,13 @@ inner_scroll_layer->CurrentScrollOffset() + inner_viewport_scroll_delta); } + if (IsUsingLayerLists()) { + auto& scroll_tree = property_trees()->scroll_tree; + scroll_tree.NotifyDidScroll( + inner_scroll->element_id, + scroll_tree.current_scroll_offset(inner_scroll->element_id) + + inner_viewport_scroll_delta); + } } ApplyPageScaleDeltaFromImplSide(info.page_scale_delta); @@ -926,19 +933,23 @@ } if (root_layer_) { - for (size_t i = 0; i < info->scrolls.size(); ++i) { - Layer* layer = LayerByElementId(info->scrolls[i].element_id); - if (!layer) - continue; - layer->SetScrollOffsetFromImplSide(layer->CurrentScrollOffset() + - info->scrolls[i].scroll_delta); - SetNeedsUpdateLayers(); + auto& scroll_tree = property_trees()->scroll_tree; + for (auto& scroll : info->scrolls) { + if (Layer* layer = LayerByElementId(scroll.element_id)) { + layer->SetScrollOffsetFromImplSide(layer->CurrentScrollOffset() + + scroll.scroll_delta); + SetNeedsUpdateLayers(); + } + if (IsUsingLayerLists()) { + scroll_tree.NotifyDidScroll( + scroll.element_id, + scroll_tree.current_scroll_offset(scroll.element_id) + + scroll.scroll_delta); + } } - for (size_t i = 0; i < info->scrollbars.size(); ++i) { - Layer* layer = LayerByElementId(info->scrollbars[i].element_id); - if (!layer) - continue; - layer->SetScrollbarsHiddenFromImplSide(info->scrollbars[i].hidden); + for (auto& scrollbar : info->scrollbars) { + scroll_tree.NotifyDidChangeScrollbarsHidden(scrollbar.element_id, + scrollbar.hidden); } }
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc index fb8bf14f..57f5ac4 100644 --- a/cc/trees/layer_tree_host_impl_unittest.cc +++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -8158,14 +8158,14 @@ // Opaque layer, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); // Layer with translucent content and painting, so drawn with blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8173,7 +8173,7 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 0.5f); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8181,7 +8181,7 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 0.5f); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8195,11 +8195,11 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 1.f); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); SetOpacity(layer2, 1.f); layer2->SetExpectation(false, false, root); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8208,9 +8208,9 @@ // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(false); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false, root); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8220,9 +8220,9 @@ // Child layer with opaque content, drawn without blending. layer1->SetContentsOpaque(true); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false, root); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8236,9 +8236,9 @@ SetOpacity(layer1, 0.5f); GetEffectNode(layer1)->render_surface_reason = RenderSurfaceReason::kTest; layer1->SetExpectation(false, true, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetExpectation(false, false, layer1); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8249,11 +8249,11 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 1.f); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); SetOpacity(layer2, 0.5f); layer2->SetExpectation(true, false, layer1); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8262,11 +8262,11 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 1.f); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(false); SetOpacity(layer2, 1.f); layer2->SetExpectation(true, false, root); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8276,11 +8276,11 @@ layer1->SetContentsOpaque(true); SetOpacity(layer1, 1.f); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); layer2->SetContentsOpaque(true); SetOpacity(layer2, 1.f); layer2->SetExpectation(false, false, root); - layer2->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer2->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); EXPECT_TRUE(layer2->quads_appended()); @@ -8291,7 +8291,7 @@ layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8301,7 +8301,7 @@ layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 5, 2)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8311,7 +8311,7 @@ layer1->SetQuadVisibleRect(gfx::Rect(7, 5, 3, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(true, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); @@ -8322,7 +8322,7 @@ layer1->SetQuadVisibleRect(gfx::Rect(5, 5, 2, 5)); layer1->SetOpaqueContentRect(gfx::Rect(5, 5, 2, 5)); layer1->SetExpectation(false, false, root); - layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); + layer1->UnionUpdateRect(gfx::Rect(layer1->bounds())); DrawFrame(); EXPECT_TRUE(layer1->quads_appended()); } @@ -8943,7 +8943,7 @@ // The second frame has damage that doesn't touch the child layer. Its quads // should still be generated. gfx::Rect small_damage = gfx::Rect(0, 0, 1, 1); - root->SetUpdateRect(small_damage); + root->UnionUpdateRect(small_damage); DrawFrameAndTestDamage(small_damage, child); // The third frame should have no damage, so no quads should be generated. @@ -9583,13 +9583,13 @@ UpdateDrawProperties(host_impl_->active_tree()); // Plumb the layer-local selection bounds. - gfx::Point selection_top(5, 0); - gfx::Point selection_bottom(5, 5); + gfx::Point selection_start(5, 0); + gfx::Point selection_end(5, 5); LayerSelection selection; selection.start.type = gfx::SelectionBound::CENTER; selection.start.layer_id = root->id(); - selection.start.edge_bottom = selection_bottom; - selection.start.edge_top = selection_top; + selection.start.edge_end = selection_end; + selection.start.edge_start = selection_start; selection.end = selection.start; host_impl_->active_tree()->RegisterSelection(selection); @@ -9601,8 +9601,8 @@ metadata.selection; EXPECT_EQ(selection.start.type, selection_after.start.type()); EXPECT_EQ(selection.end.type, selection_after.end.type()); - EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); + EXPECT_EQ(gfx::PointF(selection_end), selection_after.start.edge_end()); + EXPECT_EQ(gfx::PointF(selection_start), selection_after.start.edge_start()); EXPECT_TRUE(selection_after.start.visible()); EXPECT_TRUE(selection_after.end.visible()); } @@ -9613,8 +9613,8 @@ UpdateDrawProperties(host_impl_->active_tree()); // Plumb the layer-local selection bounds. - gfx::Point selection_top(5, 0); - gfx::Point selection_bottom(5, 5); + gfx::Point selection_start(5, 0); + gfx::Point selection_end(5, 5); LayerSelection selection; // Mark the start as hidden. @@ -9622,8 +9622,8 @@ selection.start.type = gfx::SelectionBound::CENTER; selection.start.layer_id = root->id(); - selection.start.edge_bottom = selection_bottom; - selection.start.edge_top = selection_top; + selection.start.edge_end = selection_end; + selection.start.edge_start = selection_start; selection.end = selection.start; host_impl_->active_tree()->RegisterSelection(selection); @@ -9635,8 +9635,8 @@ metadata.selection; EXPECT_EQ(selection.start.type, selection_after.start.type()); EXPECT_EQ(selection.end.type, selection_after.end.type()); - EXPECT_EQ(gfx::PointF(selection_bottom), selection_after.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(selection_top), selection_after.start.edge_top()); + EXPECT_EQ(gfx::PointF(selection_end), selection_after.start.edge_end()); + EXPECT_EQ(gfx::PointF(selection_start), selection_after.start.edge_start()); EXPECT_FALSE(selection_after.start.visible()); EXPECT_FALSE(selection_after.end.visible()); } @@ -12814,19 +12814,19 @@ observer_ptr->last_metadata()->selection; EXPECT_EQ(gfx::SelectionBound::EMPTY, selection_1.start.type()); EXPECT_EQ(gfx::SelectionBound::EMPTY, selection_1.end.type()); - EXPECT_EQ(gfx::PointF(), selection_1.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(), selection_1.start.edge_top()); + EXPECT_EQ(gfx::PointF(), selection_1.start.edge_end()); + EXPECT_EQ(gfx::PointF(), selection_1.start.edge_start()); EXPECT_FALSE(selection_1.start.visible()); EXPECT_FALSE(selection_1.end.visible()); // Plumb the layer-local selection bounds. - gfx::Point selection_top(5, 0); - gfx::Point selection_bottom(5, 5); + gfx::Point selection_start(5, 0); + gfx::Point selection_end(5, 5); LayerSelection selection; selection.start.type = gfx::SelectionBound::CENTER; selection.start.layer_id = root->id(); - selection.start.edge_bottom = selection_bottom; - selection.start.edge_top = selection_top; + selection.start.edge_end = selection_end; + selection.start.edge_start = selection_start; selection.end = selection.start; host_impl_->active_tree()->RegisterSelection(selection); @@ -12840,8 +12840,8 @@ observer_ptr->last_metadata()->selection; EXPECT_EQ(selection.start.type, selection_2.start.type()); EXPECT_EQ(selection.end.type, selection_2.end.type()); - EXPECT_EQ(gfx::PointF(selection_bottom), selection_2.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(selection_top), selection_2.start.edge_top()); + EXPECT_EQ(gfx::PointF(selection_end), selection_2.start.edge_end()); + EXPECT_EQ(gfx::PointF(selection_start), selection_2.start.edge_start()); EXPECT_TRUE(selection_2.start.visible()); EXPECT_TRUE(selection_2.end.visible()); }
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc index 6f6915e..b9e7aa3 100644 --- a/cc/trees/layer_tree_host_unittest_scroll.cc +++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -72,7 +72,7 @@ return &layer_impl->layer_tree_impl()->property_trees()->scroll_tree; } -class LayerTreeHostScrollTest : public LayerTreeTest { +class LayerTreeHostScrollTest : public LayerTreeTest, public ScrollCallbacks { protected: LayerTreeHostScrollTest() { SetUseLayerLists(); } @@ -85,29 +85,37 @@ root_layer->bounds().height() + 100); SetupViewport(root_layer, root_layer->bounds(), scroll_layer_bounds); - layer_tree_host() - ->OuterViewportScrollLayerForTesting() - ->set_did_scroll_callback(base::BindRepeating( - &LayerTreeHostScrollTest::DidScrollOuterViewport, - base::Unretained(this))); + layer_tree_host()->property_trees()->scroll_tree.SetScrollCallbacks( + weak_ptr_factory_.GetWeakPtr()); } - // This is set as did_scroll_callback of scroll layers to automatically - // synchronize scroll delta from impl-side, which simulates cc client (e.g. - // Blink) behavior when handling impl-side scrolls. - void SyncScrollFromImpl(const gfx::ScrollOffset& scroll_offset, - const ElementId& element_id) { + // This is called from DidScroll() to synchronize scroll delta from impl-side, + // which simulates cc client (e.g Blink) behavior when handling impl-side + // scrolls. + void SyncScrollFromImpl(ElementId element_id, + const gfx::ScrollOffset& scroll_offset) { SetScrollOffset(layer_tree_host()->LayerByElementId(element_id), scroll_offset); } - virtual void DidScrollOuterViewport(const gfx::ScrollOffset& scroll_offset, - const ElementId& element_id) { - SyncScrollFromImpl(scroll_offset, element_id); + // ScrollCallbacks + void DidScroll(ElementId element_id, + const gfx::ScrollOffset& scroll_offset) override { + SyncScrollFromImpl(element_id, scroll_offset); + if (element_id == + layer_tree_host()->OuterViewportScrollLayerForTesting()->element_id()) + DidScrollOuterViewport(scroll_offset); + } + void DidChangeScrollbarsHidden(ElementId, bool) override {} + + virtual void DidScrollOuterViewport(const gfx::ScrollOffset& scroll_offset) { num_outer_viewport_scrolls_++; } int num_outer_viewport_scrolls_ = 0; + + private: + base::WeakPtrFactory<LayerTreeHostScrollTest> weak_ptr_factory_{this}; }; class LayerTreeHostScrollTestScrollSimple : public LayerTreeHostScrollTest { @@ -523,10 +531,6 @@ CreateScrollNode(scroll_layer_.get()); layer_tree_host()->root_layer()->AddChild(scroll_layer_); - scroll_layer_->set_did_scroll_callback(base::BindRepeating( - &LayerTreeHostScrollTestScrollSnapping::SyncScrollFromImpl, - base::Unretained(this))); - layer_tree_host()->SetPageScaleFactorAndLimits(1.f, 0.1f, 100.f); } @@ -585,9 +589,6 @@ layer_tree_host()->OuterViewportScrollLayerForTesting(); child_layer_ = Layer::Create(); - child_layer_->set_did_scroll_callback( - base::BindRepeating(&LayerTreeHostScrollTestCaseWithChild::DidScroll, - base::Unretained(this))); child_layer_->SetElementId( LayerIdToElementIdForTesting(child_layer_->id())); child_layer_->SetBounds(gfx::Size(110, 110)); @@ -637,11 +638,16 @@ } } - void DidScroll(const gfx::ScrollOffset& offset, const ElementId& element_id) { - SyncScrollFromImpl(offset, element_id); - final_scroll_offset_ = expected_scroll_layer_->CurrentScrollOffset(); - EXPECT_VECTOR_EQ(offset, final_scroll_offset_); - EXPECT_EQ(element_id, expected_scroll_layer_->element_id()); + void DidScroll(ElementId element_id, + const gfx::ScrollOffset& offset) override { + LayerTreeHostScrollTest::DidScroll(element_id, offset); + if (element_id == expected_scroll_layer_->element_id()) { + final_scroll_offset_ = expected_scroll_layer_->CurrentScrollOffset(); + EXPECT_EQ(offset, final_scroll_offset_); + EXPECT_EQ(element_id, expected_scroll_layer_->element_id()); + } else { + EXPECT_TRUE(offset.IsZero()); + } } void UpdateLayerTreeHost() override { @@ -757,15 +763,10 @@ } void AfterTest() override { - if (scroll_child_layer_) { - EXPECT_EQ(0, num_outer_viewport_scrolls_); - EXPECT_VECTOR_EQ(gfx::ScrollOffsetWithDelta(javascript_scroll_, - scroll_amount_), - final_scroll_offset_); - } else { - EXPECT_EQ(2, num_outer_viewport_scrolls_); - EXPECT_VECTOR_EQ(gfx::ScrollOffset(), final_scroll_offset_); - } + EXPECT_EQ(scroll_child_layer_ ? 0 : 2, num_outer_viewport_scrolls_); + EXPECT_VECTOR_EQ( + gfx::ScrollOffsetWithDelta(javascript_scroll_, scroll_amount_), + final_scroll_offset_); } protected: @@ -1344,12 +1345,9 @@ Layer* outer_scroll_layer = layer_tree_host()->OuterViewportScrollLayerForTesting(); - Layer* root_scroll_layer = - CreateScrollLayer(outer_scroll_layer, &root_scroll_layer_client_); - Layer* sibling_scroll_layer = - CreateScrollLayer(outer_scroll_layer, &sibling_scroll_layer_client_); - Layer* child_scroll_layer = - CreateScrollLayer(root_scroll_layer, &child_scroll_layer_client_); + Layer* root_scroll_layer = CreateScrollLayer(outer_scroll_layer); + Layer* sibling_scroll_layer = CreateScrollLayer(outer_scroll_layer); + Layer* child_scroll_layer = CreateScrollLayer(root_scroll_layer); root_scroll_layer_id_ = root_scroll_layer->id(); sibling_scroll_layer_id_ = sibling_scroll_layer->id(); child_scroll_layer_id_ = child_scroll_layer->id(); @@ -1378,7 +1376,7 @@ } } - virtual void DidScroll(Layer* layer) { + void DidScroll(ElementId element_id, const gfx::ScrollOffset&) override { if (scroll_destroy_whole_tree_) { layer_tree_host()->SetRootLayer(nullptr); layer_tree_host()->property_trees()->clear(); @@ -1387,20 +1385,11 @@ EndTest(); return; } - layer->RemoveFromParent(); + layer_tree_host()->LayerByElementId(element_id)->RemoveFromParent(); } protected: - class FakeLayerScrollClient { - public: - void DidScroll(const gfx::ScrollOffset&, const ElementId&) { - owner_->DidScroll(layer_); - } - LayerTreeHostScrollTestLayerStructureChange* owner_; - Layer* layer_; - }; - - Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) { + Layer* CreateScrollLayer(Layer* parent) { scoped_refptr<PictureLayer> scroll_layer = PictureLayer::Create(&fake_content_layer_client_); scroll_layer->SetIsDrawable(true); @@ -1410,10 +1399,6 @@ LayerIdToElementIdForTesting(scroll_layer->id())); scroll_layer->SetBounds(gfx::Size(parent->bounds().width() + 100, parent->bounds().height() + 100)); - scroll_layer->set_did_scroll_callback(base::BindRepeating( - &FakeLayerScrollClient::DidScroll, base::Unretained(client))); - client->owner_ = this; - client->layer_ = scroll_layer.get(); CopyProperties(parent, scroll_layer.get()); CreateTransformNode(scroll_layer.get()); @@ -1433,9 +1418,6 @@ layer_impl->element_id()); } - FakeLayerScrollClient root_scroll_layer_client_; - FakeLayerScrollClient sibling_scroll_layer_client_; - FakeLayerScrollClient child_scroll_layer_client_; int root_scroll_layer_id_; int sibling_scroll_layer_id_; int child_scroll_layer_id_; @@ -2034,9 +2016,8 @@ PostSetNeedsCommitToMainThread(); } - void DidScrollOuterViewport(const gfx::ScrollOffset& offset, - const ElementId& element_id) override { - LayerTreeHostScrollTest::DidScrollOuterViewport(offset, element_id); + void DidScrollOuterViewport(const gfx::ScrollOffset& offset) override { + LayerTreeHostScrollTest::DidScrollOuterViewport(offset); // Defer responding to the main frame until an impl-side pending tree is // created for the invalidation request.
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc index 4959be6..eb36121 100644 --- a/cc/trees/layer_tree_impl.cc +++ b/cc/trees/layer_tree_impl.cc
@@ -2293,27 +2293,27 @@ if (!layer || layer_bound.type == gfx::SelectionBound::EMPTY) return viewport_bound; - auto layer_top = gfx::PointF(layer_bound.edge_top); - auto layer_bottom = gfx::PointF(layer_bound.edge_bottom); + auto layer_start = gfx::PointF(layer_bound.edge_start); + auto layer_end = gfx::PointF(layer_bound.edge_end); gfx::Transform screen_space_transform = layer->ScreenSpaceTransform(); bool clipped = false; - gfx::PointF screen_top = - MathUtil::MapPoint(screen_space_transform, layer_top, &clipped); - gfx::PointF screen_bottom = - MathUtil::MapPoint(screen_space_transform, layer_bottom, &clipped); + gfx::PointF screen_start = + MathUtil::MapPoint(screen_space_transform, layer_start, &clipped); + gfx::PointF screen_end = + MathUtil::MapPoint(screen_space_transform, layer_end, &clipped); // MapPoint can produce points with NaN components (even when no inputs are - // NaN). Since consumers of gfx::SelectionBounds may round |edge_top| or - // |edge_bottom| (and since rounding will crash on NaN), we return an empty + // NaN). Since consumers of gfx::SelectionBounds may round |edge_start| or + // |edge_end| (and since rounding will crash on NaN), we return an empty // bound instead. - if (std::isnan(screen_top.x()) || std::isnan(screen_top.y()) || - std::isnan(screen_bottom.x()) || std::isnan(screen_bottom.y())) + if (std::isnan(screen_start.x()) || std::isnan(screen_start.y()) || + std::isnan(screen_end.x()) || std::isnan(screen_end.y())) return gfx::SelectionBound(); const float inv_scale = 1.f / device_scale_factor; - viewport_bound.SetEdgeTop(gfx::ScalePoint(screen_top, inv_scale)); - viewport_bound.SetEdgeBottom(gfx::ScalePoint(screen_bottom, inv_scale)); + viewport_bound.SetEdgeStart(gfx::ScalePoint(screen_start, inv_scale)); + viewport_bound.SetEdgeEnd(gfx::ScalePoint(screen_end, inv_scale)); // If |layer_bound| is already hidden due to being occluded by painted content // within the layer, it must remain hidden. Otherwise, check whether its @@ -2326,9 +2326,9 @@ // Shifting the visibility point fractionally inward ensures that // neighboring or logically coincident layers aligned to integral DPI // coordinates will not spuriously occlude the bound. - gfx::Vector2dF visibility_offset = layer_top - layer_bottom; + gfx::Vector2dF visibility_offset = layer_start - layer_end; visibility_offset.Scale(device_scale_factor / visibility_offset.Length()); - gfx::PointF visibility_point = layer_bottom + visibility_offset; + gfx::PointF visibility_point = layer_end + visibility_offset; if (visibility_point.x() <= 0) visibility_point.set_x(visibility_point.x() + device_scale_factor); visibility_point = @@ -2340,27 +2340,27 @@ } if (viewport_bound.visible()) { - viewport_bound.SetVisibleEdge(viewport_bound.edge_top(), - viewport_bound.edge_bottom()); + viewport_bound.SetVisibleEdge(viewport_bound.edge_start(), + viewport_bound.edge_end()); } else { - // The |layer_top| and |layer_bottom| might be clipped. + // The |layer_start| and |layer_end| might be clipped. gfx::RectF visible_layer_rect(layer->visible_layer_rect()); - auto visible_layer_start = layer_top; - auto visible_layer_end = layer_bottom; + auto visible_layer_start = layer_start; + auto visible_layer_end = layer_end; if (!visible_layer_rect.Contains(visible_layer_start) && !visible_layer_rect.Contains(visible_layer_end)) std::tie(visible_layer_start, visible_layer_end) = - GetVisibleSelectionEndPoints(visible_layer_rect, layer_top, - layer_bottom); + GetVisibleSelectionEndPoints(visible_layer_rect, layer_start, + layer_end); gfx::PointF visible_screen_start = MathUtil::MapPoint( screen_space_transform, visible_layer_start, &clipped); gfx::PointF visible_screen_end = MathUtil::MapPoint(screen_space_transform, visible_layer_end, &clipped); - viewport_bound.SetVisibleEdgeTop( + viewport_bound.SetVisibleEdgeStart( gfx::ScalePoint(visible_screen_start, inv_scale)); - viewport_bound.SetVisibleEdgeBottom( + viewport_bound.SetVisibleEdgeEnd( gfx::ScalePoint(visible_screen_end, inv_scale)); }
diff --git a/cc/trees/layer_tree_impl_unittest.cc b/cc/trees/layer_tree_impl_unittest.cc index de50089ce..dcce0e46 100644 --- a/cc/trees/layer_tree_impl_unittest.cc +++ b/cc/trees/layer_tree_impl_unittest.cc
@@ -1763,13 +1763,13 @@ LayerSelection input; input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(10, 10); - input.start.edge_bottom = gfx::Point(10, 20); + input.start.edge_start = gfx::Point(10, 10); + input.start.edge_end = gfx::Point(10, 20); input.start.layer_id = root->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(50, 10); - input.end.edge_bottom = gfx::Point(50, 30); + input.end.edge_start = gfx::Point(50, 10); + input.end.edge_end = gfx::Point(50, 30); input.end.layer_id = root->id(); viz::Selection<gfx::SelectionBound> output; @@ -1783,67 +1783,65 @@ host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - EXPECT_EQ(gfx::PointF(input.start.edge_bottom), output.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(input.start.edge_top), output.start.edge_top()); - EXPECT_EQ(gfx::PointF(input.start.edge_bottom), - output.start.visible_edge_bottom()); - EXPECT_EQ(gfx::PointF(input.start.edge_top), output.start.visible_edge_top()); + EXPECT_EQ(gfx::PointF(input.start.edge_end), output.start.edge_end()); + EXPECT_EQ(gfx::PointF(input.start.edge_start), output.start.edge_start()); + EXPECT_EQ(gfx::PointF(input.start.edge_end), output.start.visible_edge_end()); + EXPECT_EQ(gfx::PointF(input.start.edge_start), + output.start.visible_edge_start()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - EXPECT_EQ(gfx::PointF(input.end.edge_bottom), output.end.edge_bottom()); - EXPECT_EQ(gfx::PointF(input.end.edge_top), output.end.edge_top()); - EXPECT_EQ(gfx::PointF(input.end.edge_bottom), - output.end.visible_edge_bottom()); - EXPECT_EQ(gfx::PointF(input.end.edge_top), output.end.visible_edge_top()); + EXPECT_EQ(gfx::PointF(input.end.edge_end), output.end.edge_end()); + EXPECT_EQ(gfx::PointF(input.end.edge_start), output.end.edge_start()); + EXPECT_EQ(gfx::PointF(input.end.edge_end), output.end.visible_edge_end()); + EXPECT_EQ(gfx::PointF(input.end.edge_start), output.end.visible_edge_start()); EXPECT_TRUE(output.end.visible()); // Selection bounds should produce distinct left and right bounds for the // vertical text. input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(20, 10); - input.start.edge_bottom = gfx::Point(10, 10); + input.start.edge_start = gfx::Point(20, 10); + input.start.edge_end = gfx::Point(10, 10); input.start.layer_id = root->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(30, 20); - input.end.edge_bottom = gfx::Point(50, 20); + input.end.edge_start = gfx::Point(30, 20); + input.end.edge_end = gfx::Point(50, 20); input.end.layer_id = root->id(); host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - EXPECT_EQ(gfx::PointF(input.start.edge_bottom), output.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(input.start.edge_top), output.start.edge_top()); - EXPECT_EQ(gfx::PointF(input.start.edge_bottom), - output.start.visible_edge_bottom()); - EXPECT_EQ(gfx::PointF(input.start.edge_top), output.start.visible_edge_top()); + EXPECT_EQ(gfx::PointF(input.start.edge_end), output.start.edge_end()); + EXPECT_EQ(gfx::PointF(input.start.edge_start), output.start.edge_start()); + EXPECT_EQ(gfx::PointF(input.start.edge_end), output.start.visible_edge_end()); + EXPECT_EQ(gfx::PointF(input.start.edge_start), + output.start.visible_edge_start()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - EXPECT_EQ(gfx::PointF(input.end.edge_bottom), output.end.edge_bottom()); - EXPECT_EQ(gfx::PointF(input.end.edge_top), output.end.edge_top()); - EXPECT_EQ(gfx::PointF(input.end.edge_bottom), - output.end.visible_edge_bottom()); - EXPECT_EQ(gfx::PointF(input.end.edge_top), output.end.visible_edge_top()); + EXPECT_EQ(gfx::PointF(input.end.edge_end), output.end.edge_end()); + EXPECT_EQ(gfx::PointF(input.end.edge_start), output.end.edge_start()); + EXPECT_EQ(gfx::PointF(input.end.edge_end), output.end.visible_edge_end()); + EXPECT_EQ(gfx::PointF(input.end.edge_start), output.end.visible_edge_start()); EXPECT_TRUE(output.end.visible()); // Insertion bounds should produce identical left and right bounds. LayerSelection insertion_input; insertion_input.start.type = gfx::SelectionBound::CENTER; - insertion_input.start.edge_top = gfx::Point(15, 10); - insertion_input.start.edge_bottom = gfx::Point(15, 30); + insertion_input.start.edge_start = gfx::Point(15, 10); + insertion_input.start.edge_end = gfx::Point(15, 30); insertion_input.start.layer_id = root->id(); insertion_input.end = insertion_input.start; host_impl().active_tree()->RegisterSelection(insertion_input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(insertion_input.start.type, output.start.type()); - EXPECT_EQ(gfx::PointF(insertion_input.start.edge_bottom), - output.start.edge_bottom()); - EXPECT_EQ(gfx::PointF(insertion_input.start.edge_top), - output.start.edge_top()); - EXPECT_EQ(gfx::PointF(insertion_input.start.edge_bottom), - output.start.visible_edge_bottom()); - EXPECT_EQ(gfx::PointF(insertion_input.start.edge_top), - output.start.visible_edge_top()); + EXPECT_EQ(gfx::PointF(insertion_input.start.edge_end), + output.start.edge_end()); + EXPECT_EQ(gfx::PointF(insertion_input.start.edge_start), + output.start.edge_start()); + EXPECT_EQ(gfx::PointF(insertion_input.start.edge_end), + output.start.visible_edge_end()); + EXPECT_EQ(gfx::PointF(insertion_input.start.edge_start), + output.start.visible_edge_start()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(output.start, output.end); } @@ -1878,13 +1876,13 @@ LayerSelection input; input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(25, 10); - input.start.edge_bottom = gfx::Point(25, 30); + input.start.edge_start = gfx::Point(25, 10); + input.start.edge_end = gfx::Point(25, 30); input.start.layer_id = clipped_layer->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(75, 10); - input.end.edge_bottom = gfx::Point(75, 30); + input.end.edge_start = gfx::Point(75, 10); + input.end.edge_end = gfx::Point(75, 30); input.end.layer_id = clipped_layer->id(); host_impl().active_tree()->RegisterSelection(input); @@ -1892,103 +1890,103 @@ viz::Selection<gfx::SelectionBound> output; host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - auto expected_output_start_top = gfx::PointF(input.start.edge_top); - auto expected_output_start_bottom = gfx::PointF(input.start.edge_bottom); - expected_output_start_top.Offset(clipping_offset.x(), clipping_offset.y()); - expected_output_start_bottom.Offset(clipping_offset.x(), clipping_offset.y()); - EXPECT_EQ(expected_output_start_top, output.start.edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.edge_bottom()); - EXPECT_EQ(expected_output_start_top, output.start.visible_edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.visible_edge_bottom()); + auto expected_output_edge_start = gfx::PointF(input.start.edge_start); + auto expected_output_edge_end = gfx::PointF(input.start.edge_end); + expected_output_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_edge_end.Offset(clipping_offset.x(), clipping_offset.y()); + EXPECT_EQ(expected_output_edge_start, output.start.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.start.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.visible_edge_end()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - auto expected_output_end_top = gfx::PointF(input.end.edge_top); - auto expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); - expected_output_end_bottom.Offset(clipping_offset.x(), clipping_offset.y()); - expected_output_end_top.Offset(clipping_offset.x(), clipping_offset.y()); - EXPECT_EQ(expected_output_end_top, output.end.edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom()); + expected_output_edge_start = gfx::PointF(input.end.edge_start); + expected_output_edge_end = gfx::PointF(input.end.edge_end); + expected_output_edge_end.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + EXPECT_EQ(expected_output_edge_start, output.end.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.edge_end()); gfx::RectF visible_layer_rect(clipped_layer->visible_layer_rect()); - gfx::PointF expected_output_end_visible_top; - gfx::PointF expected_output_end_visible_bottom; - std::tie(expected_output_end_visible_top, - expected_output_end_visible_bottom) = + gfx::PointF expected_output_visible_edge_start; + gfx::PointF expected_output_visible_edge_end; + std::tie(expected_output_visible_edge_start, + expected_output_visible_edge_end) = GetVisibleSelectionEndPoints(visible_layer_rect, - gfx::PointF(input.end.edge_top), - gfx::PointF(input.end.edge_bottom)); - expected_output_end_visible_top.Offset(clipping_offset.x(), - clipping_offset.y()); - expected_output_end_visible_bottom.Offset(clipping_offset.x(), + gfx::PointF(input.end.edge_start), + gfx::PointF(input.end.edge_end)); + expected_output_visible_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_visible_edge_end.Offset(clipping_offset.x(), + clipping_offset.y()); - EXPECT_EQ(expected_output_end_visible_top, output.end.visible_edge_top()); - EXPECT_EQ(expected_output_end_visible_bottom, - output.end.visible_edge_bottom()); + EXPECT_EQ(expected_output_visible_edge_start, + output.end.visible_edge_start()); + EXPECT_EQ(expected_output_visible_edge_end, output.end.visible_edge_end()); EXPECT_FALSE(output.end.visible()); // The right bound should be occluded by the clip layer for the vertical text. input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(25, 10); - input.start.edge_bottom = gfx::Point(15, 10); + input.start.edge_start = gfx::Point(25, 10); + input.start.edge_end = gfx::Point(15, 10); input.start.layer_id = clipped_layer->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(75, 30); - input.end.edge_bottom = gfx::Point(85, 30); + input.end.edge_start = gfx::Point(75, 30); + input.end.edge_end = gfx::Point(85, 30); input.end.layer_id = clipped_layer->id(); host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - expected_output_start_top = gfx::PointF(input.start.edge_top); - expected_output_start_bottom = gfx::PointF(input.start.edge_bottom); - expected_output_start_top.Offset(clipping_offset.x(), clipping_offset.y()); - expected_output_start_bottom.Offset(clipping_offset.x(), clipping_offset.y()); - EXPECT_EQ(expected_output_start_top, output.start.edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.edge_bottom()); - EXPECT_EQ(expected_output_start_top, output.start.visible_edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.visible_edge_bottom()); + expected_output_edge_start = gfx::PointF(input.start.edge_start); + expected_output_edge_end = gfx::PointF(input.start.edge_end); + expected_output_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_edge_end.Offset(clipping_offset.x(), clipping_offset.y()); + EXPECT_EQ(expected_output_edge_start, output.start.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.start.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.visible_edge_end()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - expected_output_end_top = gfx::PointF(input.end.edge_top); - expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); - expected_output_end_bottom.Offset(clipping_offset.x(), clipping_offset.y()); - expected_output_end_top.Offset(clipping_offset.x(), clipping_offset.y()); - EXPECT_EQ(expected_output_end_top, output.end.edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom()); + expected_output_edge_start = gfx::PointF(input.end.edge_start); + expected_output_edge_end = gfx::PointF(input.end.edge_end); + expected_output_edge_end.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + EXPECT_EQ(expected_output_edge_start, output.end.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.edge_end()); - std::tie(expected_output_end_visible_top, - expected_output_end_visible_bottom) = + std::tie(expected_output_visible_edge_start, + expected_output_visible_edge_end) = GetVisibleSelectionEndPoints(visible_layer_rect, - gfx::PointF(input.end.edge_top), - gfx::PointF(input.end.edge_bottom)); - expected_output_end_visible_top.Offset(clipping_offset.x(), - clipping_offset.y()); - expected_output_end_visible_bottom.Offset(clipping_offset.x(), + gfx::PointF(input.end.edge_start), + gfx::PointF(input.end.edge_end)); + expected_output_visible_edge_start.Offset(clipping_offset.x(), clipping_offset.y()); + expected_output_visible_edge_end.Offset(clipping_offset.x(), + clipping_offset.y()); - EXPECT_EQ(expected_output_end_visible_top, output.end.visible_edge_top()); - EXPECT_EQ(expected_output_end_visible_bottom, - output.end.visible_edge_bottom()); + EXPECT_EQ(expected_output_visible_edge_start, + output.end.visible_edge_start()); + EXPECT_EQ(expected_output_visible_edge_end, output.end.visible_edge_end()); EXPECT_FALSE(output.end.visible()); // Handles outside the viewport bounds should be marked invisible. - input.start.edge_top = gfx::Point(-25, 0); - input.start.edge_bottom = gfx::Point(-25, 20); + input.start.edge_start = gfx::Point(-25, 0); + input.start.edge_end = gfx::Point(-25, 20); host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_FALSE(output.start.visible()); - input.start.edge_top = gfx::Point(0, -25); - input.start.edge_bottom = gfx::Point(0, -5); + input.start.edge_start = gfx::Point(0, -25); + input.start.edge_end = gfx::Point(0, -5); host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_FALSE(output.start.visible()); - // If the handle bottom is partially visible, the handle is marked visible. - input.start.edge_top = gfx::Point(0, -20); - input.start.edge_bottom = gfx::Point(0, 1); + // If the handle end is partially visible, the handle is marked visible. + input.start.edge_start = gfx::Point(0, -20); + input.start.edge_end = gfx::Point(0, 1); host_impl().active_tree()->RegisterSelection(input); host_impl().active_tree()->GetViewportSelection(&output); EXPECT_TRUE(output.start.visible()); @@ -2037,13 +2035,13 @@ LayerSelection input; input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(10, 10); - input.start.edge_bottom = gfx::Point(10, 30); + input.start.edge_start = gfx::Point(10, 10); + input.start.edge_end = gfx::Point(10, 30); input.start.layer_id = page_scale_layer->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(0, 0); - input.end.edge_bottom = gfx::Point(0, 20); + input.end.edge_start = gfx::Point(0, 0); + input.end.edge_end = gfx::Point(0, 20); input.end.layer_id = sub_layer->id(); host_impl().active_tree()->RegisterSelection(input); @@ -2052,27 +2050,27 @@ viz::Selection<gfx::SelectionBound> output; host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - auto expected_output_start_top = gfx::PointF(input.start.edge_top); - auto expected_output_start_bottom = gfx::PointF(input.start.edge_bottom); - expected_output_start_top.Scale(page_scale_factor); - expected_output_start_bottom.Scale(page_scale_factor); - EXPECT_EQ(expected_output_start_top, output.start.edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.edge_bottom()); - EXPECT_EQ(expected_output_start_top, output.start.visible_edge_top()); - EXPECT_EQ(expected_output_start_bottom, output.start.visible_edge_bottom()); + auto expected_output_edge_start = gfx::PointF(input.start.edge_start); + auto expected_output_edge_end = gfx::PointF(input.start.edge_end); + expected_output_edge_start.Scale(page_scale_factor); + expected_output_edge_end.Scale(page_scale_factor); + EXPECT_EQ(expected_output_edge_start, output.start.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.start.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.visible_edge_end()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - auto expected_output_end_top = gfx::PointF(input.end.edge_top); - auto expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); - expected_output_end_top.Offset(sub_layer_offset.x(), sub_layer_offset.y()); - expected_output_end_bottom.Offset(sub_layer_offset.x(), sub_layer_offset.y()); - expected_output_end_top.Scale(page_scale_factor); - expected_output_end_bottom.Scale(page_scale_factor); - EXPECT_EQ(expected_output_end_top, output.end.edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom()); - EXPECT_EQ(expected_output_end_top, output.end.visible_edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.visible_edge_bottom()); + expected_output_edge_start = gfx::PointF(input.end.edge_start); + expected_output_edge_end = gfx::PointF(input.end.edge_end); + expected_output_edge_start.Offset(sub_layer_offset.x(), sub_layer_offset.y()); + expected_output_edge_end.Offset(sub_layer_offset.x(), sub_layer_offset.y()); + expected_output_edge_start.Scale(page_scale_factor); + expected_output_edge_end.Scale(page_scale_factor); + EXPECT_EQ(expected_output_edge_start, output.end.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.end.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.visible_edge_end()); EXPECT_TRUE(output.end.visible()); } @@ -2099,13 +2097,13 @@ LayerSelection input; input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(10, 10); - input.start.edge_bottom = gfx::Point(10, 30); + input.start.edge_start = gfx::Point(10, 10); + input.start.edge_end = gfx::Point(10, 30); input.start.layer_id = root->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(0, 0); - input.end.edge_bottom = gfx::Point(0, 20); + input.end.edge_start = gfx::Point(0, 0); + input.end.edge_end = gfx::Point(0, 20); input.end.layer_id = sub_layer->id(); host_impl().active_tree()->RegisterSelection(input); @@ -2114,31 +2112,31 @@ viz::Selection<gfx::SelectionBound> output; host_impl().active_tree()->GetViewportSelection(&output); EXPECT_EQ(input.start.type, output.start.type()); - auto expected_output_start_top = gfx::PointF(input.start.edge_top); - auto expected_output_edge_bottom = gfx::PointF(input.start.edge_bottom); - expected_output_start_top.Scale( + auto expected_output_edge_start = gfx::PointF(input.start.edge_start); + auto expected_output_edge_end = gfx::PointF(input.start.edge_end); + expected_output_edge_start.Scale( 1.f / (device_scale_factor * painted_device_scale_factor)); - expected_output_edge_bottom.Scale( + expected_output_edge_end.Scale( 1.f / (device_scale_factor * painted_device_scale_factor)); - EXPECT_EQ(expected_output_start_top, output.start.edge_top()); - EXPECT_EQ(expected_output_edge_bottom, output.start.edge_bottom()); - EXPECT_EQ(expected_output_start_top, output.start.visible_edge_top()); - EXPECT_EQ(expected_output_edge_bottom, output.start.visible_edge_bottom()); + EXPECT_EQ(expected_output_edge_start, output.start.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.start.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.start.visible_edge_end()); EXPECT_TRUE(output.start.visible()); EXPECT_EQ(input.end.type, output.end.type()); - auto expected_output_end_top = gfx::PointF(input.end.edge_top); - auto expected_output_end_bottom = gfx::PointF(input.end.edge_bottom); - expected_output_end_top.Offset(sub_layer_offset.x(), sub_layer_offset.y()); - expected_output_end_bottom.Offset(sub_layer_offset.x(), sub_layer_offset.y()); - expected_output_end_top.Scale( + expected_output_edge_start = gfx::PointF(input.end.edge_start); + expected_output_edge_end = gfx::PointF(input.end.edge_end); + expected_output_edge_start.Offset(sub_layer_offset.x(), sub_layer_offset.y()); + expected_output_edge_end.Offset(sub_layer_offset.x(), sub_layer_offset.y()); + expected_output_edge_start.Scale( 1.f / (device_scale_factor * painted_device_scale_factor)); - expected_output_end_bottom.Scale( + expected_output_edge_end.Scale( 1.f / (device_scale_factor * painted_device_scale_factor)); - EXPECT_EQ(expected_output_end_top, output.end.edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.edge_bottom()); - EXPECT_EQ(expected_output_end_top, output.end.visible_edge_top()); - EXPECT_EQ(expected_output_end_bottom, output.end.visible_edge_bottom()); + EXPECT_EQ(expected_output_edge_start, output.end.edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.edge_end()); + EXPECT_EQ(expected_output_edge_start, output.end.visible_edge_start()); + EXPECT_EQ(expected_output_edge_end, output.end.visible_edge_end()); EXPECT_TRUE(output.end.visible()); } @@ -2167,13 +2165,13 @@ LayerSelection input; input.start.type = gfx::SelectionBound::LEFT; - input.start.edge_top = gfx::Point(10, 10); - input.start.edge_bottom = gfx::Point(10, 20); + input.start.edge_start = gfx::Point(10, 10); + input.start.edge_end = gfx::Point(10, 20); input.start.layer_id = grand_child->id(); input.end.type = gfx::SelectionBound::RIGHT; - input.end.edge_top = gfx::Point(50, 10); - input.end.edge_bottom = gfx::Point(50, 30); + input.end.edge_start = gfx::Point(50, 10); + input.end.edge_end = gfx::Point(50, 30); input.end.layer_id = grand_child->id(); host_impl().active_tree()->RegisterSelection(input); @@ -2181,7 +2179,7 @@ viz::Selection<gfx::SelectionBound> output; host_impl().active_tree()->GetViewportSelection(&output); - // edge_bottom and edge_top aren't allowed to have NaNs, so the selection + // edge_end and edge_start aren't allowed to have NaNs, so the selection // should be empty. EXPECT_EQ(gfx::SelectionBound(), output.start); EXPECT_EQ(gfx::SelectionBound(), output.end);
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc index 6b306c71..23552bc 100644 --- a/cc/trees/property_tree.cc +++ b/cc/trees/property_tree.cc
@@ -1148,11 +1148,12 @@ ScrollTree& ScrollTree::operator=(const ScrollTree& from) { PropertyTree::operator=(from); currently_scrolling_node_id_ = kInvalidNodeId; - // Maps for ScrollOffsets/SyncedScrollOffsets are intentionally ommitted here + // Maps for ScrollOffsets/SyncedScrollOffsets are intentionally omitted here // since we can not directly copy them. Pushing of these updates from main // currently depends on Layer properties for scroll offset animation changes // (setting clobber_active_value for scroll offset animations interrupted on // the main thread) being pushed to impl first. + // |callbacks_| is omitted because it's for the main thread only. return *this; } @@ -1161,6 +1162,8 @@ return false; if (synced_scroll_offset_map_ != other.synced_scroll_offset_map_) return false; + if (callbacks_.get() != other.callbacks_.get()) + return false; bool is_currently_scrolling_node_equal = currently_scrolling_node_id_ == other.currently_scrolling_node_id_; @@ -1173,6 +1176,7 @@ currently_scrolling_node_id_ = other.currently_scrolling_node_id_; scroll_offset_map_ = other.scroll_offset_map_; synced_scroll_offset_map_ = other.synced_scroll_offset_map_; + callbacks_ = other.callbacks_; } #endif @@ -1202,7 +1206,9 @@ #if DCHECK_IS_ON() ScrollTree tree; - if (!property_trees()->is_main_thread) { + if (property_trees()->is_main_thread) { + tree.callbacks_ = callbacks_; + } else { DCHECK(scroll_offset_map_.empty()); tree.currently_scrolling_node_id_ = currently_scrolling_node_id_; tree.synced_scroll_offset_map_ = synced_scroll_offset_map_; @@ -1626,6 +1632,25 @@ return offset; } +void ScrollTree::SetScrollCallbacks(base::WeakPtr<ScrollCallbacks> callbacks) { + DCHECK(property_trees()->is_main_thread); + callbacks_ = std::move(callbacks); +} + +void ScrollTree::NotifyDidScroll(ElementId scroll_element_id, + const gfx::ScrollOffset& scroll_offset) { + DCHECK(property_trees()->is_main_thread); + if (callbacks_) + callbacks_->DidScroll(scroll_element_id, scroll_offset); +} + +void ScrollTree::NotifyDidChangeScrollbarsHidden(ElementId scroll_element_id, + bool hidden) { + DCHECK(property_trees()->is_main_thread); + if (callbacks_) + callbacks_->DidChangeScrollbarsHidden(scroll_element_id, hidden); +} + PropertyTreesCachedData::PropertyTreesCachedData() : transform_tree_update_number(0) { animation_scales.clear();
diff --git a/cc/trees/property_tree.h b/cc/trees/property_tree.h index 8370ad1..c8f6f99 100644 --- a/cc/trees/property_tree.h +++ b/cc/trees/property_tree.h
@@ -11,7 +11,9 @@ #include <unordered_map> #include <vector> +#include "base/callback.h" #include "base/containers/flat_map.h" +#include "base/memory/weak_ptr.h" #include "cc/base/synced_property.h" #include "cc/cc_export.h" #include "cc/paint/element_id.h" @@ -362,6 +364,22 @@ std::vector<std::unique_ptr<RenderSurfaceImpl>> render_surfaces_; }; +// These callbacks are called in the main thread to notify changes of scroll +// information in the compositor thread during commit. +class ScrollCallbacks { + public: + // Called after the composited scroll offset changed. + virtual void DidScroll(ElementId scroll_element_id, + const gfx::ScrollOffset&) = 0; + // Called after the hidden status of composited scrollbars changed. Note that + // |scroll_element_id| is the element id of the scroll not of the scrollbars. + virtual void DidChangeScrollbarsHidden(ElementId scroll_element_id, + bool hidden) = 0; + + protected: + virtual ~ScrollCallbacks() {} +}; + class CC_EXPORT ScrollTree final : public PropertyTree<ScrollNode> { public: ScrollTree(); @@ -459,6 +477,13 @@ ScrollNode* FindNodeFromElementId(ElementId id); const ScrollNode* FindNodeFromElementId(ElementId id) const; + void SetScrollCallbacks(base::WeakPtr<ScrollCallbacks> callbacks); + + void NotifyDidScroll(ElementId scroll_element_id, + const gfx::ScrollOffset& scroll_offset); + void NotifyDidChangeScrollbarsHidden(ElementId scroll_element_id, + bool hidden); + private: using ScrollOffsetMap = base::flat_map<ElementId, gfx::ScrollOffset>; using SyncedScrollOffsetMap = @@ -474,6 +499,8 @@ ScrollOffsetMap scroll_offset_map_; SyncedScrollOffsetMap synced_scroll_offset_map_; + base::WeakPtr<ScrollCallbacks> callbacks_; + SyncedScrollOffset* GetOrCreateSyncedScrollOffset(ElementId id); gfx::ScrollOffset PullDeltaForMainThread(SyncedScrollOffset* scroll_offset, bool use_fractional_deltas);
diff --git a/chrome/VERSION b/chrome/VERSION index e078d7e..ae2a8a9 100644 --- a/chrome/VERSION +++ b/chrome/VERSION
@@ -1,4 +1,4 @@ MAJOR=80 MINOR=0 -BUILD=3965 +BUILD=3966 PATCH=0
diff --git a/chrome/android/java/res/layout/top_view.xml b/chrome/android/java/res/layout/top_view.xml index 801176f..cbcede39 100644 --- a/chrome/android/java/res/layout/top_view.xml +++ b/chrome/android/java/res/layout/top_view.xml
@@ -29,6 +29,13 @@ app:horizontalSpacing="10dp"> <org.chromium.ui.widget.ChipView + android:id="@+id/icon_filter" + android:gravity="center" + android:layout_height="wrap_content" + android:layout_width="wrap_content" + style="@style/SuggestionChip" /> + + <org.chromium.ui.widget.ChipView android:id="@+id/names_filter" android:gravity="center" android:layout_height="wrap_content"
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java index 90a3b20..49d593c 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchBarControl.java
@@ -569,32 +569,34 @@ assert ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT); // There are 3 cases: - // 1) The whole Bar minus icon (when the icon is present) - // 2) The icon - // 3) The whole Bar (without any icons) - boolean wereIconsVisibleOnTouch = !mContextualSearchPanel.isPeeking(); + // 1) The whole Bar (without any icons) + // 2) The Bar minus icon (when the icon is present) + // 3) The icon int panelWidth = mContextualSearchPanel.getContentViewWidthPx(); - if (wereIconsVisibleOnTouch) { - float iconOffsetPx = (mContextualSearchPanel.getOpenTabIconX() - - mContextualSearchPanel.getButtonPaddingDps()) - * mDpToPx; - if (xPx < iconOffsetPx) { - // Case 1 - whole Bar minus icon. - mTouchHighlightXOffsetPx = 0; - mTouchHighlightWidthPx = iconOffsetPx; - } else { - // Case 2 - the icon. - mTouchHighlightXOffsetPx = iconOffsetPx; - mTouchHighlightWidthPx = panelWidth - iconOffsetPx; - } - } else { - // Case 3 - whole Bar. + if (mContextualSearchPanel.isPeeking()) { + // Case 1 - whole Bar. mTouchHighlightXOffsetPx = 0; mTouchHighlightWidthPx = panelWidth; - } - // If RTL then width is correct, just move offset to the other side of the panel. - if (LocalizationUtils.isLayoutRtl()) { - mTouchHighlightXOffsetPx = panelWidth - mTouchHighlightXOffsetPx; + } else { + // The open-tab-icon is on the right (on the left in RTL). + boolean isRtl = LocalizationUtils.isLayoutRtl(); + float paddedIconWithMarginWidth = + (mContextualSearchPanel.getBarMarginSide() + + mContextualSearchPanel.getOpenTabIconDimension() + + mContextualSearchPanel.getButtonPaddingDps()) + * mDpToPx; + float contentWidth = panelWidth - paddedIconWithMarginWidth; + // Adjust the touch point to panel coordinates. + xPx -= mContextualSearchPanel.getOffsetX() * mDpToPx; + if (isRtl && xPx > paddedIconWithMarginWidth || !isRtl && xPx < contentWidth) { + // Case 2 - Bar minus icon. + mTouchHighlightXOffsetPx = isRtl ? paddedIconWithMarginWidth : 0; + mTouchHighlightWidthPx = contentWidth; + } else { + // Case 3 - the icon. + mTouchHighlightXOffsetPx = isRtl ? 0 : contentWidth; + mTouchHighlightWidthPx = paddedIconWithMarginWidth; + } } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactView.java b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactView.java index 0298678..fc5dbbcd 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactView.java
@@ -198,7 +198,7 @@ if (contactDetails.isSelf()) mStar.setVisibility(View.VISIBLE); - if (icon == null) { + if (icon == null || !PickerAdapter.includesIcons()) { icon = mCategoryView.getIconGenerator().generateIconForText( contactDetails.getDisplayNameAbbreviation()); setIconDrawable(new BitmapDrawable(getResources(), icon));
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialog.java index 3df9cf09..0ed02fd7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialog.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialog.java
@@ -25,21 +25,22 @@ * @param context The context to use. * @param listener The listener object that gets notified when an action is taken. * @param allowMultiple Whether the contacts picker should allow multiple items to be selected. - * @param includeNames Whether the contacts data returned includes names. - * @param includeEmails Whether the contacts data returned includes emails. - * @param includeTel Whether the contacts data returned includes telephone numbers. - * @param includeAddresses Whether the contacts data returned includes addresses. + * @param includeNames Whether the contacts data returned should include names. + * @param includeEmails Whether the contacts data returned should include emails. + * @param includeTel Whether the contacts data returned should include telephone numbers. + * @param includeAddresses Whether the contacts data returned should include addresses. + * @param includeIcons Whether the contacts data returned should include icons. * @param formattedOrigin The origin the data will be shared with, formatted for display with * the scheme omitted. */ public ContactsPickerDialog(Context context, ContactsPickerListener listener, boolean allowMultiple, boolean includeNames, boolean includeEmails, boolean includeTel, - boolean includeAddresses, String formattedOrigin) { + boolean includeAddresses, boolean includeIcons, String formattedOrigin) { super(context, R.style.Theme_Chromium_Fullscreen); // Initialize the main content view. mCategoryView = new PickerCategoryView(context, allowMultiple, includeNames, includeEmails, - includeTel, includeAddresses, formattedOrigin, this); + includeTel, includeAddresses, includeIcons, formattedOrigin, this); mCategoryView.initialize(this, listener); setView(mCategoryView); }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerAdapter.java index 68eb2ef..455e5af 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerAdapter.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerAdapter.java
@@ -65,12 +65,14 @@ * The types of filters supported. */ @Retention(RetentionPolicy.SOURCE) - @IntDef({FilterType.NAMES, FilterType.EMAILS, FilterType.TELEPHONES, FilterType.ADDRESSES}) + @IntDef({FilterType.NAMES, FilterType.EMAILS, FilterType.TELEPHONES, FilterType.ADDRESSES, + FilterType.ICONS}) public @interface FilterType { int NAMES = 0; int EMAILS = 1; int TELEPHONES = 2; int ADDRESSES = 3; + int ICONS = 4; } /** @@ -135,6 +137,9 @@ // Whether to include telephone numbers in the returned results. private static boolean sIncludeTelephones; + // Whether to include icons in the returned results. + private static boolean sIncludeIcons; + // A list of contacts to use for testing (instead of querying Android). private static ArrayList<ContactDetails> sTestContacts; @@ -156,6 +161,7 @@ sIncludeNames = true; sIncludeEmails = true; sIncludeTelephones = true; + sIncludeIcons = true; mProfileDataCache = new ProfileDataCache(context, mContext.getResources().getDimensionPixelSize(R.dimen.contact_picker_icon_size)); @@ -284,7 +290,7 @@ mTopView.updateCheckboxVisibility(mCategoryView.multiSelectionAllowed()); mTopView.updateChipVisibility(mCategoryView.includeNames, mCategoryView.includeAddresses, mCategoryView.includeEmails, - mCategoryView.includeTel); + mCategoryView.includeTel, mCategoryView.includeIcons); mCategoryView.setTopView(mTopView); if (mContactDetails != null) mTopView.updateContactCount(mContactDetails.size()); return new TopViewHolder(mTopView); @@ -350,6 +356,9 @@ case FilterType.TELEPHONES: sIncludeTelephones = !sIncludeTelephones; break; + case FilterType.ICONS: + sIncludeIcons = !sIncludeIcons; + break; default: assert false; } @@ -386,6 +395,13 @@ } /** + * Returns true unless the adapter is filtering out icons. + */ + public static boolean includesIcons() { + return sIncludeIcons; + } + + /** * Sets a list of contacts to use as data for the dialog, and the owner email. For testing use * only. */
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerCategoryView.java b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerCategoryView.java index eaf54f49..19d2e3a3e 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerCategoryView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/PickerCategoryView.java
@@ -104,6 +104,9 @@ // Whether the picker is in multi-selection mode. private boolean mMultiSelectionAllowed; + // Whether the contacts data returned includes icons. + public final boolean includeIcons; + // Whether the contacts data returned includes names. public final boolean includeNames; @@ -123,12 +126,13 @@ @SuppressWarnings("unchecked") // mSelectableListLayout public PickerCategoryView(Context context, boolean multiSelectionAllowed, boolean shouldIncludeNames, boolean shouldIncludeEmails, boolean shouldIncludeTel, - boolean shouldIncludeAddresses, String formattedOrigin, + boolean shouldIncludeAddresses, boolean shouldIncludeIcons, String formattedOrigin, ContactsPickerToolbar.ContactsToolbarDelegate delegate) { super(context, null); mActivity = (ChromeActivity) context; mMultiSelectionAllowed = multiSelectionAllowed; + includeIcons = shouldIncludeIcons; includeNames = shouldIncludeNames; includeEmails = shouldIncludeEmails; includeTel = shouldIncludeTel; @@ -394,6 +398,9 @@ if (includeAddresses) { propertiesRequested |= ContactsPickerPropertiesRequested.PROPERTIES_ADDRESSES; } + if (includeIcons) { + propertiesRequested |= ContactsPickerPropertiesRequested.PROPERTIES_ICONS; + } mListener.onContactsPickerUserAction( action, contacts, percentageShared, propertiesRequested);
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/TopView.java b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/TopView.java index b3979880..71556cf 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/TopView.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/contacts_picker/TopView.java
@@ -73,6 +73,9 @@ // A Chip for filtering out telephones. private ChipView mTelephonesFilterChip; + // A Chip for filtering out telephones. + private ChipView mIconsFilterChip; + // The callback to use to notify when the filter chips are toggled. private ChipToggledCallback mChipToggledCallback; @@ -121,6 +124,12 @@ textView.setText(R.string.top_view_telephone_filter_label); mTelephonesFilterChip.setSelected(true); mTelephonesFilterChip.setOnClickListener(this); + + mIconsFilterChip = findViewById(R.id.icon_filter); + textView = mIconsFilterChip.getPrimaryTextView(); + textView.setText(R.string.top_view_icon_filter_label); + mIconsFilterChip.setSelected(true); + mIconsFilterChip.setOnClickListener(this); } @Override @@ -134,6 +143,8 @@ notifyChipToggled(PickerAdapter.FilterType.EMAILS); } else if (id == R.id.tel_filter) { notifyChipToggled(PickerAdapter.FilterType.TELEPHONES); + } else if (id == R.id.icon_filter) { + notifyChipToggled(PickerAdapter.FilterType.ICONS); } } @@ -157,6 +168,9 @@ case PickerAdapter.FilterType.TELEPHONES: chipView = mTelephonesFilterChip; break; + case PickerAdapter.FilterType.ICONS: + chipView = mIconsFilterChip; + break; default: assert false; return; @@ -213,11 +227,12 @@ * @param shouldDisplayTel Whether the telephone chip should be displayed. */ public void updateChipVisibility(boolean shouldDisplayNames, boolean shouldDisplayAddresses, - boolean shouldDisplayEmails, boolean shouldDisplayTel) { + boolean shouldDisplayEmails, boolean shouldDisplayTel, boolean shouldDisplayIcons) { mNamesFilterChip.setVisibility(shouldDisplayNames ? View.VISIBLE : View.GONE); mAddressFilterChip.setVisibility(shouldDisplayAddresses ? View.VISIBLE : View.GONE); mEmailFilterChip.setVisibility(shouldDisplayEmails ? View.VISIBLE : View.GONE); mTelephonesFilterChip.setVisibility(shouldDisplayTel ? View.VISIBLE : View.GONE); + mIconsFilterChip.setVisibility(shouldDisplayIcons ? View.VISIBLE : View.GONE); } /**
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/flags/FeatureUtilities.java b/chrome/android/java/src/org/chromium/chrome/browser/flags/FeatureUtilities.java index 556572f..88052a9d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/flags/FeatureUtilities.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/flags/FeatureUtilities.java
@@ -139,6 +139,12 @@ private static final String START_SURFACE_ENABLED_KEY = "start_surface_enabled"; /** + * Whether or not grey triangle icon on non-secure connections feature is enabled. + * Default value is false. + */ + private static final String MARK_HTTP_AS_DANGER_WARNING = "mark_http_as_danger_warning"; + + /** * Whether or not the grid tab switcher is enabled. * Default value is false. */ @@ -242,6 +248,7 @@ cacheReachedCodeProfilerTrialGroup(); cacheStartSurfaceEnabled(); cacheClickToCallOpenDialerDirectlyEnabled(); + cacheMarkHttpAsDangerWarningEnabled(); if (isHighEndPhone()) cacheGridTabSwitcherEnabled(); if (isHighEndPhone()) cacheTabGroupsAndroidEnabled(); @@ -689,6 +696,35 @@ } /** + * Cache the value of the flag of whether to use the grey triangle security indicator on + * insecure pages. + */ + public static void cacheMarkHttpAsDangerWarningEnabled() { + String featureParam = "danger-warning"; + String enabledFeature = ChromeFeatureList.getFieldTrialParamByFeature( + ChromeFeatureList.MARK_HTTP_AS, "treatment"); + SharedPreferencesManager.getInstance().writeBoolean( + MARK_HTTP_AS_DANGER_WARNING, enabledFeature.equals(featureParam)); + } + + /** + * @return Whether a grey triangle icon should be used in the omnibox instead of the info icon + * on insecure pages. + */ + public static boolean isMarkHttpAsDangerWarningEnabled() { + return isFlagEnabled(MARK_HTTP_AS_DANGER_WARNING, false); + } + + /** + * Toggles whether experiment for marking insecure connections with a grey triangle + * icon is enabled for testing. Should be reset back to null after the test has finished. + */ + @VisibleForTesting + public static void setMarkHttpAsDangerWarningEnabledForTesting(@Nullable Boolean isEnabled) { + sFlags.put(MARK_HTTP_AS_DANGER_WARNING, isEnabled); + } + + /** * Caches the trial group of the reached code profiler feature to be using on next startup. */ private static void cacheReachedCodeProfilerTrialGroup() {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java index 1a5b63db..7f78fee9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/init/ProcessInitializationHandler.java
@@ -259,7 +259,8 @@ boolean allowMultiple, boolean includeNames, boolean includeEmails, boolean includeTel, boolean includeAddresses, String formattedOrigin) { mDialog = new ContactsPickerDialog(context, listener, allowMultiple, includeNames, - includeEmails, includeTel, includeAddresses, formattedOrigin); + includeEmails, includeTel, includeAddresses, /*includeIcons=*/false, + formattedOrigin); mDialog.getWindow().getAttributes().windowAnimations = R.style.PickerDialogAnimation; mDialog.show();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java b/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java index 37302ad..9eb2789 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/page_info/PermissionParamsListBuilder.java
@@ -20,7 +20,6 @@ import org.chromium.chrome.browser.ContentSettingsType; import org.chromium.chrome.browser.browserservices.Origin; import org.chromium.chrome.browser.browserservices.permissiondelegation.TrustedWebActivityPermissionManager; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.website.ContentSettingValues; import org.chromium.chrome.browser.preferences.website.ContentSettingsResources; import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; @@ -99,8 +98,8 @@ } else if (!hasAndroidPermission(permission.type)) { permissionParams.warningTextResource = R.string.page_info_android_permission_blocked; - androidPermissions = - PrefServiceBridge.getAndroidPermissionsForContentSetting(permission.type); + androidPermissions = WebsitePreferenceBridge.getAndroidPermissionsForContentSetting( + permission.type); } if (permissionParams.warningTextResource != 0) { @@ -167,7 +166,7 @@ private boolean hasAndroidPermission(int contentSettingType) { String[] androidPermissions = - PrefServiceBridge.getAndroidPermissionsForContentSetting(contentSettingType); + WebsitePreferenceBridge.getAndroidPermissionsForContentSetting(contentSettingType); if (androidPermissions == null) return true; for (int i = 0; i < androidPermissions.length; i++) { if (!mPermissionDelegate.hasPermission(androidPermissions[i])) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java b/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java index 1b70360e2..2c0d84ca 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/permissions/AndroidPermissionRequester.java
@@ -15,7 +15,7 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ContentSettingsType; import org.chromium.chrome.browser.metrics.WebApkUma; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; +import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.webapps.WebApkActivity; import org.chromium.ui.base.PermissionCallback; @@ -50,7 +50,7 @@ WindowAndroid windowAndroid, int[] contentSettingsTypes) { SparseArray<String[]> permissionsToRequest = new SparseArray<>(); for (int i = 0; i < contentSettingsTypes.length; i++) { - String[] permissions = PrefServiceBridge.getAndroidPermissionsForContentSetting( + String[] permissions = WebsitePreferenceBridge.getAndroidPermissionsForContentSetting( contentSettingsTypes[i]); if (permissions == null) continue; List<String> missingPermissions = new ArrayList<>();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java index f01a95ca..ffef7d54 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java
@@ -12,6 +12,7 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.NativeMethods; import org.chromium.chrome.browser.AppHooks; +import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; import org.chromium.components.location.LocationSettingsDialogContext; import org.chromium.components.location.LocationSettingsDialogOutcome; import org.chromium.components.location.LocationUtils; @@ -101,7 +102,7 @@ * Returns whether Chrome's user-configurable location setting is enabled. */ public boolean isChromeLocationSettingEnabled() { - return PrefServiceBridge.getInstance().isAllowLocationEnabled(); + return WebsitePreferenceBridge.isAllowLocationEnabled(); } @VisibleForTesting
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/NotificationsPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/NotificationsPreferences.java index 47b24b2..641fef0 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/NotificationsPreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/NotificationsPreferences.java
@@ -18,6 +18,7 @@ import org.chromium.chrome.browser.preferences.website.ContentSettingsResources; import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences; import org.chromium.chrome.browser.preferences.website.SiteSettingsCategory; +import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; /** * Settings fragment that allows the user to configure notifications. It contains general @@ -75,9 +76,8 @@ : R.string.notifications_content_suggestions_summary_disabled); } - mFromWebsitesPref.setSummary( - ContentSettingsResources.getCategorySummary(ContentSettingsType.NOTIFICATIONS, - PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.NOTIFICATIONS))); + mFromWebsitesPref.setSummary(ContentSettingsResources.getCategorySummary( + ContentSettingsType.NOTIFICATIONS, + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.NOTIFICATIONS))); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java index eec13edc..15b3b71 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
@@ -9,33 +9,15 @@ import org.chromium.base.ThreadUtils; import org.chromium.base.VisibleForTesting; -import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.NativeMethods; -import org.chromium.chrome.browser.ContentSettingsType; -import org.chromium.chrome.browser.preferences.website.ContentSettingException; import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * PrefServiceBridge is a singleton which provides access to some native preferences. Ideally * preferences should be grouped with their relevant functionality but this is a grab-bag for other * preferences. */ public class PrefServiceBridge { - /** The android permissions associated with requesting location. */ - private static final String[] LOCATION_PERMISSIONS = { - android.Manifest.permission.ACCESS_FINE_LOCATION, - android.Manifest.permission.ACCESS_COARSE_LOCATION}; - /** The android permissions associated with requesting access to the camera. */ - private static final String[] CAMERA_PERMISSIONS = {android.Manifest.permission.CAMERA}; - /** The android permissions associated with requesting access to the microphone. */ - private static final String[] MICROPHONE_PERMISSIONS = { - android.Manifest.permission.RECORD_AUDIO}; - /** Signifies there are no permissions associated. */ - private static final String[] EMPTY_PERMISSIONS = {}; private static final String LOG_TAG = "PrefServiceBridge"; @@ -126,114 +108,6 @@ } /** - * Returns whether a particular content setting type is enabled. - * @param contentSettingsType The content setting type to check. - */ - public boolean isContentSettingEnabled(int contentSettingsType) { - return PrefServiceBridgeJni.get().isContentSettingEnabled(contentSettingsType); - } - - /** - * @return Whether a particular content setting type is managed by policy. - * @param contentSettingsType The content setting type to check. - */ - public boolean isContentSettingManaged(int contentSettingsType) { - return PrefServiceBridgeJni.get().isContentSettingManaged(contentSettingsType); - } - - /** - * Sets a default value for content setting type. - * @param contentSettingsType The content setting type to check. - * @param enabled Whether the default value should be disabled or enabled. - */ - public void setContentSettingEnabled(int contentSettingsType, boolean enabled) { - PrefServiceBridgeJni.get().setContentSettingEnabled(contentSettingsType, enabled); - } - - /** - * Returns all the currently saved exceptions for a given content settings type. - * @param contentSettingsType The type to fetch exceptions for. - */ - public List<ContentSettingException> getContentSettingsExceptions(int contentSettingsType) { - List<ContentSettingException> list = new ArrayList<ContentSettingException>(); - PrefServiceBridgeJni.get().getContentSettingsExceptions(contentSettingsType, list); - return list; - } - - @CalledByNative - private static void addContentSettingExceptionToList(ArrayList<ContentSettingException> list, - int contentSettingsType, String pattern, int contentSetting, String source) { - ContentSettingException exception = - new ContentSettingException(contentSettingsType, pattern, contentSetting, source); - list.add(exception); - } - - /** - * Return the list of android permission strings for a given {@link ContentSettingsType}. If - * there is no permissions associated with the content setting, then an empty array is returned. - * - * @param contentSettingType The content setting to get the android permission for. - * @return The android permissions for the given content setting. - */ - @CalledByNative - public static String[] getAndroidPermissionsForContentSetting(int contentSettingType) { - switch (contentSettingType) { - case ContentSettingsType.GEOLOCATION: - return Arrays.copyOf(LOCATION_PERMISSIONS, LOCATION_PERMISSIONS.length); - case ContentSettingsType.MEDIASTREAM_MIC: - return Arrays.copyOf(MICROPHONE_PERMISSIONS, MICROPHONE_PERMISSIONS.length); - case ContentSettingsType.MEDIASTREAM_CAMERA: - return Arrays.copyOf(CAMERA_PERMISSIONS, CAMERA_PERMISSIONS.length); - default: - return EMPTY_PERMISSIONS; - } - } - - /** - * @return Whether cookies acceptance is modifiable by the user - */ - public boolean isAcceptCookiesUserModifiable() { - return PrefServiceBridgeJni.get().getAcceptCookiesUserModifiable(); - } - - /** - * @return Whether cookies acceptance is configured by the user's custodian - * (for supervised users). - */ - public boolean isAcceptCookiesManagedByCustodian() { - return PrefServiceBridgeJni.get().getAcceptCookiesManagedByCustodian(); - } - - /** - * @return Whether geolocation information can be shared with content. - */ - public boolean isAllowLocationEnabled() { - return PrefServiceBridgeJni.get().getAllowLocationEnabled(); - } - - /** - * @return Whether geolocation information access is set to be shared with all sites, by policy. - */ - public boolean isLocationAllowedByPolicy() { - return PrefServiceBridgeJni.get().getLocationAllowedByPolicy(); - } - - /** - * @return Whether the location preference is modifiable by the user. - */ - public boolean isAllowLocationUserModifiable() { - return PrefServiceBridgeJni.get().getAllowLocationUserModifiable(); - } - - /** - * @return Whether the location preference is - * being managed by the custodian of the supervised account. - */ - public boolean isAllowLocationManagedByCustodian() { - return PrefServiceBridgeJni.get().getAllowLocationManagedByCustodian(); - } - - /** * @return Whether EULA has been accepted by the user. */ public boolean isFirstRunEulaAccepted() { @@ -241,27 +115,6 @@ } /** - * @return Whether JavaScript is managed by policy. - */ - public boolean javaScriptManaged() { - return isContentSettingManaged(ContentSettingsType.JAVASCRIPT); - } - - /** - * @return true if background sync is managed by policy. - */ - public boolean isBackgroundSyncManaged() { - return isContentSettingManaged(ContentSettingsType.BACKGROUND_SYNC); - } - - /** - * @return true if automatic downloads is managed by policy. - */ - public boolean isAutomaticDownloadsManaged() { - return isContentSettingManaged(ContentSettingsType.AUTOMATIC_DOWNLOADS); - } - - /** * Sets the preference that signals when the user has accepted the EULA. */ public void setEulaAccepted() { @@ -307,168 +160,6 @@ } /** - * @return Whether the setting to allow popups is configured by policy - */ - public boolean isPopupsManaged() { - return isContentSettingManaged(ContentSettingsType.POPUPS); - } - - /** - * Whether the setting type requires tri-state (Allowed/Ask/Blocked) setting. - */ - public boolean requiresTriStateContentSetting(int contentSettingsType) { - switch (contentSettingsType) { - case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER: - return true; - default: - return false; - } - } - - /** - * Sets the preferences on whether to enable/disable given setting. - */ - public void setCategoryEnabled(int contentSettingsType, boolean allow) { - assert !requiresTriStateContentSetting(contentSettingsType); - - switch (contentSettingsType) { - case ContentSettingsType.ADS: - case ContentSettingsType.BLUETOOTH_SCANNING: - case ContentSettingsType.JAVASCRIPT: - case ContentSettingsType.POPUPS: - case ContentSettingsType.USB_GUARD: - setContentSettingEnabled(contentSettingsType, allow); - break; - case ContentSettingsType.AUTOMATIC_DOWNLOADS: - PrefServiceBridgeJni.get().setAutomaticDownloadsEnabled(allow); - break; - case ContentSettingsType.AUTOPLAY: - PrefServiceBridgeJni.get().setAutoplayEnabled(allow); - break; - case ContentSettingsType.BACKGROUND_SYNC: - PrefServiceBridgeJni.get().setBackgroundSyncEnabled(allow); - break; - case ContentSettingsType.CLIPBOARD_READ: - PrefServiceBridgeJni.get().setClipboardEnabled(allow); - break; - case ContentSettingsType.COOKIES: - PrefServiceBridgeJni.get().setAllowCookiesEnabled(allow); - break; - case ContentSettingsType.GEOLOCATION: - PrefServiceBridgeJni.get().setAllowLocationEnabled(allow); - break; - case ContentSettingsType.MEDIASTREAM_CAMERA: - PrefServiceBridgeJni.get().setCameraEnabled(allow); - break; - case ContentSettingsType.MEDIASTREAM_MIC: - PrefServiceBridgeJni.get().setMicEnabled(allow); - break; - case ContentSettingsType.NFC: - PrefServiceBridgeJni.get().setNfcEnabled(allow); - break; - case ContentSettingsType.NOTIFICATIONS: - PrefServiceBridgeJni.get().setNotificationsEnabled(allow); - break; - case ContentSettingsType.SENSORS: - PrefServiceBridgeJni.get().setSensorsEnabled(allow); - break; - case ContentSettingsType.SOUND: - PrefServiceBridgeJni.get().setSoundEnabled(allow); - break; - default: - assert false; - } - } - - public boolean isCategoryEnabled(int contentSettingsType) { - assert !requiresTriStateContentSetting(contentSettingsType); - - switch (contentSettingsType) { - case ContentSettingsType.ADS: - case ContentSettingsType.CLIPBOARD_READ: - // Returns true if JavaScript is enabled. It may return the temporary value set by - // {@link #setJavaScriptEnabled}. The default is true. - case ContentSettingsType.JAVASCRIPT: - case ContentSettingsType.POPUPS: - // Returns true if websites are allowed to request permission to access USB devices. - case ContentSettingsType.USB_GUARD: - case ContentSettingsType.BLUETOOTH_SCANNING: - return isContentSettingEnabled(contentSettingsType); - case ContentSettingsType.AUTOMATIC_DOWNLOADS: - return PrefServiceBridgeJni.get().getAutomaticDownloadsEnabled(); - case ContentSettingsType.AUTOPLAY: - return PrefServiceBridgeJni.get().getAutoplayEnabled(); - case ContentSettingsType.BACKGROUND_SYNC: - return PrefServiceBridgeJni.get().getBackgroundSyncEnabled(); - case ContentSettingsType.COOKIES: - return PrefServiceBridgeJni.get().getAcceptCookiesEnabled(); - case ContentSettingsType.MEDIASTREAM_CAMERA: - return PrefServiceBridgeJni.get().getCameraEnabled(); - case ContentSettingsType.MEDIASTREAM_MIC: - return PrefServiceBridgeJni.get().getMicEnabled(); - case ContentSettingsType.NFC: - return PrefServiceBridgeJni.get().getNfcEnabled(); - case ContentSettingsType.NOTIFICATIONS: - return PrefServiceBridgeJni.get().getNotificationsEnabled(); - case ContentSettingsType.SENSORS: - return PrefServiceBridgeJni.get().getSensorsEnabled(); - case ContentSettingsType.SOUND: - return PrefServiceBridgeJni.get().getSoundEnabled(); - default: - assert false; - return false; - } - } - - /** - * Gets the ContentSetting for a settings type. Should only be used for more - * complex settings where a binary on/off value is not sufficient. - * Otherwise, use isCategoryEnabled() above. - * @param contentSettingsType The settings type to get setting for. - * @return The ContentSetting for |contentSettingsType|. - */ - public int getContentSetting(int contentSettingsType) { - return PrefServiceBridgeJni.get().getContentSetting(contentSettingsType); - } - - /** - * @param setting New ContentSetting to set for |contentSettingsType|. - */ - public void setContentSetting(int contentSettingsType, int setting) { - PrefServiceBridgeJni.get().setContentSetting(contentSettingsType, setting); - } - - /** - * @return Whether the camera/microphone permission is managed - * by the custodian of the supervised account. - */ - public boolean isCameraManagedByCustodian() { - return PrefServiceBridgeJni.get().getCameraManagedByCustodian(); - } - - /** - * @return Whether the camera permission is editable by the user. - */ - public boolean isCameraUserModifiable() { - return PrefServiceBridgeJni.get().getCameraUserModifiable(); - } - - /** - * @return Whether the microphone permission is managed by the custodian of - * the supervised account. - */ - public boolean isMicManagedByCustodian() { - return PrefServiceBridgeJni.get().getMicManagedByCustodian(); - } - - /** - * @return Whether the microphone permission is editable by the user. - */ - public boolean isMicUserModifiable() { - return PrefServiceBridgeJni.get().getMicUserModifiable(); - } - - /** * @return true if incognito mode is enabled. */ public boolean isIncognitoModeEnabled() { @@ -503,11 +194,6 @@ return PrefServiceBridgeJni.get().isMetricsReportingManaged(); } - public void setContentSettingForPattern(int contentSettingType, String pattern, int setting) { - PrefServiceBridgeJni.get().setContentSettingForPattern( - contentSettingType, pattern, setting); - } - @VisibleForTesting public static void setInstanceForTesting(@Nullable PrefServiceBridge instanceForTesting) { sInstance = instanceForTesting; @@ -515,14 +201,6 @@ @NativeMethods public interface Natives { - boolean isContentSettingEnabled(int contentSettingType); - boolean isContentSettingManaged(int contentSettingType); - void setContentSettingEnabled(int contentSettingType, boolean allow); - void getContentSettingsExceptions( - int contentSettingsType, List<ContentSettingException> list); - void setContentSettingForPattern(int contentSettingType, String pattern, int setting); - int getContentSetting(int contentSettingType); - void setContentSetting(int contentSettingType, int setting); boolean getBoolean(int preference); void setBoolean(int preference, boolean value); int getInteger(int preference); @@ -530,41 +208,9 @@ String getString(int preference); void setString(int preference, String value); boolean isManagedPreference(int preference); - boolean getAcceptCookiesEnabled(); - boolean getAcceptCookiesUserModifiable(); - boolean getAcceptCookiesManagedByCustodian(); - boolean getAutomaticDownloadsEnabled(); - boolean getAutoplayEnabled(); - boolean getBackgroundSyncEnabled(); - boolean getAllowLocationUserModifiable(); - boolean getLocationAllowedByPolicy(); - boolean getAllowLocationManagedByCustodian(); boolean getFirstRunEulaAccepted(); - boolean getCameraEnabled(); - void setCameraEnabled(boolean enabled); - boolean getCameraUserModifiable(); - boolean getCameraManagedByCustodian(); - boolean getMicEnabled(); - void setMicEnabled(boolean enabled); - boolean getMicUserModifiable(); - boolean getMicManagedByCustodian(); boolean getIncognitoModeEnabled(); boolean getIncognitoModeManaged(); - boolean getNfcEnabled(); - boolean getSensorsEnabled(); - boolean getSoundEnabled(); - void setAutomaticDownloadsEnabled(boolean enabled); - void setAutoplayEnabled(boolean enabled); - void setAllowCookiesEnabled(boolean enabled); - void setBackgroundSyncEnabled(boolean enabled); - void setClipboardEnabled(boolean enabled); - boolean getAllowLocationEnabled(); - boolean getNotificationsEnabled(); - void setAllowLocationEnabled(boolean enabled); - void setNotificationsEnabled(boolean enabled); - void setNfcEnabled(boolean enabled); - void setSensorsEnabled(boolean enabled); - void setSoundEnabled(boolean enabled); boolean canPrefetchAndPrerender(); boolean getNetworkPredictionManaged(); boolean obsoleteNetworkPredictionOptionsHasUserSetting();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ContentSettingException.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ContentSettingException.java index e92fd39..26154ee 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ContentSettingException.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ContentSettingException.java
@@ -8,7 +8,6 @@ import androidx.annotation.Nullable; import org.chromium.chrome.browser.ContentSettingsType; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import java.io.Serializable; import java.lang.annotation.Retention; @@ -80,8 +79,7 @@ * Sets the content setting value for this exception. */ public void setContentSetting(@ContentSettingValues @Nullable Integer value) { - PrefServiceBridge.getInstance().setContentSettingForPattern( - mContentSettingType, mPattern, value); + WebsitePreferenceBridge.setContentSettingForPattern(mContentSettingType, mPattern, value); } public static @ContentSettingsType int getContentSettingsType(@Type int type) {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/LocationCategory.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/LocationCategory.java index 46ab5932..eced798f 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/LocationCategory.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/LocationCategory.java
@@ -11,7 +11,6 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.preferences.LocationSettings; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.components.location.LocationUtils; /** @@ -37,9 +36,8 @@ // The only time we don't want to show location as blocked in system is when Chrome also // blocks Location by policy (because then turning it on in the system isn't going to // turn on location in Chrome). - PrefServiceBridge prefs = PrefServiceBridge.getInstance(); if (!LocationSettings.getInstance().isChromeLocationSettingEnabled() - && !prefs.isAllowLocationUserModifiable()) { + && !WebsitePreferenceBridge.isAllowLocationUserModifiable()) { return false; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java index eef88b3..9ea6c65 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java
@@ -285,7 +285,7 @@ int contentType = mCategory.getContentSettingsType(); mRequiresTriStateSetting = - PrefServiceBridge.getInstance().requiresTriStateContentSetting(contentType); + WebsitePreferenceBridge.requiresTriStateContentSetting(contentType); ViewGroup view = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState); @@ -459,8 +459,6 @@ // OnPreferenceChangeListener: @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); - if (BINARY_TOGGLE_KEY.equals(preference.getKey())) { assert !mCategory.isManaged(); @@ -472,7 +470,7 @@ continue; } - prefServiceBridge.setCategoryEnabled( + WebsitePreferenceBridge.setCategoryEnabled( SiteSettingsCategory.contentSettingsType(type), (boolean) newValue); if (type == SiteSettingsCategory.Type.COOKIES) { @@ -514,12 +512,14 @@ } else if (TRI_STATE_TOGGLE_KEY.equals(preference.getKey())) { @ContentSettingValues int setting = (int) newValue; - prefServiceBridge.setContentSetting(mCategory.getContentSettingsType(), setting); + WebsitePreferenceBridge.setContentSetting(mCategory.getContentSettingsType(), setting); getInfoForOrigins(); } else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) { - prefServiceBridge.setBoolean(Pref.BLOCK_THIRD_PARTY_COOKIES, ((boolean) newValue)); + PrefServiceBridge.getInstance().setBoolean( + Pref.BLOCK_THIRD_PARTY_COOKIES, ((boolean) newValue)); } else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) { - prefServiceBridge.setBoolean(Pref.NOTIFICATIONS_VIBRATE_ENABLED, (boolean) newValue); + PrefServiceBridge.getInstance().setBoolean( + Pref.NOTIFICATIONS_VIBRATE_ENABLED, (boolean) newValue); } return true; } @@ -533,17 +533,15 @@ } else if (mCategory.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC)) { resource = R.string.website_settings_add_site_description_background_sync; } else if (mCategory.showSites(SiteSettingsCategory.Type.JAVASCRIPT)) { - resource = PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.JAVASCRIPT) + resource = WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.JAVASCRIPT) ? R.string.website_settings_add_site_description_javascript_block : R.string.website_settings_add_site_description_javascript_allow; } else if (mCategory.showSites(SiteSettingsCategory.Type.SOUND)) { - resource = PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.SOUND) + resource = WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.SOUND) ? R.string.website_settings_add_site_description_sound_block : R.string.website_settings_add_site_description_sound_allow; } else if (mCategory.showSites(SiteSettingsCategory.Type.COOKIES)) { - resource = - PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.COOKIES) + resource = WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.COOKIES) ? R.string.website_settings_add_site_description_cookies_block : R.string.website_settings_add_site_description_cookies_allow; } @@ -580,12 +578,12 @@ // AddExceptionPreference.SiteAddedCallback: @Override public void onAddSite(String hostname) { - int setting = (PrefServiceBridge.getInstance().isCategoryEnabled( - mCategory.getContentSettingsType())) + int setting = + (WebsitePreferenceBridge.isCategoryEnabled(mCategory.getContentSettingsType())) ? ContentSettingValues.BLOCK : ContentSettingValues.ALLOW; - PrefServiceBridge.getInstance().setContentSettingForPattern( + WebsitePreferenceBridge.setContentSettingForPattern( mCategory.getContentSettingsType(), hostname, setting); Toast.makeText(getActivity(), String.format(getActivity().getString( @@ -619,12 +617,11 @@ if (mCategory.showSites(SiteSettingsCategory.Type.SOUND)) { exception = true; } else if (mCategory.showSites(SiteSettingsCategory.Type.AUTOPLAY) - && !PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.AUTOPLAY)) { + && !WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.AUTOPLAY)) { exception = true; } else if (mCategory.showSites(SiteSettingsCategory.Type.JAVASCRIPT) && (ChromeFeatureList.isEnabled(ChromeFeatureList.ANDROID_SITE_SETTINGS_UI_REFRESH) - || !PrefServiceBridge.getInstance().isCategoryEnabled( + || !WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.JAVASCRIPT))) { exception = true; } else if (mCategory.showSites(SiteSettingsCategory.Type.COOKIES) @@ -632,11 +629,11 @@ ChromeFeatureList.ANDROID_SITE_SETTINGS_UI_REFRESH)) { exception = true; } else if (mCategory.showSites(SiteSettingsCategory.Type.BACKGROUND_SYNC) - && !PrefServiceBridge.getInstance().isCategoryEnabled( + && !WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.BACKGROUND_SYNC)) { exception = true; } else if (mCategory.showSites(SiteSettingsCategory.Type.AUTOMATIC_DOWNLOADS) - && !PrefServiceBridge.getInstance().isCategoryEnabled( + && !WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.AUTOMATIC_DOWNLOADS)) { exception = true; } @@ -821,7 +818,6 @@ } private void configureGlobalToggles() { - PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); int contentType = mCategory.getContentSettingsType(); PreferenceScreen screen = getPreferenceScreen(); @@ -939,7 +935,7 @@ TriStateSiteSettingsPreference triStateToggle, int contentType) { triStateToggle.setOnPreferenceChangeListener(this); @ContentSettingValues - int setting = PrefServiceBridge.getInstance().getContentSetting(contentType); + int setting = WebsitePreferenceBridge.getContentSetting(contentType); int[] descriptionIds = ContentSettingsResources.getTriStateSettingDescriptionIDs(contentType); triStateToggle.initialize(setting, descriptionIds); @@ -951,7 +947,7 @@ // Set summary on or off. if (mCategory.showSites(SiteSettingsCategory.Type.DEVICE_LOCATION) - && PrefServiceBridge.getInstance().isLocationAllowedByPolicy()) { + && WebsitePreferenceBridge.isLocationAllowedByPolicy()) { binaryToggle.setSummaryOn(ContentSettingsResources.getGeolocationAllowedSummary()); } else { binaryToggle.setSummaryOn(ContentSettingsResources.getEnabledSummary(contentType)); @@ -977,7 +973,7 @@ binaryToggle.setChecked( LocationSettings.getInstance().isChromeLocationSettingEnabled()); } else { - binaryToggle.setChecked(PrefServiceBridge.getInstance().isCategoryEnabled(contentType)); + binaryToggle.setChecked(WebsitePreferenceBridge.isCategoryEnabled(contentType)); } } @@ -988,7 +984,7 @@ thirdPartyCookiesPref.setChecked( PrefServiceBridge.getInstance().getBoolean(Pref.BLOCK_THIRD_PARTY_COOKIES)); thirdPartyCookiesPref.setEnabled( - PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.COOKIES)); + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.COOKIES)); thirdPartyCookiesPref.setManagedPreferenceDelegate(preference -> PrefServiceBridge.getInstance().isManagedPreference( Pref.BLOCK_THIRD_PARTY_COOKIES)); @@ -999,8 +995,8 @@ (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference( NOTIFICATIONS_VIBRATE_TOGGLE_KEY); if (preference != null) { - preference.setEnabled(PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.NOTIFICATIONS)); + preference.setEnabled( + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.NOTIFICATIONS)); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java index 3aa72be..db14845 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java
@@ -33,7 +33,6 @@ import org.chromium.chrome.browser.preferences.ChromeImageViewPreference; import org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate; import org.chromium.chrome.browser.preferences.ManagedPreferencesUtils; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.chrome.browser.preferences.PreferenceUtils; import java.util.Arrays; @@ -762,8 +761,7 @@ // In order to always show the sound permission, set it up with the default value if it // doesn't have a current value. if (currentValue == null) { - currentValue = - PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.SOUND) + currentValue = WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.SOUND) ? ContentSettingValues.ALLOW : ContentSettingValues.BLOCK; } @@ -802,7 +800,7 @@ // However, if the blocking is activated, we still want to show the permission, even if it // is in the default state. if (permission == null) { - permission = PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.ADS) + permission = WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.ADS) ? ContentSettingValues.ALLOW : ContentSettingValues.BLOCK; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsCategory.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsCategory.java index d86083f..78f2a79 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsCategory.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsCategory.java
@@ -27,7 +27,6 @@ import org.chromium.chrome.R; import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ContentSettingsType; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import org.chromium.ui.text.SpanApplier; import org.chromium.ui.text.SpanApplier.SpanInfo; @@ -274,23 +273,22 @@ * custodian of a supervised account. */ public boolean isManaged() { - PrefServiceBridge prefs = PrefServiceBridge.getInstance(); if (showSites(Type.AUTOMATIC_DOWNLOADS)) { - return prefs.isAutomaticDownloadsManaged(); + return WebsitePreferenceBridge.isAutomaticDownloadsManaged(); } else if (showSites(Type.BACKGROUND_SYNC)) { - return prefs.isBackgroundSyncManaged(); + return WebsitePreferenceBridge.isBackgroundSyncManaged(); } else if (showSites(Type.COOKIES)) { - return !prefs.isAcceptCookiesUserModifiable(); + return !WebsitePreferenceBridge.isAcceptCookiesUserModifiable(); } else if (showSites(Type.DEVICE_LOCATION)) { - return !prefs.isAllowLocationUserModifiable(); + return !WebsitePreferenceBridge.isAllowLocationUserModifiable(); } else if (showSites(Type.JAVASCRIPT)) { - return prefs.javaScriptManaged(); + return WebsitePreferenceBridge.javaScriptManaged(); } else if (showSites(Type.CAMERA)) { - return !prefs.isCameraUserModifiable(); + return !WebsitePreferenceBridge.isCameraUserModifiable(); } else if (showSites(Type.MICROPHONE)) { - return !prefs.isMicUserModifiable(); + return !WebsitePreferenceBridge.isMicUserModifiable(); } else if (showSites(Type.POPUPS)) { - return prefs.isPopupsManaged(); + return WebsitePreferenceBridge.isPopupsManaged(); } return false; } @@ -300,15 +298,14 @@ * enterprise admin) of the account if the account is supervised. */ public boolean isManagedByCustodian() { - PrefServiceBridge prefs = PrefServiceBridge.getInstance(); if (showSites(Type.COOKIES)) { - return prefs.isAcceptCookiesManagedByCustodian(); + return WebsitePreferenceBridge.isAcceptCookiesManagedByCustodian(); } else if (showSites(Type.DEVICE_LOCATION)) { - return prefs.isAllowLocationManagedByCustodian(); + return WebsitePreferenceBridge.isAllowLocationManagedByCustodian(); } else if (showSites(Type.CAMERA)) { - return prefs.isCameraManagedByCustodian(); + return WebsitePreferenceBridge.isCameraManagedByCustodian(); } else if (showSites(Type.MICROPHONE)) { - return prefs.isMicManagedByCustodian(); + return WebsitePreferenceBridge.isMicManagedByCustodian(); } return false; }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferences.java index 34334840..602bd46 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferences.java
@@ -99,8 +99,6 @@ } private void updatePreferenceStates() { - PrefServiceBridge prefServiceBridge = PrefServiceBridge.getInstance(); - // Preferences that navigate to Website Settings. List<Integer> websitePrefs = new ArrayList<Integer>(); if (mMediaSubMenu) { @@ -138,7 +136,7 @@ Preference p = findPreference(prefCategory); int contentType = SiteSettingsCategory.contentSettingsType(prefCategory); boolean requiresTriStateSetting = - prefServiceBridge.requiresTriStateContentSetting(contentType); + WebsitePreferenceBridge.requiresTriStateContentSetting(contentType); boolean checked = false; @ContentSettingValues @@ -147,9 +145,9 @@ if (prefCategory == Type.DEVICE_LOCATION) { checked = LocationSettings.getInstance().areAllLocationSettingsEnabled(); } else if (requiresTriStateSetting) { - setting = prefServiceBridge.getContentSetting(contentType); + setting = WebsitePreferenceBridge.getContentSetting(contentType); } else { - checked = prefServiceBridge.isCategoryEnabled(contentType); + checked = WebsitePreferenceBridge.isCategoryEnabled(contentType); } p.setTitle(ContentSettingsResources.getTitle(contentType)); @@ -162,10 +160,10 @@ // Show 'disabled' message when permission is not granted in Android. p.setSummary(ContentSettingsResources.getCategorySummary(contentType, false)); } else if (Type.COOKIES == prefCategory && checked - && prefServiceBridge.getBoolean(Pref.BLOCK_THIRD_PARTY_COOKIES)) { + && PrefServiceBridge.getInstance().getBoolean(Pref.BLOCK_THIRD_PARTY_COOKIES)) { p.setSummary(ContentSettingsResources.getCookieAllowedExceptThirdPartySummary()); } else if (Type.DEVICE_LOCATION == prefCategory && checked - && prefServiceBridge.isLocationAllowedByPolicy()) { + && WebsitePreferenceBridge.isLocationAllowedByPolicy()) { p.setSummary(ContentSettingsResources.getGeolocationAllowedSummary()); } else if (Type.CLIPBOARD == prefCategory && !checked) { p.setSummary(ContentSettingsResources.getClipboardBlockedListSummary());
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePreferenceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePreferenceBridge.java index 281099c1..112ae8a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePreferenceBridge.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/WebsitePreferenceBridge.java
@@ -9,9 +9,9 @@ import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.NativeMethods; import org.chromium.chrome.browser.ContentSettingsType; -import org.chromium.chrome.browser.preferences.PrefServiceBridge; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -19,6 +19,18 @@ * Utility class that interacts with native to retrieve and set website settings. */ public class WebsitePreferenceBridge { + /** The android permissions associated with requesting location. */ + private static final String[] LOCATION_PERMISSIONS = { + android.Manifest.permission.ACCESS_FINE_LOCATION, + android.Manifest.permission.ACCESS_COARSE_LOCATION}; + /** The android permissions associated with requesting access to the camera. */ + private static final String[] CAMERA_PERMISSIONS = {android.Manifest.permission.CAMERA}; + /** The android permissions associated with requesting access to the microphone. */ + private static final String[] MICROPHONE_PERMISSIONS = { + android.Manifest.permission.RECORD_AUDIO}; + /** Signifies there are no permissions associated. */ + private static final String[] EMPTY_PERMISSIONS = {}; + /** * Interface for an object that listens to storage info is cleared callback. */ @@ -36,15 +48,15 @@ // Camera, Location & Microphone can be managed by the custodian // of a supervised account or by enterprise policy. if (type == PermissionInfo.Type.CAMERA) { - boolean managedOnly = !PrefServiceBridge.getInstance().isCameraUserModifiable(); + boolean managedOnly = !isCameraUserModifiable(); WebsitePreferenceBridgeJni.get().getCameraOrigins(list, managedOnly); } else if (type == PermissionInfo.Type.CLIPBOARD) { WebsitePreferenceBridgeJni.get().getClipboardOrigins(list); } else if (type == PermissionInfo.Type.GEOLOCATION) { - boolean managedOnly = !PrefServiceBridge.getInstance().isAllowLocationUserModifiable(); + boolean managedOnly = !isAllowLocationUserModifiable(); WebsitePreferenceBridgeJni.get().getGeolocationOrigins(list, managedOnly); } else if (type == PermissionInfo.Type.MICROPHONE) { - boolean managedOnly = !PrefServiceBridge.getInstance().isMicUserModifiable(); + boolean managedOnly = !isMicUserModifiable(); WebsitePreferenceBridgeJni.get().getMicrophoneOrigins(list, managedOnly); } else if (type == PermissionInfo.Type.MIDI) { WebsitePreferenceBridgeJni.get().getMidiOrigins(list); @@ -154,10 +166,10 @@ public List<ContentSettingException> getContentSettingsExceptions( @ContentSettingsType int contentSettingsType) { - List<ContentSettingException> exceptions = - PrefServiceBridge.getInstance().getContentSettingsExceptions( - contentSettingsType); - if (!PrefServiceBridge.getInstance().isContentSettingManaged(contentSettingsType)) { + List<ContentSettingException> exceptions = new ArrayList<>(); + WebsitePreferenceBridgeJni.get().getContentSettingsExceptions( + contentSettingsType, exceptions); + if (!isContentSettingManaged(contentSettingsType)) { return exceptions; } @@ -222,6 +234,293 @@ return WebsitePreferenceBridgeJni.get().getAdBlockingActivated(origin); } + /** + * Return the list of android permission strings for a given {@link ContentSettingsType}. If + * there is no permissions associated with the content setting, then an empty array is returned. + * + * @param contentSettingType The content setting to get the android permission for. + * @return The android permissions for the given content setting. + */ + @CalledByNative + public static String[] getAndroidPermissionsForContentSetting(int contentSettingType) { + switch (contentSettingType) { + case ContentSettingsType.GEOLOCATION: + return Arrays.copyOf(LOCATION_PERMISSIONS, LOCATION_PERMISSIONS.length); + case ContentSettingsType.MEDIASTREAM_MIC: + return Arrays.copyOf(MICROPHONE_PERMISSIONS, MICROPHONE_PERMISSIONS.length); + case ContentSettingsType.MEDIASTREAM_CAMERA: + return Arrays.copyOf(CAMERA_PERMISSIONS, CAMERA_PERMISSIONS.length); + default: + return EMPTY_PERMISSIONS; + } + } + + @CalledByNative + private static void addContentSettingExceptionToList(ArrayList<ContentSettingException> list, + int contentSettingsType, String pattern, int contentSetting, String source) { + ContentSettingException exception = + new ContentSettingException(contentSettingsType, pattern, contentSetting, source); + list.add(exception); + } + + /** + * Returns whether a particular content setting type is enabled. + * @param contentSettingsType The content setting type to check. + */ + public static boolean isContentSettingEnabled(int contentSettingsType) { + return WebsitePreferenceBridgeJni.get().isContentSettingEnabled(contentSettingsType); + } + + /** + * @return Whether a particular content setting type is managed by policy. + * @param contentSettingsType The content setting type to check. + */ + public static boolean isContentSettingManaged(int contentSettingsType) { + return WebsitePreferenceBridgeJni.get().isContentSettingManaged(contentSettingsType); + } + + /** + * Sets a default value for content setting type. + * @param contentSettingsType The content setting type to check. + * @param enabled Whether the default value should be disabled or enabled. + */ + public static void setContentSettingEnabled(int contentSettingsType, boolean enabled) { + WebsitePreferenceBridgeJni.get().setContentSettingEnabled(contentSettingsType, enabled); + } + + /** + * @return Whether JavaScript is managed by policy. + */ + public static boolean javaScriptManaged() { + return isContentSettingManaged(ContentSettingsType.JAVASCRIPT); + } + + /** + * @return true if background sync is managed by policy. + */ + public static boolean isBackgroundSyncManaged() { + return isContentSettingManaged(ContentSettingsType.BACKGROUND_SYNC); + } + + /** + * @return true if automatic downloads is managed by policy. + */ + public static boolean isAutomaticDownloadsManaged() { + return isContentSettingManaged(ContentSettingsType.AUTOMATIC_DOWNLOADS); + } + + /** + * @return Whether the setting to allow popups is configured by policy + */ + public static boolean isPopupsManaged() { + return isContentSettingManaged(ContentSettingsType.POPUPS); + } + + /** + * Whether the setting type requires tri-state (Allowed/Ask/Blocked) setting. + */ + public static boolean requiresTriStateContentSetting(int contentSettingsType) { + switch (contentSettingsType) { + case ContentSettingsType.PROTECTED_MEDIA_IDENTIFIER: + return true; + default: + return false; + } + } + + /** + * Sets the preferences on whether to enable/disable given setting. + */ + public static void setCategoryEnabled(int contentSettingsType, boolean allow) { + assert !requiresTriStateContentSetting(contentSettingsType); + + switch (contentSettingsType) { + case ContentSettingsType.ADS: + case ContentSettingsType.BLUETOOTH_SCANNING: + case ContentSettingsType.JAVASCRIPT: + case ContentSettingsType.POPUPS: + case ContentSettingsType.USB_GUARD: + setContentSettingEnabled(contentSettingsType, allow); + break; + case ContentSettingsType.AUTOMATIC_DOWNLOADS: + WebsitePreferenceBridgeJni.get().setAutomaticDownloadsEnabled(allow); + break; + case ContentSettingsType.AUTOPLAY: + WebsitePreferenceBridgeJni.get().setAutoplayEnabled(allow); + break; + case ContentSettingsType.BACKGROUND_SYNC: + WebsitePreferenceBridgeJni.get().setBackgroundSyncEnabled(allow); + break; + case ContentSettingsType.CLIPBOARD_READ: + WebsitePreferenceBridgeJni.get().setClipboardEnabled(allow); + break; + case ContentSettingsType.COOKIES: + WebsitePreferenceBridgeJni.get().setAllowCookiesEnabled(allow); + break; + case ContentSettingsType.GEOLOCATION: + WebsitePreferenceBridgeJni.get().setAllowLocationEnabled(allow); + break; + case ContentSettingsType.MEDIASTREAM_CAMERA: + WebsitePreferenceBridgeJni.get().setCameraEnabled(allow); + break; + case ContentSettingsType.MEDIASTREAM_MIC: + WebsitePreferenceBridgeJni.get().setMicEnabled(allow); + break; + case ContentSettingsType.NFC: + WebsitePreferenceBridgeJni.get().setNfcEnabled(allow); + break; + case ContentSettingsType.NOTIFICATIONS: + WebsitePreferenceBridgeJni.get().setNotificationsEnabled(allow); + break; + case ContentSettingsType.SENSORS: + WebsitePreferenceBridgeJni.get().setSensorsEnabled(allow); + break; + case ContentSettingsType.SOUND: + WebsitePreferenceBridgeJni.get().setSoundEnabled(allow); + break; + default: + assert false; + } + } + + public static boolean isCategoryEnabled(int contentSettingsType) { + assert !requiresTriStateContentSetting(contentSettingsType); + + switch (contentSettingsType) { + case ContentSettingsType.ADS: + case ContentSettingsType.CLIPBOARD_READ: + // Returns true if JavaScript is enabled. It may return the temporary value set by + // {@link #setJavaScriptEnabled}. The default is true. + case ContentSettingsType.JAVASCRIPT: + case ContentSettingsType.POPUPS: + // Returns true if websites are allowed to request permission to access USB devices. + case ContentSettingsType.USB_GUARD: + case ContentSettingsType.BLUETOOTH_SCANNING: + return isContentSettingEnabled(contentSettingsType); + case ContentSettingsType.AUTOMATIC_DOWNLOADS: + return WebsitePreferenceBridgeJni.get().getAutomaticDownloadsEnabled(); + case ContentSettingsType.AUTOPLAY: + return WebsitePreferenceBridgeJni.get().getAutoplayEnabled(); + case ContentSettingsType.BACKGROUND_SYNC: + return WebsitePreferenceBridgeJni.get().getBackgroundSyncEnabled(); + case ContentSettingsType.COOKIES: + return WebsitePreferenceBridgeJni.get().getAcceptCookiesEnabled(); + case ContentSettingsType.MEDIASTREAM_CAMERA: + return WebsitePreferenceBridgeJni.get().getCameraEnabled(); + case ContentSettingsType.MEDIASTREAM_MIC: + return WebsitePreferenceBridgeJni.get().getMicEnabled(); + case ContentSettingsType.NFC: + return WebsitePreferenceBridgeJni.get().getNfcEnabled(); + case ContentSettingsType.NOTIFICATIONS: + return WebsitePreferenceBridgeJni.get().getNotificationsEnabled(); + case ContentSettingsType.SENSORS: + return WebsitePreferenceBridgeJni.get().getSensorsEnabled(); + case ContentSettingsType.SOUND: + return WebsitePreferenceBridgeJni.get().getSoundEnabled(); + default: + assert false; + return false; + } + } + + /** + * Gets the ContentSetting for a settings type. Should only be used for more + * complex settings where a binary on/off value is not sufficient. + * Otherwise, use isCategoryEnabled() above. + * @param contentSettingsType The settings type to get setting for. + * @return The ContentSetting for |contentSettingsType|. + */ + public static int getContentSetting(int contentSettingsType) { + return WebsitePreferenceBridgeJni.get().getContentSetting(contentSettingsType); + } + + /** + * @param setting New ContentSetting to set for |contentSettingsType|. + */ + public static void setContentSetting(int contentSettingsType, int setting) { + WebsitePreferenceBridgeJni.get().setContentSetting(contentSettingsType, setting); + } + + /** + * @return Whether cookies acceptance is modifiable by the user + */ + public static boolean isAcceptCookiesUserModifiable() { + return WebsitePreferenceBridgeJni.get().getAcceptCookiesUserModifiable(); + } + + /** + * @return Whether cookies acceptance is configured by the user's custodian + * (for supervised users). + */ + public static boolean isAcceptCookiesManagedByCustodian() { + return WebsitePreferenceBridgeJni.get().getAcceptCookiesManagedByCustodian(); + } + + /** + * @return Whether geolocation information can be shared with content. + */ + public static boolean isAllowLocationEnabled() { + return WebsitePreferenceBridgeJni.get().getAllowLocationEnabled(); + } + + /** + * @return Whether geolocation information access is set to be shared with all sites, by policy. + */ + public static boolean isLocationAllowedByPolicy() { + return WebsitePreferenceBridgeJni.get().getLocationAllowedByPolicy(); + } + + /** + * @return Whether the location preference is modifiable by the user. + */ + public static boolean isAllowLocationUserModifiable() { + return WebsitePreferenceBridgeJni.get().getAllowLocationUserModifiable(); + } + + /** + * @return Whether the location preference is + * being managed by the custodian of the supervised account. + */ + public static boolean isAllowLocationManagedByCustodian() { + return WebsitePreferenceBridgeJni.get().getAllowLocationManagedByCustodian(); + } + + /** + * @return Whether the camera/microphone permission is managed + * by the custodian of the supervised account. + */ + public static boolean isCameraManagedByCustodian() { + return WebsitePreferenceBridgeJni.get().getCameraManagedByCustodian(); + } + + /** + * @return Whether the camera permission is editable by the user. + */ + public static boolean isCameraUserModifiable() { + return WebsitePreferenceBridgeJni.get().getCameraUserModifiable(); + } + + /** + * @return Whether the microphone permission is managed by the custodian of + * the supervised account. + */ + public static boolean isMicManagedByCustodian() { + return WebsitePreferenceBridgeJni.get().getMicManagedByCustodian(); + } + + /** + * @return Whether the microphone permission is editable by the user. + */ + public static boolean isMicUserModifiable() { + return WebsitePreferenceBridgeJni.get().getMicUserModifiable(); + } + + public static void setContentSettingForPattern( + int contentSettingType, String pattern, int setting) { + WebsitePreferenceBridgeJni.get().setContentSettingForPattern( + contentSettingType, pattern, setting); + } + @VisibleForTesting @NativeMethods public interface Natives { @@ -233,6 +532,7 @@ void getNotificationOrigins(Object list); void getNfcOrigins(Object list); void getProtectedMediaIdentifierOrigins(Object list); + boolean getNfcEnabled(); void getSensorsOrigins(Object list); int getCameraSettingForOrigin(String origin, String embedder, boolean isIncognito); int getClipboardSettingForOrigin(String origin, boolean isIncognito); @@ -275,5 +575,44 @@ boolean isPermissionControlledByDSE( @ContentSettingsType int contentSettingsType, String origin, boolean isIncognito); boolean getAdBlockingActivated(String origin); + boolean isContentSettingEnabled(int contentSettingType); + boolean isContentSettingManaged(int contentSettingType); + void setContentSettingEnabled(int contentSettingType, boolean allow); + void getContentSettingsExceptions( + int contentSettingsType, List<ContentSettingException> list); + void setContentSettingForPattern(int contentSettingType, String pattern, int setting); + int getContentSetting(int contentSettingType); + void setContentSetting(int contentSettingType, int setting); + boolean getAcceptCookiesEnabled(); + boolean getAcceptCookiesUserModifiable(); + boolean getAcceptCookiesManagedByCustodian(); + boolean getAutomaticDownloadsEnabled(); + boolean getAutoplayEnabled(); + boolean getBackgroundSyncEnabled(); + boolean getAllowLocationUserModifiable(); + boolean getLocationAllowedByPolicy(); + boolean getAllowLocationManagedByCustodian(); + boolean getCameraEnabled(); + void setCameraEnabled(boolean enabled); + boolean getCameraUserModifiable(); + boolean getCameraManagedByCustodian(); + boolean getMicEnabled(); + void setMicEnabled(boolean enabled); + boolean getMicUserModifiable(); + boolean getMicManagedByCustodian(); + boolean getSensorsEnabled(); + boolean getSoundEnabled(); + void setAutomaticDownloadsEnabled(boolean enabled); + void setAutoplayEnabled(boolean enabled); + void setAllowCookiesEnabled(boolean enabled); + void setBackgroundSyncEnabled(boolean enabled); + void setClipboardEnabled(boolean enabled); + boolean getAllowLocationEnabled(); + boolean getNotificationsEnabled(); + void setAllowLocationEnabled(boolean enabled); + void setNotificationsEnabled(boolean enabled); + void setNfcEnabled(boolean enabled); + void setSensorsEnabled(boolean enabled); + void setSoundEnabled(boolean enabled); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ssl/SecurityStateModel.java b/chrome/android/java/src/org/chromium/chrome/browser/ssl/SecurityStateModel.java index 7915c8b..7c0477a 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/ssl/SecurityStateModel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/ssl/SecurityStateModel.java
@@ -25,10 +25,33 @@ return SecurityStateModelJni.get().getSecurityLevelForWebContents(webContents); } + /** + * Returns true for a valid URL from a secure origin, e.g., http://localhost, + * file:///home/user/test.html, https://bobpay.com. + * + * @param url The URL to check. + * @return Whether the origin of the URL is secure. + */ + public static boolean isOriginSecure(String url) { + return SecurityStateModelJni.get().isOriginSecure(url); + } + + /** + * Returns true for a valid URL with a cryptographic scheme, e.g., HTTPS, WSS. + * + * @param url The URL to check. + * @return Whether the scheme of the URL is cryptographic. + */ + public static boolean isSchemeCryptographic(String url) { + return SecurityStateModelJni.get().isSchemeCryptographic(url); + } + private SecurityStateModel() {} @NativeMethods interface Natives { int getSecurityLevelForWebContents(WebContents webContents); + boolean isOriginSecure(String url); + boolean isSchemeCryptographic(String url); } }
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java index 02fdfe79..598f3a7 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/LocationBarModel.java
@@ -20,6 +20,7 @@ import org.chromium.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior; import org.chromium.chrome.browser.dom_distiller.DomDistillerTabUtils; +import org.chromium.chrome.browser.flags.FeatureUtilities; import org.chromium.chrome.browser.native_page.NativePageFactory; import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; @@ -28,6 +29,7 @@ import org.chromium.chrome.browser.omnibox.UrlBarData; import org.chromium.chrome.browser.previews.PreviewsAndroidBridge; import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.TrustedCdn; import org.chromium.chrome.browser.ui.styles.ChromeColors; @@ -388,14 +390,30 @@ return R.drawable.ic_offline_pin_24dp; } + boolean featureIsEnabled = FeatureUtilities.isMarkHttpAsDangerWarningEnabled(); + String url = getCurrentUrl(); + switch (securityLevel) { case ConnectionSecurityLevel.NONE: + // For HTTPS sites with passive mixed content, ConnectionSecurityLevel + // is NONE, but the security indicator should be shown on all devices. + if (mNativeLocationBarModelAndroid != 0 + && SecurityStateModel.isSchemeCryptographic(url)) { + return featureIsEnabled ? R.drawable.omnibox_not_secure_warning + : R.drawable.omnibox_info; + } return isSmallDevice && (!SearchEngineLogoUtils.shouldShowSearchEngineLogo(isIncognito()) || getNewTabPageForCurrentTab() != null) ? 0 : R.drawable.omnibox_info; case ConnectionSecurityLevel.WARNING: + if (mNativeLocationBarModelAndroid == 0) { + return R.drawable.omnibox_info; + } + if (featureIsEnabled && !SecurityStateModel.isOriginSecure(url)) { + return R.drawable.omnibox_not_secure_warning; + } return R.drawable.omnibox_info; case ConnectionSecurityLevel.DANGEROUS: return R.drawable.omnibox_not_secure_warning;
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialogTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialogTest.java index 7fc5bb78..5a59644 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialogTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/contacts_picker/ContactsPickerDialogTest.java
@@ -125,18 +125,30 @@ return (RecyclerView) mDialog.findViewById(R.id.recycler_view); } + /** + * Creates a ContactPicker dialog with no filtering (default case). For a more fine-grained + * version, see below. + */ + private ContactsPickerDialog createDialog(final boolean multiselect) throws Exception { + return createDialog(multiselect, /* includeNames = */ true, + /* includeEmails = */ true, + /* includeTel = */ true, + /* includeAddresses = */ true, + /* includeIcons = */ true); + } + private ContactsPickerDialog createDialog(final boolean multiselect, final boolean includeNames, - final boolean includeEmails, final boolean includeTel, final boolean includeAddresses) - throws Exception { + final boolean includeEmails, final boolean includeTel, final boolean includeAddresses, + final boolean includeIcons) throws Exception { mClosing = false; final ContactsPickerDialog dialog = TestThreadUtils.runOnUiThreadBlocking(new Callable<ContactsPickerDialog>() { @Override public ContactsPickerDialog call() { - final ContactsPickerDialog dialog = - new ContactsPickerDialog(mActivityTestRule.getActivity(), - ContactsPickerDialogTest.this, multiselect, includeNames, - includeEmails, includeTel, includeAddresses, "example.com"); + final ContactsPickerDialog dialog = new ContactsPickerDialog( + mActivityTestRule.getActivity(), ContactsPickerDialogTest.this, + multiselect, includeNames, includeEmails, includeTel, + includeAddresses, includeIcons, "example.com"); dialog.show(); return dialog; } @@ -325,10 +337,7 @@ @LargeTest public void testOriginString() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ true, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ true); Assert.assertTrue(mDialog.isShowing()); TopView topView = getTopView(); @@ -349,7 +358,8 @@ createDialog(/* multiselect = */ false, /* includeNames = */ true, /* includeEmails = */ false, /* includeTel = */ true, - /* includeAddresses = */ false); + /* includeAddresses = */ false, + /* includeIcons = */ true); Assert.assertTrue(mDialog.isShowing()); TopView topView = getTopView(); @@ -363,6 +373,8 @@ Assert.assertNotNull(telFilter); View addrFilter = topView.findViewById(R.id.address_filter); Assert.assertNotNull(addrFilter); + View iconFilter = topView.findViewById(R.id.icon_filter); + Assert.assertNotNull(iconFilter); // Per configuration given in the createDialog() call, the names and telephone filters // should be visible, but the e-mail and address filter should be gone. @@ -370,6 +382,7 @@ Assert.assertEquals(emailFilter.getVisibility(), View.GONE); Assert.assertEquals(telFilter.getVisibility(), View.VISIBLE); Assert.assertEquals(addrFilter.getVisibility(), View.GONE); + Assert.assertEquals(iconFilter.getVisibility(), View.VISIBLE); } @Test @@ -379,7 +392,8 @@ createDialog(/* multiselect = */ false, /* includeNames = */ false, /* includeEmails = */ true, /* includeTel = */ false, - /* includeAddresses = */ true); + /* includeAddresses = */ true, + /* includeIcons = */ false); Assert.assertTrue(mDialog.isShowing()); TopView topView = getTopView(); @@ -393,6 +407,8 @@ Assert.assertNotNull(telFilter); View addrFilter = topView.findViewById(R.id.address_filter); Assert.assertNotNull(addrFilter); + View iconFilter = topView.findViewById(R.id.icon_filter); + Assert.assertNotNull(iconFilter); // Per configuration given in the createDialog() call, the names and telephone filters // should be hidden, but the e-mail and address filter should be visible. @@ -400,16 +416,14 @@ Assert.assertEquals(emailFilter.getVisibility(), View.VISIBLE); Assert.assertEquals(telFilter.getVisibility(), View.GONE); Assert.assertEquals(addrFilter.getVisibility(), View.VISIBLE); + Assert.assertEquals(iconFilter.getVisibility(), View.GONE); } @Test @LargeTest public void testNoSelection() throws Throwable { setTestContacts(/*ownerEmail=*/"notanowner@example.com"); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); int expectedSelectionCount = 1; @@ -418,7 +432,7 @@ Assert.assertEquals(null, mLastSelectedContacts); Assert.assertEquals(0, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); Assert.assertEquals(ContactsPickerAction.CANCEL, mLastActionRecorded); } @@ -426,10 +440,7 @@ @LargeTest public void testOwnerContact() throws Throwable { setTestContacts(/*ownerEmail=*/"owner@example.com"); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); int expectedSelectionCount = 1; @@ -441,17 +452,14 @@ Assert.assertEquals( mTestContacts.get(0).getDisplayName(), mLastSelectedContacts.get(0).names.get(0)); Assert.assertEquals(12, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testSingleSelectionContacts() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); // Expected selection count is 1 because clicking on a new view deselects other. @@ -465,17 +473,14 @@ Assert.assertEquals( mTestContacts.get(1).getDisplayName(), mLastSelectedContacts.get(0).names.get(0)); Assert.assertEquals(16, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testMultiSelectionContacts() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ true, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ true); Assert.assertTrue(mDialog.isShowing()); // Multi-selection is enabled, so each click is counted. @@ -494,17 +499,14 @@ Assert.assertEquals( mTestContacts.get(0).getDisplayName(), mLastSelectedContacts.get(2).names.get(0)); Assert.assertEquals(50, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testNamesRemoved() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); toggleFilter(PickerAdapter.FilterType.NAMES); @@ -531,17 +533,14 @@ Assert.assertEquals(selectedAddress.region, testAddress.region); Assert.assertEquals(16, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testEmailsRemoved() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); toggleFilter(PickerAdapter.FilterType.EMAILS); @@ -556,17 +555,14 @@ mTestContacts.get(0).getDisplayName(), mLastSelectedContacts.get(0).names.get(0)); Assert.assertEquals(new ArrayList<String>(), mLastSelectedContacts.get(0).emails); Assert.assertEquals(16, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testTelephonesRemoved() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); toggleFilter(PickerAdapter.FilterType.TELEPHONES); @@ -581,9 +577,12 @@ mTestContacts.get(0).getDisplayName(), mLastSelectedContacts.get(0).names.get(0)); Assert.assertEquals(new ArrayList<String>(), mLastSelectedContacts.get(0).tel); Assert.assertEquals(16, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } + // TODO(crbug.com/1020564): Add a test (once icons have been implemented end-to-end) that + // validates that icons are not returned when the filter chip is off. + @Test @LargeTest public void testPropertiesRequested() throws Throwable { @@ -592,7 +591,8 @@ createDialog(/* multiselect = */ false, /* includeNames = */ true, /* includeEmails = */ false, /* includeTel = */ false, - /* includeAddresses = */ false); + /* includeAddresses = */ false, + /* includeIcons = */ false); Assert.assertTrue(mDialog.isShowing()); clickCancel(); Assert.assertEquals(4, mLastPropertiesRequested); @@ -601,7 +601,8 @@ createDialog(/* multiselect = */ false, /* includeNames = */ false, /* includeEmails = */ true, /* includeTel = */ false, - /* includeAddresses = */ false); + /* includeAddresses = */ false, + /* includeIcons = */ false); Assert.assertTrue(mDialog.isShowing()); clickCancel(); Assert.assertEquals(2, mLastPropertiesRequested); @@ -610,7 +611,8 @@ createDialog(/* multiselect = */ false, /* includeNames = */ false, /* includeEmails = */ false, /* includeTel = */ true, - /* includeAddresses = */ false); + /* includeAddresses = */ false, + /* includeIcons = */ false); Assert.assertTrue(mDialog.isShowing()); clickCancel(); Assert.assertEquals(1, mLastPropertiesRequested); @@ -619,20 +621,28 @@ createDialog(/* multiselect = */ false, /* includeNames = */ false, /* includeEmails = */ false, /* includeTel = */ false, - /* includeAddresses = */ true); + /* includeAddresses = */ true, + /* includeIcons = */ false); Assert.assertTrue(mDialog.isShowing()); clickCancel(); Assert.assertEquals(8, mLastPropertiesRequested); + + // Create a dialog showing icons only. + createDialog(/* multiselect = */ false, /* includeNames = */ false, + /* includeEmails = */ false, + /* includeTel = */ false, + /* includeAddresses = */ false, + /* includeIcons = */ true); + Assert.assertTrue(mDialog.isShowing()); + clickCancel(); + Assert.assertEquals(16, mLastPropertiesRequested); } @Test @LargeTest public void testSelectAll() throws Throwable { setTestContacts(/*ownerEmail=*/"owner@example.com"); - createDialog(/* multiselect = */ true, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ true); Assert.assertTrue(mDialog.isShowing()); toggleSelectAll(8, ContactsPickerAction.SELECT_ALL); @@ -662,10 +672,7 @@ @LargeTest public void testSearchString() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ false, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ false); Assert.assertTrue(mDialog.isShowing()); clickSearchButton(); @@ -682,17 +689,14 @@ Assert.assertEquals( mTestContacts.get(3).getDisplayName(), mLastSelectedContacts.get(0).names.get(0)); Assert.assertEquals(16, mLastPercentageShared); - Assert.assertEquals(15, mLastPropertiesRequested); + Assert.assertEquals(31, mLastPropertiesRequested); } @Test @LargeTest public void testNoSearchStringNoCrash() throws Throwable { setTestContacts(/*ownerEmail=*/null); - createDialog(/* multiselect = */ true, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ true); Assert.assertTrue(mDialog.isShowing()); clickSearchButton(); @@ -704,10 +708,7 @@ public void testEmptyContactListCrash() throws Throwable { PickerAdapter.setTestContactsAndOwner(new ArrayList<ContactDetails>(), null); - createDialog(/* multiselect = */ true, /* includeNames = */ true, - /* includeEmails = */ true, - /* includeTel = */ true, - /* includeAddresses = */ true); + createDialog(/* multiselect = */ true); Assert.assertTrue(mDialog.isShowing()); dismissDialog();
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/NotificationsPreferencesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/NotificationsPreferencesTest.java index 565c7c7e..bc878a9 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/NotificationsPreferencesTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/NotificationsPreferencesTest.java
@@ -26,6 +26,7 @@ import org.chromium.chrome.browser.preferences.website.ContentSettingsResources; import org.chromium.chrome.browser.preferences.website.SingleCategoryPreferences; import org.chromium.chrome.browser.preferences.website.SiteSettingsCategory; +import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; import org.chromium.chrome.browser.test.ScreenShooter; import org.chromium.chrome.test.ChromeBrowserTestRule; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; @@ -155,13 +156,11 @@ fragment.findPreference(NotificationsPreferences.PREF_FROM_WEBSITES); TestThreadUtils.runOnUiThreadBlocking(() -> { - PrefServiceBridge.getInstance().setCategoryEnabled( - ContentSettingsType.NOTIFICATIONS, false); + WebsitePreferenceBridge.setCategoryEnabled(ContentSettingsType.NOTIFICATIONS, false); fragment.onResume(); Assert.assertEquals(fromWebsites.getSummary(), getNotificationsSummary(false)); - PrefServiceBridge.getInstance().setCategoryEnabled( - ContentSettingsType.NOTIFICATIONS, true); + WebsitePreferenceBridge.setCategoryEnabled(ContentSettingsType.NOTIFICATIONS, true); fragment.onResume(); Assert.assertEquals(fromWebsites.getSummary(), getNotificationsSummary(true)); });
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferencesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferencesTest.java index b948eca..ef3ba0f 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferencesTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/preferences/website/SiteSettingsPreferencesTest.java
@@ -169,8 +169,7 @@ } private boolean doesAcceptCookies() { - return PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.COOKIES); + return WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.COOKIES); } }); } @@ -212,7 +211,7 @@ TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals("Popups should be " + (enabled ? "allowed" : "blocked"), enabled, - PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.POPUPS)); + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.POPUPS)); }); } @@ -221,7 +220,7 @@ TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals("Camera should be " + (enabled ? "allowed" : "blocked"), enabled, - PrefServiceBridge.getInstance().isCategoryEnabled( + WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.MEDIASTREAM_CAMERA)); }); } @@ -586,8 +585,7 @@ TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertFalse("Mic should be blocked", - PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.MEDIASTREAM_MIC)); + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.MEDIASTREAM_MIC)); }); // Test that the microphone permission doesn't get requested. @@ -659,8 +657,7 @@ setGlobalToggleForCategory(SiteSettingsCategory.Type.BACKGROUND_SYNC, enabled); TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals("Background Sync should be " + (enabled ? "enabled" : "disabled"), - PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.BACKGROUND_SYNC), + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.BACKGROUND_SYNC), enabled); }); } @@ -687,8 +684,7 @@ setGlobalToggleForCategory(SiteSettingsCategory.Type.USB, enabled); TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals("USB should be " + (enabled ? "enabled" : "disabled"), - PrefServiceBridge.getInstance().isCategoryEnabled( - ContentSettingsType.USB_GUARD), + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.USB_GUARD), enabled); }); } @@ -717,7 +713,7 @@ TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals( "Automatic Downloads should be " + (enabled ? "enabled" : "disabled"), - PrefServiceBridge.getInstance().isCategoryEnabled( + WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.AUTOMATIC_DOWNLOADS), enabled); }); @@ -747,7 +743,7 @@ TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals( "Bluetooth scanning should be " + (enabled ? "enabled" : "disabled"), - PrefServiceBridge.getInstance().isCategoryEnabled( + WebsitePreferenceBridge.isCategoryEnabled( ContentSettingsType.BLUETOOTH_SCANNING), enabled); }); @@ -776,8 +772,7 @@ setGlobalToggleForCategory(SiteSettingsCategory.Type.NFC, enabled); TestThreadUtils.runOnUiThreadBlocking(() -> { Assert.assertEquals("NFC should be " + (enabled ? "enabled" : "disabled"), - PrefServiceBridge.getInstance().isCategoryEnabled(ContentSettingsType.NFC), - enabled); + WebsitePreferenceBridge.isCategoryEnabled(ContentSettingsType.NFC), enabled); }); }
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java index ea367226..f9336b7 100644 --- a/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java +++ b/chrome/android/junit/src/org/chromium/chrome/browser/toolbar/ToolbarSecurityIconTest.java
@@ -4,22 +4,31 @@ package org.chromium.chrome.browser.toolbar; import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; +import org.junit.After; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.robolectric.annotation.Config; +import org.robolectric.annotation.Implementation; +import org.robolectric.annotation.Implements; +import org.robolectric.annotation.Resetter; import org.chromium.base.test.BaseRobolectricTestRunner; +import org.chromium.base.test.util.JniMocker; import org.chromium.chrome.R; +import org.chromium.chrome.browser.flags.FeatureUtilities; import org.chromium.chrome.browser.omnibox.LocationBarLayout; +import org.chromium.chrome.browser.ssl.SecurityStateModel; import org.chromium.chrome.browser.tab.Tab; import org.chromium.components.security_state.ConnectionSecurityLevel; @@ -27,7 +36,7 @@ * Unit tests for {@link LocationBarLayout} class. */ @RunWith(BaseRobolectricTestRunner.class) -@Config(manifest = Config.NONE) +@Config(manifest = Config.NONE, shadows = {ToolbarSecurityIconTest.ShadowSecurityStateModel.class}) public final class ToolbarSecurityIconTest { private static final boolean IS_SMALL_DEVICE = true; private static final boolean IS_OFFLINE_PAGE = true; @@ -35,6 +44,10 @@ private static final int[] SECURITY_LEVELS = new int[] {ConnectionSecurityLevel.NONE, ConnectionSecurityLevel.WARNING, ConnectionSecurityLevel.DANGEROUS, ConnectionSecurityLevel.SECURE, ConnectionSecurityLevel.EV_SECURE}; + private static final long NATIVE_PTR = 1; + + @Rule + public JniMocker mocker = new JniMocker(); @Mock private Tab mTab; @@ -42,14 +55,55 @@ private Context mContext; @Mock private Resources mResources; + @Mock + LocationBarModel.Natives mNativeMocks; private LocationBarModel mLocationBarModel; + @Implements(SecurityStateModel.class) + static class ShadowSecurityStateModel { + private static boolean sSchemeIsCryptographic; + private static boolean sOriginIsSecure; + + @Resetter + public static void reset() { + sSchemeIsCryptographic = false; + sOriginIsSecure = false; + } + + @Implementation + public static boolean isSchemeCryptographic(String url) { + return sSchemeIsCryptographic; + } + + @Implementation + public static boolean isOriginSecure(String url) { + return sOriginIsSecure; + } + + public static void setSchemeIsCryptographic(boolean schemeIsCryptographicValue) { + sSchemeIsCryptographic = schemeIsCryptographicValue; + } + + public static void setOriginIsSecure(boolean originIsSecureValue) { + sOriginIsSecure = originIsSecureValue; + } + } + @Before public void setUp() { MockitoAnnotations.initMocks(this); + mocker.mock(LocationBarModelJni.TEST_HOOKS, mNativeMocks); doReturn(mResources).when(mContext).getResources(); + when(mNativeMocks.init(any())).thenReturn(NATIVE_PTR); mLocationBarModel = new LocationBarModel(mContext); + mLocationBarModel.initializeWithNative(); + } + + @After + public void tearDown() { + ShadowSecurityStateModel.reset(); + FeatureUtilities.setMarkHttpAsDangerWarningEnabledForTesting(null); } @Test @@ -109,6 +163,15 @@ mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + // Tests passive mixed content. + ShadowSecurityStateModel.setSchemeIsCryptographic(true); + assertEquals(R.drawable.omnibox_info, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_info, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_info, mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); @@ -146,4 +209,43 @@ mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.EV_SECURE, !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); } + + @Test + public void testGetSecurityIconResourceForMarkHttpAsDangerWarning() { + FeatureUtilities.setMarkHttpAsDangerWarningEnabledForTesting(true); + + assertEquals(0, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_info, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + + // Tests passive mixed content. + ShadowSecurityStateModel.setSchemeIsCryptographic(true); + assertEquals(R.drawable.omnibox_not_secure_warning, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_not_secure_warning, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.NONE, + !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + + // Tests non-secure connection (e.g. HTTP). + ShadowSecurityStateModel.setSchemeIsCryptographic(false); + assertEquals(R.drawable.omnibox_not_secure_warning, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, + IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_not_secure_warning, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, + !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + + // Tests non-cryptographic secure origins. + ShadowSecurityStateModel.setOriginIsSecure(true); + assertEquals(R.drawable.omnibox_info, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, + IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + assertEquals(R.drawable.omnibox_info, + mLocationBarModel.getSecurityIconResource(ConnectionSecurityLevel.WARNING, + !IS_SMALL_DEVICE, !IS_OFFLINE_PAGE, !IS_PREVIEW)); + } }
diff --git a/chrome/android/profiles/newest.txt b/chrome/android/profiles/newest.txt index b50f8bbf..e229b28b 100644 --- a/chrome/android/profiles/newest.txt +++ b/chrome/android/profiles/newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-80.0.3961.0_rc-r1-merged.afdo.bz2 \ No newline at end of file +chromeos-chrome-amd64-80.0.3964.0_rc-r1-merged.afdo.bz2 \ No newline at end of file
diff --git a/chrome/app/chrome_content_browser_overlay_manifest.cc b/chrome/app/chrome_content_browser_overlay_manifest.cc index 20e3d67..962f55c6 100644 --- a/chrome/app/chrome_content_browser_overlay_manifest.cc +++ b/chrome/app/chrome_content_browser_overlay_manifest.cc
@@ -69,7 +69,6 @@ #endif #if BUILDFLAG(ENABLE_EXTENSIONS) -#include "extensions/common/api/mime_handler.mojom.h" // nogncheck #include "extensions/common/mojom/keep_alive.mojom.h" // nogncheck #endif @@ -158,7 +157,6 @@ contextual_search::mojom::ContextualSearchJsApiService, #if BUILDFLAG(ENABLE_EXTENSIONS) extensions::KeepAlive, - extensions::mime_handler::BeforeUnloadControl, #endif media::mojom::MediaEngagementScoreDetailsProvider, media_router::mojom::MediaRouter,
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn index 6abcb3c9..51db56c7 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn
@@ -2554,6 +2554,7 @@ "android/preferences/preferences_launcher.h", "android/preferences/prefs.h", "android/preferences/website_preference_bridge.cc", + "android/preferences/website_preference_bridge.h", "android/profile_key_startup_accessor.cc", "android/profile_key_startup_accessor.h", "android/profile_key_util.cc",
diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc index d26a328..5a0ec00 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.cc +++ b/chrome/browser/android/preferences/pref_service_bridge.cc
@@ -27,22 +27,17 @@ #include "chrome/android/chrome_jni_headers/PrefServiceBridge_jni.h" #include "chrome/browser/android/preferences/prefs.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/content_settings/host_content_settings_map_factory.h" #include "chrome/browser/net/prediction_options.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/common/chrome_features.h" #include "chrome/common/pref_names.h" -#include "components/content_settings/core/browser/host_content_settings_map.h" -#include "components/content_settings/core/common/content_settings.h" -#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/metrics/metrics_pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/prefs/pref_service.h" #include "components/web_resource/web_resource_pref_names.h" #include "content/public/browser/browser_thread.h" -using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF8; using base::android::ConvertUTF8ToJavaString; using base::android::JavaParamRef; @@ -51,56 +46,10 @@ namespace { -Profile* GetOriginalProfile() { - return ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); -} - -bool GetBooleanForContentSetting(ContentSettingsType type) { - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - switch (content_settings->GetDefaultContentSetting(type, NULL)) { - case CONTENT_SETTING_BLOCK: - return false; - case CONTENT_SETTING_ALLOW: - case CONTENT_SETTING_ASK: - default: - return true; - } -} - -bool IsContentSettingManaged(ContentSettingsType content_settings_type) { - std::string source; - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - content_settings->GetDefaultContentSetting(content_settings_type, &source); - HostContentSettingsMap::ProviderType provider = - content_settings->GetProviderTypeFromSource(source); - return provider == HostContentSettingsMap::POLICY_PROVIDER; -} - -bool IsContentSettingManagedByCustodian( - ContentSettingsType content_settings_type) { - std::string source; - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - content_settings->GetDefaultContentSetting(content_settings_type, &source); - HostContentSettingsMap::ProviderType provider = - content_settings->GetProviderTypeFromSource(source); - return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; -} - -bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { - std::string source; - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - content_settings->GetDefaultContentSetting(content_settings_type, &source); - HostContentSettingsMap::ProviderType provider = - content_settings->GetProviderTypeFromSource(source); - return provider >= HostContentSettingsMap::PREF_PROVIDER; -} - PrefService* GetPrefService() { - return GetOriginalProfile()->GetPrefs(); + return ProfileManager::GetActiveUserProfile() + ->GetOriginalProfile() + ->GetPrefs(); } } // namespace @@ -160,150 +109,6 @@ PrefServiceBridge::GetPrefNameExposedToJava(j_pref_index)); } -static jboolean JNI_PrefServiceBridge_IsContentSettingManaged( - JNIEnv* env, - int content_settings_type) { - return IsContentSettingManaged( - static_cast<ContentSettingsType>(content_settings_type)); -} - -static jboolean JNI_PrefServiceBridge_IsContentSettingEnabled( - JNIEnv* env, - int content_settings_type) { - ContentSettingsType type = - static_cast<ContentSettingsType>(content_settings_type); - // Before we migrate functions over to this central function, we must verify - // that the functionality provided below is correct. - DCHECK(type == ContentSettingsType::JAVASCRIPT || - type == ContentSettingsType::POPUPS || - type == ContentSettingsType::ADS || - type == ContentSettingsType::CLIPBOARD_READ || - type == ContentSettingsType::USB_GUARD || - type == ContentSettingsType::BLUETOOTH_SCANNING); - return GetBooleanForContentSetting(type); -} - -static void JNI_PrefServiceBridge_SetContentSettingEnabled( - JNIEnv* env, - int content_settings_type, - jboolean allow) { - ContentSettingsType type = - static_cast<ContentSettingsType>(content_settings_type); - - // Before we migrate functions over to this central function, we must verify - // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. - DCHECK(type == ContentSettingsType::JAVASCRIPT || - type == ContentSettingsType::POPUPS || - type == ContentSettingsType::ADS || - type == ContentSettingsType::USB_GUARD || - type == ContentSettingsType::BLUETOOTH_SCANNING); - - ContentSetting value = CONTENT_SETTING_BLOCK; - if (allow) { - if (type == ContentSettingsType::USB_GUARD || - type == ContentSettingsType::BLUETOOTH_SCANNING) { - value = CONTENT_SETTING_ASK; - } else { - value = CONTENT_SETTING_ALLOW; - } - } - - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting(type, value); -} - -static void JNI_PrefServiceBridge_SetContentSettingForPattern( - JNIEnv* env, - int content_settings_type, - const JavaParamRef<jstring>& pattern, - int setting) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetContentSettingCustomScope( - ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), - ContentSettingsPattern::Wildcard(), - static_cast<ContentSettingsType>(content_settings_type), std::string(), - static_cast<ContentSetting>(setting)); -} - -static void JNI_PrefServiceBridge_GetContentSettingsExceptions( - JNIEnv* env, - int content_settings_type, - const JavaParamRef<jobject>& list) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - ContentSettingsForOneType entries; - host_content_settings_map->GetSettingsForOneType( - static_cast<ContentSettingsType>(content_settings_type), "", &entries); - for (size_t i = 0; i < entries.size(); ++i) { - Java_PrefServiceBridge_addContentSettingExceptionToList( - env, list, content_settings_type, - ConvertUTF8ToJavaString(env, entries[i].primary_pattern.ToString()), - entries[i].GetContentSetting(), - ConvertUTF8ToJavaString(env, entries[i].source)); - } -} - -static jint JNI_PrefServiceBridge_GetContentSetting( - JNIEnv* env, - int content_settings_type) { - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - return content_settings->GetDefaultContentSetting( - static_cast<ContentSettingsType>(content_settings_type), nullptr); -} - -static void JNI_PrefServiceBridge_SetContentSetting( - JNIEnv* env, - int content_settings_type, - int setting) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - static_cast<ContentSettingsType>(content_settings_type), - static_cast<ContentSetting>(setting)); -} - -static jboolean JNI_PrefServiceBridge_GetAcceptCookiesEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::COOKIES); -} - -static jboolean JNI_PrefServiceBridge_GetAcceptCookiesUserModifiable( - JNIEnv* env) { - return IsContentSettingUserModifiable(ContentSettingsType::COOKIES); -} - -static jboolean JNI_PrefServiceBridge_GetAcceptCookiesManagedByCustodian( - JNIEnv* env) { - return IsContentSettingManagedByCustodian(ContentSettingsType::COOKIES); -} - -static jboolean JNI_PrefServiceBridge_GetAutoplayEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::AUTOPLAY); -} - -static jboolean JNI_PrefServiceBridge_GetNfcEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::NFC); -} - -static jboolean JNI_PrefServiceBridge_GetSensorsEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::SENSORS); -} - -static jboolean JNI_PrefServiceBridge_GetSoundEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::SOUND); -} - -static jboolean JNI_PrefServiceBridge_GetBackgroundSyncEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::BACKGROUND_SYNC); -} - -static jboolean JNI_PrefServiceBridge_GetAutomaticDownloadsEnabled( - JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::AUTOMATIC_DOWNLOADS); -} - static jboolean JNI_PrefServiceBridge_GetNetworkPredictionEnabled(JNIEnv* env) { return GetPrefService()->GetInteger(prefs::kNetworkPredictionOptions) != chrome_browser_net::NETWORK_PREDICTION_NEVER; @@ -314,34 +119,6 @@ prefs::kNetworkPredictionOptions); } -static jboolean JNI_PrefServiceBridge_GetNotificationsEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::NOTIFICATIONS); -} - -static jboolean JNI_PrefServiceBridge_GetAllowLocationEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::GEOLOCATION); -} - -static jboolean JNI_PrefServiceBridge_GetLocationAllowedByPolicy(JNIEnv* env) { - if (!IsContentSettingManaged(ContentSettingsType::GEOLOCATION)) - return false; - HostContentSettingsMap* content_settings = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - return content_settings->GetDefaultContentSetting( - ContentSettingsType::GEOLOCATION, nullptr) == - CONTENT_SETTING_ALLOW; -} - -static jboolean JNI_PrefServiceBridge_GetAllowLocationUserModifiable( - JNIEnv* env) { - return IsContentSettingUserModifiable(ContentSettingsType::GEOLOCATION); -} - -static jboolean JNI_PrefServiceBridge_GetAllowLocationManagedByCustodian( - JNIEnv* env) { - return IsContentSettingManagedByCustodian(ContentSettingsType::GEOLOCATION); -} - static jboolean JNI_PrefServiceBridge_GetIncognitoModeEnabled(JNIEnv* env) { PrefService* prefs = GetPrefService(); IncognitoModePrefs::Availability incognito_pref = @@ -374,164 +151,11 @@ metrics::prefs::kMetricsReportingEnabled); } -static void JNI_PrefServiceBridge_SetAutoplayEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::AUTOPLAY, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetClipboardEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::CLIPBOARD_READ, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetNfcEnabled(JNIEnv* env, jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::NFC, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetSensorsEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::SENSORS, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetSoundEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::SOUND, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); - - if (allow) { - base::RecordAction( - base::UserMetricsAction("SoundContentSetting.UnmuteBy.DefaultSwitch")); - } else { - base::RecordAction( - base::UserMetricsAction("SoundContentSetting.MuteBy.DefaultSwitch")); - } -} - -static void JNI_PrefServiceBridge_SetAllowCookiesEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::COOKIES, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetBackgroundSyncEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::BACKGROUND_SYNC, - allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetAutomaticDownloadsEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::AUTOMATIC_DOWNLOADS, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetAllowLocationEnabled( - JNIEnv* env, - jboolean is_enabled) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::GEOLOCATION, - is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetCameraEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::MEDIASTREAM_CAMERA, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetMicEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::MEDIASTREAM_MIC, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - -static void JNI_PrefServiceBridge_SetNotificationsEnabled( - JNIEnv* env, - jboolean allow) { - HostContentSettingsMap* host_content_settings_map = - HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); - host_content_settings_map->SetDefaultContentSetting( - ContentSettingsType::NOTIFICATIONS, - allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); -} - static jboolean JNI_PrefServiceBridge_CanPrefetchAndPrerender(JNIEnv* env) { return chrome_browser_net::CanPrefetchAndPrerenderUI(GetPrefService()) == chrome_browser_net::NetworkPredictionStatus::ENABLED; } -static jboolean JNI_PrefServiceBridge_GetCameraEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::MEDIASTREAM_CAMERA); -} - -static jboolean JNI_PrefServiceBridge_GetCameraUserModifiable(JNIEnv* env) { - return IsContentSettingUserModifiable( - ContentSettingsType::MEDIASTREAM_CAMERA); -} - -static jboolean JNI_PrefServiceBridge_GetCameraManagedByCustodian(JNIEnv* env) { - return IsContentSettingManagedByCustodian( - ContentSettingsType::MEDIASTREAM_CAMERA); -} - -static jboolean JNI_PrefServiceBridge_GetMicEnabled(JNIEnv* env) { - return GetBooleanForContentSetting(ContentSettingsType::MEDIASTREAM_MIC); -} - -static jboolean JNI_PrefServiceBridge_GetMicUserModifiable(JNIEnv* env) { - return IsContentSettingUserModifiable(ContentSettingsType::MEDIASTREAM_MIC); -} - -static jboolean JNI_PrefServiceBridge_GetMicManagedByCustodian(JNIEnv* env) { - return IsContentSettingManagedByCustodian( - ContentSettingsType::MEDIASTREAM_MIC); -} - static void JNI_PrefServiceBridge_SetNetworkPredictionEnabled( JNIEnv* env, jboolean enabled) { @@ -556,18 +180,6 @@ g_browser_process->local_state()->SetBoolean(prefs::kEulaAccepted, true); } -// static -void PrefServiceBridge::GetAndroidPermissionsForContentSetting( - ContentSettingsType content_settings_type, - std::vector<std::string>* out) { - JNIEnv* env = AttachCurrentThread(); - base::android::AppendJavaStringArrayToStringVector( - env, - Java_PrefServiceBridge_getAndroidPermissionsForContentSetting( - env, static_cast<int>(content_settings_type)), - out); -} - const char* PrefServiceBridge::GetPrefNameExposedToJava(int pref_index) { DCHECK_GE(pref_index, 0); DCHECK_LT(pref_index, Pref::PREF_NUM_PREFS);
diff --git a/chrome/browser/android/preferences/pref_service_bridge.h b/chrome/browser/android/preferences/pref_service_bridge.h index 7b2e27e..2043c84a 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.h +++ b/chrome/browser/android/preferences/pref_service_bridge.h
@@ -5,19 +5,8 @@ #ifndef CHROME_BROWSER_ANDROID_PREFERENCES_PREF_SERVICE_BRIDGE_H_ #define CHROME_BROWSER_ANDROID_PREFERENCES_PREF_SERVICE_BRIDGE_H_ -#include <string> -#include <vector> - -#include "components/content_settings/core/common/content_settings.h" - class PrefServiceBridge { public: - // Populate the list of corresponding Android permissions associated with the - // ContentSettingsType specified. - static void GetAndroidPermissionsForContentSetting( - ContentSettingsType content_type, - std::vector<std::string>* out); - static const char* GetPrefNameExposedToJava(int pref_index); };
diff --git a/chrome/browser/android/preferences/website_preference_bridge.cc b/chrome/browser/android/preferences/website_preference_bridge.cc index e9d0ca5..79fbce0 100644 --- a/chrome/browser/android/preferences/website_preference_bridge.cc +++ b/chrome/browser/android/preferences/website_preference_bridge.cc
@@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/android/preferences/website_preference_bridge.h" + #include <algorithm> #include <string> #include <vector> #include "base/android/callback_android.h" #include "base/android/jni_android.h" +#include "base/android/jni_array.h" #include "base/android/jni_string.h" #include "base/android/scoped_java_ref.h" #include "base/bind.h" @@ -16,6 +19,7 @@ #include "base/json/json_writer.h" #include "base/logging.h" #include "base/macros.h" +#include "base/metrics/user_metrics.h" #include "base/stl_util.h" #include "chrome/android/chrome_jni_headers/WebsitePreferenceBridge_jni.h" #include "chrome/browser/android/search_permissions/search_permissions_service.h" @@ -36,6 +40,7 @@ #include "chrome/browser/storage/storage_info_fetcher.h" #include "chrome/browser/usb/usb_chooser_context.h" #include "chrome/browser/usb/usb_chooser_context_factory.h" +#include "chrome/common/pref_names.h" #include "components/content_settings/core/browser/cookie_settings.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "content/public/browser/browser_thread.h" @@ -48,6 +53,7 @@ #include "url/url_constants.h" #include "url/url_util.h" +using base::android::AttachCurrentThread; using base::android::ConvertJavaStringToUTF8; using base::android::ConvertUTF8ToJavaString; using base::android::JavaParamRef; @@ -150,8 +156,8 @@ content_settings_map->GetSettingsForOneType( ContentSettingsType::PERMISSION_AUTOBLOCKER_DATA, std::string(), &embargo_settings); - ContentSetting default_content_setting = content_settings_map-> - GetDefaultContentSetting(content_type, NULL); + ContentSetting default_content_setting = + content_settings_map->GetDefaultContentSetting(content_type, nullptr); // Use a vector since the overall number of origins should be small. std::vector<std::string> seen_origins; @@ -286,6 +292,54 @@ return origin == url::Origin::Create(other); } +Profile* GetOriginalProfile() { + return ProfileManager::GetActiveUserProfile()->GetOriginalProfile(); +} + +bool GetBooleanForContentSetting(ContentSettingsType type) { + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + switch (content_settings->GetDefaultContentSetting(type, nullptr)) { + case CONTENT_SETTING_BLOCK: + return false; + case CONTENT_SETTING_ALLOW: + case CONTENT_SETTING_ASK: + default: + return true; + } +} + +bool IsContentSettingManaged(ContentSettingsType content_settings_type) { + std::string source; + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + content_settings->GetDefaultContentSetting(content_settings_type, &source); + HostContentSettingsMap::ProviderType provider = + content_settings->GetProviderTypeFromSource(source); + return provider == HostContentSettingsMap::POLICY_PROVIDER; +} + +bool IsContentSettingManagedByCustodian( + ContentSettingsType content_settings_type) { + std::string source; + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + content_settings->GetDefaultContentSetting(content_settings_type, &source); + HostContentSettingsMap::ProviderType provider = + content_settings->GetProviderTypeFromSource(source); + return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; +} + +bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { + std::string source; + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + content_settings->GetDefaultContentSetting(content_settings_type, &source); + HostContentSettingsMap::ProviderType provider = + content_settings->GetProviderTypeFromSource(source); + return provider >= HostContentSettingsMap::PREF_PROVIDER; +} + } // anonymous namespace static void JNI_WebsitePreferenceBridge_GetClipboardOrigins( @@ -888,3 +942,342 @@ GetHostContentSettingsMap(/*is_incognito=*/false) ->ClearSettingsForOneType(ContentSettingsType::NOTIFICATIONS); } + +static jboolean JNI_WebsitePreferenceBridge_IsContentSettingManaged( + JNIEnv* env, + int content_settings_type) { + return IsContentSettingManaged( + static_cast<ContentSettingsType>(content_settings_type)); +} + +static jboolean JNI_WebsitePreferenceBridge_IsContentSettingEnabled( + JNIEnv* env, + int content_settings_type) { + ContentSettingsType type = + static_cast<ContentSettingsType>(content_settings_type); + // Before we migrate functions over to this central function, we must verify + // that the functionality provided below is correct. + DCHECK(type == ContentSettingsType::JAVASCRIPT || + type == ContentSettingsType::POPUPS || + type == ContentSettingsType::ADS || + type == ContentSettingsType::CLIPBOARD_READ || + type == ContentSettingsType::USB_GUARD || + type == ContentSettingsType::BLUETOOTH_SCANNING); + return GetBooleanForContentSetting(type); +} + +static void JNI_WebsitePreferenceBridge_SetContentSettingEnabled( + JNIEnv* env, + int content_settings_type, + jboolean allow) { + ContentSettingsType type = + static_cast<ContentSettingsType>(content_settings_type); + + // Before we migrate functions over to this central function, we must verify + // that the new category supports ALLOW/BLOCK pairs and, if not, handle them. + DCHECK(type == ContentSettingsType::JAVASCRIPT || + type == ContentSettingsType::POPUPS || + type == ContentSettingsType::ADS || + type == ContentSettingsType::USB_GUARD || + type == ContentSettingsType::BLUETOOTH_SCANNING); + + ContentSetting value = CONTENT_SETTING_BLOCK; + if (allow) { + if (type == ContentSettingsType::USB_GUARD || + type == ContentSettingsType::BLUETOOTH_SCANNING) { + value = CONTENT_SETTING_ASK; + } else { + value = CONTENT_SETTING_ALLOW; + } + } + + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting(type, value); +} + +static void JNI_WebsitePreferenceBridge_SetContentSettingForPattern( + JNIEnv* env, + int content_settings_type, + const JavaParamRef<jstring>& pattern, + int setting) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetContentSettingCustomScope( + ContentSettingsPattern::FromString(ConvertJavaStringToUTF8(env, pattern)), + ContentSettingsPattern::Wildcard(), + static_cast<ContentSettingsType>(content_settings_type), std::string(), + static_cast<ContentSetting>(setting)); +} + +static void JNI_WebsitePreferenceBridge_GetContentSettingsExceptions( + JNIEnv* env, + int content_settings_type, + const JavaParamRef<jobject>& list) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + ContentSettingsForOneType entries; + host_content_settings_map->GetSettingsForOneType( + static_cast<ContentSettingsType>(content_settings_type), "", &entries); + for (size_t i = 0; i < entries.size(); ++i) { + Java_WebsitePreferenceBridge_addContentSettingExceptionToList( + env, list, content_settings_type, + ConvertUTF8ToJavaString(env, entries[i].primary_pattern.ToString()), + entries[i].GetContentSetting(), + ConvertUTF8ToJavaString(env, entries[i].source)); + } +} + +static jint JNI_WebsitePreferenceBridge_GetContentSetting( + JNIEnv* env, + int content_settings_type) { + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + return content_settings->GetDefaultContentSetting( + static_cast<ContentSettingsType>(content_settings_type), nullptr); +} + +static void JNI_WebsitePreferenceBridge_SetContentSetting( + JNIEnv* env, + int content_settings_type, + int setting) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + static_cast<ContentSettingsType>(content_settings_type), + static_cast<ContentSetting>(setting)); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesEnabled( + JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::COOKIES); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesUserModifiable( + JNIEnv* env) { + return IsContentSettingUserModifiable(ContentSettingsType::COOKIES); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAcceptCookiesManagedByCustodian( + JNIEnv* env) { + return IsContentSettingManagedByCustodian(ContentSettingsType::COOKIES); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAutoplayEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::AUTOPLAY); +} + +static jboolean JNI_WebsitePreferenceBridge_GetNfcEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::NFC); +} + +static jboolean JNI_WebsitePreferenceBridge_GetSensorsEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::SENSORS); +} + +static jboolean JNI_WebsitePreferenceBridge_GetSoundEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::SOUND); +} + +static jboolean JNI_WebsitePreferenceBridge_GetBackgroundSyncEnabled( + JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::BACKGROUND_SYNC); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAutomaticDownloadsEnabled( + JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::AUTOMATIC_DOWNLOADS); +} + +static jboolean JNI_WebsitePreferenceBridge_GetNotificationsEnabled( + JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::NOTIFICATIONS); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationEnabled( + JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::GEOLOCATION); +} + +static jboolean JNI_WebsitePreferenceBridge_GetLocationAllowedByPolicy( + JNIEnv* env) { + if (!IsContentSettingManaged(ContentSettingsType::GEOLOCATION)) + return false; + HostContentSettingsMap* content_settings = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + return content_settings->GetDefaultContentSetting( + ContentSettingsType::GEOLOCATION, nullptr) == + CONTENT_SETTING_ALLOW; +} + +static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationUserModifiable( + JNIEnv* env) { + return IsContentSettingUserModifiable(ContentSettingsType::GEOLOCATION); +} + +static jboolean JNI_WebsitePreferenceBridge_GetAllowLocationManagedByCustodian( + JNIEnv* env) { + return IsContentSettingManagedByCustodian(ContentSettingsType::GEOLOCATION); +} + +static void JNI_WebsitePreferenceBridge_SetAutoplayEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::AUTOPLAY, + allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetClipboardEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::CLIPBOARD_READ, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetNfcEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::NFC, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetSensorsEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::SENSORS, + allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetSoundEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::SOUND, + allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); + + if (allow) { + base::RecordAction( + base::UserMetricsAction("SoundContentSetting.UnmuteBy.DefaultSwitch")); + } else { + base::RecordAction( + base::UserMetricsAction("SoundContentSetting.MuteBy.DefaultSwitch")); + } +} + +static void JNI_WebsitePreferenceBridge_SetAllowCookiesEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::COOKIES, + allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetBackgroundSyncEnabled( + JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::BACKGROUND_SYNC, + allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetAutomaticDownloadsEnabled( + JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::AUTOMATIC_DOWNLOADS, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetAllowLocationEnabled( + JNIEnv* env, + jboolean is_enabled) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::GEOLOCATION, + is_enabled ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetCameraEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::MEDIASTREAM_CAMERA, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetMicEnabled(JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::MEDIASTREAM_MIC, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static void JNI_WebsitePreferenceBridge_SetNotificationsEnabled( + JNIEnv* env, + jboolean allow) { + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(GetOriginalProfile()); + host_content_settings_map->SetDefaultContentSetting( + ContentSettingsType::NOTIFICATIONS, + allow ? CONTENT_SETTING_ASK : CONTENT_SETTING_BLOCK); +} + +static jboolean JNI_WebsitePreferenceBridge_GetCameraEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::MEDIASTREAM_CAMERA); +} + +static jboolean JNI_WebsitePreferenceBridge_GetCameraUserModifiable( + JNIEnv* env) { + return IsContentSettingUserModifiable( + ContentSettingsType::MEDIASTREAM_CAMERA); +} + +static jboolean JNI_WebsitePreferenceBridge_GetCameraManagedByCustodian( + JNIEnv* env) { + return IsContentSettingManagedByCustodian( + ContentSettingsType::MEDIASTREAM_CAMERA); +} + +static jboolean JNI_WebsitePreferenceBridge_GetMicEnabled(JNIEnv* env) { + return GetBooleanForContentSetting(ContentSettingsType::MEDIASTREAM_MIC); +} + +static jboolean JNI_WebsitePreferenceBridge_GetMicUserModifiable(JNIEnv* env) { + return IsContentSettingUserModifiable(ContentSettingsType::MEDIASTREAM_MIC); +} + +static jboolean JNI_WebsitePreferenceBridge_GetMicManagedByCustodian( + JNIEnv* env) { + return IsContentSettingManagedByCustodian( + ContentSettingsType::MEDIASTREAM_MIC); +} + +// static +void WebsitePreferenceBridge::GetAndroidPermissionsForContentSetting( + ContentSettingsType content_settings_type, + std::vector<std::string>* out) { + JNIEnv* env = AttachCurrentThread(); + base::android::AppendJavaStringArrayToStringVector( + env, + Java_WebsitePreferenceBridge_getAndroidPermissionsForContentSetting( + env, static_cast<int>(content_settings_type)), + out); +}
diff --git a/chrome/browser/android/preferences/website_preference_bridge.h b/chrome/browser/android/preferences/website_preference_bridge.h new file mode 100644 index 0000000..60a0f5f --- /dev/null +++ b/chrome/browser/android/preferences/website_preference_bridge.h
@@ -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. + +#ifndef CHROME_BROWSER_ANDROID_PREFERENCES_WEBSITE_PREFERENCE_BRIDGE_H_ +#define CHROME_BROWSER_ANDROID_PREFERENCES_WEBSITE_PREFERENCE_BRIDGE_H_ + +#include <string> +#include <vector> + +#include "components/content_settings/core/common/content_settings.h" + +class WebsitePreferenceBridge { + public: + // Populate the list of corresponding Android permissions associated with the + // ContentSettingsType specified. + static void GetAndroidPermissionsForContentSetting( + ContentSettingsType content_type, + std::vector<std::string>* out); +}; + +#endif // CHROME_BROWSER_ANDROID_PREFERENCES_WEBSITE_PREFERENCE_BRIDGE_H_
diff --git a/chrome/browser/chrome_browser_interface_binders.cc b/chrome/browser/chrome_browser_interface_binders.cc index f1b14d8..3b6ea88 100644 --- a/chrome/browser/chrome_browser_interface_binders.cc +++ b/chrome/browser/chrome_browser_interface_binders.cc
@@ -160,6 +160,19 @@ extensions::MimeHandlerServiceImpl::Create(guest_view->GetStreamWeakPtr(), std::move(receiver)); } + +void BindBeforeUnloadControl( + content::RenderFrameHost* frame_host, + mojo::PendingReceiver<extensions::mime_handler::BeforeUnloadControl> + receiver) { + content::WebContents* contents = + content::WebContents::FromRenderFrameHost(frame_host); + auto* guest_view = + extensions::MimeHandlerViewGuest::FromWebContents(contents); + if (!guest_view) + return; + guest_view->FuseBeforeUnloadControl(std::move(receiver)); +} #endif void PopulateChromeFrameBinders( @@ -219,6 +232,8 @@ #if BUILDFLAG(ENABLE_EXTENSIONS) map->Add<extensions::mime_handler::MimeHandlerService>( base::BindRepeating(&BindMimeHandlerService)); + map->Add<extensions::mime_handler::BeforeUnloadControl>( + base::BindRepeating(&BindBeforeUnloadControl)); #endif }
diff --git a/chrome/browser/chromeos/BUILD.gn b/chrome/browser/chromeos/BUILD.gn index 6d68ef2..e1c4f4e 100644 --- a/chrome/browser/chromeos/BUILD.gn +++ b/chrome/browser/chromeos/BUILD.gn
@@ -2327,6 +2327,8 @@ "printing/cups_proxy_service_manager.h", "printing/cups_proxy_service_manager_factory.cc", "printing/cups_proxy_service_manager_factory.h", + "printing/cups_wrapper.cc", + "printing/cups_wrapper.h", "printing/printer_info_cups.cc", ] } else { @@ -2406,6 +2408,8 @@ "crostini/ansible/ansible_management_test_helper.h", "crostini/crostini_test_helper.cc", "crostini/crostini_test_helper.h", + "crostini/crostini_test_util.cc", + "crostini/crostini_test_util.h", "crostini/fake_crostini_features.cc", "crostini/fake_crostini_features.h", "drive/drivefs_test_support.cc",
diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.cc b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.cc index a7cfc1f..1ada0f3 100644 --- a/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.cc +++ b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.cc
@@ -46,26 +46,6 @@ } } -bool SpokenFeedbackEventRewriterDelegate::ShouldDispatchKeyEventToChromeVox( - const ui::Event* event) const { - chromeos::AccessibilityManager* accessibility_manager = - chromeos::AccessibilityManager::Get(); - if (!accessibility_manager->IsSpokenFeedbackEnabled() || - accessibility_manager->keyboard_listener_extension_id().empty() || - !chromeos::GetAccessibilityExtensionHost( - extension_misc::kChromeVoxExtensionId)) { - VLOG(1) << "Event sent to Spoken Feedback when disabled or unavailable"; - return false; - } - - if (!event || !event->IsKeyEvent()) { - NOTREACHED() << "Unexpected event sent to Spoken Feedback"; - return false; - } - - return true; -} - void SpokenFeedbackEventRewriterDelegate::OnUnhandledSpokenFeedbackEvent( std::unique_ptr<ui::Event> event) const { ash::EventRewriterController::Get()->OnUnhandledSpokenFeedbackEvent(
diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.h b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.h index c002d1bf..35588a0 100644 --- a/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.h +++ b/chrome/browser/chromeos/accessibility/spoken_feedback_event_rewriter_delegate.h
@@ -27,9 +27,6 @@ void DispatchMouseEventToChromeVox(std::unique_ptr<ui::Event> event) override; private: - // Returns whether the event should be dispatched to the ChromeVox extension. - bool ShouldDispatchKeyEventToChromeVox(const ui::Event* event) const; - // Reports unhandled key events to the EventRewriterController for dispatch. void OnUnhandledSpokenFeedbackEvent(std::unique_ptr<ui::Event> event) const;
diff --git a/chrome/browser/chromeos/crostini/ansible/ansible_management_service.cc b/chrome/browser/chromeos/crostini/ansible/ansible_management_service.cc index 5b2685a..07613fe 100644 --- a/chrome/browser/chromeos/crostini/ansible/ansible_management_service.cc +++ b/chrome/browser/chromeos/crostini/ansible/ansible_management_service.cc
@@ -7,6 +7,8 @@ #include "base/files/file_util.h" #include "base/logging.h" #include "base/no_destructor.h" +#include "base/task/post_task.h" +#include "base/task/task_traits.h" #include "chrome/browser/chromeos/crostini/crostini_manager_factory.h" #include "chrome/browser/chromeos/crostini/crostini_pref_names.h" #include "chrome/browser/chromeos/crostini/crostini_util.h" @@ -73,17 +75,15 @@ DCHECK(!configuration_finished_callback_); configuration_finished_callback_ = std::move(callback); - // TODO(okalitova): Show Ansible software config dialog. + // TODO(okalitova): Reflect configuration progress in installer view when + // Crostini is being installed. + + // Popup dialog is shown in case Crostini has already been installed. + if (!CrostiniManager::GetForProfile(profile_)->GetInstallerViewStatus()) + ShowCrostiniAnsibleSoftwareConfigView(profile_); CrostiniManager::GetForProfile(profile_) ->AddLinuxPackageOperationProgressObserver(this); - InstallAnsibleInDefaultContainer(); -} - -void AnsibleManagementService::InstallAnsibleInDefaultContainer() { - for (auto& observer : observers_) { - observer.OnAnsibleSoftwareConfigurationStarted(); - } CrostiniManager::GetForProfile(profile_)->InstallLinuxPackageFromApt( kCrostiniDefaultVmName, kCrostiniDefaultContainerName, @@ -116,11 +116,12 @@ DCHECK_EQ(container_id.container_name, kCrostiniDefaultContainerName); switch (status) { - case InstallLinuxPackageProgressStatus::SUCCEEDED: + case InstallLinuxPackageProgressStatus::SUCCEEDED: { CrostiniManager::GetForProfile(profile_) ->RemoveLinuxPackageOperationProgressObserver(this); - ApplyAnsiblePlaybookToDefaultContainer(); + GetAnsiblePlaybookToApply(); return; + } case InstallLinuxPackageProgressStatus::FAILED: LOG(ERROR) << "Ansible installation failed"; CrostiniManager::GetForProfile(profile_) @@ -139,9 +140,34 @@ } } -void AnsibleManagementService::ApplyAnsiblePlaybookToDefaultContainer() { - std::string playbook = GetAnsiblePlaybookToApply(); +void AnsibleManagementService::GetAnsiblePlaybookToApply() { + const base::FilePath& ansible_playbook_file_path = + profile_->GetPrefs()->GetFilePath( + prefs::kCrostiniAnsiblePlaybookFilePath); + bool success = base::PostTaskAndReplyWithResult( + FROM_HERE, + {base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE}, + base::BindOnce(base::ReadFileToString, ansible_playbook_file_path, + &playbook_), + base::BindOnce(&AnsibleManagementService::OnAnsiblePlaybookRetrieved, + weak_ptr_factory_.GetWeakPtr())); + if (!success) { + LOG(ERROR) << "Failed to post task to retrieve Ansible playbook content"; + OnConfigurationFinished(false); + } +} +void AnsibleManagementService::OnAnsiblePlaybookRetrieved(bool success) { + if (!success) { + LOG(ERROR) << "Failed to retrieve Ansible playbook content"; + OnConfigurationFinished(false); + return; + } + + ApplyAnsiblePlaybookToDefaultContainer(); +} + +void AnsibleManagementService::ApplyAnsiblePlaybookToDefaultContainer() { if (!GetCiceroneClient()->IsApplyAnsiblePlaybookProgressSignalConnected()) { // Technically we could still start the application, but we wouldn't be able // to detect when the application completes, successfully or otherwise. @@ -155,7 +181,7 @@ request.set_owner_id(CryptohomeIdForProfile(profile_)); request.set_vm_name(std::move(kCrostiniDefaultVmName)); request.set_container_name(std::move(kCrostiniDefaultContainerName)); - request.set_playbook(std::move(playbook)); + request.set_playbook(std::move(playbook_)); GetCiceroneClient()->ApplyAnsiblePlaybook( std::move(request), @@ -218,24 +244,11 @@ } void AnsibleManagementService::OnConfigurationFinished(bool success) { + DCHECK(configuration_finished_callback_); std::move(configuration_finished_callback_).Run(success); for (auto& observer : observers_) { observer.OnAnsibleSoftwareConfigurationFinished(success); } } -std::string AnsibleManagementService::GetAnsiblePlaybookToApply() { - const base::FilePath& ansible_playbook_file_path = - profile_->GetPrefs()->GetFilePath( - prefs::kCrostiniAnsiblePlaybookFilePath); - std::string playbook_content; - if (!base::ReadFileToString(ansible_playbook_file_path, &playbook_content)) { - LOG(ERROR) << "Failed to retrieve Ansible playbook content from " - << ansible_playbook_file_path.value(); - std::move(configuration_finished_callback_).Run(/*success=*/false); - return std::string(); - } - return playbook_content; -} - } // namespace crostini
diff --git a/chrome/browser/chromeos/crostini/ansible/ansible_management_service.h b/chrome/browser/chromeos/crostini/ansible/ansible_management_service.h index e818475..9a64b83 100644 --- a/chrome/browser/chromeos/crostini/ansible/ansible_management_service.h +++ b/chrome/browser/chromeos/crostini/ansible/ansible_management_service.h
@@ -59,6 +59,8 @@ private: void InstallAnsibleInDefaultContainer(); void OnInstallAnsibleInDefaultContainer(CrostiniResult result); + void GetAnsiblePlaybookToApply(); + void OnAnsiblePlaybookRetrieved(bool success); void ApplyAnsiblePlaybookToDefaultContainer(); void OnApplyAnsiblePlaybook( base::Optional<vm_tools::cicerone::ApplyAnsiblePlaybookResponse> @@ -67,11 +69,10 @@ // Helper function that runs relevant callback and notifies observers. void OnConfigurationFinished(bool success); - std::string GetAnsiblePlaybookToApply(); - Profile* profile_; base::ObserverList<Observer> observers_; base::OnceCallback<void(bool success)> configuration_finished_callback_; + std::string playbook_; base::WeakPtrFactory<AnsibleManagementService> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(AnsibleManagementService);
diff --git a/chrome/browser/chromeos/crostini/ansible/ansible_management_service_unittest.cc b/chrome/browser/chromeos/crostini/ansible/ansible_management_service_unittest.cc index 96cef9ed..8d6675c7 100644 --- a/chrome/browser/chromeos/crostini/ansible/ansible_management_service_unittest.cc +++ b/chrome/browser/chromeos/crostini/ansible/ansible_management_service_unittest.cc
@@ -6,6 +6,7 @@ #include "base/test/mock_callback.h" #include "chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h" +#include "chrome/browser/chromeos/crostini/crostini_test_util.h" #include "chrome/test/base/testing_profile.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "content/public/test/browser_task_environment.h" @@ -24,8 +25,17 @@ AnsibleManagementService::GetForProfile(profile_.get()); test_helper_ = std::make_unique<AnsibleManagementTestHelper>(profile_.get()); + test_helper_->SetUpAnsibleInfra(); + + SetUpViewsEnvironmentForTesting(); } + ~AnsibleManagementServiceTest() override { + crostini::CloseCrostiniAnsibleSoftwareConfigViewForTesting(); + // Wait for view triggered to be closed. + base::RunLoop().RunUntilIdle(); + TearDownViewsEnvironmentForTesting(); + test_helper_.reset(); ansible_management_service_->Shutdown(); crostini_manager_->Shutdown(); @@ -38,19 +48,20 @@ return ansible_management_service_; } - std::unique_ptr<TestingProfile> profile_; - std::unique_ptr<AnsibleManagementTestHelper> test_helper_; content::BrowserTaskEnvironment task_environment_; - CrostiniManager* crostini_manager_; - AnsibleManagementService* ansible_management_service_; + std::unique_ptr<AnsibleManagementTestHelper> test_helper_; base::MockCallback<base::OnceCallback<void(bool)>> configuration_finished_mock_callback_; + private: + std::unique_ptr<TestingProfile> profile_; + CrostiniManager* crostini_manager_; + AnsibleManagementService* ansible_management_service_; + DISALLOW_COPY_AND_ASSIGN(AnsibleManagementServiceTest); }; TEST_F(AnsibleManagementServiceTest, ConfigureDefaultContainerSuccess) { - test_helper_->SetUpAnsibleInfra(); test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::STARTED); test_helper_->SetUpPlaybookApplication( @@ -60,16 +71,16 @@ ansible_management_service()->ConfigureDefaultContainer( configuration_finished_mock_callback_.Get()); - base::RunLoop().RunUntilIdle(); + test_helper_->SendSucceededInstallSignal(); - base::RunLoop().RunUntilIdle(); + task_environment_.RunUntilIdle(); + test_helper_->SendSucceededApplySignal(); } TEST_F(AnsibleManagementServiceTest, ConfigureDefaultContainerInstallFail) { - test_helper_->SetUpAnsibleInfra(); test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::FAILED); @@ -77,12 +88,10 @@ ansible_management_service()->ConfigureDefaultContainer( configuration_finished_mock_callback_.Get()); - base::RunLoop().RunUntilIdle(); } TEST_F(AnsibleManagementServiceTest, ConfigureDefaultContainerApplyFail) { - test_helper_->SetUpAnsibleInfra(); test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::STARTED); test_helper_->SetUpPlaybookApplication( @@ -92,11 +101,11 @@ ansible_management_service()->ConfigureDefaultContainer( configuration_finished_mock_callback_.Get()); - base::RunLoop().RunUntilIdle(); + test_helper_->SendSucceededInstallSignal(); - base::RunLoop().RunUntilIdle(); + task_environment_.RunUntilIdle(); } } // namespace crostini
diff --git a/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.cc b/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.cc index c7ce3db..f6c9f64a 100644 --- a/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.cc +++ b/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.cc
@@ -7,15 +7,14 @@ #include "base/files/file_util.h" #include "chrome/browser/chromeos/crostini/crostini_pref_names.h" #include "chrome/browser/chromeos/crostini/crostini_util.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_features.h" -#include "chrome/test/base/testing_profile.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "components/prefs/pref_service.h" namespace crostini { -AnsibleManagementTestHelper::AnsibleManagementTestHelper( - TestingProfile* profile) +AnsibleManagementTestHelper::AnsibleManagementTestHelper(Profile* profile) : profile_(profile) { fake_cicerone_client_ = static_cast<chromeos::FakeCiceroneClient*>( chromeos::DBusThreadManager::Get()->GetCiceroneClient());
diff --git a/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h b/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h index 82cb614..866b512 100644 --- a/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h +++ b/chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h
@@ -9,7 +9,7 @@ #include "chromeos/dbus/cicerone/cicerone_service.pb.h" #include "chromeos/dbus/fake_cicerone_client.h" -class TestingProfile; +class Profile; namespace crostini { @@ -18,8 +18,9 @@ // DBusThreadManager is already initialized and Crostini is enabled. class AnsibleManagementTestHelper { public: - explicit AnsibleManagementTestHelper(TestingProfile* profile); + explicit AnsibleManagementTestHelper(Profile* profile); + void SetUpAnsiblePlaybookPreference(); void SetUpAnsibleInfra(); void SetUpAnsibleInstallation( @@ -30,9 +31,7 @@ void SendSucceededApplySignal(); private: - void SetUpAnsiblePlaybookPreference(); - - TestingProfile* profile_; + Profile* profile_; base::test::ScopedFeatureList scoped_feature_list_; // Owned by chromeos::DBusThreadManager
diff --git a/chrome/browser/chromeos/crostini/crostini_manager_unittest.cc b/chrome/browser/chromeos/crostini/crostini_manager_unittest.cc index e56460b..bf72c127 100644 --- a/chrome/browser/chromeos/crostini/crostini_manager_unittest.cc +++ b/chrome/browser/chromeos/crostini/crostini_manager_unittest.cc
@@ -14,6 +14,7 @@ #include "base/test/scoped_feature_list.h" #include "chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h" #include "chrome/browser/chromeos/crostini/crostini_pref_names.h" +#include "chrome/browser/chromeos/crostini/crostini_test_util.h" #include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/chromeos/crostini/fake_crostini_features.h" #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" @@ -190,13 +191,9 @@ mojo::Remote<device::mojom::UsbDeviceManager> fake_usb_manager; fake_usb_manager_.AddReceiver( fake_usb_manager.BindNewPipeAndPassReceiver()); - - ansible_management_test_helper_ = - std::make_unique<AnsibleManagementTestHelper>(profile_.get()); } void TearDown() override { - ansible_management_test_helper_.reset(); scoped_user_manager_.reset(); crostini_manager_->Shutdown(); profile_.reset(); @@ -218,7 +215,6 @@ CrostiniManager* crostini_manager_; device::FakeUsbDeviceManager fake_usb_manager_; base::test::ScopedFeatureList scoped_feature_list_; - std::unique_ptr<AnsibleManagementTestHelper> ansible_management_test_helper_; private: content::BrowserTaskEnvironment task_environment_; @@ -1572,8 +1568,33 @@ run_loop()->Run(); } -TEST_F(CrostiniManagerTest, StartContainerWithAnsibleInfraInstallFailure) { - ansible_management_test_helper_->SetUpAnsibleInfra(); +class CrostiniManagerAnsibleInfraTest : public CrostiniManagerTest { + public: + void SetUp() override { + CrostiniManagerTest::SetUp(); + ansible_management_test_helper_ = + std::make_unique<AnsibleManagementTestHelper>(profile_.get()); + ansible_management_test_helper_->SetUpAnsibleInfra(); + + SetUpViewsEnvironmentForTesting(); + } + + void TearDown() override { + crostini::CloseCrostiniAnsibleSoftwareConfigViewForTesting(); + // Wait for view triggered to be closed. + base::RunLoop().RunUntilIdle(); + + TearDownViewsEnvironmentForTesting(); + + ansible_management_test_helper_.reset(); + CrostiniManagerTest::TearDown(); + } + + protected: + std::unique_ptr<AnsibleManagementTestHelper> ansible_management_test_helper_; +}; + +TEST_F(CrostiniManagerAnsibleInfraTest, StartContainerAnsibleInstallFailure) { ansible_management_test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::FAILED); @@ -1585,8 +1606,7 @@ run_loop()->Run(); } -TEST_F(CrostiniManagerTest, StartContainerWithAnsibleInfraApplyFailure) { - ansible_management_test_helper_->SetUpAnsibleInfra(); +TEST_F(CrostiniManagerAnsibleInfraTest, StartContainerApplyFailure) { ansible_management_test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::STARTED); ansible_management_test_helper_->SetUpPlaybookApplication( @@ -1596,15 +1616,14 @@ kCrostiniDefaultVmName, kCrostiniDefaultContainerName, base::BindOnce(&ExpectCrostiniResult, run_loop()->QuitClosure(), CrostiniResult::UNKNOWN_ERROR)); - base::RunLoop().RunUntilIdle(); + ansible_management_test_helper_->SendSucceededInstallSignal(); run_loop()->Run(); } -TEST_F(CrostiniManagerTest, StartContainerWithAnsibleInfraSuccess) { - ansible_management_test_helper_->SetUpAnsibleInfra(); +TEST_F(CrostiniManagerAnsibleInfraTest, StartContainerSuccess) { ansible_management_test_helper_->SetUpAnsibleInstallation( vm_tools::cicerone::InstallLinuxPackageResponse::STARTED); ansible_management_test_helper_->SetUpPlaybookApplication( @@ -1614,11 +1633,11 @@ kCrostiniDefaultVmName, kCrostiniDefaultContainerName, base::BindOnce(&ExpectCrostiniResult, run_loop()->QuitClosure(), CrostiniResult::SUCCESS)); - base::RunLoop().RunUntilIdle(); + ansible_management_test_helper_->SendSucceededInstallSignal(); - base::RunLoop().RunUntilIdle(); + ansible_management_test_helper_->SendSucceededApplySignal(); run_loop()->Run();
diff --git a/chrome/browser/chromeos/crostini/crostini_test_util.cc b/chrome/browser/chromeos/crostini/crostini_test_util.cc new file mode 100644 index 0000000..76f01aa --- /dev/null +++ b/chrome/browser/chromeos/crostini/crostini_test_util.cc
@@ -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. + +#include "chrome/browser/chromeos/crostini/crostini_test_util.h" + +#include "chrome/browser/ui/views/chrome_layout_provider.h" +#include "ui/views/test/scoped_views_test_helper.h" +#include "ui/views/test/test_views_delegate.h" + +namespace { + +std::unique_ptr<views::ScopedViewsTestHelper> views_helper_; + +// ViewsDelegate to provide context to dialog creation functions which do not +// allow InitParams to be set, and pass a null |context| argument to +// DialogDelegate::CreateDialogWidget(). +class TestViewsDelegateWithContext : public views::TestViewsDelegate { + public: + TestViewsDelegateWithContext() {} + + void set_context(gfx::NativeWindow context) { context_ = context; } + + // ViewsDelegate: + void OnBeforeWidgetInit( + views::Widget::InitParams* params, + views::internal::NativeWidgetDelegate* delegate) override { + if (!params->context) + params->context = context_; + TestViewsDelegate::OnBeforeWidgetInit(params, delegate); + } + + private: + gfx::NativeWindow context_ = nullptr; + + DISALLOW_COPY_AND_ASSIGN(TestViewsDelegateWithContext); +}; + +} // namespace + +namespace crostini { + +void SetUpViewsEnvironmentForTesting() { + std::unique_ptr<TestViewsDelegateWithContext> views_delegate( + new TestViewsDelegateWithContext); + TestViewsDelegateWithContext* views_delegate_weak = views_delegate.get(); + views_helper_ = + std::make_unique<views::ScopedViewsTestHelper>(std::move(views_delegate)); + views_delegate_weak->set_context(views_helper_->GetContext()); + views_delegate_weak->set_layout_provider( + ChromeLayoutProvider::CreateLayoutProvider()); +} + +void TearDownViewsEnvironmentForTesting() { + views_helper_.reset(); +} + +} // namespace crostini
diff --git a/chrome/browser/chromeos/crostini/crostini_test_util.h b/chrome/browser/chromeos/crostini/crostini_test_util.h new file mode 100644 index 0000000..ad3f04a --- /dev/null +++ b/chrome/browser/chromeos/crostini/crostini_test_util.h
@@ -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. + +#ifndef CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_TEST_UTIL_H_ +#define CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_TEST_UTIL_H_ + +namespace crostini { + +// Sets up environment to allow dialog creation in tests. +void SetUpViewsEnvironmentForTesting(); + +// Tears down environment that allowed dialog creation in tests. +void TearDownViewsEnvironmentForTesting(); + +void CloseCrostiniAnsibleSoftwareConfigViewForTesting(); + +} // namespace crostini + +#endif // CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_TEST_UTIL_H_
diff --git a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc index 2e15bae..ba22bfe 100644 --- a/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc +++ b/chrome/browser/chromeos/extensions/autotest_private/autotest_private_api.cc
@@ -578,6 +578,13 @@ return wm::GetActivationClient(list[0]->GetRootWindow())->GetActiveWindow(); } +bool IsFrameVisible(views::Widget* widget) { + views::NonClientFrameView* frame_view = + widget->non_client_view() ? widget->non_client_view()->frame_view() + : nullptr; + return frame_view && frame_view->GetEnabled() && frame_view->GetVisible(); +} + } // namespace class WindowStateChangeObserver : public aura::WindowObserver { @@ -3060,39 +3067,60 @@ } // Frame information - auto* widget = views::Widget::GetWidgetForNativeWindow(window); - auto* immersive_controller = - ash::ImmersiveFullscreenController::Get(widget); - // The widget that hosts the immersive frame can be different from the - // application's widget itself. Use the widget from the immersive - // controller to obtain the FrameHeader. - auto* frame_header = ash::FrameHeader::Get(immersive_controller->widget()); - window_info.caption_height = frame_header->GetHeaderHeight(); + auto* immersive_controller = ash::ImmersiveFullscreenController::Get( + views::Widget::GetWidgetForNativeWindow(window)); + if (immersive_controller) { + // The widget that hosts the immersive frame can be different from the + // application's widget itself. Use the widget from the immersive + // controller to obtain the FrameHeader. + auto* widget = immersive_controller->widget(); + if (immersive_controller->IsEnabled()) { + window_info.frame_mode = + api::autotest_private::FrameMode::FRAME_MODE_IMMERSIVE; + window_info.is_frame_visible = immersive_controller->IsRevealed(); + } else { + window_info.frame_mode = + api::autotest_private::FrameMode::FRAME_MODE_NORMAL; + window_info.is_frame_visible = IsFrameVisible(widget); + } + auto* frame_header = ash::FrameHeader::Get(widget); + window_info.caption_height = frame_header->GetHeaderHeight(); - const ash::CaptionButtonModel* button_model = - frame_header->GetCaptionButtonModel(); - int caption_button_enabled_status = 0; - int caption_button_visible_status = 0; + const ash::CaptionButtonModel* button_model = + frame_header->GetCaptionButtonModel(); + int caption_button_enabled_status = 0; + int caption_button_visible_status = 0; - constexpr views::CaptionButtonIcon all_button_icons[] = { - views::CAPTION_BUTTON_ICON_MINIMIZE, - views::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, - views::CAPTION_BUTTON_ICON_CLOSE, - views::CAPTION_BUTTON_ICON_LEFT_SNAPPED, - views::CAPTION_BUTTON_ICON_RIGHT_SNAPPED, - views::CAPTION_BUTTON_ICON_BACK, - views::CAPTION_BUTTON_ICON_LOCATION, - views::CAPTION_BUTTON_ICON_MENU, - views::CAPTION_BUTTON_ICON_ZOOM}; + constexpr views::CaptionButtonIcon all_button_icons[] = { + views::CAPTION_BUTTON_ICON_MINIMIZE, + views::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE, + views::CAPTION_BUTTON_ICON_CLOSE, + views::CAPTION_BUTTON_ICON_LEFT_SNAPPED, + views::CAPTION_BUTTON_ICON_RIGHT_SNAPPED, + views::CAPTION_BUTTON_ICON_BACK, + views::CAPTION_BUTTON_ICON_LOCATION, + views::CAPTION_BUTTON_ICON_MENU, + views::CAPTION_BUTTON_ICON_ZOOM}; - for (const auto button : all_button_icons) { - if (button_model->IsEnabled(button)) - caption_button_enabled_status |= (1 << button); - if (button_model->IsVisible(button)) - caption_button_visible_status |= (1 << button); + for (const auto button : all_button_icons) { + if (button_model->IsEnabled(button)) + caption_button_enabled_status |= (1 << button); + if (button_model->IsVisible(button)) + caption_button_visible_status |= (1 << button); + } + window_info.caption_button_enabled_status = caption_button_enabled_status; + window_info.caption_button_visible_status = caption_button_visible_status; + } else { + auto* widget = views::Widget::GetWidgetForNativeWindow(window); + // All widgets for app windows in chromeos should have a frame with + // immersive controller. Non app windows may not have a frame and + // frame mode will be NONE. + DCHECK(!widget || widget->GetNativeWindow()->type() != + aura::client::WINDOW_TYPE_NORMAL); + window_info.frame_mode = + api::autotest_private::FrameMode::FRAME_MODE_NONE; + window_info.is_frame_visible = false; } - window_info.caption_button_enabled_status = caption_button_enabled_status; - window_info.caption_button_visible_status = caption_button_visible_status; result_list.emplace_back(std::move(window_info)); }
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular.cc index 3560207e..2e55d815 100644 --- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular.cc +++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular.cc
@@ -127,7 +127,6 @@ // OnFeatureStatesChanged() will call back on this method when feature state // changes. PA_LOG(VERBOSE) << "Smart Lock is not enabled by user; aborting."; - SetStoredRemoteDevices(base::ListValue()); SetProximityAuthDevices(GetAccountId(), multidevice::RemoteDeviceRefList(), base::nullopt /* local_device */); return; @@ -149,7 +148,6 @@ } else { PA_LOG(ERROR) << "Smart Lock is enabled by user, but no unlock key is " "present; aborting."; - SetStoredRemoteDevices(base::ListValue()); SetProximityAuthDevices(GetAccountId(), multidevice::RemoteDeviceRefList(), base::nullopt /* local_device */);
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular_unittest.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular_unittest.cc index e009389..c1f167f9 100644 --- a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular_unittest.cc +++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_regular_unittest.cc
@@ -416,14 +416,6 @@ VerifyGetRemoteDevices(true /* are_local_and_remote_devices_expected */); } -TEST_F(EasyUnlockServiceRegularTest, GetRemoteDevices_SmartLockHostRemoved) { - InitializeService(true /* should_initialize_all_dependencies */); - VerifyGetRemoteDevices(true /* are_local_and_remote_devices_expected */); - - SetSyncedDevices(multidevice::RemoteDeviceRefList() /* synced_devices */); - VerifyGetRemoteDevices(false /* are_local_and_remote_devices_expected */); -} - TEST_F(EasyUnlockServiceRegularTest, GetRemoteDevices_SmartLockHostChanged) { InitializeService(true /* should_initialize_all_dependencies */); SetScreenLockState(true /* is_locked */);
diff --git a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_download_client.cc b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_download_client.cc index 691211e..af8bc95 100644 --- a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_download_client.cc +++ b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_download_client.cc
@@ -73,11 +73,15 @@ void PluginVmImageDownloadClient::OnDownloadFailed( const std::string& guid, const download::CompletionInfo& completion_info, - download::Client::FailureReason reason) { + download::Client::FailureReason clientReason) { VLOG(1) << __func__ << " called"; - switch (reason) { + auto managerReason = + PluginVmImageManager::FailureReason::DOWNLOAD_FAILED_UNKNOWN; + switch (clientReason) { case download::Client::FailureReason::NETWORK: VLOG(1) << "Failure reason: NETWORK"; + managerReason = + PluginVmImageManager::FailureReason::DOWNLOAD_FAILED_NETWORK; break; case download::Client::FailureReason::UPLOAD_TIMEDOUT: VLOG(1) << "Failure reason: UPLOAD_TIMEDOUT"; @@ -90,6 +94,8 @@ break; case download::Client::FailureReason::ABORTED: VLOG(1) << "Failure reason: ABORTED"; + managerReason = + PluginVmImageManager::FailureReason::DOWNLOAD_FAILED_ABORTED; break; case download::Client::FailureReason::CANCELLED: VLOG(1) << "Failure reason: CANCELLED"; @@ -101,10 +107,10 @@ if (old_downloads_.find(guid) != old_downloads_.end()) return; - if (reason == download::Client::FailureReason::CANCELLED) + if (clientReason == download::Client::FailureReason::CANCELLED) GetManager()->OnDownloadCancelled(); else - GetManager()->OnDownloadFailed(); + GetManager()->OnDownloadFailed(managerReason); } void PluginVmImageDownloadClient::OnDownloadSucceeded(
diff --git a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.cc b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.cc index 1dc0ebb..4b90365e 100644 --- a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.cc +++ b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.cc
@@ -53,7 +53,7 @@ LOG(ERROR) << "Download of a PluginVm image couldn't be started as" << " another PluginVm image is currently being processed " << "in state " << GetStateName(state_); - OnDownloadFailed(); + OnDownloadFailed(FailureReason::OPERATION_IN_PROGRESS); return; } @@ -63,14 +63,14 @@ if (!IsPluginVmAllowedForProfile(profile_)) { LOG(ERROR) << "Download of PluginVm image cannot be started because " << "the user is not allowed to run PluginVm"; - OnDownloadFailed(); + OnDownloadFailed(FailureReason::NOT_ALLOWED); return; } state_ = State::DOWNLOADING; GURL url = GetPluginVmImageDownloadUrl(); if (url.is_empty()) { - OnDownloadFailed(); + OnDownloadFailed(FailureReason::INVALID_IMAGE_URL); return; } download_service_->StartDownload(GetDownloadParams(url)); @@ -105,7 +105,7 @@ if (!VerifyDownload(info.hash256)) { LOG(ERROR) << "Downloaded PluginVm image archive hash doesn't match " << "hash specified by the PluginVmImage policy"; - OnDownloadFailed(); + OnDownloadFailed(FailureReason::HASH_MISMATCH); return; } @@ -126,12 +126,12 @@ state_ = State::NOT_STARTED; } -void PluginVmImageManager::OnDownloadFailed() { +void PluginVmImageManager::OnDownloadFailed(FailureReason reason) { state_ = State::DOWNLOAD_FAILED; RemoveTemporaryPluginVmImageArchiveIfExists(); current_download_guid_.clear(); if (observer_) - observer_->OnDownloadFailed(); + observer_->OnDownloadFailed(reason); } void PluginVmImageManager::StartImport() { @@ -139,7 +139,7 @@ LOG(ERROR) << "Importing of PluginVm image couldn't proceed as current " << "state is " << GetStateName(state_) << " not " << GetStateName(State::DOWNLOADED); - OnImported(false); + OnImported(FailureReason::LOGIC_ERROR); return; } @@ -157,7 +157,7 @@ void PluginVmImageManager::OnPluginVmDispatcherStarted(bool success) { if (!success) { LOG(ERROR) << "Failed to start PluginVm dispatcher service"; - OnImported(false); + OnImported(FailureReason::DISPATCHER_NOT_AVAILABLE); return; } GetConciergeClient()->WaitForServiceToBeAvailable( @@ -168,12 +168,12 @@ void PluginVmImageManager::OnConciergeAvailable(bool success) { if (!success) { LOG(ERROR) << "Concierge did not become available"; - OnImported(false); + OnImported(FailureReason::CONCIERGE_NOT_AVAILABLE); return; } if (!GetConciergeClient()->IsDiskImageProgressSignalConnected()) { LOG(ERROR) << "Disk image progress signal is not connected"; - OnImported(false); + OnImported(FailureReason::SIGNAL_NOT_CONNECTED); return; } VLOG(1) << "Plugin VM dispatcher service has been started and disk image " @@ -212,7 +212,7 @@ if (!maybeFd.has_value()) { LOG(ERROR) << "Could not open downloaded image archive"; - OnImported(false); + OnImported(FailureReason::COULD_NOT_OPEN_IMAGE); return; } @@ -237,7 +237,7 @@ if (!reply.has_value()) { LOG(ERROR) << "Could not retrieve response from ImportDiskImage call to " << "concierge"; - OnImported(false); + OnImported(FailureReason::INVALID_IMPORT_RESPONSE); return; } @@ -251,7 +251,7 @@ vm_tools::concierge::DiskImageStatus::DISK_STATUS_IN_PROGRESS) { LOG(ERROR) << "Disk image is not in progress. Status: " << response.status() << ", " << response.failure_reason(); - OnImported(false); + OnImported(FailureReason::UNEXPECTED_DISK_IMAGE_STATUS); return; } @@ -289,7 +289,7 @@ LOG(ERROR) << "Disk image status signal has status: " << status << " with error message: " << signal.failure_reason() << " and current progress: " << percent_completed; - OnImported(false); + OnImported(FailureReason::UNEXPECTED_DISK_IMAGE_STATUS); return; } } @@ -308,7 +308,7 @@ if (!reply.has_value()) { LOG(ERROR) << "Could not retrieve response from DiskImageStatus call to " << "concierge"; - OnImported(false); + OnImported(FailureReason::INVALID_DISK_IMAGE_STATUS_RESPONSE); return; } @@ -318,23 +318,25 @@ vm_tools::concierge::DiskImageStatus::DISK_STATUS_CREATED) { LOG(ERROR) << "Disk image is not created. Status: " << response.status() << ", " << response.failure_reason(); - OnImported(false); + OnImported(FailureReason::IMAGE_IMPORT_FAILED); return; } - OnImported(true); + OnImported(base::nullopt); } -void PluginVmImageManager::OnImported(bool success) { +void PluginVmImageManager::OnImported( + base::Optional<FailureReason> failure_reason) { GetConciergeClient()->RemoveDiskImageObserver(this); RemoveTemporaryPluginVmImageArchiveIfExists(); current_import_command_uuid_.clear(); - if (!success) { + if (failure_reason) { LOG(ERROR) << "Image import failed"; state_ = State::IMPORT_FAILED; - if (observer_) - observer_->OnImportFailed(); + if (observer_) { + observer_->OnImportFailed(*failure_reason); + } return; } @@ -505,7 +507,7 @@ if (start_result == download::DownloadParams::ACCEPTED) current_download_guid_ = download_guid; else - OnDownloadFailed(); + OnDownloadFailed(FailureReason::DOWNLOAD_FAILED_UNKNOWN); } bool PluginVmImageManager::VerifyDownload(
diff --git a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.h b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.h index a44017e..4acba7e 100644 --- a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.h +++ b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager.h
@@ -40,6 +40,27 @@ : public KeyedService, public chromeos::ConciergeClient::DiskImageObserver { public: + // FailureReasons values can be shown to the user. Do not reorder or renumber + // these values without careful consideration. + enum class FailureReason { + LOGIC_ERROR = 0, + SIGNAL_NOT_CONNECTED = 1, + OPERATION_IN_PROGRESS = 2, + NOT_ALLOWED = 3, + INVALID_IMAGE_URL = 4, + UNEXPECTED_DISK_IMAGE_STATUS = 5, + INVALID_DISK_IMAGE_STATUS_RESPONSE = 6, + DOWNLOAD_FAILED_UNKNOWN = 7, + DOWNLOAD_FAILED_NETWORK = 8, + DOWNLOAD_FAILED_ABORTED = 9, + HASH_MISMATCH = 10, + DISPATCHER_NOT_AVAILABLE = 11, + CONCIERGE_NOT_AVAILABLE = 12, + COULD_NOT_OPEN_IMAGE = 13, + INVALID_IMPORT_RESPONSE = 14, + IMAGE_IMPORT_FAILED = 15, + }; + // Observer class for the PluginVm image related events. class Observer { public: @@ -50,13 +71,12 @@ base::TimeDelta elapsed_time) = 0; virtual void OnDownloadCompleted() = 0; virtual void OnDownloadCancelled() = 0; - // TODO(https://crbug.com/904851): Add failure reasons. - virtual void OnDownloadFailed() = 0; + virtual void OnDownloadFailed(FailureReason reason) = 0; virtual void OnImportProgressUpdated(int percent_completed, base::TimeDelta elapsed_time) = 0; virtual void OnImported() = 0; virtual void OnImportCancelled() = 0; - virtual void OnImportFailed() = 0; + virtual void OnImportFailed(FailureReason reason) = 0; }; explicit PluginVmImageManager(Profile* profile); @@ -86,7 +106,7 @@ int64_t content_length); void OnDownloadCompleted(const download::CompletionInfo& info); void OnDownloadCancelled(); - void OnDownloadFailed(); + void OnDownloadFailed(FailureReason reason); // ConciergeClient::DiskImageObserver: void OnDiskImageProgress( @@ -171,8 +191,9 @@ void OnFinalDiskImageStatus( base::Optional<vm_tools::concierge::DiskImageStatusResponse> reply); - // Finishes the processing of PluginVm image. - void OnImported(bool success); + // Finishes the processing of PluginVm image. If |failure_reason| has a value, + // then the import has failed, otherwise it was successful. + void OnImported(base::Optional<FailureReason> failure_reason); // Callback for the concierge CancelDiskImageOperation call. void OnImportDiskImageCancelled(
diff --git a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager_unittest.cc b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager_unittest.cc index 7678ab8..757cb633 100644 --- a/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager_unittest.cc +++ b/chrome/browser/chromeos/plugin_vm/plugin_vm_image_manager_unittest.cc
@@ -62,12 +62,14 @@ base::TimeDelta elapsed_time)); MOCK_METHOD0(OnDownloadCompleted, void()); MOCK_METHOD0(OnDownloadCancelled, void()); - MOCK_METHOD0(OnDownloadFailed, void()); + MOCK_METHOD1(OnDownloadFailed, + void(plugin_vm::PluginVmImageManager::FailureReason)); MOCK_METHOD2(OnImportProgressUpdated, void(int percent_completed, base::TimeDelta elapsed_time)); MOCK_METHOD0(OnImported, void()); MOCK_METHOD0(OnImportCancelled, void()); - MOCK_METHOD0(OnImportFailed, void()); + MOCK_METHOD1(OnImportFailed, + void(plugin_vm::PluginVmImageManager::FailureReason)); }; class PluginVmImageManagerTest : public testing::Test { @@ -252,7 +254,10 @@ TEST_F(PluginVmImageManagerTest, CanProceedWithANewImageWhenFailedTest) { SetupConciergeForSuccessfulDiskImageImport(fake_concierge_client_); - EXPECT_CALL(*observer_, OnDownloadFailed()); + EXPECT_CALL( + *observer_, + OnDownloadFailed( + PluginVmImageManager::FailureReason::DOWNLOAD_FAILED_ABORTED)); EXPECT_CALL(*observer_, OnDownloadCompleted()); EXPECT_CALL(*observer_, OnImportProgressUpdated(50.0, _)); EXPECT_CALL(*observer_, OnImported()); @@ -287,7 +292,9 @@ SetupConciergeForSuccessfulDiskImageImport(fake_concierge_client_); EXPECT_CALL(*observer_, OnDownloadCompleted()); - EXPECT_CALL(*observer_, OnImportFailed()); + EXPECT_CALL(*observer_, + OnImportFailed( + PluginVmImageManager::FailureReason::COULD_NOT_OPEN_IMAGE)); ProcessImageUntilImporting(); // Should fail as fake downloaded file isn't set. @@ -318,7 +325,9 @@ TEST_F(PluginVmImageManagerTest, EmptyPluginVmImageUrlTest) { SetPluginVmImagePref("", kHash); - EXPECT_CALL(*observer_, OnDownloadFailed()); + EXPECT_CALL( + *observer_, + OnDownloadFailed(PluginVmImageManager::FailureReason::INVALID_IMAGE_URL)); ProcessImageUntilImporting(); histogram_tester_->ExpectTotalCount(kPluginVmImageDownloadedSizeHistogram, 0); @@ -334,7 +343,9 @@ TEST_F(PluginVmImageManagerTest, CannotStartDownloadIfPluginVmGetsDisabled) { profile_->ScopedCrosSettingsTestHelper()->SetBoolean( chromeos::kPluginVmAllowed, false); - EXPECT_CALL(*observer_, OnDownloadFailed()); + EXPECT_CALL( + *observer_, + OnDownloadFailed(PluginVmImageManager::FailureReason::NOT_ALLOWED)); ProcessImageUntilImporting(); }
diff --git a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc index 79db3bc2..2eb864f 100644 --- a/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc +++ b/chrome/browser/chromeos/printing/cups_print_job_manager_impl.cc
@@ -14,17 +14,16 @@ #include "base/compiler_specific.h" #include "base/metrics/histogram_macros.h" #include "base/optional.h" -#include "base/sequenced_task_runner.h" #include "base/strings/utf_string_conversions.h" #include "base/task/post_task.h" #include "base/task_runner_util.h" -#include "base/threading/scoped_blocking_call.h" #include "base/threading/thread_task_runner_handle.h" #include "base/timer/timer.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chromeos/printing/cups_print_job.h" #include "chrome/browser/chromeos/printing/cups_printers_manager.h" #include "chrome/browser/chromeos/printing/cups_printers_manager_factory.h" +#include "chrome/browser/chromeos/printing/cups_wrapper.h" #include "chrome/browser/chromeos/printing/history/print_job_info.pb.h" #include "chrome/browser/chromeos/printing/history/print_job_info_proto_conversions.h" #include "chrome/browser/printing/print_job.h" @@ -36,7 +35,6 @@ #include "content/public/browser/browser_thread.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_service.h" -#include "printing/backend/cups_connection.h" #include "printing/printed_document.h" #include "printing/printing_utils.h" #include "ui/base/l10n/l10n_util.h" @@ -68,16 +66,6 @@ RESULT_MAX }; -// Container for results from CUPS queries. -struct QueryResult { - QueryResult() = default; - QueryResult(const QueryResult& other) = default; - ~QueryResult() = default; - - bool success; - std::vector<::printing::QueueStatus> queues; -}; - // Returns the appropriate JobResultForHistogram for a given |state|. Only // FINISHED and PRINTER_CANCEL are derived from CupsPrintJob::State. JobResultForHistogram ResultForHistogram(State state) { @@ -220,63 +208,11 @@ namespace chromeos { -// A wrapper around the CUPS connection to ensure that it's always accessed on -// the same sequence. -class CupsWrapper { - public: - CupsWrapper() : cups_connection_(GURL(), HTTP_ENCRYPT_NEVER, false) { - DETACH_FROM_SEQUENCE(sequence_checker_); - } - - ~CupsWrapper() = default; - - // Query CUPS for the current jobs for the given |printer_ids|. Writes result - // to |result|. - void QueryCups(const std::vector<std::string>& printer_ids, - QueryResult* result) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - base::ScopedBlockingCall scoped_blocking_call( - FROM_HERE, base::BlockingType::MAY_BLOCK); - - result->success = cups_connection_.GetJobs(printer_ids, &result->queues); - } - - // Cancel the print job on the blocking thread. - void CancelJobImpl(const std::string& printer_id, const int job_id) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - base::ScopedBlockingCall scoped_blocking_call( - FROM_HERE, base::BlockingType::MAY_BLOCK); - - std::unique_ptr<::printing::CupsPrinter> printer = - cups_connection_.GetPrinter(printer_id); - if (!printer) { - LOG(WARNING) << "Printer not found: " << printer_id; - return; - } - - if (!printer->CancelJob(job_id)) { - // This is not expected to fail but log it if it does. - LOG(WARNING) << "Cancelling job failed. Job may be stuck in queue."; - } - } - - private: - ::printing::CupsConnection cups_connection_; - SEQUENCE_CHECKER(sequence_checker_); - - DISALLOW_COPY_AND_ASSIGN(CupsWrapper); -}; - class CupsPrintJobManagerImpl : public CupsPrintJobManager, public content::NotificationObserver { public: explicit CupsPrintJobManagerImpl(Profile* profile) : CupsPrintJobManager(profile), - query_runner_(base::CreateSequencedTaskRunner(base::TaskTraits{ - base::ThreadPool(), base::TaskPriority::BEST_EFFORT, - base::MayBlock(), base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), - cups_wrapper_(new CupsWrapper(), - base::OnTaskRunnerDeleter(query_runner_)), weak_ptr_factory_(this) { timer_.SetTaskRunner( base::CreateSingleThreadTaskRunner({content::BrowserThread::UI})); @@ -405,10 +341,7 @@ // Stop montioring jobs after we cancel them. The user no longer cares. jobs_.erase(job->GetUniqueId()); - query_runner_->PostTask( - FROM_HERE, base::BindOnce(&CupsWrapper::CancelJobImpl, - base::Unretained(cups_wrapper_.get()), - printer_id, job_id)); + cups_wrapper_.CancelJob(printer_id, job_id); } // Schedule a query of CUPS for print job status with a delay of |delay|. @@ -418,8 +351,6 @@ weak_ptr_factory_.GetWeakPtr())); } - // Schedule the CUPS query off the UI thread. Posts results back to UI thread - // to UpdateJobs. void PostQuery() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -430,23 +361,16 @@ } std::vector<std::string> ids{printer_ids.begin(), printer_ids.end()}; - auto result = std::make_unique<QueryResult>(); - QueryResult* result_ptr = result.get(); - // Runs a query on |query_runner_| which will rejoin this sequnece on - // completion. - query_runner_->PostTaskAndReply( - FROM_HERE, - base::BindOnce(&CupsWrapper::QueryCups, - base::Unretained(cups_wrapper_.get()), ids, result_ptr), - base::BindOnce(&CupsPrintJobManagerImpl::UpdateJobs, - weak_ptr_factory_.GetWeakPtr(), std::move(result))); + cups_wrapper_.QueryCups(ids, + base::BindOnce(&CupsPrintJobManagerImpl::UpdateJobs, + weak_ptr_factory_.GetWeakPtr())); } // Process jobs from CUPS and perform notifications. // Use job information to update local job states. Previously completed jobs // could be in |jobs| but those are ignored as we will not emit updates for // them after they are completed. - void UpdateJobs(std::unique_ptr<QueryResult> result) { + void UpdateJobs(std::unique_ptr<CupsWrapper::QueryResult> result) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // If the query failed, either retry or purge. @@ -580,9 +504,7 @@ base::RepeatingTimer timer_; content::NotificationRegistrar registrar_; - // Task runner for queries to CUPS. - scoped_refptr<base::SequencedTaskRunner> query_runner_; - std::unique_ptr<CupsWrapper, base::OnTaskRunnerDeleter> cups_wrapper_; + CupsWrapper cups_wrapper_; base::WeakPtrFactory<CupsPrintJobManagerImpl> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(CupsPrintJobManagerImpl);
diff --git a/chrome/browser/chromeos/printing/cups_wrapper.cc b/chrome/browser/chromeos/printing/cups_wrapper.cc new file mode 100644 index 0000000..78dc3ab --- /dev/null +++ b/chrome/browser/chromeos/printing/cups_wrapper.cc
@@ -0,0 +1,115 @@ +// 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. + +#include "chrome/browser/chromeos/printing/cups_wrapper.h" + +#include <cups/cups.h> + +#include "base/callback.h" +#include "base/task/post_task.h" +#include "base/task/task_traits.h" +#include "base/task_runner_util.h" +#include "base/threading/scoped_blocking_call.h" +#include "printing/backend/cups_printer.h" +#include "url/gurl.h" + +namespace chromeos { + +CupsWrapper::QueryResult::QueryResult() = default; + +CupsWrapper::QueryResult::~QueryResult() = default; + +class CupsWrapper::Backend { + public: + Backend(); + Backend(const Backend&) = delete; + Backend& operator=(const Backend&) = delete; + ~Backend(); + + std::unique_ptr<QueryResult> QueryCups( + const std::vector<std::string>& printer_ids); + + void CancelJob(const std::string& printer_id, int job_id); + + private: + ::printing::CupsConnection cups_connection_; + + SEQUENCE_CHECKER(sequence_checker_); +}; + +CupsWrapper::Backend::Backend() + : cups_connection_(GURL(), HTTP_ENCRYPT_NEVER, false) { + DETACH_FROM_SEQUENCE(sequence_checker_); +} + +CupsWrapper::Backend::~Backend() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); +} + +std::unique_ptr<CupsWrapper::QueryResult> CupsWrapper::Backend::QueryCups( + const std::vector<std::string>& printer_ids) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + auto result = std::make_unique<CupsWrapper::QueryResult>(); + base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, + base::BlockingType::MAY_BLOCK); + result->success = cups_connection_.GetJobs(printer_ids, &result->queues); + return result; +} + +void CupsWrapper::Backend::CancelJob(const std::string& printer_id, + int job_id) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + base::ScopedBlockingCall scoped_blocking_call(FROM_HERE, + base::BlockingType::MAY_BLOCK); + + std::unique_ptr<::printing::CupsPrinter> printer = + cups_connection_.GetPrinter(printer_id); + if (!printer) { + LOG(WARNING) << "Printer not found: " << printer_id; + return; + } + + if (!printer->CancelJob(job_id)) { + // This is not expected to fail but log it if it does. + LOG(WARNING) << "Cancelling job failed. Job may be stuck in queue."; + } +} + +CupsWrapper::CupsWrapper() + : backend_(std::make_unique<Backend>()), + backend_task_runner_(base::CreateSequencedTaskRunner( + {base::ThreadPool(), base::MayBlock(), + base::TaskPriority::BEST_EFFORT, + base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})) {} + +CupsWrapper::~CupsWrapper() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + backend_task_runner_->DeleteSoon(FROM_HERE, backend_.release()); +} + +void CupsWrapper::QueryCups( + const std::vector<std::string>& printer_ids, + base::OnceCallback<void(std::unique_ptr<CupsWrapper::QueryResult>)> + callback) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + // It's safe to pass unretained pointer here because we delete |backend_| on + // the same task runner. + base::PostTaskAndReplyWithResult( + backend_task_runner_.get(), FROM_HERE, + base::BindOnce(&Backend::QueryCups, base::Unretained(backend_.get()), + printer_ids), + std::move(callback)); +} + +void CupsWrapper::CancelJob(const std::string& printer_id, int job_id) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + // It's safe to pass unretained pointer here because we delete |backend_| on + // the same task runner. + backend_task_runner_->PostTask( + FROM_HERE, + base::BindOnce(&Backend::CancelJob, base::Unretained(backend_.get()), + printer_id, job_id)); +} + +} // namespace chromeos
diff --git a/chrome/browser/chromeos/printing/cups_wrapper.h b/chrome/browser/chromeos/printing/cups_wrapper.h new file mode 100644 index 0000000..2a58187b5 --- /dev/null +++ b/chrome/browser/chromeos/printing/cups_wrapper.h
@@ -0,0 +1,64 @@ +// 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. + +#ifndef CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_WRAPPER_H_ +#define CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_WRAPPER_H_ + +#include <memory> +#include <string> +#include <vector> + +#include "base/callback_forward.h" +#include "base/sequence_checker.h" +#include "base/sequenced_task_runner.h" +#include "printing/backend/cups_connection.h" + +namespace chromeos { + +// A wrapper around the CUPS connection to ensure that it's always accessed on +// the same sequence and run in the appropriate sequence off of the calling +// sequence. +class CupsWrapper { + public: + // Container for results from CUPS queries. + struct QueryResult { + QueryResult(); + QueryResult(const QueryResult& other) = delete; + QueryResult& operator=(const QueryResult& other) = delete; + ~QueryResult(); + + bool success; + std::vector<::printing::QueueStatus> queues; + }; + + CupsWrapper(); + CupsWrapper(const CupsWrapper&) = delete; + CupsWrapper& operator=(const CupsWrapper&) = delete; + ~CupsWrapper(); + + // Queries CUPS for the current jobs for the given |printer_ids|. Passes + // the result to |callback|. + void QueryCups( + const std::vector<std::string>& printer_ids, + base::OnceCallback<void(std::unique_ptr<QueryResult>)> callback); + + // Cancels the print job on the blocking thread. + void CancelJob(const std::string& printer_id, int job_id); + + private: + class Backend; + // The |backend_| handles all communication with CUPS. + // It is instantiated on the thread |this| runs on but after that, + // must only be accessed and eventually destroyed via the + // |backend_task_runner_|. + std::unique_ptr<Backend> backend_; + + scoped_refptr<base::SequencedTaskRunner> backend_task_runner_; + + SEQUENCE_CHECKER(sequence_checker_); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_PRINTING_CUPS_WRAPPER_H_
diff --git a/chrome/browser/enterprise_reporting/report_scheduler.cc b/chrome/browser/enterprise_reporting/report_scheduler.cc index 56baaf7..d2f5cb2 100644 --- a/chrome/browser/enterprise_reporting/report_scheduler.cc +++ b/chrome/browser/enterprise_reporting/report_scheduler.cc
@@ -36,14 +36,16 @@ // Reads DM token and client id. Returns true if boths are non empty. bool GetDMTokenAndDeviceId(std::string* dm_token, std::string* client_id) { DCHECK(dm_token && client_id); - *dm_token = policy::BrowserDMTokenStorage::Get()->RetrieveDMToken(); + auto browser_dm_token = + policy::BrowserDMTokenStorage::Get()->RetrieveBrowserDMToken(); *client_id = policy::BrowserDMTokenStorage::Get()->RetrieveClientId(); - if (dm_token->empty() || client_id->empty()) { + if (!browser_dm_token.is_valid() || client_id->empty()) { VLOG(1) << "Enterprise reporting is disabled because device is not enrolled."; return false; } + *dm_token = browser_dm_token.value(); return true; }
diff --git a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc index c5b8d64f..7ca027f 100644 --- a/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc +++ b/chrome/browser/extensions/api/declarative_net_request/declarative_net_request_browsertest.cc
@@ -458,7 +458,7 @@ void AddDynamicRules(const ExtensionId& extension_id, const std::vector<TestRule>& rules) { static constexpr char kScript[] = R"( - chrome.declarativeNetRequest.addDynamicRules($1, function () { + chrome.declarativeNetRequest.updateDynamicRules([], $1, function () { window.domAutomationController.send(chrome.runtime.lastError ? chrome.runtime.lastError.message : 'success'); }); @@ -478,7 +478,7 @@ void RemoveDynamicRules(const ExtensionId& extension_id, const std::vector<int> rule_ids) { static constexpr char kScript[] = R"( - chrome.declarativeNetRequest.removeDynamicRules($1, function () { + chrome.declarativeNetRequest.updateDynamicRules($1, [], function () { window.domAutomationController.send(chrome.runtime.lastError ? chrome.runtime.lastError.message : 'success'); });
diff --git a/chrome/browser/media/webrtc/media_stream_devices_controller.cc b/chrome/browser/media/webrtc/media_stream_devices_controller.cc index 90d8ee7..77cb933 100644 --- a/chrome/browser/media/webrtc/media_stream_devices_controller.cc +++ b/chrome/browser/media/webrtc/media_stream_devices_controller.cc
@@ -39,7 +39,7 @@ #if defined(OS_ANDROID) #include "chrome/browser/android/android_theme_resources.h" -#include "chrome/browser/android/preferences/pref_service_bridge.h" +#include "chrome/browser/android/preferences/website_preference_bridge.h" #include "chrome/browser/permissions/permission_dialog_delegate.h" #include "chrome/browser/permissions/permission_update_infobar_delegate_android.h" #include "ui/android/window_android.h" @@ -569,7 +569,7 @@ return false; std::vector<std::string> android_permissions; - PrefServiceBridge::GetAndroidPermissionsForContentSetting( + WebsitePreferenceBridge::GetAndroidPermissionsForContentSetting( content_type, &android_permissions); for (const auto& android_permission : android_permissions) { if (!window_android->HasPermission(android_permission) &&
diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc index 170b888..023f7bb 100644 --- a/chrome/browser/pdf/pdf_extension_test.cc +++ b/chrome/browser/pdf/pdf_extension_test.cc
@@ -48,6 +48,9 @@ #include "chrome/test/base/ui_test_utils.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/download/public/common/download_item.h" +#include "components/guest_view/browser/guest_view_manager.h" +#include "components/guest_view/browser/guest_view_manager_delegate.h" +#include "components/guest_view/browser/test_guest_view_manager.h" #include "components/viz/common/features.h" #include "components/zoom/page_zoom.h" #include "components/zoom/test/zoom_test_utils.h" @@ -74,6 +77,7 @@ #include "content/public/test/hit_test_region_observer.h" #include "content/public/test/test_navigation_observer.h" #include "content/public/test/url_loader_interceptor.h" +#include "extensions/browser/api/extensions_api_client.h" #include "extensions/browser/extension_registry.h" #include "extensions/common/manifest_handlers/mime_types_handler.h" #include "extensions/test/result_catcher.h" @@ -96,6 +100,10 @@ #endif using content::WebContents; +using extensions::ExtensionsAPIClient; +using guest_view::GuestViewManager; +using guest_view::TestGuestViewManager; +using guest_view::TestGuestViewManagerFactory; const int kNumberLoadTestParts = 10; @@ -393,6 +401,95 @@ } }; +class PDFExtensionTestWithTestGuestViewManager : public PDFExtensionTest { + public: + PDFExtensionTestWithTestGuestViewManager() { + GuestViewManager::set_factory_for_testing(&factory_); + } + + protected: + TestGuestViewManager* GetGuestViewManager() { + // TODO(wjmaclean): Re-implement FromBrowserContext in the + // TestGuestViewManager class to avoid all callers needing this cast. + auto* manager = static_cast<TestGuestViewManager*>( + TestGuestViewManager::FromBrowserContext(browser()->profile())); + // TestGuestViewManager::WaitForSingleGuestCreated can and will get called + // before a guest is created. Since GuestViewManager is usually not created + // until the first guest is created, this means that |manager| will be + // nullptr if trying to use the manager to wait for the first guest. Because + // of this, the manager must be created here if it does not already exist. + if (!manager) { + manager = static_cast<TestGuestViewManager*>( + GuestViewManager::CreateWithDelegate( + browser()->profile(), + ExtensionsAPIClient::Get()->CreateGuestViewManagerDelegate( + browser()->profile()))); + } + return manager; + } + + private: + TestGuestViewManagerFactory factory_; +}; + +IN_PROC_BROWSER_TEST_F(PDFExtensionTestWithTestGuestViewManager, + LoadingPdfDoesNotStealFocus) { + // Load test HTML, and verify the text area has focus. + GURL main_url(embedded_test_server()->GetURL("/pdf/two_iframes.html")); + ui_test_utils::NavigateToURL(browser(), main_url); + auto* embedder_web_contents = GetActiveWebContents(); + + // Make sure we can see the iframe's document. + ASSERT_TRUE( + content::EvalJs(embedder_web_contents, + "new Promise((resolve) => {" + " var iframe1 = document.getElementById('iframe1');" + " var iframe1doc = iframe1.contentDocument;" + " resolve(iframe1doc != null);" + "});") + .ExtractBool()); + + // Make sure the text area is focused. + ASSERT_TRUE(content::EvalJs( + embedder_web_contents, + "new Promise((resolve) => {" + " iframe1doc = " + " document.getElementById('iframe1').contentDocument;" + " resolve(iframe1doc.hasFocus());" + "});") + .ExtractBool()); + + GURL pdf_url(embedded_test_server()->GetURL("/pdf/test.pdf")); + ASSERT_TRUE(content::ExecJs( + embedder_web_contents, + content::JsReplace("document.getElementById('iframe2').src = $1;", + pdf_url.spec()))); + + // Verify the pdf has loaded. + auto* guest_web_contents = GetGuestViewManager()->WaitForSingleGuestCreated(); + ASSERT_TRUE(guest_web_contents); + EXPECT_NE(embedder_web_contents, guest_web_contents); + while (guest_web_contents->IsLoading()) { + base::RunLoop run_loop; + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); + run_loop.Run(); + } + + // Make sure the text area still has focus. + ASSERT_TRUE( + content::EvalJs( + embedder_web_contents, + "new Promise((resolve) => {" + " iframe1doc = " + " document.getElementById('iframe1').contentDocument;" + " text_area = iframe1doc.getElementById('text_area');" + " text_area_is_active = iframe1doc.activeElement == text_area;" + " resolve(iframe1doc.hasFocus() && text_area_is_active);" + "});") + .ExtractBool()); +} + class PDFExtensionLoadTest : public PDFExtensionTest, public testing::WithParamInterface<int> { public:
diff --git a/chrome/browser/permissions/permission_update_infobar_delegate_android.cc b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc index 82881df..9087463 100644 --- a/chrome/browser/permissions/permission_update_infobar_delegate_android.cc +++ b/chrome/browser/permissions/permission_update_infobar_delegate_android.cc
@@ -10,7 +10,7 @@ #include "base/android/jni_array.h" #include "chrome/android/chrome_jni_headers/PermissionUpdateInfoBarDelegate_jni.h" #include "chrome/browser/android/android_theme_resources.h" -#include "chrome/browser/android/preferences/pref_service_bridge.h" +#include "chrome/browser/android/preferences/website_preference_bridge.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/grit/chromium_strings.h" #include "chrome/grit/generated_resources.h" @@ -38,7 +38,7 @@ for (ContentSettingsType content_settings_type : content_settings_types) { int previous_size = permissions.size(); - PrefServiceBridge::GetAndroidPermissionsForContentSetting( + WebsitePreferenceBridge::GetAndroidPermissionsForContentSetting( content_settings_type, &permissions); bool has_all_permissions = true; @@ -111,7 +111,7 @@ for (ContentSettingsType content_settings_type : content_settings_types) { std::vector<std::string> android_permissions; - PrefServiceBridge::GetAndroidPermissionsForContentSetting( + WebsitePreferenceBridge::GetAndroidPermissionsForContentSetting( content_settings_type, &android_permissions); for (const auto& android_permission : android_permissions) {
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc index 09bf51b..9a6f5cd 100644 --- a/chrome/browser/profiles/profile_io_data.cc +++ b/chrome/browser/profiles/profile_io_data.cc
@@ -220,8 +220,7 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - std::unique_ptr<ProfileParams> params(new ProfileParams); - params->path = profile->GetPath(); + auto params = std::make_unique<ProfileParams>(); params->cookie_settings = CookieSettingsFactory::GetForProfile(profile); params->host_content_settings_map = @@ -256,7 +255,6 @@ } #endif - params->profile = profile; profile_params_ = std::move(params); scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
diff --git a/chrome/browser/profiles/profile_io_data.h b/chrome/browser/profiles/profile_io_data.h index 456e729..92721687 100644 --- a/chrome/browser/profiles/profile_io_data.h +++ b/chrome/browser/profiles/profile_io_data.h
@@ -89,8 +89,6 @@ ProfileParams(); ~ProfileParams(); - base::FilePath path; - scoped_refptr<content_settings::CookieSettings> cookie_settings; scoped_refptr<HostContentSettingsMap> host_content_settings_map; #if BUILDFLAG(ENABLE_EXTENSIONS) @@ -101,11 +99,6 @@ std::string username_hash; bool user_is_affiliated = false; #endif - - // The profile this struct was populated from. It's passed as a void* to - // ensure it's not accidently used on the IO thread. Before using it on the - // UI thread, call ProfileManager::IsValidProfile to ensure it's alive. - void* profile = nullptr; }; ProfileIOData();
diff --git a/chrome/browser/resource_coordinator/local_site_characteristics_database_browsertest.cc b/chrome/browser/resource_coordinator/local_site_characteristics_database_browsertest.cc index da00b53..a11c4af3 100644 --- a/chrome/browser/resource_coordinator/local_site_characteristics_database_browsertest.cc +++ b/chrome/browser/resource_coordinator/local_site_characteristics_database_browsertest.cc
@@ -614,7 +614,7 @@ HistoryServiceFactory::GetForProfile(browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) - ->DeleteURL(test_url); + ->DeleteURLs({test_url}); // The history gets cleared asynchronously. while (reader->UpdatesTitleInBackground() != performance_manager::SiteFeatureUsage::kSiteFeatureUsageUnknown) {
diff --git a/chrome/browser/resources/BUILD.gn b/chrome/browser/resources/BUILD.gn index 93d5f6e..5383807c 100644 --- a/chrome/browser/resources/BUILD.gn +++ b/chrome/browser/resources/BUILD.gn
@@ -340,21 +340,25 @@ if (enable_print_preview) { grit("print_preview_resources") { + # The .grd contains references to generated files. + source_is_generated = true + + grit_flags = [ + "-E", + "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), + ] + if (optimize_webui) { source = "print_preview/print_preview_resources_vulcanized.grd" - # The .grd contains references to generated files. - source_is_generated = true - deps = [ "//chrome/browser/resources/print_preview:build", ] - grit_flags = [ - "-E", - "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), - ] } else { source = "print_preview/print_preview_resources.grd" + deps = [ + "//chrome/browser/resources/print_preview/ui:polymer3_elements", + ] } defines = chrome_grit_defines
diff --git a/chrome/browser/resources/bookmarks/BUILD.gn b/chrome/browser/resources/bookmarks/BUILD.gn index 5029f2a5..a3d0734 100644 --- a/chrome/browser/resources/bookmarks/BUILD.gn +++ b/chrome/browser/resources/bookmarks/BUILD.gn
@@ -55,6 +55,7 @@ ":actions", ":api_listener", ":app", + ":browser_proxy", ":command_manager", ":constants", ":debouncer", @@ -88,6 +89,7 @@ js_library("api_listener") { deps = [ ":actions", + ":browser_proxy", ":debouncer", ":store", ":util", @@ -112,9 +114,17 @@ externs_list = [ "$externs_path/chrome_extensions.js" ] } +js_library("browser_proxy") { + deps = [ + ":constants", + "//ui/webui/resources/js:cr", + ] +} + js_library("command_manager") { deps = [ ":api_listener", + ":browser_proxy", ":dialog_focus_manager", ":edit_dialog", ":store_client", @@ -197,6 +207,7 @@ js_library("list") { deps = [ ":actions", + ":browser_proxy", ":command_manager", ":item", ":store_client",
diff --git a/chrome/browser/resources/bookmarks/api_listener.html b/chrome/browser/resources/bookmarks/api_listener.html index 8e6f5ee..91d42ecb 100644 --- a/chrome/browser/resources/bookmarks/api_listener.html +++ b/chrome/browser/resources/bookmarks/api_listener.html
@@ -1,5 +1,6 @@ <link rel="import" href="chrome://resources/html/cr.html"> <link rel="import" href="actions.html"> +<link rel="import" href="browser_proxy.html"> <link rel="import" href="debouncer.html"> <link rel="import" href="store.html"> <link rel="import" href="util.html">
diff --git a/chrome/browser/resources/bookmarks/api_listener.js b/chrome/browser/resources/bookmarks/api_listener.js index 7bc20ec2..0b8bd63 100644 --- a/chrome/browser/resources/bookmarks/api_listener.js +++ b/chrome/browser/resources/bookmarks/api_listener.js
@@ -172,12 +172,13 @@ function init() { listeners.forEach((listener) => listener.api.addListener(listener.fn)); - cr.sendWithPromise('getIncognitoAvailability') - .then(onIncognitoAvailabilityChanged); + const browserProxy = bookmarks.BrowserProxy.getInstance(); + browserProxy.getIncognitoAvailability().then( + onIncognitoAvailabilityChanged); cr.addWebUIListener( 'incognito-availability-changed', onIncognitoAvailabilityChanged); - cr.sendWithPromise('getCanEditBookmarks').then(onCanEditBookmarksChanged); + browserProxy.getCanEditBookmarks().then(onCanEditBookmarksChanged); cr.addWebUIListener( 'can-edit-bookmarks-changed', onCanEditBookmarksChanged); }
diff --git a/chrome/browser/resources/bookmarks/bookmarks_resources.grd b/chrome/browser/resources/bookmarks/bookmarks_resources.grd index 9a80d1a..5faa35c4 100644 --- a/chrome/browser/resources/bookmarks/bookmarks_resources.grd +++ b/chrome/browser/resources/bookmarks/bookmarks_resources.grd
@@ -34,6 +34,12 @@ <structure name="IDR_BOOKMARKS_BOOKMARKS_HTML" file="bookmarks.html" type="chrome_html" /> + <structure name="IDR_BOOKMARKS_BROWSER_PROXY_HTML" + file="browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_BOOKMARKS_BROWSER_PROXY_JS" + file="browser_proxy.js" + type="chrome_html" /> <structure name="IDR_BOOKMARKS_COMMAND_MANAGER_HTML" file="command_manager.html" type="chrome_html" />
diff --git a/chrome/browser/resources/bookmarks/browser_proxy.html b/chrome/browser/resources/bookmarks/browser_proxy.html new file mode 100644 index 0000000..d0156f1 --- /dev/null +++ b/chrome/browser/resources/bookmarks/browser_proxy.html
@@ -0,0 +1,4 @@ +<link rel="import" href="chrome://resources/html/cr.html"> +<link rel="import" href="constants.html"> + +<script src="browser_proxy.js"></script>
diff --git a/chrome/browser/resources/bookmarks/browser_proxy.js b/chrome/browser/resources/bookmarks/browser_proxy.js new file mode 100644 index 0000000..50da3879 --- /dev/null +++ b/chrome/browser/resources/bookmarks/browser_proxy.js
@@ -0,0 +1,50 @@ +// 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. + +cr.define('bookmarks', function() { + 'use strict'; + + class BrowserProxy { + /** + * @return {!Promise<!IncognitoAvailability>} Promise resolved with the + * current incognito mode preference. + */ + getIncognitoAvailability() { + return cr.sendWithPromise('getIncognitoAvailability'); + } + + /** + * @return {!Promise<boolean>} Promise resolved with whether the bookmarks + * can be edited. + */ + getCanEditBookmarks() { + return cr.sendWithPromise('getCanEditBookmarks'); + } + + /** + * @return {!Promise<string>} Promise resolved with the appropriate plural + * string for |messageName| with |itemCount| items. + */ + getPluralString(messageName, itemCount) { + return cr.sendWithPromise('getPluralString', messageName, itemCount); + } + + /** + * Notifies the metrics handler to record a histogram value. + * @param {string} histogram The name of the histogram to record + * @param {number} bucket The bucket to record + * @param {number} maxBucket The maximum bucket value in the histogram. + */ + recordInHistogram(histogram, bucket, maxBucket) { + chrome.send( + 'metricsHandler:recordInHistogram', [histogram, bucket, maxBucket]); + } + } + + cr.addSingletonGetter(BrowserProxy); + + return { + BrowserProxy: BrowserProxy, + }; +});
diff --git a/chrome/browser/resources/bookmarks/command_manager.html b/chrome/browser/resources/bookmarks/command_manager.html index ebd622e..39c8f28 100644 --- a/chrome/browser/resources/bookmarks/command_manager.html +++ b/chrome/browser/resources/bookmarks/command_manager.html
@@ -6,6 +6,7 @@ <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/html/cr/ui/command.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html"> +<link rel="import" href="browser_proxy.html"> <link rel="import" href="dialog_focus_manager.html"> <link rel="import" href="edit_dialog.html"> <link rel="import" href="shared_style.html">
diff --git a/chrome/browser/resources/bookmarks/command_manager.js b/chrome/browser/resources/bookmarks/command_manager.js index eb2408d..01288a6 100644 --- a/chrome/browser/resources/bookmarks/command_manager.js +++ b/chrome/browser/resources/bookmarks/command_manager.js
@@ -56,6 +56,9 @@ assert(CommandManager.instance_ == null); CommandManager.instance_ = this; + /** @private {!bookmarks.BrowserProxy} */ + this.browserProxy_ = bookmarks.BrowserProxy.getInstance(); + this.watch('globalCanEdit_', state => state.prefs.canEdit); this.updateFromStore(); @@ -318,8 +321,8 @@ labelPromise = Promise.resolve(loadTimeData.getString('toastItemCopied')); } else { - labelPromise = cr.sendWithPromise( - 'getPluralString', 'toastItemsCopied', idList.length); + labelPromise = this.browserProxy_.getPluralString( + 'toastItemsCopied', idList.length); } this.showTitleToast_( @@ -344,8 +347,8 @@ labelPromise = Promise.resolve(loadTimeData.getString('toastItemDeleted')); } else { - labelPromise = cr.sendWithPromise( - 'getPluralString', 'toastItemsDeleted', idList.length); + labelPromise = this.browserProxy_.getPluralString( + 'toastItemsDeleted', idList.length); } chrome.bookmarkManagerPrivate.removeTrees(idList, () => { @@ -778,7 +781,8 @@ Command.OPEN_BOOKMARK; } - bookmarks.util.recordEnumHistogram(histogram, command, Command.MAX_VALUE); + this.browserProxy_.recordInHistogram( + histogram, command, Command.MAX_VALUE); }, /** @@ -829,7 +833,7 @@ } else { this.openCommandMenuAtPosition(e.detail.x, e.detail.y, e.detail.source); } - bookmarks.util.recordEnumHistogram( + this.browserProxy_.recordInHistogram( 'BookmarkManager.CommandMenuOpened', e.detail.source, MenuSource.NUM_VALUES); },
diff --git a/chrome/browser/resources/bookmarks/list.html b/chrome/browser/resources/bookmarks/list.html index 776b00e..b3701d1 100644 --- a/chrome/browser/resources/bookmarks/list.html +++ b/chrome/browser/resources/bookmarks/list.html
@@ -3,6 +3,7 @@ <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-announcer/iron-a11y-announcer.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> +<link rel="import" href="browser_proxy.html"> <link rel="import" href="command_manager.html"> <link rel="import" href="item.html"> <link rel="import" href="shared_style.html">
diff --git a/chrome/browser/resources/bookmarks/list.js b/chrome/browser/resources/bookmarks/list.js index 3ff90db0c..b4e9e91 100644 --- a/chrome/browser/resources/bookmarks/list.js +++ b/chrome/browser/resources/bookmarks/list.js
@@ -119,8 +119,8 @@ // Trigger a layout of the iron list. Otherwise some elements may render // as blank entries. See https://crbug.com/848683 this.$.list.fire('iron-resize'); - const label = await cr.sendWithPromise( - 'getPluralString', 'listChanged', this.displayedList_.length); + const label = await bookmarks.BrowserProxy.getInstance().getPluralString( + 'listChanged', this.displayedList_.length); this.fire('iron-announce', {text: label}); if (!skipFocus && selectIndex > -1) {
diff --git a/chrome/browser/resources/bookmarks/util.js b/chrome/browser/resources/bookmarks/util.js index 67db95f..9e621fbd 100644 --- a/chrome/browser/resources/bookmarks/util.js +++ b/chrome/browser/resources/bookmarks/util.js
@@ -172,15 +172,6 @@ } /** - * @param {string} name - * @param {number} value - * @param {number} maxValue - */ - function recordEnumHistogram(name, value, maxValue) { - chrome.send('metricsHandler:recordInHistogram', [name, value, maxValue]); - } - - /** * @param {!Object<string, T>} map * @param {!Set<string>} ids * @return {!Object<string, T>} @@ -232,7 +223,6 @@ isShowingSearch: isShowingSearch, normalizeNode: normalizeNode, normalizeNodes: normalizeNodes, - recordEnumHistogram: recordEnumHistogram, removeIdsFromMap: removeIdsFromMap, removeIdsFromObject: removeIdsFromObject, removeIdsFromSet: removeIdsFromSet,
diff --git a/chrome/browser/resources/chromeos/camera/BUILD.gn b/chrome/browser/resources/chromeos/camera/BUILD.gn index 6c9ce20..21631df5 100644 --- a/chrome/browser/resources/chromeos/camera/BUILD.gn +++ b/chrome/browser/resources/chromeos/camera/BUILD.gn
@@ -119,7 +119,6 @@ "src/js/main.js", "src/js/metrics.js", "src/js/nav.js", - "src/js/resolution_event_broker.js", "src/js/scrollbar.js", "src/js/sound.js", "src/js/state.js",
diff --git a/chrome/browser/resources/chromeos/camera/Makefile b/chrome/browser/resources/chromeos/camera/Makefile index eb3a4c7c..ef9e57da 100644 --- a/chrome/browser/resources/chromeos/camera/Makefile +++ b/chrome/browser/resources/chromeos/camera/Makefile
@@ -139,7 +139,6 @@ src/js/mojo/device_operator.js \ src/js/mojo/image_capture.js \ src/js/nav.js \ - src/js/resolution_event_broker.js \ src/js/scrollbar.js \ src/js/sound.js \ src/js/state.js \
diff --git a/chrome/browser/resources/chromeos/camera/camera_resources.grd b/chrome/browser/resources/chromeos/camera/camera_resources.grd index 3d9b6e4..a10255d 100644 --- a/chrome/browser/resources/chromeos/camera/camera_resources.grd +++ b/chrome/browser/resources/chromeos/camera/camera_resources.grd
@@ -42,7 +42,6 @@ <structure name="IDR_CAMERA_OPTIONS_JS" file="src/js/views/camera/options.js" type="chrome_html" /> <structure name="IDR_CAMERA_PREVIEW_JS" file="src/js/views/camera/preview.js" type="chrome_html" /> <structure name="IDR_CAMERA_RECORDTIME_JS" file="src/js/views/camera/recordtime.js" type="chrome_html" /> - <structure name="IDR_CAMERA_RESOLUTION_EVENT_BROKER_JS" file="src/js/resolution_event_broker.js" type="chrome_html" /> <structure name="IDR_CAMERA_RESULT_SAVER_JS" file="src/js/models/result_saver.js" type="chrome_html" /> <structure name="IDR_CAMERA_REVIEW_RESULT_JS" file="src/js/views/camera/review_result.js" type="chrome_html" /> <structure name="IDR_CAMERA_SCROLLBAR_JS" file="src/js/scrollbar.js" type="chrome_html" />
diff --git a/chrome/browser/resources/chromeos/camera/src/js/BUILD.gn b/chrome/browser/resources/chromeos/camera/src/js/BUILD.gn index 064166b..e62c648 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/BUILD.gn +++ b/chrome/browser/resources/chromeos/camera/src/js/BUILD.gn
@@ -21,7 +21,6 @@ ":intent", ":metrics", ":nav", - ":resolution_event_broker", ":state", ":toast", ":tooltip", @@ -42,9 +41,6 @@ ] } -js_library("resolution_event_broker") { -} - js_library("type") { }
diff --git a/chrome/browser/resources/chromeos/camera/src/js/device/BUILD.gn b/chrome/browser/resources/chromeos/camera/src/js/device/BUILD.gn index 2bbbd93..0a43ce9 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/device/BUILD.gn +++ b/chrome/browser/resources/chromeos/camera/src/js/device/BUILD.gn
@@ -23,7 +23,6 @@ js_library("constraints_preferrer") { deps = [ ":camera3_device_info", - "..:resolution_event_broker", "..:state", "..:type", "../browser_proxy:browser_proxy",
diff --git a/chrome/browser/resources/chromeos/camera/src/js/device/constraints_preferrer.js b/chrome/browser/resources/chromeos/camera/src/js/device/constraints_preferrer.js index 45dae11..c0dbb6a 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/device/constraints_preferrer.js +++ b/chrome/browser/resources/chromeos/camera/src/js/device/constraints_preferrer.js
@@ -42,18 +42,11 @@ */ cca.device.ConstraintsPreferrer = class { /** - * @param {!cca.ResolutionEventBroker} resolBroker * @param {!function()} doReconfigureStream Trigger stream reconfiguration to * reflect changes in user preferred settings. * @protected */ - constructor(resolBroker, doReconfigureStream) { - /** - * @type {!cca.ResolutionEventBroker} - * @protected - */ - this.resolBroker_ = resolBroker; - + constructor(doReconfigureStream) { /** * @type {!function()} * @protected @@ -82,6 +75,14 @@ * @protected */ this.deviceResolutions_ = {}; + + /** + * Listener for changes of preferred resolution used on particular video + * device. + * @type {!function(string, !Resolution)} + * @private + */ + this.preferredResolutionChangeListener_ = () => {}; } /** @@ -150,6 +151,23 @@ * constraints-candidates. */ getSortedCandidates(deviceId, previewResolutions) {} + + /** + * Changes user preferred capture resolution. + * @abstract + * @param {string} deviceId Device id of the video device to be changed. + * @param {!Resolution} resolution Preferred capture resolution. + */ + changePreferredResolution(deviceId, resolution) {} + + /** + * Sets listener for changes of preferred resolution used in taking photo on + * particular video device. + * @param {!function(string, !Resolution)} listener + */ + setPreferredResolutionChangeListener(listener) { + this.preferredResolutionChangeListener_ = listener; + } }; /** @@ -165,12 +183,11 @@ cca.device.VideoConstraintsPreferrer = class extends cca.device.ConstraintsPreferrer { /** - * @param {!cca.ResolutionEventBroker} resolBroker * @param {!function()} doReconfigureStream * @public */ - constructor(resolBroker, doReconfigureStream) { - super(resolBroker, doReconfigureStream); + constructor(doReconfigureStream) { + super(doReconfigureStream); /** * Object saving information of device supported constant fps. Each of its @@ -206,17 +223,6 @@ this.resolution_ = new Resolution(0, -1); this.restoreResolutionPreference_('deviceVideoResolution'); this.restoreFpsPreference_(); - this.resolBroker_.registerChangeVideoPrefResolHandler( - (deviceId, width, height) => { - this.prefResolution_[deviceId] = new Resolution(width, height); - this.saveResolutionPreference_('deviceVideoResolution'); - if (cca.state.get('video-mode') && deviceId == this.deviceId_) { - this.doReconfigureStream_(); - } else { - this.resolBroker_.notifyVideoPrefResolChange( - deviceId, width, height); - } - }); this.toggleFps_.addEventListener('click', (event) => { if (!cca.state.get('streaming') || cca.state.get('taking')) { @@ -250,6 +256,19 @@ } /** + * @override + */ + changePreferredResolution(deviceId, resolution) { + this.prefResolution_[deviceId] = resolution; + this.saveResolutionPreference_('deviceVideoResolution'); + if (cca.state.get('video-mode') && deviceId === this.deviceId_) { + this.doReconfigureStream_(); + } else { + this.preferredResolutionChangeListener_(deviceId, resolution); + } + } + + /** * Sets the preferred fps used in video recording for particular video device * with particular resolution. * @param {string} deviceId Device id of video device to be set with. @@ -263,7 +282,7 @@ } this.toggleFps_.checked = prefFps === 60; cca.device.SUPPORTED_CONSTANT_FPS.forEach( - (fps) => cca.state.set(`_${fps}fps`, fps == prefFps)); + (fps) => cca.state.set(`_${fps}fps`, fps === prefFps)); this.prefFpses_[deviceId] = this.prefFpses_[deviceId] || {}; this.prefFpses_[deviceId][resolution] = prefFps; this.saveFpsPreference_(); @@ -284,7 +303,7 @@ * @return {!Resolution|undefined} */ const findResol = (width, height) => - videoResols.find((r) => r.width == width && r.height == height); + videoResols.find((r) => r.width === width && r.height === height); /** @type {!Resolution} */ let prefR = this.getPrefResolution(deviceId) || findResol(1920, 1080) || findResol(1280, 720) || new Resolution(0, -1); @@ -316,7 +335,7 @@ this.resolution_ = new Resolution(width, height); this.prefResolution_[deviceId] = this.resolution_; this.saveResolutionPreference_('deviceVideoResolution'); - this.resolBroker_.notifyVideoPrefResolChange(deviceId, width, height); + this.preferredResolutionChangeListener_(deviceId, this.resolution_); const fps = stream.getVideoTracks()[0].getSettings().frameRate; this.setPreferredConstFps_(deviceId, this.resolution_, fps); @@ -381,7 +400,7 @@ if (constFpsInfo.includes(30) && constFpsInfo.includes(60)) { const prefFps = this.prefFpses_[deviceId] && this.prefFpses_[deviceId][r] || 30; - constFpses = prefFps == 30 ? [30, 60] : [60, 30]; + constFpses = prefFps === 30 ? [30, 60] : [60, 30]; } else { constFpses = [...constFpsInfo.filter((fps) => fps >= 30).sort().reverse(), null]; @@ -420,25 +439,26 @@ */ cca.device.PhotoResolPreferrer = class extends cca.device.ConstraintsPreferrer { /** - * @param {!cca.ResolutionEventBroker} resolBroker * @param {!function()} doReconfigureStream * @public */ - constructor(resolBroker, doReconfigureStream) { - super(resolBroker, doReconfigureStream); + constructor(doReconfigureStream) { + super(doReconfigureStream); this.restoreResolutionPreference_('devicePhotoResolution'); - this.resolBroker_.registerChangePhotoPrefResolHandler( - (deviceId, width, height) => { - this.prefResolution_[deviceId] = new Resolution(width, height); - this.saveResolutionPreference_('devicePhotoResolution'); - if (!cca.state.get('video-mode') && deviceId == this.deviceId_) { - this.doReconfigureStream_(); - } else { - this.resolBroker_.notifyPhotoPrefResolChange( - deviceId, width, height); - } - }); + } + + /** + * @override + */ + changePreferredResolution(deviceId, resolution) { + this.prefResolution_[deviceId] = resolution; + this.saveResolutionPreference_('devicePhotoResolution'); + if (!cca.state.get('video-mode') && deviceId === this.deviceId_) { + this.doReconfigureStream_(); + } else { + this.preferredResolutionChangeListener_(deviceId, resolution); + } } /** @@ -465,10 +485,11 @@ * @override */ updateValues(deviceId, stream, width, height) { + const resolution = new Resolution(width, height); this.deviceId_ = deviceId; - this.prefResolution_[deviceId] = new Resolution(width, height); + this.prefResolution_[deviceId] = resolution; this.saveResolutionPreference_('devicePhotoResolution'); - this.resolBroker_.notifyPhotoPrefResolChange(deviceId, width, height); + this.preferredResolutionChangeListener_(deviceId, resolution); } /** @@ -549,7 +570,7 @@ * @return {!ResolutionList} */ const sortPreview = (rs) => { - if (rs.length == 0) { + if (rs.length === 0) { return []; } rs = [...rs].sort((r1, r2) => r2.width - r1.width);
diff --git a/chrome/browser/resources/chromeos/camera/src/js/device/device_info_updater.js b/chrome/browser/resources/chromeos/camera/src/js/device/device_info_updater.js index 31a61ad3..00e14800d 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/device/device_info_updater.js +++ b/chrome/browser/resources/chromeos/camera/src/js/device/device_info_updater.js
@@ -202,7 +202,6 @@ await this.lockingUpdate_; } - /** * Gets MediaDeviceInfo for all available video devices. * @return {!Promise<!Array<!MediaDeviceInfo>>} @@ -213,6 +212,17 @@ } /** + * Gets MediaDeviceInfo of specific video device. + * @param {string} deviceId Device id of video device to get information from. + * @return {!Promise<?MediaDeviceInfo>} + * @private + */ + async getDeviceInfo(deviceId) { + const /** !Array<!MediaDeviceInfo> */ infos = await this.getDevicesInfo(); + return infos.find((d) => d.deviceId === deviceId) || null; + } + + /** * Gets Camera3DeviceInfo for all available video devices. * @return {!Promise<?Array<!cca.device.Camera3DeviceInfo>>} */
diff --git a/chrome/browser/resources/chromeos/camera/src/js/main.js b/chrome/browser/resources/chromeos/camera/src/js/main.js index af99ae9..5127576 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/main.js +++ b/chrome/browser/resources/chromeos/camera/src/js/main.js
@@ -25,24 +25,18 @@ this.gallery_ = new cca.models.Gallery(); /** - * @type {cca.ResolutionEventBroker} - * @private - */ - this.resolBroker_ = new cca.ResolutionEventBroker(); - - /** * @type {cca.device.PhotoResolPreferrer} * @private */ - this.photoPreferrer_ = new cca.device.PhotoResolPreferrer( - this.resolBroker_, () => this.cameraView_.restart()); + this.photoPreferrer_ = + new cca.device.PhotoResolPreferrer(() => this.cameraView_.restart()); /** * @type {cca.device.VideoConstraintsPreferrer} * @private */ this.videoPreferrer_ = new cca.device.VideoConstraintsPreferrer( - this.resolBroker_, () => this.cameraView_.restart()); + () => this.cameraView_.restart()); /** * @type {cca.device.DeviceInfoUpdater} @@ -91,8 +85,7 @@ new cca.views.BaseSettings('#gridsettings'), new cca.views.BaseSettings('#timersettings'), new cca.views.ResolutionSettings( - this.infoUpdater_, this.photoPreferrer_, this.videoPreferrer_, - this.resolBroker_), + this.infoUpdater_, this.photoPreferrer_, this.videoPreferrer_), new cca.views.BaseSettings('#photoresolutionsettings'), new cca.views.BaseSettings('#videoresolutionsettings'), new cca.views.BaseSettings('#expertsettings'),
diff --git a/chrome/browser/resources/chromeos/camera/src/js/resolution_event_broker.js b/chrome/browser/resources/chromeos/camera/src/js/resolution_event_broker.js deleted file mode 100644 index bce5d7d0..0000000 --- a/chrome/browser/resources/chromeos/camera/src/js/resolution_event_broker.js +++ /dev/null
@@ -1,132 +0,0 @@ -// 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. - -'use strict'; - -/** - * Namespace for the Camera app. - */ -var cca = cca || {}; - -/** - * Broker for registering or notifying resolution related events. - */ -cca.ResolutionEventBroker = class { - /** @public */ - constructor() { - /** - * Handler for requests of changing user-preferred resolution used in photo - * taking. - * @type {!function(string, number, number)} - * @private - */ - this.photoChangePrefResolHandler_ = () => {}; - - /** - * Handler for requests of changing user-preferred resolution used in video - * recording. - * @type {!function(string, number, number)} - * @private - */ - this.videoChangePrefResolHandler_ = () => {}; - - /** - * Listener for changes of preferred photo resolution used on particular - * video device. - * @type {!function(string, number, number)} - * @private - */ - this.photoPrefResolChangeListener_ = () => {}; - - /** - * Listener for changes of preferred video resolution used on particular - * video device. - * @type {!function(string, number, number)} - * @private - */ - this.videoPrefResolChangeListener_ = () => {}; - } - - /** - * Registers handler for requests of changing user-preferred resolution used - * in photo taking. - * @param {!function(string, number, number)} handler Called with device id of - * video device to be changed and width, height of new resolution. - */ - registerChangePhotoPrefResolHandler(handler) { - this.photoChangePrefResolHandler_ = handler; - } - - /** - * Registers handler for requests of changing user-preferred resolution used - * in video recording. - * @param {!function(string, number, number)} handler Called with device id of - * video device to be changed and width, height of new resolution. - */ - registerChangeVideoPrefResolHandler(handler) { - this.videoChangePrefResolHandler_ = handler; - } - - /** - * Requests for changing user-preferred resolution used in photo taking. - * @param {string} deviceId Device id of video device to be changed. - * @param {number} width Change to resolution width. - * @param {number} height Change to resolution height. - */ - requestChangePhotoPrefResol(deviceId, width, height) { - this.photoChangePrefResolHandler_(deviceId, width, height); - } - - /** - * Requests for changing user-preferred resolution used in video recording. - * @param {string} deviceId Device id of video device to be changed. - * @param {number} width Change to resolution width. - * @param {number} height Change to resolution height. - */ - requestChangeVideoPrefResol(deviceId, width, height) { - this.videoChangePrefResolHandler_(deviceId, width, height); - } - - /** - * Adds listener for changes of preferred resolution used in taking photo on - * particular video device. - * @param {!function(string, number, number)} listener Called with changed - * video device id and new preferred resolution width, height. - */ - addPhotoPrefResolChangeListener(listener) { - this.photoPrefResolChangeListener_ = listener; - } - - /** - * Adds listener for changes of preferred resolution used in video recording - * on particular video device. - * @param {!function(string, number, number)} listener Called with changed - * video device id and new preferred resolution width, height. - */ - addVideoPrefResolChangeListener(listener) { - this.videoPrefResolChangeListener_ = listener; - } - - /** - * Notifies the change of preferred resolution used in photo taking on - * particular video device. - * @param {string} deviceId Device id of changed video device. - * @param {number} width New resolution width. - * @param {number} height New resolution height. - */ - notifyPhotoPrefResolChange(deviceId, width, height) { - this.photoPrefResolChangeListener_(deviceId, width, height); - } - - /** - * Notifies the change of preferred resolution used in video recording on - * particular video device. - * @param {string} deviceId Device id of changed video device. - * @param {number} width New resolution width. - * @param {number} height New resolution height. - */ - notifyVideoPrefResolChange(deviceId, width, height) { - this.videoPrefResolChangeListener_(deviceId, width, height); - } -};
diff --git a/chrome/browser/resources/chromeos/camera/src/js/views/camera.js b/chrome/browser/resources/chromeos/camera/src/js/views/camera.js index 25d8c874..eb057ec 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/views/camera.js +++ b/chrome/browser/resources/chromeos/camera/src/js/views/camera.js
@@ -73,6 +73,14 @@ */ this.resultSaver_ = resultSaver; + /** + * Device id of video device of active preview stream. Sets to null when + * preview become inactive. + * @type {?string} + * @private + */ + this.activeDeviceId_ = null; + const createVideoSaver = async () => resultSaver.startSaveVideo(); /** @@ -381,6 +389,17 @@ if (!this.suspended) { for (const id of await this.options_.videoDeviceIds()) { if (await this.startWithDevice_(id)) { + // Make the different active camera announced by screen reader. + const currentId = this.options_.currentDeviceId; + if (currentId === this.activeDeviceId_) { + return; + } + this.activeDeviceId_ = currentId; + const info = await this.infoUpdater_.getDeviceInfo(id); + if (info !== null) { + cca.toast.speak(chrome.i18n.getMessage( + 'status_msg_camera_switched', info.label)); + } return; } } @@ -390,6 +409,7 @@ this.configuring_ = null; return true; } catch (error) { + this.activeDeviceId_ = null; if (!(error instanceof cca.views.CameraSuspendedError)) { console.error(error); cca.nav.open('warning', 'no-camera');
diff --git a/chrome/browser/resources/chromeos/camera/src/js/views/camera/options.js b/chrome/browser/resources/chromeos/camera/src/js/views/camera/options.js index 917e4da..03d5a7b 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/views/camera/options.js +++ b/chrome/browser/resources/chromeos/camera/src/js/views/camera/options.js
@@ -128,6 +128,16 @@ }); }; +cca.views.camera.Options.prototype = { + /** + * Device id of the camera device currently used or selected. + * @return {string} + */ + get currentDeviceId() { + return this.videoDeviceId_; + }, +}; + /** * Switches to the next available camera device. * @private @@ -148,12 +158,6 @@ this.videoDeviceId_ = devices[index].deviceId; } await this.doSwitchDevice_(); - // Make the active camera announced by screen reader. - var found = devices.find((entry) => entry.deviceId == this.videoDeviceId_); - if (found) { - cca.toast.speak( - chrome.i18n.getMessage('status_msg_camera_switched', found.label)); - } }; /**
diff --git a/chrome/browser/resources/chromeos/camera/src/js/views/camera/review_result.js b/chrome/browser/resources/chromeos/camera/src/js/views/camera/review_result.js index ebce269..c43118f 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/views/camera/review_result.js +++ b/chrome/browser/resources/chromeos/camera/src/js/views/camera/review_result.js
@@ -42,6 +42,30 @@ document.querySelector('#review-video-result')); /** + * @const {!HTMLButtonElement} + * @private + */ + this.confirmResultButton_ = + /** @type {!HTMLButtonElement} */ ( + document.querySelector('#confirm-result')); + + /** + * @const {!HTMLButtonElement} + * @private + */ + this.cancelResultButton_ = + /** @type {!HTMLButtonElement} */ ( + document.querySelector('#cancel-result')); + + /** + * @const {!HTMLButtonElement} + * @private + */ + this.playResultVideoButton_ = + /** @type {!HTMLButtonElement} */ ( + document.querySelector('#play-result-video')); + + /** * Function resolving open result call called with whether user confirms * after reviewing intent result. * @type {?function(boolean)} @@ -54,11 +78,12 @@ cca.state.set('playing-result-video', false); }; - const addClickListener = (selector, handler) => - document.querySelector(selector).addEventListener('click', handler); - addClickListener('#confirm-result', () => this.close_(true)); - addClickListener('#cancel-result', () => this.close_(false)); - addClickListener('#play-result-video', () => this.playResultVideo_()); + this.confirmResultButton_.addEventListener( + 'click', () => this.close_(true)); + this.cancelResultButton_.addEventListener( + 'click', () => this.close_(false)); + this.playResultVideoButton_.addEventListener( + 'click', () => this.playResultVideo_()); } /** @@ -106,6 +131,8 @@ this.reviewPhotoResult_.src = img.src; cca.state.set('review-photo-result', true); cca.state.set('review-result', true); + this.confirmResultButton_.focus(); + return new Promise((resolve) => { this.resolveOpen_ = resolve; }); @@ -121,6 +148,8 @@ this.reviewVideoResult_.src = fileEntry.toURL(); cca.state.set('review-video-result', true); cca.state.set('review-result', true); + this.playResultVideoButton_.focus(); + return new Promise((resolve) => { this.resolveOpen_ = resolve; });
diff --git a/chrome/browser/resources/chromeos/camera/src/js/views/camera_intent.js b/chrome/browser/resources/chromeos/camera/src/js/views/camera_intent.js index 5dffa34..d2f481a 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/views/camera_intent.js +++ b/chrome/browser/resources/chromeos/camera/src/js/views/camera_intent.js
@@ -151,6 +151,7 @@ window.close(); return; } + this.focus(); // Refocus the visible shutter button for ChromeVox. cca.state.set('suspend', false); await this.intent_.clearData(); await this.restart();
diff --git a/chrome/browser/resources/chromeos/camera/src/js/views/settings.js b/chrome/browser/resources/chromeos/camera/src/js/views/settings.js index 238fb26..10dfd0d4 100644 --- a/chrome/browser/resources/chromeos/camera/src/js/views/settings.js +++ b/chrome/browser/resources/chromeos/camera/src/js/views/settings.js
@@ -134,12 +134,11 @@ * @param {!cca.device.DeviceInfoUpdater} infoUpdater * @param {!cca.device.PhotoResolPreferrer} photoPreferrer * @param {!cca.device.VideoConstraintsPreferrer} videoPreferrer - * @param {!cca.ResolutionEventBroker} resolBroker * @extends {cca.views.BaseSettings} * @constructor */ cca.views.ResolutionSettings = function( - infoUpdater, photoPreferrer, videoPreferrer, resolBroker) { + infoUpdater, photoPreferrer, videoPreferrer) { /** * @param {function(): ?cca.views.DeviceSetting} getSetting * @param {function(): !HTMLElement} getElement @@ -173,10 +172,16 @@ }); /** - * @type {!cca.ResolutionEventBroker} + * @type {!cca.device.PhotoResolPreferrer} * @private */ - this.resolBroker_ = resolBroker; + this.photoPreferrer_ = photoPreferrer; + + /** + * @type {!cca.device.VideoConstraintsPreferrer} + * @private + */ + this.videoPreferrer_ = videoPreferrer; /** * @type {!HTMLElement} @@ -317,9 +322,9 @@ this.updateResolutions_(); }); - this.resolBroker_.addPhotoPrefResolChangeListener( + this.photoPreferrer_.setPreferredResolutionChangeListener( this.updateSelectedPhotoResolution_.bind(this)); - this.resolBroker_.addVideoPrefResolChangeListener( + this.videoPreferrer_.setPreferredResolutionChangeListener( this.updateSelectedVideoResolution_.bind(this)); }; @@ -497,14 +502,13 @@ /** * Updates current selected photo resolution. * @param {string} deviceId Device id of the selected resolution. - * @param {number} width Width of selected resolution. - * @param {number} height Height of selected resolution. + * @param {!Resolution} resolution Selected resolution. * @private */ cca.views.ResolutionSettings.prototype.updateSelectedPhotoResolution_ = - function(deviceId, width, height) { + function(deviceId, resolution) { const {photo} = this.getDeviceSetting_(deviceId); - photo.prefResol = new Resolution(width, height); + photo.prefResol = resolution; let /** !HTMLElement */ photoItem; if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) { photoItem = this.frontPhotoItem_; @@ -521,7 +525,10 @@ if (cca.state.get('photoresolutionsettings') && this.openedSettingDeviceId_ === deviceId) { this.photoResMenu_ - .querySelector(`input[data-width="${width}"][data-height="${height}"]`) + .querySelector( + 'input' + + `[data-width="${resolution.width}"]` + + `[data-height="${resolution.height}"]`) .checked = true; } }; @@ -529,14 +536,13 @@ /** * Updates current selected video resolution. * @param {string} deviceId Device id of the selected resolution. - * @param {number} width Width of selected resolution. - * @param {number} height Height of selected resolution. + * @param {!Resolution} resolution Selected resolution. * @private */ cca.views.ResolutionSettings.prototype.updateSelectedVideoResolution_ = - function(deviceId, width, height) { + function(deviceId, resolution) { const {video} = this.getDeviceSetting_(deviceId); - video.prefResol = new Resolution(width, height); + video.prefResol = resolution; let /** !HTMLElement */ videoItem; if (this.frontSetting_ && this.frontSetting_.deviceId === deviceId) { videoItem = this.frontVideoItem_; @@ -553,7 +559,10 @@ if (cca.state.get('videoresolutionsettings') && this.openedSettingDeviceId_ === deviceId) { this.videoResMenu_ - .querySelector(`input[data-width="${width}"][data-height="${height}"]`) + .querySelector( + 'input' + + `[data-width="${resolution.width}"]` + + `[data-height="${resolution.height}"]`) .checked = true; } }; @@ -570,8 +579,7 @@ this.openedSettingDeviceId_ = deviceId; this.updateMenu_( resolItem, this.photoResMenu_, this.photoOptTextTempl_, - (r) => this.resolBroker_.requestChangePhotoPrefResol( - deviceId, r.width, r.height), + (r) => this.photoPreferrer_.changePreferredResolution(deviceId, r), photo.resols, photo.prefResol); this.openSubSettings('photoresolutionsettings'); }; @@ -588,8 +596,7 @@ this.openedSettingDeviceId_ = deviceId; this.updateMenu_( resolItem, this.videoResMenu_, this.videoOptTextTempl_, - (r) => this.resolBroker_.requestChangeVideoPrefResol( - deviceId, r.width, r.height), + (r) => this.videoPreferrer_.changePreferredResolution(deviceId, r), video.resols, video.prefResol); this.openSubSettings('videoresolutionsettings'); };
diff --git a/chrome/browser/resources/chromeos/camera/src/views/main.html b/chrome/browser/resources/chromeos/camera/src/views/main.html index 2b8f922..7e91116 100644 --- a/chrome/browser/resources/chromeos/camera/src/views/main.html +++ b/chrome/browser/resources/chromeos/camera/src/views/main.html
@@ -15,7 +15,6 @@ <script src="../js/metrics.js"></script> <script src="../js/intent.js"></script> <script src="../js/util.js"></script> - <script src="../js/resolution_event_broker.js"></script> <script src="../js/toast.js"></script> <script src="../js/tooltip.js"></script> <script src="../js/state.js"></script>
diff --git a/chrome/browser/resources/chromeos/login/oobe_eula.css b/chrome/browser/resources/chromeos/login/oobe_eula.css index 80537de..f31285c1 100644 --- a/chrome/browser/resources/chromeos/login/oobe_eula.css +++ b/chrome/browser/resources/chromeos/login/oobe_eula.css
@@ -49,6 +49,10 @@ margin-inline-start: 16px; } +#usageStatsLabel { + cursor: pointer; +} + #settings-close-button { padding-inline-end: 18px; }
diff --git a/chrome/browser/resources/chromeos/login/oobe_eula.html b/chrome/browser/resources/chromeos/login/oobe_eula.html index 000287d..5400e78 100644 --- a/chrome/browser/resources/chromeos/login/oobe_eula.html +++ b/chrome/browser/resources/chromeos/login/oobe_eula.html
@@ -40,7 +40,8 @@ on-change="onUsageChanged_" aria-labelledby="usageStatsLabel"> </cr-toggle> <div id="usageStatsLabelContainer"> - <span id="usageStatsLabel" i18n-content="checkboxLogging"></span> + <span id="usageStatsLabel" i18n-content="checkboxLogging" + on-click="usageStatsLabelClicked_"></span> <a id="learn-more" href="#" i18n-content="learnMore" on-tap="onUsageStatsHelpLinkClicked_"> </a>
diff --git a/chrome/browser/resources/chromeos/login/oobe_eula.js b/chrome/browser/resources/chromeos/login/oobe_eula.js index 8f44440..076e478 100644 --- a/chrome/browser/resources/chromeos/login/oobe_eula.js +++ b/chrome/browser/resources/chromeos/login/oobe_eula.js
@@ -200,4 +200,13 @@ isPasswordEmpty_: function(password) { return password != null && password.length == 0; }, + + /** + * Switches usage stats toggle state. + * + * @private + */ + usageStatsLabelClicked_: function() { + this.usageStatsChecked = !this.usageStatsChecked; + }, });
diff --git a/chrome/browser/resources/local_ntp/customize.js b/chrome/browser/resources/local_ntp/customize.js index caf02abf..ea3d853 100644 --- a/chrome/browser/resources/local_ntp/customize.js +++ b/chrome/browser/resources/local_ntp/customize.js
@@ -1429,25 +1429,25 @@ customize.preselectedOptions.backgroundsMenuTile = null; - const themeInfo = assert(ntpApiHandle.themeBackgroundInfo); - if (!themeInfo.customBackgroundConfigured) { + const ntpTheme = assert(ntpApiHandle.ntpTheme); + if (!ntpTheme.customBackgroundConfigured) { // Default. customize.preselectedOptions.backgroundsMenuTile = $(customize.IDS.BACKGROUNDS_DEFAULT_ICON); - } else if (themeInfo.imageUrl.includes( + } else if (ntpTheme.imageUrl.includes( 'chrome-search://local-ntp/background.jpg')) { // Local image. customize.preselectedOptions.backgroundsMenuTile = $(customize.IDS.BACKGROUNDS_UPLOAD_ICON); } else if ( - themeInfo.collectionId !== '' && - customize.currentCollectionId == themeInfo.collectionId) { + ntpTheme.collectionId !== '' && + customize.currentCollectionId == ntpTheme.collectionId) { // Daily refresh. $(customize.IDS.REFRESH_TOGGLE).checked = true; } else if (!customize.selectedOptions.backgroundData) { // Image tile. Only if another background hasn't already been selected. customize.preselectedOptions.backgroundsMenuTile = - document.querySelector('[data-url="' + themeInfo.imageUrl + '"]'); + document.querySelector('[data-url="' + ntpTheme.imageUrl + '"]'); } customize.richerPicker_selectBackgroundTile( @@ -2326,12 +2326,12 @@ */ customize.colorsMenuOnThemeChange = function() { // Update webstore theme information. - const themeInfo = assert(ntpApiHandle.themeBackgroundInfo); - if (themeInfo.themeId && themeInfo.themeName) { + const ntpTheme = assert(ntpApiHandle.ntpTheme); + if (ntpTheme.themeId && ntpTheme.themeName) { $(customize.IDS.COLORS_THEME).classList.add(customize.CLASSES.VISIBLE); - $(customize.IDS.COLORS_THEME_NAME).innerHTML = themeInfo.themeName; + $(customize.IDS.COLORS_THEME_NAME).innerHTML = ntpTheme.themeName; $(customize.IDS.COLORS_THEME_WEBSTORE_LINK).href = - 'https://chrome.google.com/webstore/detail/' + themeInfo.themeId; + 'https://chrome.google.com/webstore/detail/' + ntpTheme.themeId; $(customize.IDS.COLORS_THEME_UNINSTALL).onclick = ntpApiHandle.useDefaultTheme; @@ -2357,40 +2357,40 @@ * Preselect Colors menu tile according to the theme info. */ customize.colorsMenuPreselectTile = function() { - const themeInfo = assert(ntpApiHandle.themeBackgroundInfo); + const ntpTheme = assert(ntpApiHandle.ntpTheme); let tile; - if (themeInfo.usingDefaultTheme) { + if (ntpTheme.usingDefaultTheme) { tile = $(customize.IDS.COLORS_DEFAULT_ICON); - } else if (themeInfo.colorId && themeInfo.colorId > 0) { + } else if (ntpTheme.colorId && ntpTheme.colorId > 0) { // Color from predefined set is selected. const tiles = Array.from( $(customize.IDS.COLORS_MENU) .getElementsByClassName(customize.CLASSES.COLLECTION_TILE)); for (let i = 0; i < tiles.length; i++) { - if (tiles[i].dataset && tiles[i].dataset.id == themeInfo.colorId) { + if (tiles[i].dataset && tiles[i].dataset.id == ntpTheme.colorId) { tile = tiles[i]; break; } } } else if ( - configData.chromeColorsCustomColorPicker && themeInfo.colorDark && - themeInfo.colorLight && themeInfo.colorPicked) { + configData.chromeColorsCustomColorPicker && ntpTheme.colorDark && + ntpTheme.colorLight && ntpTheme.colorPicked) { // Custom color is selected. tile = $(customize.IDS.COLOR_PICKER_TILE); // Update color picker tile colors. - customize.customColorPicked = colorArrayToHex(themeInfo.colorPicked); + customize.customColorPicked = colorArrayToHex(ntpTheme.colorPicked); $(customize.IDS.COLORS_MENU) .style.setProperty( - '--custom-color-border', colorArrayToHex(themeInfo.colorDark)); + '--custom-color-border', colorArrayToHex(ntpTheme.colorDark)); $(customize.IDS.COLORS_MENU) .style.setProperty( - '--custom-color-dark', colorArrayToHex(themeInfo.colorDark)); + '--custom-color-dark', colorArrayToHex(ntpTheme.colorDark)); $(customize.IDS.COLORS_MENU) .style.setProperty( - '--custom-color-light', colorArrayToHex(themeInfo.colorLight)); + '--custom-color-light', colorArrayToHex(ntpTheme.colorLight)); $(customize.IDS.COLOR_PICKER_ICON) - .classList.toggle('white', themeInfo.isNtpBackgroundDark); + .classList.toggle('white', ntpTheme.isNtpBackgroundDark); } if (tile && tile !== customize.selectedOptions.color) {
diff --git a/chrome/browser/resources/local_ntp/externs.js b/chrome/browser/resources/local_ntp/externs.js index 945e980..bd71cf68 100644 --- a/chrome/browser/resources/local_ntp/externs.js +++ b/chrome/browser/resources/local_ntp/externs.js
@@ -333,10 +333,10 @@ * usingDefaultTheme: boolean, * }} */ -let ThemeBackgroundInfo; +let NtpTheme; -/** @type {?ThemeBackgroundInfo} */ -window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo; +/** @type {?NtpTheme} */ +window.chrome.embeddedSearch.newTabPage.ntpTheme; /** * No params.
diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js index 59e04c00..a70ef1d 100644 --- a/chrome/browser/resources/local_ntp/local_ntp.js +++ b/chrome/browser/resources/local_ntp/local_ntp.js
@@ -391,7 +391,7 @@ $(IDS.TILES).appendChild(iframe); iframe.onload = function() { - sendThemeInfoToMostVisitedIframe(); + sendNtpThemeToMostVisitedIframe(); reloadTiles(); }; @@ -575,9 +575,9 @@ * the page has notheme set, returns a fallback light-colored theme (or dark- * colored theme if dark mode is enabled). This is used when the doodle is * displayed after clicking the notifier. - * @return {?ThemeBackgroundInfo} + * @return {?NtpTheme} */ -function getThemeBackgroundInfo() { +function getNtpTheme() { if (history.state && history.state.notheme) { return { alternateLogo: false, @@ -599,7 +599,7 @@ }; } - const info = window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo; + const info = window.chrome.embeddedSearch.newTabPage.ntpTheme; const preview = $(customize.IDS.CUSTOM_BG_PREVIEW); if (preview.dataset.hasPreview === 'true') { info.isNtpBackgroundDark = preview.dataset.hasImage === 'true'; @@ -1397,7 +1397,7 @@ function onThemeChange() { renderTheme(); renderOneGoogleBarTheme(); - sendThemeInfoToMostVisitedIframe(); + sendNtpThemeToMostVisitedIframe(); if ($(IDS.PROMO)) { showPromoIfNotOverlapping(); } @@ -1618,8 +1618,8 @@ const oneGoogleBarPromise = oneGoogleBarApi.bf(); oneGoogleBarPromise.then(function(oneGoogleBar) { const setForegroundStyle = oneGoogleBar.pc.bind(oneGoogleBar); - const themeInfo = getThemeBackgroundInfo(); - setForegroundStyle(themeInfo && themeInfo.isNtpBackgroundDark ? 1 : 0); + const ntpTheme = getNtpTheme(); + setForegroundStyle(ntpTheme && ntpTheme.isNtpBackgroundDark ? 1 : 0); }); } catch (err) { console.log('Failed setting OneGoogleBar theme:\n' + err); @@ -1628,7 +1628,7 @@ /** Updates the NTP based on the current theme. */ function renderTheme() { - const info = getThemeBackgroundInfo(); + const info = getNtpTheme(); if (!info) { return; } @@ -1772,8 +1772,8 @@ } /** Sends the current theme info to the most visited iframe. */ -function sendThemeInfoToMostVisitedIframe() { - const info = getThemeBackgroundInfo(); +function sendNtpThemeToMostVisitedIframe() { + const info = getNtpTheme(); if (!info) { return; } @@ -1818,15 +1818,15 @@ /** * Updates the NTP style according to theme. - * @param {Object} themeInfo The information about the theme. + * @param {Object} ntpTheme The information about the theme. */ -function setCustomThemeStyle(themeInfo) { +function setCustomThemeStyle(ntpTheme) { let textColor = ''; let textColorLight = ''; let mvxFilter = ''; - if (!themeInfo.usingDefaultTheme) { - textColor = convertToRGBAColor(themeInfo.textColorRgba); - textColorLight = convertToRGBAColor(themeInfo.textColorLightRgba); + if (!ntpTheme.usingDefaultTheme) { + textColor = convertToRGBAColor(ntpTheme.textColorRgba); + textColorLight = convertToRGBAColor(ntpTheme.textColorLightRgba); mvxFilter = 'drop-shadow(0 0 0 ' + textColor + ')'; }
diff --git a/chrome/browser/resources/local_ntp/most_visited_util.js b/chrome/browser/resources/local_ntp/most_visited_util.js index fc6a7442..86e4e59c 100644 --- a/chrome/browser/resources/local_ntp/most_visited_util.js +++ b/chrome/browser/resources/local_ntp/most_visited_util.js
@@ -175,11 +175,11 @@ // For backward compatibility with server-side NTP, look at themes directly // and use param.c for non-title or as fallback. const apiHandle = chrome.embeddedSearch.newTabPage; - const themeInfo = assert(apiHandle.themeBackgroundInfo); + const ntpTheme = assert(apiHandle.ntpTheme); let c = '#777'; - if (isTitle && themeInfo && !themeInfo.usingDefaultTheme) { + if (isTitle && ntpTheme && !ntpTheme.usingDefaultTheme) { // Read from theme directly - c = convertArrayToRGBAColor(themeInfo.textColorRgba) || c; + c = convertArrayToRGBAColor(ntpTheme.textColorRgba) || c; } else if ('c' in params) { c = convertToHexColor(parseInt(params.c, 16)) || c; }
diff --git a/chrome/browser/resources/pdf/index.html b/chrome/browser/resources/pdf/index.html index ade4c62..1af4cc2f 100644 --- a/chrome/browser/resources/pdf/index.html +++ b/chrome/browser/resources/pdf/index.html
@@ -26,8 +26,5 @@ <div id="content"></div> </body> -<!-- TODO(crbug.com/1012574): Convert pdf_scripting_api.js to a JS module once - Print Preview has been migrated to JS modules as well --> -<script src="pdf_scripting_api.js"></script> <script type="module" src="main.js"></script> </html>
diff --git a/chrome/browser/resources/pdf/pdf_scripting_api.js b/chrome/browser/resources/pdf/pdf_scripting_api.js index 49c333d..e69dd69e 100644 --- a/chrome/browser/resources/pdf/pdf_scripting_api.js +++ b/chrome/browser/resources/pdf/pdf_scripting_api.js
@@ -8,7 +8,7 @@ * @param {Object} dict A dictionary representing the key event. * @return {!Event} A key event. */ -function DeserializeKeyEvent(dict) { +export function DeserializeKeyEvent(dict) { const e = document.createEvent('Event'); e.initEvent('keydown', true, true); e.keyCode = dict.keyCode; @@ -27,7 +27,7 @@ * @param {Event} event A key event. * @return {Object} A dictionary representing the key event. */ -function SerializeKeyEvent(event) { +export function SerializeKeyEvent(event) { return { keyCode: event.keyCode, code: event.code, @@ -43,7 +43,7 @@ * has finished loading or failed to load. * @enum {string} */ -const LoadState = { +export const LoadState = { LOADING: 'loading', SUCCESS: 'success', FAILED: 'failed' @@ -54,7 +54,7 @@ * the PDF viewer so that it can be customized by things like print preview. * */ -class PDFScriptingAPI { +export class PDFScriptingAPI { /** * @param {Window} window the window of the page containing the pdf viewer. * @param {Object} plugin the plugin element containing the pdf viewer. @@ -298,7 +298,7 @@ * @param {string} baseUrl the base URL of the PDF viewer * @return {!HTMLIFrameElement} the iframe element containing the PDF viewer. */ -function PDFCreateOutOfProcessPlugin(src, baseUrl) { +export function PDFCreateOutOfProcessPlugin(src, baseUrl) { const client = new PDFScriptingAPI(window, null); const iframe = /** @type {!HTMLIFrameElement} */ ( window.document.createElement('iframe'));
diff --git a/chrome/browser/resources/pdf/pdf_viewer.js b/chrome/browser/resources/pdf/pdf_viewer.js index 54e4718..d356d12 100644 --- a/chrome/browser/resources/pdf/pdf_viewer.js +++ b/chrome/browser/resources/pdf/pdf_viewer.js
@@ -17,6 +17,7 @@ import {NavigatorDelegate, PdfNavigator} from './navigator.js'; import {OpenPdfParamsParser} from './open_pdf_params_parser.js'; import {FittingType} from './pdf_fitting_type.js'; +import {DeserializeKeyEvent, LoadState, SerializeKeyEvent} from './pdf_scripting_api.js'; import {ToolbarManager} from './toolbar_manager.js'; import {LayoutOptions, Point, Viewport} from './viewport.js'; import {ViewportScroller} from './viewport_scroller.js';
diff --git a/chrome/browser/resources/print_preview/BUILD.gn b/chrome/browser/resources/print_preview/BUILD.gn index 2c304a0..b1a726a 100644 --- a/chrome/browser/resources/print_preview/BUILD.gn +++ b/chrome/browser/resources/print_preview/BUILD.gn
@@ -5,6 +5,7 @@ import("//chrome/common/features.gni") import("//third_party/closure_compiler/compile_js.gni") import("//tools/grit/grit_rule.gni") +import("//tools/polymer/polymer.gni") import("../optimize_webui.gni") if (optimize_webui) { @@ -15,14 +16,17 @@ host = "print" html_in_files = [ "print_preview.html" ] html_out_files = [ "vulcanized.html" ] - insert_in_head = "<base href=\"chrome://print\">" input = rebase_path("$target_gen_dir/$unpak_folder", root_build_dir) - js_out_files = [ "crisper.js" ] - - excludes = [ "pdf/pdf_scripting_api.js" ] + js_out_files = [ "print_preview.js" ] + js_module_in_files = [ "print_preview.js" ] deps = [ ":unpak", + "../../../../ui/webui/resources:modulize", + ] + excludes = [ + "chrome://resources/js/cr.m.js", + "pdf/pdf_scripting_api.js", ] } @@ -40,7 +44,14 @@ # The .grd contains references to generated files. source_is_generated = true + grit_flags = [ + "-E", + "root_gen_dir=" + rebase_path(root_gen_dir, root_build_dir), + ] + deps = [ + "ui:polymer3_elements", + ] defines = chrome_grit_defines outputs = [ "grit/print_preview_resources.h", @@ -54,13 +65,14 @@ group("closure_compile") { deps = [ - ":print_preview_resources", - "data:closure_compile", - "ui:closure_compile", + ":print_preview_module_resources", + "data:closure_compile_module", + "ui:closure_compile_module", ] } -js_type_check("print_preview_resources") { +js_type_check("print_preview_module_resources") { + is_polymer3 = true deps = [ ":cloud_print_interface", ":cloud_print_interface_js", @@ -76,22 +88,22 @@ js_library("print_preview_utils") { deps = [ ":dark_mode_behavior", - "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted", - "//ui/webui/resources/js:util", + "//third_party/polymer/v3_0/components-chromium/iron-iconset-svg:iron-iconset-svg", + "//ui/webui/resources/js:util.m", ] } js_library("metrics") { deps = [ ":native_layer", - "//ui/webui/resources/js:cr", ] } js_library("cloud_print_interface") { deps = [ - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js/cr:event_target", + "data:destination", + "data:invitation", + "//ui/webui/resources/js/cr:event_target.m", ] } @@ -101,6 +113,7 @@ ":cloud_print_interface_js", ":cloud_print_interface_native", ":native_layer", + "//ui/webui/resources/js:load_time_data.m", ] } @@ -110,10 +123,9 @@ ":native_layer", "data:cloud_parsers", "data:destination", - "data:document_info", "data:invitation", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js/cr:event_target", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js/cr:event_target.m", ] } @@ -127,14 +139,15 @@ deps = [ "data:destination", "data:destination_match", + "data:destination_policies", "data:measurement_system", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:cr.m", ] } js_library("dark_mode_behavior") { deps = [ - "//ui/webui/resources/js:assert", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] }
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface.html b/chrome/browser/resources/print_preview/cloud_print_interface.html deleted file mode 100644 index 64ed397..0000000 --- a/chrome/browser/resources/print_preview/cloud_print_interface.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr/event_target.html"> - -<script src="cloud_print_interface.js"></script>
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface.js b/chrome/browser/resources/print_preview/cloud_print_interface.js index 477efe90..900f44bf 100644 --- a/chrome/browser/resources/print_preview/cloud_print_interface.js +++ b/chrome/browser/resources/print_preview/cloud_print_interface.js
@@ -2,12 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('cloudprint', function() { +import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {Destination, DestinationOrigin} from './data/destination.js'; +import {Invitation} from './data/invitation.js'; + /** * Event types dispatched by the cloudprint interface. * @enum {string} */ - const CloudPrintInterfaceEventType = { + export const CloudPrintInterfaceEventType = { INVITES_DONE: 'cloudprint.CloudPrintInterface.INVITES_DONE', INVITES_FAILED: 'cloudprint.CloudPrintInterface.INVITES_FAILED', PRINTER_DONE: 'cloudprint.CloudPrintInterface.PRINTER_DONE', @@ -25,62 +28,62 @@ * status: number, * errorCode: number, * message: string, - * origin: !print_preview.DestinationOrigin, + * origin: !DestinationOrigin, * }} */ - let CloudPrintInterfaceErrorEventDetail; + export let CloudPrintInterfaceErrorEventDetail; /** * @typedef {{ * user: string, - * origin: !print_preview.DestinationOrigin, - * printers: (!Array<!print_preview.Destination>|undefined), + * origin: !DestinationOrigin, + * printers: (!Array<!Destination>|undefined), * searchDone: boolean, * }} */ - let CloudPrintInterfaceSearchDoneDetail; + export let CloudPrintInterfaceSearchDoneDetail; /** * @typedef {{ * destinationId: string, - * origin: !print_preview.DestinationOrigin, + * origin: !DestinationOrigin, * }} */ - let CloudPrintInterfacePrinterFailedDetail; + export let CloudPrintInterfacePrinterFailedDetail; /** * @typedef {{ - * invitations: !Array<!print_preview.Invitation>, + * invitations: !Array<!Invitation>, * user: string, * }} */ - let CloudPrintInterfaceInvitesDoneDetail; + export let CloudPrintInterfaceInvitesDoneDetail; /** * @typedef {{ - * invitation: !print_preview.Invitation, - * printer: ?print_preview.Destination, + * invitation: !Invitation, + * printer: ?Destination, * accept: boolean, * user: string, * }} */ - let CloudPrintInterfaceProcessInviteDetail; + export let CloudPrintInterfaceProcessInviteDetail; /** @interface */ - class CloudPrintInterface { + export class CloudPrintInterface { /** * @return {boolean} Whether a search for cloud destinations is in progress. */ isCloudDestinationSearchInProgress() {} - /** @return {!cr.EventTarget} The event target for this interface. */ + /** @return {!EventTarget} The event target for this interface. */ getEventTarget() {} /** * Sends Google Cloud Print search API request. * @param {?string=} opt_account Account the search is sent for. When * null or omitted, the search is done on behalf of the primary user. - * @param {print_preview.DestinationOrigin=} opt_origin When specified, + * @param {DestinationOrigin=} opt_origin When specified, * searches destinations for {@code opt_origin} only, otherwise starts * searches for all origins. */ @@ -100,14 +103,14 @@ /** * Accepts or rejects printer sharing invitation. - * @param {!print_preview.Invitation} invitation Invitation to process. + * @param {!Invitation} invitation Invitation to process. * @param {boolean} accept Whether to accept this invitation. */ processInvite(invitation, accept) {} /** * Sends a Google Cloud Print submit API request. - * @param {!print_preview.Destination} destination Cloud destination to + * @param {!Destination} destination Cloud destination to * print to. * @param {string} printTicket The print ticket to print. * @param {string} documentTitle Title of the document. @@ -118,7 +121,7 @@ /** * Sends a Google Cloud Print printer API request. * @param {string} printerId ID of the printer to lookup. - * @param {!print_preview.DestinationOrigin} origin Origin of the printer. + * @param {!DestinationOrigin} origin Origin of the printer. * @param {string=} account Account this printer is registered for. When * provided for COOKIES {@code origin}, and users sessions are still not * known, will be checked against the response (both success and failure @@ -127,17 +130,3 @@ */ printer(printerId, origin, account) {} } - - // Export - return { - CloudPrintInterface: CloudPrintInterface, - CloudPrintInterfaceErrorEventDetail: CloudPrintInterfaceErrorEventDetail, - CloudPrintInterfaceEventType: CloudPrintInterfaceEventType, - CloudPrintInterfaceInvitesDoneDetail: CloudPrintInterfaceInvitesDoneDetail, - CloudPrintInterfacePrinterFailedDetail: - CloudPrintInterfacePrinterFailedDetail, - CloudPrintInterfaceProcessInviteDetail: - CloudPrintInterfaceProcessInviteDetail, - CloudPrintInterfaceSearchDoneDetail: CloudPrintInterfaceSearchDoneDetail, - }; -});
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface_js.js b/chrome/browser/resources/print_preview/cloud_print_interface_js.js index cde3343..c2c85f5 100644 --- a/chrome/browser/resources/print_preview/cloud_print_interface_js.js +++ b/chrome/browser/resources/print_preview/cloud_print_interface_js.js
@@ -2,19 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('cloudprint', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {CloudPrintInterface, CloudPrintInterfaceErrorEventDetail, CloudPrintInterfaceEventType} from './cloud_print_interface.js'; +import {NativeLayer} from './native_layer.js'; +import {CloudOrigins, DestinationOrigin} from './data/destination.js'; +import {Invitation} from './data/invitation.js'; +import {parseCloudDestination, parseInvitation} from './data/cloud_parsers.js'; - const CloudPrintInterfaceEventType = cloudprint.CloudPrintInterfaceEventType; - /** @implements {cloudprint.CloudPrintInterface} */ - class CloudPrintInterfaceJS { + /** @implements {CloudPrintInterface} */ + export class CloudPrintInterfaceJS { /** * API to the Google Cloud Print service. * @param {string} baseUrl Base part of the Google Cloud Print service URL * with no trailing slash. For example, * 'https://www.google.com/cloudprint'. - * @param {!print_preview.NativeLayer} nativeLayer Native layer used to get + * @param {!NativeLayer} nativeLayer Native layer used to get * Auth2 tokens. * @param {boolean} isInAppKioskMode Whether the print preview is in App * Kiosk mode. @@ -29,7 +33,7 @@ /** * Used to get Auth2 tokens. - * @private {!print_preview.NativeLayer} + * @private {!NativeLayer} */ this.nativeLayer_ = nativeLayer; @@ -63,7 +67,7 @@ /** * Outstanding cloud destination search requests. - * @private {!Array<!cloudprint.CloudPrintRequest>} + * @private {!Array<!CloudPrintRequest>} */ this.outstandingCloudSearchRequests_ = []; @@ -77,8 +81,8 @@ this.accessTokenRequestPromise_ = null; // </if> - /** @private {!cr.EventTarget} */ - this.eventTarget_ = new cr.EventTarget(); + /** @private {!EventTarget} */ + this.eventTarget_ = new EventTarget(); } /** @override */ @@ -94,10 +98,10 @@ /** @override */ search(opt_account, opt_origin) { const account = opt_account || ''; - let origins = opt_origin ? [opt_origin] : print_preview.CloudOrigins; + let origins = opt_origin ? [opt_origin] : CloudOrigins; if (this.isInAppKioskMode_) { origins = origins.filter(function(origin) { - return origin != print_preview.DestinationOrigin.COOKIES; + return origin != DestinationOrigin.COOKIES; }); } this.abortSearchRequests_(origins); @@ -112,7 +116,7 @@ * @param {string} account Account the search is sent for. It matters for * COOKIES origin only, and can be empty (sent on behalf of the primary * user in this case). - * @param {!Array<!print_preview.DestinationOrigin>} origins Origins to + * @param {!Array<!DestinationOrigin>} origins Origins to * search printers for. * @private */ @@ -139,7 +143,7 @@ new HttpParam('client', 'chrome'), ]; this.sendOrQueueRequest_(this.buildRequest_( - 'GET', 'invites', params, print_preview.DestinationOrigin.COOKIES, + 'GET', 'invites', params, DestinationOrigin.COOKIES, account, this.onInvitesDone_.bind(this))); } @@ -196,19 +200,19 @@ * @param {string} action Google Cloud Print action to perform. * @param {Array<!HttpParam>} params HTTP parameters to include in the * request. - * @param {!print_preview.DestinationOrigin} origin Origin for destination. + * @param {!DestinationOrigin} origin Origin for destination. * @param {?string} account Account the request is sent for. Can be * {@code null} or empty string if the request is not cookie bound or * is sent on behalf of the primary user. - * @param {function(!cloudprint.CloudPrintRequest)} callback Callback to + * @param {function(!CloudPrintRequest)} callback Callback to * invoke when request completes. - * @return {!cloudprint.CloudPrintRequest} Partially prepared request. + * @return {!CloudPrintRequest} Partially prepared request. * @private */ buildRequest_(method, action, params, origin, account, callback) { const url = new URL(this.baseUrl_ + '/' + action); const searchParams = url.searchParams; - if (origin == print_preview.DestinationOrigin.COOKIES) { + if (origin == DestinationOrigin.COOKIES) { const xsrfToken = this.xsrfTokens_[account]; if (!xsrfToken) { searchParams.append('xsrf', ''); @@ -254,29 +258,29 @@ const xhr = new XMLHttpRequest(); xhr.open(method, url.toString(), true); - xhr.withCredentials = (origin == print_preview.DestinationOrigin.COOKIES); + xhr.withCredentials = (origin == DestinationOrigin.COOKIES); for (const header in headers) { xhr.setRequestHeader(header, headers[header]); } - return new cloudprint.CloudPrintRequest( + return new CloudPrintRequest( xhr, body, origin, account, callback); } /** * Sends a request to the Google Cloud Print API or queues if it needs to * wait OAuth2 access token. - * @param {!cloudprint.CloudPrintRequest} request Request to send or queue. + * @param {!CloudPrintRequest} request Request to send or queue. * @private */ sendOrQueueRequest_(request) { - if (request.origin == print_preview.DestinationOrigin.COOKIES) { + if (request.origin == DestinationOrigin.COOKIES) { this.sendRequest_(request); return; } // <if expr="chromeos"> - assert(request.origin == print_preview.DestinationOrigin.DEVICE); + assert(request.origin == DestinationOrigin.DEVICE); if (this.accessTokenRequestPromise_ == null) { this.accessTokenRequestPromise_ = this.nativeLayer_.getAccessToken(); } @@ -288,7 +292,7 @@ /** * Sends a request to the Google Cloud Print API. - * @param {!cloudprint.CloudPrintRequest} request Request to send. + * @param {!CloudPrintRequest} request Request to send. * @private */ sendRequest_(request) { @@ -300,9 +304,9 @@ /** * Creates an object containing information about the error based on the * request. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. - * @return {!cloudprint.CloudPrintInterfaceErrorEventDetail} Information + * @return {!CloudPrintInterfaceErrorEventDetail} Information * about the error. * @private */ @@ -332,12 +336,12 @@ /** * Updates user info and session index from the {@code request} response. - * @param {!cloudprint.CloudPrintRequest} request Request to extract user + * @param {!CloudPrintRequest} request Request to extract user * info from. * @private */ setUsers_(request) { - if (request.origin == print_preview.DestinationOrigin.COOKIES) { + if (request.origin == DestinationOrigin.COOKIES) { const users = request.result['request']['users'] || []; this.setUsers(users); } @@ -353,7 +357,7 @@ /** * Terminates search requests for requested {@code origins}. - * @param {!Array<print_preview.DestinationOrigin>} origins Origins + * @param {!Array<DestinationOrigin>} origins Origins * to terminate search requests for. * @private */ @@ -372,13 +376,13 @@ /** * Called when a native layer receives access token. Assumes that the * destination type for this token is DestinationOrigin.DEVICE. - * @param {cloudprint.CloudPrintRequest} request The pending request that + * @param {CloudPrintRequest} request The pending request that * requires the access token. * @param {string} accessToken The access token obtained. * @private */ onAccessTokenReady_(request, accessToken) { - assert(request.origin == print_preview.DestinationOrigin.DEVICE); + assert(request.origin == DestinationOrigin.DEVICE); if (accessToken) { request.xhr.setRequestHeader('Authorization', 'Bearer ' + accessToken); this.sendRequest_(request); @@ -394,7 +398,7 @@ /** * Called when the ready-state of a XML http request changes. * Calls the successCallback with the result or dispatches an ERROR event. - * @param {!cloudprint.CloudPrintRequest} request Request that was changed. + * @param {!CloudPrintRequest} request Request that was changed. * @private */ onReadyStateChange_(request) { @@ -402,7 +406,7 @@ if (request.xhr.status == 200) { request.result = /** @type {Object} */ (JSON.parse(request.xhr.responseText)); - if (request.origin == print_preview.DestinationOrigin.COOKIES && + if (request.origin == DestinationOrigin.COOKIES && request.result['success']) { this.xsrfTokens_[request.result['request']['user']] = request.result['xsrf_token']; @@ -416,7 +420,7 @@ * Called when the search request completes. * @param {boolean} isRecent Whether the search request was for recent * destinations. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. * @private */ @@ -430,7 +434,7 @@ return item != request; }); let activeUser = ''; - if (request.origin == print_preview.DestinationOrigin.COOKIES) { + if (request.origin == DestinationOrigin.COOKIES) { activeUser = request.result && request.result['request'] && request.result['request']['user']; } @@ -440,7 +444,7 @@ const printerList = []; printerListJson.forEach(function(printerJson) { try { - printerList.push(cloudprint.parseCloudDestination( + printerList.push(parseCloudDestination( printerJson, request.origin, activeUser)); } catch (err) { console.error('Unable to parse cloud print destination: ' + err); @@ -473,7 +477,7 @@ /** * Called when invitations search request completes. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. * @private */ @@ -488,7 +492,7 @@ invitationListJson.forEach(function(invitationJson) { try { invitationList.push( - cloudprint.parseInvitation(invitationJson, activeUser)); + parseInvitation(invitationJson, activeUser)); } catch (e) { console.error('Unable to parse invitation: ' + e); } @@ -509,9 +513,9 @@ /** * Called when invitation processing request completes. - * @param {!print_preview.Invitation} invitation Processed invitation. + * @param {!Invitation} invitation Processed invitation. * @param {boolean} accept Whether this invitation was accepted or rejected. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. * @private */ @@ -522,7 +526,7 @@ let printer = null; if (request.xhr.status == 200 && request.result['success'] && accept) { try { - printer = cloudprint.parseCloudDestination( + printer = parseCloudDestination( request.result['printer'], request.origin, activeUser); } catch (e) { console.error('Failed to parse cloud print destination: ' + e); @@ -541,7 +545,7 @@ /** * Called when the submit request completes. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. * @private */ @@ -561,14 +565,14 @@ /** * Called when the printer request completes. * @param {string} destinationId ID of the destination that was looked up. - * @param {!cloudprint.CloudPrintRequest} request Request that has been + * @param {!CloudPrintRequest} request Request that has been * completed. * @private */ onPrinterDone_(destinationId, request) { // Special handling of the first printer request. It does not matter at // this point, whether printer was found or not. - if (request.origin == print_preview.DestinationOrigin.COOKIES && + if (request.origin == DestinationOrigin.COOKIES && request.result && request.result['request']['user'] && request.result['request']['users']) { const users = request.result['request']['users']; @@ -590,13 +594,13 @@ // Process response. if (request.xhr.status == 200 && request.result['success']) { let activeUser = ''; - if (request.origin == print_preview.DestinationOrigin.COOKIES) { + if (request.origin == DestinationOrigin.COOKIES) { activeUser = request.result['request']['user']; } const printerJson = request.result['printers'][0]; let printer; try { - printer = cloudprint.parseCloudDestination( + printer = parseCloudDestination( printerJson, request.origin, activeUser); } catch (err) { console.error( @@ -646,16 +650,16 @@ */ const VERSION_REGEXP_ = /.*Chrome\/([\d\.]+)/i; - class CloudPrintRequest { + export class CloudPrintRequest { /** * Data structure that holds data for Cloud Print requests. * @param {!XMLHttpRequest} xhr Partially prepared http request. * @param {string} body Data to send with POST requests. - * @param {!print_preview.DestinationOrigin} origin Origin for destination. + * @param {!DestinationOrigin} origin Origin for destination. * @param {?string} account Account the request is sent for. Can be * {@code null} or empty string if the request is not cookie bound or * is sent on behalf of the primary user. - * @param {function(!cloudprint.CloudPrintRequest)} callback Callback to + * @param {function(!CloudPrintRequest)} callback Callback to * invoke when request completes. */ constructor(xhr, body, origin, account, callback) { @@ -673,7 +677,7 @@ /** * Origin for destination. - * @type {!print_preview.DestinationOrigin} + * @type {!DestinationOrigin} */ this.origin = origin; @@ -685,7 +689,7 @@ /** * Callback to invoke when request completes. - * @type {function(!cloudprint.CloudPrintRequest)} + * @type {function(!CloudPrintRequest)} */ this.callback = callback; @@ -717,10 +721,3 @@ this.value = value; } } - - // Export - return { - CloudPrintInterfaceJS: CloudPrintInterfaceJS, - CloudPrintRequest: CloudPrintRequest, - }; -});
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface_manager.html b/chrome/browser/resources/print_preview/cloud_print_interface_manager.html deleted file mode 100644 index 31eac5d..0000000 --- a/chrome/browser/resources/print_preview/cloud_print_interface_manager.html +++ /dev/null
@@ -1,11 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="cloud_print_interface.html"> -<link rel="import" href="native_layer.html"> -<link rel="import" href="data/cloud_parsers.html"> -<link rel="import" href="data/destination.html"> -<link rel="import" href="data/document_info.html"> -<link rel="import" href="data/invitation.html"> - -<script src="cloud_print_interface_js.js"></script> -<script src="cloud_print_interface_native.js"></script> -<script src="cloud_print_interface_manager.js"></script>
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface_manager.js b/chrome/browser/resources/print_preview/cloud_print_interface_manager.js index 83d98d4..ce3ac756 100644 --- a/chrome/browser/resources/print_preview/cloud_print_interface_manager.js +++ b/chrome/browser/resources/print_preview/cloud_print_interface_manager.js
@@ -2,29 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('cloudprint', function() { - 'use strict'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {CloudPrintInterface} from './cloud_print_interface.js'; +import {CloudPrintInterfaceJS} from './cloud_print_interface_js.js'; +import {CloudPrintInterfaceNative} from './cloud_print_interface_native.js'; +import {NativeLayer} from './native_layer.js'; - /** @type {?cloudprint.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let instance = null; /** * @param {string} baseUrl Base part of the Google Cloud Print service URL * with no trailing slash. For example, * 'https://www.google.com/cloudprint'. - * @param {!print_preview.NativeLayer} nativeLayer Native layer instance. + * @param {!NativeLayer} nativeLayer Native layer instance. * @param {boolean} isInAppKioskMode Whether the print preview is in App * Kiosk mode. * @param {string} uiLocale The UI locale, for example "en-US" or "fr". - * @return {!cloudprint.CloudPrintInterface} + * @return {!CloudPrintInterface} */ - function getCloudPrintInterface( + export function getCloudPrintInterface( baseUrl, nativeLayer, isInAppKioskMode, uiLocale) { if (instance === null) { if (loadTimeData.getBoolean('cloudPrinterHandlerEnabled')) { - instance = new cloudprint.CloudPrintInterfaceNative(); + instance = new CloudPrintInterfaceNative(); } else { - instance = new cloudprint.CloudPrintInterfaceJS( + instance = new CloudPrintInterfaceJS( baseUrl, nativeLayer, isInAppKioskMode, uiLocale); } } @@ -33,15 +36,8 @@ /** * Sets the CloudPrintInterface singleton instance, useful for testing. - * @param {!cloudprint.CloudPrintInterface} cloudPrintInterface + * @param {!CloudPrintInterface} cloudPrintInterface */ - function setCloudPrintInterfaceForTesting(cloudPrintInterface) { + export function setCloudPrintInterfaceForTesting(cloudPrintInterface) { instance = cloudPrintInterface; } - - // Export - return { - getCloudPrintInterface: getCloudPrintInterface, - setCloudPrintInterfaceForTesting: setCloudPrintInterfaceForTesting, - }; -});
diff --git a/chrome/browser/resources/print_preview/cloud_print_interface_native.js b/chrome/browser/resources/print_preview/cloud_print_interface_native.js index c12f284..abaf6a8 100644 --- a/chrome/browser/resources/print_preview/cloud_print_interface_native.js +++ b/chrome/browser/resources/print_preview/cloud_print_interface_native.js
@@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('cloudprint', function() { - 'use strict'; +import {CloudPrintInterface} from './cloud_print_interface.js'; - /** @implements {cloudprint.CloudPrintInterface} */ - class CloudPrintInterfaceNative { + /** @implements {CloudPrintInterface} */ + export class CloudPrintInterfaceNative { constructor() {} /** @override */ @@ -33,9 +32,3 @@ /** @override */ printer(printerId, origin, account) {} } - - // Export - return { - CloudPrintInterfaceNative: CloudPrintInterfaceNative, - }; -});
diff --git a/chrome/browser/resources/print_preview/dark_mode_behavior.html b/chrome/browser/resources/print_preview/dark_mode_behavior.html deleted file mode 100644 index b8924f4f..0000000 --- a/chrome/browser/resources/print_preview/dark_mode_behavior.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="dark_mode_behavior.js"></script>
diff --git a/chrome/browser/resources/print_preview/dark_mode_behavior.js b/chrome/browser/resources/print_preview/dark_mode_behavior.js index f25bbb3..7d570d6 100644 --- a/chrome/browser/resources/print_preview/dark_mode_behavior.js +++ b/chrome/browser/resources/print_preview/dark_mode_behavior.js
@@ -1,15 +1,12 @@ // 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. - -cr.exportPath('print_preview'); - -(function() { +import {assert} from 'chrome://resources/js/assert.m.js'; const prefersDark = window.matchMedia('(prefers-color-scheme: dark)'); /** @polymerBehavior */ -print_preview.DarkModeBehavior = { +export const DarkModeBehavior = { properties: { /** Whether or not the OS is in dark mode. */ inDarkMode: { @@ -35,5 +32,4 @@ }, }; -print_preview.DarkModeBehavior.inDarkMode = () => prefersDark.matches; -}()); +DarkModeBehavior.inDarkMode = () => prefersDark.matches;
diff --git a/chrome/browser/resources/print_preview/data/BUILD.gn b/chrome/browser/resources/print_preview/data/BUILD.gn index 7f04cc61..4720df3d 100644 --- a/chrome/browser/resources/print_preview/data/BUILD.gn +++ b/chrome/browser/resources/print_preview/data/BUILD.gn
@@ -3,13 +3,16 @@ # found in the LICENSE file. import("//third_party/closure_compiler/compile_js.gni") +import("//tools/polymer/polymer.gni") -js_type_check("closure_compile") { +js_type_check("closure_compile_module") { + is_polymer3 = true deps = [ ":cloud_parsers", ":coordinate2d", ":destination", ":destination_match", + ":destination_policies", ":destination_store", ":document_info", ":invitation", @@ -22,9 +25,13 @@ ":scaling", ":size", ":state", + ":user_manager", ] } +js_library("destination_policies") { +} + js_library("destination_store") { deps = [ ":destination", @@ -33,9 +40,11 @@ "..:cloud_print_interface", "..:metrics", "..:native_layer", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:event_tracker", - "//ui/webui/resources/js/cr:event_target", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:cr.m", + "//ui/webui/resources/js:event_tracker.m", + "//ui/webui/resources/js:load_time_data.m", + "//ui/webui/resources/js/cr:event_target.m", ] } @@ -43,8 +52,8 @@ deps = [ ":invitation", "..:cloud_print_interface", - "//ui/webui/resources/js:event_tracker", - "//ui/webui/resources/js/cr:event_target", + "//ui/webui/resources/js:event_tracker.m", + "//ui/webui/resources/js/cr:event_target.m", ] } @@ -53,14 +62,14 @@ ":destination", ":destination_match", "..:native_layer", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:cr.m", ] } js_library("destination_match") { deps = [ ":destination", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] } @@ -68,22 +77,26 @@ deps = [ ":destination", ":invitation", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] } js_library("invitation") { deps = [ ":destination", - "//ui/webui/resources/js:cr", ] } js_library("destination") { deps = [ - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:load_time_data", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:cr.m", + "//ui/webui/resources/js:load_time_data.m", ] + + if (is_chromeos) { + deps += [ ":destination_policies" ] + } } js_library("document_info") { @@ -92,20 +105,17 @@ ":margins", ":printable_area", ":size", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:web_ui_listener_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] } js_library("margins") { - deps = [ - "//ui/webui/resources/js:cr", - ] } js_library("measurement_system") { deps = [ - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] } @@ -116,8 +126,12 @@ ":document_info", ":margins", ":scaling", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:promise_resolver", + ":size", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:cr.m", + "//ui/webui/resources/js:load_time_data.m", + "//ui/webui/resources/js:promise_resolver.m", ] } @@ -125,41 +139,33 @@ deps = [ ":coordinate2d", ":size", - "//ui/webui/resources/js:cr", ] } js_library("scaling") { - deps = [ - "//ui/webui/resources/js:cr", - ] } js_library("size") { - deps = [ - "//ui/webui/resources/js:cr", - ] } js_library("state") { deps = [ - "//ui/webui/resources/js:cr", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:assert.m", ] } js_library("coordinate2d") { - deps = [ - "//ui/webui/resources/js:cr", - ] } js_library("user_manager") { deps = [ + ":destination", ":destination_store", ":invitation_store", "..:cloud_print_interface", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:event_tracker", - "//ui/webui/resources/js:web_ui_listener_behavior", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:event_tracker.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] }
diff --git a/chrome/browser/resources/print_preview/data/cloud_parsers.html b/chrome/browser/resources/print_preview/data/cloud_parsers.html deleted file mode 100644 index 12f99eb..0000000 --- a/chrome/browser/resources/print_preview/data/cloud_parsers.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="destination.html"> -<link rel="import" href="invitation.html"> - -<script src="cloud_parsers.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/cloud_parsers.js b/chrome/browser/resources/print_preview/data/cloud_parsers.js index 996ddfca..53843a9e 100644 --- a/chrome/browser/resources/print_preview/data/cloud_parsers.js +++ b/chrome/browser/resources/print_preview/data/cloud_parsers.js
@@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('cloudprint', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Cdd, Destination, DestinationCertificateStatus, DestinationConnectionStatus, DestinationOrigin, DestinationType} from './destination.js'; +import {Invitation} from './invitation.js'; /** * Enumeration of cloud destination field names. @@ -52,38 +53,38 @@ * Parses the destination type. * @param {string} typeStr Destination type given by the Google Cloud Print * server. - * @return {!print_preview.DestinationType} Destination type. + * @return {!DestinationType} Destination type. * @private */ function parseType(typeStr) { if (typeStr == DestinationCloudType.ANDROID || typeStr == DestinationCloudType.IOS) { - return print_preview.DestinationType.MOBILE; + return DestinationType.MOBILE; } if (typeStr == DestinationCloudType.DOCS) { - return print_preview.DestinationType.GOOGLE_PROMOTED; + return DestinationType.GOOGLE_PROMOTED; } - return print_preview.DestinationType.GOOGLE; + return DestinationType.GOOGLE; } /** * @param {!Array<string>} tags The array of tag strings sent by GCP server. - * @return {!print_preview.DestinationCertificateStatus} The certificate + * @return {!DestinationCertificateStatus} The certificate * status indicated by the tag. Returns NONE if certificate tag is not * found. */ function extractCertificateStatus(tags) { const certTag = tags.find(tag => tag.startsWith(CERT_TAG)); if (!certTag) { - return print_preview.DestinationCertificateStatus.NONE; + return DestinationCertificateStatus.NONE; } - const value = /** @type {print_preview.DestinationCertificateStatus} */ ( + const value = /** @type {DestinationCertificateStatus} */ ( certTag.substring(CERT_TAG.length)); // Only 2 valid values sent by GCP server. assert( - value == print_preview.DestinationCertificateStatus.UNKNOWN || - value == print_preview.DestinationCertificateStatus.YES || - value == print_preview.DestinationCertificateStatus.NO); + value == DestinationCertificateStatus.UNKNOWN || + value == DestinationCertificateStatus.YES || + value == DestinationCertificateStatus.NO); return value; } @@ -92,13 +93,13 @@ * response. * @param {!Object} json Object that represents a Google Cloud Print search or * printer response. - * @param {!print_preview.DestinationOrigin} origin The origin of the + * @param {!DestinationOrigin} origin The origin of the * response. * @param {string} account The account this destination is registered for or * empty string, if origin != COOKIES. - * @return {!print_preview.Destination} Parsed destination. + * @return {!Destination} Parsed destination. */ - function parseCloudDestination(json, origin, account) { + export function parseCloudDestination(json, origin, account) { if (!json.hasOwnProperty(CloudDestinationField.ID) || !json.hasOwnProperty(CloudDestinationField.TYPE) || !json.hasOwnProperty(CloudDestinationField.DISPLAY_NAME)) { @@ -107,7 +108,7 @@ const id = json[CloudDestinationField.ID]; const tags = json[CloudDestinationField.TAGS] || []; const connectionStatus = json[CloudDestinationField.CONNECTION_STATUS] || - print_preview.DestinationConnectionStatus.UNKNOWN; + DestinationConnectionStatus.UNKNOWN; const optionalParams = { account: account, tags: tags, @@ -118,12 +119,12 @@ description: json[CloudDestinationField.DESCRIPTION], certificateStatus: extractCertificateStatus(tags), }; - const cloudDest = new print_preview.Destination( + const cloudDest = new Destination( id, parseType(json[CloudDestinationField.TYPE]), origin, json[CloudDestinationField.DISPLAY_NAME], connectionStatus, optionalParams); if (json.hasOwnProperty(CloudDestinationField.CAPABILITIES)) { - cloudDest.capabilities = /** @type {!print_preview.Cdd} */ ( + cloudDest.capabilities = /** @type {!Cdd} */ ( json[CloudDestinationField.CAPABILITIES]); } return cloudDest; @@ -150,9 +151,9 @@ * Parses printer sharing invitation from JSON from GCP invite API response. * @param {!Object} json Object that represents a invitation search response. * @param {string} account The account this invitation is sent for. - * @return {!print_preview.Invitation} Parsed invitation. + * @return {!Invitation} Parsed invitation. */ - function parseInvitation(json, account) { + export function parseInvitation(json, account) { if (!json.hasOwnProperty(InvitationField.SENDER) || !json.hasOwnProperty(InvitationField.RECEIVER) || !json.hasOwnProperty(InvitationField.PRINTER)) { @@ -179,17 +180,11 @@ throw Error('Invitation of unsupported receiver type'); } - const destination = cloudprint.parseCloudDestination( - json[InvitationField.PRINTER], print_preview.DestinationOrigin.COOKIES, + const destination = parseCloudDestination( + json[InvitationField.PRINTER], DestinationOrigin.COOKIES, account); - return new print_preview.Invitation( + return new Invitation( senderName, receiverName, destination, receiver, account); } - // Export - return { - parseCloudDestination: parseCloudDestination, - parseInvitation: parseInvitation, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/coordinate2d.html b/chrome/browser/resources/print_preview/data/coordinate2d.html deleted file mode 100644 index a121f096..0000000 --- a/chrome/browser/resources/print_preview/data/coordinate2d.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="coordinate2d.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/coordinate2d.js b/chrome/browser/resources/print_preview/data/coordinate2d.js index 2944e47d..f453d2c 100644 --- a/chrome/browser/resources/print_preview/data/coordinate2d.js +++ b/chrome/browser/resources/print_preview/data/coordinate2d.js
@@ -2,10 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; - - class Coordinate2d { + export class Coordinate2d { /** * Immutable two dimensional point in space. The units of the dimensions are * undefined. @@ -39,7 +36,7 @@ } /** - * @param {print_preview.Coordinate2d} other The point to compare against. + * @param {Coordinate2d} other The point to compare against. * @return {boolean} Whether another point is equal to this one. */ equals(other) { @@ -47,6 +44,3 @@ } } - // Export - return {Coordinate2d: Coordinate2d}; -});
diff --git a/chrome/browser/resources/print_preview/data/destination.html b/chrome/browser/resources/print_preview/data/destination.html deleted file mode 100644 index 30a5495..0000000 --- a/chrome/browser/resources/print_preview/data/destination.html +++ /dev/null
@@ -1,6 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="../ui/strings.html"> - -<script src="destination.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/destination.js b/chrome/browser/resources/print_preview/data/destination.js index ef23d35..9cc7acb 100644 --- a/chrome/browser/resources/print_preview/data/destination.js +++ b/chrome/browser/resources/print_preview/data/destination.js
@@ -2,14 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import '../strings.m.js'; +// <if expr="chromeos"> +import {BackgroundGraphicsModeRestriction, ColorModeRestriction, DuplexModeRestriction, PinModeRestriction, Policies} from './destination_policies.js'; +// </if> /** * Enumeration of the types of destinations. * @enum {string} */ - const DestinationType = { + export const DestinationType = { GOOGLE: 'google', GOOGLE_PROMOTED: 'google_promoted', LOCAL: 'local', @@ -20,7 +25,7 @@ * Enumeration of the origin types for cloud destinations. * @enum {string} */ - const DestinationOrigin = { + export const DestinationOrigin = { LOCAL: 'local', COOKIES: 'cookies', // <if expr="chromeos"> @@ -33,9 +38,9 @@ /** * Cloud Print origins. - * @const {!Array<!print_preview.DestinationOrigin>} + * @const {!Array<!DestinationOrigin>} */ - const CloudOrigins = [ + export const CloudOrigins = [ DestinationOrigin.COOKIES, // <if expr="chromeos"> DestinationOrigin.DEVICE, @@ -46,7 +51,7 @@ * Enumeration of the connection statuses of printer destinations. * @enum {string} */ - const DestinationConnectionStatus = { + export const DestinationConnectionStatus = { DORMANT: 'DORMANT', OFFLINE: 'OFFLINE', ONLINE: 'ONLINE', @@ -59,7 +64,7 @@ * the destination is provisional. * @enum {string} */ - const DestinationProvisionalType = { + export const DestinationProvisionalType = { // Destination is not provisional. NONE: 'NONE', // User has to grant USB access for the destination to its provider. @@ -72,7 +77,7 @@ * Values UNKNOWN and YES are returned directly by the GCP server. * @enum {string} */ - const DestinationCertificateStatus = { + export const DestinationCertificateStatus = { // Destination is not a cloud printer or no status was retrieved. NONE: 'NONE', // Printer does not have a valid 2018 certificate. Currently unused, to be @@ -92,13 +97,13 @@ * is_default: (boolean | undefined), * }} */ - let VendorCapabilitySelectOption; + export let VendorCapabilitySelectOption; /** * Same as cloud_devices::printer::TypedValueVendorCapability::ValueType. * @enum {string} */ - const VendorCapabilityValueType = { + export const VendorCapabilityValueType = { BOOLEAN: 'BOOLEAN', FLOAT: 'FLOAT', INTEGER: 'INTEGER', @@ -113,18 +118,18 @@ * localized_display_name: (string | undefined), * type: (string), * select_cap: ({ - * option: (Array<!print_preview.VendorCapabilitySelectOption>|undefined), + * option: (Array<!VendorCapabilitySelectOption>|undefined), * }|undefined), * typed_value_cap: ({ * default: (number | string | boolean | undefined), - * value_type: (print_preview.VendorCapabilityValueType | undefined), + * value_type: (VendorCapabilityValueType | undefined), * }|undefined), * range_cap: ({ * default: (number), * }), * }} */ - let VendorCapability; + export let VendorCapability; /** * Capabilities of a print destination represented in a CDD. @@ -132,7 +137,7 @@ * only on Chrome OS. * * @typedef {{ - * vendor_capability: !Array<!print_preview.VendorCapability>, + * vendor_capability: !Array<!VendorCapability>, * collate: ({default: (boolean|undefined)}|undefined), * color: ({ * option: !Array<{ @@ -169,7 +174,7 @@ * pin: ({supported: (boolean|undefined)}|undefined) * }} */ - let CddCapabilities; + export let CddCapabilities; /** * The CDD (Cloud Device Description) describes the capabilities of a print @@ -177,110 +182,40 @@ * * @typedef {{ * version: string, - * printer: !print_preview.CddCapabilities, + * printer: !CddCapabilities, * }} */ - let Cdd; + export let Cdd; /** * Enumeration of color modes used by Chromium. * @enum {number} */ - const ColorMode = { + export const ColorMode = { GRAY: 1, COLOR: 2, }; - // <if expr="chromeos"> - /** - * Enumeration of color mode restrictions used by Chromium. - * This has to coincide with |printing::ColorModeRestriction| as defined in - * printing/backend/printing_restrictions.h - * @enum {number} - */ - const ColorModeRestriction = { - UNSET: 0x0, - MONOCHROME: 0x1, - COLOR: 0x2, - }; - - /** - * Enumeration of duplex mode restrictions used by Chromium. - * This has to coincide with |printing::DuplexModeRestriction| as defined in - * printing/backend/printing_restrictions.h - * @enum {number} - */ - const DuplexModeRestriction = { - UNSET: 0x0, - SIMPLEX: 0x1, - LONG_EDGE: 0x2, - SHORT_EDGE: 0x4, - DUPLEX: 0x6, - }; - - /** - * Enumeration of PIN printing mode restrictions used by Chromium. - * This has to coincide with |printing::PinModeRestriction| as defined in - * printing/backend/printing_restrictions.h - * @enum {number} - */ - const PinModeRestriction = { - UNSET: 0, - PIN: 1, - NO_PIN: 2, - }; - - /** - * Enumeration of background graphics printing mode restrictions used by - * Chromium. - * This has to coincide with |printing::BackgroundGraphicsModeRestriction| as - * defined in printing/backend/printing_restrictions.h - * @enum {number} - */ - const BackgroundGraphicsModeRestriction = { - UNSET: 0, - ENABLED: 1, - DISABLED: 2, - }; - - /** - * Policies affecting a destination. - * @typedef {{ - * allowedColorModes: ?print_preview.ColorModeRestriction, - * allowedDuplexModes: ?print_preview.DuplexModeRestriction, - * allowedPinMode: ?print_preview.PinModeRestriction, - * allowedBackgroundGraphicsMode: - * ?print_preview.BackgroundGraphicsModeRestriction, - * defaultColorMode: ?print_preview.ColorModeRestriction, - * defaultDuplexMode: ?print_preview.DuplexModeRestriction, - * defaultPinMode: ?print_preview.PinModeRestriction, - * defaultBackgroundGraphicsMode: - * ?print_preview.BackgroundGraphicsModeRestriction, - * }} - */ - let Policies; - // </if> - /** * @typedef {{id: string, - * origin: print_preview.DestinationOrigin, + * origin: DestinationOrigin, * account: string, - * capabilities: ?print_preview.Cdd, + * capabilities: ?Cdd, * displayName: string, * extensionId: string, * extensionName: string, * icon: (string | undefined) * }} */ - let RecentDestination; + export let RecentDestination; /** * Creates a |RecentDestination| to represent |destination| in the app * state. - * @param {!print_preview.Destination} destination The destination to store. - * @return {!print_preview.RecentDestination} + * @param {!Destination} destination The destination to store. + * @return {!RecentDestination} */ - function makeRecentDestination(destination) { + export function makeRecentDestination(destination) { return { id: destination.id, origin: destination.origin, @@ -295,36 +230,36 @@ /** * @param {string} id Destination id. - * @param {!print_preview.DestinationOrigin} origin Destination origin. + * @param {!DestinationOrigin} origin Destination origin. * @param {string} account User account destination is registered for. * @return {string} A key that maps to a destination with the selected |id|, * |origin|, and |account|. */ - function createDestinationKey(id, origin, account) { + export function createDestinationKey(id, origin, account) { return `${id}/${origin}/${account}`; } /** - * @param {!print_preview.RecentDestination} recentDestination + * @param {!RecentDestination} recentDestination * @return {string} A key that maps to a destination with parameters matching * |recentDestination|. */ - function createRecentDestinationKey(recentDestination) { - return print_preview.createDestinationKey( + export function createRecentDestinationKey(recentDestination) { + return createDestinationKey( recentDestination.id, recentDestination.origin, recentDestination.account); } - class Destination { + export class Destination { /** * Print destination data object that holds data for both local and cloud * destinations. * @param {string} id ID of the destination. - * @param {!print_preview.DestinationType} type Type of the destination. - * @param {!print_preview.DestinationOrigin} origin Origin of the + * @param {!DestinationType} type Type of the destination. + * @param {!DestinationOrigin} origin Origin of the * destination. * @param {string} displayName Display name of the destination. - * @param {!print_preview.DestinationConnectionStatus} connectionStatus + * @param {!DestinationConnectionStatus} connectionStatus * Connection status of the print destination. * @param {{tags: (Array<string>|undefined), * isOwned: (boolean|undefined), @@ -333,13 +268,13 @@ * lastAccessTime: (number|undefined), * cloudID: (string|undefined), * provisionalType: - * (print_preview.DestinationProvisionalType|undefined), + * (DestinationProvisionalType|undefined), * extensionId: (string|undefined), * extensionName: (string|undefined), * description: (string|undefined), * certificateStatus: - * (print_preview.DestinationCertificateStatus|undefined), - * policies: (print_preview.Policies|undefined), + * (DestinationCertificateStatus|undefined), + * policies: (Policies|undefined), * }=} opt_params Optional * parameters for the destination. */ @@ -352,13 +287,13 @@ /** * Type of the destination. - * @private {!print_preview.DestinationType} + * @private {!DestinationType} */ this.type_ = type; /** * Origin of the destination. - * @private {!print_preview.DestinationOrigin} + * @private {!DestinationOrigin} */ this.origin_ = origin; @@ -376,13 +311,13 @@ /** * Print capabilities of the destination. - * @private {?print_preview.Cdd} + * @private {?Cdd} */ this.capabilities_ = null; /** * Policies affecting the destination. - * @private {?print_preview.Policies} + * @private {?Policies} */ this.policies_ = (opt_params && opt_params.policies) || null; @@ -419,7 +354,7 @@ /** * Connection status of the destination. - * @private {!print_preview.DestinationConnectionStatus} + * @private {!DestinationConnectionStatus} */ this.connectionStatus_ = connectionStatus; @@ -450,24 +385,24 @@ this.extensionName_ = (opt_params && opt_params.extensionName) || ''; /** - * Different from {@code print_preview.DestinationProvisionalType.NONE} if + * Different from DestinationProvisionalType.NONE if * the destination is provisional. Provisional destinations cannot be * selected as they are, but have to be resolved first (i.e. extra steps * have to be taken to get actual destination properties, which should * replace the provisional ones). Provisional destination resolvment flow * will be started when the user attempts to select the destination in * search UI. - * @private {print_preview.DestinationProvisionalType} + * @private {DestinationProvisionalType} */ this.provisionalType_ = (opt_params && opt_params.provisionalType) || DestinationProvisionalType.NONE; /** * Printer 2018 certificate status - * @private {print_preview.DestinationCertificateStatus} + * @private {DestinationCertificateStatus} */ this.certificateStatus_ = opt_params && opt_params.certificateStatus || - print_preview.DestinationCertificateStatus.NONE; + DestinationCertificateStatus.NONE; assert( this.provisionalType_ != @@ -494,13 +429,13 @@ return this.id_; } - /** @return {!print_preview.DestinationType} Type of the destination. */ + /** @return {!DestinationType} Type of the destination. */ get type() { return this.type_; } /** - * @return {!print_preview.DestinationOrigin} Origin of the destination. + * @return {!DestinationOrigin} Origin of the destination. */ get origin() { return this.origin_; @@ -612,13 +547,13 @@ return this.extensionName_; } - /** @return {?print_preview.Cdd} Print capabilities of the destination. */ + /** @return {?Cdd} Print capabilities of the destination. */ get capabilities() { return this.capabilities_; } /** - * @param {?print_preview.Cdd} capabilities Print capabilities of the + * @param {?Cdd} capabilities Print capabilities of the * destination. */ set capabilities(capabilities) { @@ -629,7 +564,7 @@ // <if expr="chromeos"> /** - * @return {?print_preview.Policies} Print policies affecting the + * @return {?Policies} Print policies affecting the * destination. */ get policies() { @@ -637,7 +572,7 @@ } /** - * @param {?print_preview.Policies} policies Print policies affecting the + * @param {?Policies} policies Print policies affecting the * destination. */ set policies(policies) { @@ -646,7 +581,7 @@ // </if> /** - * @return {!print_preview.DestinationConnectionStatus} Connection status + * @return {!DestinationConnectionStatus} Connection status * of the print destination. */ get connectionStatus() { @@ -654,7 +589,7 @@ } /** - * @param {!print_preview.DestinationConnectionStatus} status Connection + * @param {!DestinationConnectionStatus} status Connection * status of the print destination. */ set connectionStatus(status) { @@ -667,7 +602,7 @@ */ get hasInvalidCertificate() { return this.certificateStatus_ == - print_preview.DestinationCertificateStatus.NO; + DestinationCertificateStatus.NO; } /** @@ -677,15 +612,15 @@ */ get shouldShowInvalidCertificateError() { return this.certificateStatus_ == - print_preview.DestinationCertificateStatus.NO && + DestinationCertificateStatus.NO && !loadTimeData.getBoolean('isEnterpriseManaged'); } /** @return {boolean} Whether the destination is considered offline. */ get isOffline() { return [ - print_preview.DestinationConnectionStatus.OFFLINE, - print_preview.DestinationConnectionStatus.DORMANT + DestinationConnectionStatus.OFFLINE, + DestinationConnectionStatus.DORMANT ].includes(this.connectionStatus_); } @@ -699,7 +634,7 @@ /** @return {boolean} Whether the destination is ready to be selected. */ get readyForSelection() { - return (!cr.isChromeOS || this.origin_ != DestinationOrigin.CROS || + return (!isChromeOS || this.origin_ != DestinationOrigin.CROS || this.capabilities_ != null) && !this.isProvisional; } @@ -750,10 +685,10 @@ if (this.isLocal) { return 'print-preview:print'; } - if (this.type_ == print_preview.DestinationType.MOBILE && this.isOwned_) { + if (this.type_ == DestinationType.MOBILE && this.isOwned_) { return 'print-preview:smartphone'; } - if (this.type_ == print_preview.DestinationType.MOBILE) { + if (this.type_ == DestinationType.MOBILE) { return 'print-preview:smartphone'; } if (this.isOwned_) { @@ -784,7 +719,7 @@ /** * Gets the destination's provisional type. - * @return {print_preview.DestinationProvisionalType} + * @return {DestinationProvisionalType} */ get provisionalType() { return this.provisionalType_; @@ -792,7 +727,7 @@ /** * Gets the destination's certificate status. - * @return {print_preview.DestinationCertificateStatus} + * @return {DestinationCertificateStatus} */ get certificateStatus() { return this.certificateStatus_; @@ -827,7 +762,7 @@ // <if expr="chromeos"> /** - * @return {?print_preview.ColorModeRestriction} Color mode set by policy. + * @return {?ColorModeRestriction} Color mode set by policy. */ get colorPolicy() { return this.policies && this.policies.allowedColorModes ? @@ -836,7 +771,7 @@ } /** - * @return {?print_preview.DuplexModeRestriction} Duplex modes allowed by + * @return {?DuplexModeRestriction} Duplex modes allowed by * policy. */ get duplexPolicy() { @@ -846,7 +781,7 @@ } /** - * @return {?print_preview.PinModeRestriction} Pin mode allowed by policy. + * @return {?PinModeRestriction} Pin mode allowed by policy. */ get pinPolicy() { return this.policies && this.policies.allowedPinModes ? @@ -855,7 +790,7 @@ } /** - * @return {?print_preview.BackgroundGraphicsModeRestriction} Background + * @return {?BackgroundGraphicsModeRestriction} Background * graphics mode allowed by policy. */ get backgroundGraphicsPolicy() { @@ -887,7 +822,7 @@ // <if expr="chromeos"> /** - * @return {?print_preview.ColorModeRestriction} Value of default color + * @return {?ColorModeRestriction} Value of default color * setting given by policy. */ get defaultColorPolicy() { @@ -895,7 +830,7 @@ } /** - * @return {?print_preview.DuplexModeRestriction} Value of default duplex + * @return {?DuplexModeRestriction} Value of default duplex * setting given by policy. */ get defaultDuplexPolicy() { @@ -903,7 +838,7 @@ } /** - * @return {?print_preview.PinModeRestriction} Value of default pin setting + * @return {?PinModeRestriction} Value of default pin setting * given by policy. */ get defaultPinPolicy() { @@ -911,7 +846,7 @@ } /** - * @return {?print_preview.BackgroundGraphicsModeRestriction} Value of + * @return {?BackgroundGraphicsModeRestriction} Value of * default background graphics setting given by policy. */ get defaultBackgroundGraphicsPolicy() { @@ -950,14 +885,14 @@ // model is ignored. const capability = this.colorCapability_(); if (!capability || !capability.option || !this.isLocal) { - return isColor ? print_preview.ColorMode.COLOR : - print_preview.ColorMode.GRAY; + return isColor ? ColorMode.COLOR : + ColorMode.GRAY; } const selected = this.getSelectedColorOption(isColor); const mode = parseInt(selected ? selected.vendor_id : null, 10); if (isNaN(mode)) { - return isColor ? print_preview.ColorMode.COLOR : - print_preview.ColorMode.GRAY; + return isColor ? ColorMode.COLOR : + ColorMode.GRAY; } return mode; } @@ -999,32 +934,3 @@ SAVE_AS_PDF: 'Save as PDF' }; - // Export - return { - CddCapabilities: CddCapabilities, - Cdd: Cdd, - CloudOrigins: CloudOrigins, - ColorMode: ColorMode, - createDestinationKey: createDestinationKey, - createRecentDestinationKey: createRecentDestinationKey, - DestinationCertificateStatus: DestinationCertificateStatus, - DestinationConnectionStatus: DestinationConnectionStatus, - Destination: Destination, - DestinationOrigin: DestinationOrigin, - DestinationProvisionalType: DestinationProvisionalType, - DestinationType: DestinationType, - makeRecentDestination: makeRecentDestination, - RecentDestination: RecentDestination, - VendorCapabilitySelectOption: VendorCapabilitySelectOption, - VendorCapabilityValueType: VendorCapabilityValueType, - VendorCapability: VendorCapability, - - // <if expr="chromeos"> - BackgroundGraphicsModeRestriction: BackgroundGraphicsModeRestriction, - ColorModeRestriction: ColorModeRestriction, - DuplexModeRestriction: DuplexModeRestriction, - PinModeRestriction: PinModeRestriction, - Policies: Policies, - // </if> - }; -});
diff --git a/chrome/browser/resources/print_preview/data/destination_match.html b/chrome/browser/resources/print_preview/data/destination_match.html deleted file mode 100644 index 288ce95..0000000 --- a/chrome/browser/resources/print_preview/data/destination_match.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="destination.html"> - -<script src="destination_match.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/destination_match.js b/chrome/browser/resources/print_preview/data/destination_match.js index c147e00..cfabe46 100644 --- a/chrome/browser/resources/print_preview/data/destination_match.js +++ b/chrome/browser/resources/print_preview/data/destination_match.js
@@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {CloudOrigins, Destination, DestinationOrigin} from './destination.js'; + /** * Printer types for capabilities and printer list requests. * Must match PrinterType in printing/print_job_constants.h * @enum {number} */ - const PrinterType = { + export const PrinterType = { PRIVET_PRINTER: 0, EXTENSION_PRINTER: 1, PDF_PRINTER: 2, @@ -19,43 +20,42 @@ /** * Converts DestinationOrigin to PrinterType. - * @param {!print_preview.DestinationOrigin} origin The printer's - * destination origin. - * return {!print_preview.PrinterType} The corresponding PrinterType. + * @param {!DestinationOrigin} origin The printer's destination origin. + * return {!PrinterType} The corresponding PrinterType. */ - const originToType = function(origin) { - if (origin === print_preview.DestinationOrigin.LOCAL || - origin === print_preview.DestinationOrigin.CROS) { - return print_preview.PrinterType.LOCAL_PRINTER; + export const originToType = function(origin) { + if (origin === DestinationOrigin.LOCAL || + origin === DestinationOrigin.CROS) { + return PrinterType.LOCAL_PRINTER; } - if (origin === print_preview.DestinationOrigin.PRIVET) { - return print_preview.PrinterType.PRIVET_PRINTER; + if (origin === DestinationOrigin.PRIVET) { + return PrinterType.PRIVET_PRINTER; } - if (origin === print_preview.DestinationOrigin.EXTENSION) { - return print_preview.PrinterType.EXTENSION_PRINTER; + if (origin === DestinationOrigin.EXTENSION) { + return PrinterType.EXTENSION_PRINTER; } - assert(print_preview.CloudOrigins.includes(origin)); - return print_preview.PrinterType.CLOUD_PRINTER; + assert(CloudOrigins.includes(origin)); + return PrinterType.CLOUD_PRINTER; }; /** - * @param {!print_preview.Destination} destination The destination to figure + * @param {!Destination} destination The destination to figure * out the printer type of. - * @return {!print_preview.PrinterType} Map the destination to a PrinterType. + * @return {!PrinterType} Map the destination to a PrinterType. */ - function getPrinterTypeForDestination(destination) { + export function getPrinterTypeForDestination(destination) { if (destination.id == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { - return print_preview.PrinterType.PDF_PRINTER; + Destination.GooglePromotedId.SAVE_AS_PDF) { + return PrinterType.PDF_PRINTER; } - return print_preview.originToType(destination.origin); + return originToType(destination.origin); } - class DestinationMatch { + export class DestinationMatch { /** * A set of key parameters describing a destination used to determine * if two destinations are the same. - * @param {!Array<!print_preview.DestinationOrigin>} origins Match + * @param {!Array<!DestinationOrigin>} origins Match * destinations from these origins. * @param {RegExp} idRegExp Match destination's id. * @param {RegExp} displayNameRegExp Match destination's displayName. @@ -63,7 +63,7 @@ * destinations, for example, Save as PDF. */ constructor(origins, idRegExp, displayNameRegExp, skipVirtualDestinations) { - /** @private {!Array<!print_preview.DestinationOrigin>} */ + /** @private {!Array<!DestinationOrigin>} */ this.origins_ = origins; /** @private {RegExp} */ @@ -77,7 +77,7 @@ } /** - * @param {!print_preview.DestinationOrigin} origin Origin to match. + * @param {!DestinationOrigin} origin Origin to match. * @return {boolean} Whether the origin is one of the {@code origins_}. */ matchOrigin(origin) { @@ -86,7 +86,7 @@ /** * @param {string} id Id of the destination. - * @param {!print_preview.DestinationOrigin} origin Origin of the + * @param {!DestinationOrigin} origin Origin of the * destination. * @return {boolean} Whether destination is the same as initial. */ @@ -96,7 +96,7 @@ } /** - * @param {!print_preview.Destination} destination Destination to match. + * @param {!Destination} destination Destination to match. * @return {boolean} Whether {@code destination} matches the last user * selected one. */ @@ -119,21 +119,21 @@ } /** - * @param {!print_preview.Destination} destination Destination to check. + * @param {!Destination} destination Destination to check. * @return {boolean} Whether {@code destination} is virtual, in terms of * destination selection. * @private */ isVirtualDestination_(destination) { - if (destination.origin === print_preview.DestinationOrigin.LOCAL) { + if (destination.origin === DestinationOrigin.LOCAL) { return destination.id === - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; + Destination.GooglePromotedId.SAVE_AS_PDF; } - return destination.id === print_preview.Destination.GooglePromotedId.DOCS; + return destination.id === Destination.GooglePromotedId.DOCS; } /** - * @return {!Set<!print_preview.PrinterType>} The printer types that + * @return {!Set<!PrinterType>} The printer types that * correspond to this destination match. */ getTypes() { @@ -141,11 +141,3 @@ } } - // Export - return { - DestinationMatch: DestinationMatch, - PrinterType: PrinterType, - getPrinterTypeForDestination: getPrinterTypeForDestination, - originToType: originToType, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/destination_policies.js b/chrome/browser/resources/print_preview/data/destination_policies.js new file mode 100644 index 0000000..00d2759 --- /dev/null +++ b/chrome/browser/resources/print_preview/data/destination_policies.js
@@ -0,0 +1,71 @@ +// 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. + + /** + * Enumeration of color mode restrictions used by Chromium. + * This has to coincide with |printing::ColorModeRestriction| as defined in + * printing/backend/printing_restrictions.h + * @enum {number} + */ + export const ColorModeRestriction = { + UNSET: 0x0, + MONOCHROME: 0x1, + COLOR: 0x2, + }; + + /** + * Enumeration of duplex mode restrictions used by Chromium. + * This has to coincide with |printing::DuplexModeRestriction| as defined in + * printing/backend/printing_restrictions.h + * @enum {number} + */ + export const DuplexModeRestriction = { + UNSET: 0x0, + SIMPLEX: 0x1, + LONG_EDGE: 0x2, + SHORT_EDGE: 0x4, + DUPLEX: 0x6, + }; + + /** + * Enumeration of PIN printing mode restrictions used by Chromium. + * This has to coincide with |printing::PinModeRestriction| as defined in + * printing/backend/printing_restrictions.h + * @enum {number} + */ + export const PinModeRestriction = { + UNSET: 0, + PIN: 1, + NO_PIN: 2, + }; + + /** + * Enumeration of background graphics printing mode restrictions used by + * Chromium. + * This has to coincide with |printing::BackgroundGraphicsModeRestriction| as + * defined in printing/backend/printing_restrictions.h + * @enum {number} + */ + export const BackgroundGraphicsModeRestriction = { + UNSET: 0, + ENABLED: 1, + DISABLED: 2, + }; + + /** + * Policies affecting a destination. + * @typedef {{ + * allowedColorModes: ?ColorModeRestriction, + * allowedDuplexModes: ?DuplexModeRestriction, + * allowedPinMode: ?PinModeRestriction, + * allowedBackgroundGraphicsMode: + * ?BackgroundGraphicsModeRestriction, + * defaultColorMode: ?ColorModeRestriction, + * defaultDuplexMode: ?DuplexModeRestriction, + * defaultPinMode: ?PinModeRestriction, + * defaultBackgroundGraphicsMode: + * ?BackgroundGraphicsModeRestriction, + * }} + */ + export let Policies;
diff --git a/chrome/browser/resources/print_preview/data/destination_store.html b/chrome/browser/resources/print_preview/data/destination_store.html deleted file mode 100644 index 9d6e7886..0000000 --- a/chrome/browser/resources/print_preview/data/destination_store.html +++ /dev/null
@@ -1,10 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="../cloud_print_interface.html"> -<link rel="import" href="../metrics.html"> -<link rel="import" href="../native_layer.html"> -<link rel="import" href="destination.html"> -<link rel="import" href="destination_match.html"> -<link rel="import" href="local_parsers.html"> - -<script src="destination_store.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/destination_store.js b/chrome/browser/resources/print_preview/data/destination_store.js index b5e767f2..3874b84 100644 --- a/chrome/browser/resources/print_preview/data/destination_store.js +++ b/chrome/browser/resources/print_preview/data/destination_store.js
@@ -2,8 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {CloudPrintInterface, CloudPrintInterfaceEventType, CloudPrintInterfaceSearchDoneDetail, CloudPrintInterfacePrinterFailedDetail, CloudPrintInterfaceProcessInviteDetail} from '../cloud_print_interface.js'; +import {Metrics, MetricsContext} from '../metrics.js'; +import {CapabilitiesResponse, LocalDestinationInfo, NativeLayer, PrinterSetupResponse, PrivetPrinterDescription, ProvisionalDestinationInfo} from '../native_layer.js'; +import {Cdd, CloudOrigins, createDestinationKey, createRecentDestinationKey, Destination, DestinationConnectionStatus, DestinationOrigin, DestinationProvisionalType, DestinationType, RecentDestination} from './destination.js'; +import {DestinationMatch, originToType, PrinterType} from './destination_match.js'; +import {parseDestination, parseExtensionDestination} from './local_parsers.js'; /** * Printer search statuses used by the destination store. @@ -19,7 +28,7 @@ * Enumeration of possible destination errors. * @enum {number} */ - const DestinationErrorType = { + export const DestinationErrorType = { INVALID: 0, UNSUPPORTED: 1, // <if expr="chromeos"> @@ -29,9 +38,9 @@ /** * Localizes printer capabilities. - * @param {!print_preview.Cdd} capabilities Printer capabilities to + * @param {!Cdd} capabilities Printer capabilities to * localize. - * @return {!print_preview.Cdd} Localized capabilities. + * @return {!Cdd} Localized capabilities. */ const localizeCapabilities = function(capabilities) { if (!capabilities.printer) { @@ -67,9 +76,9 @@ /** * Sort printer media sizes. - * @param {!print_preview.Cdd} capabilities Printer capabilities to + * @param {!Cdd} capabilities Printer capabilities to * localize. - * @return {!print_preview.Cdd} Localized capabilities. + * @return {!Cdd} Localized capabilities. * @private */ const sortMediaSizes = function(capabilities) { @@ -136,7 +145,7 @@ }; - class DestinationStore extends cr.EventTarget { + export class DestinationStore extends EventTarget { /** * A data store that stores destinations and dispatches events when the * data store changes. @@ -155,7 +164,7 @@ /** * Whether the destination store will auto select the destination that * matches this set of parameters. - * @private {print_preview.DestinationMatch} + * @private {DestinationMatch} */ this.autoSelectMatchingDestination_ = null; @@ -170,39 +179,39 @@ /** * Used to fetch cloud-based print destinations. - * @private {cloudprint.CloudPrintInterface} + * @private {CloudPrintInterface} */ this.cloudPrintInterface_ = null; /** * Cache used for constant lookup of destinations by key. - * @private {!Map<string, !print_preview.Destination>} + * @private {!Map<string, !Destination>} */ this.destinationMap_ = new Map(); /** * Internal backing store for the data store. - * @private {!Array<!print_preview.Destination>} + * @private {!Array<!Destination>} */ this.destinations_ = []; /** * Whether a search for destinations is in progress for each type of * printer. - * @private {!Map<!print_preview.PrinterType, + * @private {!Map<!PrinterType, * !DestinationStorePrinterSearchStatus>} */ this.destinationSearchStatus_ = new Map([ [ - print_preview.PrinterType.EXTENSION_PRINTER, + PrinterType.EXTENSION_PRINTER, DestinationStorePrinterSearchStatus.START ], [ - print_preview.PrinterType.PRIVET_PRINTER, + PrinterType.PRIVET_PRINTER, DestinationStorePrinterSearchStatus.START ], [ - print_preview.PrinterType.LOCAL_PRINTER, + PrinterType.LOCAL_PRINTER, DestinationStorePrinterSearchStatus.START ], ]); @@ -213,21 +222,21 @@ /** * Maps user account to the list of origins for which destinations are * already loaded. - * @private {!Map<string, !Array<!print_preview.DestinationOrigin>>} + * @private {!Map<string, !Array<!DestinationOrigin>>} */ this.loadedCloudOrigins_ = new Map(); /** * Used to track metrics. - * @private {!print_preview.MetricsContext} + * @private {!MetricsContext} */ - this.metrics_ = print_preview.MetricsContext.destinationSearch(); + this.metrics_ = MetricsContext.destinationSearch(); /** * Used to fetch local print destinations. - * @private {!print_preview.NativeLayer} + * @private {!NativeLayer} */ - this.nativeLayer_ = print_preview.NativeLayer.getInstance(); + this.nativeLayer_ = NativeLayer.getInstance(); /** * Whether PDF printer is enabled. It's disabled, for example, in App @@ -239,15 +248,15 @@ /** * Local destinations are CROS destinations on ChromeOS because they * require extra setup. - * @private {!print_preview.DestinationOrigin} + * @private {!DestinationOrigin} */ - this.platformOrigin_ = cr.isChromeOS ? - print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL; + this.platformOrigin_ = isChromeOS ? + DestinationOrigin.CROS : + DestinationOrigin.LOCAL; /** * Currently selected destination. - * @private {print_preview.Destination} + * @private {Destination} */ this.selectedDestination_ = null; @@ -284,7 +293,7 @@ /** * @param {?string=} opt_account Account to filter destinations by. When * null or omitted, all destinations are returned. - * @return {!Array<!print_preview.Destination>} List of destinations + * @return {!Array<!Destination>} List of destinations * accessible by the {@code account}. */ destinations(opt_account) { @@ -311,7 +320,7 @@ } /** - * @return {print_preview.Destination} The currently selected destination or + * @return {Destination} The currently selected destination or * {@code null} if none is selected. */ get selectedDestination() { @@ -319,8 +328,8 @@ } /** - * @param {(?print_preview.Destination | - * ?print_preview.RecentDestination)} destination + * @param {(?Destination | + * ?RecentDestination)} destination * @return {boolean} Whether the destination is valid. * @private */ @@ -338,7 +347,7 @@ * destination. * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized * default destination selection rules. - * @param {!Array<!print_preview.RecentDestination>} + * @param {!Array<!RecentDestination>} * recentDestinations The recent print destinations. */ init( @@ -358,7 +367,7 @@ // select or try to fetch it and return. for (const destination of recentDestinations) { const candidate = this.destinationMap_.get( - print_preview.createRecentDestinationKey(destination)); + createRecentDestinationKey(destination)); if (candidate) { this.selectDestination(candidate); return; @@ -399,8 +408,8 @@ const serializedSystemDefault = { id: this.systemDefaultDestinationId_, origin: this.systemDefaultDestinationId_ == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? - print_preview.DestinationOrigin.LOCAL : + Destination.GooglePromotedId.SAVE_AS_PDF ? + DestinationOrigin.LOCAL : this.platformOrigin_, account: '', capabilities: null, @@ -410,7 +419,7 @@ }; const systemDefaultCandidate = this.destinationMap_.get( - print_preview.createRecentDestinationKey(serializedSystemDefault)); + createRecentDestinationKey(serializedSystemDefault)); if (systemDefaultCandidate) { this.selectDestination(systemDefaultCandidate); return true; @@ -427,13 +436,13 @@ /** * Attempts to fetch capabilities of the destination identified by * |serializedDestination|. - * @param {!print_preview.RecentDestination} serializedDestination + * @param {!RecentDestination} serializedDestination * @return {boolean} Whether capabilities fetch was successfully started. * @private */ fetchPreselectedDestination_(serializedDestination) { const key = - print_preview.createRecentDestinationKey(serializedDestination); + createRecentDestinationKey(serializedDestination); if (this.inFlightCloudPrintRequests_.has(key)) { // Don't send another request if we are already fetching this // destination. @@ -446,15 +455,15 @@ this.createExactDestinationMatch_(origin, id); let error = false; - const type = print_preview.originToType(origin); + const type = originToType(origin); switch (type) { - case print_preview.PrinterType.LOCAL_PRINTER: + case PrinterType.LOCAL_PRINTER: this.nativeLayer_.getPrinterCapabilities(id, type).then( this.onCapabilitiesSet_.bind(this, origin, id), this.onGetCapabilitiesFail_.bind(this, origin, id)); break; - case print_preview.PrinterType.PRIVET_PRINTER: - case print_preview.PrinterType.EXTENSION_PRINTER: + case PrinterType.PRIVET_PRINTER: + case PrinterType.EXTENSION_PRINTER: // TODO(noamsml): Resolve a specific printer instead of listing all // privet or extension printers in this case. this.startLoadDestinations_(type); @@ -463,16 +472,16 @@ // destination store. When the real destination is created, this // destination will be overwritten. const params = - (origin === print_preview.DestinationOrigin.PRIVET) ? {} : { + (origin === DestinationOrigin.PRIVET) ? {} : { description: '', extensionId: serializedDestination.extensionId, extensionName: serializedDestination.extensionName, - provisionalType: print_preview.DestinationProvisionalType.NONE + provisionalType: DestinationProvisionalType.NONE }; - this.selectedDestination_ = new print_preview.Destination( - id, print_preview.DestinationType.LOCAL, origin, + this.selectedDestination_ = new Destination( + id, DestinationType.LOCAL, origin, serializedDestination.displayName, - print_preview.DestinationConnectionStatus.ONLINE, params); + DestinationConnectionStatus.ONLINE, params); if (serializedDestination.capabilities) { this.selectedDestination_.capabilities = @@ -482,7 +491,7 @@ .SELECTED_DESTINATION_CAPABILITIES_READY)); } break; - case print_preview.PrinterType.CLOUD_PRINTER: + case PrinterType.CLOUD_PRINTER: if (this.cloudPrintInterface_) { this.inFlightCloudPrintRequests_.add(key); this.cloudPrintInterface_.printer( @@ -505,17 +514,17 @@ /** * Attempts to find a destination matching the provided rules. - * @param {!print_preview.DestinationMatch} destinationMatch Rules to match. + * @param {!DestinationMatch} destinationMatch Rules to match. * @private */ fetchMatchingDestination_(destinationMatch) { this.autoSelectMatchingDestination_ = destinationMatch; const types = destinationMatch.getTypes(); types.forEach(type => { - if (type != print_preview.PrinterType.CLOUD_PRINTER) { + if (type != PrinterType.CLOUD_PRINTER) { // Local, extension, or privet printer this.startLoadDestinations_(type); - } else if (print_preview.CloudOrigins.some(origin => { + } else if (CloudOrigins.some(origin => { return destinationMatch.matchOrigin(origin); })) { this.startLoadCloudDestinations(); @@ -526,7 +535,7 @@ /** * @param {?string} serializedDefaultDestinationSelectionRulesStr Serialized * default destination selection rules. - * @return {?print_preview.DestinationMatch} Creates rules matching + * @return {?DestinationMatch} Creates rules matching * previously selected destination. * @private */ @@ -553,13 +562,13 @@ const origins = []; if (isLocal) { - origins.push(print_preview.DestinationOrigin.LOCAL); - origins.push(print_preview.DestinationOrigin.PRIVET); - origins.push(print_preview.DestinationOrigin.EXTENSION); - origins.push(print_preview.DestinationOrigin.CROS); + origins.push(DestinationOrigin.LOCAL); + origins.push(DestinationOrigin.PRIVET); + origins.push(DestinationOrigin.EXTENSION); + origins.push(DestinationOrigin.CROS); } if (isCloud) { - origins.push(...print_preview.CloudOrigins); + origins.push(...CloudOrigins); } let idRegExp = null; @@ -580,13 +589,13 @@ console.error('Failed to parse regexp for "name": ' + e); } - return new print_preview.DestinationMatch( + return new DestinationMatch( origins, idRegExp, displayNameRegExp, true /*skipVirtualDestinations*/); } /** - * @return {print_preview.DestinationMatch} Creates rules matching + * @return {DestinationMatch} Creates rules matching * previously selected destination. * @private */ @@ -603,15 +612,15 @@ } /** - * @param {string | print_preview.DestinationOrigin} origin Destination + * @param {string | DestinationOrigin} origin Destination * origin. * @param {string} id Destination id. - * @return {!print_preview.DestinationMatch} Creates rules matching + * @return {!DestinationMatch} Creates rules matching * provided destination. * @private */ createExactDestinationMatch_(origin, id) { - return new print_preview.DestinationMatch( + return new DestinationMatch( [origin], new RegExp('^' + id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '$'), null /*displayNameRegExp*/, false /*skipVirtualDestinations*/); @@ -627,14 +636,14 @@ /** * Sets the destination store's Google Cloud Print interface. - * @param {!cloudprint.CloudPrintInterface} cloudPrintInterface Interface + * @param {!CloudPrintInterface} cloudPrintInterface Interface * to set. */ setCloudPrintInterface(cloudPrintInterface) { assert(this.cloudPrintInterface_ == null); this.cloudPrintInterface_ = cloudPrintInterface; - [cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE, - cloudprint.CloudPrintInterfaceEventType.SEARCH_FAILED, + [CloudPrintInterfaceEventType.SEARCH_DONE, + CloudPrintInterfaceEventType.SEARCH_FAILED, ].forEach(eventName => { this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), eventName, @@ -642,20 +651,20 @@ }); this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.PRINTER_DONE, + CloudPrintInterfaceEventType.PRINTER_DONE, this.onCloudPrintPrinterDone_.bind(this)); this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.PRINTER_FAILED, + CloudPrintInterfaceEventType.PRINTER_FAILED, this.onCloudPrintPrinterFailed_.bind(this)); this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, + CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, this.onCloudPrintProcessInviteDone_.bind(this)); } /** - * @param {print_preview.Destination} destination Destination to select. + * @param {Destination} destination Destination to select. */ selectDestination(destination) { this.autoSelectMatchingDestination_ = null; @@ -687,9 +696,9 @@ otherDestination != destination; })) { this.metrics_.record( - destination.isPrivet ? print_preview.Metrics.DestinationSearchBucket + destination.isPrivet ? Metrics.DestinationSearchBucket .PRIVET_DUPLICATE_SELECTED : - print_preview.Metrics.DestinationSearchBucket + Metrics.DestinationSearchBucket .CLOUD_DUPLICATE_SELECTED); } // Notify about selected destination change. @@ -698,8 +707,8 @@ // Request destination capabilities from backend, since they are not // known yet. if (destination.capabilities == null) { - const type = print_preview.originToType(destination.origin); - if (type !== print_preview.PrinterType.CLOUD_PRINTER) { + const type = originToType(destination.origin); + if (type !== PrinterType.CLOUD_PRINTER) { this.nativeLayer_.getPrinterCapabilities(destination.id, type) .then( (caps) => this.onCapabilitiesSet_( @@ -721,25 +730,25 @@ // <if expr="chromeos"> /** * Attempt to resolve the capabilities for a Chrome OS printer. - * @param {!print_preview.Destination} destination The destination which + * @param {!Destination} destination The destination which * requires resolution. - * @return {!Promise<!print_preview.PrinterSetupResponse>} + * @return {!Promise<!PrinterSetupResponse>} */ resolveCrosDestination(destination) { - assert(destination.origin == print_preview.DestinationOrigin.CROS); + assert(destination.origin == DestinationOrigin.CROS); return this.nativeLayer_.setupPrinter(destination.id); } /** * Attempts to resolve a provisional destination. - * @param {!print_preview.Destination} destination Provisional destination + * @param {!Destination} destination Provisional destination * that should be resolved. - * @return {!Promise<?print_preview.Destination>} + * @return {!Promise<?Destination>} */ resolveProvisionalDestination(destination) { assert( destination.provisionalType == - print_preview.DestinationProvisionalType.NEEDS_USB_PERMISSION, + DestinationProvisionalType.NEEDS_USB_PERMISSION, 'Provisional type cannot be resolved.'); return this.nativeLayer_.grantExtensionPrinterAccess(destination.id) .then( @@ -751,7 +760,7 @@ */ this.removeProvisionalDestination_(destination.id); const parsedDestination = - print_preview.parseExtensionDestination(destinationInfo); + parseExtensionDestination(destinationInfo); this.insertIntoStore_(parsedDestination); return parsedDestination; }, @@ -775,9 +784,9 @@ selectFinalFallbackDestination_() { // Save as PDF should always exist if it is enabled. if (this.pdfPrinterEnabled_) { - const saveToPdfKey = print_preview.createDestinationKey( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, - print_preview.DestinationOrigin.LOCAL, ''); + const saveToPdfKey = createDestinationKey( + Destination.GooglePromotedId.SAVE_AS_PDF, + DestinationOrigin.LOCAL, ''); this.selectDestination(assert(this.destinationMap_.get(saveToPdfKey))); return; } @@ -814,7 +823,7 @@ /** * Initiates loading of destinations. - * @param {!print_preview.PrinterType} type The type of destinations to + * @param {!PrinterType} type The type of destinations to * load. * @private */ @@ -829,7 +838,7 @@ this.onDestinationSearchDone_.bind(this, type), () => { // Will be rejected by C++ for privet printers if privet printing // is disabled. - assert(type === print_preview.PrinterType.PRIVET_PRINTER); + assert(type === PrinterType.PRIVET_PRINTER); this.destinationSearchStatus_.set( type, DestinationStorePrinterSearchStatus.DONE); }); @@ -841,12 +850,12 @@ */ reloadUserCookieBasedDestinations(account) { const origins = this.loadedCloudOrigins_.get(account) || []; - if (origins.includes(print_preview.DestinationOrigin.COOKIES)) { + if (origins.includes(DestinationOrigin.COOKIES)) { this.dispatchEvent(new CustomEvent( DestinationStore.EventType.DESTINATION_SEARCH_DONE)); } else { this.startLoadCloudDestinations( - print_preview.DestinationOrigin.COOKIES); + DestinationOrigin.COOKIES); } } @@ -854,9 +863,9 @@ startLoadAllDestinations() { // Printer types that need to be retrieved from the handler. const types = [ - print_preview.PrinterType.PRIVET_PRINTER, - print_preview.PrinterType.EXTENSION_PRINTER, - print_preview.PrinterType.LOCAL_PRINTER, + PrinterType.PRIVET_PRINTER, + PrinterType.EXTENSION_PRINTER, + PrinterType.LOCAL_PRINTER, ]; // If the cloud printer handler is enabled, request cloud printers from @@ -865,9 +874,9 @@ if (loadTimeData.getBoolean('cloudPrinterHandlerEnabled')) { // Add cloud printer to the map. this.destinationSearchStatus_.set( - print_preview.PrinterType.CLOUD_PRINTER, + PrinterType.CLOUD_PRINTER, DestinationStorePrinterSearchStatus.START); - types.push(print_preview.PrinterType.CLOUD_PRINTER); + types.push(PrinterType.CLOUD_PRINTER); } else { this.startLoadCloudDestinations(); } @@ -879,7 +888,7 @@ /** * Initiates loading of cloud destinations. - * @param {print_preview.DestinationOrigin=} opt_origin Search destinations + * @param {DestinationOrigin=} opt_origin Search destinations * for the specified origin only. */ startLoadCloudDestinations(opt_origin) { @@ -897,7 +906,7 @@ * If a destination with key |key| is already in the store, selects it. * Otherwise, fetches the recent destination with key matching |key|. * @param {string} key - * @param {!Array<!print_preview.RecentDestination>} recentDestinations + * @param {!Array<!RecentDestination>} recentDestinations * @return {boolean} Whether the destination was selected or fetch was * started successfully. */ @@ -909,7 +918,7 @@ } const recent = recentDestinations.find(d => { - return print_preview.createRecentDestinationKey(d) === key; + return createRecentDestinationKey(d) === key; }); if (recent) { return this.fetchPreselectedDestination_(recent); @@ -924,12 +933,12 @@ * @return {boolean} */ startLoadGoogleDrive() { - const driveKey = print_preview.createDestinationKey( - print_preview.Destination.GooglePromotedId.DOCS, - print_preview.DestinationOrigin.COOKIES, this.activeUser_); + const driveKey = createDestinationKey( + Destination.GooglePromotedId.DOCS, + DestinationOrigin.COOKIES, this.activeUser_); return this.fetchPreselectedDestination_({ - id: print_preview.Destination.GooglePromotedId.DOCS, - origin: print_preview.DestinationOrigin.COOKIES, + id: Destination.GooglePromotedId.DOCS, + origin: DestinationOrigin.COOKIES, account: this.activeUser_, capabilities: null, displayName: '', @@ -960,7 +969,7 @@ /** * Inserts {@code destination} to the data store and dispatches a * DESTINATIONS_INSERTED event. - * @param {!print_preview.Destination} destination Print destination to + * @param {!Destination} destination Print destination to * insert. * @private */ @@ -973,8 +982,8 @@ /** * Inserts multiple {@code destinations} to the data store and dispatches * single DESTINATIONS_INSERTED event. - * @param {!Array<!print_preview.Destination | - * !Array<print_preview.Destination>>} destinations Print + * @param {!Array<!Destination | + * !Array<Destination>>} destinations Print * destinations to insert. * @private */ @@ -999,7 +1008,7 @@ * Dispatches DESTINATIONS_INSERTED event. In auto select mode, tries to * update selected destination to match * {@code autoSelectMatchingDestination_}. - * @param {print_preview.Destination=} opt_destination The only destination + * @param {Destination=} opt_destination The only destination * that was changed or skipped if possibly more than one destination was * changed. Used as a hint to limit destination search scope against * {@code autoSelectMatchingDestination_}. @@ -1028,7 +1037,7 @@ if (this.selectedDestination_.shouldShowInvalidCertificateError) { this.dispatchEvent(new CustomEvent( DestinationStore.EventType.ERROR, - {detail: print_preview.DestinationErrorType.UNSUPPORTED})); + {detail: DestinationErrorType.UNSUPPORTED})); } else { this.dispatchEvent( new CustomEvent(DestinationStore.EventType @@ -1039,15 +1048,15 @@ /** * Updates an existing print destination with capabilities and display name * information. If the destination doesn't already exist, it will be added. - * @param {!print_preview.Destination} destination Destination to update. + * @param {!Destination} destination Destination to update. * @private */ updateDestination_(destination) { assert(destination.constructor !== Array, 'Single printer expected'); destination.capabilities = localizeCapabilities(assert(destination.capabilities)); - if (print_preview.originToType(destination.origin) !== - print_preview.PrinterType.LOCAL_PRINTER) { + if (originToType(destination.origin) !== + PrinterType.LOCAL_PRINTER) { destination.capabilities = sortMediaSizes(destination.capabilities); } const existingDestination = this.destinationMap_.get(destination.key); @@ -1073,7 +1082,7 @@ // been found among reported extension destinations. if (this.autoSelectMatchingDestination_ && this.autoSelectMatchingDestination_.matchOrigin( - print_preview.DestinationOrigin.EXTENSION) && + DestinationOrigin.EXTENSION) && this.selectedDestination_ && this.selectedDestination_.isExtension) { this.selectDefaultDestination(); } @@ -1081,7 +1090,7 @@ /** * Inserts a destination into the store without dispatching any events. - * @param {!print_preview.Destination} destination The destination to be + * @param {!Destination} destination The destination to be * inserted. * @return {boolean} Whether the inserted destination was not already in the * store. @@ -1096,9 +1105,9 @@ return true; } if (existingDestination.connectionStatus == - print_preview.DestinationConnectionStatus.UNKNOWN && + DestinationConnectionStatus.UNKNOWN && destination.connectionStatus != - print_preview.DestinationConnectionStatus.UNKNOWN) { + DestinationConnectionStatus.UNKNOWN) { existingDestination.connectionStatus = destination.connectionStatus; return true; } @@ -1113,12 +1122,12 @@ // TODO(alekseys): Create PDF printer in the native code and send its // capabilities back with other local printers. if (this.pdfPrinterEnabled_) { - this.insertDestination_(new print_preview.Destination( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, - print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, + this.insertDestination_(new Destination( + Destination.GooglePromotedId.SAVE_AS_PDF, + DestinationType.LOCAL, + DestinationOrigin.LOCAL, loadTimeData.getString('printToPDF'), - print_preview.DestinationConnectionStatus.ONLINE)); + DestinationConnectionStatus.ONLINE)); } } @@ -1135,7 +1144,7 @@ /** * Called when destination search is complete for some type of printer. - * @param {!print_preview.PrinterType} type The type of printers that are + * @param {!PrinterType} type The type of printers that are * done being retreived. */ onDestinationSearchDone_(type) { @@ -1143,7 +1152,7 @@ type, DestinationStorePrinterSearchStatus.DONE); this.dispatchEvent( new CustomEvent(DestinationStore.EventType.DESTINATION_SEARCH_DONE)); - if (type === print_preview.PrinterType.EXTENSION_PRINTER) { + if (type === PrinterType.EXTENSION_PRINTER) { this.endExtensionPrinterSearch_(); } this.sendNoPrinterEventIfNeeded_(); @@ -1154,37 +1163,37 @@ * local destination. Updates the destination with new capabilities if the * destination already exists, otherwise it creates a new destination and * then updates its capabilities. - * @param {!print_preview.DestinationOrigin} origin The origin of the + * @param {!DestinationOrigin} origin The origin of the * print destination. * @param {string} id The id of the print destination. - * @param {!print_preview.CapabilitiesResponse} settingsInfo Contains + * @param {!CapabilitiesResponse} settingsInfo Contains * the capabilities of the print destination, and information about * the destination except in the case of extension printers. * @private */ onCapabilitiesSet_(origin, id, settingsInfo) { let dest = null; - if (origin !== print_preview.DestinationOrigin.PRIVET) { - const key = print_preview.createDestinationKey(id, origin, ''); + if (origin !== DestinationOrigin.PRIVET) { + const key = createDestinationKey(id, origin, ''); dest = this.destinationMap_.get(key); } if (!dest) { // Ignore unrecognized extension printers if (!settingsInfo.printer) { - assert(origin === print_preview.DestinationOrigin.EXTENSION); + assert(origin === DestinationOrigin.EXTENSION); return; } - dest = /** @type {!print_preview.Destination} */ ( - print_preview.parseDestination( - print_preview.originToType(origin), + dest = /** @type {!Destination} */ ( + parseDestination( + originToType(origin), assert(settingsInfo.printer))); } if (dest) { if (settingsInfo.printer && settingsInfo.printer.policies) { dest.policies = settingsInfo.printer.policies; } - if ((origin === print_preview.DestinationOrigin.LOCAL || - origin === print_preview.DestinationOrigin.CROS) && + if ((origin === DestinationOrigin.LOCAL || + origin === DestinationOrigin.CROS) && dest.capabilities) { // If capabilities are already set for this destination ignore new // results. This prevents custom margins from being cleared as long @@ -1200,7 +1209,7 @@ * Called when a request to get a local destination's print capabilities * fails. If the destination is the initial destination, auto-select another * destination instead. - * @param {print_preview.DestinationOrigin} origin The origin type of the + * @param {DestinationOrigin} origin The origin type of the * failed destination. * @param {string} destinationId The destination ID that failed. * @private @@ -1212,7 +1221,7 @@ this.selectedDestination_.id == destinationId) { this.dispatchEvent(new CustomEvent( DestinationStore.EventType.ERROR, - {detail: print_preview.DestinationErrorType.INVALID})); + {detail: DestinationErrorType.INVALID})); } if (this.autoSelectMatchingDestination_ && this.autoSelectMatchingDestination_.matchIdAndOrigin( @@ -1224,7 +1233,7 @@ /** * Called when the /search call completes, either successfully or not. * In case of success, stores fetched destinations. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceSearchDoneDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceSearchDoneDetail>} * event Contains the request result. * @private */ @@ -1267,14 +1276,14 @@ this.selectFirstDestination_ = false; this.dispatchEvent(new CustomEvent( DestinationStore.EventType.ERROR, - {detail: print_preview.DestinationErrorType.NO_DESTINATIONS})); + {detail: DestinationErrorType.NO_DESTINATIONS})); // </if> } /** * Called when /printer call completes. Updates the specified destination's * print capabilities. - * @param {!CustomEvent<!print_preview.Destination>} event Contains + * @param {!CustomEvent<!Destination>} event Contains * detailed information about the destination. * @private */ @@ -1287,12 +1296,12 @@ * Called when the Google Cloud Print interface fails to lookup a * destination. Selects another destination if the failed destination was * the initial destination. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfacePrinterFailedDetail>} + * @param {!CustomEvent<!CloudPrintInterfacePrinterFailedDetail>} * event Contains the ID of the destination that failed to be looked up. * @private */ onCloudPrintPrinterFailed_(event) { - const key = print_preview.createDestinationKey( + const key = createDestinationKey( event.detail.destinationId, event.detail.origin, this.activeUser_); this.inFlightCloudPrintRequests_.delete(key); if (this.autoSelectMatchingDestination_ && @@ -1312,7 +1321,7 @@ /** * Called when printer sharing invitation was processed successfully. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceProcessInviteDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceProcessInviteDetail>} * event Contains detailed information about the invite and newly * accepted destination (if known). * @private @@ -1326,16 +1335,16 @@ /** * Called when a printer or printers are detected after sending getPrinters * from the native layer. - * @param {!print_preview.PrinterType} type The type of printer(s) added. - * @param {!Array<!print_preview.LocalDestinationInfo | - * !print_preview.PrivetPrinterDescription | - * !print_preview.ProvisionalDestinationInfo>} printers + * @param {!PrinterType} type The type of printer(s) added. + * @param {!Array<!LocalDestinationInfo | + * !PrivetPrinterDescription | + * !ProvisionalDestinationInfo>} printers * Information about the printers that have been retrieved. */ onPrintersAdded_(type, printers) { this.insertDestinations_(printers.map( - printer => /** @type {!print_preview.Destination} */ ( - print_preview.parseDestination(type, printer)))); + printer => /** @type {!Destination} */ ( + parseDestination(type, printer)))); if (this.selectFirstDestination_) { this.selectDestination(this.destinations_[0]); @@ -1350,12 +1359,12 @@ */ DestinationStore.EventType = { DESTINATION_SEARCH_DONE: - 'print_preview.DestinationStore.DESTINATION_SEARCH_DONE', - DESTINATION_SELECT: 'print_preview.DestinationStore.DESTINATION_SELECT', + 'DestinationStore.DESTINATION_SEARCH_DONE', + DESTINATION_SELECT: 'DestinationStore.DESTINATION_SELECT', DESTINATIONS_INSERTED: - 'print_preview.DestinationStore.DESTINATIONS_INSERTED', - ERROR: 'print_preview.DestinationStore.ERROR', - SELECTED_DESTINATION_CAPABILITIES_READY: 'print_preview.DestinationStore' + + 'DestinationStore.DESTINATIONS_INSERTED', + ERROR: 'DestinationStore.ERROR', + SELECTED_DESTINATION_CAPABILITIES_READY: 'DestinationStore' + '.SELECTED_DESTINATION_CAPABILITIES_READY', }; @@ -1550,9 +1559,3 @@ 'ROC_8K': 'ROC 8k', }; - // Export - return { - DestinationErrorType: DestinationErrorType, - DestinationStore: DestinationStore, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/document_info.html b/chrome/browser/resources/print_preview/data/document_info.html deleted file mode 100644 index 59729c4..0000000 --- a/chrome/browser/resources/print_preview/data/document_info.html +++ /dev/null
@@ -1,10 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="coordinate2d.html"> -<link rel="import" href="margins.html"> -<link rel="import" href="printable_area.html"> -<link rel="import" href="size.html"> - -<script src="document_info.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/document_info.js b/chrome/browser/resources/print_preview/data/document_info.js index e5e56a1..0d26e71 100644 --- a/chrome/browser/resources/print_preview/data/document_info.js +++ b/chrome/browser/resources/print_preview/data/document_info.js
@@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {Coordinate2d} from './coordinate2d.js'; +import {CustomMarginsOrientation, Margins} from './margins.js'; +import {PrintableArea} from './printable_area.js'; +import {Size} from './size.js'; /** * @typedef {{ @@ -17,7 +22,7 @@ * title: string, * }} */ -print_preview.DocumentSettings; +export let DocumentSettings; /** * @typedef {{ @@ -33,7 +38,7 @@ * printableAreaHeight: number, * }} */ -print_preview.PageLayoutInfo; +export let PageLayoutInfo; Polymer({ is: 'print-preview-document-info', @@ -41,7 +46,7 @@ behaviors: [WebUIListenerBehavior], properties: { - /** @type {!print_preview.DocumentSettings} */ + /** @type {!DocumentSettings} */ documentSettings: { type: Object, notify: true, @@ -65,7 +70,7 @@ value: -1, }, - /** @type {print_preview.Margins} */ + /** @type {Margins} */ margins: { type: Object, notify: true, @@ -75,27 +80,27 @@ * Size of the pages of the document in points. Actual page-related * information won't be set until preview generation occurs, so use * a default value until then. - * @type {!print_preview.Size} + * @type {!Size} */ pageSize: { type: Object, notify: true, value: function() { - return new print_preview.Size(612, 792); + return new Size(612, 792); }, }, /** * Printable area of the document in points. - * @type {!print_preview.PrintableArea} + * @type {!PrintableArea} */ printableArea: { type: Object, notify: true, value: function() { - return new print_preview.PrintableArea( - new print_preview.Coordinate2d(0, 0), - new print_preview.Size(612, 792)); + return new PrintableArea( + new Coordinate2d(0, 0), + new Size(612, 792)); }, }, }, @@ -147,29 +152,29 @@ /** * Called when the page layout of the document is ready. Always occurs * as a result of a preview request. - * @param {!print_preview.PageLayoutInfo} pageLayout Layout information + * @param {!PageLayoutInfo} pageLayout Layout information * about the document. * @param {boolean} hasCustomPageSizeStyle Whether this document has a * custom page size or style to use. * @private */ onPageLayoutReady_: function(pageLayout, hasCustomPageSizeStyle) { - const origin = new print_preview.Coordinate2d( + const origin = new Coordinate2d( pageLayout.printableAreaX, pageLayout.printableAreaY); - const size = new print_preview.Size( + const size = new Size( pageLayout.printableAreaWidth, pageLayout.printableAreaHeight); - const margins = new print_preview.Margins( + const margins = new Margins( Math.round(pageLayout.marginTop), Math.round(pageLayout.marginRight), Math.round(pageLayout.marginBottom), Math.round(pageLayout.marginLeft)); - const o = print_preview.CustomMarginsOrientation; - const pageSize = new print_preview.Size( + const o = CustomMarginsOrientation; + const pageSize = new Size( pageLayout.contentWidth + margins.get(o.LEFT) + margins.get(o.RIGHT), pageLayout.contentHeight + margins.get(o.TOP) + margins.get(o.BOTTOM)); if (this.isInitialized_) { - this.printableArea = new print_preview.PrintableArea(origin, size); + this.printableArea = new PrintableArea(origin, size); this.pageSize = pageSize; this.set('documentSettings.hasCssMediaStyles', hasCustomPageSizeStyle); this.margins = margins;
diff --git a/chrome/browser/resources/print_preview/data/invitation.html b/chrome/browser/resources/print_preview/data/invitation.html deleted file mode 100644 index 0a72be7..0000000 --- a/chrome/browser/resources/print_preview/data/invitation.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="destination.html"> - -<script src="invitation.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/invitation.js b/chrome/browser/resources/print_preview/data/invitation.js index 6f5d09d..0849e1a 100644 --- a/chrome/browser/resources/print_preview/data/invitation.js +++ b/chrome/browser/resources/print_preview/data/invitation.js
@@ -2,17 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {Destination} from './destination.js'; - class Invitation { + export class Invitation { /** * Printer sharing invitation data object. * @param {string} sender Text identifying invitation sender. * @param {string} receiver Text identifying invitation receiver. Empty in * case of a personal invitation. Identifies a group or domain in case * of an invitation received by a group manager. - * @param {!print_preview.Destination} destination Shared destination. + * @param {!Destination} destination Shared destination. * @param {!Object} aclEntry JSON representation of the ACL entry this * invitation was sent to. * @param {string} account User account this invitation is sent for. @@ -34,7 +33,7 @@ /** * Shared destination. - * @private {!print_preview.Destination} + * @private {!Destination} */ this.destination_ = destination; @@ -69,7 +68,7 @@ return !!this.receiver_; } - /** @return {!print_preview.Destination} Shared destination. */ + /** @return {!Destination} Shared destination. */ get destination() { return this.destination_; } @@ -85,6 +84,3 @@ } } - // Export - return {Invitation: Invitation}; -});
diff --git a/chrome/browser/resources/print_preview/data/invitation_store.html b/chrome/browser/resources/print_preview/data/invitation_store.html deleted file mode 100644 index c2dd17bd..0000000 --- a/chrome/browser/resources/print_preview/data/invitation_store.html +++ /dev/null
@@ -1,6 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr/event_target.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="invitation.html"> -<link rel="import" href="../cloud_print_interface.html"> - -<script src="invitation_store.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/invitation_store.js b/chrome/browser/resources/print_preview/data/invitation_store.js index 253e442..92001a4 100644 --- a/chrome/browser/resources/print_preview/data/invitation_store.js +++ b/chrome/browser/resources/print_preview/data/invitation_store.js
@@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {Invitation} from './invitation.js'; +import {CloudPrintInterface, CloudPrintInterfaceEventType, CloudPrintInterfaceInvitesDoneDetail, CloudPrintInterfaceProcessInviteDetail } from '../cloud_print_interface.js'; /** * @enum {number} @@ -15,14 +18,14 @@ FAILED: 3, }; - class InvitationStore extends cr.EventTarget { + export class InvitationStore extends EventTarget { /** Printer sharing invitations data store. */ constructor() { super(); /** * Maps user account to the list of invitations for this account. - * @private {!Object<!Array<!print_preview.Invitation>>} + * @private {!Object<!Array<!Invitation>>} */ this.invitations_ = {}; @@ -41,20 +44,20 @@ /** * Used to fetch and process invitations. - * @private {cloudprint.CloudPrintInterface} + * @private {CloudPrintInterface} */ this.cloudPrintInterface_ = null; /** * Invitation being processed now. Only one invitation can be processed at * a time. - * @private {print_preview.Invitation} + * @private {Invitation} */ this.invitationInProgress_ = null; } /** - * @return {print_preview.Invitation} Currently processed invitation or + * @return {Invitation} Currently processed invitation or * {@code null}. */ get invitationInProgress() { @@ -63,7 +66,7 @@ /** * @param {string} account Account to filter invitations by. - * @return {!Array<!print_preview.Invitation>} List of invitations for the + * @return {!Array<!Invitation>} List of invitations for the * {@code account}. */ invitations(account) { @@ -72,7 +75,7 @@ /** * Sets the invitation store's Google Cloud Print interface. - * @param {!cloudprint.CloudPrintInterface} cloudPrintInterface Interface + * @param {!CloudPrintInterface} cloudPrintInterface Interface * to set. */ setCloudPrintInterface(cloudPrintInterface) { @@ -80,15 +83,15 @@ this.cloudPrintInterface_ = cloudPrintInterface; this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.INVITES_DONE, + CloudPrintInterfaceEventType.INVITES_DONE, this.onCloudPrintInvitesDone_.bind(this)); this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.INVITES_FAILED, + CloudPrintInterfaceEventType.INVITES_FAILED, this.onCloudPrintInvitesFailed_.bind(this)); this.tracker_.add( this.cloudPrintInterface_.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, + CloudPrintInterfaceEventType.PROCESS_INVITE_DONE, this.onCloudPrintProcessInviteDone_.bind(this)); } @@ -120,7 +123,7 @@ /** * Accepts or rejects the {@code invitation}, based on {@code accept} value. - * @param {!print_preview.Invitation} invitation Invitation to process. + * @param {!Invitation} invitation Invitation to process. * @param {boolean} accept Whether to accept this invitation. */ processInvitation(invitation, accept) { @@ -133,7 +136,7 @@ /** * Removes processed invitation from the internal storage. - * @param {!print_preview.Invitation} invitation Processed invitation. + * @param {!Invitation} invitation Processed invitation. * @private */ invitationProcessed_(invitation) { @@ -150,7 +153,7 @@ /** * Called when printer sharing invitations are fetched. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceInvitesDoneDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceInvitesDoneDetail>} * event Contains the list of invitations. * @private */ @@ -174,7 +177,7 @@ /** * Called when printer sharing invitation was processed successfully. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceProcessInviteDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceProcessInviteDetail>} * event Contains detailed information about the invite. * @private */ @@ -190,11 +193,8 @@ * @enum {string} */ InvitationStore.EventType = { - INVITATION_PROCESSED: 'print_preview.InvitationStore.INVITATION_PROCESSED', + INVITATION_PROCESSED: 'InvitationStore.INVITATION_PROCESSED', INVITATION_SEARCH_DONE: - 'print_preview.InvitationStore.INVITATION_SEARCH_DONE' + 'InvitationStore.INVITATION_SEARCH_DONE' }; - // Export - return {InvitationStore: InvitationStore}; -});
diff --git a/chrome/browser/resources/print_preview/data/local_parsers.html b/chrome/browser/resources/print_preview/data/local_parsers.html deleted file mode 100644 index fed4e851..0000000 --- a/chrome/browser/resources/print_preview/data/local_parsers.html +++ /dev/null
@@ -1,6 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="../native_layer.html"> -<link rel="import" href="destination.html"> -<link rel="import" href="destination_match.html"> - -<script src="local_parsers.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/local_parsers.js b/chrome/browser/resources/print_preview/data/local_parsers.js index 9716c128..1e292f1 100644 --- a/chrome/browser/resources/print_preview/data/local_parsers.js +++ b/chrome/browser/resources/print_preview/data/local_parsers.js
@@ -2,33 +2,36 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assertNotReached} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {LocalDestinationInfo, PrivetPrinterDescription, ProvisionalDestinationInfo} from '../native_layer.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationProvisionalType, DestinationType} from './destination.js'; +import {PrinterType} from './destination_match.js'; /** - * @param{!print_preview.PrinterType} type The type of printer to parse. - * @param{!print_preview.LocalDestinationInfo | - * !print_preview.PrivetPrinterDescription | - * !print_preview.ProvisionalDestinationInfo} printer Information + * @param{!PrinterType} type The type of printer to parse. + * @param{!LocalDestinationInfo | + * !PrivetPrinterDescription | + * !ProvisionalDestinationInfo} printer Information * about the printer. Type expected depends on |type|: - * For LOCAL_PRINTER => print_preview.LocalDestinationInfo - * For PRIVET_PRINTER => print_preview.PrivetPrinterDescription - * For EXTENSION_PRINTER => print_preview.ProvisionalDestinationInfo - * @return {?print_preview.Destination} Only returns null if an invalid value + * For LOCAL_PRINTER => LocalDestinationInfo + * For PRIVET_PRINTER => PrivetPrinterDescription + * For EXTENSION_PRINTER => ProvisionalDestinationInfo + * @return {?Destination} Only returns null if an invalid value * is provided for |type|. */ - function parseDestination(type, printer) { - if (type === print_preview.PrinterType.LOCAL_PRINTER) { + export function parseDestination(type, printer) { + if (type === PrinterType.LOCAL_PRINTER) { return parseLocalDestination( - /** @type {!print_preview.LocalDestinationInfo} */ (printer)); + /** @type {!LocalDestinationInfo} */ (printer)); } - if (type === print_preview.PrinterType.PRIVET_PRINTER) { + if (type === PrinterType.PRIVET_PRINTER) { return parsePrivetDestination( - /** @type {!print_preview.PrivetPrinterDescription} */ (printer)); + /** @type {!PrivetPrinterDescription} */ (printer)); } - if (type === print_preview.PrinterType.EXTENSION_PRINTER) { + if (type === PrinterType.EXTENSION_PRINTER) { return parseExtensionDestination( - /** @type {!print_preview.ProvisionalDestinationInfo} */ (printer)); + /** @type {!ProvisionalDestinationInfo} */ (printer)); } assertNotReached('Unknown printer type ' + type); return null; @@ -36,9 +39,9 @@ /** * Parses a local print destination. - * @param {!print_preview.LocalDestinationInfo} destinationInfo Information + * @param {!LocalDestinationInfo} destinationInfo Information * describing a local print destination. - * @return {!print_preview.Destination} Parsed local print destination. + * @return {!Destination} Parsed local print destination. */ function parseLocalDestination(destinationInfo) { const options = { @@ -53,44 +56,44 @@ return '__cp__' + key + '=' + this[key]; }, destinationInfo.printerOptions); } - return new print_preview.Destination( - destinationInfo.deviceName, print_preview.DestinationType.LOCAL, - cr.isChromeOS ? print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL, + return new Destination( + destinationInfo.deviceName, DestinationType.LOCAL, + isChromeOS ? DestinationOrigin.CROS : + DestinationOrigin.LOCAL, destinationInfo.printerName, - print_preview.DestinationConnectionStatus.ONLINE, options); + DestinationConnectionStatus.ONLINE, options); } /** * Parses a privet destination as a local printer. - * @param {!print_preview.PrivetPrinterDescription} destinationInfo Object + * @param {!PrivetPrinterDescription} destinationInfo Object * that describes a privet printer. - * @return {!print_preview.Destination} Parsed destination info. + * @return {!Destination} Parsed destination info. */ function parsePrivetDestination(destinationInfo) { - return new print_preview.Destination( - destinationInfo.serviceName, print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.PRIVET, destinationInfo.name, - print_preview.DestinationConnectionStatus.ONLINE, + return new Destination( + destinationInfo.serviceName, DestinationType.LOCAL, + DestinationOrigin.PRIVET, destinationInfo.name, + DestinationConnectionStatus.ONLINE, {cloudID: destinationInfo.cloudID}); } /** * Parses an extension destination from an extension supplied printer * description. - * @param {!print_preview.ProvisionalDestinationInfo} destinationInfo Object + * @param {!ProvisionalDestinationInfo} destinationInfo Object * describing an extension printer. - * @return {!print_preview.Destination} Parsed destination. + * @return {!Destination} Parsed destination. */ - function parseExtensionDestination(destinationInfo) { + export function parseExtensionDestination(destinationInfo) { const provisionalType = destinationInfo.provisional ? - print_preview.DestinationProvisionalType.NEEDS_USB_PERMISSION : - print_preview.DestinationProvisionalType.NONE; + DestinationProvisionalType.NEEDS_USB_PERMISSION : + DestinationProvisionalType.NONE; - return new print_preview.Destination( - destinationInfo.id, print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.EXTENSION, destinationInfo.name, - print_preview.DestinationConnectionStatus.ONLINE, { + return new Destination( + destinationInfo.id, DestinationType.LOCAL, + DestinationOrigin.EXTENSION, destinationInfo.name, + DestinationConnectionStatus.ONLINE, { description: destinationInfo.description || '', extensionId: destinationInfo.extensionId, extensionName: destinationInfo.extensionName || '', @@ -98,9 +101,3 @@ }); } - // Export - return { - parseDestination: parseDestination, - parseExtensionDestination: parseExtensionDestination - }; -});
diff --git a/chrome/browser/resources/print_preview/data/margins.html b/chrome/browser/resources/print_preview/data/margins.html deleted file mode 100644 index 6f429ae..0000000 --- a/chrome/browser/resources/print_preview/data/margins.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="margins.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/margins.js b/chrome/browser/resources/print_preview/data/margins.js index ce38eb6..776ef95 100644 --- a/chrome/browser/resources/print_preview/data/margins.js +++ b/chrome/browser/resources/print_preview/data/margins.js
@@ -2,14 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; - /** * Enumeration of the orientations of margins. * @enum {string} */ - const CustomMarginsOrientation = { + export const CustomMarginsOrientation = { TOP: 'top', RIGHT: 'right', BOTTOM: 'bottom', @@ -21,22 +18,13 @@ * printing/print_job_constants.h. * @enum {number} */ - const MarginsType = { + export const MarginsType = { DEFAULT: 0, NO_MARGINS: 1, MINIMUM: 2, CUSTOM: 3, }; - return { - CustomMarginsOrientation: CustomMarginsOrientation, - MarginsType: MarginsType, - }; -}); - -cr.define('print_preview', function() { - 'use strict'; - /** * Keep in sync with the C++ kSettingMargin... values in * printing/print_job_constants.h. @@ -47,9 +35,9 @@ * marginLeft: number, * }} */ - let MarginsSetting; + export let MarginsSetting; - class Margins { + export class Margins { /** * Creates a Margins object that holds four margin values in points. * @param {number} top The top margin in pts. @@ -61,32 +49,32 @@ /** * Backing store for the margin values in points. * @type {!Object< - * !print_preview.CustomMarginsOrientation, number>} + * !CustomMarginsOrientation, number>} * @private */ this.value_ = {}; - this.value_[print_preview.CustomMarginsOrientation.TOP] = top; - this.value_[print_preview.CustomMarginsOrientation.RIGHT] = right; - this.value_[print_preview.CustomMarginsOrientation.BOTTOM] = bottom; - this.value_[print_preview.CustomMarginsOrientation.LEFT] = left; + this.value_[CustomMarginsOrientation.TOP] = top; + this.value_[CustomMarginsOrientation.RIGHT] = right; + this.value_[CustomMarginsOrientation.BOTTOM] = bottom; + this.value_[CustomMarginsOrientation.LEFT] = left; } /** * Parses a margins object from the given serialized state. * @param {Object} state Serialized representation of the margins created by * the {@code serialize} method. - * @return {!print_preview.Margins} New margins instance. + * @return {!Margins} New margins instance. */ static parse(state) { - return new print_preview.Margins( - state[print_preview.CustomMarginsOrientation.TOP] || 0, - state[print_preview.CustomMarginsOrientation.RIGHT] || 0, - state[print_preview.CustomMarginsOrientation.BOTTOM] || 0, - state[print_preview.CustomMarginsOrientation.LEFT] || 0); + return new Margins( + state[CustomMarginsOrientation.TOP] || 0, + state[CustomMarginsOrientation.RIGHT] || 0, + state[CustomMarginsOrientation.BOTTOM] || 0, + state[CustomMarginsOrientation.LEFT] || 0); } /** - * @param {!print_preview.CustomMarginsOrientation} + * @param {!CustomMarginsOrientation} * orientation Specifies the margin value to get. * @return {number} Value of the margin of the given orientation. */ @@ -95,24 +83,24 @@ } /** - * @param {!print_preview.CustomMarginsOrientation} + * @param {!CustomMarginsOrientation} * orientation Specifies the margin to set. * @param {number} value Updated value of the margin in points to modify. - * @return {!print_preview.Margins} A new copy of |this| with the + * @return {!Margins} A new copy of |this| with the * modification made to the specified margin. */ set(orientation, value) { const newValue = this.clone_(); newValue[orientation] = value; return new Margins( - newValue[print_preview.CustomMarginsOrientation.TOP], - newValue[print_preview.CustomMarginsOrientation.RIGHT], - newValue[print_preview.CustomMarginsOrientation.BOTTOM], - newValue[print_preview.CustomMarginsOrientation.LEFT]); + newValue[CustomMarginsOrientation.TOP], + newValue[CustomMarginsOrientation.RIGHT], + newValue[CustomMarginsOrientation.BOTTOM], + newValue[CustomMarginsOrientation.LEFT]); } /** - * @param {print_preview.Margins} other The other margins object to compare + * @param {Margins} other The other margins object to compare * against. * @return {boolean} Whether this margins object is equal to another. */ @@ -146,9 +134,3 @@ } } - // Export - return { - Margins: Margins, - MarginsSetting: MarginsSetting, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/measurement_system.html b/chrome/browser/resources/print_preview/data/measurement_system.html deleted file mode 100644 index 053e643..0000000 --- a/chrome/browser/resources/print_preview/data/measurement_system.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="measurement_system.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/measurement_system.js b/chrome/browser/resources/print_preview/data/measurement_system.js index c57e8a9..08828b6b 100644 --- a/chrome/browser/resources/print_preview/data/measurement_system.js +++ b/chrome/browser/resources/print_preview/data/measurement_system.js
@@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; /** * Enumeration of measurement unit types. * @enum {number} */ - const MeasurementSystemUnitType = { + export const MeasurementSystemUnitType = { METRIC: 0, // millimeters IMPERIAL: 1 // inches }; @@ -22,14 +21,14 @@ */ let MeasurementSystemPrefs; - class MeasurementSystem { + export class MeasurementSystem { /** * Measurement system of the print preview. Used to parse and serialize * point measurements into the system's local units (e.g. millimeters, * inches). * @param {string} thousandsDelimiter Delimiter between thousands digits. * @param {string} decimalDelimiter Delimiter between integers and decimals. - * @param {!print_preview.MeasurementSystemUnitType} unitType Measurement + * @param {!MeasurementSystemUnitType} unitType Measurement * unit type of the system. */ constructor(thousandsDelimiter, decimalDelimiter, unitType) { @@ -105,7 +104,7 @@ /** * Maximum resolution and number of decimal places for local unit values. - * @private {!Map<!print_preview.MeasurementSystemUnitType, + * @private {!Map<!MeasurementSystemUnitType, * !MeasurementSystemPrefs>} */ const measurementSystemPrefs = new Map([ @@ -123,9 +122,3 @@ ] ]); - // Export - return { - MeasurementSystem: MeasurementSystem, - MeasurementSystemUnitType: MeasurementSystemUnitType, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/model.html b/chrome/browser/resources/print_preview/data/model.html deleted file mode 100644 index 1fb0c92..0000000 --- a/chrome/browser/resources/print_preview/data/model.html +++ /dev/null
@@ -1,11 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/promise_resolver.html"> -<link rel="import" href="destination.html"> -<link rel="import" href="destination_match.html"> -<link rel="import" href="document_info.html"> -<link rel="import" href="margins.html"> -<link rel="import" href="scaling.html"> - -<script src="model.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/model.js b/chrome/browser/resources/print_preview/data/model.js index 4161986..6dc19c8a 100644 --- a/chrome/browser/resources/print_preview/data/model.js +++ b/chrome/browser/resources/print_preview/data/model.js
@@ -2,7 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isMac, isWindows} from 'chrome://resources/js/cr.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js'; +// <if expr="chromeos"> +import {BackgroundGraphicsModeRestriction, ColorModeRestriction, DuplexModeRestriction, PinModeRestriction} from './destination_policies.js'; +// </if> +import {Cdd, CddCapabilities, Destination, DestinationOrigin, DestinationType, RecentDestination} from './destination.js'; +import {getPrinterTypeForDestination} from './destination_match.js'; +import {DocumentSettings} from './document_info.js'; +import {CustomMarginsOrientation, Margins, MarginsSetting, MarginsType} from './margins.js'; +import {ScalingType} from './scaling.js'; +import {Size} from './size.js'; + /** * |key| is the field in the serialized settings state that corresponds to the * setting, or an empty string if the setting should not be saved in the @@ -18,41 +32,41 @@ * updatesPreview: boolean, * }} */ - let Setting; + export let Setting; /** * @typedef {{ - * pages: !print_preview.Setting, - * copies: !print_preview.Setting, - * collate: !print_preview.Setting, - * layout: !print_preview.Setting, - * color: !print_preview.Setting, - * mediaSize: !print_preview.Setting, - * margins: !print_preview.Setting, - * dpi: !print_preview.Setting, - * scaling: !print_preview.Setting, - * scalingType: !print_preview.Setting, - * scalingTypePdf: !print_preview.Setting, - * duplex: !print_preview.Setting, - * duplexShortEdge: !print_preview.Setting, - * cssBackground: !print_preview.Setting, - * selectionOnly: !print_preview.Setting, - * headerFooter: !print_preview.Setting, - * rasterize: !print_preview.Setting, - * vendorItems: !print_preview.Setting, - * otherOptions: !print_preview.Setting, - * ranges: !print_preview.Setting, - * pagesPerSheet: !print_preview.Setting, - * pin: (print_preview.Setting|undefined), - * pinValue: (print_preview.Setting|undefined), + * pages: !Setting, + * copies: !Setting, + * collate: !Setting, + * layout: !Setting, + * color: !Setting, + * mediaSize: !Setting, + * margins: !Setting, + * dpi: !Setting, + * scaling: !Setting, + * scalingType: !Setting, + * scalingTypePdf: !Setting, + * duplex: !Setting, + * duplexShortEdge: !Setting, + * cssBackground: !Setting, + * selectionOnly: !Setting, + * headerFooter: !Setting, + * rasterize: !Setting, + * vendorItems: !Setting, + * otherOptions: !Setting, + * ranges: !Setting, + * pagesPerSheet: !Setting, + * pin: (Setting|undefined), + * pinValue: (Setting|undefined), * }} */ - let Settings; + export let Settings; /** * @typedef {{ * version: string, - * recentDestinations: (!Array<!print_preview.RecentDestination> | + * recentDestinations: (!Array<!RecentDestination> | * undefined), * dpi: ({horizontal_dpi: number, * vertical_dpi: number, @@ -61,8 +75,8 @@ * width_microns: number, * custom_display_name: (string | undefined), * is_default: (boolean | undefined)} | undefined), - * marginsType: (print_preview.MarginsType | undefined), - * customMargins: (print_preview.MarginsSetting | undefined), + * marginsType: (MarginsType | undefined), + * customMargins: (MarginsSetting | undefined), * isColorEnabled: (boolean | undefined), * isDuplexEnabled: (boolean | undefined), * isHeaderFooterEnabled: (boolean | undefined), @@ -70,14 +84,14 @@ * isCollateEnabled: (boolean | undefined), * isCssBackgroundEnabled: (boolean | undefined), * scaling: (string | undefined), - * scalingType: (print_preview.ScalingType | undefined), - * scalingTypePdf: (print_preview.ScalingType | undefined), + * scalingType: (ScalingType | undefined), + * scalingTypePdf: (ScalingType | undefined), * vendor_options: (Object | undefined), * isPinEnabled: (boolean | undefined), * pinValue: (string | undefined) * }} */ - let SerializedSettings; + export let SerializedSettings; /** * @typedef {{ @@ -85,20 +99,20 @@ * managed: boolean * }} */ - let PolicyEntry; + export let PolicyEntry; /** * @typedef {{ - * headerFooter: print_preview.PolicyEntry + * headerFooter: PolicyEntry * }} */ - let PolicySettings; + export let PolicySettings; /** * Constant values matching printing::DuplexMode enum. * @enum {number} */ - const DuplexMode = { + export const DuplexMode = { SIMPLEX: 0, LONG_EDGE: 1, SHORT_EDGE: 2, @@ -109,44 +123,27 @@ * Values matching the types of duplex in a CDD. * @enum {string} */ - const DuplexType = { + export const DuplexType = { NO_DUPLEX: 'NO_DUPLEX', LONG_EDGE: 'LONG_EDGE', SHORT_EDGE: 'SHORT_EDGE' }; - return { - DuplexMode: DuplexMode, - DuplexType: DuplexType, - PolicyEntry: PolicyEntry, - PolicySettings: PolicySettings, - SerializedSettings: SerializedSettings, - Setting: Setting, - Settings: Settings, - }; -}); - -cr.define('print_preview.Model', () => { - return { /** @private {?PrintPreviewModelElement} */ - instance_: null, + let instance = null; /** @private {!PromiseResolver} */ - whenReady_: new PromiseResolver(), + let whenReadyResolver = new PromiseResolver(); /** @return {!PrintPreviewModelElement} */ - getInstance: () => assert(print_preview.Model.instance_), + export function getInstance() { + return assert(instance); + } /** @return {!Promise} */ - whenReady: - () => { - return print_preview.Model.whenReady_.promise; - }, - }; -}); - -(function() { -'use strict'; + export function whenReady() { + return whenReadyResolver.promise; + } /** * Sticky setting names in alphabetical order. @@ -185,6 +182,8 @@ Polymer({ is: 'print-preview-model', + _template: null, + properties: { /** * Object containing current settings of Print Preview, for use by Polymer @@ -192,7 +191,7 @@ * Initialize all settings to available so that more settings always stays * in a collapsed state during startup, when document information and * printer capabilities may arrive at slightly different times. - * @type {!print_preview.Settings} + * @type {!Settings} */ settings: { type: Object, @@ -263,8 +262,8 @@ updatesPreview: true, }, margins: { - value: print_preview.MarginsType.DEFAULT, - unavailableValue: print_preview.MarginsType.DEFAULT, + value: MarginsType.DEFAULT, + unavailableValue: MarginsType.DEFAULT, valid: true, available: true, setByPolicy: false, @@ -303,8 +302,8 @@ updatesPreview: true, }, scalingType: { - value: print_preview.ScalingType.DEFAULT, - unavailableValue: print_preview.ScalingType.DEFAULT, + value: ScalingType.DEFAULT, + unavailableValue: ScalingType.DEFAULT, valid: true, available: true, setByPolicy: false, @@ -313,8 +312,8 @@ updatesPreview: true, }, scalingTypePdf: { - value: print_preview.ScalingType.DEFAULT, - unavailableValue: print_preview.ScalingType.DEFAULT, + value: ScalingType.DEFAULT, + unavailableValue: ScalingType.DEFAULT, valid: true, available: true, setByPolicy: false, @@ -468,16 +467,16 @@ value: false, }, - /** @type {print_preview.Destination} */ + /** @type {Destination} */ destination: Object, - /** @type {!print_preview.DocumentSettings} */ + /** @type {!DocumentSettings} */ documentSettings: Object, - /** @type {print_preview.Margins} */ + /** @type {Margins} */ margins: Object, - /** @type {!print_preview.Size} */ + /** @type {!Size} */ pageSize: Object, }, @@ -495,34 +494,34 @@ /** @private {boolean} */ initialized_: false, - /** @private {?print_preview.SerializedSettings} */ + /** @private {?SerializedSettings} */ stickySettings_: null, - /** @private {?print_preview.PolicySettings} */ + /** @private {?PolicySettings} */ policySettings_: null, - /** @private {?print_preview.Cdd} */ + /** @private {?Cdd} */ lastDestinationCapabilities_: null, /** @override */ attached: function() { - assert(!print_preview.Model.instance_); - print_preview.Model.instance_ = this; - print_preview.Model.whenReady_.resolve(); + assert(!instance); + instance = this; + whenReadyResolver.resolve(); }, /** @override */ detached: function() { - print_preview.Model.instance_ = null; - print_preview.Model.whenReady_ = new PromiseResolver(); + instance = null; + whenReadyResolver = new PromiseResolver(); }, /** * @param {string} settingName Name of the setting to get. - * @return {print_preview.Setting} The setting object. + * @return {Setting} The setting object. */ getSetting: function(settingName) { - const setting = /** @type {print_preview.Setting} */ ( + const setting = /** @type {Setting} */ ( this.get(settingName, this.settings)); assert(setting, 'Setting is missing: ' + settingName); return setting; @@ -656,7 +655,7 @@ }, /** - * @param {?print_preview.CddCapabilities} caps The printer capabilities. + * @param {?CddCapabilities} caps The printer capabilities. * @private */ updateSettingsAvailabilityFromDestination_: function(caps) { @@ -668,17 +667,17 @@ const capsHasDuplex = !!caps && !!caps.duplex && !!caps.duplex.option; const capsHasLongEdge = capsHasDuplex && caps.duplex.option.some( - o => o.type == print_preview.DuplexType.LONG_EDGE); + o => o.type == DuplexType.LONG_EDGE); const capsHasShortEdge = capsHasDuplex && caps.duplex.option.some( - o => o.type == print_preview.DuplexType.SHORT_EDGE); + o => o.type == DuplexType.SHORT_EDGE); this.setSettingPath_( 'duplexShortEdge.available', capsHasLongEdge && capsHasShortEdge); this.setSettingPath_( 'duplex.available', (capsHasLongEdge || capsHasShortEdge) && caps.duplex.option.some( - o => o.type == print_preview.DuplexType.NO_DUPLEX)); + o => o.type == DuplexType.NO_DUPLEX)); this.setSettingPath_( 'vendorItems.available', !!caps && !!caps.vendor_capability); @@ -698,7 +697,7 @@ /** @private */ updateSettingsAvailabilityFromDestinationAndDocumentSettings_: function() { const isSaveAsPDF = this.destination.id == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; + Destination.GooglePromotedId.SAVE_AS_PDF; const knownSizeToSaveAsPdf = isSaveAsPDF && (!this.documentSettings.isModifiable || this.documentSettings.hasCssMediaStyles); @@ -756,7 +755,7 @@ this.setSettingPath_( 'rasterize.available', !this.documentSettings.isFromArc && - !this.documentSettings.isModifiable && !cr.isWindows && !cr.isMac); + !this.documentSettings.isModifiable && !isWindows && !isMac); this.setSettingPath_( 'otherOptions.available', this.settings.cssBackground.available || @@ -800,20 +799,20 @@ // Otherwise, availability depends on the margins. let available = false; const marginsType = - /** @type {!print_preview.MarginsType} */ ( + /** @type {!MarginsType} */ ( this.getSettingValue('margins')); switch (marginsType) { - case print_preview.MarginsType.DEFAULT: + case MarginsType.DEFAULT: available = !this.margins || - this.margins.get(print_preview.CustomMarginsOrientation.TOP) > 0 || - this.margins.get(print_preview.CustomMarginsOrientation.BOTTOM) > 0; + this.margins.get(CustomMarginsOrientation.TOP) > 0 || + this.margins.get(CustomMarginsOrientation.BOTTOM) > 0; break; - case print_preview.MarginsType.NO_MARGINS: + case MarginsType.NO_MARGINS: break; - case print_preview.MarginsType.MINIMUM: + case MarginsType.MINIMUM: available = true; break; - case print_preview.MarginsType.CUSTOM: + case MarginsType.CUSTOM: const margins = this.getSettingValue('customMargins'); available = margins.marginTop > 0 || margins.marginBottom > 0; break; @@ -824,7 +823,7 @@ }, /** - * @param {?print_preview.CddCapabilities} caps The printer capabilities. + * @param {?CddCapabilities} caps The printer capabilities. * @private */ isLayoutAvailable_: function(caps) { @@ -845,7 +844,7 @@ }, /** - * @param {?print_preview.CddCapabilities} caps The printer capabilities. + * @param {?CddCapabilities} caps The printer capabilities. * @private */ updateSettingsValues_: function(caps) { @@ -895,8 +894,8 @@ } else if ( !this.settings.color.available && (this.destination.id === - print_preview.Destination.GooglePromotedId.DOCS || - this.destination.type === print_preview.DestinationType.MOBILE)) { + Destination.GooglePromotedId.DOCS || + this.destination.type === DestinationType.MOBILE)) { this.setSettingPath_('color.unavailableValue', true); } else if ( !this.settings.color.available && caps && caps.color && @@ -915,14 +914,14 @@ this.setSetting( 'duplex', defaultOption ? - (defaultOption.type == print_preview.DuplexType.LONG_EDGE || - defaultOption.type == print_preview.DuplexType.SHORT_EDGE) : + (defaultOption.type == DuplexType.LONG_EDGE || + defaultOption.type == DuplexType.SHORT_EDGE) : false, true); this.setSetting( 'duplexShortEdge', defaultOption ? - defaultOption.type == print_preview.DuplexType.SHORT_EDGE : + defaultOption.type == DuplexType.SHORT_EDGE : false, true); @@ -932,16 +931,16 @@ this.setSettingPath_( 'duplexShortEdge.unavailableValue', caps.duplex.option.some( - o => o.type == print_preview.DuplexType.SHORT_EDGE)); + o => o.type == DuplexType.SHORT_EDGE)); } } else if ( !this.settings.duplex.available && caps && caps.duplex && caps.duplex.option) { // In this case, there must only be one option. const hasLongEdge = caps.duplex.option.some( - o => o.type == print_preview.DuplexType.LONG_EDGE); + o => o.type == DuplexType.LONG_EDGE); const hasShortEdge = caps.duplex.option.some( - o => o.type == print_preview.DuplexType.SHORT_EDGE); + o => o.type == DuplexType.SHORT_EDGE); // If the only option available is long edge, the value should always be // true. this.setSettingPath_( @@ -993,7 +992,7 @@ let savedSettings; try { - savedSettings = /** @type {print_preview.SerializedSettings} */ ( + savedSettings = /** @type {SerializedSettings} */ ( JSON.parse(savedSettingsStr)); } catch (e) { console.error('Unable to parse state ' + e); @@ -1072,23 +1071,23 @@ if (settingName === 'scalingType' && 'customScaling' in this.stickySettings_) { const isCustom = this.stickySettings_['customScaling']; - const scalingType = isCustom ? print_preview.ScalingType.CUSTOM : - print_preview.ScalingType.DEFAULT; + const scalingType = isCustom ? ScalingType.CUSTOM : + ScalingType.DEFAULT; this.setSetting(settingName, scalingType); } else if (settingName === 'scalingTypePdf') { if ('isFitToPageEnabled' in this.stickySettings_) { const isFitToPage = this.stickySettings_['isFitToPageEnabled']; const scalingTypePdf = isFitToPage ? - print_preview.ScalingType.FIT_TO_PAGE : + ScalingType.FIT_TO_PAGE : this.getSetting('scalingType').value; this.setSetting(settingName, scalingTypePdf); } else if ( this.getSetting('scalingType').value === - print_preview.ScalingType.CUSTOM) { + ScalingType.CUSTOM) { // In the event that 'isFitToPageEnabled' was not in the sticky // settings, and 'scalingType' has been set to custom, we want // 'scalingTypePdf' to match. - this.setSetting(settingName, print_preview.ScalingType.CUSTOM); + this.setSetting(settingName, ScalingType.CUSTOM); } } }, @@ -1107,7 +1106,7 @@ // We want to set the value nevertheless so we call |this.set| directly. this.set( 'settings.color.value', - colorValue === print_preview.ColorModeRestriction.COLOR); + colorValue === ColorModeRestriction.COLOR); } this.set('settings.color.setByPolicy', !!colorPolicy); @@ -1118,12 +1117,12 @@ if (duplexValue) { this.set( 'settings.duplex.value', - duplexValue != print_preview.DuplexModeRestriction.SIMPLEX); - if (duplexValue === print_preview.DuplexModeRestriction.SHORT_EDGE) { + duplexValue != DuplexModeRestriction.SIMPLEX); + if (duplexValue === DuplexModeRestriction.SHORT_EDGE) { this.set('settings.duplexShortEdge.value', true); setDuplexTypeByPolicy = true; } else if ( - duplexValue === print_preview.DuplexModeRestriction.LONG_EDGE) { + duplexValue === DuplexModeRestriction.LONG_EDGE) { this.set('settings.duplexShortEdge.value', false); setDuplexTypeByPolicy = true; } @@ -1134,7 +1133,7 @@ !!duplexPolicy && setDuplexTypeByPolicy); const pinPolicy = this.destination.pinPolicy; - if (pinPolicy === print_preview.PinModeRestriction.NO_PIN) { + if (pinPolicy === PinModeRestriction.NO_PIN) { this.set('settings.pin.available', false); this.set('settings.pinValue.available', false); } @@ -1142,7 +1141,7 @@ if (pinValue) { this.set( 'settings.pin.value', - pinValue === print_preview.PinModeRestriction.PIN); + pinValue === PinModeRestriction.PIN); } this.set('settings.pin.setByPolicy', !!pinPolicy); @@ -1154,7 +1153,7 @@ this.set( 'settings.cssBackground.value', backgroundGraphicsValue === - print_preview.BackgroundGraphicsModeRestriction.ENABLED); + BackgroundGraphicsModeRestriction.ENABLED); } this.set('settings.cssBackground.setByPolicy', !!backgroundGraphicsPolicy); @@ -1200,36 +1199,36 @@ }, /** - * @return {!print_preview.DuplexMode} The duplex mode selected. + * @return {!DuplexMode} The duplex mode selected. * @private */ getDuplexMode_: function() { if (!this.getSettingValue('duplex')) { - return print_preview.DuplexMode.SIMPLEX; + return DuplexMode.SIMPLEX; } return this.getSettingValue('duplexShortEdge') ? - print_preview.DuplexMode.SHORT_EDGE : - print_preview.DuplexMode.LONG_EDGE; + DuplexMode.SHORT_EDGE : + DuplexMode.LONG_EDGE; }, /** - * @return {!print_preview.DuplexType} The duplex type selected. + * @return {!DuplexType} The duplex type selected. * @private */ getCddDuplexType_: function() { if (!this.getSettingValue('duplex')) { - return print_preview.DuplexType.NO_DUPLEX; + return DuplexType.NO_DUPLEX; } return this.getSettingValue('duplexShortEdge') ? - print_preview.DuplexType.SHORT_EDGE : - print_preview.DuplexType.LONG_EDGE; + DuplexType.SHORT_EDGE : + DuplexType.LONG_EDGE; }, /** * Creates a string that represents a print ticket. - * @param {!print_preview.Destination} destination Destination to print to. + * @param {!Destination} destination Destination to print to. * @param {boolean} openPdfInPreview Whether this print request is to open * the PDF in Preview app (Mac only). * @param {boolean} showSystemDialog Whether this print request is to show @@ -1262,11 +1261,11 @@ shouldPrintSelectionOnly: false, // only used in print preview previewModifiable: this.documentSettings.isModifiable, printToGoogleDrive: - destination.id == print_preview.Destination.GooglePromotedId.DOCS, - printerType: print_preview.getPrinterTypeForDestination(destination), + destination.id == Destination.GooglePromotedId.DOCS, + printerType: getPrinterTypeForDestination(destination), rasterizePDF: this.getSettingValue('rasterize'), scaleFactor: this.getSettingValue(scalingSettingKey) === - print_preview.ScalingType.CUSTOM ? + ScalingType.CUSTOM ? parseInt(this.getSettingValue('scaling'), 10) : 100, scalingType: this.getSettingValue(scalingSettingKey), @@ -1285,7 +1284,7 @@ ticket.cloudPrintID = destination.id; } - if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) { + if (this.getSettingValue('margins') == MarginsType.CUSTOM) { ticket.marginsCustom = this.getSettingValue('customMargins'); } @@ -1304,7 +1303,7 @@ if (this.getSettingValue('pin')) { ticket.pinValue = this.getSettingValue('pinValue'); } - if (destination.origin == print_preview.DestinationOrigin.CROS) { + if (destination.origin == DestinationOrigin.CROS) { ticket.advancedSettings = this.getSettingValue('vendorItems'); } // </if> @@ -1314,7 +1313,7 @@ /** * Creates an object that represents a Google Cloud Print print ticket. - * @param {!print_preview.Destination} destination Destination to print to. + * @param {!Destination} destination Destination to print to. * @return {string} Google Cloud Print print ticket. */ createCloudJobTicket: function(destination) { @@ -1409,4 +1408,3 @@ return JSON.stringify(cjt); }, }); -})();
diff --git a/chrome/browser/resources/print_preview/data/printable_area.html b/chrome/browser/resources/print_preview/data/printable_area.html deleted file mode 100644 index d6801fd..0000000 --- a/chrome/browser/resources/print_preview/data/printable_area.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="size.html"> -<link rel="import" href="coordinate2d.html"> - -<script src="printable_area.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/printable_area.js b/chrome/browser/resources/print_preview/data/printable_area.js index 83791b7..d641a64 100644 --- a/chrome/browser/resources/print_preview/data/printable_area.js +++ b/chrome/browser/resources/print_preview/data/printable_area.js
@@ -2,35 +2,35 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {Size} from './size.js'; +import {Coordinate2d} from './coordinate2d.js'; - class PrintableArea { + export class PrintableArea { /** * Object describing the printable area of a page in the document. - * @param {!print_preview.Coordinate2d} origin Top left corner of the + * @param {!Coordinate2d} origin Top left corner of the * printable area of the document. - * @param {!print_preview.Size} size Size of the printable area of the + * @param {!Size} size Size of the printable area of the * document. */ constructor(origin, size) { /** * Top left corner of the printable area of the document. - * @type {!print_preview.Coordinate2d} + * @type {!Coordinate2d} * @private */ this.origin_ = origin; /** * Size of the printable area of the document. - * @type {!print_preview.Size} + * @type {!Size} * @private */ this.size_ = size; } /** - * @return {!print_preview.Coordinate2d} Top left corner of the printable + * @return {!Coordinate2d} Top left corner of the printable * area of the document. */ get origin() { @@ -38,14 +38,14 @@ } /** - * @return {!print_preview.Size} Size of the printable area of the document. + * @return {!Size} Size of the printable area of the document. */ get size() { return this.size_; } /** - * @param {print_preview.PrintableArea} other Other printable area to check + * @param {PrintableArea} other Other printable area to check * for equality. * @return {boolean} Whether another printable area is equal to this one. */ @@ -55,6 +55,3 @@ } } - // Export - return {PrintableArea: PrintableArea}; -});
diff --git a/chrome/browser/resources/print_preview/data/scaling.html b/chrome/browser/resources/print_preview/data/scaling.html deleted file mode 100644 index cbaac09..0000000 --- a/chrome/browser/resources/print_preview/data/scaling.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="scaling.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/scaling.js b/chrome/browser/resources/print_preview/data/scaling.js index 49c8d5b..572dbe5 100644 --- a/chrome/browser/resources/print_preview/data/scaling.js +++ b/chrome/browser/resources/print_preview/data/scaling.js
@@ -2,23 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; - /** * Must be kept in sync with the C++ ScalingType enum in * printing/print_job_constants.h. * @enum {number} */ - const ScalingType = { + export const ScalingType = { DEFAULT: 0, FIT_TO_PAGE: 1, FIT_TO_PAPER: 2, CUSTOM: 3, }; - // Export - return { - ScalingType: ScalingType, - }; -});
diff --git a/chrome/browser/resources/print_preview/data/size.html b/chrome/browser/resources/print_preview/data/size.html deleted file mode 100644 index 8eeefa0..0000000 --- a/chrome/browser/resources/print_preview/data/size.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="size.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/size.js b/chrome/browser/resources/print_preview/data/size.js index 8012258..5986bcd 100644 --- a/chrome/browser/resources/print_preview/data/size.js +++ b/chrome/browser/resources/print_preview/data/size.js
@@ -2,10 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; - - class Size { + export class Size { /** * Immutable two-dimensional size. * @param {number} width Width of the size. @@ -38,7 +35,7 @@ } /** - * @param {print_preview.Size} other Other size object to compare against. + * @param {Size} other Other size object to compare against. * @return {boolean} Whether this size object is equal to another. */ equals(other) { @@ -47,6 +44,3 @@ } } - // Export - return {Size: Size}; -});
diff --git a/chrome/browser/resources/print_preview/data/state.html b/chrome/browser/resources/print_preview/data/state.html deleted file mode 100644 index 12da96d..0000000 --- a/chrome/browser/resources/print_preview/data/state.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="state.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/state.js b/chrome/browser/resources/print_preview/data/state.js index df591b1f..7806499 100644 --- a/chrome/browser/resources/print_preview/data/state.js +++ b/chrome/browser/resources/print_preview/data/state.js
@@ -2,10 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; /** @enum {number} */ -print_preview.State = { +export const State = { NOT_READY: 0, READY: 1, HIDDEN: 2, @@ -17,7 +18,7 @@ }; /** @enum {number} */ -print_preview.Error = { +export const Error = { NONE: 0, INVALID_TICKET: 1, INVALID_PRINTER: 2, @@ -32,65 +33,67 @@ Polymer({ is: 'print-preview-state', + _template: null, + properties: { - /** @type {!print_preview.State} */ + /** @type {!State} */ state: { type: Number, notify: true, - value: print_preview.State.NOT_READY, + value: State.NOT_READY, }, - /** @type {!print_preview.Error} */ + /** @type {!Error} */ error: { type: Number, notify: true, - value: print_preview.Error.NONE, + value: Error.NONE, }, }, - /** @param {print_preview.State} newState The state to transition to. */ + /** @param {State} newState The state to transition to. */ transitTo: function(newState) { switch (newState) { - case (print_preview.State.NOT_READY): + case (State.NOT_READY): assert( - this.state == print_preview.State.NOT_READY || - this.state == print_preview.State.READY || - this.state == print_preview.State.ERROR); + this.state == State.NOT_READY || + this.state == State.READY || + this.state == State.ERROR); break; - case (print_preview.State.READY): + case (State.READY): assert( - this.state == print_preview.State.ERROR || - this.state == print_preview.State.NOT_READY || - this.state == print_preview.State.PRINTING); + this.state == State.ERROR || + this.state == State.NOT_READY || + this.state == State.PRINTING); break; - case (print_preview.State.HIDDEN): - assert(this.state == print_preview.State.READY); + case (State.HIDDEN): + assert(this.state == State.READY); break; - case (print_preview.State.PRINTING): + case (State.PRINTING): assert( - this.state == print_preview.State.READY || - this.state == print_preview.State.HIDDEN); + this.state == State.READY || + this.state == State.HIDDEN); break; - case (print_preview.State.SYSTEM_DIALOG): + case (State.SYSTEM_DIALOG): assert( - this.state != print_preview.State.HIDDEN && - this.state != print_preview.State.PRINTING && - this.state != print_preview.State.CLOSING); + this.state != State.HIDDEN && + this.state != State.PRINTING && + this.state != State.CLOSING); break; - case (print_preview.State.ERROR): + case (State.ERROR): assert( - this.state == print_preview.State.ERROR || - this.state == print_preview.State.NOT_READY || - this.state == print_preview.State.READY); + this.state == State.ERROR || + this.state == State.NOT_READY || + this.state == State.READY); break; - case (print_preview.State.CLOSING): - assert(this.state != print_preview.State.HIDDEN); + case (State.CLOSING): + assert(this.state != State.HIDDEN); break; } this.state = newState; - if (newState !== print_preview.State.ERROR && - newState !== print_preview.State.FATAL_ERROR) { - this.error = print_preview.Error.NONE; + if (newState !== State.ERROR && + newState !== State.FATAL_ERROR) { + this.error = Error.NONE; } }, });
diff --git a/chrome/browser/resources/print_preview/data/user_manager.html b/chrome/browser/resources/print_preview/data/user_manager.html deleted file mode 100644 index c4b5c315..0000000 --- a/chrome/browser/resources/print_preview/data/user_manager.html +++ /dev/null
@@ -1,10 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../cloud_print_interface.html"> -<link rel="import" href="destination_store.html"> -<link rel="import" href="invitation_store.html"> - -<script src="user_manager.js"></script>
diff --git a/chrome/browser/resources/print_preview/data/user_manager.js b/chrome/browser/resources/print_preview/data/user_manager.js index 03df1cc..e81daba 100644 --- a/chrome/browser/resources/print_preview/data/user_manager.js +++ b/chrome/browser/resources/print_preview/data/user_manager.js
@@ -2,10 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); - -(function() { -'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {CloudPrintInterface, CloudPrintInterfaceEventType, CloudPrintInterfaceErrorEventDetail} from '../cloud_print_interface.js'; +import {DestinationOrigin} from './destination.js'; +import {DestinationStore} from './destination_store.js'; +import {InvitationStore} from './invitation_store.js'; /** * @typedef {{ activeUser: string, @@ -16,6 +20,8 @@ Polymer({ is: 'print-preview-user-manager', + _template: null, + behaviors: [WebUIListenerBehavior], properties: { @@ -32,16 +38,16 @@ notify: true, }, - /** @type {?cloudprint.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ cloudPrintInterface: { type: Object, observer: 'onCloudPrintInterfaceSet_', }, - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ destinationStore: Object, - /** @type {?print_preview.InvitationStore} */ + /** @type {?InvitationStore} */ invitationStore: Object, shouldReloadCookies: Boolean, @@ -95,7 +101,7 @@ this.destinationStore.startLoadGoogleDrive(); this.addWebUIListener('check-for-account-update', () => { this.destinationStore.startLoadCloudDestinations( - print_preview.DestinationOrigin.COOKIES); + DestinationOrigin.COOKIES); }); } }, @@ -104,10 +110,10 @@ onCloudPrintInterfaceSet_: function() { this.tracker_.add( this.cloudPrintInterface.getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.UPDATE_USERS, + CloudPrintInterfaceEventType.UPDATE_USERS, this.onCloudPrintUpdateUsers_.bind(this)); - [cloudprint.CloudPrintInterfaceEventType.SEARCH_FAILED, - cloudprint.CloudPrintInterfaceEventType.PRINTER_FAILED, + [CloudPrintInterfaceEventType.SEARCH_FAILED, + CloudPrintInterfaceEventType.PRINTER_FAILED, ].forEach(eventType => { this.tracker_.add( this.cloudPrintInterface.getEventTarget(), eventType, @@ -123,7 +129,7 @@ /** * Updates the cloud print status to NOT_SIGNED_IN if there is an * authentication error. - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceErrorEventDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceErrorEventDetail>} * event Contains the error status * @private */ @@ -184,4 +190,3 @@ this.invitationStore.startLoadingInvitations(user); }, }); -})();
diff --git a/chrome/browser/resources/print_preview/metrics.html b/chrome/browser/resources/print_preview/metrics.html deleted file mode 100644 index 4e71977..0000000 --- a/chrome/browser/resources/print_preview/metrics.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="native_layer.html"> - -<script src="metrics.js"></script>
diff --git a/chrome/browser/resources/print_preview/metrics.js b/chrome/browser/resources/print_preview/metrics.js index 83d0cf7..f3fd209 100644 --- a/chrome/browser/resources/print_preview/metrics.js +++ b/chrome/browser/resources/print_preview/metrics.js
@@ -2,14 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {NativeLayer} from './native_layer.js'; /** * Object used to measure usage statistics. * @constructor */ - function Metrics() {} + export function Metrics() {} /** * Enumeration of buckets that a user can enter while using the destination @@ -77,7 +76,7 @@ }; /* A context for recording a value in a specific UMA histogram. */ - class MetricsContext { + export class MetricsContext { /** * @param {string} histogram The name of the histogram to be recorded in. * @param {number} maxBucket The max value for the last histogram bucket. @@ -89,8 +88,8 @@ /** @private {number} */ this.maxBucket_ = maxBucket; - /** @private {!print_preview.NativeLayer} */ - this.nativeLayer_ = print_preview.NativeLayer.getInstance(); + /** @private {!NativeLayer} */ + this.nativeLayer_ = NativeLayer.getInstance(); } /** @@ -107,7 +106,7 @@ /** * Destination Search specific usage statistics context. - * @return {!print_preview.MetricsContext} + * @return {!MetricsContext} */ static destinationSearch() { return new MetricsContext( @@ -117,7 +116,7 @@ /** * Print settings UI specific usage statistics context - * @return {!print_preview.MetricsContext} + * @return {!MetricsContext} */ static printSettingsUi() { return new MetricsContext( @@ -125,10 +124,3 @@ Metrics.PrintSettingsUiBucket.PRINT_SETTINGS_UI_MAX_BUCKET); } } - - // Export - return { - Metrics: Metrics, - MetricsContext: MetricsContext, - }; -});
diff --git a/chrome/browser/resources/print_preview/native_layer.html b/chrome/browser/resources/print_preview/native_layer.html deleted file mode 100644 index cb76a2b..0000000 --- a/chrome/browser/resources/print_preview/native_layer.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="data/destination.html"> -<link rel="import" href="data/measurement_system.html"> - -<script src="native_layer.js"></script>
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js index eb5d3478..43d6dab69 100644 --- a/chrome/browser/resources/print_preview/native_layer.js +++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -2,8 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {sendWithPromise} from 'chrome://resources/js/cr.m.js'; +import {Cdd, Destination} from'./data/destination.js'; +// <if expr="chromeos"> +import {Policies} from'./data/destination_policies.js'; +// </if> +import {PrinterType} from './data/destination_match.js'; +import {MeasurementSystemUnitType} from './data/measurement_system.js'; /** * @typedef {{selectSaveAsPdfDestination: boolean, @@ -14,7 +20,7 @@ * margins: number}} * @see chrome/browser/printing/print_preview_pdf_generated_browsertest.cc */ - let PreviewSettings; + export let PreviewSettings; /** * @typedef {{ @@ -23,10 +29,10 @@ * printerDescription: (string | undefined), * cupsEnterprisePrinter: (boolean | undefined), * printerOptions: (Object | undefined), - * policies: (print_preview.Policies | undefined), + * policies: (Policies | undefined), * }} */ - let LocalDestinationInfo; + export let LocalDestinationInfo; /** * @typedef {{ @@ -35,7 +41,7 @@ * uiLocale: string, * thousandsDelimiter: string, * decimalDelimiter: string, - * unitType: !print_preview.MeasurementSystemUnitType, + * unitType: !MeasurementSystemUnitType, * previewModifiable: boolean, * previewIsFromArc: boolean, * previewIsPdf: boolean, @@ -53,7 +59,7 @@ * }} * @see corresponding field name definitions in print_preview_handler.cc */ - let NativeInitialSettings; + export let NativeInitialSettings; /** * @typedef {{ @@ -66,27 +72,27 @@ * @see PrintPreviewHandler::FillPrinterDescription in * print_preview_handler.cc */ - let PrivetPrinterDescription; + export let PrivetPrinterDescription; /** * @typedef {{ - * printer:(print_preview.PrivetPrinterDescription | - * print_preview.LocalDestinationInfo | + * printer:(PrivetPrinterDescription | + * LocalDestinationInfo | * undefined), - * capabilities: !print_preview.Cdd, + * capabilities: !Cdd, * }} */ - let CapabilitiesResponse; + export let CapabilitiesResponse; /** * @typedef {{ * printerId: string, * success: boolean, - * capabilities: !print_preview.Cdd, - * policies: (print_preview.Policies | undefined), + * capabilities: !Cdd, + * policies: (Policies | undefined), * }} */ - let PrinterSetupResponse; + export let PrinterSetupResponse; /** * @typedef {{ @@ -97,15 +103,15 @@ * description: (string|undefined), * }} */ - let ProvisionalDestinationInfo; + export let ProvisionalDestinationInfo; /** * An interface to the native Chromium printing system layer. */ - class NativeLayer { + export class NativeLayer { /** * Creates a new NativeLayer if the current instance is not set. - * @return {!print_preview.NativeLayer} The singleton instance. + * @return {!NativeLayer} The singleton instance. */ static getInstance() { if (currentInstance == null) { @@ -115,7 +121,7 @@ } /** - * @param {!print_preview.NativeLayer} instance The NativeLayer instance + * @param {!NativeLayer} instance The NativeLayer instance * to set for print preview construction. */ static setInstance(instance) { @@ -128,43 +134,43 @@ * @return {!Promise<string>} */ getAccessToken() { - return cr.sendWithPromise('getAccessToken'); + return sendWithPromise('getAccessToken'); } // </if> /** * Gets the initial settings to initialize the print preview with. - * @return {!Promise<!print_preview.NativeInitialSettings>} + * @return {!Promise<!NativeInitialSettings>} */ getInitialSettings() { - return cr.sendWithPromise('getInitialSettings'); + return sendWithPromise('getInitialSettings'); } /** * Requests the system's print destinations. The promise will be resolved * when all destinations of that type have been retrieved. One or more * 'printers-added' events may be fired in response before resolution. - * @param {!print_preview.PrinterType} type The type of destinations to + * @param {!PrinterType} type The type of destinations to * request. * @return {!Promise} */ getPrinters(type) { - return cr.sendWithPromise('getPrinters', type); + return sendWithPromise('getPrinters', type); } /** * Requests the destination's printing capabilities. Returns a promise that * will be resolved with the capabilities if they are obtained successfully. * @param {string} destinationId ID of the destination. - * @param {!print_preview.PrinterType} type The destination's printer type. - * @return {!Promise<!print_preview.CapabilitiesResponse>} + * @param {!PrinterType} type The destination's printer type. + * @return {!Promise<!CapabilitiesResponse>} */ getPrinterCapabilities(destinationId, type) { - return cr.sendWithPromise( + return sendWithPromise( 'getPrinterCapabilities', destinationId, destinationId == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? - print_preview.PrinterType.PDF_PRINTER : + Destination.GooglePromotedId.SAVE_AS_PDF ? + PrinterType.PDF_PRINTER : type); } @@ -173,20 +179,20 @@ * Requests Chrome to resolve provisional extension destination by granting * the provider extension access to the printer. * @param {string} provisionalDestinationId - * @return {!Promise<!print_preview.ProvisionalDestinationInfo>} + * @return {!Promise<!ProvisionalDestinationInfo>} */ grantExtensionPrinterAccess(provisionalDestinationId) { - return cr.sendWithPromise('grantExtensionPrinterAccess', + return sendWithPromise('grantExtensionPrinterAccess', provisionalDestinationId); } /** * Requests that Chrome peform printer setup for the given printer. * @param {string} printerId - * @return {!Promise<!print_preview.PrinterSetupResponse>} + * @return {!Promise<!PrinterSetupResponse>} */ setupPrinter(printerId) { - return cr.sendWithPromise('setupPrinter', printerId); + return sendWithPromise('setupPrinter', printerId); } // </if> @@ -202,7 +208,7 @@ * the preview UI when the preview has been generated. */ getPreview(printTicket) { - return cr.sendWithPromise('getPreview', printTicket); + return sendWithPromise('getPreview', printTicket); } /** @@ -226,7 +232,7 @@ * finished or rejected. */ print(printTicket) { - return cr.sendWithPromise('print', printTicket); + return sendWithPromise('print', printTicket); } /** Requests that the current pending print request be cancelled. */ @@ -307,18 +313,5 @@ } } - /** @private {?print_preview.NativeLayer} */ + /** @private {?NativeLayer} */ let currentInstance = null; - - // Export - return { - CapabilitiesResponse: CapabilitiesResponse, - LocalDestinationInfo: LocalDestinationInfo, - NativeInitialSettings: NativeInitialSettings, - NativeLayer: NativeLayer, - PreviewSettings: PreviewSettings, - PrinterSetupResponse: PrinterSetupResponse, - PrivetPrinterDescription: PrivetPrinterDescription, - ProvisionalDestinationInfo: ProvisionalDestinationInfo, - }; -});
diff --git a/chrome/browser/resources/print_preview/print_preview.html b/chrome/browser/resources/print_preview/print_preview.html index 086f350..80cdb5a 100644 --- a/chrome/browser/resources/print_preview/print_preview.html +++ b/chrome/browser/resources/print_preview/print_preview.html
@@ -56,6 +56,6 @@ <print-preview-app></print-preview-app> <link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css"> <link rel="stylesheet" href="chrome://resources/css/md_colors.css"> - <link rel="import" href="ui/app.html"> + <script type="module" src="print_preview.js"></script> </body> </html>
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js new file mode 100644 index 0000000..2746717 --- /dev/null +++ b/chrome/browser/resources/print_preview/print_preview.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. + +import './ui/app.js'; + +export {createDestinationKey, ColorMode, Destination, DestinationCertificateStatus, DestinationConnectionStatus, DestinationOrigin, DestinationType, makeRecentDestination} from './data/destination.js'; +// <if expr="chromeos"> +export {BackgroundGraphicsModeRestriction, ColorModeRestriction, DuplexModeRestriction, PinModeRestriction} from './data/destination_policies.js'; +// </if> +export {DestinationErrorType, DestinationStore} from './data/destination_store.js'; +export {CloudPrintInterface, CloudPrintInterfaceEventType} from './cloud_print_interface.js'; +export {InvitationStore} from './data/invitation_store.js'; +export {PrinterType} from './data/destination_match.js'; +export {NativeLayer} from './native_layer.js'; +export {Error, State} from './data/state.js'; +export {PreviewAreaState} from './ui/preview_area.js'; +export {MeasurementSystem, MeasurementSystemUnitType} from './data/measurement_system.js'; +export {setCloudPrintInterfaceForTesting} from './cloud_print_interface_manager.js'; +export {PluginProxy} from './ui/plugin_proxy.js'; +export {DuplexMode, DuplexType, getInstance, whenReady} from './data/model.js'; +export {DestinationState} from './ui/destination_settings.js'; +export {SelectBehavior} from './ui/select_behavior.js'; +export {CustomMarginsOrientation, Margins, MarginsType} from './data/margins.js'; +export {ScalingType} from './data/scaling.js'; +export {Size} from './data/size.js'; +export {getSelectDropdownBackground} from './print_preview_utils.js';
diff --git a/chrome/browser/resources/print_preview/print_preview_resources.grd b/chrome/browser/resources/print_preview/print_preview_resources.grd index 7e6be89..c671967 100644 --- a/chrome/browser/resources/print_preview/print_preview_resources.grd +++ b/chrome/browser/resources/print_preview/print_preview_resources.grd
@@ -11,37 +11,140 @@ <output filename="print_preview_resources.pak" type="data_package" /> </outputs> <release seq="1"> + <includes> + <!-- Generated Polymer 3 elements --> + <include name="IDR_PRINT_PREVIEW_UI_APP_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/app.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_SIDEBAR_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/sidebar.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/margin_control.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_CONTAINER_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/margin_control_container.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_PREVIEW_AREA_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/preview_area.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_HEADER_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/header.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_BUTTON_STRIP_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/button_strip.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_SETTINGS_SECTION_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/settings_section.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_SETTINGS_SELECT_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/settings_select.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_DESTINATION_SELECT_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/destination_select.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_DESTINATION_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/destination_settings.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <if expr="chromeos"> + <include name="IDR_PRINT_PREVIEW_UI_PIN_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/pin_settings.js" + use_base_dir="false" type="BINDATA"/> + </if> + <include name="IDR_PRINT_PREVIEW_UI_PAGES_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/pages_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_COPIES_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/copies_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_LAYOUT_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/layout_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_COLOR_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/color_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_MEDIA_SIZE_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/media_size_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_MARGINS_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/margins_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_DPI_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/dpi_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_DUPLEX_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/duplex_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_SCALING_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/scaling_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_PAGES_PER_SHEET_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_OTHER_OPTIONS_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/other_options_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_ADVANCED_OPTIONS_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/advanced_options_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_MORE_SETTINGS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/more_settings.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_DIALOG_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_ITEM_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/advanced_settings_item.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_NUMBER_SETTINGS_SECTION_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/number_settings_section.js" + use_base_dir="false" type="BINDATA"/> + <if expr="not chromeos"> + <include name="IDR_PRINT_PREVIEW_UI_LINK_CONTAINER_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/link_container.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + </if> + <include name="IDR_PRINT_PREVIEW_UI_DESTINATION_DIALOG_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/destination_dialog.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/destination_list.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_ITEM_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/destination_list_item.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_PROVISIONAL_DESTINATION_RESOLVER_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_SEARCH_BOX_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/print_preview_search_box.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_SHARED_CSS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/print_preview_shared_css.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_VARS_CSS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/print_preview_vars_css.js" + use_base_dir="false" type="BINDATA" preprocess="true"/> + <include name="IDR_PRINT_PREVIEW_UI_THROBBER_CSS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/throbber_css.js" + use_base_dir="false" type="BINDATA"/> + <include name="IDR_PRINT_PREVIEW_UI_ICONS_JS" + file="${root_gen_dir}/chrome/browser/resources/print_preview/ui/icons.js" + use_base_dir="false" type="BINDATA"/> + </includes> <structures> <structure name="IDR_PRINT_PREVIEW_HTML" file="print_preview.html" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_APP_HTML" - file="ui/app.html" + <structure name="IDR_PRINT_PREVIEW_JS" + file="print_preview.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_APP_JS" - file="ui/app.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_SIDEBAR_HTML" - file="ui/sidebar.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_SIDEBAR_JS" - file="ui/sidebar.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_DATA_MODEL_HTML" - file="data/model.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_MODEL_JS" file="data/model.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_CLOUD_PRINT_INTERFACE_HTML" - file="cloud_print_interface.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_CLOUD_PRINT_INTERFACE_JS" file="cloud_print_interface.js" type="chrome_html" /> @@ -52,388 +155,92 @@ <structure name="IDR_PRINT_PREVIEW_CLOUD_PRINT_INTERFACE_NATIVE_JS" file="cloud_print_interface_native.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_CLOUD_PRINT_INTERFACE_MANAGER_HTML" - file="cloud_print_interface_manager.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_CLOUD_PRINT_INTERFACE_MANAGER_JS" file="cloud_print_interface_manager.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_NATIVE_LAYER_HTML" - file="native_layer.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_NATIVE_LAYER_JS" file="native_layer.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_HTML" - file="data/destination.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_JS" file="data/destination.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_MATCH_HTML" - file="data/destination_match.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_MATCH_JS" file="data/destination_match.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_STORE_HTML" - file="data/destination_store.html" + <if expr="chromeos"> + <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_POLICIES_JS" + file="data/destination_policies.js" type="chrome_html" /> + </if> <structure name="IDR_PRINT_PREVIEW_DATA_DESTINATION_STORE_JS" file="data/destination_store.js" type="chrome_html" preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_DATA_CLOUD_PARSERS_HTML" - file="data/cloud_parsers.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_CLOUD_PARSERS_JS" file="data/cloud_parsers.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_LOCAL_PARSERS_HTML" - file="data/local_parsers.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_LOCAL_PARSERS_JS" file="data/local_parsers.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_INVITATION_HTML" - file="data/invitation.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_INVITATION_JS" file="data/invitation.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_INVITATION_STORE_HTML" - file="data/invitation_store.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_INVITATION_STORE_JS" file="data/invitation_store.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_MARGINS_HTML" - file="data/margins.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_MARGINS_JS" file="data/margins.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_USER_MANAGER_HTML" - file="data/user_manager.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_USER_MANAGER_JS" file="data/user_manager.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_METRICS_HTML" - file="metrics.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_METRICS_JS" file="metrics.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_UTILS_HTML" - file="print_preview_utils.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_UTILS_JS" file="print_preview_utils.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_PRINT_DARK_MODE_BEHAVIOR_HTML" - file="dark_mode_behavior.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_PRINT_DARK_MODE_BEHAVIOR_JS" file="dark_mode_behavior.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_DOCUMENT_INFO_HTML" - file="data/document_info.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_DOCUMENT_INFO_JS" file="data/document_info.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_SCALING_HTML" - file="data/scaling.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_SCALING_JS" file="data/scaling.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_SIZE_HTML" - file="data/size.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_SIZE_JS" file="data/size.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_COORDINATE2D_HTML" - file="data/coordinate2d.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_COORDINATE2D_JS" file="data/coordinate2d.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_MEASUREMENT_SYSTEM_HTML" - file="data/measurement_system.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_MEASUREMENT_SYSTEM_JS" file="data/measurement_system.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_PRINTABLE_AREA_HTML" - file="data/printable_area.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_PRINTABLE_AREA_JS" file="data/printable_area.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_HTML" - file="ui/margin_control.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_JS" - file="ui/margin_control.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_CONTAINER_HTML" - file="ui/margin_control_container.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGIN_CONTROL_CONTAINER_JS" - file="ui/margin_control_container.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PREVIEW_AREA_HTML" - file="ui/preview_area.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PREVIEW_AREA_JS" - file="ui/preview_area.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_PLUGIN_PROXY_HTML" - file="ui/plugin_proxy.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_UI_PLUGIN_PROXY_JS" file="ui/plugin_proxy.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_HEADER_HTML" - file="ui/header.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_HEADER_JS" - file="ui/header.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_BUTTON_STRIP_HTML" - file="ui/button_strip.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_BUTTON_STRIP_JS" - file="ui/button_strip.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_BEHAVIOR_HTML" - file="ui/settings_behavior.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_BEHAVIOR_JS" file="ui/settings_behavior.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_INPUT_BEHAVIOR_HTML" - file="ui/input_behavior.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_UI_INPUT_BEHAVIOR_JS" file="ui/input_behavior.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SELECT_BEHAVIOR_HTML" - file="ui/select_behavior.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_UI_SELECT_BEHAVIOR_JS" file="ui/select_behavior.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_DATA_STATE_HTML" - file="data/state.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_DATA_STATE_JS" file="data/state.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_SECTION_HTML" - file="ui/settings_section.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_SECTION_JS" - file="ui/settings_section.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_SELECT_HTML" - file="ui/settings_select.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SETTINGS_SELECT_JS" - file="ui/settings_select.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_SELECT_HTML" - file="ui/destination_select.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_SELECT_JS" - file="ui/destination_select.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_SETTINGS_HTML" - file="ui/destination_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_SETTINGS_JS" - file="ui/destination_settings.js" - type="chrome_html" - preprocess="true" /> - <if expr="chromeos"> - <structure name="IDR_PRINT_PREVIEW_UI_PIN_SETTINGS_HTML" - file="ui/pin_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PIN_SETTINGS_JS" - file="ui/pin_settings.js" - type="chrome_html" /> - </if> - <structure name="IDR_PRINT_PREVIEW_UI_PAGES_SETTINGS_HTML" - file="ui/pages_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PAGES_SETTINGS_JS" - file="ui/pages_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_COPIES_SETTINGS_HTML" - file="ui/copies_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_COPIES_SETTINGS_JS" - file="ui/copies_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_LAYOUT_SETTINGS_HTML" - file="ui/layout_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_LAYOUT_SETTINGS_JS" - file="ui/layout_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_COLOR_SETTINGS_HTML" - file="ui/color_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_COLOR_SETTINGS_JS" - file="ui/color_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MEDIA_SIZE_SETTINGS_HTML" - file="ui/media_size_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MEDIA_SIZE_SETTINGS_JS" - file="ui/media_size_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGINS_SETTINGS_HTML" - file="ui/margins_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MARGINS_SETTINGS_JS" - file="ui/margins_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DPI_SETTINGS_HTML" - file="ui/dpi_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DPI_SETTINGS_JS" - file="ui/dpi_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DUPLEX_SETTINGS_HTML" - file="ui/duplex_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DUPLEX_SETTINGS_JS" - file="ui/duplex_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SCALING_SETTINGS_HTML" - file="ui/scaling_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_SCALING_SETTINGS_JS" - file="ui/scaling_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PAGES_PER_SHEET_SETTINGS_HTML" - file="ui/pages_per_sheet_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PAGES_PER_SHEET_SETTINGS_JS" - file="ui/pages_per_sheet_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_OTHER_OPTIONS_SETTINGS_HTML" - file="ui/other_options_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_OTHER_OPTIONS_SETTINGS_JS" - file="ui/other_options_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_OPTIONS_SETTINGS_HTML" - file="ui/advanced_options_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MORE_SETTINGS_JS" - file="ui/more_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_MORE_SETTINGS_HTML" - file="ui/more_settings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_OPTIONS_SETTINGS_JS" - file="ui/advanced_options_settings.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_DIALOG_HTML" - file="ui/advanced_settings_dialog.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_DIALOG_JS" - file="ui/advanced_settings_dialog.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_ITEM_HTML" - file="ui/advanced_settings_item.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ADVANCED_SETTINGS_ITEM_JS" - file="ui/advanced_settings_item.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_NUMBER_SETTINGS_SECTION_HTML" - file="ui/number_settings_section.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_NUMBER_SETTINGS_SECTION_JS" - file="ui/number_settings_section.js" - type="chrome_html" /> - <if expr="not chromeos"> - <structure name="IDR_PRINT_PREVIEW_UI_LINK_CONTAINER_HTML" - file="ui/link_container.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_LINK_CONTAINER_JS" - file="ui/link_container.js" - type="chrome_html" - preprocess="true" /> - </if> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_DIALOG_HTML" - file="ui/destination_dialog.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_DIALOG_JS" - file="ui/destination_dialog.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_HTML" - file="ui/destination_list.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_JS" - file="ui/destination_list.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_ITEM_HTML" - file="ui/destination_list_item.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_DESTINATION_LIST_ITEM_JS" - file="ui/destination_list_item.js" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_PROVISIONAL_DESTINATION_RESOLVER_HTML" - file="ui/provisional_destination_resolver.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PROVISIONAL_DESTINATION_RESOLVER_JS" - file="ui/provisional_destination_resolver.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_SEARCH_BOX_HTML" - file="ui/print_preview_search_box.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_SEARCH_BOX_JS" - file="ui/print_preview_search_box.js" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_HIGHLIGHT_UTILS_HTML" - file="ui/highlight_utils.html" - type="chrome_html" /> <structure name="IDR_PRINT_PREVIEW_UI_HIGHLIGHT_UTILS_JS" file="ui/highlight_utils.js" type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_SHARED_CSS_HTML" - file="ui/print_preview_shared_css.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_PRINT_PREVIEW_VARS_CSS_HTML" - file="ui/print_preview_vars_css.html" - type="chrome_html" - preprocess="true" /> - <structure name="IDR_PRINT_PREVIEW_UI_THROBBER_CSS_HTML" - file="ui/throbber_css.html" - type="chrome_html"/> - <structure name="IDR_PRINT_PREVIEW_UI_STRINGS_HTML" - file="ui/strings.html" - type="chrome_html" /> - <structure name="IDR_PRINT_PREVIEW_UI_ICONS_HTML" - file="ui/icons.html" - type="chrome_html" /> <if expr="not optimize_webui"> <!-- TODO(crbug.com/965770): The folowing 2 files are unrelated to Print
diff --git a/chrome/browser/resources/print_preview/print_preview_resources_vulcanized.grd b/chrome/browser/resources/print_preview/print_preview_resources_vulcanized.grd index 7a8b0f8..517a7c1 100644 --- a/chrome/browser/resources/print_preview/print_preview_resources_vulcanized.grd +++ b/chrome/browser/resources/print_preview/print_preview_resources_vulcanized.grd
@@ -13,7 +13,7 @@ <release seq="1"> <includes> <include name="IDR_PRINT_PREVIEW_VULCANIZED_HTML" file="${root_gen_dir}\chrome\browser\resources\print_preview\vulcanized.html" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" /> - <include name="IDR_PRINT_PREVIEW_CRISPER_JS" file="${root_gen_dir}\chrome\browser\resources\print_preview\crisper.js" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" /> + <include name="IDR_PRINT_PREVIEW_PRINT_PREVIEW_JS" file="${root_gen_dir}\chrome\browser\resources\print_preview\print_preview.js" use_base_dir="false" preprocess="true" compress="gzip" type="BINDATA" /> </includes> </release> </grit>
diff --git a/chrome/browser/resources/print_preview/print_preview_utils.html b/chrome/browser/resources/print_preview/print_preview_utils.html deleted file mode 100644 index 59e5c96..0000000 --- a/chrome/browser/resources/print_preview/print_preview_utils.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> -<link rel="import" href="dark_mode_behavior.html"> - -<script src="print_preview_utils.js"></script>
diff --git a/chrome/browser/resources/print_preview/print_preview_utils.js b/chrome/browser/resources/print_preview/print_preview_utils.js index cf7256f..811d510 100644 --- a/chrome/browser/resources/print_preview/print_preview_utils.js +++ b/chrome/browser/resources/print_preview/print_preview_utils.js
@@ -1,6 +1,9 @@ // Copyright (c) 2012 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. +import {isRTL} from 'chrome://resources/js/util.m.js'; +import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js'; +import {DarkModeBehavior} from './dark_mode_behavior.js'; /** * Returns true if the contents of the two page ranges are equal. @@ -8,7 +11,7 @@ * @param {!Array<{ to: number, from: number }>} array2 The second array. * @return {boolean} true if the arrays are equal. */ -function areRangesEqual(array1, array2) { +export function areRangesEqual(array1, array2) { if (array1.length != array2.length) { return false; } @@ -27,7 +30,7 @@ * @return {string} A string for the requested {@code locale}. An empty string * if there's no string for the specified locale found. */ -function getStringForLocale(localizedStrings, locale) { +export function getStringForLocale(localizedStrings, locale) { locale = locale.toLowerCase(); for (let i = 0; i < localizedStrings.length; i++) { if (localizedStrings[i].locale.toLowerCase() == locale) { @@ -43,7 +46,7 @@ * @return {string} A string for the current locale. An empty string if there's * no string for the current locale found. */ -function getStringForCurrentLocale(localizedStrings) { +export function getStringForCurrentLocale(localizedStrings) { // First try to find an exact match and then look for the language only. return getStringForLocale(localizedStrings, navigator.language) || getStringForLocale(localizedStrings, navigator.language.split('-')[0]); @@ -53,7 +56,7 @@ * @param {!Array<*>} args The arguments for the observer. * @return {boolean} Whether all arguments are defined. */ -function observerDepsDefined(args) { +export function observerDepsDefined(args) { return args.every(arg => arg !== undefined); } @@ -65,10 +68,10 @@ * @return {string} String containing inlined SVG of the icon and * url(path_to_arrow) separated by a comma. */ -function getSelectDropdownBackground(iconset, iconName, el) { +export function getSelectDropdownBackground(iconset, iconName, el) { const serializer = new XMLSerializer(); const iconElement = iconset.createIcon(iconName, isRTL()); - const inDarkMode = print_preview.DarkModeBehavior.inDarkMode(); + const inDarkMode = DarkModeBehavior.inDarkMode(); const fillColor = getComputedStyle(el).getPropertyValue( inDarkMode ? '--google-grey-refresh-500' : '--google-grey-600'); iconElement.style.fill = fillColor;
diff --git a/chrome/browser/resources/print_preview/ui/BUILD.gn b/chrome/browser/resources/print_preview/ui/BUILD.gn index a9bb63c..fb256729 100644 --- a/chrome/browser/resources/print_preview/ui/BUILD.gn +++ b/chrome/browser/resources/print_preview/ui/BUILD.gn
@@ -3,8 +3,15 @@ # found in the LICENSE file. import("//third_party/closure_compiler/compile_js.gni") +import("//tools/polymer/polymer.gni") -js_type_check("closure_compile") { +js_type_check("closure_compile_module") { + is_polymer3 = true + closure_flags = + default_closure_args + [ + "js_module_root=../../chrome/browser/resources/print_preview/", + "js_module_root=../../chrome/browser/resources/", + ] deps = [ ":advanced_options_settings", ":advanced_settings_dialog", @@ -16,6 +23,7 @@ ":destination_dialog", ":destination_list", ":destination_list_item", + ":destination_select", ":destination_settings", ":dpi_settings", ":duplex_settings", @@ -33,6 +41,7 @@ ":other_options_settings", ":pages_per_sheet_settings", ":pages_settings", + ":plugin_proxy", ":preview_area", ":print_preview_search_box", ":provisional_destination_resolver", @@ -57,13 +66,16 @@ "..:native_layer", "../data:destination", "../data:document_info", + "../data:margins", "../data:measurement_system", "../data:model", + "../data:printable_area", + "../data:size", "../data:state", - "//ui/webui/resources/js:event_tracker", - "//ui/webui/resources/js:util", - "//ui/webui/resources/js:web_ui_listener_behavior", - "//ui/webui/resources/js/cr/ui:focus_outline_manager", + "//ui/webui/resources/js:event_tracker.m", + "//ui/webui/resources/js:util.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", + "//ui/webui/resources/js/cr/ui:focus_outline_manager.m", ] } @@ -91,9 +103,9 @@ "..:metrics", "../data:destination", "../data:state", - "//ui/webui/resources/cr_elements:cr_container_shadow_behavior", - "//ui/webui/resources/js:load_time_data", - "//ui/webui/resources/js:web_ui_listener_behavior", + "//ui/webui/resources/cr_elements:cr_container_shadow_behavior.m", + "//ui/webui/resources/js:load_time_data.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] } @@ -101,7 +113,7 @@ deps = [ "../data:destination", "../data:state", - "//ui/webui/resources/js:cr", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] if (is_chromeos) { @@ -114,7 +126,8 @@ ":settings_behavior", "../data:destination", "../data:state", - "//ui/webui/resources/js:cr", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:load_time_data.m", ] } @@ -129,9 +142,10 @@ "../data:invitation_store", "../data:state", "../data:user_manager", - "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render", - "//ui/webui/resources/js:i18n_behavior", - "//ui/webui/resources/js:web_ui_listener_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render.m", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] } @@ -140,9 +154,10 @@ ":select_behavior", "..:print_preview_utils", "../data:destination", - "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted", - "//third_party/polymer/v1_0/components-chromium/iron-meta:iron-meta-extracted", - "//ui/webui/resources/js:i18n_behavior", + "//third_party/polymer/v3_0/components-chromium/iron-iconset-svg:iron-iconset-svg", + "//third_party/polymer/v3_0/components-chromium/iron-meta:iron-meta", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:i18n_behavior.m", ] } @@ -152,6 +167,7 @@ ":input_behavior", ":settings_behavior", "../data:state", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } } @@ -161,8 +177,9 @@ ":input_behavior", ":settings_behavior", "..:print_preview_utils", - "//ui/webui/resources/cr_elements/cr_input:cr_input", - "//ui/webui/resources/js:load_time_data", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_input:cr_input.m", + "//ui/webui/resources/js:load_time_data.m", ] } @@ -170,6 +187,7 @@ deps = [ ":number_settings_section", ":settings_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -177,6 +195,7 @@ deps = [ ":select_behavior", ":settings_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -184,6 +203,7 @@ deps = [ ":select_behavior", ":settings_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -191,6 +211,7 @@ deps = [ ":settings_behavior", ":settings_select", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -198,6 +219,8 @@ deps = [ ":select_behavior", ":settings_behavior", + "../data:margins", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } @@ -205,8 +228,9 @@ deps = [ ":settings_behavior", ":settings_select", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:load_time_data", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:load_time_data.m", ] } @@ -214,20 +238,26 @@ deps = [ ":select_behavior", ":settings_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } js_library("scaling_settings") { deps = [ ":number_settings_section", + ":select_behavior", ":settings_behavior", "../data:scaling", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:load_time_data.m", ] } js_library("other_options_settings") { deps = [ ":settings_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:i18n_behavior.m", ] } @@ -236,29 +266,37 @@ ":select_behavior", ":settings_behavior", "..:print_preview_utils", - "//third_party/polymer/v1_0/components-chromium/iron-iconset-svg:iron-iconset-svg-extracted", + "../data:model", + "//third_party/polymer/v3_0/components-chromium/iron-iconset-svg:iron-iconset-svg", + "//third_party/polymer/v3_0/components-chromium/iron-meta:iron-meta", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } js_library("advanced_options_settings") { deps = [ ":advanced_settings_dialog", - ":settings_behavior", "../data:destination", + "../data:model", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } js_library("more_settings") { deps = [ "..:metrics", - "//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button", - "//ui/webui/resources/js:i18n_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_expand_button:cr_expand_button.m", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:i18n_behavior.m", ] } js_library("number_settings_section") { deps = [ ":input_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_input:cr_input.m", ] } @@ -267,33 +305,32 @@ ":select_behavior", ":settings_behavior", "..:print_preview_utils", - "//ui/webui/resources/js:cr", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:assert.m", ] } js_library("settings_behavior") { deps = [ "../data:model", - "//ui/webui/resources/js:assert", - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] } js_library("input_behavior") { deps = [ - "//ui/webui/resources/js:cr", + "//ui/webui/resources/js:assert.m", ] } js_library("select_behavior") { - deps = [] } js_library("link_container") { deps = [ "../data:destination", - "//ui/webui/resources/js:assert", - "//ui/webui/resources/js:cr", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:cr.m", ] } @@ -304,19 +341,22 @@ ":settings_behavior", "..:dark_mode_behavior", "..:native_layer", + "..:print_preview_utils", "../../pdf:pdf_scripting_api", "../data:coordinate2d", "../data:destination", "../data:destination_match", "../data:margins", + "../data:measurement_system", "../data:model", "../data:printable_area", "../data:size", "../data:state", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:i18n_behavior", - "//ui/webui/resources/js:util", - "//ui/webui/resources/js:web_ui_listener_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:cr.m", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:util.m", + "//ui/webui/resources/js:web_ui_listener_behavior.m", ] } @@ -329,7 +369,8 @@ "../data:measurement_system", "../data:size", "../data:state", - "//ui/webui/resources/js:event_tracker", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:event_tracker.m", ] externs_list = [ "$externs_path/pending.js" ] } @@ -341,13 +382,15 @@ "../data:margins", "../data:measurement_system", "../data:size", - "//ui/webui/resources/js:i18n_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:i18n_behavior.m", ] } js_library("plugin_proxy") { deps = [ - "//ui/webui/resources/js:cr", + "../../pdf:pdf_scripting_api", + "//ui/webui/resources/js:assert.m", ] } @@ -362,20 +405,21 @@ "../data:destination_store", "../data:invitation", "../data:invitation_store", - "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", - "//ui/webui/resources/js:event_tracker", - "//ui/webui/resources/js:i18n_behavior", - "//ui/webui/resources/js:list_property_update_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m", + "//ui/webui/resources/js:event_tracker.m", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:list_property_update_behavior.m", ] - externs_list = [ "$externs_path/pending_polymer.js" ] } js_library("destination_list") { deps = [ ":destination_list_item", "../data:destination", - "//ui/webui/resources/js:i18n_behavior", - "//ui/webui/resources/js:list_property_update_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:list_property_update_behavior.m", ] } @@ -383,6 +427,9 @@ deps = [ ":highlight_utils", "../data:destination", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/js:load_time_data.m", + "//ui/webui/resources/js:search_highlight_utils.m", ] } @@ -393,8 +440,10 @@ ":settings_behavior", "..:metrics", "../data:destination", - "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", - "//ui/webui/resources/js:i18n_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:search_highlight_utils.m", ] } @@ -404,12 +453,15 @@ ":settings_behavior", "..:print_preview_utils", "../data:destination", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", ] } js_library("print_preview_search_box") { deps = [ - "//ui/webui/resources/cr_elements/cr_search_field:cr_search_field_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_input:cr_input.m", + "//ui/webui/resources/cr_elements/cr_search_field:cr_search_field_behavior.m", ] } @@ -417,14 +469,288 @@ deps = [ "../data:destination", "../data:destination_store", - "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog", - "//ui/webui/resources/js:cr", - "//ui/webui/resources/js:i18n_behavior", + "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", + "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:i18n_behavior.m", + "//ui/webui/resources/js:promise_resolver.m", ] } js_library("highlight_utils") { deps = [ - "//ui/webui/resources/js:search_highlight_utils", + "//ui/webui/resources/js:assert.m", + "//ui/webui/resources/js:search_highlight_utils.m", ] } + +group("polymer3_elements") { + deps = [ + ":advanced_options_settings_module", + ":advanced_settings_dialog_module", + ":advanced_settings_item_module", + ":app_module", + ":button_strip_module", + ":color_settings_module", + ":copies_settings_module", + ":destination_dialog_module", + ":destination_list_item_module", + ":destination_list_module", + ":destination_select_module", + ":destination_settings_module", + ":dpi_settings_module", + ":duplex_settings_module", + ":header_module", + ":icons_module", + ":layout_settings_module", + ":link_container_module", + ":margin_control_container_module", + ":margin_control_module", + ":margins_settings_module", + ":media_size_settings_module", + ":more_settings_module", + ":number_settings_section_module", + ":other_options_settings_module", + ":pages_per_sheet_settings_module", + ":pages_settings_module", + ":pin_settings_module", + ":preview_area_module", + ":print_preview_search_box_module", + ":print_preview_shared_css_module", + ":print_preview_vars_css_module", + ":provisional_destination_resolver_module", + ":scaling_settings_module", + ":settings_section_module", + ":settings_select_module", + ":sidebar_module", + ":throbber_css_module", + ] +} + +polymer_modulizer("advanced_options_settings") { + html_file = "advanced_options_settings.html" + js_file = "advanced_options_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("advanced_settings_dialog") { + html_file = "advanced_settings_dialog.html" + js_file = "advanced_settings_dialog.js" + html_type = "v3-ready" +} + +polymer_modulizer("advanced_settings_item") { + html_file = "advanced_settings_item.html" + js_file = "advanced_settings_item.js" + html_type = "v3-ready" +} + +polymer_modulizer("app") { + html_file = "app.html" + js_file = "app.js" + html_type = "v3-ready" +} + +polymer_modulizer("button_strip") { + html_file = "button_strip.html" + js_file = "button_strip.js" + html_type = "v3-ready" +} + +polymer_modulizer("color_settings") { + html_file = "color_settings.html" + js_file = "color_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("copies_settings") { + html_file = "copies_settings.html" + js_file = "copies_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("destination_dialog") { + html_file = "destination_dialog.html" + js_file = "destination_dialog.js" + html_type = "v3-ready" +} + +polymer_modulizer("destination_list") { + html_file = "destination_list.html" + js_file = "destination_list.js" + html_type = "v3-ready" +} + +polymer_modulizer("destination_list_item") { + html_file = "destination_list_item.html" + js_file = "destination_list_item.js" + html_type = "v3-ready" +} + +polymer_modulizer("destination_select") { + html_file = "destination_select.html" + js_file = "destination_select.js" + html_type = "v3-ready" +} + +polymer_modulizer("destination_settings") { + html_file = "destination_settings.html" + js_file = "destination_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("dpi_settings") { + html_file = "dpi_settings.html" + js_file = "dpi_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("duplex_settings") { + html_file = "duplex_settings.html" + js_file = "duplex_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("header") { + html_file = "header.html" + js_file = "header.js" + html_type = "v3-ready" +} + +polymer_modulizer("layout_settings") { + html_file = "layout_settings.html" + js_file = "layout_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("link_container") { + html_file = "link_container.html" + js_file = "link_container.js" + html_type = "v3-ready" +} + +polymer_modulizer("margin_control_container") { + html_file = "margin_control_container.html" + js_file = "margin_control_container.js" + html_type = "v3-ready" +} + +polymer_modulizer("margin_control") { + html_file = "margin_control.html" + js_file = "margin_control.js" + html_type = "v3-ready" +} + +polymer_modulizer("margins_settings") { + html_file = "margins_settings.html" + js_file = "margins_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("media_size_settings") { + html_file = "media_size_settings.html" + js_file = "media_size_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("more_settings") { + html_file = "more_settings.html" + js_file = "more_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("number_settings_section") { + html_file = "number_settings_section.html" + js_file = "number_settings_section.js" + html_type = "v3-ready" +} + +polymer_modulizer("other_options_settings") { + html_file = "other_options_settings.html" + js_file = "other_options_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("pages_per_sheet_settings") { + html_file = "pages_per_sheet_settings.html" + js_file = "pages_per_sheet_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("pages_settings") { + html_file = "pages_settings.html" + js_file = "pages_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("pin_settings") { + html_file = "pin_settings.html" + js_file = "pin_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("preview_area") { + html_file = "preview_area.html" + js_file = "preview_area.js" + html_type = "v3-ready" +} + +polymer_modulizer("print_preview_search_box") { + html_file = "print_preview_search_box.html" + js_file = "print_preview_search_box.js" + html_type = "v3-ready" +} + +polymer_modulizer("provisional_destination_resolver") { + html_file = "provisional_destination_resolver.html" + js_file = "provisional_destination_resolver.js" + html_type = "v3-ready" +} + +polymer_modulizer("scaling_settings") { + html_file = "scaling_settings.html" + js_file = "scaling_settings.js" + html_type = "v3-ready" +} + +polymer_modulizer("settings_section") { + html_file = "settings_section.html" + js_file = "settings_section.js" + html_type = "v3-ready" +} + +polymer_modulizer("settings_select") { + html_file = "settings_select.html" + js_file = "settings_select.js" + html_type = "v3-ready" +} + +polymer_modulizer("sidebar") { + html_file = "sidebar.html" + js_file = "sidebar.js" + html_type = "v3-ready" +} + +polymer_modulizer("print_preview_shared_css") { + html_file = "print_preview_shared_css.html" + js_file = "print_preview_shared_css.js" + html_type = "v3-ready" +} + +polymer_modulizer("throbber_css") { + html_file = "throbber_css.html" + js_file = "throbber_css.js" + html_type = "v3-ready" +} + +polymer_modulizer("print_preview_vars_css") { + html_file = "print_preview_vars_css.html" + js_file = "print_preview_vars_css.js" + html_type = "v3-ready" +} + +polymer_modulizer("icons") { + html_file = "icons.html" + js_file = "icons.js" + html_type = "v3-ready" +}
diff --git a/chrome/browser/resources/print_preview/ui/advanced_options_settings.html b/chrome/browser/resources/print_preview/ui/advanced_options_settings.html index ec2c7ba..3bd7dd5c 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_options_settings.html +++ b/chrome/browser/resources/print_preview/ui/advanced_options_settings.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="advanced_settings_dialog.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-advanced-options-settings"> - <template> <style include="print-preview-shared"> cr-button { height: fit-content; @@ -31,6 +22,3 @@ on-close="onDialogClose_"> </print-preview-advanced-settings-dialog> </template> - </template> - <script src="advanced_options_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/advanced_options_settings.js b/chrome/browser/resources/print_preview/ui/advanced_options_settings.js index 6156206..b6a4dad7 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_options_settings.js +++ b/chrome/browser/resources/print_preview/ui/advanced_options_settings.js
@@ -2,16 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; +import {Destination} from '../data/destination.js'; +import {Settings} from '../data/model.js'; +import './advanced_settings_dialog.js'; +import './print_preview_shared_css.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-advanced-options-settings', + _template: html`{__html_template__}`, + properties: { disabled: Boolean, - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, - /** @type {!print_preview.Settings} */ + /** @type {!Settings} */ settings: Object, /** @private {boolean} */
diff --git a/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.html b/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.html index a81ba439..87e272443 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.html +++ b/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.html
@@ -1,20 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../metrics.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="advanced_settings_item.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="print_preview_search_box.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-advanced-settings-dialog"> - <template> <style include="print-preview-shared cr-hidden-style"> #dialog::part(dialog) { height: -webkit-fit-content; @@ -59,6 +43,3 @@ </cr-button> </div> </cr-dialog> - </template> - <script src="advanced_settings_dialog.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.js b/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.js index 00abe9b1..490b0d6 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.js +++ b/chrome/browser/resources/print_preview/ui/advanced_settings_dialog.js
@@ -2,13 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; +import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {Metrics, MetricsContext} from '../metrics.js'; +import {Destination} from '../data/destination.js'; +import './advanced_settings_item.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import {removeHighlights} from 'chrome://resources/js/search_highlight_utils.m.js'; +import './print_preview_search_box.js'; +import './print_preview_shared_css.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; + Polymer({ is: 'print-preview-advanced-settings-dialog', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior, I18nBehavior], properties: { - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, /** @private {?RegExp} */ @@ -35,12 +52,12 @@ /** @private {!Array<Node>} */ bubbles_: [], - /** @private {!print_preview.MetricsContext} */ - metrics_: print_preview.MetricsContext.printSettingsUi(), + /** @private {!MetricsContext} */ + metrics_: MetricsContext.printSettingsUi(), /** @override */ attached: function() { - this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket + this.metrics_.record(Metrics.PrintSettingsUiBucket .ADVANCED_SETTINGS_DIALOG_SHOWN); this.$.dialog.showModal(); }, @@ -87,7 +104,7 @@ return true; } - cr.search_highlight_utils.removeHighlights(this.highlights_); + removeHighlights(this.highlights_); for (const bubble of this.bubbles_) { bubble.remove(); } @@ -122,7 +139,7 @@ this.$.searchBox.setValue(''); } if (this.$.dialog.getNative().returnValue == 'success') { - this.metrics_.record(print_preview.Metrics.PrintSettingsUiBucket + this.metrics_.record(Metrics.PrintSettingsUiBucket .ADVANCED_SETTINGS_DIALOG_CANCELED); } },
diff --git a/chrome/browser/resources/print_preview/ui/advanced_settings_item.html b/chrome/browser/resources/print_preview/ui/advanced_settings_item.html index 396e852..f50fad3 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_settings_item.html +++ b/chrome/browser/resources/print_preview/ui/advanced_settings_item.html
@@ -1,19 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/search_highlight_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="highlight_utils.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> - -<dom-module id="print-preview-advanced-settings-item"> - <template> <style include="print-preview-shared md-select search-highlight-style cr-hidden-style"> :host { @@ -88,6 +73,3 @@ </cr-checkbox> </span> </div> - </template> - <script src="advanced_settings_item.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/advanced_settings_item.js b/chrome/browser/resources/print_preview/ui/advanced_settings_item.js index 56450e98..4c80ab7 100644 --- a/chrome/browser/resources/print_preview/ui/advanced_settings_item.js +++ b/chrome/browser/resources/print_preview/ui/advanced_settings_item.js
@@ -2,13 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; +import 'chrome://resources/cr_elements/search_highlight_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {getStringForCurrentLocale} from '../print_preview_utils.js'; +import {Destination, VendorCapability, VendorCapabilitySelectOption} from '../data/destination.js'; +import {updateHighlights, HighlightResults} from './highlight_utils.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; + Polymer({ is: 'print-preview-advanced-settings-item', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior], properties: { - /** @type {!print_preview.VendorCapability} */ + /** @type {!VendorCapability} */ capability: Object, /** @private {string} */ @@ -44,8 +59,8 @@ }, /** - * @param {!print_preview.VendorCapability | - * !print_preview.VendorCapabilitySelectOption} item + * @param {!VendorCapability | + * !VendorCapabilitySelectOption} item * @return {string} The display name for the setting. * @private */ @@ -94,7 +109,7 @@ }, /** - * @param {!print_preview.VendorCapabilitySelectOption} option The option + * @param {!VendorCapabilitySelectOption} option The option * for a select capability. * @return {boolean} Whether the option is selected. * @private @@ -146,7 +161,7 @@ } for (const option of - /** @type {!Array<!print_preview.VendorCapabilitySelectOption>} */ ( + /** @type {!Array<!VendorCapabilitySelectOption>} */ ( this.capability.select_cap.option)) { if (this.getDisplayName_(option).match(query)) { return true; @@ -189,10 +204,10 @@ /** * @param {?RegExp} query The current search query. - * @return {!print_preview.HighlightResults} The highlight wrappers and + * @return {!HighlightResults} The highlight wrappers and * search bubbles that were created. */ updateHighlighting: function(query) { - return print_preview.updateHighlights(this, query); + return updateHighlights(this, query); }, });
diff --git a/chrome/browser/resources/print_preview/ui/app.html b/chrome/browser/resources/print_preview/ui/app.html index d1a8b40..946b66b 100644 --- a/chrome/browser/resources/print_preview/ui/app.html +++ b/chrome/browser/resources/print_preview/ui/app.html
@@ -1,27 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_outline_manager.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../cloud_print_interface.html"> -<link rel="import" href="../cloud_print_interface_manager.html"> -<link rel="import" href="../native_layer.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/document_info.html"> -<link rel="import" href="../data/measurement_system.html"> -<link rel="import" href="../data/model.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="preview_area.html"> -<link rel="import" href="sidebar.html"> - -<dom-module id="print-preview-app"> - <template> <style> :host { display: flex; @@ -86,6 +63,3 @@ on-print-requested="onPrintRequested_" on-cancel-requested="onCancelRequested_"> </print-preview-sidebar> - </template> - <script src="app.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/app.js b/chrome/browser/resources/print_preview/ui/app.js index 060c8c46..381c7d0 100644 --- a/chrome/browser/resources/print_preview/ui/app.js +++ b/chrome/browser/resources/print_preview/ui/app.js
@@ -2,16 +2,45 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isMac, isWindows} from 'chrome://resources/js/cr.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {FocusOutlineManager} from 'chrome://resources/js/cr/ui/focus_outline_manager.m.js'; +import {hasKeyModifiers} from 'chrome://resources/js/util.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {CloudPrintInterface, CloudPrintInterfaceErrorEventDetail, CloudPrintInterfaceEventType} from '../cloud_print_interface.js'; +import {getCloudPrintInterface} from '../cloud_print_interface_manager.js'; +import {NativeInitialSettings, NativeLayer} from '../native_layer.js'; +import {Destination} from '../data/destination.js'; +import {DocumentSettings} from '../data/document_info.js'; +import {Margins} from '../data/margins.js'; +import {MeasurementSystem} from '../data/measurement_system.js'; +import {PrintableArea} from '../data/printable_area.js'; +import {Size} from '../data/size.js'; +import {DuplexMode, whenReady} from '../data/model.js'; +import {Error, State} from '../data/state.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; +import {DestinationState} from './destination_settings.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import {PreviewAreaState} from './preview_area.js'; +import './sidebar.js'; + Polymer({ is: 'print-preview-app', + _template: html`{__html_template__}`, + behaviors: [ SettingsBehavior, WebUIListenerBehavior, ], properties: { - /** @type {!print_preview.State} */ + /** @type {!State} */ state: { type: Number, observer: 'onStateChanged_', @@ -20,43 +49,43 @@ /** @private {string} */ cloudPrintErrorMessage_: String, - /** @private {!cloudprint.CloudPrintInterface} */ + /** @private {!CloudPrintInterface} */ cloudPrintInterface_: Object, /** @private {boolean} */ controlsManaged_: Boolean, - /** @private {print_preview.Destination} */ + /** @private {Destination} */ destination_: Object, - /** @private {!print_preview.DestinationState} */ + /** @private {!DestinationState} */ destinationState_: { type: Number, observer: 'onDestinationStateChange_', }, - /** @private {print_preview.DocumentSettings} */ + /** @private {DocumentSettings} */ documentSettings_: Object, - /** @private {!print_preview.Error} */ + /** @private {!Error} */ error_: Number, - /** @private {print_preview.Margins} */ + /** @private {Margins} */ margins_: Object, - /** @private {!print_preview.Size} */ + /** @private {!Size} */ pageSize_: Object, - /** @private {!print_preview.PreviewAreaState} */ + /** @private {!PreviewAreaState} */ previewState_: { type: String, observer: 'onPreviewStateChange_', }, - /** @private {!print_preview.PrintableArea} */ + /** @private {!PrintableArea} */ printableArea_: Object, - /** @private {?print_preview.MeasurementSystem} */ + /** @private {?MeasurementSystem} */ measurementSystem_: { type: Object, value: null, @@ -68,7 +97,7 @@ 'close': 'onCrDialogClose_', }, - /** @private {?print_preview.NativeLayer} */ + /** @private {?NativeLayer} */ nativeLayer_: null, /** @private {!EventTracker} */ @@ -111,19 +140,19 @@ /** @override */ ready: function() { - cr.ui.FocusOutlineManager.forDocument(document); + FocusOutlineManager.forDocument(document); }, /** @override */ attached: function() { document.documentElement.classList.remove('loading'); - this.nativeLayer_ = print_preview.NativeLayer.getInstance(); + this.nativeLayer_ = NativeLayer.getInstance(); this.addWebUIListener('print-failed', this.onPrintFailed_.bind(this)); this.addWebUIListener( 'print-preset-options', this.onPrintPresetOptions_.bind(this)); this.tracker_.add(window, 'keydown', this.onKeyDown_.bind(this)); this.$.previewArea.setPluginKeyEventCallback(this.onKeyDown_.bind(this)); - this.whenReady_ = print_preview.Model.whenReady(); + this.whenReady_ = whenReady(); this.nativeLayer_.getInitialSettings().then( this.onInitialSettingsSet_.bind(this)); }, @@ -162,7 +191,7 @@ // On non-mac with toolkit-views, ESC key is handled by C++-side instead // of JS-side. - if (cr.isMac) { + if (isMac) { this.close_(); e.preventDefault(); } @@ -170,7 +199,7 @@ } // On Mac, Cmd+Period should close the print dialog. - if (cr.isMac && e.code == 'Period' && e.metaKey) { + if (isMac && e.code == 'Period' && e.metaKey) { this.close_(); e.preventDefault(); return; @@ -178,8 +207,8 @@ // Ctrl + Shift + p / Mac equivalent. if (e.code == 'KeyP') { - if ((cr.isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) || - (!cr.isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) { + if ((isMac && e.metaKey && e.altKey && !e.shiftKey && !e.ctrlKey) || + (!isMac && e.shiftKey && e.ctrlKey && !e.altKey && !e.metaKey)) { // Don't use system dialog if the link isn't available. if (!this.$.sidebar.systemDialogLinkAvailable()) { return; @@ -188,7 +217,7 @@ // Don't try to print with system dialog on Windows if the document is // not ready, because we send the preview document to the printer on // Windows. - if (!cr.isWindows || this.state == print_preview.State.READY) { + if (!isWindows || this.state == State.READY) { this.onPrintWithSystemDialog_(); } e.preventDefault(); @@ -197,7 +226,7 @@ } if ((e.code === 'Enter' || e.code === 'NumpadEnter') && - this.state === print_preview.State.READY && + this.state === State.READY && this.openDialogs_.length === 0) { const activeElementTag = e.path[0].tagName; if (['CR-BUTTON', 'BUTTON', 'SELECT', 'A', 'CR-CHECKBOX'].includes( @@ -239,7 +268,7 @@ }, /** - * @param {!print_preview.NativeInitialSettings} settings + * @param {!NativeInitialSettings} settings * @private */ onInitialSettingsSet_: function(settings) { @@ -263,7 +292,7 @@ this.$.model.setStickySettings(settings.serializedAppStateStr); this.$.model.setPolicySettings( settings.headerFooter, settings.isHeaderFooterManaged); - this.measurementSystem_ = new print_preview.MeasurementSystem( + this.measurementSystem_ = new MeasurementSystem( settings.thousandsDelimiter, settings.decimalDelimiter, settings.unitType); this.setSetting('selectionOnly', settings.shouldPrintSelectionOnly); @@ -292,28 +321,28 @@ */ initializeCloudPrint_: function(cloudPrintUrl, appKioskMode, uiLocale) { assert(!this.cloudPrintInterface_); - this.cloudPrintInterface_ = cloudprint.getCloudPrintInterface( + this.cloudPrintInterface_ = getCloudPrintInterface( cloudPrintUrl, assert(this.nativeLayer_), appKioskMode, uiLocale); this.tracker_.add( assert(this.cloudPrintInterface_).getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.SUBMIT_DONE, + CloudPrintInterfaceEventType.SUBMIT_DONE, this.close_.bind(this)); this.tracker_.add( assert(this.cloudPrintInterface_).getEventTarget(), - cloudprint.CloudPrintInterfaceEventType.SUBMIT_FAILED, + CloudPrintInterfaceEventType.SUBMIT_FAILED, this.onCloudPrintError_.bind(this, appKioskMode)); }, /** @private */ onDestinationStateChange_: function() { switch (this.destinationState_) { - case print_preview.DestinationState.SELECTED: - case print_preview.DestinationState.SET: - if (this.state !== print_preview.State.NOT_READY) { - this.$.state.transitTo(print_preview.State.NOT_READY); + case DestinationState.SELECTED: + case DestinationState.SET: + if (this.state !== State.NOT_READY) { + this.$.state.transitTo(State.NOT_READY); } break; - case print_preview.DestinationState.UPDATED: + case DestinationState.UPDATED: if (!this.$.model.initialized()) { this.$.model.applyStickySettings(); } @@ -323,13 +352,13 @@ // </if> this.startPreviewWhenReady_ = true; - this.$.state.transitTo(print_preview.State.READY); + this.$.state.transitTo(State.READY); break; - case print_preview.DestinationState.ERROR: - let newState = print_preview.State.ERROR; + case DestinationState.ERROR: + let newState = State.ERROR; // <if expr="chromeos"> - if (this.error_ === print_preview.Error.NO_DESTINATIONS) { - newState = print_preview.State.FATAL_ERROR; + if (this.error_ === Error.NO_DESTINATIONS) { + newState = State.FATAL_ERROR; } // </if> this.$.state.transitTo(newState); @@ -349,7 +378,7 @@ /** @private */ onPreviewSettingChanged_: function() { - if (this.state === print_preview.State.READY) { + if (this.state === State.READY) { this.$.previewArea.startPreview(false); this.startPreviewWhenReady_ = false; } else { @@ -359,7 +388,7 @@ /** @private */ onStateChanged_: function() { - if (this.state == print_preview.State.READY) { + if (this.state == State.READY) { if (this.startPreviewWhenReady_) { this.$.previewArea.startPreview(false); this.startPreviewWhenReady_ = false; @@ -369,17 +398,17 @@ // Reset in case printing fails. this.printRequested_ = false; } - } else if (this.state == print_preview.State.CLOSING) { + } else if (this.state == State.CLOSING) { this.remove(); this.nativeLayer_.dialogClose(this.cancelled_); - } else if (this.state == print_preview.State.HIDDEN) { + } else if (this.state == State.HIDDEN) { if (this.destination_.isLocal && this.destination_.id !== - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { + Destination.GooglePromotedId.SAVE_AS_PDF) { // Only hide the preview for local, non PDF destinations. this.nativeLayer_.hidePreview(); } - } else if (this.state == print_preview.State.PRINTING) { + } else if (this.state == State.PRINTING) { const destination = assert(this.destination_); const whenPrintDone = this.nativeLayer_.print(this.$.model.createPrintTicket( @@ -387,7 +416,7 @@ this.showSystemDialogBeforePrint_)); if (destination.isLocal) { const onError = destination.id == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF ? + Destination.GooglePromotedId.SAVE_AS_PDF ? this.onFileSelectionCancel_.bind(this) : this.onPrintFailed_.bind(this); whenPrintDone.then(this.close_.bind(this), onError); @@ -403,19 +432,19 @@ /** @private */ onPrintRequested_: function() { - if (this.state === print_preview.State.NOT_READY) { + if (this.state === State.NOT_READY) { this.printRequested_ = true; return; } this.$.state.transitTo( - this.$.previewArea.previewLoaded() ? print_preview.State.PRINTING : - print_preview.State.HIDDEN); + this.$.previewArea.previewLoaded() ? State.PRINTING : + State.HIDDEN); }, /** @private */ onCancelRequested_: function() { this.cancelled_ = true; - this.$.state.transitTo(print_preview.State.CLOSING); + this.$.state.transitTo(State.CLOSING); }, /** @@ -424,16 +453,16 @@ */ onSettingValidChanged_: function(e) { if (e.detail) { - this.$.state.transitTo(print_preview.State.READY); + this.$.state.transitTo(State.READY); } else { - this.error_ = print_preview.Error.INVALID_TICKET; - this.$.state.transitTo(print_preview.State.ERROR); + this.error_ = Error.INVALID_TICKET; + this.$.state.transitTo(State.ERROR); } }, /** @private */ onFileSelectionCancel_: function() { - this.$.state.transitTo(print_preview.State.READY); + this.$.state.transitTo(State.READY); }, /** @@ -460,7 +489,7 @@ // </if> // <if expr="not is_win"> this.nativeLayer_.showSystemDialog(); - this.$.state.transitTo(print_preview.State.SYSTEM_DIALOG); + this.$.state.transitTo(State.SYSTEM_DIALOG); // </if> }, // </if> @@ -482,26 +511,26 @@ */ onPrintFailed_: function(httpError) { console.error('Printing failed with error code ' + httpError); - this.error_ = print_preview.Error.PRINT_FAILED; - this.$.state.transitTo(print_preview.State.FATAL_ERROR); + this.error_ = Error.PRINT_FAILED; + this.$.state.transitTo(State.FATAL_ERROR); }, /** @private */ onPreviewStateChange_: function() { switch (this.previewState_) { - case print_preview.PreviewAreaState.DISPLAY_PREVIEW: - case print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADED: - if (this.state === print_preview.State.HIDDEN) { - this.$.state.transitTo(print_preview.State.PRINTING); + case PreviewAreaState.DISPLAY_PREVIEW: + case PreviewAreaState.OPEN_IN_PREVIEW_LOADED: + if (this.state === State.HIDDEN) { + this.$.state.transitTo(State.PRINTING); } break; - case print_preview.PreviewAreaState.ERROR: - if (this.state !== print_preview.State.ERROR && - this.state !== print_preview.State.FATAL_ERROR) { + case PreviewAreaState.ERROR: + if (this.state !== State.ERROR && + this.state !== State.FATAL_ERROR) { this.$.state.transitTo( - this.error_ === print_preview.Error.INVALID_PRINTER ? - print_preview.State.ERROR : - print_preview.State.FATAL_ERROR); + this.error_ === Error.INVALID_PRINTER ? + State.ERROR : + State.FATAL_ERROR); } break; default: @@ -513,7 +542,7 @@ * Called when there was an error communicating with Google Cloud print. * Displays an error message in the print header. * @param {boolean} appKioskMode - * @param {!CustomEvent<!cloudprint.CloudPrintInterfaceErrorEventDetail>} + * @param {!CustomEvent<!CloudPrintInterfaceErrorEventDetail>} * event Contains the error message. * @private */ @@ -523,8 +552,8 @@ return; // No internet connectivity or not signed in. } this.cloudPrintErrorMessage_ = event.detail.message; - this.error_ = print_preview.Error.CLOUD_PRINT_ERROR; - this.$.state.transitTo(print_preview.State.FATAL_ERROR); + this.error_ = Error.CLOUD_PRINT_ERROR; + this.$.state.transitTo(State.FATAL_ERROR); if (event.detail.status == 200) { console.error( 'Google Cloud Print Error: ' + @@ -540,7 +569,7 @@ * Updates printing options according to source document presets. * @param {boolean} disableScaling Whether the document disables scaling. * @param {number} copies The default number of copies from the document. - * @param {!print_preview.DuplexMode} duplex The default duplex setting + * @param {!DuplexMode} duplex The default duplex setting * from the document. * @private */ @@ -553,22 +582,22 @@ this.setSetting('copies', copies, true); } - if (duplex === print_preview.DuplexMode.UNKNOWN_DUPLEX_MODE) { + if (duplex === DuplexMode.UNKNOWN_DUPLEX_MODE) { return; } if (this.getSetting('duplex').available) { this.setSetting( 'duplex', - duplex === print_preview.DuplexMode.LONG_EDGE || - duplex === print_preview.DuplexMode.SHORT_EDGE, + duplex === DuplexMode.LONG_EDGE || + duplex === DuplexMode.SHORT_EDGE, true); } - if (duplex !== print_preview.DuplexMode.SIMPLEX && + if (duplex !== DuplexMode.SIMPLEX && this.getSetting('duplexShortEdge').available) { this.setSetting( - 'duplexShortEdge', duplex === print_preview.DuplexMode.SHORT_EDGE, + 'duplexShortEdge', duplex === DuplexMode.SHORT_EDGE, true); } }, @@ -583,6 +612,6 @@ /** @private */ close_: function() { - this.$.state.transitTo(print_preview.State.CLOSING); + this.$.state.transitTo(State.CLOSING); }, });
diff --git a/chrome/browser/resources/print_preview/ui/button_strip.html b/chrome/browser/resources/print_preview/ui/button_strip.html index e6d16e5e..c896c95 100644 --- a/chrome/browser/resources/print_preview/ui/button_strip.html +++ b/chrome/browser/resources/print_preview/ui/button_strip.html
@@ -1,15 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-button-strip"> - <template> <style> :host { display: flex; @@ -48,6 +37,3 @@ $i18n{cancel} </cr-button> </if> - </template> - <script src="button_strip.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/button_strip.js b/chrome/browser/resources/print_preview/ui/button_strip.js index 971a6c3e..83153db 100644 --- a/chrome/browser/resources/print_preview/ui/button_strip.js +++ b/chrome/browser/resources/print_preview/ui/button_strip.js
@@ -2,16 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {Destination} from '../data/destination.js'; +import {State} from '../data/state.js'; +import '../strings.m.js'; + Polymer({ is: 'print-preview-button-strip', + _template: html`{__html_template__}`, + properties: { - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, firstLoad: Boolean, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: { type: Number, observer: 'updatePrintButtonEnabled_', @@ -34,8 +44,8 @@ observers: ['updatePrintButtonLabel_(destination.id)'], - /** @private {!print_preview.State} */ - lastState_: print_preview.State.NOT_READY, + /** @private {!State} */ + lastState_: State.NOT_READY, /** @private */ onPrintClick_: function() { @@ -54,9 +64,9 @@ isPdfOrDrive_: function() { return this.destination && (this.destination.id == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || + Destination.GooglePromotedId.SAVE_AS_PDF || this.destination.id == - print_preview.Destination.GooglePromotedId.DOCS); + Destination.GooglePromotedId.DOCS); }, /** @private */ @@ -68,10 +78,10 @@ /** @private */ updatePrintButtonEnabled_: function() { switch (this.state) { - case (print_preview.State.PRINTING): + case (State.PRINTING): this.printButtonEnabled_ = false; break; - case (print_preview.State.READY): + case (State.READY): this.printButtonEnabled_ = true; if (this.firstLoad) { this.$$('cr-button.action-button').focus();
diff --git a/chrome/browser/resources/print_preview/ui/color_settings.html b/chrome/browser/resources/print_preview/ui/color_settings.html index 030305a..3cc4a72 100644 --- a/chrome/browser/resources/print_preview/ui/color_settings.html +++ b/chrome/browser/resources/print_preview/ui/color_settings.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-color-settings"> - <template> <style include="print-preview-shared md-select"> </style> <print-preview-settings-section> @@ -20,6 +11,3 @@ </select> </div> </print-preview-settings-section> - </template> - <script src="color_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/color_settings.js b/chrome/browser/resources/print_preview/ui/color_settings.js index 53f65ff..d9ba54a 100644 --- a/chrome/browser/resources/print_preview/ui/color_settings.js +++ b/chrome/browser/resources/print_preview/ui/color_settings.js
@@ -2,10 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-color-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { disabled: Boolean,
diff --git a/chrome/browser/resources/print_preview/ui/copies_settings.html b/chrome/browser/resources/print_preview/ui/copies_settings.html index c8ecb08..17be19c9 100644 --- a/chrome/browser/resources/print_preview/ui/copies_settings.html +++ b/chrome/browser/resources/print_preview/ui/copies_settings.html
@@ -1,12 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="number_settings_section.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> - -<dom-module id="print-preview-copies-settings"> - <template> <style include="print-preview-shared"> #collate { margin-inline-start: 16px; @@ -25,6 +17,3 @@ </cr-checkbox> </div> </print-preview-number-settings-section> - </template> - <script src="copies_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/copies_settings.js b/chrome/browser/resources/print_preview/ui/copies_settings.js index fad6d800..5a33dd5 100644 --- a/chrome/browser/resources/print_preview/ui/copies_settings.js +++ b/chrome/browser/resources/print_preview/ui/copies_settings.js
@@ -2,9 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js'; +import './number_settings_section.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; + Polymer({ is: 'print-preview-copies-settings', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior], properties: {
diff --git a/chrome/browser/resources/print_preview/ui/destination_dialog.html b/chrome/browser/resources/print_preview/ui/destination_dialog.html index a9f9176..60015582 100644 --- a/chrome/browser/resources/print_preview/ui/destination_dialog.html +++ b/chrome/browser/resources/print_preview/ui/destination_dialog.html
@@ -1,39 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<!-- The imports below are needed as an action-link is added to the promo-text - div to create the cloud print "Sign in" link when this element is - attached. --> -<link rel="import" href="chrome://resources/html/action_link.html"> -<link rel="import" href="chrome://resources/cr_elements/action_link_css.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="icons.html"> -<link rel="import" href="../metrics.html"> -<link rel="import" href="../native_layer.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/destination_store.html"> -<link rel="import" href="../data/invitation.html"> -<link rel="import" href="../data/invitation_store.html"> -<link rel="import" href="destination_list.html"> -<link rel="import" href="print_preview_search_box.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="provisional_destination_resolver.html"> -<link rel="import" href="strings.html"> -<link rel="import" href="throbber_css.html"> - -<dom-module id="print-preview-destination-dialog"> - <template> <style include="print-preview-shared action-link md-select cr-hidden-style throbber"> #dialog::part(dialog) { @@ -216,6 +181,3 @@ </div> </div> </cr-dialog> - </template> - <script src="destination_dialog.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/destination_dialog.js b/chrome/browser/resources/print_preview/ui/destination_dialog.js index 06dabe38..e4a2b99 100644 --- a/chrome/browser/resources/print_preview/ui/destination_dialog.js +++ b/chrome/browser/resources/print_preview/ui/destination_dialog.js
@@ -2,19 +2,52 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html, beforeNextRender} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; +import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js'; +import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/icons.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/js/action_link.js'; +import 'chrome://resources/cr_elements/action_link_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {ListPropertyUpdateBehavior} from 'chrome://resources/js/list_property_update_behavior.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; +import './icons.js'; +import {Metrics, MetricsContext} from '../metrics.js'; +import {NativeLayer} from '../native_layer.js'; +import '../print_preview_utils.js'; +import {Destination} from '../data/destination.js'; +import {DestinationStore} from '../data/destination_store.js'; +import {Invitation} from '../data/invitation.js'; +import {InvitationStore} from '../data/invitation_store.js'; +import './destination_list.js'; +import './print_preview_search_box.js'; +import './print_preview_shared_css.js'; +import './print_preview_vars_css.js'; +import './provisional_destination_resolver.js'; +import '../strings.m.js'; +import './throbber_css.js'; + Polymer({ is: 'print-preview-destination-dialog', + _template: html`{__html_template__}`, + behaviors: [I18nBehavior, ListPropertyUpdateBehavior], properties: { - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ destinationStore: { type: Object, observer: 'onDestinationStoreSet_', }, - /** @type {?print_preview.InvitationStore} */ + /** @type {?InvitationStore} */ invitationStore: { type: Object, observer: 'onInvitationStoreSet_', @@ -30,7 +63,7 @@ /** @type {!Array<string>} */ users: Array, - /** @private {?print_preview.Invitation} */ + /** @private {?Invitation} */ invitation_: { type: Object, value: null, @@ -44,7 +77,7 @@ value: false, }, - /** @private {!Array<!print_preview.Destination>} */ + /** @private {!Array<!Destination>} */ destinations_: { type: Array, value: [], @@ -78,11 +111,11 @@ /** @private {!EventTracker} */ tracker_: new EventTracker(), - /** @private {!print_preview.MetricsContext} */ - metrics_: print_preview.MetricsContext.destinationSearch(), + /** @private {!MetricsContext} */ + metrics_: MetricsContext.destinationSearch(), // <if expr="chromeos"> - /** @private {?print_preview.Destination} */ + /** @private {?Destination} */ destinationInConfiguring_: null, // </if> @@ -134,11 +167,11 @@ const destinationStore = assert(this.destinationStore); this.tracker_.add( destinationStore, - print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED, + DestinationStore.EventType.DESTINATIONS_INSERTED, this.updateDestinations_.bind(this)); this.tracker_.add( destinationStore, - print_preview.DestinationStore.EventType.DESTINATION_SEARCH_DONE, + DestinationStore.EventType.DESTINATION_SEARCH_DONE, this.updateDestinationsAndInvitations_.bind(this)); this.initialized_ = true; }, @@ -148,11 +181,11 @@ const invitationStore = assert(this.invitationStore); this.tracker_.add( invitationStore, - print_preview.InvitationStore.EventType.INVITATION_SEARCH_DONE, + InvitationStore.EventType.INVITATION_SEARCH_DONE, this.updateInvitations_.bind(this)); this.tracker_.add( invitationStore, - print_preview.InvitationStore.EventType.INVITATION_PROCESSED, + InvitationStore.EventType.INVITATION_PROCESSED, this.updateInvitations_.bind(this)); }, @@ -198,9 +231,9 @@ } const cancelled = this.$.dialog.getNative().returnValue !== 'success'; this.metrics_.record( - cancelled ? print_preview.Metrics.DestinationSearchBucket + cancelled ? Metrics.DestinationSearchBucket .DESTINATION_CLOSED_UNCHANGED : - print_preview.Metrics.DestinationSearchBucket + Metrics.DestinationSearchBucket .DESTINATION_CLOSED_CHANGED); if (this.currentDestinationAccount && this.currentDestinationAccount !== this.activeUser) { @@ -277,7 +310,7 @@ }, /** - * @param {!print_preview.Destination} destination The destination to select. + * @param {!Destination} destination The destination to select. * @private */ selectDestination_: function(destination) { @@ -290,9 +323,9 @@ this.loadingDestinations_ = this.destinationStore === undefined || this.destinationStore.isPrintDestinationSearchInProgress; this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.DESTINATION_SHOWN); + Metrics.DestinationSearchBucket.DESTINATION_SHOWN); if (this.activeUser) { - Polymer.RenderStatus.beforeNextRender(assert(this.$$('select')), () => { + beforeNextRender(assert(this.$$('select')), () => { this.$$('select').value = this.activeUser; }); } @@ -307,8 +340,8 @@ /** @private */ onSignInClick_: function() { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.SIGNIN_TRIGGERED); - print_preview.NativeLayer.getInstance().signIn(false); + Metrics.DestinationSearchBucket.SIGNIN_TRIGGERED); + NativeLayer.getInstance().signIn(false); }, /** @private */ @@ -326,7 +359,7 @@ []; if (this.invitation_ != invitations[0]) { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.INVITATION_AVAILABLE); + Metrics.DestinationSearchBucket.INVITATION_AVAILABLE); } this.invitation_ = invitations.length > 0 ? invitations[0] : null; }, @@ -373,7 +406,7 @@ /** @private */ onInvitationAcceptClick_: function() { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED); + Metrics.DestinationSearchBucket.INVITATION_ACCEPTED); this.invitationStore.processInvitation(assert(this.invitation_), true); this.updateInvitations_(); }, @@ -381,7 +414,7 @@ /** @private */ onInvitationRejectClick_: function() { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED); + Metrics.DestinationSearchBucket.INVITATION_REJECTED); this.invitationStore.processInvitation(assert(this.invitation_), false); this.updateInvitations_(); }, @@ -394,12 +427,12 @@ this.loadingDestinations_ = true; this.fire('account-change', account); this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.ACCOUNT_CHANGED); + Metrics.DestinationSearchBucket.ACCOUNT_CHANGED); } else { select.value = this.activeUser; - print_preview.NativeLayer.getInstance().signIn(true); + NativeLayer.getInstance().signIn(true); this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.ADD_ACCOUNT_SELECTED); + Metrics.DestinationSearchBucket.ADD_ACCOUNT_SELECTED); } }, @@ -416,7 +449,7 @@ onShouldShowCloudPrintPromoChanged_: function() { if (this.shouldShowCloudPrintPromo_) { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.SIGNIN_PROMPT); + Metrics.DestinationSearchBucket.SIGNIN_PROMPT); } else { // Since the sign in link/dismiss promo button is disappearing, focus the // search box. @@ -435,7 +468,7 @@ /** @private */ onOpenSettingsPrintPage_: function() { this.metrics_.record( - print_preview.Metrics.DestinationSearchBucket.MANAGE_BUTTON_CLICKED); - print_preview.NativeLayer.getInstance().openSettingsPrintPage(); + Metrics.DestinationSearchBucket.MANAGE_BUTTON_CLICKED); + NativeLayer.getInstance().openSettingsPrintPage(); }, });
diff --git a/chrome/browser/resources/print_preview/ui/destination_list.html b/chrome/browser/resources/print_preview/ui/destination_list.html index 9191f1ca..e62d64b4 100644 --- a/chrome/browser/resources/print_preview/ui/destination_list.html +++ b/chrome/browser/resources/print_preview/ui/destination_list.html
@@ -1,17 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/list_property_update_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="destination_list_item.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> -<link rel="import" href="throbber_css.html"> - -<dom-module id="print-preview-destination-list"> - <template> <style include="cr-hidden-style throbber"> :host { display: flex; @@ -78,7 +65,3 @@ <div class="throbber-container" hidden$="[[throbberHidden_]]"> <div class="throbber"></div> </div> - </template> - <script src="destination_list.js"></script> -</dom-module> -
diff --git a/chrome/browser/resources/print_preview/ui/destination_list.js b/chrome/browser/resources/print_preview/ui/destination_list.js index c513269..f31466a 100644 --- a/chrome/browser/resources/print_preview/ui/destination_list.js +++ b/chrome/browser/resources/print_preview/ui/destination_list.js
@@ -2,16 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function() { -'use strict'; +import {Polymer, html, afterNextRender} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {ListPropertyUpdateBehavior} from 'chrome://resources/js/list_property_update_behavior.m.js'; +import 'chrome://resources/polymer/v3_0/iron-list/iron-list.js'; +import {Destination} from '../data/destination.js'; +import './destination_list_item.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; +import './throbber_css.js'; Polymer({ is: 'print-preview-destination-list', + _template: html`{__html_template__}`, + behaviors: [ListPropertyUpdateBehavior], properties: { - /** @type {Array<!print_preview.Destination>} */ + /** @type {Array<!Destination>} */ destinations: Array, /** @type {?RegExp} */ @@ -25,7 +35,7 @@ listName: String, - /** @private {!Array<!print_preview.Destination>} */ + /** @private {!Array<!Destination>} */ matchingDestinations_: { type: Array, value: () => [], @@ -115,9 +125,8 @@ this.throbberHidden_ = maxDisplayedItems <= this.matchingDestinations_.length; } - Polymer.RenderStatus.afterNextRender(this, () => { + afterNextRender(this, () => { this.forceIronResize(); }); } }); -})();
diff --git a/chrome/browser/resources/print_preview/ui/destination_list_item.html b/chrome/browser/resources/print_preview/ui/destination_list_item.html index 2a98fe8f..93e347d 100644 --- a/chrome/browser/resources/print_preview/ui/destination_list_item.html +++ b/chrome/browser/resources/print_preview/ui/destination_list_item.html
@@ -1,19 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="icons.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="highlight_utils.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-destination-list-item"> - <template> <style include="cr-hidden-style"> :host { align-items: center; @@ -118,6 +103,3 @@ $i18n{configuringFailedText} </span> </if> - </template> - <script src="destination_list_item.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/destination_list_item.js b/chrome/browser/resources/print_preview/ui/destination_list_item.js index f3bc722..d36f90b 100644 --- a/chrome/browser/resources/print_preview/ui/destination_list_item.js +++ b/chrome/browser/resources/print_preview/ui/destination_list_item.js
@@ -2,11 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/icons.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {removeHighlights} from 'chrome://resources/js/search_highlight_utils.m.js'; +import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; +import './icons.js'; +import {Destination, DestinationOrigin} from '../data/destination.js'; +import {HighlightResults, updateHighlights} from './highlight_utils.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; // <if expr="chromeos"> /** @enum {number} */ -print_preview.DestinationConfigStatus = { +const DestinationConfigStatus = { IDLE: 0, IN_PROGRESS: 1, FAILED: 2, @@ -16,8 +28,10 @@ Polymer({ is: 'print-preview-destination-list-item', + _template: html`{__html_template__}`, + properties: { - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, /** @type {?RegExp} */ @@ -33,10 +47,10 @@ searchHint_: String, // <if expr="chromeos"> - /** @private {!print_preview.DestinationConfigStatus} */ + /** @private {!DestinationConfigStatus} */ configurationStatus_: { type: Number, - value: print_preview.DestinationConfigStatus.IDLE, + value: DestinationConfigStatus.IDLE, }, /** @@ -45,7 +59,7 @@ */ statusEnum_: { type: Object, - value: print_preview.DestinationConfigStatus, + value: DestinationConfigStatus, }, // </if> }, @@ -82,10 +96,10 @@ onConfigureRequestAccepted: function() { // It must be a Chrome OS CUPS printer which hasn't been set up before. assert( - this.destination.origin == print_preview.DestinationOrigin.CROS && + this.destination.origin == DestinationOrigin.CROS && !this.destination.capabilities); this.configurationStatus_ = - print_preview.DestinationConfigStatus.IN_PROGRESS; + DestinationConfigStatus.IN_PROGRESS; }, /** @@ -94,12 +108,12 @@ */ onConfigureComplete: function(success) { this.configurationStatus_ = success ? - print_preview.DestinationConfigStatus.IDLE : - print_preview.DestinationConfigStatus.FAILED; + DestinationConfigStatus.IDLE : + DestinationConfigStatus.FAILED; }, /** - * @param {!print_preview.DestinationConfigStatus} status + * @param {!DestinationConfigStatus} status * @return {boolean} Whether the current configuration status is |status|. * @private */ @@ -111,7 +125,7 @@ /** @private */ updateHighlightsAndHint_: function() { this.updateSearchHint_(); - cr.search_highlight_utils.removeHighlights(this.highlights_); + removeHighlights(this.highlights_); this.highlights_ = this.updateHighlighting_().highlights; }, @@ -127,12 +141,12 @@ }, /** - * @return {!print_preview.HighlightResults} The highlight wrappers and + * @return {!HighlightResults} The highlight wrappers and * search bubbles that were created. * @private */ updateHighlighting_: function() { - return print_preview.updateHighlights(this, this.searchQuery); + return updateHighlights(this, this.searchQuery); }, /**
diff --git a/chrome/browser/resources/print_preview/ui/destination_select.html b/chrome/browser/resources/print_preview/ui/destination_select.html index 7824a9f..a1b5444 100644 --- a/chrome/browser/resources/print_preview/ui/destination_select.html +++ b/chrome/browser/resources/print_preview/ui/destination_select.html
@@ -1,21 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-meta/iron-meta.html"> -<link rel="import" href="icons.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-destination-select"> - <template> <style include="print-preview-shared md-select cr-hidden-style"> :host { --printer-icon-side-padding: 4px; @@ -62,6 +45,3 @@ $i18n{seeMore} </option> </select> - </template> - <script src="destination_select.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/destination_select.js b/chrome/browser/resources/print_preview/ui/destination_select.js index 5dc16ae8..26e6548b 100644 --- a/chrome/browser/resources/print_preview/ui/destination_select.js +++ b/chrome/browser/resources/print_preview/ui/destination_select.js
@@ -2,10 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html, Base} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import 'chrome://resources/js/util.m.js'; +import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js'; +import 'chrome://resources/polymer/v3_0/iron-meta/iron-meta.js'; +import './icons.js'; +import {getSelectDropdownBackground} from '../print_preview_utils.js'; +import {createDestinationKey, createRecentDestinationKey, Destination, DestinationOrigin, RecentDestination} from '../data/destination.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import '../strings.m.js'; + Polymer({ is: 'print-preview-destination-select', - behaviors: [I18nBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [I18nBehavior, SelectBehavior], properties: { activeUser: String, @@ -14,20 +31,20 @@ dark: Boolean, - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, disabled: Boolean, noDestinations: Boolean, - /** @type {!Array<!print_preview.RecentDestination>} */ + /** @type {!Array<!RecentDestination>} */ recentDestinationList: Array, }, /** @private {!IronMetaElement} */ meta_: /** @type {!IronMetaElement} */ ( - Polymer.Base.create('iron-meta', {type: 'iconset'})), + Base.create('iron-meta', {type: 'iconset'})), focus: function() { this.$$('.md-select').focus(); @@ -43,9 +60,9 @@ * @private */ getPdfDestinationKey_: function() { - return print_preview.createDestinationKey( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, - print_preview.DestinationOrigin.LOCAL, ''); + return createDestinationKey( + Destination.GooglePromotedId.SAVE_AS_PDF, + DestinationOrigin.LOCAL, ''); }, /** @@ -53,9 +70,9 @@ * @private */ getGoogleDriveDestinationKey_: function() { - return print_preview.createDestinationKey( - print_preview.Destination.GooglePromotedId.DOCS, - print_preview.DestinationOrigin.COOKIES, this.activeUser); + return createDestinationKey( + Destination.GooglePromotedId.DOCS, + DestinationOrigin.COOKIES, this.activeUser); }, /** @@ -78,17 +95,17 @@ // Check for the Docs or Save as PDF ids first. const keyParams = this.selectedValue.split('/'); - if (keyParams[0] === print_preview.Destination.GooglePromotedId.DOCS) { + if (keyParams[0] === Destination.GooglePromotedId.DOCS) { return 'print-preview:save-to-drive'; } if (keyParams[0] === - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { + Destination.GooglePromotedId.SAVE_AS_PDF) { return 'cr:insert-drive-file'; } // Otherwise, must be in the recent list. const recent = this.recentDestinationList.find(d => { - return print_preview.createRecentDestinationKey(d) === this.selectedValue; + return createRecentDestinationKey(d) === this.selectedValue; }); if (recent && recent.icon) { return recent.icon; @@ -123,17 +140,16 @@ return getSelectDropdownBackground(iconset, iconSetAndIcon[1], this); }, - /** @private */ onProcessSelectChange: function(value) { this.fire('selected-option-change', value); }, /** - * @param {!print_preview.RecentDestination} recentDestination + * @param {!RecentDestination} recentDestination * @return {string} Key for the recent destination * @private */ getKey_: function(recentDestination) { - return print_preview.createRecentDestinationKey(recentDestination); + return createRecentDestinationKey(recentDestination); }, });
diff --git a/chrome/browser/resources/print_preview/ui/destination_settings.html b/chrome/browser/resources/print_preview/ui/destination_settings.html index 96c34177..e84ffe397 100644 --- a/chrome/browser/resources/print_preview/ui/destination_settings.html +++ b/chrome/browser/resources/print_preview/ui/destination_settings.html
@@ -1,29 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../cloud_print_interface.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/destination_store.html"> -<link rel="import" href="../data/invitation_store.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="../data/user_manager.html"> -<link rel="import" href="destination_dialog.html"> -<link rel="import" href="destination_select.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="throbber_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-destination-settings"> - <template> <style include="print-preview-shared throbber cr-hidden-style"> <if expr="chromeos"> :host([has-pin-setting_]) { @@ -105,6 +80,3 @@ </print-preview-destination-dialog> </template> </cr-lazy-render> - </template> - <script src="destination_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/destination_settings.js b/chrome/browser/resources/print_preview/ui/destination_settings.js index 390fad8..0e8861c 100644 --- a/chrome/browser/resources/print_preview/ui/destination_settings.js +++ b/chrome/browser/resources/print_preview/ui/destination_settings.js
@@ -2,11 +2,31 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {Polymer, html, beforeNextRender} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {CloudPrintInterface} from '../cloud_print_interface.js'; +import {createRecentDestinationKey, Destination, DestinationOrigin, makeRecentDestination, RecentDestination} from '../data/destination.js'; +import {DestinationErrorType, DestinationStore} from '../data/destination_store.js'; +import {InvitationStore} from '../data/invitation_store.js'; +import {Error, State} from '../data/state.js'; +import '../data/user_manager.js'; +import './destination_dialog.js'; +import './destination_select.js'; +import './print_preview_shared_css.js'; +import './print_preview_vars_css.js'; +import './throbber_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; +import '../strings.m.js'; /** @enum {number} */ - const DestinationState = { + export const DestinationState = { INIT: 0, SELECTED: 1, SET: 2, @@ -20,6 +40,8 @@ Polymer({ is: 'print-preview-destination-settings', + _template: html`{__html_template__}`, + behaviors: [ I18nBehavior, SettingsBehavior, @@ -29,7 +51,7 @@ properties: { appKioskMode: Boolean, - /** @type {cloudprint.CloudPrintInterface} */ + /** @type {CloudPrintInterface} */ cloudPrintInterface: { type: Object, observer: 'onCloudPrintInterfaceSet_', @@ -37,14 +59,14 @@ dark: Boolean, - /** @type {?print_preview.Destination} */ + /** @type {?Destination} */ destination: { type: Object, notify: true, value: null, }, - /** @private {!print_preview.DestinationState} */ + /** @private {!DestinationState} */ destinationState: { type: Number, notify: true, @@ -54,7 +76,7 @@ disabled: Boolean, - /** @type {!print_preview.Error} */ + /** @type {!Error} */ error: { type: Number, notify: true, @@ -63,7 +85,7 @@ firstLoad: Boolean, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: Number, /** @private {string} */ @@ -75,13 +97,13 @@ /** @private {boolean} */ cloudPrintDisabled_: Boolean, - /** @private {?print_preview.DestinationStore} */ + /** @private {?DestinationStore} */ destinationStore_: { type: Object, value: null, }, - /** @private {!Array<!print_preview.RecentDestination>} */ + /** @private {!Array<!RecentDestination>} */ displayedDestinations_: Array, // <if expr="chromeos"> @@ -92,7 +114,7 @@ }, // </if> - /** @private {?print_preview.InvitationStore} */ + /** @private {?InvitationStore} */ invitationStore_: { type: Object, value: null, @@ -135,20 +157,20 @@ /** @override */ attached: function() { this.destinationStore_ = - new print_preview.DestinationStore(this.addWebUIListener.bind(this)); - this.invitationStore_ = new print_preview.InvitationStore(); + new DestinationStore(this.addWebUIListener.bind(this)); + this.invitationStore_ = new InvitationStore(); this.tracker_.add( this.destinationStore_, - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + DestinationStore.EventType.DESTINATION_SELECT, this.onDestinationSelect_.bind(this)); this.tracker_.add( this.destinationStore_, - print_preview.DestinationStore.EventType + DestinationStore.EventType .SELECTED_DESTINATION_CAPABILITIES_READY, this.onDestinationCapabilitiesReady_.bind(this)); this.tracker_.add( this.destinationStore_, - print_preview.DestinationStore.EventType.ERROR, + DestinationStore.EventType.ERROR, this.onDestinationError_.bind(this)); // Need to update the recent list when the destination store inserts // destinations, in case any recent destinations have been added to the @@ -157,7 +179,7 @@ // fetched by the DestinationStore, to ensure that they still exist. this.tracker_.add( assert(this.destinationStore_), - print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED, + DestinationStore.EventType.DESTINATIONS_INSERTED, this.updateDropdownDestinations_.bind(this)); }, @@ -185,7 +207,7 @@ } if (!this.destination || - this.destination.origin !== print_preview.DestinationOrigin.COOKIES) { + this.destination.origin !== DestinationOrigin.COOKIES) { // Active user changing doesn't impact non-cookie based destinations. return; } @@ -213,12 +235,12 @@ // the most recent destination associated with the new account, or the // default. const recent = this.displayedDestinations_.find(d => { - return d.origin !== print_preview.DestinationOrigin.COOKIES || + return d.origin !== DestinationOrigin.COOKIES || d.account === this.activeUser_; }); if (recent) { const success = this.destinationStore_.selectRecentDestinationByKey( - print_preview.createRecentDestinationKey(recent), + createRecentDestinationKey(recent), this.displayedDestinations_); if (success) { return; @@ -243,7 +265,7 @@ this.destinationStore_.init( this.appKioskMode, defaultPrinter, serializedDefaultDestinationRulesStr, - /** @type {!Array<print_preview.RecentDestination>} */ + /** @type {!Array<RecentDestination>} */ (this.getSettingValue('recentDestinations'))); }, @@ -255,14 +277,14 @@ this.updateDropdownDestinations_(); } - if (this.state === print_preview.State.FATAL_ERROR) { + if (this.state === State.FATAL_ERROR) { // Don't let anything reset if there is a fatal error. return; } const destination = this.destinationStore_.selectedDestination; if (!!this.activeUser_ || - destination.origin !== print_preview.DestinationOrigin.COOKIES) { + destination.origin !== DestinationOrigin.COOKIES) { this.destinationState = DestinationState.SET; } else { this.destinationState = DestinationState.SELECTED; @@ -283,21 +305,21 @@ }, /** - * @param {!CustomEvent<!print_preview.DestinationErrorType>} e + * @param {!CustomEvent<!DestinationErrorType>} e * @private */ onDestinationError_: function(e) { - let errorType = print_preview.Error.NONE; + let errorType = Error.NONE; switch (e.detail) { - case print_preview.DestinationErrorType.INVALID: - errorType = print_preview.Error.INVALID_PRINTER; + case DestinationErrorType.INVALID: + errorType = Error.INVALID_PRINTER; break; - case print_preview.DestinationErrorType.UNSUPPORTED: - errorType = print_preview.Error.UNSUPPORTED_PRINTER; + case DestinationErrorType.UNSUPPORTED: + errorType = Error.UNSUPPORTED_PRINTER; break; // <if expr="chromeos"> - case print_preview.DestinationErrorType.NO_DESTINATIONS: - errorType = print_preview.Error.NO_DESTINATIONS; + case DestinationErrorType.NO_DESTINATIONS: + errorType = Error.NO_DESTINATIONS; this.noDestinations_ = true; break; // </if> @@ -309,22 +331,22 @@ /** @private */ onErrorChanged_: function() { - if (this.error == print_preview.Error.INVALID_PRINTER || - this.error == print_preview.Error.UNSUPPORTED_PRINTER || - this.error == print_preview.Error.NO_DESTINATIONS) { + if (this.error == Error.INVALID_PRINTER || + this.error == Error.UNSUPPORTED_PRINTER || + this.error == Error.NO_DESTINATIONS) { this.destinationState = DestinationState.ERROR; } }, /** - * @param {!print_preview.RecentDestination} destination + * @param {!RecentDestination} destination * @return {boolean} Whether the destination is Save as PDF or Save to * Drive. */ destinationIsDriveOrPdf_: function(destination) { return destination.id === - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || - destination.id === print_preview.Destination.GooglePromotedId.DOCS; + Destination.GooglePromotedId.SAVE_AS_PDF || + destination.id === Destination.GooglePromotedId.DOCS; }, /** @private */ @@ -336,9 +358,9 @@ // Determine if this destination is already in the recent destinations, // and where in the array it is located. const newDestination = - print_preview.makeRecentDestination(assert(this.destination)); + makeRecentDestination(assert(this.destination)); const recentDestinations = - /** @type {!Array<!print_preview.RecentDestination>} */ ( + /** @type {!Array<!RecentDestination>} */ ( this.getSettingValue('recentDestinations')); let indexFound = recentDestinations.findIndex(function(recent) { return ( @@ -372,11 +394,11 @@ /** @private */ updateDropdownDestinations_: function() { this.displayedDestinations_ = - /** @type {!Array<!print_preview.RecentDestination>} */ ( + /** @type {!Array<!RecentDestination>} */ ( this.getSettingValue('recentDestinations')) .filter(d => { return !this.destinationIsDriveOrPdf_(d) && - (d.origin !== print_preview.DestinationOrigin.COOKIES || + (d.origin !== DestinationOrigin.COOKIES || d.account === this.activeUser_); }); }, @@ -386,9 +408,9 @@ * @private */ shouldDisableDropdown_: function() { - return this.state === print_preview.State.FATAL_ERROR || + return this.state === State.FATAL_ERROR || (this.destinationState === DestinationState.UPDATED && - this.disabled && this.state !== print_preview.State.NOT_READY); + this.disabled && this.state !== State.NOT_READY); }, /** @private */ @@ -399,7 +421,7 @@ !!this.destination && (!!this.destination.capabilities || this.destination.id === - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF)); + Destination.GooglePromotedId.SAVE_AS_PDF)); }, /** @@ -446,7 +468,7 @@ const success = this.destinationStore_.selectRecentDestinationByKey( value, this.displayedDestinations_); if (!success) { - this.error = print_preview.Error.INVALID_PRINTER; + this.error = Error.INVALID_PRINTER; } } }, @@ -487,7 +509,7 @@ const shouldFocus = this.destinationState !== DestinationState.SET && !this.firstLoad; - Polymer.RenderStatus.beforeNextRender(this.$.destinationSelect, () => { + beforeNextRender(this.$.destinationSelect, () => { this.$.destinationSelect.updateDestination(); if (shouldFocus) { this.$.destinationSelect.focus(); @@ -496,7 +518,3 @@ }, }); - return { - DestinationState: DestinationState, - }; -});
diff --git a/chrome/browser/resources/print_preview/ui/dpi_settings.html b/chrome/browser/resources/print_preview/ui/dpi_settings.html index a9c68bbe..c8399fa 100644 --- a/chrome/browser/resources/print_preview/ui/dpi_settings.html +++ b/chrome/browser/resources/print_preview/ui/dpi_settings.html
@@ -1,14 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> -<link rel="import" href="settings_select.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-dpi-settings"> - <template> <style include="print-preview-shared"> :host print-preview-settings-select { margin: 0 calc(var(--print-preview-sidebar-margin) - 2px); @@ -23,6 +13,3 @@ </print-preview-settings-select> </div> </print-preview-settings-section> - </template> - <script src="dpi_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/dpi_settings.js b/chrome/browser/resources/print_preview/ui/dpi_settings.js index 932335c3..c2a0943 100644 --- a/chrome/browser/resources/print_preview/ui/dpi_settings.js +++ b/chrome/browser/resources/print_preview/ui/dpi_settings.js
@@ -2,7 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; +import {SelectOption} from './settings_select.js'; +import '../strings.m.js'; /** * @typedef {{ @@ -10,7 +17,7 @@ * vertical_dpi: (number | undefined), * vendor_id: (number | undefined)}} */ -print_preview.DpiOption; +let DpiOption; /** * @typedef {{ @@ -19,20 +26,22 @@ * vertical_dpi: (number | undefined), * vendor_id: (number | undefined)}} */ -print_preview.LabelledDpiOption; +let LabelledDpiOption; + Polymer({ + _template: html`{__html_template__}`, is: 'print-preview-dpi-settings', behaviors: [SettingsBehavior], properties: { - /** @type {{ option: Array<!print_preview.SelectOption> }} */ + /** @type {{ option: Array<!SelectOption> }} */ capability: Object, disabled: Boolean, - /** @private {{ option: Array<!print_preview.SelectOption> }} */ + /** @private {{ option: Array<!SelectOption> }} */ capabilityWithLabels_: { type: Object, computed: 'computeCapabilityWithLabels_(capability)', @@ -45,7 +54,7 @@ /** * Adds default labels for each option. - * @return {?{option: Array<!print_preview.SelectOption>}} + * @return {?{option: Array<!SelectOption>}} * @private */ computeCapabilityWithLabels_: function() { @@ -54,10 +63,10 @@ } const result = - /** @type {{option: Array<!print_preview.SelectOption>}} */ ( + /** @type {{option: Array<!SelectOption>}} */ ( JSON.parse(JSON.stringify(this.capability))); this.capability.option.forEach((option, index) => { - const dpiOption = /** @type {print_preview.DpiOption} */ (option); + const dpiOption = /** @type {DpiOption} */ (option); const hDpi = dpiOption.horizontal_dpi || 0; const vDpi = dpiOption.vertical_dpi || 0; if (hDpi > 0 && vDpi > 0 && hDpi != vDpi) { @@ -80,10 +89,10 @@ } const dpiValue = - /** @type {print_preview.DpiOption} */ (this.getSettingValue('dpi')); + /** @type {DpiOption} */ (this.getSettingValue('dpi')); for (const option of assert(this.capabilityWithLabels_.option)) { const dpiOption = - /** @type {print_preview.LabelledDpiOption} */ (option); + /** @type {LabelledDpiOption} */ (option); if (dpiValue.horizontal_dpi == dpiOption.horizontal_dpi && dpiValue.vertical_dpi == dpiOption.vertical_dpi && dpiValue.vendor_id == dpiOption.vendor_id) {
diff --git a/chrome/browser/resources/print_preview/ui/duplex_settings.html b/chrome/browser/resources/print_preview/ui/duplex_settings.html index c1393ed..6c2ef907 100644 --- a/chrome/browser/resources/print_preview/ui/duplex_settings.html +++ b/chrome/browser/resources/print_preview/ui/duplex_settings.html
@@ -1,20 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-meta/iron-meta.html"> -<link rel="import" href="icons.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-duplex-settings"> - <template> <style include="print-preview-shared cr-hidden-style md-select"> :host { --duplex-icon-side-padding: 8px; @@ -66,6 +50,3 @@ </div> </print-preview-settings-section> </iron-collapse> - </template> - <script src="duplex_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/duplex_settings.js b/chrome/browser/resources/print_preview/ui/duplex_settings.js index 22b0820..cf44c40 100644 --- a/chrome/browser/resources/print_preview/ui/duplex_settings.js +++ b/chrome/browser/resources/print_preview/ui/duplex_settings.js
@@ -2,10 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html, Base} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js'; +import 'chrome://resources/polymer/v3_0/iron-meta/iron-meta.js'; +import './icons.js'; +import {DuplexMode} from '../data/model.js'; +import {getSelectDropdownBackground} from '../print_preview_utils.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-duplex-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { dark: Boolean, @@ -18,7 +34,7 @@ */ duplexValueEnum_: { type: Object, - value: print_preview.DuplexMode, + value: DuplexMode, }, }, @@ -29,7 +45,7 @@ /** @private {!IronMetaElement} */ meta_: /** @type {!IronMetaElement} */ ( - Polymer.Base.create('iron-meta', {type: 'iconset'})), + Base.create('iron-meta', {type: 'iconset'})), /** @private */ onDuplexSettingChange_: function() {
diff --git a/chrome/browser/resources/print_preview/ui/header.html b/chrome/browser/resources/print_preview/ui/header.html index b26a992..47a09aa 100644 --- a/chrome/browser/resources/print_preview/ui/header.html +++ b/chrome/browser/resources/print_preview/ui/header.html
@@ -1,17 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="icons.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-header"> - <template> <style> :host { align-items: center; @@ -62,6 +49,3 @@ </iron-icon> </div> <span class="summary">[[summary_]]</span> - </template> - <script src="header.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/header.js b/chrome/browser/resources/print_preview/ui/header.js index fde8d0bd..c9a59d1f 100644 --- a/chrome/browser/resources/print_preview/ui/header.js +++ b/chrome/browser/resources/print_preview/ui/header.js
@@ -2,7 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview.Header'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; +import {Destination} from '../data/destination.js'; +import {State, Error} from '../data/state.js'; +import './icons.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; /** * @typedef {{numPages: number, @@ -10,23 +19,25 @@ * pagesLabel: string, * summaryLabel: string}} */ -print_preview.Header.LabelInfo; +let LabelInfo; Polymer({ is: 'print-preview-header', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior], properties: { cloudPrintErrorMessage: String, - /** @type {!print_preview.Destination} */ + /** @type {!Destination} */ destination: Object, - /** @type {!print_preview.Error} */ + /** @type {!Error} */ error: Number, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: Number, managed: Boolean, @@ -50,13 +61,13 @@ isPdfOrDrive_: function() { return this.destination && (this.destination.id == - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF || + Destination.GooglePromotedId.SAVE_AS_PDF || this.destination.id == - print_preview.Destination.GooglePromotedId.DOCS); + Destination.GooglePromotedId.DOCS); }, /** - * @return {!print_preview.Header.LabelInfo} + * @return {!LabelInfo} * @private */ computeLabelInfo_: function() { @@ -93,15 +104,15 @@ /** @private */ update_: function() { switch (this.state) { - case (print_preview.State.PRINTING): + case (State.PRINTING): this.summary_ = loadTimeData.getString( this.isPdfOrDrive_() ? 'saving' : 'printing'); break; - case (print_preview.State.READY): + case (State.READY): const labelInfo = this.computeLabelInfo_(); this.summary_ = this.getSummary_(labelInfo); break; - case (print_preview.State.FATAL_ERROR): + case (State.FATAL_ERROR): this.summary_ = this.getErrorMessage_(); break; default: @@ -116,9 +127,9 @@ */ getErrorMessage_: function() { switch (this.error) { - case print_preview.Error.PRINT_FAILED: + case Error.PRINT_FAILED: return loadTimeData.getString('couldNotPrint'); - case print_preview.Error.CLOUD_PRINT_ERROR: + case Error.CLOUD_PRINT_ERROR: return this.cloudPrintErrorMessage; default: return ''; @@ -126,7 +137,7 @@ }, /** - * @param {!print_preview.Header.LabelInfo} labelInfo + * @param {!LabelInfo} labelInfo * @return {string} * @private */
diff --git a/chrome/browser/resources/print_preview/ui/highlight_utils.html b/chrome/browser/resources/print_preview/ui/highlight_utils.html deleted file mode 100644 index ad6c804..0000000 --- a/chrome/browser/resources/print_preview/ui/highlight_utils.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/search_highlight_utils.html"> - -<script src="highlight_utils.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/highlight_utils.js b/chrome/browser/resources/print_preview/ui/highlight_utils.js index 07fc9719..5bf3cba 100644 --- a/chrome/browser/resources/print_preview/ui/highlight_utils.js +++ b/chrome/browser/resources/print_preview/ui/highlight_utils.js
@@ -2,10 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - - -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {highlight, highlightControlWithBubble} from 'chrome://resources/js/search_highlight_utils.m.js'; /** * @typedef {{ @@ -13,16 +11,16 @@ * bubbles: !Array<!Node> * }} */ - let HighlightResults; + export let HighlightResults; /** * @param {!HTMLElement} element The element to update. Element should have a * shadow root. * @param {?RegExp} query The current search query - * @return {!print_preview.HighlightResults} The highlight wrappers and + * @return {!HighlightResults} The highlight wrappers and * search bubbles that were created. */ - function updateHighlights(element, query) { + export function updateHighlights(element, query) { const result = {highlights: [], bubbles: []}; if (!query) { return result; @@ -43,7 +41,7 @@ // Don't highlight <select> nodes, yellow rectangles can't be // displayed within an <option>. if (node.parentNode.nodeName != 'OPTION') { - result.highlights.push(cr.search_highlight_utils.highlight( + result.highlights.push(highlight( node, textContent.split(query))); } else { const selectNode = node.parentNode.parentNode; @@ -51,7 +49,7 @@ // Note: The bubble's ::after element, a yellow arrow, will not // appear correctly in print preview without SPv175 enabled. See // https://crbug.com/817058. - const bubble = cr.search_highlight_utils.highlightControlWithBubble( + const bubble = highlightControlWithBubble( /** @type {!HTMLElement} */ (assert(selectNode.parentNode)), textContent.match(query)[0]); if (bubble) { @@ -63,9 +61,3 @@ }); return result; } - - return { - HighlightResults: HighlightResults, - updateHighlights: updateHighlights, - }; -});
diff --git a/chrome/browser/resources/print_preview/ui/icons.html b/chrome/browser/resources/print_preview/ui/icons.html index 1f5ce331..47b84d6 100644 --- a/chrome/browser/resources/print_preview/ui/icons.html +++ b/chrome/browser/resources/print_preview/ui/icons.html
@@ -1,6 +1,3 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> <iron-iconset-svg name="print-preview" size="24"> <svg>
diff --git a/chrome/browser/resources/print_preview/ui/icons.js b/chrome/browser/resources/print_preview/ui/icons.js new file mode 100644 index 0000000..687097c84 --- /dev/null +++ b/chrome/browser/resources/print_preview/ui/icons.js
@@ -0,0 +1,8 @@ +// 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. + +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/polymer/v3_0/iron-iconset-svg/iron-iconset-svg.js'; +const template = html`{__html_template__}`; +document.head.appendChild(template.content);
diff --git a/chrome/browser/resources/print_preview/ui/input_behavior.html b/chrome/browser/resources/print_preview/ui/input_behavior.html deleted file mode 100644 index d2e0f62..0000000 --- a/chrome/browser/resources/print_preview/ui/input_behavior.html +++ /dev/null
@@ -1,3 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="input_behavior.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/input_behavior.js b/chrome/browser/resources/print_preview/ui/input_behavior.js index 016e4f2..fefb9fc 100644 --- a/chrome/browser/resources/print_preview/ui/input_behavior.js +++ b/chrome/browser/resources/print_preview/ui/input_behavior.js
@@ -2,14 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; + /** * Helper functions for an input with timeout. * @polymerBehavior */ - const InputBehavior = { + export const InputBehavior = { properties: { - /** @private */ + /** @private {?string} */ lastValue_: { type: String, value: '', @@ -42,7 +45,9 @@ * @private */ getTimeoutDelayMs_: function() { - const delay = parseInt(this.getInput().dataset.timeoutDelay, 10); + const delay = parseInt( + /** @type {{timeoutDelay: number}} */ (this.getInput().dataset) + .timeoutDelay, 10); assert(!Number.isNaN(delay)); return delay; }, @@ -99,6 +104,3 @@ this.onTimeout_(); }, }; - - return {InputBehavior: InputBehavior}; -});
diff --git a/chrome/browser/resources/print_preview/ui/layout_settings.html b/chrome/browser/resources/print_preview/ui/layout_settings.html index b3c22b2..8c25e21 100644 --- a/chrome/browser/resources/print_preview/ui/layout_settings.html +++ b/chrome/browser/resources/print_preview/ui/layout_settings.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-layout-settings"> - <template> <style include="print-preview-shared md-select"></style> <print-preview-settings-section> <span id="layout-label" slot="title">$i18n{layoutLabel}</span> @@ -19,6 +10,3 @@ </select> </div> </print-preview-settings-section> - </template> - <script src="layout_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/layout_settings.js b/chrome/browser/resources/print_preview/ui/layout_settings.js index 9d073c5..477a0b83 100644 --- a/chrome/browser/resources/print_preview/ui/layout_settings.js +++ b/chrome/browser/resources/print_preview/ui/layout_settings.js
@@ -2,10 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-layout-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { disabled: Boolean,
diff --git a/chrome/browser/resources/print_preview/ui/link_container.html b/chrome/browser/resources/print_preview/ui/link_container.html index 2f9274b..c23e589 100644 --- a/chrome/browser/resources/print_preview/ui/link_container.html +++ b/chrome/browser/resources/print_preview/ui/link_container.html
@@ -1,15 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="throbber_css.html"> - -<dom-module id="print-preview-link-container"> - <template> <style include="cr-shared-style throbber cr-hidden-style"> :host { display: block; @@ -80,6 +69,3 @@ class="throbber"></div> </div> </if> - </template> - <script src="link_container.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/link_container.js b/chrome/browser/resources/print_preview/ui/link_container.js index eb34c23..89ed02c 100644 --- a/chrome/browser/resources/print_preview/ui/link_container.js +++ b/chrome/browser/resources/print_preview/ui/link_container.js
@@ -2,13 +2,24 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_style_css.m.js'; +import {isWindows} from 'chrome://resources/js/cr.m.js'; +import {Destination, DestinationOrigin} from '../data/destination.js'; +import './print_preview_vars_css.js'; +import './throbber_css.js'; + Polymer({ is: 'print-preview-link-container', + _template: html`{__html_template__}`, + properties: { appKioskMode: Boolean, - /** @type {?print_preview.Destination} */ + /** @type {?Destination} */ destination: Object, disabled: Boolean, @@ -47,13 +58,13 @@ if (this.appKioskMode) { return false; } - if (!cr.isWindows) { + if (!isWindows) { return true; } return !!this.destination && - this.destination.origin == print_preview.DestinationOrigin.LOCAL && + this.destination.origin == DestinationOrigin.LOCAL && this.destination.id != - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF; + Destination.GooglePromotedId.SAVE_AS_PDF; }, /** @@ -61,7 +72,7 @@ * @private */ computeSystemDialogLinkDisabled_: function() { - return cr.isWindows && this.disabled; + return isWindows && this.disabled; }, /** @private */
diff --git a/chrome/browser/resources/print_preview/ui/margin_control.html b/chrome/browser/resources/print_preview/ui/margin_control.html index 2d21005..3f14030 100644 --- a/chrome/browser/resources/print_preview/ui/margin_control.html +++ b/chrome/browser/resources/print_preview/ui/margin_control.html
@@ -1,18 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input_style_css.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="../data/coordinate2d.html"> -<link rel="import" href="../data/margins.html"> -<link rel="import" href="../data/measurement_system.html"> -<link rel="import" href="../data/size.html"> -<link rel="import" href="input_behavior.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-margin-control"> - <template> <style include="cr-input-style"> :host { display: block; @@ -156,6 +142,3 @@ <div id="underline"></div> </div> </div> - </template> - <script src="margin_control.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/margin_control.js b/chrome/browser/resources/print_preview/ui/margin_control.js index 97e8f1b..2d7b2a04 100644 --- a/chrome/browser/resources/print_preview/ui/margin_control.js +++ b/chrome/browser/resources/print_preview/ui/margin_control.js
@@ -2,8 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function() { -'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input_style_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {observerDepsDefined} from '../print_preview_utils.js'; +import {Coordinate2d} from '../data/coordinate2d.js'; +import {CustomMarginsOrientation} from '../data/margins.js'; +import {MeasurementSystem} from '../data/measurement_system.js'; +import {Size} from '../data/size.js'; +import {InputBehavior} from './input_behavior.js'; +import '../strings.m.js'; /** * Radius of the margin control in pixels. Padding of control + 1 for border. @@ -14,7 +24,9 @@ Polymer({ is: 'print-preview-margin-control', - behaviors: [print_preview.InputBehavior, I18nBehavior], + _template: html`{__html_template__}`, + + behaviors: [InputBehavior, I18nBehavior], properties: { disabled: { @@ -39,7 +51,7 @@ observer: 'onClipSizeChange_', }, - /** @type {?print_preview.MeasurementSystem} */ + /** @type {?MeasurementSystem} */ measurementSystem: Object, /** @private {boolean} */ @@ -62,19 +74,19 @@ notify: true, }, - /** @type {!print_preview.Coordinate2d} */ + /** @type {!Coordinate2d} */ translateTransform: { type: Object, notify: true, }, - /** @type {!print_preview.Size} */ + /** @type {!Size} */ pageSize: { type: Object, notify: true, }, - /** @type {?print_preview.Size} */ + /** @type {?Size} */ clipSize: { type: Object, notify: true, @@ -92,7 +104,7 @@ /** @return {!HTMLInputElement} The input element for InputBehavior. */ getInput: function() { - return this.$.input; + return /** @type {!HTMLInputElement} */ (this.$.input); }, /** @@ -138,7 +150,7 @@ */ convertPixelsToPts: function(pixels) { let pts; - const Orientation = print_preview.CustomMarginsOrientation; + const Orientation = CustomMarginsOrientation; if (this.side == Orientation.TOP) { pts = pixels - this.translateTransform.y + RADIUS_PX; pts /= this.scaleTransform; @@ -253,7 +265,7 @@ return; } - const Orientation = print_preview.CustomMarginsOrientation; + const Orientation = CustomMarginsOrientation; let x = this.translateTransform.x; let y = this.translateTransform.y; let width = null; @@ -302,4 +314,3 @@ }); }, }); -})();
diff --git a/chrome/browser/resources/print_preview/ui/margin_control_container.html b/chrome/browser/resources/print_preview/ui/margin_control_container.html index fa7375b..4795306 100644 --- a/chrome/browser/resources/print_preview/ui/margin_control_container.html +++ b/chrome/browser/resources/print_preview/ui/margin_control_container.html
@@ -1,16 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/html/event_tracker.html"> -<link rel="import" href="margin_control.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="../data/coordinate2d.html"> -<link rel="import" href="../data/margins.html"> -<link rel="import" href="../data/measurement_system.html"> -<link rel="import" href="../data/size.html"> -<link rel="import" href="../data/state.html"> - -<dom-module id="print-preview-margin-control-container"> - <template> <style> :host { display: block; @@ -37,6 +25,3 @@ on-text-focus="onTextFocus_" on-transition-end="onTransitionEnd_"> </print-preview-margin-control> </template> - </template> - <script src="margin_control_container.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/margin_control_container.js b/chrome/browser/resources/print_preview/ui/margin_control_container.js index c675756..d88db42c 100644 --- a/chrome/browser/resources/print_preview/ui/margin_control_container.js +++ b/chrome/browser/resources/print_preview/ui/margin_control_container.js
@@ -2,18 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - -cr.define('print_preview', function() { - 'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {EventTracker} from 'chrome://resources/js/event_tracker.m.js'; +import './margin_control.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import {Coordinate2d} from '../data/coordinate2d.js'; +import {CustomMarginsOrientation, Margins, MarginsSetting, MarginsType} from '../data/margins.js'; +import {MeasurementSystem} from '../data/measurement_system.js'; +import {Size} from '../data/size.js'; +import {State} from '../data/state.js'; /** - * @const {!Map<!print_preview.CustomMarginsOrientation, string>} + * @const {!Map<!CustomMarginsOrientation, string>} */ - const MARGIN_KEY_MAP = new Map([ - [print_preview.CustomMarginsOrientation.TOP, 'marginTop'], - [print_preview.CustomMarginsOrientation.RIGHT, 'marginRight'], - [print_preview.CustomMarginsOrientation.BOTTOM, 'marginBottom'], - [print_preview.CustomMarginsOrientation.LEFT, 'marginLeft'] + export const MARGIN_KEY_MAP = new Map([ + [CustomMarginsOrientation.TOP, 'marginTop'], + [CustomMarginsOrientation.RIGHT, 'marginRight'], + [CustomMarginsOrientation.BOTTOM, 'marginBottom'], + [CustomMarginsOrientation.LEFT, 'marginLeft'] ]); /** @const {number} */ @@ -22,16 +29,18 @@ Polymer({ is: 'print-preview-margin-control-container', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior], properties: { - /** @type {!print_preview.Size} */ + /** @type {!Size} */ pageSize: { type: Object, notify: true, }, - /** @type {!print_preview.Margins} */ + /** @type {!Margins} */ documentMargins: { type: Object, notify: true, @@ -39,10 +48,10 @@ previewLoaded: Boolean, - /** @type {?print_preview.MeasurementSystem} */ + /** @type {?MeasurementSystem} */ measurementSystem: Object, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: { type: Number, observer: 'onStateChanged_', @@ -55,14 +64,14 @@ value: 0, }, - /** @private {!print_preview.Coordinate2d} */ + /** @private {!Coordinate2d} */ translateTransform_: { type: Object, notify: true, - value: new print_preview.Coordinate2d(0, 0), + value: new Coordinate2d(0, 0), }, - /** @private {?print_preview.Size} */ + /** @private {?Size} */ clipSize_: { type: Object, notify: true, @@ -85,16 +94,16 @@ }, /** - * @private {!Array<!print_preview.CustomMarginsOrientation>} + * @private {!Array<!CustomMarginsOrientation>} */ marginSides_: { type: Array, notify: true, value: [ - print_preview.CustomMarginsOrientation.TOP, - print_preview.CustomMarginsOrientation.RIGHT, - print_preview.CustomMarginsOrientation.BOTTOM, - print_preview.CustomMarginsOrientation.LEFT, + CustomMarginsOrientation.TOP, + CustomMarginsOrientation.RIGHT, + CustomMarginsOrientation.BOTTOM, + CustomMarginsOrientation.LEFT, ], }, @@ -121,10 +130,10 @@ 'settings.mediaSize.value, settings.layout.value)', ], - /** @private {!print_preview.Coordinate2d} */ - pointerStartPositionInPixels_: new print_preview.Coordinate2d(0, 0), + /** @private {!Coordinate2d} */ + pointerStartPositionInPixels_: new Coordinate2d(0, 0), - /** @private {?print_preview.Coordinate2d} */ + /** @private {?Coordinate2d} */ marginStartPositionInPixels_: null, /** @private {?boolean} */ @@ -136,7 +145,7 @@ */ computeAvailable_: function() { return this.previewLoaded && !!this.clipSize_ && - this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM && + this.getSettingValue('margins') == MarginsType.CUSTOM && !!this.pageSize; }, @@ -147,8 +156,8 @@ // custom margins were reset. const newMargins = {}; for (const side of Object.values( - print_preview.CustomMarginsOrientation)) { - const key = print_preview.MARGIN_KEY_MAP.get(side); + CustomMarginsOrientation)) { + const key = MARGIN_KEY_MAP.get(side); newMargins[key] = this.documentMargins.get(side); } this.setSetting('customMargins', newMargins); @@ -167,7 +176,7 @@ } this.shadowRoot.querySelectorAll('print-preview-margin-control') .forEach(control => { - const key = print_preview.MARGIN_KEY_MAP.get(control.side); + const key = MARGIN_KEY_MAP.get(control.side); const newValue = margins[key] || 0; control.setPositionInPts(newValue); control.setTextboxValue(newValue); @@ -184,9 +193,9 @@ this.resetMargins_ = true; const marginsSetting = this.getSetting('margins'); - if (marginsSetting.value == print_preview.MarginsType.CUSTOM) { + if (marginsSetting.value == MarginsType.CUSTOM) { // Set the margins value to default first. - this.setSetting('margins', print_preview.MarginsType.DEFAULT); + this.setSetting('margins', MarginsType.DEFAULT); } // Reset custom margins so that the sticky value is not restored for the // new paper size. @@ -195,7 +204,7 @@ /** @private */ onStateChanged_: function() { - if (this.state == print_preview.State.READY && + if (this.state == State.READY && this.resetMargins_ === null) { // Don't reset margins if there are sticky values. Otherwise, set them // to the document margins when the user selects custom margins. @@ -209,23 +218,23 @@ * @private */ controlsDisabled_: function() { - return this.state !== print_preview.State.READY || this.invisible_; + return this.state !== State.READY || this.invisible_; }, /** - * @param {!print_preview.CustomMarginsOrientation} orientation + * @param {!CustomMarginsOrientation} orientation * Orientation value to test. * @return {boolean} Whether the given orientation is TOP or BOTTOM. * @private */ isTopOrBottom_: function(orientation) { - return orientation == print_preview.CustomMarginsOrientation.TOP || - orientation == print_preview.CustomMarginsOrientation.BOTTOM; + return orientation == CustomMarginsOrientation.TOP || + orientation == CustomMarginsOrientation.BOTTOM; }, /** * @param {!HTMLElement} control Control being repositioned. - * @param {!print_preview.Coordinate2d} posInPixels Desired position, in + * @param {!Coordinate2d} posInPixels Desired position, in * pixels. * @return {number} The new position for the control, in pts. Returns the * position for the dimension that the control operates in, i.e. @@ -234,7 +243,7 @@ */ posInPixelsToPts_: function(control, posInPixels) { const side = - /** @type {print_preview.CustomMarginsOrientation} */ (control.side); + /** @type {CustomMarginsOrientation} */ (control.side); return this.clipAndRoundValue_( side, control.convertPixelsToPts( @@ -258,12 +267,12 @@ /** * Translates the position of the margin control relative to the pointer * position in pixels. - * @param {!print_preview.Coordinate2d} pointerPosition New position of + * @param {!Coordinate2d} pointerPosition New position of * the pointer. - * @return {!print_preview.Coordinate2d} New position of the margin control. + * @return {!Coordinate2d} New position of the margin control. */ translatePointerToPositionInPixels: function(pointerPosition) { - return new print_preview.Coordinate2d( + return new Coordinate2d( pointerPosition.x - this.pointerStartPositionInPixels_.x + this.marginStartPositionInPixels_.x, pointerPosition.y - this.pointerStartPositionInPixels_.y + @@ -282,7 +291,7 @@ const posInPts = this.posInPixelsToPts_( control, this.translatePointerToPositionInPixels( - new print_preview.Coordinate2d(event.x, event.y))); + new Coordinate2d(event.x, event.y))); this.moveControlWithConstraints_(control, posInPts); }, @@ -297,7 +306,7 @@ /** @type {!PrintPreviewMarginControlElement} */ (event.target); this.dragging_ = ''; const posInPixels = this.translatePointerToPositionInPixels( - new print_preview.Coordinate2d(event.x, event.y)); + new Coordinate2d(event.x, event.y)); const posInPts = this.posInPixelsToPts_(control, posInPixels); this.moveControlWithConstraints_(control, posInPts); this.setMargin_(control.side, posInPts); @@ -341,7 +350,7 @@ const x = control.offsetLeft; const y = control.offsetTop; const isTopOrBottom = this.isTopOrBottom_( - /** @type {!print_preview.CustomMarginsOrientation} */ ( + /** @type {!CustomMarginsOrientation} */ ( control.side)); const position = {}; // Extra padding, in px, to ensure the full textbox will be visible and @@ -387,10 +396,10 @@ */ setMargin_: function(side, marginValue) { const marginSide = - /** @type {!print_preview.CustomMarginsOrientation} */ (side); - const oldMargins = /** @type {print_preview.MarginsSetting} */ ( + /** @type {!CustomMarginsOrientation} */ (side); + const oldMargins = /** @type {MarginsSetting} */ ( this.getSettingValue('customMargins')); - const key = print_preview.MARGIN_KEY_MAP.get(marginSide); + const key = MARGIN_KEY_MAP.get(marginSide); if (oldMargins[key] == marginValue) { return; } @@ -407,11 +416,11 @@ */ clipAndRoundValue_: function(side, value) { const marginSide = - /** @type {!print_preview.CustomMarginsOrientation} */ (side); + /** @type {!CustomMarginsOrientation} */ (side); if (value < 0) { return 0; } - const Orientation = print_preview.CustomMarginsOrientation; + const Orientation = CustomMarginsOrientation; let limit = 0; const margins = this.getSettingValue('customMargins'); if (marginSide == Orientation.TOP) { @@ -469,11 +478,11 @@ } this.pointerStartPositionInPixels_ = - new print_preview.Coordinate2d(e.x, e.y); + new Coordinate2d(e.x, e.y); this.marginStartPositionInPixels_ = - new print_preview.Coordinate2d(control.offsetLeft, control.offsetTop); + new Coordinate2d(control.offsetLeft, control.offsetTop); this.dragging_ = this.isTopOrBottom_( - /** @type {print_preview.CustomMarginsOrientation} */ + /** @type {CustomMarginsOrientation} */ (control.side)) ? 'dragging-vertical' : 'dragging-horizontal'; @@ -498,7 +507,7 @@ /** * Updates the translation transformation that translates pixel values in * the space of the HTML DOM. - * @param {print_preview.Coordinate2d} translateTransform Updated value of + * @param {Coordinate2d} translateTransform Updated value of * the translation transformation. */ updateTranslationTransform: function(translateTransform) { @@ -519,7 +528,7 @@ /** * Clips margin controls to the given clip size in pixels. - * @param {print_preview.Size} clipSize Size to clip the margin controls to. + * @param {Size} clipSize Size to clip the margin controls to. */ updateClippingMask: function(clipSize) { if (!clipSize) { @@ -530,7 +539,3 @@ }, }); - return { - MARGIN_KEY_MAP: MARGIN_KEY_MAP, - }; -});
diff --git a/chrome/browser/resources/print_preview/ui/margins_settings.html b/chrome/browser/resources/print_preview/ui/margins_settings.html index a47ee581..ae28aaf 100644 --- a/chrome/browser/resources/print_preview/ui/margins_settings.html +++ b/chrome/browser/resources/print_preview/ui/margins_settings.html
@@ -1,14 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="../data/margins.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-margins-settings"> - <template> <style include="print-preview-shared md-select"> </style> <print-preview-settings-section> @@ -19,7 +9,7 @@ settings.pagesPerSheet.value)]]" value="{{selectedValue::change}}"> <!-- The order of these options must match the natural order of their - values, which come from print_preview.MarginsType. --> + values, which come from MarginsType. --> <option value="[[MarginsTypeEnum.DEFAULT]]" selected> $i18n{defaultMargins} </option> @@ -35,6 +25,3 @@ </select> </div> </print-preview-settings-section> - </template> - <script src="margins_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/margins_settings.js b/chrome/browser/resources/print_preview/ui/margins_settings.js index cd4e0ae..280e639 100644 --- a/chrome/browser/resources/print_preview/ui/margins_settings.js +++ b/chrome/browser/resources/print_preview/ui/margins_settings.js
@@ -2,10 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {MarginsType} from '../data/margins.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-margins-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { disabled: Boolean, @@ -18,7 +28,7 @@ /** @override */ ready: function() { - this.MarginsTypeEnum = print_preview.MarginsType; + this.MarginsTypeEnum = MarginsType; }, /** @@ -27,7 +37,7 @@ */ onMarginsSettingChange_: function(newValue) { this.selectedValue = - /** @type {!print_preview.MarginsType} */ (newValue).toString(); + /** @type {!MarginsType} */ (newValue).toString(); }, /** @param {string} value The new select value. */
diff --git a/chrome/browser/resources/print_preview/ui/media_size_settings.html b/chrome/browser/resources/print_preview/ui/media_size_settings.html index fb55307..e4aea18 100644 --- a/chrome/browser/resources/print_preview/ui/media_size_settings.html +++ b/chrome/browser/resources/print_preview/ui/media_size_settings.html
@@ -1,12 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> -<link rel="import" href="settings_select.html"> - -<dom-module id="print-preview-media-size-settings"> - <template> <style include="print-preview-shared"> :host print-preview-settings-select { margin: 0 calc(var(--print-preview-sidebar-margin) - 2px); @@ -21,6 +13,3 @@ </print-preview-settings-select> </div> </print-preview-settings-section> - </template> - <script src="media_size_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/media_size_settings.js b/chrome/browser/resources/print_preview/ui/media_size_settings.js index de283d0..bc463937 100644 --- a/chrome/browser/resources/print_preview/ui/media_size_settings.js +++ b/chrome/browser/resources/print_preview/ui/media_size_settings.js
@@ -2,9 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; +import {SelectOption} from './settings_select.js'; + Polymer({ is: 'print-preview-media-size-settings', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior], properties: { @@ -23,7 +31,7 @@ } const valueToSet = JSON.stringify(this.getSettingValue('mediaSize')); for (const option of - /** @type {!Array<!print_preview.SelectOption>} */ ( + /** @type {!Array<!SelectOption>} */ ( this.capability.option)) { if (JSON.stringify(option) === valueToSet) { this.$$('print-preview-settings-select').selectValue(valueToSet);
diff --git a/chrome/browser/resources/print_preview/ui/more_settings.html b/chrome/browser/resources/print_preview/ui/more_settings.html index 97cdcc6..db3dd610 100644 --- a/chrome/browser/resources/print_preview/ui/more_settings.html +++ b/chrome/browser/resources/print_preview/ui/more_settings.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../metrics.html"> -<link rel="import" href="strings.html"> -<dom-module id="print-preview-more-settings"> - <template> <style include="cr-hidden-style print-preview-shared"> :host { border-top: var(--print-preview-settings-border); @@ -52,6 +43,3 @@ expanded="{{settingsExpandedByUser}}" disabled="[[disabled]]"> </cr-expand-button> </div> - </template> - <script src="more_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/more_settings.js b/chrome/browser/resources/print_preview/ui/more_settings.js index 5c23f08..0697d63e 100644 --- a/chrome/browser/resources/print_preview/ui/more_settings.js +++ b/chrome/browser/resources/print_preview/ui/more_settings.js
@@ -2,9 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/cr_expand_button/cr_expand_button.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {Metrics, MetricsContext} from '../metrics.js'; +import '../strings.m.js'; + Polymer({ is: 'print-preview-more-settings', + _template: html`{__html_template__}`, + behaviors: [I18nBehavior], properties: { @@ -19,8 +30,8 @@ }, }, - /** @private {!print_preview.MetricsContext} */ - metrics_: print_preview.MetricsContext.printSettingsUi(), + /** @private {!MetricsContext} */ + metrics_: MetricsContext.printSettingsUi(), /** * Toggles the expand button within the element being listened to. @@ -44,7 +55,7 @@ expandButton.expanded = !expandButton.expanded; this.metrics_.record( this.settingsExpandedByUser ? - print_preview.Metrics.PrintSettingsUiBucket.MORE_SETTINGS_CLICKED : - print_preview.Metrics.PrintSettingsUiBucket.LESS_SETTINGS_CLICKED); + Metrics.PrintSettingsUiBucket.MORE_SETTINGS_CLICKED : + Metrics.PrintSettingsUiBucket.LESS_SETTINGS_CLICKED); }, });
diff --git a/chrome/browser/resources/print_preview/ui/number_settings_section.html b/chrome/browser/resources/print_preview/ui/number_settings_section.html index c0d8f124..2bb529dd3 100644 --- a/chrome/browser/resources/print_preview/ui/number_settings_section.html +++ b/chrome/browser/resources/print_preview/ui/number_settings_section.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="input_behavior.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-number-settings-section"> - <template> <style include="print-preview-shared"> :host { /* Width = 3 digits + space + cr-input-padding-end/start */ @@ -56,6 +47,3 @@ </span> </div> </print-preview-settings-section> - </template> - <script src="number_settings_section.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/number_settings_section.js b/chrome/browser/resources/print_preview/ui/number_settings_section.js index 70f53ec4..5b0fa4b 100644 --- a/chrome/browser/resources/print_preview/ui/number_settings_section.js +++ b/chrome/browser/resources/print_preview/ui/number_settings_section.js
@@ -2,10 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; +import {InputBehavior} from './input_behavior.js'; +import './print_preview_shared_css.js'; +import './print_preview_vars_css.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-number-settings-section', - behaviors: [print_preview.InputBehavior], + _template: html`{__html_template__}`, + + behaviors: [InputBehavior], properties: { /** @private {string} */ @@ -51,7 +60,7 @@ /** @return {!CrInputElement} The cr-input field element for InputBehavior. */ getInput: function() { - return this.$.userValue; + return /** @type {!CrInputElement} */ (this.$.userValue); }, /**
diff --git a/chrome/browser/resources/print_preview/ui/other_options_settings.html b/chrome/browser/resources/print_preview/ui/other_options_settings.html index 1b5d66e2..058a76c 100644 --- a/chrome/browser/resources/print_preview/ui/other_options_settings.html +++ b/chrome/browser/resources/print_preview/ui/other_options_settings.html
@@ -1,15 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-other-options-settings"> - <template> <style include="print-preview-shared cr-hidden-style"> print-preview-settings-section:not(.first-visible) .title { display: none; @@ -30,6 +19,3 @@ </div> </print-preview-settings-section> </template> - </template> - <script src="other_options_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/other_options_settings.js b/chrome/browser/resources/print_preview/ui/other_options_settings.js index 1e7746d..45442cce 100644 --- a/chrome/browser/resources/print_preview/ui/other_options_settings.js +++ b/chrome/browser/resources/print_preview/ui/other_options_settings.js
@@ -2,9 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; +import '../strings.m.js'; + Polymer({ is: 'print-preview-other-options-settings', + _template: html`{__html_template__}`, + behaviors: [SettingsBehavior, I18nBehavior], properties: {
diff --git a/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.html b/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.html index 13a454c..feb6515 100644 --- a/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.html +++ b/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.html
@@ -1,14 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="../data/margins.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-pages-per-sheet-settings"> - <template> <style include="print-preview-shared md-select"> </style> <print-preview-settings-section> @@ -26,6 +16,3 @@ </select> </div> </print-preview-settings-section> - </template> - <script src="pages_per_sheet_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js b/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js index 97533754..a1e2335 100644 --- a/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js +++ b/chrome/browser/resources/print_preview/ui/pages_per_sheet_settings.js
@@ -2,10 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {MarginsType} from '../data/margins.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-pages-per-sheet-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { disabled: Boolean, @@ -19,7 +29,7 @@ */ onPagesPerSheetSettingChange_: function(newValue) { this.selectedValue = /** @type {number} */ (newValue).toString(); - this.setSetting('margins', print_preview.MarginsType.DEFAULT); + this.setSetting('margins', MarginsType.DEFAULT); }, /** @param {string} value The new select value. */
diff --git a/chrome/browser/resources/print_preview/ui/pages_settings.html b/chrome/browser/resources/print_preview/ui/pages_settings.html index 4d6c107..135f0a3 100644 --- a/chrome/browser/resources/print_preview/ui/pages_settings.html +++ b/chrome/browser/resources/print_preview/ui/pages_settings.html
@@ -1,19 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../data/document_info.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="input_behavior.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-pages-settings"> - <template> <style include="print-preview-shared md-select"> :host([error-state_='0']) #pageSettingsCustomInput, :host([error-state_='3']) #pageSettingsCustomInput { @@ -65,6 +50,3 @@ </div> </print-preview-settings-section> </iron-collapse> - </template> - <script src="pages_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/pages_settings.js b/chrome/browser/resources/print_preview/ui/pages_settings.js index c25f952..29a4b3e7 100644 --- a/chrome/browser/resources/print_preview/ui/pages_settings.js +++ b/chrome/browser/resources/print_preview/ui/pages_settings.js
@@ -2,8 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function() { -'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js'; +import {areRangesEqual} from '../print_preview_utils.js'; +import {InputBehavior} from './input_behavior.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; +import '../strings.m.js'; /** @enum {number} */ const PagesInputErrorState = { @@ -37,9 +47,9 @@ Polymer({ is: 'print-preview-pages-settings', - behaviors: [ - SettingsBehavior, print_preview.InputBehavior, print_preview.SelectBehavior - ], + _template: html`{__html_template__}`, + + behaviors: [ SettingsBehavior, InputBehavior, SelectBehavior ], properties: { disabled: Boolean, @@ -128,7 +138,7 @@ /** @return {!CrInputElement} The cr-input field element for InputBehavior. */ getInput: function() { - return this.$.pageSettingsCustomInput; + return /** @type {!CrInputElement} */ (this.$.pageSettingsCustomInput); }, /** @@ -448,4 +458,3 @@ } }, }); -})();
diff --git a/chrome/browser/resources/print_preview/ui/pin_settings.html b/chrome/browser/resources/print_preview/ui/pin_settings.html index 58d7b4b..1797e64 100644 --- a/chrome/browser/resources/print_preview/ui/pin_settings.html +++ b/chrome/browser/resources/print_preview/ui/pin_settings.html
@@ -1,16 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="input_behavior.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-pin-settings"> - <template> <style include="print-preview-shared"> :host { margin-top: 0 !important; @@ -57,6 +45,3 @@ </div> </print-preview-settings-section> </iron-collapse> - </template> - <script src="pin_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/pin_settings.js b/chrome/browser/resources/print_preview/ui/pin_settings.js index 8e56e89..37d54af 100644 --- a/chrome/browser/resources/print_preview/ui/pin_settings.js +++ b/chrome/browser/resources/print_preview/ui/pin_settings.js
@@ -2,13 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; +import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js'; +import {State} from '../data/state.js'; +import {InputBehavior} from './input_behavior.js'; +import './print_preview_shared_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; + Polymer({ is: 'print-preview-pin-settings', - behaviors: [SettingsBehavior, print_preview.InputBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, InputBehavior], properties: { - /** @type {!print_preview.State} */ + /** @type {!State} */ state: Number, disabled: Boolean, @@ -52,7 +64,7 @@ /** @return {!CrInputElement} The cr-input field element for InputBehavior. */ getInput: function() { - return this.$.pinValue; + return /** @type {!CrInputElement} */ (this.$.pinValue); }, /** @@ -136,7 +148,7 @@ // It's done because we don't permit multiple simultaneous validation errors // in Print Preview and we also don't want to set the value when sticky // settings may not yet have been set. - if (this.state != print_preview.State.READY && + if (this.state != State.READY && this.settings.pinValue.valid) { return; }
diff --git a/chrome/browser/resources/print_preview/ui/plugin_proxy.html b/chrome/browser/resources/print_preview/ui/plugin_proxy.html deleted file mode 100644 index 08625db..0000000 --- a/chrome/browser/resources/print_preview/ui/plugin_proxy.html +++ /dev/null
@@ -1,4 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="plugin_proxy.js"></script> -<script src="../pdf/pdf_scripting_api.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/plugin_proxy.js b/chrome/browser/resources/print_preview/ui/plugin_proxy.js index 3ed597c..d4d9585 100644 --- a/chrome/browser/resources/print_preview/ui/plugin_proxy.js +++ b/chrome/browser/resources/print_preview/ui/plugin_proxy.js
@@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { - 'use strict'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {PDFCreateOutOfProcessPlugin} from '../pdf/pdf_scripting_api.js'; /** * @typedef {{accessibility: Function, @@ -34,15 +34,15 @@ * zoomIn: Function, * zoomOut: Function}} */ - let PDFPlugin; + export let PDFPlugin; /** * An interface to the PDF plugin. */ - class PluginProxy { + export class PluginProxy { /** * Creates a new PluginProxy if the current instance is not set. - * @return {!print_preview.PluginProxy} The singleton instance. + * @return {!PluginProxy} The singleton instance. */ static getInstance() { if (instance == null) { @@ -52,7 +52,7 @@ } /** - * @param {!print_preview.PluginProxy} newInstance The PluginProxy + * @param {!PluginProxy} newInstance The PluginProxy * instance to set for print preview construction. */ static setInstance(newInstance) { @@ -60,7 +60,7 @@ } constructor() { - /** @private {?print_preview.PDFPlugin} */ + /** @private {?PDFPlugin} */ this.plugin_ = null; } @@ -84,12 +84,12 @@ * Creates the PDF plugin. * @param {number} previewUid The unique ID of the preview UI. * @param {number} index The preview index to load. - * @return {!print_preview.PDFPlugin} The created plugin. + * @return {!PDFPlugin} The created plugin. */ createPlugin(previewUid, index) { assert(!this.plugin_); const srcUrl = this.getPreviewUrl_(previewUid, index); - this.plugin_ = /** @type {print_preview.PDFPlugin} */ ( + this.plugin_ = /** @type {PDFPlugin} */ ( PDFCreateOutOfProcessPlugin(srcUrl, 'chrome://print/pdf')); this.plugin_.classList.add('preview-area-plugin'); this.plugin_.setAttribute('aria-live', 'polite'); @@ -180,12 +180,5 @@ } } - /** @type {?print_preview.PluginProxy} */ + /** @type {?PluginProxy} */ let instance = null; - - // Export - return { - PDFPlugin: PDFPlugin, - PluginProxy: PluginProxy, - }; -});
diff --git a/chrome/browser/resources/print_preview/ui/preview_area.html b/chrome/browser/resources/print_preview/ui/preview_area.html index 2f1c5f68d..6a4f762b 100644 --- a/chrome/browser/resources/print_preview/ui/preview_area.html +++ b/chrome/browser/resources/print_preview/ui/preview_area.html
@@ -1,29 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../native_layer.html"> -<link rel="import" href="../dark_mode_behavior.html"> -<link rel="import" href="../data/coordinate2d.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/destination_match.html"> -<link rel="import" href="../data/margins.html"> -<link rel="import" href="../data/model.html"> -<link rel="import" href="../data/printable_area.html"> -<link rel="import" href="../data/size.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="margin_control_container.html"> -<link rel="import" href="plugin_proxy.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="strings.html"> - -<dom-module id="print-preview-preview-area"> - <template> <style include="cr-hidden-style"> @keyframes dancing-dots-jump { 0% { top: 0; } @@ -138,6 +113,3 @@ on-text-focus-position="onTextFocusPosition_" on-margin-drag-changed="onMarginDragChanged_"> </print-preview-margin-control-container> - </template> - <script src="preview_area.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/preview_area.js b/chrome/browser/resources/print_preview/ui/preview_area.js index ce0f731..d69f858 100644 --- a/chrome/browser/resources/print_preview/ui/preview_area.js +++ b/chrome/browser/resources/print_preview/ui/preview_area.js
@@ -2,7 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isMac} from 'chrome://resources/js/cr.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {hasKeyModifiers} from 'chrome://resources/js/util.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {NativeLayer} from '../native_layer.js'; +import {DarkModeBehavior} from '../dark_mode_behavior.js'; +import {areRangesEqual} from '../print_preview_utils.js'; +import {Coordinate2d} from '../data/coordinate2d.js'; +import {Destination} from '../data/destination.js'; +import {getPrinterTypeForDestination} from '../data/destination_match.js'; +import {CustomMarginsOrientation, Margins, MarginsSetting, MarginsType} from '../data/margins.js'; +import {MeasurementSystem} from '../data/measurement_system.js'; +import {DuplexMode} from '../data/model.js'; +import {PrintableArea} from '../data/printable_area.js'; +import {ScalingType} from '../data/scaling.js'; +import {Size} from '../data/size.js'; +import {Error, State} from '../data/state.js'; +import {MARGIN_KEY_MAP} from './margin_control_container.js'; +import {PluginProxy} from './plugin_proxy.js'; +import './print_preview_vars_css.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import '../strings.m.js'; /** * @typedef {{ @@ -10,10 +35,10 @@ * height_microns: number, * }} */ -print_preview.MediaSizeValue; +let MediaSizeValue; /** @enum {string} */ -print_preview.PreviewAreaState = { +export const PreviewAreaState = { NO_PLUGIN: 'no-plugin', LOADING: 'loading', DISPLAY_PREVIEW: 'display-preview', @@ -25,42 +50,44 @@ Polymer({ is: 'print-preview-preview-area', + _template: html`{__html_template__}`, + behaviors: [ WebUIListenerBehavior, SettingsBehavior, I18nBehavior, - print_preview.DarkModeBehavior, + DarkModeBehavior, ], properties: { - /** @type {print_preview.Destination} */ + /** @type {Destination} */ destination: Object, documentModifiable: Boolean, - /** @type {!print_preview.Error} */ + /** @type {!Error} */ error: { type: Number, notify: true, }, - /** @type {print_preview.Margins} */ + /** @type {Margins} */ margins: Object, - /** @type {?print_preview.MeasurementSystem} */ + /** @type {?MeasurementSystem} */ measurementSystem: Object, - /** @type {!print_preview.Size} */ + /** @type {!Size} */ pageSize: Object, - /** @type {!print_preview.PreviewAreaState} */ + /** @type {!PreviewAreaState} */ previewState: { type: String, notify: true, - value: print_preview.PreviewAreaState.LOADING, + value: PreviewAreaState.LOADING, }, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: Number, /** @private {boolean} Whether the plugin is loaded */ @@ -94,7 +121,7 @@ 'onStateOrErrorChange_(state, error)', ], - /** @private {?print_preview.NativeLayer} */ + /** @private {?NativeLayer} */ nativeLayer_: null, /** @private {?Object} */ @@ -103,7 +130,7 @@ /** @private {number} */ inFlightRequestId_: -1, - /** @private {?print_preview.PluginProxy} */ + /** @private {?PluginProxy} */ pluginProxy_: null, /** @private {?function(!KeyboardEvent)} */ @@ -111,20 +138,20 @@ /** @override */ attached: function() { - this.nativeLayer_ = print_preview.NativeLayer.getInstance(); + this.nativeLayer_ = NativeLayer.getInstance(); this.addWebUIListener( 'page-preview-ready', this.onPagePreviewReady_.bind(this)); if (!this.pluginProxy_.checkPluginCompatibility(assert( this.$$('.preview-area-compatibility-object-out-of-process')))) { - this.error = print_preview.Error.NO_PLUGIN; - this.previewState = print_preview.PreviewAreaState.ERROR; + this.error = Error.NO_PLUGIN; + this.previewState = PreviewAreaState.ERROR; } }, /** @override */ created: function() { - this.pluginProxy_ = print_preview.PluginProxy.getInstance(); + this.pluginProxy_ = PluginProxy.getInstance(); }, /** @@ -181,14 +208,14 @@ /** @private */ pluginOrDocumentStatusChanged_: function() { if (!this.pluginLoaded_ || !this.documentReady_ || - this.previewState === print_preview.PreviewAreaState.ERROR) { + this.previewState === PreviewAreaState.ERROR) { return; } this.previewState = this.previewState == - print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADING ? - print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADED : - print_preview.PreviewAreaState.DISPLAY_PREVIEW; + PreviewAreaState.OPEN_IN_PREVIEW_LOADING ? + PreviewAreaState.OPEN_IN_PREVIEW_LOADED : + PreviewAreaState.DISPLAY_PREVIEW; }, /** @@ -212,7 +239,7 @@ * @private */ isInDisplayPreviewState_: function() { - return this.previewState == print_preview.PreviewAreaState.DISPLAY_PREVIEW; + return this.previewState == PreviewAreaState.DISPLAY_PREVIEW; }, /** @@ -220,7 +247,7 @@ * @private */ isPreviewLoading_: function() { - return this.previewState == print_preview.PreviewAreaState.LOADING; + return this.previewState == PreviewAreaState.LOADING; }, /** @@ -237,7 +264,7 @@ * @private */ shouldShowLearnMoreLink_: function() { - return this.error === print_preview.Error.UNSUPPORTED_PRINTER; + return this.error === Error.UNSUPPORTED_PRINTER; }, /** @@ -246,16 +273,16 @@ */ currentMessage_: function() { switch (this.previewState) { - case print_preview.PreviewAreaState.LOADING: + case PreviewAreaState.LOADING: return this.i18n('loading'); - case print_preview.PreviewAreaState.DISPLAY_PREVIEW: + case PreviewAreaState.DISPLAY_PREVIEW: return ''; // <if expr="is_macosx"> - case print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADING: - case print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADED: + case PreviewAreaState.OPEN_IN_PREVIEW_LOADING: + case PreviewAreaState.OPEN_IN_PREVIEW_LOADED: return this.i18n('openingPDFInPreview'); // </if> - case print_preview.PreviewAreaState.ERROR: + case PreviewAreaState.ERROR: // The preview area is responsible for displaying all errors except // print failed and cloud print error. return this.getErrorMessage_(); @@ -270,10 +297,10 @@ */ startPreview: function(forceUpdate) { if (!this.hasTicketChanged_() && !forceUpdate && - this.previewState !== print_preview.PreviewAreaState.ERROR) { + this.previewState !== PreviewAreaState.ERROR) { return; } - this.previewState = print_preview.PreviewAreaState.LOADING; + this.previewState = PreviewAreaState.LOADING; this.documentReady_ = false; this.getPreview_().then( previewUid => { @@ -284,11 +311,11 @@ }, type => { if (/** @type{string} */ (type) == 'SETTINGS_INVALID') { - this.error = print_preview.Error.INVALID_PRINTER; - this.previewState = print_preview.PreviewAreaState.ERROR; + this.error = Error.INVALID_PRINTER; + this.previewState = PreviewAreaState.ERROR; } else if (/** @type{string} */ (type) != 'CANCELLED') { - this.error = print_preview.Error.PREVIEW_FAILED; - this.previewState = print_preview.PreviewAreaState.ERROR; + this.error = Error.PREVIEW_FAILED; + this.previewState = PreviewAreaState.ERROR; } }); }, @@ -296,11 +323,11 @@ // <if expr="is_macosx"> /** Set the preview state to display the "opening in preview" message. */ setOpeningPdfInPreview: function() { - assert(cr.isMac); + assert(isMac); this.previewState = - this.previewState == print_preview.PreviewAreaState.LOADING ? - print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADING : - print_preview.PreviewAreaState.OPEN_IN_PREVIEW_LOADED; + this.previewState == PreviewAreaState.LOADING ? + PreviewAreaState.OPEN_IN_PREVIEW_LOADING : + PreviewAreaState.OPEN_IN_PREVIEW_LOADED; }, // </if> @@ -342,8 +369,8 @@ if (success) { this.pluginLoaded_ = true; } else { - this.error = print_preview.Error.PREVIEW_FAILED; - this.previewState = print_preview.PreviewAreaState.ERROR; + this.error = Error.PREVIEW_FAILED; + this.previewState = PreviewAreaState.ERROR; } }, @@ -365,11 +392,11 @@ const tabindex = viewportWidth < 300 || viewportHeight < 200 ? '-1' : '0'; this.$$('.preview-area-plugin').setAttribute('tabindex', tabindex); this.$.marginControlContainer.updateTranslationTransform( - new print_preview.Coordinate2d(pageX, pageY)); + new Coordinate2d(pageX, pageY)); this.$.marginControlContainer.updateScaleTransform( pageWidth / this.pageSize.width); this.$.marginControlContainer.updateClippingMask( - new print_preview.Size(viewportWidth, viewportHeight)); + new Size(viewportWidth, viewportHeight)); }, /** @@ -407,7 +434,7 @@ this.pluginProxy_.darkModeChanged(this.inDarkMode); } - if (this.previewState === print_preview.PreviewAreaState.DISPLAY_PREVIEW) { + if (this.previewState === PreviewAreaState.DISPLAY_PREVIEW) { this.startPreview(true); } }, @@ -520,12 +547,12 @@ */ marginsValid_: function() { const type = this.getSettingValue('margins'); - if (!Object.values(print_preview.MarginsType).includes(type)) { + if (!Object.values(MarginsType).includes(type)) { // Unrecognized margins type. return false; } - if (type !== print_preview.MarginsType.CUSTOM) { + if (type !== MarginsType.CUSTOM) { return true; } @@ -557,13 +584,13 @@ // Margins const newMarginsType = this.getSettingValue('margins'); if (newMarginsType !== lastTicket.marginsType && - newMarginsType !== print_preview.MarginsType.CUSTOM) { + newMarginsType !== MarginsType.CUSTOM) { return true; } - if (newMarginsType === print_preview.MarginsType.CUSTOM) { + if (newMarginsType === MarginsType.CUSTOM) { const customMargins = - /** @type {!print_preview.MarginsSetting} */ ( + /** @type {!MarginsSetting} */ ( this.getSettingValue('customMargins')); // Change in custom margins values. @@ -585,9 +612,9 @@ } const customMarginsChanged = - Object.values(print_preview.CustomMarginsOrientation).some(side => { + Object.values(CustomMarginsOrientation).some(side => { return this.margins.get(side) !== - customMargins[print_preview.MARGIN_KEY_MAP.get(side)]; + customMargins[MARGIN_KEY_MAP.get(side)]; }); if (customMarginsChanged) { return true; @@ -615,24 +642,24 @@ // Pages per sheet. If margins are non-default, wait for the return to // default margins to trigger a request. if (this.getSettingValue('pagesPerSheet') !== lastTicket.pagesPerSheet && - this.getSettingValue('margins') === print_preview.MarginsType.DEFAULT) { + this.getSettingValue('margins') === MarginsType.DEFAULT) { return true; } // Media size const newValue = - /** @type {!print_preview.MediaSizeValue} */ ( + /** @type {!MediaSizeValue} */ ( this.getSettingValue('mediaSize')); if (newValue.height_microns != lastTicket.mediaSize.height_microns || newValue.width_microns != lastTicket.mediaSize.width_microns || (this.destination.id !== lastTicket.deviceName && this.getSettingValue('margins') === - print_preview.MarginsType.MINIMUM)) { + MarginsType.MINIMUM)) { return true; } // Destination - if (print_preview.getPrinterTypeForDestination(this.destination) !== + if (getPrinterTypeForDestination(this.destination) !== lastTicket.printerType) { return true; } @@ -649,7 +676,7 @@ /** @return {number} Scale factor for print ticket. */ getScaleFactorForTicket_: function() { return this.getSettingValue(this.getScalingSettingKey_()) === - print_preview.ScalingType.CUSTOM ? + ScalingType.CUSTOM ? parseInt(this.getSettingValue('scaling'), 10) : 100; }, @@ -680,10 +707,10 @@ // Scaling doesn't always change because of a scalingType change. Changing // between custom scaling with a scale factor of 100 and default scaling // makes no difference. - const defaultToCustom = scalingType === print_preview.ScalingType.DEFAULT && - lastTicket.scalingType === print_preview.ScalingType.CUSTOM; - const customToDefault = scalingType === print_preview.ScalingType.CUSTOM && - lastTicket.scalingType === print_preview.ScalingType.DEFAULT; + const defaultToCustom = scalingType === ScalingType.DEFAULT && + lastTicket.scalingType === ScalingType.CUSTOM; + const customToDefault = scalingType === ScalingType.CUSTOM && + lastTicket.scalingType === ScalingType.DEFAULT; return !defaultToCustom && !customToDefault; }, @@ -735,9 +762,9 @@ dpiHorizontal: this.getDpiForTicket_('horizontal_dpi'), dpiVertical: this.getDpiForTicket_('vertical_dpi'), duplex: this.getSettingValue('duplex') ? - print_preview.DuplexMode.LONG_EDGE : - print_preview.DuplexMode.SIMPLEX, - printerType: print_preview.getPrinterTypeForDestination(this.destination), + DuplexMode.LONG_EDGE : + DuplexMode.SIMPLEX, + printerType: getPrinterTypeForDestination(this.destination), rasterizePDF: this.getSettingValue('rasterize'), }; @@ -746,7 +773,7 @@ ticket.cloudPrintID = this.destination.id; } - if (this.getSettingValue('margins') == print_preview.MarginsType.CUSTOM) { + if (this.getSettingValue('margins') == MarginsType.CUSTOM) { ticket.marginsCustom = this.getSettingValue('customMargins'); } this.lastTicket_ = ticket; @@ -757,33 +784,33 @@ /** @private */ onStateOrErrorChange_: function() { - if ((this.state === print_preview.State.ERROR || - this.state === print_preview.State.FATAL_ERROR) && + if ((this.state === State.ERROR || + this.state === State.FATAL_ERROR) && this.getErrorMessage_() !== '') { - this.previewState = print_preview.PreviewAreaState.ERROR; + this.previewState = PreviewAreaState.ERROR; } }, /** @return {string} The error message to display in the preview area. */ getErrorMessage_: function() { switch (this.error) { - case print_preview.Error.INVALID_PRINTER: + case Error.INVALID_PRINTER: return this.i18nAdvanced('invalidPrinterSettings', { substitutions: [], tags: ['BR'], }); - case print_preview.Error.UNSUPPORTED_PRINTER: + case Error.UNSUPPORTED_PRINTER: return this.i18nAdvanced('unsupportedCloudPrinter', { substitutions: [], tags: ['BR'], }); // <if expr="chromeos"> - case print_preview.Error.NO_DESTINATIONS: + case Error.NO_DESTINATIONS: return this.i18n('noDestinationsMessage'); // </if> - case print_preview.Error.NO_PLUGIN: + case Error.NO_PLUGIN: return this.i18n('noPlugin'); - case print_preview.Error.PREVIEW_FAILED: + case Error.PREVIEW_FAILED: return this.i18n('previewFailed'); default: return '';
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_search_box.html b/chrome/browser/resources/print_preview/ui/print_preview_search_box.html index 12f71762..3f5abaa 100644 --- a/chrome/browser/resources/print_preview/ui/print_preview_search_box.html +++ b/chrome/browser/resources/print_preview/ui/print_preview_search_box.html
@@ -1,14 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_search_field/cr_search_field_behavior.html"> -<link rel="import" href="print_preview_shared_css.html"> - -<dom-module id="print-preview-search-box"> - <template> <style include="print-preview-shared cr-input-style"> :host { display: flex; @@ -68,6 +58,3 @@ title="[[clearLabel]]"> </cr-icon-button> </cr-input> - </template> - <script src="print_preview_search_box.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_search_box.js b/chrome/browser/resources/print_preview/ui/print_preview_search_box.js index c928228..febf1a0 100644 --- a/chrome/browser/resources/print_preview/ui/print_preview_search_box.js +++ b/chrome/browser/resources/print_preview/ui/print_preview_search_box.js
@@ -2,8 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function() { -'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_icons_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js'; +import 'chrome://resources/cr_elements/cr_input/cr_input.m.js'; +import {CrSearchFieldBehavior} from 'chrome://resources/cr_elements/cr_search_field/cr_search_field_behavior.m.js'; +import './print_preview_shared_css.js'; /** @type {!RegExp} */ const SANITIZE_REGEX = /[-[\]{}()*+?.,\\^$|#\s]/g; @@ -11,6 +16,8 @@ Polymer({ is: 'print-preview-search-box', + _template: html`{__html_template__}`, + behaviors: [CrSearchFieldBehavior], properties: { @@ -33,9 +40,9 @@ */ lastString_: '', - /** @return {!HTMLInputElement} */ + /** @return {!CrInputElement} */ getSearchInput: function() { - return this.$.searchInput; + return /** @type {!CrInputElement} */ (this.$.searchInput); }, focus: function() { @@ -64,4 +71,3 @@ this.$.searchInput.focus(); }, }); -})();
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_shared_css.html b/chrome/browser/resources/print_preview/ui/print_preview_shared_css.html index 1d85437..4d74ea1f 100644 --- a/chrome/browser/resources/print_preview/ui/print_preview_shared_css.html +++ b/chrome/browser/resources/print_preview/ui/print_preview_shared_css.html
@@ -1,10 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="print_preview_vars_css.html"> - -<dom-module id="print-preview-shared"> <template> <style include="cr-shared-style"> /* Default state ********************************************************/ @@ -83,4 +77,3 @@ } </style> </template> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_shared_css.js b/chrome/browser/resources/print_preview/ui/print_preview_shared_css.js new file mode 100644 index 0000000..08e30f8 --- /dev/null +++ b/chrome/browser/resources/print_preview/ui/print_preview_shared_css.js
@@ -0,0 +1,13 @@ +// 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. + +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/shared_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import './print_preview_vars_css.js'; +const template = document.createElement('template'); +template.innerHTML = ` +<dom-module id="print-preview-shared" assetpath="chrome://resources/">{__html_template__}</dom-module> +`; +document.body.appendChild(template.content.cloneNode(true));
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_vars_css.html b/chrome/browser/resources/print_preview/ui/print_preview_vars_css.html index 3fbfea419..07d6ba36 100644 --- a/chrome/browser/resources/print_preview/ui/print_preview_vars_css.html +++ b/chrome/browser/resources/print_preview/ui/print_preview_vars_css.html
@@ -1,8 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> - -<!-- Common CSS variables for Print Preview. --> <custom-style> <style> html {
diff --git a/chrome/browser/resources/print_preview/ui/print_preview_vars_css.js b/chrome/browser/resources/print_preview/ui/print_preview_vars_css.js new file mode 100644 index 0000000..76a3e95 --- /dev/null +++ b/chrome/browser/resources/print_preview/ui/print_preview_vars_css.js
@@ -0,0 +1,9 @@ +// 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. + +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +const $_documentContainer = document.createElement('template'); +$_documentContainer.innerHTML = `{__html_template__}`; +document.head.appendChild($_documentContainer.content);
diff --git a/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.html b/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.html index f77b393..3a509d3 100644 --- a/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.html +++ b/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.html
@@ -1,20 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/destination_store.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="strings.html"> -<link rel="import" href="throbber_css.html"> - -<dom-module id="print-preview-provisional-destination-resolver"> - <template> <style include="print-preview-shared cr-hidden-style throbber"> #dialog::part(dialog) { height: -webkit-fit-content; @@ -89,6 +73,3 @@ </cr-button> </div> </cr-dialog> - </template> - <script src="provisional_destination_resolver.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.js b/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.js index 025447a4..501640f 100644 --- a/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.js +++ b/chrome/browser/resources/print_preview/ui/provisional_destination_resolver.js
@@ -2,6 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/cr_button/cr_button.m.js'; +import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {PromiseResolver} from 'chrome://resources/js/promise_resolver.m.js'; +import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js'; +import {Destination} from '../data/destination.js'; +import {DestinationStore} from '../data/destination_store.js'; +import './print_preview_shared_css.js'; +import './print_preview_vars_css.js'; +import '../strings.m.js'; +import './throbber_css.js'; + /** * @fileoverview PrintPreviewProvisionalDestinationResolver * This class is a dialog for resolving provisional destinations. Provisional @@ -11,13 +26,11 @@ * has successfully granted access. */ -cr.exportPath('print_preview'); - /** * States that the provisional destination resolver can be in. * @enum {string} */ -print_preview.ResolverState = { +const ResolverState = { INITIAL: 'INITIAL', ACTIVE: 'ACTIVE', GRANTING_PERMISSION: 'GRANTING_PERMISSION', @@ -28,22 +41,24 @@ Polymer({ is: 'print-preview-provisional-destination-resolver', + _template: html`{__html_template__}`, + behaviors: [I18nBehavior], properties: { - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ destinationStore: Object, - /** @private {?print_preview.Destination} */ + /** @private {?Destination} */ destination_: { type: Object, value: null, }, - /** @private {!print_preview.ResolverState} */ + /** @private {!ResolverState} */ state_: { type: String, - value: print_preview.ResolverState.INITIAL, + value: ResolverState.INITIAL, }, }, @@ -53,18 +68,18 @@ /** * Promise resolver for promise returned by {@code this.resolveDestination}. - * @private {?PromiseResolver<!print_preview.Destination>} + * @private {?PromiseResolver<!Destination>} */ promiseResolver_: null, /** - * @param {!print_preview.Destination} destination The destination this + * @param {!Destination} destination The destination this * dialog is needed to resolve. * @return {!Promise} Promise that is resolved when the destination has been * resolved. */ resolveDestination: function(destination) { - this.state_ = print_preview.ResolverState.ACTIVE; + this.state_ = ResolverState.ACTIVE; this.destination_ = destination; this.$.dialog.showModal(); const icon = this.$$('.extension-icon'); @@ -85,18 +100,18 @@ */ startResolveDestination_: function() { assert( - this.state_ == print_preview.ResolverState.ACTIVE, + this.state_ == ResolverState.ACTIVE, 'Invalid state in request grant permission'); - this.state_ = print_preview.ResolverState.GRANTING_PERMISSION; + this.state_ = ResolverState.GRANTING_PERMISSION; const destination = - /** @type {!print_preview.Destination} */ (this.destination_); + /** @type {!Destination} */ (this.destination_); this.destinationStore.resolveProvisionalDestination(destination) .then( - /** @param {?print_preview.Destination} resolvedDestination */ + /** @param {?Destination} resolvedDestination */ (resolvedDestination) => { if (this.state_ != - print_preview.ResolverState.GRANTING_PERMISSION) { + ResolverState.GRANTING_PERMISSION) { return; } @@ -105,12 +120,12 @@ } if (resolvedDestination) { - this.state_ = print_preview.ResolverState.DONE; + this.state_ = ResolverState.DONE; this.promiseResolver_.resolve(resolvedDestination); this.promiseResolver_ = null; this.$.dialog.close(); } else { - this.state_ = print_preview.ResolverState.ERROR; + this.state_ = ResolverState.ERROR; } }); }, @@ -135,7 +150,7 @@ /** @private */ onCancel_: function() { this.promiseResolver_.reject(); - this.state_ = print_preview.ResolverState.INITIAL; + this.state_ = ResolverState.INITIAL; }, /** @@ -143,7 +158,7 @@ * @private */ getPermissionMessage_: function() { - return this.state_ == print_preview.ResolverState.ERROR ? + return this.state_ == ResolverState.ERROR ? this.i18n( 'resolveExtensionUSBErrorMessage', this.destination_.extensionName) : @@ -155,7 +170,7 @@ * @private */ isInErrorState_: function() { - return this.state_ == print_preview.ResolverState.ERROR; + return this.state_ == ResolverState.ERROR; }, /** @@ -163,7 +178,7 @@ * @private */ isInActiveState_: function() { - return this.state_ == print_preview.ResolverState.ACTIVE; + return this.state_ == ResolverState.ACTIVE; }, /** @@ -171,7 +186,7 @@ * state, empty otherwise. */ getThrobberClass_: function() { - return this.state_ == print_preview.ResolverState.GRANTING_PERMISSION ? + return this.state_ == ResolverState.GRANTING_PERMISSION ? 'throbber' : ''; },
diff --git a/chrome/browser/resources/print_preview/ui/scaling_settings.html b/chrome/browser/resources/print_preview/ui/scaling_settings.html index 8da1200..94d272c7 100644 --- a/chrome/browser/resources/print_preview/ui/scaling_settings.html +++ b/chrome/browser/resources/print_preview/ui/scaling_settings.html
@@ -1,16 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../data/scaling.html"> -<link rel="import" href="number_settings_section.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="settings_section.html"> - -<dom-module id="print-preview-scaling-settings"> - <template> <style include="print-preview-shared md-select"> </style> <print-preview-settings-section> @@ -42,6 +30,3 @@ hint-message="$i18n{scalingInstruction}"> </print-preview-number-settings-section> </iron-collapse> - </template> - <script src="scaling_settings.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/scaling_settings.js b/chrome/browser/resources/print_preview/ui/scaling_settings.js index 500637a..4f66e9a0 100644 --- a/chrome/browser/resources/print_preview/ui/scaling_settings.js +++ b/chrome/browser/resources/print_preview/ui/scaling_settings.js
@@ -2,7 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js'; +import {ScalingType} from '../data/scaling.js'; +import './number_settings_section.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import './settings_section.js'; /* * Fit to page and fit to paper options will only be displayed for PDF @@ -12,7 +20,9 @@ Polymer({ is: 'print-preview-scaling-settings', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { disabled: { @@ -53,7 +63,7 @@ /** Mirroring the enum so that it can be used from HTML bindings. */ ScalingValue: { type: Object, - value: print_preview.ScalingType, + value: ScalingType, }, }, @@ -83,7 +93,7 @@ userSelectedCustomScaling_: false, onProcessSelectChange: function(value) { - const isCustom = value === print_preview.ScalingType.CUSTOM.toString(); + const isCustom = value === ScalingType.CUSTOM.toString(); if (isCustom && !this.customScalingSettingSet_) { this.userSelectedCustomScaling_ = true; } else { @@ -91,14 +101,14 @@ } const valueAsNumber = parseInt(value, 10); - if (isCustom || value === print_preview.ScalingType.DEFAULT.toString()) { + if (isCustom || value === ScalingType.DEFAULT.toString()) { this.setSetting('scalingType', valueAsNumber); } if (this.isPdf || this.getSetting('scalingTypePdf').value === - print_preview.ScalingType.DEFAULT || + ScalingType.DEFAULT || this.getSetting('scalingTypePdf').value === - print_preview.ScalingType.CUSTOM) { + ScalingType.CUSTOM) { this.setSetting('scalingTypePdf', valueAsNumber); } @@ -132,9 +142,9 @@ return; } - const value = /** @type {!print_preview.ScalingType} */ + const value = /** @type {!ScalingType} */ (this.getSettingValue(this.settingKey_)); - if (value !== print_preview.ScalingType.CUSTOM) { + if (value !== ScalingType.CUSTOM) { this.updateScalingToValid_(); } else { this.customScalingSettingSet_ = true; @@ -176,7 +186,7 @@ computeCustomSelected_: function() { return !!this.settingKey_ && this.getSettingValue(this.settingKey_) === - print_preview.ScalingType.CUSTOM; + ScalingType.CUSTOM; }, /**
diff --git a/chrome/browser/resources/print_preview/ui/select_behavior.html b/chrome/browser/resources/print_preview/ui/select_behavior.html deleted file mode 100644 index 2059526..0000000 --- a/chrome/browser/resources/print_preview/ui/select_behavior.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/cr.html"> - -<script src="select_behavior.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/select_behavior.js b/chrome/browser/resources/print_preview/ui/select_behavior.js index 4f00dc0..91142b5 100644 --- a/chrome/browser/resources/print_preview/ui/select_behavior.js +++ b/chrome/browser/resources/print_preview/ui/select_behavior.js
@@ -1,8 +1,8 @@ // Copyright 2018 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. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -cr.define('print_preview', function() { /** * Helper functions for a select with timeout. Implemented by select settings * sections, so that the preview does not immediately begin generating and @@ -11,7 +11,7 @@ * select element. * @polymerBehavior */ - const SelectBehavior = { + export const SelectBehavior = { properties: { selectedValue: { type: String, @@ -45,6 +45,3 @@ */ onProcessSelectChange: function(value) {}, }; - - return {SelectBehavior: SelectBehavior}; -});
diff --git a/chrome/browser/resources/print_preview/ui/settings_behavior.html b/chrome/browser/resources/print_preview/ui/settings_behavior.html deleted file mode 100644 index b3df869..0000000 --- a/chrome/browser/resources/print_preview/ui/settings_behavior.html +++ /dev/null
@@ -1,5 +0,0 @@ -<link rel="import" href="chrome://resources/html/assert.html"> - -<link rel="import" href="../data/model.html"> - -<script src="settings_behavior.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/settings_behavior.js b/chrome/browser/resources/print_preview/ui/settings_behavior.js index 89dba47..48de187 100644 --- a/chrome/browser/resources/print_preview/ui/settings_behavior.js +++ b/chrome/browser/resources/print_preview/ui/settings_behavior.js
@@ -1,20 +1,22 @@ // 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. +import {assert} from 'chrome://resources/js/assert.m.js'; +import {getInstance, Setting, Settings} from '../data/model.js'; /** @polymerBehavior */ -const SettingsBehavior = { +export const SettingsBehavior = { properties: { - /** @type {print_preview.Settings} */ + /** @type {Settings} */ settings: Object, }, /** * @param {string} settingName Name of the setting to get. - * @return {print_preview.Setting} The setting object. + * @return {Setting} The setting object. */ getSetting: function(settingName) { - return print_preview.Model.getInstance().getSetting(settingName); + return getInstance().getSetting(settingName); }, /** @@ -22,7 +24,7 @@ * @return {*} The value of the setting, accounting for availability. */ getSettingValue: function(settingName) { - return print_preview.Model.getInstance().getSettingValue(settingName); + return getInstance().getSettingValue(settingName); }, /** @@ -36,7 +38,7 @@ * to false. */ setSetting: function(settingName, value, noSticky) { - print_preview.Model.getInstance().setSetting(settingName, value, noSticky); + getInstance().setSetting(settingName, value, noSticky); }, /** @@ -48,7 +50,7 @@ * to false. */ setSettingSplice: function(settingName, start, end, newValue, noSticky) { - print_preview.Model.getInstance().setSettingSplice( + getInstance().setSettingSplice( settingName, start, end, newValue, noSticky); }, @@ -59,6 +61,6 @@ * @param {boolean} valid Whether the setting value is currently valid. */ setSettingValid: function(settingName, valid) { - print_preview.Model.getInstance().setSettingValid(settingName, valid); + getInstance().setSettingValid(settingName, valid); }, };
diff --git a/chrome/browser/resources/print_preview/ui/settings_interface.html b/chrome/browser/resources/print_preview/ui/settings_interface.html deleted file mode 100644 index a5f05af..0000000 --- a/chrome/browser/resources/print_preview/ui/settings_interface.html +++ /dev/null
@@ -1 +0,0 @@ -<script src="settings_interface.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/settings_section.html b/chrome/browser/resources/print_preview/ui/settings_section.html index 42248000..2fe0390c 100644 --- a/chrome/browser/resources/print_preview/ui/settings_section.html +++ b/chrome/browser/resources/print_preview/ui/settings_section.html
@@ -1,10 +1,3 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="print_preview_shared_css.html"> - -<dom-module id="print-preview-settings-section"> - <template> <style include="print-preview-shared"> :host { display: flex; @@ -35,6 +28,3 @@ </style> <slot name="title"></slot> <slot name="controls"></slot> - </template> - <script src="settings_section.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/settings_section.js b/chrome/browser/resources/print_preview/ui/settings_section.js index a28a505..b070e7b 100644 --- a/chrome/browser/resources/print_preview/ui/settings_section.js +++ b/chrome/browser/resources/print_preview/ui/settings_section.js
@@ -2,6 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import './print_preview_shared_css.js'; + Polymer({ is: 'print-preview-settings-section', + + _template: html`{__html_template__}`, });
diff --git a/chrome/browser/resources/print_preview/ui/settings_select.html b/chrome/browser/resources/print_preview/ui/settings_select.html index dd4a716..71c8090f 100644 --- a/chrome/browser/resources/print_preview/ui/settings_select.html +++ b/chrome/browser/resources/print_preview/ui/settings_select.html
@@ -1,13 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="../print_preview_utils.html"> -<link rel="import" href="print_preview_shared_css.html"> -<link rel="import" href="select_behavior.html"> -<link rel="import" href="settings_behavior.html"> - -<dom-module id="print-preview-settings-select"> - <template> <style include="print-preview-shared md-select"> select.md-select { margin: 2px; @@ -23,6 +14,3 @@ </option> </template> </select> - </template> - <script src="settings_select.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/settings_select.js b/chrome/browser/resources/print_preview/ui/settings_select.js index 2a107ba0..016c743d 100644 --- a/chrome/browser/resources/print_preview/ui/settings_select.js +++ b/chrome/browser/resources/print_preview/ui/settings_select.js
@@ -2,7 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.exportPath('print_preview'); +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {assert, assertNotReached} from 'chrome://resources/js/assert.m.js'; +import 'chrome://resources/cr_elements/md_select_css.m.js'; +import {getStringForCurrentLocale} from '../print_preview_utils.js'; +import './print_preview_shared_css.js'; +import {SelectBehavior} from './select_behavior.js'; +import {SettingsBehavior} from './settings_behavior.js'; + /** * @typedef {{ * is_default: (boolean | undefined), @@ -12,15 +19,17 @@ * name: (string | undefined), * }} */ -print_preview.SelectOption; +export let SelectOption; Polymer({ is: 'print-preview-settings-select', - behaviors: [SettingsBehavior, print_preview.SelectBehavior], + _template: html`{__html_template__}`, + + behaviors: [SettingsBehavior, SelectBehavior], properties: { - /** @type {{ option: Array<!print_preview.SelectOption> }} */ + /** @type {{ option: Array<!SelectOption> }} */ capability: Object, settingName: String, @@ -29,7 +38,7 @@ }, /** - * @param {!print_preview.SelectOption} option Option to check. + * @param {!SelectOption} option Option to check. * @return {boolean} Whether the option is selected. * @private */ @@ -44,7 +53,7 @@ }, /** - * @param {!print_preview.SelectOption} option Option to get the value + * @param {!SelectOption} option Option to get the value * for. * @return {string} Value for the option. * @private @@ -54,7 +63,7 @@ }, /** - * @param {!print_preview.SelectOption} option Option to get the display + * @param {!SelectOption} option Option to get the display * name for. * @return {string} Display name for the option. * @private
diff --git a/chrome/browser/resources/print_preview/ui/sidebar.html b/chrome/browser/resources/print_preview/ui/sidebar.html index fa64549..3412486 100644 --- a/chrome/browser/resources/print_preview/ui/sidebar.html +++ b/chrome/browser/resources/print_preview/ui/sidebar.html
@@ -1,44 +1,4 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_container_shadow_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="../metrics.html"> -<link rel="import" href="../dark_mode_behavior.html"> -<link rel="import" href="../data/destination.html"> -<link rel="import" href="../data/state.html"> -<link rel="import" href="advanced_options_settings.html"> -<link rel="import" href="button_strip.html"> -<link rel="import" href="color_settings.html"> -<link rel="import" href="copies_settings.html"> -<link rel="import" href="destination_settings.html"> -<link rel="import" href="dpi_settings.html"> -<link rel="import" href="duplex_settings.html"> -<link rel="import" href="header.html"> -<link rel="import" href="layout_settings.html"> -<link rel="import" href="media_size_settings.html"> -<link rel="import" href="margins_settings.html"> -<link rel="import" href="more_settings.html"> -<link rel="import" href="other_options_settings.html"> -<link rel="import" href="pages_per_sheet_settings.html"> -<link rel="import" href="pages_settings.html"> -<if expr="chromeos"> - <link rel="import" href="pin_settings.html"> -</if> -<link rel="import" href="print_preview_vars_css.html"> -<link rel="import" href="scaling_settings.html"> -<link rel="import" href="settings_behavior.html"> -<link rel="import" href="strings.html"> - -<if expr="not chromeos"> - <link rel="import" href="link_container.html"> -</if> -<dom-module id="print-preview-sidebar"> - <template> <style include="cr-hidden-style cr-shared-style"> :host { background-color: white; @@ -174,6 +134,3 @@ state="[[state]]" first-load="[[firstLoad_]]" on-print-button-focused="onPrintButtonFocused_"> </print-preview-button-strip> - </template> - <script src="sidebar.js"></script> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/sidebar.js b/chrome/browser/resources/print_preview/ui/sidebar.js index 7a25a354..9e1abc1 100644 --- a/chrome/browser/resources/print_preview/ui/sidebar.js +++ b/chrome/browser/resources/print_preview/ui/sidebar.js
@@ -2,8 +2,44 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -(function() { -'use strict'; +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {CrContainerShadowBehavior} from 'chrome://resources/cr_elements/cr_container_shadow_behavior.m.js'; +import 'chrome://resources/cr_elements/hidden_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_style_css.m.js'; +import 'chrome://resources/cr_elements/shared_vars_css.m.js'; +import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import 'chrome://resources/polymer/v3_0/iron-collapse/iron-collapse.js'; +import {CloudPrintInterface} from '../cloud_print_interface.js'; +import {Metrics, MetricsContext} from '../metrics.js'; +import {DarkModeBehavior} from '../dark_mode_behavior.js'; +import {Destination} from '../data/destination.js'; +import {Error, State} from '../data/state.js'; +import './advanced_options_settings.js'; +import './button_strip.js'; +import './color_settings.js'; +import './copies_settings.js'; +import {DestinationState} from './destination_settings.js'; +import './dpi_settings.js'; +import './duplex_settings.js'; +import './header.js'; +import './layout_settings.js'; +import './media_size_settings.js'; +import './margins_settings.js'; +import './more_settings.js'; +import './other_options_settings.js'; +import './pages_per_sheet_settings.js'; +import './pages_settings.js'; +// <if expr="chromeos"> +import './pin_settings.js'; +// </if> +import './print_preview_vars_css.js'; +import './scaling_settings.js'; +import {SettingsBehavior} from './settings_behavior.js'; +import '../strings.m.js'; +// <if expr="not chromeos"> +import './link_container.js'; +// </if> /** * Number of settings sections to show when "More settings" is collapsed. @@ -14,34 +50,36 @@ Polymer({ is: 'print-preview-sidebar', + _template: html`{__html_template__}`, + behaviors: [ SettingsBehavior, CrContainerShadowBehavior, WebUIListenerBehavior, - print_preview.DarkModeBehavior, + DarkModeBehavior, ], properties: { cloudPrintErrorMessage: String, - /** @type {cloudprint.CloudPrintInterface} */ + /** @type {CloudPrintInterface} */ cloudPrintInterface: Object, controlsManaged: Boolean, - /** @type {print_preview.Destination} */ + /** @type {Destination} */ destination: { type: Object, notify: true, }, - /** @private {!print_preview.DestinationState} */ + /** @private {!DestinationState} */ destinationState: { type: Number, notify: true, }, - /** @type {!print_preview.Error} */ + /** @type {!Error} */ error: { type: Number, notify: true, @@ -51,7 +89,7 @@ pageCount: Number, - /** @type {!print_preview.State} */ + /** @type {!State} */ state: { type: Number, observer: 'onStateChanged_', @@ -116,7 +154,7 @@ * @private */ computeControlsDisabled_: function() { - return this.state != print_preview.State.READY; + return this.state != State.READY; }, /** @@ -155,16 +193,16 @@ }, onStateChanged_: function() { - if (this.state !== print_preview.State.PRINTING) { + if (this.state !== State.PRINTING) { return; } if (this.shouldShowMoreSettings_) { - print_preview.MetricsContext.printSettingsUi().record( + MetricsContext.printSettingsUi().record( this.settingsExpandedByUser_ ? - print_preview.Metrics.PrintSettingsUiBucket + Metrics.PrintSettingsUiBucket .PRINT_WITH_SETTINGS_EXPANDED : - print_preview.Metrics.PrintSettingsUiBucket + Metrics.PrintSettingsUiBucket .PRINT_WITH_SETTINGS_COLLAPSED); } }, @@ -175,4 +213,3 @@ return !!linkContainer && linkContainer.systemDialogLinkAvailable(); }, }); -})();
diff --git a/chrome/browser/resources/print_preview/ui/strings.html b/chrome/browser/resources/print_preview/ui/strings.html deleted file mode 100644 index 3bf6630..0000000 --- a/chrome/browser/resources/print_preview/ui/strings.html +++ /dev/null
@@ -1,2 +0,0 @@ -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<script src="../strings.js"></script>
diff --git a/chrome/browser/resources/print_preview/ui/throbber_css.html b/chrome/browser/resources/print_preview/ui/throbber_css.html index 747c166..79e435c 100644 --- a/chrome/browser/resources/print_preview/ui/throbber_css.html +++ b/chrome/browser/resources/print_preview/ui/throbber_css.html
@@ -1,7 +1,4 @@ -<!-- Styles copied from resources/css/throbber.css. --> -<link rel="import" href="chrome://resources/html/polymer.html"> -<dom-module id="throbber"> <template> <style> .throbber { @@ -12,4 +9,3 @@ } </style> </template> -</dom-module>
diff --git a/chrome/browser/resources/print_preview/ui/throbber_css.js b/chrome/browser/resources/print_preview/ui/throbber_css.js new file mode 100644 index 0000000..a6cbb0f --- /dev/null +++ b/chrome/browser/resources/print_preview/ui/throbber_css.js
@@ -0,0 +1,10 @@ +// 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. + +import {Polymer, html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +const template = document.createElement('template'); +template.innerHTML = ` +<dom-module id="throbber" assetpath="chrome://resources/">{__html_template__}</dom-module> +`; +document.body.appendChild(template.content.cloneNode(true));
diff --git a/chrome/browser/resources/usb_internals/usb_internals.js b/chrome/browser/resources/usb_internals/usb_internals.js index 45bce59..6d9fc98 100644 --- a/chrome/browser/resources/usb_internals/usb_internals.js +++ b/chrome/browser/resources/usb_internals/usb_internals.js
@@ -21,7 +21,7 @@ /** @type {device.mojom.UsbDeviceManagerRemote} */ const usbManager = new device.mojom.UsbDeviceManagerRemote; await pageHandler.bindUsbDeviceManagerInterface( - usbManager.$.createRequest()); + usbManager.$.bindNewPipeAndPassReceiver()); /** @private {devices_page.DevicesPage} */ this.devicesPage_ = new devices_page.DevicesPage(usbManager); @@ -29,7 +29,7 @@ /** @private {device.mojom.UsbDeviceManagerTestRemote} */ this.usbManagerTest_ = new device.mojom.UsbDeviceManagerTestRemote; await pageHandler.bindTestInterface( - this.usbManagerTest_.$.createRequest()); + this.usbManagerTest_.$.bindNewPipeAndPassReceiver()); $('add-test-device-form').addEventListener('submit', (event) => { this.addTestDevice(event);
diff --git a/chrome/browser/search/instant_service.cc b/chrome/browser/search/instant_service.cc index 1613d897..46c1007 100644 --- a/chrome/browser/search/instant_service.cc +++ b/chrome/browser/search/instant_service.cc
@@ -408,18 +408,18 @@ return true; } -void InstantService::UpdateThemeInfo() { - ApplyOrResetCustomBackgroundThemeInfo(); - SetNtpElementsThemeInfo(); +void InstantService::UpdateNtpTheme() { + ApplyOrResetCustomBackgroundNtpTheme(); + SetNtpElementsNtpTheme(); - NotifyAboutThemeInfo(); + NotifyAboutNtpTheme(); } void InstantService::UpdateBackgroundFromSync() { // Any incoming change to synced background data should clear the local image. pref_service_->SetBoolean(prefs::kNtpCustomBackgroundLocalToDevice, false); RemoveLocalBackgroundImageCopy(); - UpdateThemeInfo(); + UpdateNtpTheme(); } void InstantService::UpdateMostVisitedInfo() { @@ -483,7 +483,7 @@ // background saved, UpdateBackgroundFromSync will not fire. Therefore, we // need to force a refresh here. if (need_forced_refresh) { - UpdateThemeInfo(); + UpdateNtpTheme(); } } } @@ -491,7 +491,7 @@ void InstantService::SetBackgroundToLocalResource() { background_updated_timestamp_ = base::TimeTicks::Now(); pref_service_->SetBoolean(prefs::kNtpCustomBackgroundLocalToDevice, true); - UpdateThemeInfo(); + UpdateNtpTheme(); } void InstantService::SelectLocalBackgroundImage(const base::FilePath& path) { @@ -503,12 +503,12 @@ weak_ptr_factory_.GetWeakPtr())); } -ThemeBackgroundInfo* InstantService::GetInitializedThemeInfo() { +NtpTheme* InstantService::GetInitializedNtpTheme() { RefreshBackgroundIfNeeded(); - if (!theme_info_) - BuildThemeInfo(); - return theme_info_.get(); + if (!theme_) + BuildNtpTheme(); + return theme_.get(); } void InstantService::SetNativeThemeForTesting(ui::NativeTheme* theme) { @@ -582,8 +582,8 @@ break; } case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: - theme_info_ = nullptr; - UpdateThemeInfo(); + theme_ = nullptr; + UpdateNtpTheme(); break; default: NOTREACHED() << "Unexpected notification type in InstantService."; @@ -604,8 +604,8 @@ DCHECK_EQ(observed_theme, native_theme_); // Force the theme information to rebuild so the correct using_dark_colors // value is sent to the renderer. - BuildThemeInfo(); - UpdateThemeInfo(); + BuildNtpTheme(); + UpdateNtpTheme(); } void InstantService::OnSearchProviderChanged() { @@ -644,9 +644,9 @@ observer.MostVisitedInfoChanged(*most_visited_info_); } -void InstantService::NotifyAboutThemeInfo() { +void InstantService::NotifyAboutNtpTheme() { for (InstantServiceObserver& observer : observers_) - observer.ThemeInfoChanged(*theme_info_); + observer.NtpThemeChanged(*theme_); } bool InstantService::IsCustomLinksEnabled() { @@ -654,26 +654,26 @@ !pref_service_->GetBoolean(prefs::kNtpUseMostVisitedTiles); } -void InstantService::BuildThemeInfo() { +void InstantService::BuildNtpTheme() { // Get theme information from theme service. - theme_info_.reset(new ThemeBackgroundInfo()); + theme_.reset(new NtpTheme()); // Get if the current theme is the default theme. ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile_); - theme_info_->using_default_theme = theme_service->UsingDefaultTheme(); + theme_->using_default_theme = theme_service->UsingDefaultTheme(); - theme_info_->using_dark_colors = native_theme_->ShouldUseDarkColors(); + theme_->using_dark_colors = native_theme_->ShouldUseDarkColors(); // Get theme colors. const ui::ThemeProvider& theme_provider = ThemeService::GetThemeProviderForProfile(profile_); // Set colors. - theme_info_->background_color = + theme_->background_color = theme_provider.GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); - theme_info_->text_color_light = + theme_->text_color_light = theme_provider.GetColor(ThemeProperties::COLOR_NTP_TEXT_LIGHT); - SetNtpElementsThemeInfo(); + SetNtpElementsNtpTheme(); if (theme_service->UsingExtensionTheme()) { const extensions::Extension* extension = @@ -681,72 +681,66 @@ ->enabled_extensions() .GetByID(theme_service->GetThemeID()); if (extension) { - theme_info_->theme_id = theme_service->GetThemeID(); - theme_info_->theme_name = extension->name(); + theme_->theme_id = theme_service->GetThemeID(); + theme_->theme_name = extension->name(); if (theme_provider.HasCustomImage(IDR_THEME_NTP_BACKGROUND)) { - theme_info_->has_theme_image = true; + theme_->has_theme_image = true; // Set theme background image horizontal alignment. int alignment = theme_provider.GetDisplayProperty( ThemeProperties::NTP_BACKGROUND_ALIGNMENT); if (alignment & ThemeProperties::ALIGN_LEFT) - theme_info_->image_horizontal_alignment = - THEME_BKGRND_IMAGE_ALIGN_LEFT; + theme_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_LEFT; else if (alignment & ThemeProperties::ALIGN_RIGHT) - theme_info_->image_horizontal_alignment = - THEME_BKGRND_IMAGE_ALIGN_RIGHT; + theme_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_RIGHT; else - theme_info_->image_horizontal_alignment = - THEME_BKGRND_IMAGE_ALIGN_CENTER; + theme_->image_horizontal_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; // Set theme background image vertical alignment. if (alignment & ThemeProperties::ALIGN_TOP) - theme_info_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; + theme_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_TOP; else if (alignment & ThemeProperties::ALIGN_BOTTOM) - theme_info_->image_vertical_alignment = - THEME_BKGRND_IMAGE_ALIGN_BOTTOM; + theme_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_BOTTOM; else - theme_info_->image_vertical_alignment = - THEME_BKGRND_IMAGE_ALIGN_CENTER; + theme_->image_vertical_alignment = THEME_BKGRND_IMAGE_ALIGN_CENTER; // Set theme background image tiling. int tiling = theme_provider.GetDisplayProperty( ThemeProperties::NTP_BACKGROUND_TILING); switch (tiling) { case ThemeProperties::NO_REPEAT: - theme_info_->image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; + theme_->image_tiling = THEME_BKGRND_IMAGE_NO_REPEAT; break; case ThemeProperties::REPEAT_X: - theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; + theme_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_X; break; case ThemeProperties::REPEAT_Y: - theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; + theme_->image_tiling = THEME_BKGRND_IMAGE_REPEAT_Y; break; case ThemeProperties::REPEAT: - theme_info_->image_tiling = THEME_BKGRND_IMAGE_REPEAT; + theme_->image_tiling = THEME_BKGRND_IMAGE_REPEAT; break; } - theme_info_->has_attribution = + theme_->has_attribution = theme_provider.HasCustomImage(IDR_THEME_NTP_ATTRIBUTION); } } } else if (theme_service->UsingAutogenerated()) { - theme_info_->color_id = chrome_colors::ChromeColorsService::GetColorId( + theme_->color_id = chrome_colors::ChromeColorsService::GetColorId( theme_service->GetThemeColor()); - theme_info_->color_dark = - theme_provider.GetColor(ThemeProperties::COLOR_FRAME); - theme_info_->color_light = + theme_->color_dark = theme_provider.GetColor(ThemeProperties::COLOR_FRAME); + theme_->color_light = theme_provider.GetColor(ThemeProperties::COLOR_NTP_BACKGROUND); - theme_info_->color_picked = theme_service->GetThemeColor(); + theme_->color_picked = theme_service->GetThemeColor(); } } -void InstantService::ApplyOrResetCustomBackgroundThemeInfo() { +void InstantService::ApplyOrResetCustomBackgroundNtpTheme() { // Custom backgrounds for non-Google search providers are not supported. if (!search::DefaultSearchProviderIsGoogle(profile_)) { - ResetCustomBackgroundThemeInfo(); + ResetCustomBackgroundNtpTheme(); return; } @@ -756,27 +750,26 @@ std::string time_string = std::to_string(base::Time::Now().ToTimeT()); std::string local_string(chrome::kChromeSearchLocalNtpBackgroundUrl); GURL timestamped_url(local_string + "?ts=" + time_string); - GetInitializedThemeInfo()->custom_background_url = timestamped_url; - GetInitializedThemeInfo()->custom_background_attribution_line_1 = + GetInitializedNtpTheme()->custom_background_url = timestamped_url; + GetInitializedNtpTheme()->custom_background_attribution_line_1 = std::string(); - GetInitializedThemeInfo()->custom_background_attribution_line_2 = + GetInitializedNtpTheme()->custom_background_attribution_line_2 = std::string(); - GetInitializedThemeInfo()->custom_background_attribution_action_url = - GURL(); + GetInitializedNtpTheme()->custom_background_attribution_action_url = GURL(); return; } // Attempt to get custom background URL from preferences. GURL custom_background_url; if (!IsCustomBackgroundPrefValid(custom_background_url)) { - ResetCustomBackgroundThemeInfo(); + ResetCustomBackgroundNtpTheme(); return; } - ApplyCustomBackgroundThemeInfo(); + ApplyCustomBackgroundNtpTheme(); } -void InstantService::ApplyCustomBackgroundThemeInfo() { +void InstantService::ApplyCustomBackgroundNtpTheme() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); const base::DictionaryValue* background_info = pref_service_->GetDictionary(prefs::kNtpCustomBackgroundDict); @@ -797,17 +790,17 @@ background_info->FindKey(kNtpCustomBackgroundAttributionLine2); const base::Value* attribution_action_url = background_info->FindKey(kNtpCustomBackgroundAttributionActionURL); - ThemeBackgroundInfo* theme_info = GetInitializedThemeInfo(); - theme_info->custom_background_url = custom_background_url; - theme_info->collection_id = collection_id; + NtpTheme* theme = GetInitializedNtpTheme(); + theme->custom_background_url = custom_background_url; + theme->collection_id = collection_id; if (attribution_line_1) { - theme_info->custom_background_attribution_line_1 = + theme->custom_background_attribution_line_1 = background_info->FindKey(kNtpCustomBackgroundAttributionLine1) ->GetString(); } if (attribution_line_2) { - theme_info->custom_background_attribution_line_2 = + theme->custom_background_attribution_line_2 = background_info->FindKey(kNtpCustomBackgroundAttributionLine2) ->GetString(); } @@ -817,28 +810,28 @@ ->GetString()); if (!action_url.SchemeIsCryptographic()) { - theme_info->custom_background_attribution_action_url = GURL(); + theme->custom_background_attribution_action_url = GURL(); } else { - theme_info->custom_background_attribution_action_url = action_url; + theme->custom_background_attribution_action_url = action_url; } } } -void InstantService::ResetCustomBackgroundThemeInfo() { +void InstantService::ResetCustomBackgroundNtpTheme() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); pref_service_->ClearPref(prefs::kNtpCustomBackgroundDict); pref_service_->SetBoolean(prefs::kNtpCustomBackgroundLocalToDevice, false); RemoveLocalBackgroundImageCopy(); - FallbackToDefaultThemeInfo(); + FallbackToDefaultNtpTheme(); } -void InstantService::FallbackToDefaultThemeInfo() { - ThemeBackgroundInfo* theme_info = GetInitializedThemeInfo(); - theme_info->custom_background_url = GURL(); - theme_info->custom_background_attribution_line_1 = std::string(); - theme_info->custom_background_attribution_line_2 = std::string(); - theme_info->custom_background_attribution_action_url = GURL(); - theme_info->collection_id = std::string(); +void InstantService::FallbackToDefaultNtpTheme() { + NtpTheme* theme = GetInitializedNtpTheme(); + theme->custom_background_url = GURL(); + theme->custom_background_attribution_line_1 = std::string(); + theme->custom_background_attribution_line_2 = std::string(); + theme->custom_background_attribution_action_url = GURL(); + theme->collection_id = std::string(); } bool InstantService::IsCustomBackgroundSet() { @@ -865,7 +858,7 @@ void InstantService::ResetToDefault() { ResetCustomLinks(); - ResetCustomBackgroundThemeInfo(); + ResetCustomBackgroundNtpTheme(); pref_service_->SetBoolean(prefs::kNtpUseMostVisitedTiles, false); pref_service_->SetBoolean(prefs::kNtpShortcutsVisible, true); } @@ -1014,31 +1007,31 @@ clock_ = clock; } -void InstantService::SetNtpElementsThemeInfo() { - ThemeBackgroundInfo* theme_info = GetInitializedThemeInfo(); +void InstantService::SetNtpElementsNtpTheme() { + NtpTheme* theme = GetInitializedNtpTheme(); if (IsCustomBackgroundSet()) { - theme_info->text_color = gfx::kGoogleGrey050; - theme_info->logo_alternate = true; - theme_info->logo_color = ThemeProperties::GetDefaultColor( + theme->text_color = gfx::kGoogleGrey050; + theme->logo_alternate = true; + theme->logo_color = ThemeProperties::GetDefaultColor( ThemeProperties::COLOR_NTP_LOGO, false); - theme_info->shortcut_color = ThemeProperties::GetDefaultColor( + theme->shortcut_color = ThemeProperties::GetDefaultColor( ThemeProperties::COLOR_NTP_SHORTCUT, false); } else { const ui::ThemeProvider& theme_provider = ThemeService::GetThemeProviderForProfile(profile_); - theme_info->text_color = + theme->text_color = theme_provider.GetColor(ThemeProperties::COLOR_NTP_TEXT); - theme_info->logo_alternate = theme_provider.GetDisplayProperty( - ThemeProperties::NTP_LOGO_ALTERNATE) == 1; - theme_info->logo_color = + theme->logo_alternate = theme_provider.GetDisplayProperty( + ThemeProperties::NTP_LOGO_ALTERNATE) == 1; + theme->logo_color = theme_provider.GetColor(ThemeProperties::COLOR_NTP_LOGO); // For default theme in dark mode use dark shortcuts. if (native_theme_->ShouldUseDarkColors() && ThemeServiceFactory::GetForProfile(profile_)->UsingDefaultTheme()) { - theme_info->shortcut_color = gfx::kGoogleGrey900; + theme->shortcut_color = gfx::kGoogleGrey900; } else { - theme_info->shortcut_color = + theme->shortcut_color = theme_provider.GetColor(ThemeProperties::COLOR_NTP_SHORTCUT); } }
diff --git a/chrome/browser/search/instant_service.h b/chrome/browser/search/instant_service.h index a2de87f..db7d2631 100644 --- a/chrome/browser/search/instant_service.h +++ b/chrome/browser/search/instant_service.h
@@ -42,7 +42,7 @@ class Profile; struct CollectionImage; struct InstantMostVisitedInfo; -struct ThemeBackgroundInfo; +struct NtpTheme; namespace content { class RenderProcessHost; @@ -122,7 +122,7 @@ bool ToggleShortcutsVisibility(bool do_notify); // Invoked to update theme information for the NTP. - void UpdateThemeInfo(); + void UpdateNtpTheme(); // Invoked when a background pref update is received via sync, triggering // an update of theme info. @@ -148,8 +148,8 @@ // Invoked when a user selected the "Upload an image" option on the NTP. void SelectLocalBackgroundImage(const base::FilePath& path); - // Getter for |theme_info_| that will also initialize it if necessary. - ThemeBackgroundInfo* GetInitializedThemeInfo(); + // Getter for |theme_| that will also initialize it if necessary. + NtpTheme* GetInitializedNtpTheme(); // Used for testing. void SetNativeThemeForTesting(ui::NativeTheme* theme); @@ -202,7 +202,7 @@ DoesToggleMostVisitedOrCustomLinks); FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, DoesToggleShortcutsVisibility); FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, IsCustomLinksEnabled); - FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, TestNoThemeInfo); + FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, TestNoNtpTheme); FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, TestUpdateCustomBackgroundColor); FRIEND_TEST_ALL_PREFIXES(InstantServiceTest, LocalImageDoesNotUpdateCustomBackgroundColor); @@ -239,22 +239,22 @@ void OnIconMadeAvailable(const GURL& site_url) override; void NotifyAboutMostVisitedInfo(); - void NotifyAboutThemeInfo(); + void NotifyAboutNtpTheme(); // Returns true if this is a Google NTP and the user has chosen to show custom // links. bool IsCustomLinksEnabled(); - void BuildThemeInfo(); + void BuildNtpTheme(); - void ApplyOrResetCustomBackgroundThemeInfo(); + void ApplyOrResetCustomBackgroundNtpTheme(); - void ApplyCustomBackgroundThemeInfo(); + void ApplyCustomBackgroundNtpTheme(); // Marked virtual for mocking in tests. - virtual void ResetCustomBackgroundThemeInfo(); + virtual void ResetCustomBackgroundNtpTheme(); - void FallbackToDefaultThemeInfo(); + void FallbackToDefaultNtpTheme(); void RemoveLocalBackgroundImageCopy(); @@ -284,7 +284,7 @@ // Sets NTP elements theme info that are overridden when custom // background is used. - void SetNtpElementsThemeInfo(); + void SetNtpElementsNtpTheme(); Profile* const profile_; @@ -296,7 +296,7 @@ std::unique_ptr<InstantMostVisitedInfo> most_visited_info_; // Theme-related data for NTP overlay to adopt themes. - std::unique_ptr<ThemeBackgroundInfo> theme_info_; + std::unique_ptr<NtpTheme> theme_; base::ObserverList<InstantServiceObserver>::Unchecked observers_;
diff --git a/chrome/browser/search/instant_service_observer.cc b/chrome/browser/search/instant_service_observer.cc index 99bd74b7..ae2ec505 100644 --- a/chrome/browser/search/instant_service_observer.cc +++ b/chrome/browser/search/instant_service_observer.cc
@@ -4,8 +4,7 @@ #include "chrome/browser/search/instant_service_observer.h" -void InstantServiceObserver::ThemeInfoChanged(const ThemeBackgroundInfo&) { -} +void InstantServiceObserver::NtpThemeChanged(const NtpTheme&) {} void InstantServiceObserver::MostVisitedInfoChanged( const InstantMostVisitedInfo&) {}
diff --git a/chrome/browser/search/instant_service_observer.h b/chrome/browser/search/instant_service_observer.h index 6edce68..29b80c5 100644 --- a/chrome/browser/search/instant_service_observer.h +++ b/chrome/browser/search/instant_service_observer.h
@@ -14,13 +14,13 @@ #endif struct InstantMostVisitedInfo; -struct ThemeBackgroundInfo; +struct NtpTheme; // InstantServiceObserver defines the observer interface for InstantService. class InstantServiceObserver { public: // Indicates that the user's custom theme has changed in some way. - virtual void ThemeInfoChanged(const ThemeBackgroundInfo&); + virtual void NtpThemeChanged(const NtpTheme&); // Indicates that the most visited items have changed in some way. virtual void MostVisitedInfoChanged(const InstantMostVisitedInfo&);
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc index cee285c..3b7004c 100644 --- a/chrome/browser/search/instant_service_unittest.cc +++ b/chrome/browser/search/instant_service_unittest.cc
@@ -37,7 +37,7 @@ class MockInstantServiceObserver : public InstantServiceObserver { public: - MOCK_METHOD1(ThemeInfoChanged, void(const ThemeBackgroundInfo&)); + MOCK_METHOD1(NtpThemeChanged, void(const NtpTheme&)); MOCK_METHOD1(MostVisitedInfoChanged, void(const InstantMostVisitedInfo&)); }; @@ -76,7 +76,7 @@ ~MockInstantService() override = default; MOCK_METHOD0(ResetCustomLinks, bool()); - MOCK_METHOD0(ResetCustomBackgroundThemeInfo, void()); + MOCK_METHOD0(ResetCustomBackgroundNtpTheme, void()); }; bool CheckBackgroundColor(SkColor color, @@ -210,8 +210,8 @@ instant_service_->AddValidBackdropUrlForTesting(kUrl); instant_service_->SetCustomBackgroundInfo(kUrl, "", "", GURL(), ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrl, theme_info->custom_background_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrl, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); } @@ -222,13 +222,13 @@ instant_service_->AddValidBackdropUrlForTesting(kValidUrl); instant_service_->SetCustomBackgroundInfo(kValidUrl, "", "", GURL(), ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kValidUrl.spec(), theme_info->custom_background_url.spec()); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kValidUrl.spec(), theme->custom_background_url.spec()); instant_service_->SetCustomBackgroundInfo(kInvalidUrl, "", "", GURL(), ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ("", theme_info->custom_background_url.spec()); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ("", theme->custom_background_url.spec()); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); } @@ -242,17 +242,15 @@ instant_service_->SetCustomBackgroundInfo(kUrl, kAttributionLine1, kAttributionLine2, kActionUrl, ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrl, theme_info->custom_background_url); - EXPECT_EQ(kAttributionLine1, - theme_info->custom_background_attribution_line_1); - EXPECT_EQ(kAttributionLine2, - theme_info->custom_background_attribution_line_2); - EXPECT_EQ(kActionUrl, theme_info->custom_background_attribution_action_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrl, theme->custom_background_url); + EXPECT_EQ(kAttributionLine1, theme->custom_background_attribution_line_1); + EXPECT_EQ(kAttributionLine2, theme->custom_background_attribution_line_2); + EXPECT_EQ(kActionUrl, theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); } -TEST_F(InstantServiceTest, ChangingSearchProviderClearsThemeInfoAndPref) { +TEST_F(InstantServiceTest, ChangingSearchProviderClearsNtpThemeAndPref) { ASSERT_FALSE(instant_service_->IsCustomBackgroundSet()); const GURL kUrl("https://www.foo.com"); const std::string kAttributionLine1 = "foo"; @@ -264,33 +262,31 @@ instant_service_->SetCustomBackgroundInfo(kUrl, kAttributionLine1, kAttributionLine2, kActionUrl, ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrl, theme_info->custom_background_url); - EXPECT_EQ(kAttributionLine1, - theme_info->custom_background_attribution_line_1); - EXPECT_EQ(kAttributionLine2, - theme_info->custom_background_attribution_line_2); - EXPECT_EQ(kActionUrl, theme_info->custom_background_attribution_action_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrl, theme->custom_background_url); + EXPECT_EQ(kAttributionLine1, theme->custom_background_attribution_line_1); + EXPECT_EQ(kAttributionLine2, theme->custom_background_attribution_line_2); + EXPECT_EQ(kActionUrl, theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); SetUserSelectedDefaultSearchProvider("https://www.search.com"); - instant_service_->UpdateThemeInfo(); + instant_service_->UpdateNtpTheme(); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_url); - EXPECT_EQ("", theme_info->custom_background_attribution_line_1); - EXPECT_EQ("", theme_info->custom_background_attribution_line_2); - EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_url); + EXPECT_EQ("", theme->custom_background_attribution_line_1); + EXPECT_EQ("", theme->custom_background_attribution_line_2); + EXPECT_EQ(GURL(), theme->custom_background_attribution_action_url); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); SetUserSelectedDefaultSearchProvider("{google:baseURL}"); - instant_service_->UpdateThemeInfo(); + instant_service_->UpdateNtpTheme(); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_url); - EXPECT_EQ("", theme_info->custom_background_attribution_line_1); - EXPECT_EQ("", theme_info->custom_background_attribution_line_2); - EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_url); + EXPECT_EQ("", theme->custom_background_attribution_line_1); + EXPECT_EQ("", theme->custom_background_attribution_line_2); + EXPECT_EQ(GURL(), theme->custom_background_attribution_action_url); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); } @@ -327,7 +323,7 @@ base::WriteFile(path, "background_image", 16); SetUserSelectedDefaultSearchProvider("https://www.search.com"); - instant_service_->UpdateThemeInfo(); + instant_service_->UpdateNtpTheme(); task_environment()->RunUntilIdle(); @@ -351,7 +347,7 @@ instant_service_->AddValidBackdropUrlForTesting(kUrl); instant_service_->SetCustomBackgroundInfo(kUrl, "", "", GURL(), ""); - instant_service_->UpdateThemeInfo(); + instant_service_->UpdateNtpTheme(); task_environment()->RunUntilIdle(); @@ -376,35 +372,33 @@ instant_service_->SetCustomBackgroundInfo( kUrl, kAttributionLine1, kAttributionLine2, kHttpsActionUrl, ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kHttpsActionUrl, - theme_info->custom_background_attribution_action_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kHttpsActionUrl, theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo( kUrl, kAttributionLine1, kAttributionLine2, kHttpActionUrl, ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo( kUrl, kAttributionLine1, kAttributionLine2, kHttpsActionUrl, ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kHttpsActionUrl, - theme_info->custom_background_attribution_action_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kHttpsActionUrl, theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo(kUrl, kAttributionLine1, kAttributionLine2, GURL(), ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_attribution_action_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); } -TEST_F(InstantServiceTest, UpdatingPrefUpdatesThemeInfo) { +TEST_F(InstantServiceTest, UpdatingPrefUpdatesNtpTheme) { ASSERT_FALSE(instant_service_->IsCustomBackgroundSet()); const GURL kUrlFoo("https://www.foo.com"); const GURL kUrlBar("https://www.bar.com"); @@ -415,16 +409,16 @@ prefs::kNtpCustomBackgroundDict, std::make_unique<base::Value>(GetBackgroundInfoAsDict(kUrlFoo))); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrlFoo, theme_info->custom_background_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrlFoo, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); pref_service->SetUserPref( prefs::kNtpCustomBackgroundDict, std::make_unique<base::Value>(GetBackgroundInfoAsDict(kUrlBar))); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrlBar, theme_info->custom_background_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrlBar, theme->custom_background_url); EXPECT_EQ(false, pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice)); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); @@ -446,8 +440,8 @@ instant_service_->SelectLocalBackgroundImage(path); task_environment()->RunUntilIdle(); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_TRUE(base::StartsWith(theme_info->custom_background_url.spec(), + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_TRUE(base::StartsWith(theme->custom_background_url.spec(), chrome::kChromeSearchLocalNtpBackgroundUrl, base::CompareCase::SENSITIVE)); EXPECT_TRUE( @@ -481,8 +475,8 @@ std::make_unique<base::Value>(GetBackgroundInfoAsDict(kUrl))); task_environment()->RunUntilIdle(); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kUrl, theme_info->custom_background_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kUrl, theme->custom_background_url); EXPECT_FALSE( pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice)); EXPECT_FALSE(base::PathExists(path)); @@ -500,43 +494,43 @@ instant_service_->AddValidBackdropUrlForTesting(kBackdropUrl2); instant_service_->SetCustomBackgroundInfo(kBackdropUrl1, "", "", GURL(), ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kBackdropUrl1, theme_info->custom_background_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kBackdropUrl1, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo(kNonBackdropUrl1, "", "", GURL(), ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_url); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo(kBackdropUrl2, "", "", GURL(), ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kBackdropUrl2, theme_info->custom_background_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kBackdropUrl2, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); instant_service_->SetCustomBackgroundInfo(kNonBackdropUrl2, "", "", GURL(), ""); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(GURL(), theme_info->custom_background_url); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(GURL(), theme->custom_background_url); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); } -TEST_F(InstantServiceTest, TestNoThemeInfo) { - instant_service_->theme_info_ = nullptr; - EXPECT_NE(nullptr, instant_service_->GetInitializedThemeInfo()); +TEST_F(InstantServiceTest, TestNoNtpTheme) { + instant_service_->theme_ = nullptr; + EXPECT_NE(nullptr, instant_service_->GetInitializedNtpTheme()); - instant_service_->theme_info_ = nullptr; - // As |FallbackToDefaultThemeInfo| uses |theme_info_| it should initialize it + instant_service_->theme_ = nullptr; + // As |FallbackToDefaultNtpTheme| uses |theme_| it should initialize it // otherwise the test should crash. - instant_service_->FallbackToDefaultThemeInfo(); - EXPECT_NE(nullptr, instant_service_->theme_info_); + instant_service_->FallbackToDefaultNtpTheme(); + EXPECT_NE(nullptr, instant_service_->theme_); } TEST_F(InstantServiceTest, TestResetToDefault) { MockInstantService mock_instant_service_(profile()); EXPECT_CALL(mock_instant_service_, ResetCustomLinks()); - EXPECT_CALL(mock_instant_service_, ResetCustomBackgroundThemeInfo()); + EXPECT_CALL(mock_instant_service_, ResetCustomBackgroundNtpTheme()); mock_instant_service_.ResetToDefault(); } @@ -567,12 +561,10 @@ instant_service_->SetCustomBackgroundInfo(kUrl, kAttributionLine1, kAttributionLine2, kActionUrl, ""); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - ASSERT_EQ(kAttributionLine1, - theme_info->custom_background_attribution_line_1); - ASSERT_EQ(kAttributionLine2, - theme_info->custom_background_attribution_line_2); - ASSERT_EQ(kActionUrl, theme_info->custom_background_attribution_action_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + ASSERT_EQ(kAttributionLine1, theme->custom_background_attribution_line_1); + ASSERT_EQ(kAttributionLine2, theme->custom_background_attribution_line_2); + ASSERT_EQ(kActionUrl, theme->custom_background_attribution_action_url); ASSERT_TRUE(instant_service_->IsCustomBackgroundSet()); base::FilePath profile_path = profile()->GetPath(); @@ -584,16 +576,16 @@ instant_service_->SelectLocalBackgroundImage(path); task_environment()->RunUntilIdle(); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_TRUE(base::StartsWith(theme_info->custom_background_url.spec(), + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_TRUE(base::StartsWith(theme->custom_background_url.spec(), chrome::kChromeSearchLocalNtpBackgroundUrl, base::CompareCase::SENSITIVE)); EXPECT_TRUE( pref_service->GetBoolean(prefs::kNtpCustomBackgroundLocalToDevice)); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); - EXPECT_EQ("", theme_info->custom_background_attribution_line_1); - EXPECT_EQ("", theme_info->custom_background_attribution_line_2); - EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url); + EXPECT_EQ("", theme->custom_background_attribution_line_1); + EXPECT_EQ("", theme->custom_background_attribution_line_2); + EXPECT_EQ(GURL(), theme->custom_background_attribution_action_url); } TEST_F(InstantServiceTest, TestUpdateCustomBackgroundColor) { @@ -698,8 +690,8 @@ instant_service_->SetCustomBackgroundInfo(GURL(), "", "", GURL(), kValidId); task_environment()->RunUntilIdle(); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kValidId, theme_info->collection_id); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kValidId, theme->collection_id); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); // An invalid id should clear the pref/background. @@ -708,8 +700,8 @@ instant_service_->SetCustomBackgroundInfo(GURL(), "", "", GURL(), kInvalidId); task_environment()->RunUntilIdle(); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(std::string(), theme_info->collection_id); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(std::string(), theme->collection_id); EXPECT_FALSE(instant_service_->IsCustomBackgroundSet()); } @@ -728,9 +720,9 @@ instant_service_->SetCustomBackgroundInfo(kUrl, "", "", GURL(), kValidId); task_environment()->RunUntilIdle(); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kValidId, theme_info->collection_id); - EXPECT_EQ("https://www.test.com/", theme_info->custom_background_url); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kValidId, theme->collection_id); + EXPECT_EQ("https://www.test.com/", theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); } @@ -753,8 +745,8 @@ instant_service_->SetCustomBackgroundInfo(GURL(), "", "", GURL(), kValidId); task_environment()->RunUntilIdle(); - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_EQ(kValidId, theme_info->collection_id); + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_EQ(kValidId, theme->collection_id); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); CollectionImage image2; @@ -763,24 +755,24 @@ instant_service_->SetNextCollectionImageForTesting(image2); // Should not refresh background. - theme_info = instant_service_->GetInitializedThemeInfo(); + theme = instant_service_->GetInitializedNtpTheme(); task_environment()->RunUntilIdle(); - EXPECT_EQ(kValidId, theme_info->collection_id); - EXPECT_EQ(kImageUrl1, theme_info->custom_background_url); + EXPECT_EQ(kValidId, theme->collection_id); + EXPECT_EQ(kImageUrl1, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); clock_->Advance(base::TimeDelta::FromHours(25)); // Should refresh background after >24 hours. - theme_info = instant_service_->GetInitializedThemeInfo(); + theme = instant_service_->GetInitializedNtpTheme(); task_environment()->RunUntilIdle(); - EXPECT_EQ(kValidId, theme_info->collection_id); - EXPECT_EQ(kImageUrl2, theme_info->custom_background_url); + EXPECT_EQ(kValidId, theme->collection_id); + EXPECT_EQ(kImageUrl2, theme->custom_background_url); EXPECT_TRUE(instant_service_->IsCustomBackgroundSet()); } -TEST_F(InstantServiceTest, SetNTPElementsThemeInfo) { - ThemeBackgroundInfo* theme_info = instant_service_->GetInitializedThemeInfo(); +TEST_F(InstantServiceTest, SetNTPElementsNtpTheme) { + NtpTheme* theme = instant_service_->GetInitializedNtpTheme(); SkColor default_text_color = ThemeProperties::GetDefaultColor(ThemeProperties::COLOR_NTP_TEXT, false); SkColor default_logo_color = @@ -791,12 +783,12 @@ ASSERT_FALSE(instant_service_->IsCustomBackgroundSet()); // Check defaults when no theme and no custom backgrounds is set. - EXPECT_EQ(default_text_color, theme_info->text_color); - EXPECT_FALSE(theme_info->logo_alternate); - EXPECT_EQ(default_logo_color, theme_info->logo_color); - EXPECT_EQ(default_shortcut_color, theme_info->shortcut_color); + EXPECT_EQ(default_text_color, theme->text_color); + EXPECT_FALSE(theme->logo_alternate); + EXPECT_EQ(default_logo_color, theme->logo_color); + EXPECT_EQ(default_shortcut_color, theme->shortcut_color); - // Install colors, theme update should trigger |SetNTPElementsThemeInfo| and + // Install colors, theme update should trigger |SetNTPElementsNtpTheme| and // update NTP themed elements info. ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile()); content::WindowedNotificationObserver theme_change_observer( @@ -805,22 +797,22 @@ theme_service->BuildFromColor(SK_ColorRED); theme_change_observer.Wait(); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_NE(default_text_color, theme_info->text_color); - EXPECT_TRUE(theme_info->logo_alternate); - EXPECT_NE(default_logo_color, theme_info->logo_color); - EXPECT_NE(default_shortcut_color, theme_info->shortcut_color); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_NE(default_text_color, theme->text_color); + EXPECT_TRUE(theme->logo_alternate); + EXPECT_NE(default_logo_color, theme->logo_color); + EXPECT_NE(default_shortcut_color, theme->shortcut_color); - // Setting a custom backgrounds should call |SetNTPElementsThemeInfo| and + // Setting a custom backgrounds should call |SetNTPElementsNtpTheme| and // update NTP themed elements info. const GURL kUrl("https://www.foo.com"); instant_service_->AddValidBackdropUrlForTesting(kUrl); instant_service_->SetCustomBackgroundInfo(kUrl, "", "", GURL(), ""); ASSERT_TRUE(instant_service_->IsCustomBackgroundSet()); - theme_info = instant_service_->GetInitializedThemeInfo(); - EXPECT_NE(default_text_color, theme_info->text_color); - EXPECT_TRUE(theme_info->logo_alternate); - EXPECT_EQ(default_logo_color, theme_info->logo_color); - EXPECT_EQ(default_shortcut_color, theme_info->shortcut_color); + theme = instant_service_->GetInitializedNtpTheme(); + EXPECT_NE(default_text_color, theme->text_color); + EXPECT_TRUE(theme->logo_alternate); + EXPECT_EQ(default_logo_color, theme->logo_color); + EXPECT_EQ(default_shortcut_color, theme->shortcut_color); }
diff --git a/chrome/browser/sharing/shared_clipboard/remote_copy_browsertest.cc b/chrome/browser/sharing/shared_clipboard/remote_copy_browsertest.cc index 3e263645..d846c76 100644 --- a/chrome/browser/sharing/shared_clipboard/remote_copy_browsertest.cc +++ b/chrome/browser/sharing/shared_clipboard/remote_copy_browsertest.cc
@@ -4,11 +4,9 @@ #include <memory> #include <string> -#include <vector> #include "base/guid.h" #include "base/macros.h" -#include "base/optional.h" #include "base/strings/utf_string_conversions.h" #include "base/test/scoped_feature_list.h" #include "chrome/browser/notifications/notification_display_service_tester.h" @@ -22,29 +20,13 @@ #include "chrome/grit/generated_resources.h" #include "chrome/test/base/in_process_browser_test.h" #include "ui/base/clipboard/clipboard.h" -#include "ui/base/clipboard/clipboard_constants.h" -#include "ui/base/clipboard/clipboard_monitor.h" -#include "ui/base/clipboard/clipboard_observer.h" #include "ui/base/clipboard/test/test_clipboard.h" #include "ui/base/l10n/l10n_util.h" #include "ui/message_center/public/cpp/notification.h" namespace { -const char kDeviceName[] = "test device name"; -const char kText[] = "test text"; - -class ClipboardObserver : public ui::ClipboardObserver { - public: - explicit ClipboardObserver(base::RepeatingClosure callback) - : callback_(callback) {} - - void OnClipboardDataChanged() override { callback_.Run(); } - - private: - base::RepeatingClosure callback_; - - DISALLOW_COPY_AND_ASSIGN(ClipboardObserver); -}; +const char kText[] = "clipboard text"; +const char kDeviceName[] = "DeviceName"; } // namespace // Browser tests for the Remote Copy feature. @@ -66,26 +48,13 @@ ui::Clipboard::DestroyClipboardForCurrentThread(); } - GURL StartServerAndGetURL(const std::string& relative_url) { - server_ = std::make_unique<net::EmbeddedTestServer>( - net::EmbeddedTestServer::TYPE_HTTPS); - server_->ServeFilesFromSourceDirectory(GetChromeTestDataDir()); - EXPECT_TRUE(server_->Start()); - return server_->GetURL(relative_url); - } - - gcm::IncomingMessage CreateMessage(const std::string& device_name, - base::Optional<std::string> text, - base::Optional<GURL> image_url) { + gcm::IncomingMessage CreateMessage(std::string guid, + std::string device_name, + std::string text) { chrome_browser_sharing::SharingMessage sharing_message; - sharing_message.set_sender_guid(base::GenerateGUID()); + sharing_message.set_sender_guid(guid); sharing_message.set_sender_device_name(device_name); - if (text) { - sharing_message.mutable_remote_copy_message()->set_text(text.value()); - } else if (image_url) { - sharing_message.mutable_remote_copy_message()->set_image_url( - image_url.value().possibly_invalid_spec()); - } + sharing_message.mutable_remote_copy_message()->set_text(text); gcm::IncomingMessage incoming_message; std::string serialized_sharing_message; @@ -94,44 +63,13 @@ return incoming_message; } - void SendTextMessage(const std::string& device_name, - const std::string& text) { - sharing_service_->GetFCMHandlerForTesting()->OnMessage( - kSharingFCMAppID, - CreateMessage(device_name, text, /*image_url=*/base::nullopt)); - } - - void SendImageMessage(const std::string& device_name, const GURL& image_url) { - base::RunLoop run_loop; - ClipboardObserver observer(run_loop.QuitClosure()); - ui::ClipboardMonitor::GetInstance()->AddObserver(&observer); - sharing_service_->GetFCMHandlerForTesting()->OnMessage( - kSharingFCMAppID, - CreateMessage(device_name, /*text*/ base::nullopt, image_url)); - run_loop.Run(); - ui::ClipboardMonitor::GetInstance()->RemoveObserver(&observer); - } - - std::vector<base::string16> GetAvailableClipboardTypes() { - std::vector<base::string16> types; - bool contains_filenames; - ui::Clipboard::GetForCurrentThread()->ReadAvailableTypes( - ui::ClipboardBuffer::kCopyPaste, &types, &contains_filenames); - return types; - } - - std::string ReadClipboardText() { + std::string GetClipboardText() { base::string16 text; ui::Clipboard::GetForCurrentThread()->ReadText( ui::ClipboardBuffer::kCopyPaste, &text); return base::UTF16ToUTF8(text); } - SkBitmap ReadClipboardImage() { - return ui::Clipboard::GetForCurrentThread()->ReadImage( - ui::ClipboardBuffer::kCopyPaste); - } - message_center::Notification GetNotification() { auto notifications = notification_tester_->GetDisplayedNotificationsForType( NotificationHandler::Type::SHARING); @@ -147,97 +85,25 @@ base::test::ScopedFeatureList feature_list_; std::unique_ptr<NotificationDisplayServiceTester> notification_tester_; SharingService* sharing_service_; - std::unique_ptr<net::EmbeddedTestServer> server_; private: DISALLOW_COPY_AND_ASSIGN(RemoteCopyBrowserTestBase); }; -class RemoteCopyDisabledBrowserTest : public RemoteCopyBrowserTestBase { - public: - RemoteCopyDisabledBrowserTest() { - feature_list_.InitAndDisableFeature(kRemoteCopyReceiver); - } -}; - -IN_PROC_BROWSER_TEST_F(RemoteCopyDisabledBrowserTest, FeatureDisabled) { - // The clipboard is empty. - ASSERT_TRUE(GetAvailableClipboardTypes().empty()); - - // Send a message with text. - SendTextMessage(kDeviceName, kText); - - // The clipboard is still empty because the feature is disabled. - ASSERT_TRUE(GetAvailableClipboardTypes().empty()); -} - class RemoteCopyBrowserTest : public RemoteCopyBrowserTestBase { public: RemoteCopyBrowserTest() { - feature_list_.InitAndEnableFeature(kRemoteCopyReceiver); + feature_list_.InitWithFeatures({kRemoteCopyReceiver}, {}); } }; -IN_PROC_BROWSER_TEST_F(RemoteCopyBrowserTest, Text) { - // The clipboard is empty. - ASSERT_TRUE(GetAvailableClipboardTypes().empty()); - - // Send a message with text. - SendTextMessage(kDeviceName, kText); - - // The text is in the clipboard and a notification is shown. - std::vector<base::string16> types = GetAvailableClipboardTypes(); - ASSERT_EQ(1u, types.size()); - ASSERT_EQ(ui::kMimeTypeText, base::UTF16ToASCII(types[0])); - ASSERT_EQ(kText, ReadClipboardText()); - ASSERT_EQ(l10n_util::GetStringFUTF16( +IN_PROC_BROWSER_TEST_F(RemoteCopyBrowserTest, HandleMessage) { + sharing_service_->GetFCMHandlerForTesting()->OnMessage( + kSharingFCMAppID, + CreateMessage(base::GenerateGUID(), kDeviceName, kText)); + EXPECT_EQ(GetClipboardText(), kText); + EXPECT_EQ(l10n_util::GetStringFUTF16( IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_NOTIFICATION_TITLE, base::ASCIIToUTF16(kDeviceName)), GetNotification().title()); } - -IN_PROC_BROWSER_TEST_F(RemoteCopyBrowserTest, ImageUrl) { - // The clipboard is empty. - ASSERT_TRUE(GetAvailableClipboardTypes().empty()); - - // Send a message with an image url. - SendImageMessage(kDeviceName, - StartServerAndGetURL("/image_decoding/droids.jpg")); - - // The image is in the clipboard and a notification is shown. - std::vector<base::string16> types = GetAvailableClipboardTypes(); - ASSERT_EQ(1u, types.size()); - ASSERT_EQ(ui::kMimeTypePNG, base::UTF16ToASCII(types[0])); - SkBitmap bitmap = ReadClipboardImage(); - ASSERT_FALSE(bitmap.drawsNothing()); - ASSERT_EQ(2560, bitmap.width()); - ASSERT_EQ(1920, bitmap.height()); - ASSERT_EQ(l10n_util::GetStringFUTF16( - IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_NOTIFICATION_TITLE, - base::ASCIIToUTF16(kDeviceName)), - GetNotification().title()); -} - -IN_PROC_BROWSER_TEST_F(RemoteCopyBrowserTest, TextThenImageUrl) { - // The clipboard is empty. - ASSERT_TRUE(GetAvailableClipboardTypes().empty()); - - // Send a message with text. - SendTextMessage(kDeviceName, kText); - - // The text is in the clipboard. - std::vector<base::string16> types = GetAvailableClipboardTypes(); - ASSERT_EQ(1u, types.size()); - ASSERT_EQ(ui::kMimeTypeText, base::UTF16ToASCII(types[0])); - ASSERT_EQ(kText, ReadClipboardText()); - - // Send a message with an image url. - SendImageMessage(kDeviceName, - StartServerAndGetURL("/image_decoding/droids.jpg")); - - // The image is in the clipboard and the text has been cleared. - types = GetAvailableClipboardTypes(); - ASSERT_EQ(1u, types.size()); - ASSERT_EQ(ui::kMimeTypePNG, base::UTF16ToASCII(types[0])); - ASSERT_EQ(std::string(), ReadClipboardText()); -}
diff --git a/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.cc b/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.cc index 4549637..d998f10 100644 --- a/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.cc +++ b/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.cc
@@ -6,22 +6,14 @@ #include <memory> -#include "base/bind.h" #include "base/guid.h" #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/notifications/notification_display_service.h" #include "chrome/browser/notifications/notification_display_service_factory.h" -#include "chrome/browser/profiles/profile.h" #include "chrome/grit/generated_resources.h" #include "components/sync/protocol/sharing_message.pb.h" #include "components/sync/protocol/sharing_remote_copy_message.pb.h" -#include "net/base/load_flags.h" -#include "net/traffic_annotation/network_traffic_annotation.h" -#include "services/network/public/cpp/is_potentially_trustworthy.h" -#include "services/network/public/cpp/resource_request.h" -#include "services/network/public/cpp/shared_url_loader_factory.h" -#include "services/network/public/cpp/simple_url_loader.h" #include "ui/base/clipboard/clipboard_buffer.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/l10n/l10n_util.h" @@ -31,30 +23,6 @@ #include "ui/message_center/public/cpp/notifier_id.h" #include "url/gurl.h" -namespace { -const net::NetworkTrafficAnnotationTag kTrafficAnnotation = - net::DefineNetworkTrafficAnnotation("remote_copy_message_handler", - R"( - semantics { - sender: "RemoteCopyMessageHandler" - description: - "Fetches an image from a URL specified in an FCM message." - trigger: - "The user sent an image to this device from another device that " - "they control." - data: - "An image URL, from a Google storage service like blobstore." - destination: GOOGLE_OWNED_SERVICE - } - policy { - cookies_allowed: NO - setting: - "Users can disable this behavior by signing out of Chrome." - policy_exception_justification: - "Can be controlled via Chrome sign-in." - })"); -} // namespace - RemoteCopyMessageHandler::RemoteCopyMessageHandler(Profile* profile) : profile_(profile) {} @@ -65,101 +33,26 @@ DoneCallback done_callback) { DCHECK(message.has_remote_copy_message()); - // First cancel any pending async tasks that might otherwise overwrite the - // results of the more recent message. - url_loader_.reset(); - ImageDecoder::Cancel(this); + ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste) + .WriteText(base::UTF8ToUTF16(message.remote_copy_message().text())); - device_name_ = message.sender_device_name(); - - switch (message.remote_copy_message().content_case()) { - case chrome_browser_sharing::RemoteCopyMessage::kText: - HandleText(message.remote_copy_message().text()); - break; - case chrome_browser_sharing::RemoteCopyMessage::kImageUrl: - HandleImage(message.remote_copy_message().image_url()); - break; - case chrome_browser_sharing::RemoteCopyMessage::CONTENT_NOT_SET: - NOTREACHED(); - break; - } + ShowNotification(message.sender_device_name()); std::move(done_callback).Run(/*response=*/nullptr); } -void RemoteCopyMessageHandler::HandleText(const std::string& text) { - if (!text.empty()) { - { - ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste) - .WriteText(base::UTF8ToUTF16(text)); - } - ShowNotification(); - } - Finish(); -} - -void RemoteCopyMessageHandler::HandleImage(const std::string& image_url) { - GURL url(image_url); - // TODO(mvanouwerkerk): Whitelist check. - if (!network::IsUrlPotentiallyTrustworthy(url)) { - Finish(); - return; - } - - auto request = std::make_unique<network::ResourceRequest>(); - request->url = url; - // This request should be unauthenticated (no cookies), and shouldn't be - // stored in the cache (this URL is only fetched once, ever.) - request->load_flags = net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE; - request->credentials_mode = network::mojom::CredentialsMode::kOmit; - - url_loader_ = - network::SimpleURLLoader::Create(std::move(request), kTrafficAnnotation); - // TODO(mvanouwerkerk): Downloads > 1MB (kMaxBoundedStringDownloadSize). - url_loader_->DownloadToString( - profile_->GetURLLoaderFactory().get(), - base::BindOnce(&RemoteCopyMessageHandler::OnURLLoadComplete, - base::Unretained(this)), - network::SimpleURLLoader::kMaxBoundedStringDownloadSize); -} - -void RemoteCopyMessageHandler::OnURLLoadComplete( - std::unique_ptr<std::string> content) { - url_loader_.reset(); - if (!content || content->empty()) { - Finish(); - return; - } - - ImageDecoder::Start(this, *content); -} - -void RemoteCopyMessageHandler::OnImageDecoded(const SkBitmap& decoded_image) { - if (!decoded_image.drawsNothing()) { - { - ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste) - .WriteImage(decoded_image); - } - ShowNotification(); - } - Finish(); -} - -void RemoteCopyMessageHandler::OnDecodeImageFailed() { - Finish(); -} - -void RemoteCopyMessageHandler::ShowNotification() { +void RemoteCopyMessageHandler::ShowNotification( + const std::string& device_name) { std::string notification_id = base::GenerateGUID(); // TODO(mvanouwerkerk): Adjust notification text and icon once we have mocks. base::string16 notification_title = - device_name_.empty() + device_name.empty() ? l10n_util::GetStringUTF16( IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_NOTIFICATION_TITLE_UNKNOWN_DEVICE) : l10n_util::GetStringFUTF16( IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_NOTIFICATION_TITLE, - base::UTF8ToUTF16(device_name_)); + base::UTF8ToUTF16(device_name)); message_center::Notification notification( message_center::NOTIFICATION_TYPE_SIMPLE, notification_id, @@ -175,8 +68,3 @@ NotificationDisplayServiceFactory::GetForProfile(profile_)->Display( NotificationHandler::Type::SHARING, notification, /*metadata=*/nullptr); } - -void RemoteCopyMessageHandler::Finish() { - // TODO(mvanouwerkerk): UMA logging. - device_name_.clear(); -}
diff --git a/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.h b/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.h index b3b17e97..5514d79e 100644 --- a/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.h +++ b/chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.h
@@ -5,22 +5,15 @@ #ifndef CHROME_BROWSER_SHARING_SHARED_CLIPBOARD_REMOTE_COPY_MESSAGE_HANDLER_H_ #define CHROME_BROWSER_SHARING_SHARED_CLIPBOARD_REMOTE_COPY_MESSAGE_HANDLER_H_ -#include <memory> #include <string> #include "base/macros.h" -#include "chrome/browser/image_decoder.h" #include "chrome/browser/sharing/sharing_message_handler.h" class Profile; -namespace network { -class SimpleURLLoader; -} // namespace network - // Handles incoming messages for the remote copy feature. -class RemoteCopyMessageHandler : public SharingMessageHandler, - public ImageDecoder::ImageRequest { +class RemoteCopyMessageHandler : public SharingMessageHandler { public: explicit RemoteCopyMessageHandler(Profile* profile); ~RemoteCopyMessageHandler() override; @@ -29,20 +22,10 @@ void OnMessage(chrome_browser_sharing::SharingMessage message, DoneCallback done_callback) override; - // ImageDecoder::ImageRequest implementation: - void OnImageDecoded(const SkBitmap& decoded_image) override; - void OnDecodeImageFailed() override; - private: - void HandleText(const std::string& text); - void HandleImage(const std::string& image_url); - void OnURLLoadComplete(std::unique_ptr<std::string> content); - void ShowNotification(); - void Finish(); + void ShowNotification(const std::string& device_name); Profile* profile_ = nullptr; - std::unique_ptr<network::SimpleURLLoader> url_loader_; - std::string device_name_; DISALLOW_COPY_AND_ASSIGN(RemoteCopyMessageHandler); };
diff --git a/chrome/browser/ssl/security_state_model_android.cc b/chrome/browser/ssl/security_state_model_android.cc index 9bb4fc5..4372f70 100644 --- a/chrome/browser/ssl/security_state_model_android.cc +++ b/chrome/browser/ssl/security_state_model_android.cc
@@ -2,12 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/android/jni_string.h" +#include "base/android/scoped_java_ref.h" #include "base/logging.h" #include "chrome/android/chrome_jni_headers/SecurityStateModel_jni.h" #include "chrome/browser/ssl/security_state_tab_helper.h" #include "components/security_state/core/security_state.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/origin_util.h" +#include "url/gurl.h" +using base::android::ConvertJavaStringToUTF16; using base::android::JavaParamRef; // static @@ -23,3 +28,19 @@ DCHECK(helper); return helper->GetSecurityLevel(); } + +// static +jboolean JNI_SecurityStateModel_IsOriginSecure( + JNIEnv* env, + const JavaParamRef<jstring>& jurl) { + GURL url(ConvertJavaStringToUTF16(env, jurl)); + return url.is_valid() && content::IsOriginSecure(url); +} + +// static +jboolean JNI_SecurityStateModel_IsSchemeCryptographic( + JNIEnv* env, + const JavaParamRef<jstring>& jurl) { + GURL url(ConvertJavaStringToUTF16(env, jurl)); + return url.is_valid() && url.SchemeIsCryptographic(); +}
diff --git a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager_unittest.cc b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager_unittest.cc index 17a5aae..b4b0fd0 100644 --- a/chrome/browser/subresource_filter/subresource_filter_content_settings_manager_unittest.cc +++ b/chrome/browser/subresource_filter/subresource_filter_content_settings_manager_unittest.cc
@@ -194,7 +194,7 @@ // Deleting a URL from history while there are still other urls for the // same origin should not delete the setting. - history_service->DeleteURL(url1); + history_service->DeleteURLs({url1}); history::BlockUntilHistoryProcessesPendingRequests(history_service); EXPECT_FALSE(settings_manager()->ShouldShowUIForSite(url1)); EXPECT_FALSE(settings_manager()->ShouldShowUIForSite(url2)); @@ -202,7 +202,7 @@ // Deleting all URLs of an origin from history should clear the setting for // this URL. Note that since there is another URL in the history this won't // clear all items. - history_service->DeleteURL(url2); + history_service->DeleteURLs({url2}); history::BlockUntilHistoryProcessesPendingRequests(history_service); EXPECT_TRUE(settings_manager()->ShouldShowUIForSite(url1));
diff --git a/chrome/browser/sync/test/integration/single_client_send_tab_to_self_sync_test.cc b/chrome/browser/sync/test/integration/single_client_send_tab_to_self_sync_test.cc index da4e8870c..e987a86 100644 --- a/chrome/browser/sync/test/integration/single_client_send_tab_to_self_sync_test.cc +++ b/chrome/browser/sync/test/integration/single_client_send_tab_to_self_sync_test.cc
@@ -115,7 +115,7 @@ GURL(kUrl)) .Wait()); - history_service->DeleteURL(GURL(kUrl)); + history_service->DeleteURLs({GURL(kUrl)}); EXPECT_TRUE(send_tab_to_self_helper::SendTabToSelfUrlDeletedChecker( SendTabToSelfSyncServiceFactory::GetForProfile(GetProfile(0)),
diff --git a/chrome/browser/sync/test/integration/typed_urls_helper.cc b/chrome/browser/sync/test/integration/typed_urls_helper.cc index 5efd4ab4..2fe7f53 100644 --- a/chrome/browser/sync/test/integration/typed_urls_helper.cc +++ b/chrome/browser/sync/test/integration/typed_urls_helper.cc
@@ -387,10 +387,13 @@ } void DeleteUrlFromHistory(int index, const GURL& url) { - GetHistoryServiceFromClient(index)->DeleteURL(url); + GetHistoryServiceFromClient(index)->DeleteURLs({url}); + if (test()->use_verifier()) - HistoryServiceFactory::GetForProfile( - test()->verifier(), ServiceAccessType::IMPLICIT_ACCESS)->DeleteURL(url); + HistoryServiceFactory::GetForProfile(test()->verifier(), + ServiceAccessType::IMPLICIT_ACCESS) + ->DeleteURLs({url}); + WaitForHistoryDBThread(index); }
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn index d3bdaf9..dc7f0e7 100644 --- a/chrome/browser/ui/BUILD.gn +++ b/chrome/browser/ui/BUILD.gn
@@ -950,6 +950,9 @@ "global_media_controls/media_toolbar_button_controller_delegate.cc", "global_media_controls/media_toolbar_button_controller_delegate.h", "global_media_controls/media_toolbar_button_observer.h", + "global_media_controls/overlay_media_notification.h", + "global_media_controls/overlay_media_notifications_manager.cc", + "global_media_controls/overlay_media_notifications_manager.h", "hats/hats_helper.cc", "hats/hats_helper.h", "hats/hats_service.cc", @@ -2853,6 +2856,8 @@ "views/global_media_controls/media_notification_list_view.h", "views/global_media_controls/media_toolbar_button_view.cc", "views/global_media_controls/media_toolbar_button_view.h", + "views/global_media_controls/overlay_media_notification_view.cc", + "views/global_media_controls/overlay_media_notification_view.h", "views/hover_button.cc", "views/hover_button.h", "views/hover_button_controller.cc",
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd index d4dd0c9..0ba69fe 100644 --- a/chrome/browser/ui/android/strings/android_chrome_strings.grd +++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -3492,9 +3492,12 @@ <message name="IDS_TOP_VIEW_EMAIL_FILTER_LABEL" desc="The label shown for the email filter toggle button (allowing the user to exclude emails)."> Email addresses </message> - <message name="IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL" desc="The label shown for the telephone filter toggle button (allowing the user to exclude emails)."> + <message name="IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL" desc="The label shown for the telephone filter toggle button (allowing the user to exclude telephones)."> Phone numbers </message> + <message name="IDS_TOP_VIEW_ICON_FILTER_LABEL" desc="The label shown for the icon filter toggle button (allowing the user to exclude icons)."> + Icons + </message> <message name="IDS_CONTACTS_PICKER_MORE_DETAILS" desc="Label describing that the user has one or more telephone/emails (used for either)."> {DETAIL_COUNT, plural, =1 {(+ 1 more)}
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_ICON_FILTER_LABEL.png.sha1 b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_ICON_FILTER_LABEL.png.sha1 new file mode 100644 index 0000000..57f1d4b --- /dev/null +++ b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_ICON_FILTER_LABEL.png.sha1
@@ -0,0 +1 @@ +8fc40d4329e025b0eeea4789fff384fa2b86a54d \ No newline at end of file
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL.png.sha1 b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL.png.sha1 new file mode 100644 index 0000000..57f1d4b --- /dev/null +++ b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_TOP_VIEW_TELEPHONE_FILTER_LABEL.png.sha1
@@ -0,0 +1 @@ +8fc40d4329e025b0eeea4789fff384fa2b86a54d \ No newline at end of file
diff --git a/chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker_unittest.cc b/chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker_unittest.cc index 5bbd4a9..0ebc473 100644 --- a/chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker_unittest.cc +++ b/chrome/browser/ui/app_list/search/search_result_ranker/search_result_ranker_unittest.cc
@@ -508,7 +508,7 @@ EXPECT_FALSE(base::PathExists(model_path)); history_service()->AddPage(GURL(url_1), base::Time::Now(), history::VisitSource::SOURCE_BROWSED); - history_service()->DeleteURL(GURL(url_1)); + history_service()->DeleteURLs({GURL(url_1)}); history::BlockUntilHistoryProcessesPendingRequests(history_service()); Wait(); EXPECT_TRUE(base::PathExists(model_path));
diff --git a/chrome/browser/ui/global_media_controls/media_dialog_delegate.h b/chrome/browser/ui/global_media_controls/media_dialog_delegate.h index 4b9fa6d97..7ba6444 100644 --- a/chrome/browser/ui/global_media_controls/media_dialog_delegate.h +++ b/chrome/browser/ui/global_media_controls/media_dialog_delegate.h
@@ -8,12 +8,14 @@ #include <string> #include "base/memory/weak_ptr.h" +#include "ui/gfx/geometry/rect.h" namespace media_message_center { class MediaNotificationItem; } // namespace media_message_center class MediaNotificationContainerImpl; +class OverlayMediaNotification; // Delegate for MediaToolbarButtonController that is told when to display or // hide a media session. @@ -29,6 +31,12 @@ // Hides a media session. virtual void HideMediaSession(const std::string& id) = 0; + // Returns an OverlayMediaNotification containing the media notification for + // the given |id|. The notification should be removed from the dialog. + virtual std::unique_ptr<OverlayMediaNotification> PopOut( + const std::string& id, + gfx::Rect bounds) = 0; + protected: virtual ~MediaDialogDelegate(); };
diff --git a/chrome/browser/ui/global_media_controls/media_notification_container_observer.h b/chrome/browser/ui/global_media_controls/media_notification_container_observer.h index e50a96a..b239b34 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_container_observer.h +++ b/chrome/browser/ui/global_media_controls/media_notification_container_observer.h
@@ -6,6 +6,7 @@ #define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_MEDIA_NOTIFICATION_CONTAINER_OBSERVER_H_ #include "base/observer_list_types.h" +#include "ui/gfx/geometry/rect.h" class MediaNotificationContainerObserver : public base::CheckedObserver { public: @@ -24,6 +25,10 @@ // Called when the container is about to be deleted. virtual void OnContainerDestroyed(const std::string& id) = 0; + // Called when the container has been dragged out of a dialog. + virtual void OnContainerDraggedOut(const std::string& id, + gfx::Rect bounds) = 0; + protected: ~MediaNotificationContainerObserver() override = default; };
diff --git a/chrome/browser/ui/global_media_controls/media_notification_service.cc b/chrome/browser/ui/global_media_controls/media_notification_service.cc index 34efdb7..9e3f4a4 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_service.cc +++ b/chrome/browser/ui/global_media_controls/media_notification_service.cc
@@ -13,6 +13,7 @@ #include "chrome/browser/ui/global_media_controls/media_dialog_delegate.h" #include "chrome/browser/ui/global_media_controls/media_notification_container_impl.h" #include "chrome/browser/ui/global_media_controls/media_notification_service_observer.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "components/media_message_center/media_notification_item.h" #include "components/media_message_center/media_notification_util.h" @@ -71,7 +72,7 @@ MediaNotificationService::MediaNotificationService( Profile* profile, service_manager::Connector* connector) - : connector_(connector) { + : connector_(connector), overlay_media_notifications_manager_(this) { if (base::FeatureList::IsEnabled(media::kGlobalMediaControlsForCast) && media_router::MediaRouterEnabled(profile)) { cast_notification_provider_ = @@ -145,7 +146,8 @@ // controller because the mojo pipe would have been reset. it->second.item()->SetController(std::move(controller), std::move(session->session_info)); - active_controllable_session_ids_.insert(id); + if (!base::Contains(dragged_out_session_ids_, id)) + active_controllable_session_ids_.insert(id); frozen_session_ids_.erase(id); for (auto& observer : observers_) observer.OnNotificationListChanged(); @@ -179,7 +181,9 @@ } void MediaNotificationService::ShowNotification(const std::string& id) { - active_controllable_session_ids_.insert(id); + if (!base::Contains(dragged_out_session_ids_, id)) + active_controllable_session_ids_.insert(id); + for (auto& observer : observers_) observer.OnNotificationListChanged(); @@ -201,6 +205,12 @@ void MediaNotificationService::HideNotification(const std::string& id) { active_controllable_session_ids_.erase(id); frozen_session_ids_.erase(id); + + if (base::Contains(dragged_out_session_ids_, id)) { + overlay_media_notifications_manager_.CloseOverlayNotification(id); + dragged_out_session_ids_.erase(id); + } + for (auto& observer : observers_) observer.OnNotificationListChanged(); @@ -218,6 +228,12 @@ void MediaNotificationService::RemoveItem(const std::string& id) { active_controllable_session_ids_.erase(id); frozen_session_ids_.erase(id); + + if (base::Contains(dragged_out_session_ids_, id)) { + overlay_media_notifications_manager_.CloseOverlayNotification(id); + dragged_out_session_ids_.erase(id); + } + sessions_.erase(id); for (auto& observer : observers_) @@ -255,6 +271,13 @@ } void MediaNotificationService::OnContainerDismissed(const std::string& id) { + // If the notification is dragged out, then dismissing should just close the + // overlay notification. + if (base::Contains(dragged_out_session_ids_, id)) { + overlay_media_notifications_manager_.CloseOverlayNotification(id); + return; + } + auto it = sessions_.find(id); if (it != sessions_.end()) it->second.item()->Dismiss(); @@ -268,6 +291,62 @@ observed_containers_.erase(iter); } +void MediaNotificationService::OnContainerDraggedOut(const std::string& id, + gfx::Rect bounds) { + if (!dialog_delegate_) + return; + + std::unique_ptr<OverlayMediaNotification> overlay_notification = + dialog_delegate_->PopOut(id, bounds); + if (!overlay_notification) + return; + + overlay_media_notifications_manager_.ShowOverlayNotification( + id, std::move(overlay_notification)); + active_controllable_session_ids_.erase(id); + dragged_out_session_ids_.insert(id); + + for (auto& observer : observers_) + observer.OnNotificationListChanged(); +} + +void MediaNotificationService::OnOverlayNotificationClosed( + const std::string& id) { + // If the session has been destroyed, no action is needed. + auto it = sessions_.find(id); + if (it == sessions_.end()) + return; + + // Since the overlay is closing, we no longer need to observe the associated + // container. + auto observed_iter = observed_containers_.find(id); + if (observed_iter != observed_containers_.end()) { + observed_iter->second->RemoveObserver(this); + observed_containers_.erase(observed_iter); + } + + // Otherwise, if it's a non-frozen item, then it's now an active one. + if (!base::Contains(frozen_session_ids_, id)) + active_controllable_session_ids_.insert(id); + dragged_out_session_ids_.erase(id); + + for (auto& observer : observers_) + observer.OnNotificationListChanged(); + + // If there's a dialog currently open, then we should show the item in the + // dialog. + if (!dialog_delegate_) + return; + + MediaNotificationContainerImpl* container = + dialog_delegate_->ShowMediaSession(id, it->second.item()->GetWeakPtr()); + + if (container) { + container->AddObserver(this); + observed_containers_[id] = container; + } +} + void MediaNotificationService::OnCastNotificationsChanged() { for (auto& observer : observers_) observer.OnNotificationListChanged();
diff --git a/chrome/browser/ui/global_media_controls/media_notification_service.h b/chrome/browser/ui/global_media_controls/media_notification_service.h index 3e8e7e9e..185741d2 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_service.h +++ b/chrome/browser/ui/global_media_controls/media_notification_service.h
@@ -13,6 +13,7 @@ #include "base/memory/weak_ptr.h" #include "chrome/browser/ui/global_media_controls/cast_media_notification_provider.h" #include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h" #include "components/keyed_service/core/keyed_service.h" #include "components/media_message_center/media_notification_controller.h" #include "content/public/browser/web_contents_observer.h" @@ -71,6 +72,11 @@ void OnContainerClicked(const std::string& id) override; void OnContainerDismissed(const std::string& id) override; void OnContainerDestroyed(const std::string& id) override; + void OnContainerDraggedOut(const std::string& id, gfx::Rect bounds) override; + + // Called by the |overlay_media_notifications_manager_| when an overlay + // notification is closed. + void OnOverlayNotificationClosed(const std::string& id); void OnCastNotificationsChanged(); @@ -123,6 +129,8 @@ service_manager::Connector* const connector_; MediaDialogDelegate* dialog_delegate_ = nullptr; + OverlayMediaNotificationsManager overlay_media_notifications_manager_; + // Used to track whether there are any active controllable media sessions. If // not, then there's nothing to show in the dialog and we can hide the toolbar // icon. @@ -132,6 +140,11 @@ // sessions, we will disable the toolbar icon and wait to hide it. std::unordered_set<std::string> frozen_session_ids_; + // Tracks the sessions that are currently dragged out of the dialog. These + // should not be shown in the dialog and will be ignored for showing the + // toolbar icon. + std::unordered_set<std::string> dragged_out_session_ids_; + // Stores a Session for each media session keyed by its |request_id| in string // format. std::map<std::string, Session> sessions_;
diff --git a/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc b/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc index 2c96938..3c191c2 100644 --- a/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc +++ b/chrome/browser/ui/global_media_controls/media_notification_service_unittest.cc
@@ -15,6 +15,7 @@ #include "chrome/browser/ui/global_media_controls/cast_media_notification_provider.h" #include "chrome/browser/ui/global_media_controls/media_dialog_delegate.h" #include "chrome/browser/ui/global_media_controls/media_notification_service_observer.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" #include "chrome/test/base/testing_profile.h" #include "components/media_message_center/media_notification_item.h" #include "components/media_message_center/media_notification_util.h" @@ -32,6 +33,9 @@ using media_session::mojom::MediaSessionInfoPtr; using testing::_; using testing::AtLeast; +using testing::Expectation; +using testing::Return; +using testing::SaveArg; namespace { @@ -76,6 +80,15 @@ const std::string& id, base::WeakPtr<media_message_center::MediaNotificationItem> item)); MOCK_METHOD1(HideMediaSession, void(const std::string& id)); + std::unique_ptr<OverlayMediaNotification> PopOut(const std::string& id, + gfx::Rect bounds) { + return std::unique_ptr<OverlayMediaNotification>(PopOutProxy(id, bounds)); + } + + // Need to use a proxy since std::unique_ptr is not copyable. + MOCK_METHOD2(PopOutProxy, + OverlayMediaNotification*(const std::string& id, + gfx::Rect bounds)); private: MediaNotificationService* service_; @@ -83,6 +96,20 @@ DISALLOW_COPY_AND_ASSIGN(MockMediaDialogDelegate); }; +class MockOverlayMediaNotification : public OverlayMediaNotification { + public: + MockOverlayMediaNotification() = default; + MockOverlayMediaNotification(const MockOverlayMediaNotification&) = delete; + MockOverlayMediaNotification& operator=(const MockOverlayMediaNotification&) = + delete; + ~MockOverlayMediaNotification() override = default; + + // MockOverlayMediaNotification implementation. + MOCK_METHOD1(SetManager, void(OverlayMediaNotificationsManager* manager)); + MOCK_METHOD0(ShowNotification, void()); + MOCK_METHOD0(CloseNotification, void()); +}; + } // anonymous namespace class MediaNotificationServiceTest : public testing::Test { @@ -213,6 +240,11 @@ service_->OnContainerDismissed(id.ToString()); } + void SimulateNotificationDraggedOut(const base::UnguessableToken& id, + gfx::Rect bounds) { + service_->OnContainerDraggedOut(id.ToString(), bounds); + } + void ExpectHistogramCountRecorded(int count, int size) { histogram_tester_.ExpectBucketCount( media_message_center::kCountHistogramName, count, size); @@ -507,3 +539,48 @@ EXPECT_FALSE(HasFrozenNotifications()); testing::Mock::VerifyAndClearExpectations(&observer()); } + +TEST_F(MediaNotificationServiceTest, ShowsOverlayForDraggedOutNotifications) { + // First, start playing active media. + base::UnguessableToken id = SimulatePlayingControllableMedia(); + EXPECT_TRUE(HasActiveNotifications()); + + // Then, open a dialog. + MockMediaDialogDelegate dialog_delegate; + EXPECT_CALL(dialog_delegate, ShowMediaSession(id.ToString(), _)); + SimulateDialogOpened(&dialog_delegate); + + gfx::Rect dragged_out_bounds(0, 1, 2, 3); + auto overlay_notification_unique = + std::make_unique<MockOverlayMediaNotification>(); + MockOverlayMediaNotification* overlay_notification = + overlay_notification_unique.get(); + + // When the notification is dragged out, the dialog should be asked to remove + // the notification and return an overlay version of it. + EXPECT_CALL(dialog_delegate, PopOutProxy(id.ToString(), dragged_out_bounds)) + .WillOnce(Return(overlay_notification_unique.release())); + + // Then, that overlay notification should receive a manager and be shown. + OverlayMediaNotificationsManager* manager = nullptr; + Expectation set_manager = EXPECT_CALL(*overlay_notification, SetManager(_)) + .WillOnce(SaveArg<0>(&manager)); + EXPECT_CALL(*overlay_notification, ShowNotification()).After(set_manager); + + // Drag out the notification. + SimulateNotificationDraggedOut(id, dragged_out_bounds); + testing::Mock::VerifyAndClearExpectations(&dialog_delegate); + testing::Mock::VerifyAndClearExpectations(overlay_notification); + + // Now, dismiss the notification. Since the notification is an overlay + // notification, this should just close the overlay notification. + EXPECT_CALL(*overlay_notification, CloseNotification()); + SimulateDismissButtonClicked(id); + testing::Mock::VerifyAndClearExpectations(overlay_notification); + + // After we close, we notify our manager, and the dialog should be informed + // that it can show the notification again. + EXPECT_CALL(dialog_delegate, ShowMediaSession(id.ToString(), _)); + manager->OnOverlayNotificationClosed(id.ToString()); + testing::Mock::VerifyAndClearExpectations(&dialog_delegate); +}
diff --git a/chrome/browser/ui/global_media_controls/media_toolbar_button_controller_unittest.cc b/chrome/browser/ui/global_media_controls/media_toolbar_button_controller_unittest.cc index c0af645..6e98e42 100644 --- a/chrome/browser/ui/global_media_controls/media_toolbar_button_controller_unittest.cc +++ b/chrome/browser/ui/global_media_controls/media_toolbar_button_controller_unittest.cc
@@ -11,6 +11,7 @@ #include "chrome/browser/ui/global_media_controls/media_dialog_delegate.h" #include "chrome/browser/ui/global_media_controls/media_notification_service.h" #include "chrome/browser/ui/global_media_controls/media_toolbar_button_controller_delegate.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" #include "chrome/test/base/testing_profile.h" #include "components/media_message_center/media_notification_item.h" #include "components/media_message_center/media_notification_util.h" @@ -69,6 +70,9 @@ const std::string& id, base::WeakPtr<media_message_center::MediaNotificationItem> item)); MOCK_METHOD1(HideMediaSession, void(const std::string& id)); + MOCK_METHOD2(PopOut, + std::unique_ptr<OverlayMediaNotification>(const std::string& id, + gfx::Rect bounds)); private: MediaNotificationService* service_;
diff --git a/chrome/browser/ui/global_media_controls/overlay_media_notification.h b/chrome/browser/ui/global_media_controls/overlay_media_notification.h new file mode 100644 index 0000000..00c1b74 --- /dev/null +++ b/chrome/browser/ui/global_media_controls/overlay_media_notification.h
@@ -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. + +#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_H_ +#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_H_ + +class OverlayMediaNotificationsManager; + +// Handles displaying media notifications as overlay controls. +class OverlayMediaNotification { + public: + // OverlayMediaNotification is owned and destroyed by the + // OverlayMediaNotificationsManager. + virtual ~OverlayMediaNotification() = default; + + // Sets the OverlayMediaNotificationsManager associated with this + // OverlayMediaNotification. + virtual void SetManager(OverlayMediaNotificationsManager* manager) = 0; + + // Displays the widget. |SetManager()| must be called first the ensure that + // the manager is set. + virtual void ShowNotification() = 0; + + // Closes the widget. + virtual void CloseNotification() = 0; +}; + +#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_H_
diff --git a/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.cc b/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.cc new file mode 100644 index 0000000..8b2d9d0 --- /dev/null +++ b/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.cc
@@ -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. + +#include "chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h" + +#include "chrome/browser/ui/global_media_controls/media_notification_service.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" + +OverlayMediaNotificationsManager::OverlayMediaNotificationsManager( + MediaNotificationService* service) + : service_(service) { + DCHECK(service_); +} + +OverlayMediaNotificationsManager::~OverlayMediaNotificationsManager() { + overlay_notifications_.clear(); +} + +void OverlayMediaNotificationsManager::ShowOverlayNotification( + const std::string& id, + std::unique_ptr<OverlayMediaNotification> overlay_notification) { + DCHECK(overlay_notification); + OverlayMediaNotification* notification = overlay_notification.get(); + overlay_notifications_.insert({id, std::move(overlay_notification)}); + notification->SetManager(this); + notification->ShowNotification(); +} + +void OverlayMediaNotificationsManager::CloseOverlayNotification( + const std::string& id) { + auto it = overlay_notifications_.find(id); + if (it == overlay_notifications_.end()) + return; + it->second->CloseNotification(); +} + +void OverlayMediaNotificationsManager::OnOverlayNotificationClosed( + const std::string& id) { + service_->OnOverlayNotificationClosed(id); + + // Warning: after this call, |id| is not safe to use since this deletes the + // caller. + overlay_notifications_.erase(id); +}
diff --git a/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h b/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h new file mode 100644 index 0000000..86ce821 --- /dev/null +++ b/chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h
@@ -0,0 +1,44 @@ +// 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. + +#ifndef CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATIONS_MANAGER_H_ +#define CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATIONS_MANAGER_H_ + +#include <map> +#include <memory> +#include <string> + +class MediaNotificationService; +class OverlayMediaNotification; + +// The OverlayMediaNotificationsManager owns, shows, and closes overlay media +// notifications. It keeps the MediaNotificationService informed of when the +// overlay notifications are closed. +class OverlayMediaNotificationsManager { + public: + explicit OverlayMediaNotificationsManager(MediaNotificationService* service); + OverlayMediaNotificationsManager(const OverlayMediaNotificationsManager&) = + delete; + OverlayMediaNotificationsManager& operator=( + const OverlayMediaNotificationsManager&) = delete; + ~OverlayMediaNotificationsManager(); + + // Displays the given OverlayMediaNotification. + void ShowOverlayNotification( + const std::string& id, + std::unique_ptr<OverlayMediaNotification> overlay_notification); + + // Closes the OverlayMediaNotification with the given |id|. + void CloseOverlayNotification(const std::string& id); + + // Called by the OverlayMediaNotification when the widget has closed. + void OnOverlayNotificationClosed(const std::string& id); + + private: + MediaNotificationService* const service_; + std::map<std::string, std::unique_ptr<OverlayMediaNotification>> + overlay_notifications_; +}; + +#endif // CHROME_BROWSER_UI_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATIONS_MANAGER_H_
diff --git a/chrome/browser/ui/search/instant_controller.cc b/chrome/browser/ui/search/instant_controller.cc index b8fc888..90471d5 100644 --- a/chrome/browser/ui/search/instant_controller.cc +++ b/chrome/browser/ui/search/instant_controller.cc
@@ -83,7 +83,7 @@ InstantService* instant_service = InstantServiceFactory::GetForProfile(profile_); if (instant_service) { - instant_service->UpdateThemeInfo(); + instant_service->UpdateNtpTheme(); instant_service->UpdateMostVisitedInfo(); } }
diff --git a/chrome/browser/ui/search/instant_theme_browsertest.cc b/chrome/browser/ui/search/instant_theme_browsertest.cc index c8869ab1..094cd166 100644 --- a/chrome/browser/ui/search/instant_theme_browsertest.cc +++ b/chrome/browser/ui/search/instant_theme_browsertest.cc
@@ -30,18 +30,18 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/color_utils.h" -class TestThemeInfoObserver : public InstantServiceObserver { +class TestNtpThemeObserver : public InstantServiceObserver { public: - explicit TestThemeInfoObserver(InstantService* service) : service_(service) { + explicit TestNtpThemeObserver(InstantService* service) : service_(service) { service_->AddObserver(this); } - ~TestThemeInfoObserver() override { service_->RemoveObserver(this); } + ~TestNtpThemeObserver() override { service_->RemoveObserver(this); } void WaitForThemeApplied(bool theme_installed) { DCHECK(!quit_closure_); theme_installed_ = theme_installed; - if (hasThemeInstalled(theme_info_) == theme_installed_) { + if (hasThemeInstalled(theme_) == theme_installed_) { return; } @@ -51,10 +51,10 @@ } private: - void ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) override { - theme_info_ = theme_info; + void NtpThemeChanged(const NtpTheme& theme) override { + theme_ = theme; - if (quit_closure_ && hasThemeInstalled(theme_info) == theme_installed_) { + if (quit_closure_ && hasThemeInstalled(theme) == theme_installed_) { std::move(quit_closure_).Run(); quit_closure_.Reset(); } @@ -62,13 +62,11 @@ void MostVisitedInfoChanged(const InstantMostVisitedInfo&) override {} - bool hasThemeInstalled(const ThemeBackgroundInfo& theme_info) { - return theme_info.theme_id != ""; - } + bool hasThemeInstalled(const NtpTheme& theme) { return theme.theme_id != ""; } InstantService* const service_; - ThemeBackgroundInfo theme_info_; + NtpTheme theme_; bool theme_installed_; base::OnceClosure quit_closure_; @@ -174,7 +172,7 @@ ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); const std::string helper_js = "document.body.style.cssText"; - TestThemeInfoObserver observer( + TestNtpThemeObserver observer( InstantServiceFactory::GetForProfile(browser()->profile())); // Open new tab. @@ -224,7 +222,7 @@ ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); const std::string helper_js = "document.body.style.cssText"; - TestThemeInfoObserver observer( + TestNtpThemeObserver observer( InstantServiceFactory::GetForProfile(browser()->profile())); // Open new tab. content::WebContents* active_tab = @@ -271,7 +269,7 @@ ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); const std::string helper_js = "document.body.style.cssText"; - TestThemeInfoObserver observer( + TestNtpThemeObserver observer( InstantServiceFactory::GetForProfile(browser()->profile())); // Open new tab.
diff --git a/chrome/browser/ui/search/local_ntp_backgrounds_browsertest.cc b/chrome/browser/ui/search/local_ntp_backgrounds_browsertest.cc index 5d75c2f..daaa8c2 100644 --- a/chrome/browser/ui/search/local_ntp_backgrounds_browsertest.cc +++ b/chrome/browser/ui/search/local_ntp_backgrounds_browsertest.cc
@@ -62,7 +62,7 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('https://www.test.com/', '', '', '', '')")); - observer.WaitForThemeInfoUpdated("https://www.test.com/", "", "", ""); + observer.WaitForNtpThemeUpdated("https://www.test.com/", "", "", ""); // Check that a URL with attributions can be set. EXPECT_TRUE(content::ExecuteScript(active_tab, @@ -70,14 +70,14 @@ "setBackgroundInfo('https:/" "/www.test.com/', 'attr1', 'attr2', " "'https://www.attribution.com/', '')")); - observer.WaitForThemeInfoUpdated("https://www.test.com/", "attr1", "attr2", - "https://www.attribution.com/"); + observer.WaitForNtpThemeUpdated("https://www.test.com/", "attr1", "attr2", + "https://www.attribution.com/"); // Setting the background URL to an empty string should clear everything. EXPECT_TRUE(content::ExecuteScript( active_tab, "window.chrome.embeddedSearch.newTabPage.resetBackgroundInfo()")); - observer.WaitForThemeInfoUpdated("", "", "", ""); + observer.WaitForNtpThemeUpdated("", "", "", ""); } IN_PROC_BROWSER_TEST_F(LocalNTPCustomBackgroundsTest, AttributionSetAndReset) { @@ -98,8 +98,8 @@ "setBackgroundInfo('https:/" "/www.test.com/', 'attr1', 'attr2', " "'https://www.attribution.com/', '')")); - observer.WaitForThemeInfoUpdated("https://www.test.com/", "attr1", "attr2", - "https://www.attribution.com/"); + observer.WaitForNtpThemeUpdated("https://www.test.com/", "attr1", "attr2", + "https://www.attribution.com/"); // Check that the custom background element has the correct attribution // applied. @@ -115,7 +115,7 @@ EXPECT_TRUE(content::ExecuteScript(active_tab, "window.chrome.embeddedSearch.newTabPage." "resetBackgroundInfo()")); - observer.WaitForThemeInfoUpdated("", "", "", ""); + observer.WaitForNtpThemeUpdated("", "", "", ""); // Check that the custom background attribution was cleared. EXPECT_TRUE(instant_test_utils::GetBoolFromJS( @@ -142,8 +142,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg" "', '', '' ,'' ,'')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Check that the custom background element has the correct attribution with // the scrim applied. @@ -160,7 +160,7 @@ EXPECT_TRUE(content::ExecuteScript(active_tab, "window.chrome.embeddedSearch.newTabPage." "resetBackgroundInfo()")); - observer.WaitForThemeInfoUpdated("", "", "", ""); + observer.WaitForNtpThemeUpdated("", "", "", ""); // Check that the custom background was cleared. EXPECT_TRUE(instant_test_utils::GetBoolFromJS( @@ -187,8 +187,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg" "', '', '', '', '')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Check that the custom background element has the correct attribution with // the scrim applied. @@ -288,8 +288,8 @@ "setBackgroundInfo('https:/" "/www.test.com/', 'attr1', 'attr2', " "'https://www.attribution.com/', '')")); - observer.WaitForThemeInfoUpdated("https://www.test.com/", "attr1", "attr2", - "https://www.attribution.com/"); + observer.WaitForNtpThemeUpdated("https://www.test.com/", "attr1", "attr2", + "https://www.attribution.com/"); // Check that the custom background element has the correct attribution // applied. @@ -347,8 +347,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg" "', '', '', '', '')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Check that the custom background element has the correct attribution with // the scrim applied. @@ -397,7 +397,7 @@ bool result = false; ASSERT_TRUE(instant_test_utils::GetBoolFromJS( active_tab, - "window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo." + "window.chrome.embeddedSearch.newTabPage.ntpTheme." "attributionUrl !== ''", &result)); EXPECT_TRUE(result); @@ -411,8 +411,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg" "', '', '', '', '')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Check that the custom background element has the correct attribution with // the scrim applied. @@ -427,7 +427,7 @@ EXPECT_FALSE(observer.IsUsingDefaultTheme()); ASSERT_TRUE(instant_test_utils::GetBoolFromJS( active_tab, - "window.chrome.embeddedSearch.newTabPage.themeBackgroundInfo." + "window.chrome.embeddedSearch.newTabPage.ntpTheme." "attributionUrl === ''", &result)); EXPECT_TRUE(result); @@ -481,8 +481,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg" "', '', '', '', '')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Elements other than chips (i.e. Most Visited, etc.) should have dark mode // applied. @@ -541,8 +541,8 @@ "window.chrome.embeddedSearch.newTabPage." "setBackgroundInfo('chrome-search://local-ntp/background1.jpg'," "'', '', '', '')")); - observer.WaitForThemeInfoUpdated("chrome-search://local-ntp/background1.jpg", - "", "", ""); + observer.WaitForNtpThemeUpdated("chrome-search://local-ntp/background1.jpg", + "", "", ""); // Switch to waiting for the theme to get applied. With img ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme_minimal", "minimal"));
diff --git a/chrome/browser/ui/search/local_ntp_browsertest_base.cc b/chrome/browser/ui/search/local_ntp_browsertest_base.cc index 73a9b55..4856eaa 100644 --- a/chrome/browser/ui/search/local_ntp_browsertest_base.cc +++ b/chrome/browser/ui/search/local_ntp_browsertest_base.cc
@@ -41,7 +41,7 @@ run_loop.Run(); } -void TestInstantServiceObserver::WaitForThemeInfoUpdated( +void TestInstantServiceObserver::WaitForNtpThemeUpdated( std::string background_url, std::string attribution_1, std::string attribution_2, @@ -53,10 +53,10 @@ expected_attribution_2_ = attribution_2; expected_attribution_action_url_ = attribution_action_url; - if (theme_info_.custom_background_url == background_url && - theme_info_.custom_background_attribution_line_1 == attribution_1 && - theme_info_.custom_background_attribution_line_2 == attribution_2 && - theme_info_.custom_background_attribution_action_url == + if (theme_.custom_background_url == background_url && + theme_.custom_background_attribution_line_1 == attribution_1 && + theme_.custom_background_attribution_line_2 == attribution_2 && + theme_.custom_background_attribution_action_url == attribution_action_url) { return; } @@ -70,7 +70,7 @@ DCHECK(!quit_closure_theme_); theme_installed_ = theme_installed; - if (!theme_info_.using_default_theme == theme_installed) { + if (!theme_.using_default_theme == theme_installed) { return; } @@ -80,26 +80,23 @@ } bool TestInstantServiceObserver::IsUsingDefaultTheme() { - return theme_info_.using_default_theme; + return theme_.using_default_theme; } -void TestInstantServiceObserver::ThemeInfoChanged( - const ThemeBackgroundInfo& theme_info) { - theme_info_ = theme_info; +void TestInstantServiceObserver::NtpThemeChanged(const NtpTheme& theme) { + theme_ = theme; if (quit_closure_custom_background_ && - theme_info_.custom_background_url == expected_background_url_ && - theme_info_.custom_background_attribution_line_1 == - expected_attribution_1_ && - theme_info_.custom_background_attribution_line_2 == - expected_attribution_2_ && - theme_info_.custom_background_attribution_action_url == + theme_.custom_background_url == expected_background_url_ && + theme_.custom_background_attribution_line_1 == expected_attribution_1_ && + theme_.custom_background_attribution_line_2 == expected_attribution_2_ && + theme_.custom_background_attribution_action_url == expected_attribution_action_url_) { // Exit when the custom background was applied successfully. std::move(quit_closure_custom_background_).Run(); quit_closure_custom_background_.Reset(); } else if (quit_closure_theme_ && - !theme_info_.using_default_theme == theme_installed_) { + !theme_.using_default_theme == theme_installed_) { // Exit when the theme was applied successfully. std::move(quit_closure_theme_).Run(); quit_closure_theme_.Reset();
diff --git a/chrome/browser/ui/search/local_ntp_browsertest_base.h b/chrome/browser/ui/search/local_ntp_browsertest_base.h index 76d36d34..d5abeec0 100644 --- a/chrome/browser/ui/search/local_ntp_browsertest_base.h +++ b/chrome/browser/ui/search/local_ntp_browsertest_base.h
@@ -23,17 +23,17 @@ void WaitForMostVisitedItems(size_t count); - void WaitForThemeInfoUpdated(std::string background_url, - std::string attribution_1, - std::string attribution_2, - std::string attribution_action_url); + void WaitForNtpThemeUpdated(std::string background_url, + std::string attribution_1, + std::string attribution_2, + std::string attribution_action_url); void WaitForThemeApplied(bool theme_installed); bool IsUsingDefaultTheme(); private: - void ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) override; + void NtpThemeChanged(const NtpTheme& theme) override; void MostVisitedInfoChanged( const InstantMostVisitedInfo& most_visited_info) override; @@ -41,7 +41,7 @@ InstantService* const service_; std::vector<InstantMostVisitedItem> items_; - ThemeBackgroundInfo theme_info_; + NtpTheme theme_; bool theme_installed_;
diff --git a/chrome/browser/ui/search/search_ipc_router.cc b/chrome/browser/ui/search/search_ipc_router.cc index 77ab9e08..64c39cd7 100644 --- a/chrome/browser/ui/search/search_ipc_router.cc +++ b/chrome/browser/ui/search/search_ipc_router.cc
@@ -131,12 +131,11 @@ embedded_search_client()->MostVisitedInfoChanged(most_visited_info); } -void SearchIPCRouter::SendThemeBackgroundInfo( - const ThemeBackgroundInfo& theme_info) { - if (!policy_->ShouldSendThemeBackgroundInfo()) +void SearchIPCRouter::SendNtpTheme(const NtpTheme& theme) { + if (!policy_->ShouldSendNtpTheme()) return; - embedded_search_client()->ThemeChanged(theme_info); + embedded_search_client()->ThemeChanged(theme); } void SearchIPCRouter::SendLocalBackgroundSelected() {
diff --git a/chrome/browser/ui/search/search_ipc_router.h b/chrome/browser/ui/search/search_ipc_router.h index a3be7fd..c737c15 100644 --- a/chrome/browser/ui/search/search_ipc_router.h +++ b/chrome/browser/ui/search/search_ipc_router.h
@@ -197,7 +197,7 @@ virtual bool ShouldSendSetInputInProgress(bool is_active_tab) = 0; virtual bool ShouldSendOmniboxFocusChanged() = 0; virtual bool ShouldSendMostVisitedInfo() = 0; - virtual bool ShouldSendThemeBackgroundInfo() = 0; + virtual bool ShouldSendNtpTheme() = 0; virtual bool ShouldSendLocalBackgroundSelected() = 0; virtual bool ShouldProcessSetCustomBackgroundInfo() = 0; virtual bool ShouldProcessSelectLocalBackgroundImage() = 0; @@ -244,7 +244,7 @@ void SendMostVisitedInfo(const InstantMostVisitedInfo& most_visited_info); // Tells the renderer about the current theme background. - void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); + void SendNtpTheme(const NtpTheme& theme); // Tells the renderer that "Done" was clicked on the file selection dialog for // uploading a image to use as the NTP background.
diff --git a/chrome/browser/ui/search/search_ipc_router_policy_impl.cc b/chrome/browser/ui/search/search_ipc_router_policy_impl.cc index 9d6b624..aaa0a287 100644 --- a/chrome/browser/ui/search/search_ipc_router_policy_impl.cc +++ b/chrome/browser/ui/search/search_ipc_router_policy_impl.cc
@@ -95,7 +95,7 @@ return !is_incognito_ && search::IsInstantNTP(web_contents_); } -bool SearchIPCRouterPolicyImpl::ShouldSendThemeBackgroundInfo() { +bool SearchIPCRouterPolicyImpl::ShouldSendNtpTheme() { return !is_incognito_ && search::IsInstantNTP(web_contents_); }
diff --git a/chrome/browser/ui/search/search_ipc_router_policy_impl.h b/chrome/browser/ui/search/search_ipc_router_policy_impl.h index 37599bfb..2fc6ca7 100644 --- a/chrome/browser/ui/search/search_ipc_router_policy_impl.h +++ b/chrome/browser/ui/search/search_ipc_router_policy_impl.h
@@ -45,7 +45,7 @@ bool ShouldSendSetInputInProgress(bool is_active_tab) override; bool ShouldSendOmniboxFocusChanged() override; bool ShouldSendMostVisitedInfo() override; - bool ShouldSendThemeBackgroundInfo() override; + bool ShouldSendNtpTheme() override; bool ShouldSendLocalBackgroundSelected() override; bool ShouldProcessSetCustomBackgroundInfo() override; bool ShouldProcessSelectLocalBackgroundImage() override;
diff --git a/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc b/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc index dc9a6529..52ced86 100644 --- a/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc +++ b/chrome/browser/ui/search/search_ipc_router_policy_unittest.cc
@@ -140,7 +140,7 @@ SetIncognitoProfile(); SearchIPCRouter::Policy* router_policy = GetSearchIPCRouterPolicy(); - EXPECT_FALSE(router_policy->ShouldSendThemeBackgroundInfo()); + EXPECT_FALSE(router_policy->ShouldSendNtpTheme()); EXPECT_FALSE(router_policy->ShouldSendMostVisitedInfo()); EXPECT_FALSE(router_policy->ShouldSendSetInputInProgress(true)); EXPECT_FALSE(router_policy->ShouldSendOmniboxFocusChanged()); @@ -157,14 +157,14 @@ EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendMostVisitedInfo()); } -TEST_F(SearchIPCRouterPolicyTest, SendThemeBackgroundInfo) { +TEST_F(SearchIPCRouterPolicyTest, SendNtpTheme) { NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); - EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); + EXPECT_TRUE(GetSearchIPCRouterPolicy()->ShouldSendNtpTheme()); } -TEST_F(SearchIPCRouterPolicyTest, DoNotSendThemeBackgroundInfo) { +TEST_F(SearchIPCRouterPolicyTest, DoNotSendNtpTheme) { // Send theme background information only if the current tab is an // Instant NTP. NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar")); - EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendThemeBackgroundInfo()); + EXPECT_FALSE(GetSearchIPCRouterPolicy()->ShouldSendNtpTheme()); }
diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc index 4023a56..d1278c5 100644 --- a/chrome/browser/ui/search/search_ipc_router_unittest.cc +++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc
@@ -145,7 +145,7 @@ MOCK_METHOD1(ShouldSendSetInputInProgress, bool(bool)); MOCK_METHOD0(ShouldSendOmniboxFocusChanged, bool()); MOCK_METHOD0(ShouldSendMostVisitedInfo, bool()); - MOCK_METHOD0(ShouldSendThemeBackgroundInfo, bool()); + MOCK_METHOD0(ShouldSendNtpTheme, bool()); MOCK_METHOD0(ShouldSendLocalBackgroundSelected, bool()); MOCK_METHOD0(ShouldProcessThemeChangeMessages, bool()); MOCK_METHOD1(ShouldProcessQueryAutocomplete, bool(bool)); @@ -836,28 +836,24 @@ GetSearchIPCRouter().SendMostVisitedInfo(InstantMostVisitedInfo()); } -TEST_F(SearchIPCRouterTest, SendThemeBackgroundInfoMsg) { +TEST_F(SearchIPCRouterTest, SendNtpThemeMsg) { NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); SetupMockDelegateAndPolicy(); MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); - EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()) - .Times(1) - .WillOnce(Return(true)); + EXPECT_CALL(*policy, ShouldSendNtpTheme()).Times(1).WillOnce(Return(true)); EXPECT_CALL(*mock_embedded_search_client(), ThemeChanged(_)); - GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo()); + GetSearchIPCRouter().SendNtpTheme(NtpTheme()); } -TEST_F(SearchIPCRouterTest, DoNotSendThemeBackgroundInfoMsg) { +TEST_F(SearchIPCRouterTest, DoNotSendNtpThemeMsg) { NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl)); SetupMockDelegateAndPolicy(); MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy(); - EXPECT_CALL(*policy, ShouldSendThemeBackgroundInfo()) - .Times(1) - .WillOnce(Return(false)); + EXPECT_CALL(*policy, ShouldSendNtpTheme()).Times(1).WillOnce(Return(false)); EXPECT_CALL(*mock_embedded_search_client(), ThemeChanged(_)).Times(0); - GetSearchIPCRouter().SendThemeBackgroundInfo(ThemeBackgroundInfo()); + GetSearchIPCRouter().SendNtpTheme(NtpTheme()); } TEST_F(SearchIPCRouterTest, SendLocalBackgroundSelectedMsg) {
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc index 084e81a..485fc08 100644 --- a/chrome/browser/ui/search/search_tab_helper.cc +++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -283,8 +283,8 @@ ipc_router_.OnNavigationEntryCommitted(); } -void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { - ipc_router_.SendThemeBackgroundInfo(theme_info); +void SearchTabHelper::NtpThemeChanged(const NtpTheme& theme) { + ipc_router_.SendNtpTheme(theme); } void SearchTabHelper::MostVisitedInfoChanged(
diff --git a/chrome/browser/ui/search/search_tab_helper.h b/chrome/browser/ui/search/search_tab_helper.h index 3fbe6fa..124a611 100644 --- a/chrome/browser/ui/search/search_tab_helper.h +++ b/chrome/browser/ui/search/search_tab_helper.h
@@ -150,7 +150,7 @@ void BlocklistPromo(const std::string& promo_id) override; // Overridden from InstantServiceObserver: - void ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) override; + void NtpThemeChanged(const NtpTheme& theme) override; void MostVisitedInfoChanged( const InstantMostVisitedInfo& most_visited_info) override;
diff --git a/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view.cc b/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view.cc index 662b35c..d48eb367 100644 --- a/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view.cc +++ b/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view.cc
@@ -37,6 +37,14 @@ g_crostini_ansible_software_configuration_view->GetWidget()->Show(); } +void CloseCrostiniAnsibleSoftwareConfigViewForTesting() { + if (g_crostini_ansible_software_configuration_view) { + g_crostini_ansible_software_configuration_view->GetWidget() + ->CloseWithReason(views::Widget::ClosedReason::kUnspecified); + } + g_crostini_ansible_software_configuration_view = nullptr; +} + } // namespace crostini int CrostiniAnsibleSoftwareConfigView::GetDialogButtons() const { @@ -69,14 +77,10 @@ void CrostiniAnsibleSoftwareConfigView::OnAnsibleSoftwareConfigurationFinished( bool success) { DCHECK_EQ(state_, State::CONFIGURING); - ansible_management_service_->RemoveObserver(this); if (!success) { state_ = State::ERROR; - // Bring dialog to front. - GetWidget()->Show(); - GetWidget()->UpdateWindowTitle(); subtext_label_->SetText(l10n_util::GetStringUTF16( IDS_CROSTINI_ANSIBLE_SOFTWARE_CONFIG_ERROR_SUBTEXT)); @@ -136,5 +140,6 @@ } CrostiniAnsibleSoftwareConfigView::~CrostiniAnsibleSoftwareConfigView() { + ansible_management_service_->RemoveObserver(this); g_crostini_ansible_software_configuration_view = nullptr; }
diff --git a/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view_browsertest.cc b/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view_browsertest.cc index 5c2c49b..2e4748a 100644 --- a/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view_browsertest.cc +++ b/chrome/browser/ui/views/crostini/crostini_ansible_software_config_view_browsertest.cc
@@ -5,6 +5,8 @@ #include "chrome/browser/ui/views/crostini/crostini_ansible_software_config_view.h" #include "base/bind_helpers.h" +#include "chrome/browser/chromeos/crostini/ansible/ansible_management_service.h" +#include "chrome/browser/chromeos/crostini/ansible/ansible_management_test_helper.h" #include "chrome/browser/chromeos/crostini/crostini_util.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/crostini/crostini_browser_test_util.h" @@ -16,7 +18,9 @@ : public CrostiniDialogBrowserTest { public: CrostiniAnsibleSoftwareConfigViewBrowserTest() - : CrostiniDialogBrowserTest(true /*register_termina*/) {} + : CrostiniDialogBrowserTest(true /*register_termina*/), + container_id_(crostini::kCrostiniDefaultVmName, + crostini::kCrostiniDefaultContainerName) {} // CrostiniDialogBrowserTest: void ShowUi(const std::string& name) override { @@ -28,6 +32,12 @@ } protected: + void SetUpOnMainThread() override { + test_helper_ = std::make_unique<crostini::AnsibleManagementTestHelper>( + browser()->profile()); + test_helper_->SetUpAnsiblePlaybookPreference(); + } + // A new Widget was created in ShowUi() or since the last VerifyUi(). bool HasView() { return VerifyUi() && ActiveView() != nullptr; } @@ -41,6 +51,13 @@ bool IsErrorDialog() { return HasAcceptButton() && HasErrorStrings(); } + crostini::AnsibleManagementService* ansible_management_service() { + return crostini::AnsibleManagementService::GetForProfile( + browser()->profile()); + } + + crostini::ContainerId container_id_; + private: bool HasAcceptButton() { return ActiveView()->GetDialogClientView()->ok_button() != nullptr; @@ -61,15 +78,15 @@ l10n_util::GetStringUTF16( IDS_CROSTINI_ANSIBLE_SOFTWARE_CONFIG_ERROR_SUBTEXT)) == 0); } + + std::unique_ptr<crostini::AnsibleManagementTestHelper> test_helper_; }; -// Test if dialog is actually launched. IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, InvokeUi_default) { ShowAndVerifyUi(); } -// Test if dialog behaviour is correct during a successful flow. IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, SuccessfulFlow) { ShowUi("default"); @@ -82,7 +99,6 @@ EXPECT_TRUE(HasNoView()); } -// Test if dialog behaviour is correct during an unsuccessful flow. IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, UnsuccessfulFlow) { ShowUi("default"); @@ -95,3 +111,64 @@ EXPECT_NE(nullptr, ActiveView()); EXPECT_TRUE(IsErrorDialog()); } + +IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, + AnsibleConfigFlow_Successful) { + ansible_management_service()->ConfigureDefaultContainer(base::DoNothing()); + base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE(HasView()); + EXPECT_TRUE(IsDefaultDialog()); + + ansible_management_service()->OnInstallLinuxPackageProgress( + container_id_, crostini::InstallLinuxPackageProgressStatus::SUCCEEDED, + 100); + base::RunLoop().RunUntilIdle(); + + EXPECT_NE(nullptr, ActiveView()); + + ansible_management_service()->OnApplyAnsiblePlaybookProgress( + vm_tools::cicerone::ApplyAnsiblePlaybookProgressSignal::SUCCEEDED); + base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE(HasNoView()); +} + +IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, + AnsibleConfigFlow_InstallationFailed) { + ansible_management_service()->ConfigureDefaultContainer(base::DoNothing()); + base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE(HasView()); + EXPECT_TRUE(IsDefaultDialog()); + + ansible_management_service()->OnInstallLinuxPackageProgress( + container_id_, crostini::InstallLinuxPackageProgressStatus::FAILED, 0); + base::RunLoop().RunUntilIdle(); + + EXPECT_NE(nullptr, ActiveView()); + EXPECT_TRUE(IsErrorDialog()); +} + +IN_PROC_BROWSER_TEST_F(CrostiniAnsibleSoftwareConfigViewBrowserTest, + AnsibleConfigFlow_ApplicationFailed) { + ansible_management_service()->ConfigureDefaultContainer(base::DoNothing()); + base::RunLoop().RunUntilIdle(); + + EXPECT_TRUE(HasView()); + EXPECT_TRUE(IsDefaultDialog()); + + ansible_management_service()->OnInstallLinuxPackageProgress( + container_id_, crostini::InstallLinuxPackageProgressStatus::SUCCEEDED, + 100); + base::RunLoop().RunUntilIdle(); + + EXPECT_NE(nullptr, ActiveView()); + + ansible_management_service()->OnApplyAnsiblePlaybookProgress( + vm_tools::cicerone::ApplyAnsiblePlaybookProgressSignal::FAILED); + base::RunLoop().RunUntilIdle(); + + EXPECT_NE(nullptr, ActiveView()); + EXPECT_TRUE(IsErrorDialog()); +}
diff --git a/chrome/browser/ui/views/frame/system_menu_model_builder.cc b/chrome/browser/ui/views/frame/system_menu_model_builder.cc index c4788288..6692871c 100644 --- a/chrome/browser/ui/views/frame/system_menu_model_builder.cc +++ b/chrome/browser/ui/views/frame/system_menu_model_builder.cc
@@ -9,11 +9,9 @@ #include "build/build_config.h" #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/toolbar/app_menu_model.h" #include "chrome/browser/ui/web_applications/app_browser_controller.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/url_constants.h" #include "chrome/grit/generated_resources.h" #include "components/strings/grit/components_strings.h" #include "ui/base/accelerators/accelerator.h" @@ -25,29 +23,13 @@ #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_helper.h" #include "chrome/browser/ui/browser_window.h" +#include "chrome/browser/ui/settings_window_manager_chromeos.h" #include "components/account_id/account_id.h" #include "components/user_manager/user_info.h" #include "components/user_manager/user_manager.h" #include "ui/base/l10n/l10n_util.h" #endif -namespace { - -// Given a |browser| that's an app or popup window, checks if it's hosting the -// settings page. -bool IsChromeSettingsAppOrPopupWindow(Browser* browser) { - DCHECK(browser); - content::WebContents* web_contents = - browser->tab_strip_model()->GetActiveWebContents(); - if (!web_contents) - return false; - const GURL& gurl = web_contents->GetURL(); - return gurl.SchemeIs(content::kChromeUIScheme) && - gurl.host_piece() == chrome::kChromeUISettingsHost; -} - -} // namespace - SystemMenuModelBuilder::SystemMenuModelBuilder( ui::AcceleratorProvider* provider, Browser* browser) @@ -135,14 +117,7 @@ model->AddSeparator(ui::NORMAL_SEPARATOR); model->AddItemWithStringId(IDC_CLOSE_WINDOW, IDS_CLOSE); #endif - - // Avoid appending the teleport menu for the settings window. This window's - // presentation is unique: it's a normal browser window with an app-like - // frame, which doesn't have a user icon badge. Thus if teleported it's not - // clear what user it applies to. Rather than bother to implement badging just - // for this rare case, simply prevent the user from teleporting the window. - if (!IsChromeSettingsAppOrPopupWindow(browser())) - AppendTeleportMenu(model); + AppendTeleportMenu(model); } void SystemMenuModelBuilder::AddFrameToggleItems(ui::SimpleMenuModel* model) { @@ -158,6 +133,16 @@ #if defined(OS_CHROMEOS) DCHECK(browser()->window()); + // Avoid appending the teleport menu for the settings window. This window's + // presentation is unique: it's a normal browser window with an app-like + // frame, which doesn't have a user icon badge. Thus if teleported it's not + // clear what user it applies to. Rather than bother to implement badging just + // for this rare case, simply prevent the user from teleporting the window. + if (chrome::SettingsWindowManager::GetInstance()->IsSettingsBrowser( + browser())) { + return; + } + // Don't show the menu for incognito windows. if (browser()->profile()->IsOffTheRecord()) return;
diff --git a/chrome/browser/ui/views/frame/system_menu_model_builder_browsertest_chromeos.cc b/chrome/browser/ui/views/frame/system_menu_model_builder_browsertest_chromeos.cc new file mode 100644 index 0000000..e7483c7 --- /dev/null +++ b/chrome/browser/ui/views/frame/system_menu_model_builder_browsertest_chromeos.cc
@@ -0,0 +1,100 @@ +// 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. + +#include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/chromeos/login/login_manager_test.h" +#include "chrome/browser/chromeos/login/startup_utils.h" +#include "chrome/browser/chromeos/login/ui/user_adding_screen.h" +#include "chrome/browser/chromeos/profiles/profile_helper.h" +#include "chrome/browser/ui/settings_window_manager_chromeos.h" +#include "chrome/browser/ui/settings_window_manager_observer_chromeos.h" +#include "chrome/browser/ui/views/frame/browser_view.h" +#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h" +#include "chrome/browser/web_applications/system_web_app_manager.h" +#include "chrome/browser/web_applications/web_app_provider.h" +#include "components/account_id/account_id.h" +#include "components/user_manager/user_manager.h" +#include "ui/base/models/menu_model.h" + +using chrome::SettingsWindowManager; +using chrome::SettingsWindowManagerObserver; +using chromeos::ProfileHelper; +using user_manager::UserManager; + +namespace { + +class SystemMenuModelBuilderMultiUserTest + : public chromeos::LoginManagerTest, + public SettingsWindowManagerObserver { + public: + SystemMenuModelBuilderMultiUserTest() + : LoginManagerTest(/*should_launch_browser=*/false, + /*should_initialize_webui=*/false), + account_id1_( + AccountId::FromUserEmailGaiaId("user1@gmail.com", "1111111111")), + account_id2_( + AccountId::FromUserEmailGaiaId("user2@gmail.com", "2222222222")) {} + ~SystemMenuModelBuilderMultiUserTest() override = default; + + // SettingsWindowManagerObserver: + void OnNewSettingsWindow(Browser* settings_browser) override { + settings_browser_ = settings_browser; + } + + protected: + const AccountId account_id1_; + const AccountId account_id2_; + Browser* settings_browser_ = nullptr; +}; + +IN_PROC_BROWSER_TEST_F(SystemMenuModelBuilderMultiUserTest, + PRE_MultiUserSettingsWindowFrameMenu) { + RegisterUser(account_id1_); + RegisterUser(account_id2_); + chromeos::StartupUtils::MarkOobeCompleted(); +} + +// Regression test for https://crbug.com/1023043 +IN_PROC_BROWSER_TEST_F(SystemMenuModelBuilderMultiUserTest, + MultiUserSettingsWindowFrameMenu) { + // Log in 2 users. + LoginUser(account_id1_); + base::RunLoop().RunUntilIdle(); + chromeos::UserAddingScreen::Get()->Start(); + AddUser(account_id2_); + base::RunLoop().RunUntilIdle(); + + // Install the Settings App. + Profile* profile = ProfileHelper::Get()->GetProfileByUser( + UserManager::Get()->FindUser(account_id1_)); + web_app::WebAppProvider::Get(profile) + ->system_web_app_manager() + .InstallSystemAppsForTesting(); + + // Open the settings window and record the |settings_browser_|. + auto* manager = SettingsWindowManager::GetInstance(); + manager->AddObserver(this); + manager->ShowOSSettings(profile); + manager->RemoveObserver(this); + ASSERT_TRUE(settings_browser_); + + // Copy the command ids from the system menu. + BrowserView* browser_view = + BrowserView::GetBrowserViewForBrowser(settings_browser_); + ui::MenuModel* menu = browser_view->frame()->GetSystemMenuModel(); + std::set<int> commands; + for (int i = 0; i < menu->GetItemCount(); i++) + commands.insert(menu->GetCommandIdAt(i)); + + // Standard WebUI commands are available. + EXPECT_TRUE(base::Contains(commands, IDC_BACK)); + EXPECT_TRUE(base::Contains(commands, IDC_FORWARD)); + EXPECT_TRUE(base::Contains(commands, IDC_RELOAD)); + + // Settings window cannot be teleported. + EXPECT_FALSE(base::Contains(commands, IDC_VISIT_DESKTOP_OF_LRU_USER_2)); + EXPECT_FALSE(base::Contains(commands, IDC_VISIT_DESKTOP_OF_LRU_USER_3)); +} + +} // namespace
diff --git a/chrome/browser/ui/views/global_media_controls/media_dialog_view.cc b/chrome/browser/ui/views/global_media_controls/media_dialog_view.cc index a260421..188c169c 100644 --- a/chrome/browser/ui/views/global_media_controls/media_dialog_view.cc +++ b/chrome/browser/ui/views/global_media_controls/media_dialog_view.cc
@@ -7,6 +7,7 @@ #include "base/metrics/histogram_functions.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/ui/global_media_controls/media_notification_service.h" +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" #include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/browser/ui/views/global_media_controls/media_dialog_view_observer.h" #include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h" @@ -89,6 +90,12 @@ observer.OnMediaSessionHidden(); } +std::unique_ptr<OverlayMediaNotification> MediaDialogView::PopOut( + const std::string& id, + gfx::Rect bounds) { + return active_sessions_view_->PopOut(id, bounds); +} + int MediaDialogView::GetDialogButtons() const { return ui::DIALOG_BUTTON_NONE; }
diff --git a/chrome/browser/ui/views/global_media_controls/media_dialog_view.h b/chrome/browser/ui/views/global_media_controls/media_dialog_view.h index d714f51..6bc0fad 100644 --- a/chrome/browser/ui/views/global_media_controls/media_dialog_view.h +++ b/chrome/browser/ui/views/global_media_controls/media_dialog_view.h
@@ -33,6 +33,8 @@ const std::string& id, base::WeakPtr<media_message_center::MediaNotificationItem> item) override; void HideMediaSession(const std::string& id) override; + std::unique_ptr<OverlayMediaNotification> PopOut(const std::string& id, + gfx::Rect bounds) override; // views::DialogDelegate implementation. int GetDialogButtons() const override; @@ -48,6 +50,8 @@ void OnContainerClicked(const std::string& id) override {} void OnContainerDismissed(const std::string& id) override {} void OnContainerDestroyed(const std::string& id) override; + void OnContainerDraggedOut(const std::string& id, gfx::Rect bounds) override { + } void AddObserver(MediaDialogViewObserver* observer); void RemoveObserver(MediaDialogViewObserver* observer);
diff --git a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.cc b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.cc index 2aea6a5..7e4d0b622 100644 --- a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.cc +++ b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.cc
@@ -4,11 +4,13 @@ #include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h" +#include "base/feature_list.h" #include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h" #include "chrome/browser/ui/global_media_controls/media_toolbar_button_controller.h" #include "chrome/browser/ui/views/global_media_controls/media_dialog_view.h" #include "chrome/grit/generated_resources.h" #include "components/vector_icons/vector_icons.h" +#include "media/base/media_switches.h" #include "ui/base/l10n/l10n_util.h" #include "ui/views/animation/ink_drop_mask.h" #include "ui/views/animation/slide_out_controller.h" @@ -33,6 +35,10 @@ // force the MediaNotificationView to be expanded. constexpr int kMinVisibleActionsForExpanding = 4; +// Once the container is dragged this distance, we will not treat the mouse +// press as a click. +constexpr int kMinMovementSquaredToBeDragging = 10; + } // anonymous namespace class MediaNotificationContainerImplView::DismissButton @@ -123,6 +129,63 @@ GetFocusManager()->RemoveFocusChangeListener(this); } +bool MediaNotificationContainerImplView::OnMousePressed( + const ui::MouseEvent& event) { + // Reset the |is_dragging_| flag to track whether this is a drag or a click. + is_dragging_ = false; + + bool button_result = views::Button::OnMousePressed(event); + if (!ShouldHandleMouseEvent(event, /*is_press=*/true)) + return button_result; + + // Set the |is_mouse_pressed_| flag to mark that we're tracking a potential + // drag. + is_mouse_pressed_ = true; + + // Keep track of the initial location to calculate movement. + initial_drag_location_ = event.location(); + + // We want to keep receiving events. + return true; +} + +bool MediaNotificationContainerImplView::OnMouseDragged( + const ui::MouseEvent& event) { + bool button_result = views::Button::OnMouseDragged(event); + if (!ShouldHandleMouseEvent(event, /*is_press=*/false)) + return button_result; + + gfx::Vector2d movement = event.location() - initial_drag_location_; + + // If we ever move enough to be dragging, set the |is_dragging_| flag to + // prevent this mouse press from firing an |OnContainerClicked| event. + if (movement.LengthSquared() >= kMinMovementSquaredToBeDragging) + is_dragging_ = true; + + gfx::Transform transform; + transform.Translate(movement); + swipeable_container_->layer()->SetTransform(transform); + return true; +} + +void MediaNotificationContainerImplView::OnMouseReleased( + const ui::MouseEvent& event) { + views::Button::OnMouseReleased(event); + if (!ShouldHandleMouseEvent(event, /*is_press=*/false)) + return; + + gfx::Vector2d movement = event.location() - initial_drag_location_; + + gfx::Rect bounds_in_screen = GetBoundsInScreen(); + gfx::Rect dragged_bounds = bounds_in_screen + movement; + swipeable_container_->layer()->SetTransform(gfx::Transform()); + + if (!dragged_bounds.Intersects(bounds_in_screen)) { + for (auto& observer : observers_) + observer.OnContainerDraggedOut(id_, dragged_bounds); + } +} + void MediaNotificationContainerImplView::OnMouseEntered( const ui::MouseEvent& event) { UpdateDismissButtonVisibility(); @@ -198,7 +261,10 @@ if (sender == dismiss_button_) { DismissNotification(); } else if (sender == this) { - ContainerClicked(); + // If |is_dragging_| is set, this click should be treated as a drag and not + // fire the |OnContainerClicked()| event. + if (!is_dragging_) + ContainerClicked(); } else { NOTREACHED(); } @@ -214,6 +280,14 @@ observers_.RemoveObserver(observer); } +void MediaNotificationContainerImplView::PopOut() { + // Ensure that we don't keep separator lines around. + SetBorder(nullptr); + + dragged_out_ = true; + SetPosition(gfx::Point(0, 0)); +} + views::ImageButton* MediaNotificationContainerImplView::GetDismissButtonForTesting() { return dismiss_button_; @@ -262,3 +336,24 @@ for (auto& observer : observers_) observer.OnContainerClicked(id_); } + +bool MediaNotificationContainerImplView::ShouldHandleMouseEvent( + const ui::MouseEvent& event, + bool is_press) { + // We only manually handle mouse events for dragging out of the dialog, so if + // the feature is disabled there's no need to handle the event. + if (!base::FeatureList::IsEnabled(media::kGlobalMediaControlsOverlayControls)) + return false; + + // We also don't need to handle if we're already dragged out. + if (dragged_out_) + return false; + + // We only handle non-press events if we've handled the associated press + // event. + if (!is_press && !is_mouse_pressed_) + return false; + + // We only drag via the left button. + return event.IsLeftMouseButton(); +}
diff --git a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h index 8e289335..5038e0b 100644 --- a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h +++ b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h
@@ -45,6 +45,9 @@ // views::Button: void AddedToWidget() override; void RemovedFromWidget() override; + bool OnMousePressed(const ui::MouseEvent& event) override; + bool OnMouseDragged(const ui::MouseEvent& event) override; + void OnMouseReleased(const ui::MouseEvent& event) override; void OnMouseEntered(const ui::MouseEvent& event) override; void OnMouseExited(const ui::MouseEvent& event) override; @@ -79,6 +82,10 @@ void AddObserver(MediaNotificationContainerObserver* observer) override; void RemoveObserver(MediaNotificationContainerObserver* observer) override; + // Sets up the notification to be ready to display in an overlay instead of + // the dialog. + void PopOut(); + views::ImageButton* GetDismissButtonForTesting(); media_message_center::MediaNotificationView* view_for_testing() { @@ -102,6 +109,9 @@ // Notify observers that we've been clicked. void ContainerClicked(); + // True if we should handle the given mouse event for dragging purposes. + bool ShouldHandleMouseEvent(const ui::MouseEvent& event, bool is_press); + const std::string id_; views::View* swipeable_container_ = nullptr; @@ -123,6 +133,23 @@ bool has_artwork_ = false; bool has_many_actions_ = false; + // True if we've been dragged out of the dialog and into an overlay. + bool dragged_out_ = false; + + // True if we're currently tracking a mouse drag. Used for dragging + // notifications out into an overlay notification, not for swiping to dismiss + // (see |slide_out_controller_| for swiping to dismiss). + bool is_mouse_pressed_ = false; + + // The start point of a mouse drag. Used for dragging notifications out into + // an overlay notification, not for swiping to dismiss (see + // |slide_out_controller_| for swiping to dismiss). + gfx::Point initial_drag_location_; + + // True if the current mouse press has been dragged enough to be considered a + // drag instead of a button click. + bool is_dragging_ = false; + base::ObserverList<MediaNotificationContainerObserver> observers_; // Handles gesture events for swiping to dismiss notifications.
diff --git a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view_unittest.cc b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view_unittest.cc index 87e09384..1b078ba 100644 --- a/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view_unittest.cc +++ b/chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view_unittest.cc
@@ -6,8 +6,10 @@ #include "base/containers/flat_set.h" #include "base/strings/utf_string_conversions.h" +#include "base/test/scoped_feature_list.h" #include "build/build_config.h" #include "chrome/browser/ui/global_media_controls/media_notification_container_observer.h" +#include "media/base/media_switches.h" #include "services/media_session/public/mojom/media_session.mojom.h" #include "testing/gmock/include/gmock/gmock.h" #include "ui/display/test/scoped_screen_override.h" @@ -39,6 +41,8 @@ MOCK_METHOD1(OnContainerClicked, void(const std::string& id)); MOCK_METHOD1(OnContainerDismissed, void(const std::string& id)); MOCK_METHOD1(OnContainerDestroyed, void(const std::string& id)); + MOCK_METHOD2(OnContainerDraggedOut, + void(const std::string& id, gfx::Rect bounds)); private: DISALLOW_COPY_AND_ASSIGN(MockMediaNotificationContainerObserver); @@ -259,6 +263,37 @@ DISALLOW_COPY_AND_ASSIGN(MediaNotificationContainerImplViewTest); }; +// TODO(https://crbug.com/1022452): Remove this class once +// |kGlobalMediaControlsOverlayControls| is enabled by default. +class MediaNotificationContainerImplViewOverlayControlsTest + : public MediaNotificationContainerImplViewTest { + public: + void SetUp() override { + feature_list_.InitAndEnableFeature( + media::kGlobalMediaControlsOverlayControls); + MediaNotificationContainerImplViewTest::SetUp(); + } + + void SimulateMouseDrag(gfx::Vector2d drag_distance) { + gfx::Rect start_bounds = notification_container()->bounds(); + gfx::Point drag_start = start_bounds.CenterPoint(); + gfx::Point drag_end = drag_start + drag_distance; + + notification_container()->OnMousePressed( + ui::MouseEvent(ui::ET_MOUSE_PRESSED, drag_start, drag_start, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0)); + notification_container()->OnMouseDragged( + ui::MouseEvent(ui::ET_MOUSE_DRAGGED, drag_end, drag_end, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0)); + notification_container()->OnMouseReleased( + ui::MouseEvent(ui::ET_MOUSE_RELEASED, drag_end, drag_end, + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0)); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + TEST_F(MediaNotificationContainerImplViewTest, SwipeToDismiss) { EXPECT_CALL(observer(), OnContainerDismissed(kTestNotificationId)); SimulateNotificationSwipedToDismiss(); @@ -372,3 +407,37 @@ EXPECT_CALL(observer(), OnContainerClicked(kTestNotificationId)); SimulateHeaderClicked(); } + +TEST_F(MediaNotificationContainerImplViewOverlayControlsTest, + Dragging_VeryShortSendsClick) { + // If the user presses and releases the mouse with only a very short drag, + // then it should be considered a click. + EXPECT_CALL(observer(), OnContainerClicked(kTestNotificationId)); + EXPECT_CALL(observer(), OnContainerDraggedOut(kTestNotificationId, _)) + .Times(0); + SimulateMouseDrag(gfx::Vector2d(1, 1)); + testing::Mock::VerifyAndClearExpectations(&observer()); +} + +TEST_F(MediaNotificationContainerImplViewOverlayControlsTest, + Dragging_ShortDoesNothing) { + // If the user presses and releases the mouse with a drag that doesn't go + // outside of the container, then it should just return to its initial + // position and do nothing. + EXPECT_CALL(observer(), OnContainerClicked(kTestNotificationId)).Times(0); + EXPECT_CALL(observer(), OnContainerDraggedOut(kTestNotificationId, _)) + .Times(0); + SimulateMouseDrag(gfx::Vector2d(20, 20)); + testing::Mock::VerifyAndClearExpectations(&observer()); +} + +TEST_F(MediaNotificationContainerImplViewOverlayControlsTest, + Dragging_LongFiresDraggedOut) { + // If the user presses and releases the mouse with a long enough drag to pull + // the container out of the dialog, then it should fire an + // |OnContainerDraggedOut()| notification. + EXPECT_CALL(observer(), OnContainerClicked(kTestNotificationId)).Times(0); + EXPECT_CALL(observer(), OnContainerDraggedOut(kTestNotificationId, _)); + SimulateMouseDrag(gfx::Vector2d(300, 300)); + testing::Mock::VerifyAndClearExpectations(&observer()); +}
diff --git a/chrome/browser/ui/views/global_media_controls/media_notification_list_view.cc b/chrome/browser/ui/views/global_media_controls/media_notification_list_view.cc index 37817df3..fea3e3d 100644 --- a/chrome/browser/ui/views/global_media_controls/media_notification_list_view.cc +++ b/chrome/browser/ui/views/global_media_controls/media_notification_list_view.cc
@@ -5,6 +5,7 @@ #include "chrome/browser/ui/views/global_media_controls/media_notification_list_view.h" #include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h" +#include "chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h" #include "ui/native_theme/native_theme.h" #include "ui/views/border.h" #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" @@ -61,8 +62,25 @@ } void MediaNotificationListView::HideNotification(const std::string& id) { + RemoveNotification(id); +} + +std::unique_ptr<OverlayMediaNotification> MediaNotificationListView::PopOut( + const std::string& id, + gfx::Rect bounds) { + std::unique_ptr<MediaNotificationContainerImplView> notification = + RemoveNotification(id); + if (!notification) + return nullptr; + + return std::make_unique<OverlayMediaNotificationView>( + id, std::move(notification), bounds); +} + +std::unique_ptr<MediaNotificationContainerImplView> +MediaNotificationListView::RemoveNotification(const std::string& id) { if (!base::Contains(notifications_, id)) - return; + return nullptr; // If we're removing the topmost notification and there are others, then we // need to remove the top-sided separator border from the new topmost @@ -73,11 +91,14 @@ } // Remove the notification. Note that since |RemoveChildView()| does not - // delete the notification, we must do so manually here. + // delete the notification, we now have ownership. contents()->RemoveChildView(notifications_[id]); - delete notifications_[id]; + std::unique_ptr<MediaNotificationContainerImplView> notification( + notifications_[id]); notifications_.erase(id); contents()->InvalidateLayout(); PreferredSizeChanged(); + + return notification; }
diff --git a/chrome/browser/ui/views/global_media_controls/media_notification_list_view.h b/chrome/browser/ui/views/global_media_controls/media_notification_list_view.h index 8bac1f6..4b7e8ef7 100644 --- a/chrome/browser/ui/views/global_media_controls/media_notification_list_view.h +++ b/chrome/browser/ui/views/global_media_controls/media_notification_list_view.h
@@ -11,6 +11,7 @@ #include "ui/views/controls/scroll_view.h" class MediaNotificationContainerImplView; +class OverlayMediaNotification; // MediaNotificationListView is a container that holds a list of active media // sessions. @@ -19,10 +20,19 @@ MediaNotificationListView(); ~MediaNotificationListView() override; + // Adds the given notification into the list. void ShowNotification( const std::string& id, std::unique_ptr<MediaNotificationContainerImplView> notification); + + // Removes the given notification from the list. void HideNotification(const std::string& id); + + // Removes the given notification from the list and returns an + // OverlayMediaNotificationView that contains it. + std::unique_ptr<OverlayMediaNotification> PopOut(const std::string& id, + gfx::Rect bounds); + bool empty() { return notifications_.empty(); } const std::map<const std::string, MediaNotificationContainerImplView*>& @@ -31,6 +41,9 @@ } private: + std::unique_ptr<MediaNotificationContainerImplView> RemoveNotification( + const std::string& id); + std::map<const std::string, MediaNotificationContainerImplView*> notifications_;
diff --git a/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.cc b/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.cc new file mode 100644 index 0000000..5a7902f --- /dev/null +++ b/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.cc
@@ -0,0 +1,133 @@ +// 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. + +#include "chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h" + +#include "chrome/browser/ui/global_media_controls/overlay_media_notifications_manager.h" +#include "chrome/browser/ui/views/global_media_controls/media_notification_container_impl_view.h" +#include "ui/base/hit_test.h" +#include "ui/views/widget/widget_delegate.h" +#include "ui/views/window/non_client_view.h" + +namespace { + +// The pixel height of the draggable area on the overlay notification. +constexpr int kDraggingBoundsHeight = 20; + +class OverlayMediaNotificationFrameView : public views::NonClientFrameView { + public: + OverlayMediaNotificationFrameView() = default; + OverlayMediaNotificationFrameView(const OverlayMediaNotificationFrameView&) = + delete; + OverlayMediaNotificationFrameView& operator=( + const OverlayMediaNotificationFrameView&) = delete; + ~OverlayMediaNotificationFrameView() override = default; + + // views::NonClientFrameView implementation. + gfx::Rect GetBoundsForClientView() const override { return bounds(); } + gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) const override { + return bounds(); + } + int NonClientHitTest(const gfx::Point& point) override { + if (!bounds().Contains(point)) + return HTNOWHERE; + + // TODO(steimel): This should be smarter, but we need to figure out how we + // want to handle dragging vs click-to-go-to-tab. + if (GetDraggingBounds().Contains(point)) + return HTCAPTION; + + return HTCLIENT; + } + void GetWindowMask(const gfx::Size& size, SkPath* window_mask) override {} + void ResetWindowControls() override {} + void UpdateWindowIcon() override {} + void UpdateWindowTitle() override {} + void SizeConstraintsChanged() override {} + + // Returns the bounds in which clicking can drag the window. + gfx::Rect GetDraggingBounds() { + gfx::Rect drag_bounds(bounds()); + drag_bounds.set_height(kDraggingBoundsHeight); + return drag_bounds; + } +}; + +class OverlayMediaNotificationWidgetDelegate : public views::WidgetDelegate { + public: + explicit OverlayMediaNotificationWidgetDelegate( + OverlayMediaNotificationView* widget) + : widget_(widget) { + DCHECK(widget_); + } + OverlayMediaNotificationWidgetDelegate( + const OverlayMediaNotificationWidgetDelegate&) = delete; + OverlayMediaNotificationWidgetDelegate& operator=( + const OverlayMediaNotificationWidgetDelegate&) = delete; + ~OverlayMediaNotificationWidgetDelegate() override = default; + + // views::WidgetDelegate implementation. + bool ShouldShowWindowTitle() const override { return false; } + views::Widget* GetWidget() override { return widget_; } + const views::Widget* GetWidget() const override { return widget_; } + views::NonClientFrameView* CreateNonClientFrameView( + views::Widget* widget) override { + return new OverlayMediaNotificationFrameView(); + } + + private: + // Owns OverlayMediaNotificationWidgetDelegate. + OverlayMediaNotificationView* widget_; +}; + +} // anonymous namespace + +OverlayMediaNotificationView::OverlayMediaNotificationView( + const std::string& id, + std::unique_ptr<MediaNotificationContainerImplView> notification, + gfx::Rect bounds) + : id_(id), notification_(notification.get()) { + DCHECK(notification_); + + // Set up the notification to be ready to show in an overlay. + notification_->PopOut(); + + InitParams params(InitParams::TYPE_WINDOW); + params.ownership = InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.bounds = bounds; + params.z_order = ui::ZOrderLevel::kFloatingWindow; + params.visible_on_all_workspaces = true; + params.remove_standard_frame = true; + params.name = "OverlayMediaNotificationView"; + params.layer_type = ui::LAYER_NOT_DRAWN; + params.delegate = new OverlayMediaNotificationWidgetDelegate(this); + Init(std::move(params)); + GetContentsView()->AddChildView(std::move(notification)); +} + +OverlayMediaNotificationView::~OverlayMediaNotificationView() = default; + +void OverlayMediaNotificationView::SetManager( + OverlayMediaNotificationsManager* manager) { + manager_ = manager; +} + +void OverlayMediaNotificationView::ShowNotification() { + // |SetManager()| should be called before showing the notification to ensure + // that we don't close before it's set. + DCHECK(manager_); + Show(); +} + +void OverlayMediaNotificationView::CloseNotification() { + CloseWithReason(ClosedReason::kUnspecified); +} + +void OverlayMediaNotificationView::OnNativeWidgetDestroyed() { + DCHECK(manager_); + manager_->OnOverlayNotificationClosed(id_); + + views::Widget::OnNativeWidgetDestroyed(); +}
diff --git a/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h b/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h new file mode 100644 index 0000000..3f5a765 --- /dev/null +++ b/chrome/browser/ui/views/global_media_controls/overlay_media_notification_view.h
@@ -0,0 +1,39 @@ +// 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. + +#ifndef CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_VIEW_H_ +#define CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_VIEW_H_ + +#include "chrome/browser/ui/global_media_controls/overlay_media_notification.h" +#include "ui/views/widget/widget.h" + +class MediaNotificationContainerImplView; + +class OverlayMediaNotificationView : public OverlayMediaNotification, + public views::Widget { + public: + OverlayMediaNotificationView( + const std::string& id, + std::unique_ptr<MediaNotificationContainerImplView> notification, + gfx::Rect bounds); + OverlayMediaNotificationView(const OverlayMediaNotificationView&) = delete; + OverlayMediaNotificationView& operator=(const OverlayMediaNotificationView&) = + delete; + ~OverlayMediaNotificationView() override; + + // OverlayMediaNotification implementation. + void SetManager(OverlayMediaNotificationsManager* manager) override; + void ShowNotification() override; + void CloseNotification() override; + + // views::Widget implementation. + void OnNativeWidgetDestroyed() override; + + protected: + OverlayMediaNotificationsManager* manager_ = nullptr; + const std::string id_; + MediaNotificationContainerImplView* const notification_; +}; + +#endif // CHROME_BROWSER_UI_VIEWS_GLOBAL_MEDIA_CONTROLS_OVERLAY_MEDIA_NOTIFICATION_VIEW_H_
diff --git a/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.cc b/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.cc index 8d74c31..d635069 100644 --- a/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.cc +++ b/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.cc
@@ -285,7 +285,8 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); } -void PluginVmLauncherView::OnDownloadFailed() { +void PluginVmLauncherView::OnDownloadFailed( + plugin_vm::PluginVmImageManager::FailureReason reason) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); state_ = State::ERROR; @@ -308,7 +309,8 @@ DCHECK_CURRENTLY_ON(content::BrowserThread::UI); } -void PluginVmLauncherView::OnImportFailed() { +void PluginVmLauncherView::OnImportFailed( + plugin_vm::PluginVmImageManager::FailureReason reason) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); state_ = State::ERROR; @@ -396,6 +398,7 @@ } void PluginVmLauncherView::OnStateUpdated() { + // TODO(https://crbug.com/1017511): display failure reasons. SetBigMessageLabel(); SetMessageLabel(); SetBigImage();
diff --git a/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.h b/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.h index 24c1921..21c69051 100644 --- a/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.h +++ b/chrome/browser/ui/views/plugin_vm/plugin_vm_launcher_view.h
@@ -44,12 +44,14 @@ base::TimeDelta elapsed_time) override; void OnDownloadCompleted() override; void OnDownloadCancelled() override; - void OnDownloadFailed() override; + void OnDownloadFailed( + plugin_vm::PluginVmImageManager::FailureReason reason) override; void OnImportProgressUpdated(int percent_completed, base::TimeDelta elapsed_time) override; void OnImported() override; void OnImportCancelled() override; - void OnImportFailed() override; + void OnImportFailed( + plugin_vm::PluginVmImageManager::FailureReason reason) override; // Public for testing purposes. base::string16 GetBigMessage() const;
diff --git a/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc b/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc index 2e4f5d8..06b32fe 100644 --- a/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc +++ b/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.cc
@@ -4,11 +4,12 @@ #include "chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h" -#include "base/bind.h" +#include <memory> +#include <utility> + #include "base/strings/utf_string_conversions.h" #include "chrome/browser/bookmarks/bookmark_model_factory.h" #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" -#include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/pref_names.h" @@ -23,29 +24,6 @@ BookmarksBrowserTest::~BookmarksBrowserTest() {} -void BookmarksBrowserTest::RegisterMessages() { - web_ui()->RegisterMessageCallback( - "testSetIncognito", - base::BindRepeating(&BookmarksBrowserTest::HandleSetIncognitoAvailability, - base::Unretained(this))); - web_ui()->RegisterMessageCallback( - "testSetCanEdit", - base::BindRepeating(&BookmarksBrowserTest::HandleSetCanEditBookmarks, - base::Unretained(this))); -} - -void BookmarksBrowserTest::SetIncognitoAvailability(int availability) { - ASSERT_TRUE(availability >= 0 && - availability < IncognitoModePrefs::AVAILABILITY_NUM_TYPES); - browser()->profile()->GetPrefs()->SetInteger( - prefs::kIncognitoModeAvailability, availability); -} - -void BookmarksBrowserTest::SetCanEditBookmarks(bool canEdit) { - browser()->profile()->GetPrefs()->SetBoolean( - bookmarks::prefs::kEditBookmarksEnabled, canEdit); -} - void BookmarksBrowserTest::SetupExtensionAPITest() { // Add managed bookmarks. Profile* profile = browser()->profile(); @@ -87,37 +65,3 @@ PrefService* prefs = user_prefs::UserPrefs::Get(profile); prefs->SetBoolean(bookmarks::prefs::kEditBookmarksEnabled, false); } - -void BookmarksBrowserTest::HandleSetIncognitoAvailability( - const base::ListValue* args) { - AllowJavascript(); - - ASSERT_EQ(2U, args->GetSize()); - const base::Value* callback_id; - ASSERT_TRUE(args->Get(0, &callback_id)); - int pref_value; - ASSERT_TRUE(args->GetInteger(1, &pref_value)); - - SetIncognitoAvailability(pref_value); - - ResolveJavascriptCallback(*callback_id, base::Value()); -} - -void BookmarksBrowserTest::HandleSetCanEditBookmarks( - const base::ListValue* args) { - AllowJavascript(); - - ASSERT_EQ(2U, args->GetSize()); - const base::Value* callback_id; - ASSERT_TRUE(args->Get(0, &callback_id)); - bool pref_value; - ASSERT_TRUE(args->GetBoolean(1, &pref_value)); - - SetCanEditBookmarks(pref_value); - - ResolveJavascriptCallback(*callback_id, base::Value()); -} - -content::WebUIMessageHandler* BookmarksBrowserTest::GetMockMessageHandler() { - return this; -}
diff --git a/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h b/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h index fe2bc149a..7eee4f0 100644 --- a/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h +++ b/chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h
@@ -6,30 +6,16 @@ #define CHROME_BROWSER_UI_WEBUI_BOOKMARKS_BOOKMARKS_BROWSERTEST_H_ #include "chrome/test/base/web_ui_browser_test.h" -#include "content/public/browser/web_ui_message_handler.h" -class BookmarksBrowserTest : public WebUIBrowserTest, - public content::WebUIMessageHandler { +class BookmarksBrowserTest : public WebUIBrowserTest { public: BookmarksBrowserTest(); ~BookmarksBrowserTest() override; - void SetIncognitoAvailability(int availability); - void SetCanEditBookmarks(bool canEdit); - void SetupExtensionAPITest(); void SetupExtensionAPIEditDisabledTest(); private: - void HandleSetIncognitoAvailability(const base::ListValue* args); - void HandleSetCanEditBookmarks(const base::ListValue* args); - - // content::WebUIMessageHandler: - void RegisterMessages() override; - - // WebUIBrowserTest: - content::WebUIMessageHandler* GetMockMessageHandler() override; - DISALLOW_COPY_AND_ASSIGN(BookmarksBrowserTest); };
diff --git a/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc b/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc index 517fd52..60fc913d 100644 --- a/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc +++ b/chrome/browser/ui/webui/bookmarks/bookmarks_ui.cc
@@ -129,6 +129,9 @@ source->AddResourcePath("api_listener.js", IDR_BOOKMARKS_API_LISTENER_JS); source->AddResourcePath("app.html", IDR_BOOKMARKS_APP_HTML); source->AddResourcePath("app.js", IDR_BOOKMARKS_APP_JS); + source->AddResourcePath("browser_proxy.html", + IDR_BOOKMARKS_BROWSER_PROXY_HTML); + source->AddResourcePath("browser_proxy.js", IDR_BOOKMARKS_BROWSER_PROXY_JS); source->AddResourcePath("command_manager.html", IDR_BOOKMARKS_COMMAND_MANAGER_HTML); source->AddResourcePath("command_manager.js",
diff --git a/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc b/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc index b37304b..11c680f 100644 --- a/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc +++ b/chrome/browser/ui/webui/chromeos/account_manager_welcome_dialog.cc
@@ -7,6 +7,7 @@ #include <string> #include "base/logging.h" +#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/settings_window_manager_chromeos.h" @@ -73,8 +74,11 @@ void AccountManagerWelcomeDialog::OnDialogClosed( const std::string& json_retval) { - chrome::SettingsWindowManager::GetInstance()->ShowOSSettings( - ProfileManager::GetActiveUserProfile(), chrome::kAccountManagerSubPage); + // Opening Settings during shutdown leads to a crash. + if (!chrome::IsAttemptingShutdown()) { + chrome::SettingsWindowManager::GetInstance()->ShowOSSettings( + ProfileManager::GetActiveUserProfile(), chrome::kAccountManagerSubPage); + } SystemWebDialogDelegate::OnDialogClosed(json_retval); }
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc index beeb4a8..2603465 100644 --- a/chrome/browser/ui/webui/print_preview/print_preview_ui.cc +++ b/chrome/browser/ui/webui/print_preview/print_preview_ui.cc
@@ -57,6 +57,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_features.h" #include "ui/gfx/geometry/rect.h" +#include "ui/resources/grit/webui_resources.h" #include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_ui.h" @@ -83,6 +84,11 @@ const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)"; #endif +#if !BUILDFLAG(OPTIMIZE_WEBUI) +constexpr char kGeneratedPath[] = + "@out_folder@/gen/chrome/browser/resources/print_preview/"; +#endif + PrintPreviewUI::TestDelegate* g_test_delegate = nullptr; // Thread-safe wrapper around a std::map to keep track of mappings from @@ -389,20 +395,34 @@ content::WebUIDataSource* CreatePrintPreviewUISource(Profile* profile) { content::WebUIDataSource* source = content::WebUIDataSource::Create(chrome::kChromeUIPrintHost); + source->OverrideContentSecurityPolicyScriptSrc( + "script-src chrome://resources chrome://test 'self';"); AddPrintPreviewStrings(source); source->UseStringsJs(); + source->EnableReplaceI18nInJS(); #if BUILDFLAG(OPTIMIZE_WEBUI) - source->AddResourcePath("crisper.js", IDR_PRINT_PREVIEW_CRISPER_JS); + source->AddResourcePath("print_preview.js", + IDR_PRINT_PREVIEW_PRINT_PREVIEW_JS); source->SetDefaultResource(IDR_PRINT_PREVIEW_VULCANIZED_HTML); #else + // Add all Print Preview resources. + std::string generated_path = + "@out_folder@/gen/chrome/browser/resources/print_preview/"; + for (size_t i = 0; i < kPrintPreviewResourcesSize; ++i) { - source->AddResourcePath(kPrintPreviewResources[i].name, - kPrintPreviewResources[i].value); + std::string path = kPrintPreviewResources[i].name; + if (path.rfind(kGeneratedPath, 0) == 0) { + path = path.substr(sizeof(kGeneratedPath) - 1); + } + + source->AddResourcePath(path, kPrintPreviewResources[i].value); } source->SetDefaultResource(IDR_PRINT_PREVIEW_HTML); #endif SetupPrintPreviewPlugin(source); AddPrintPreviewFlags(source, profile); + source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER); + source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER); return source; }
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc index ce238a4..5aa96cc 100644 --- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc +++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.cc
@@ -9,6 +9,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/containers/flat_map.h" +#include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/json/json_string_value_serializer.h" #include "base/logging.h" @@ -29,6 +30,7 @@ #include "chrome/browser/chromeos/printing/printer_event_tracker_factory.h" #include "chrome/browser/chromeos/printing/printer_info.h" #include "chrome/browser/download/download_prefs.h" +#include "chrome/browser/local_discovery/endpoint_resolver.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_window.h"
diff --git a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h index 3fe1146..6d211cc 100644 --- a/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h +++ b/chrome/browser/ui/webui/settings/chromeos/cups_printers_handler.h
@@ -10,23 +10,25 @@ #include <string> #include <vector> -#include "base/files/file_path.h" #include "base/memory/weak_ptr.h" #include "base/scoped_observer.h" #include "chrome/browser/chromeos/printing/cups_printers_manager.h" #include "chrome/browser/chromeos/printing/printer_configurer.h" #include "chrome/browser/chromeos/printing/printer_event_tracker.h" -#include "chrome/browser/local_discovery/endpoint_resolver.h" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" -#include "chromeos/printing/ppd_provider.h" #include "chromeos/printing/printer_configuration.h" #include "printing/printer_query_result_chromeos.h" #include "ui/shell_dialogs/select_file_dialog.h" namespace base { +class FilePath; class ListValue; } // namespace base +namespace local_discovery { +class EndpointResolver; +} // namespace local_discovery + class Profile; namespace chromeos {
diff --git a/chrome/common/extensions/api/autotest_private.idl b/chrome/common/extensions/api/autotest_private.idl index 896298d..011a8ab 100644 --- a/chrome/common/extensions/api/autotest_private.idl +++ b/chrome/common/extensions/api/autotest_private.idl
@@ -335,6 +335,12 @@ ExtensionApp }; + // The frame mode of a window. None if the window is framesless. + enum FrameMode { + Normal, + Immersive + }; + dictionary AppWindowInfo { // The identifier of the window. This shouldn't change across the time. long id; @@ -380,6 +386,8 @@ boolean hasCapture; // Window frame info + FrameMode frameMode; + boolean isFrameVisible; long captionHeight; // The bitset of the enabled caption buttons. See // ui/views/window/caption_button_types.h.
diff --git a/chrome/common/instant_mojom_traits.h b/chrome/common/instant_mojom_traits.h index 93ee65be..8736ee0d 100644 --- a/chrome/common/instant_mojom_traits.h +++ b/chrome/common/instant_mojom_traits.h
@@ -62,7 +62,7 @@ IPC_STRUCT_TRAITS_MEMBER(is_visible) IPC_STRUCT_TRAITS_END() -IPC_STRUCT_TRAITS_BEGIN(ThemeBackgroundInfo) +IPC_STRUCT_TRAITS_BEGIN(NtpTheme) IPC_STRUCT_TRAITS_MEMBER(using_default_theme) IPC_STRUCT_TRAITS_MEMBER(using_dark_colors) IPC_STRUCT_TRAITS_MEMBER(custom_background_url)
diff --git a/chrome/common/search.mojom b/chrome/common/search.mojom index 5f76fb2..4c71ce0a 100644 --- a/chrome/common/search.mojom +++ b/chrome/common/search.mojom
@@ -204,7 +204,7 @@ struct InstantMostVisitedInfo; [Native] -struct ThemeBackgroundInfo; +struct NtpTheme; // Renderer interface used by the browser to push updates to the client. For // example, the browser will tell the frame if the omnibox got focus. @@ -224,8 +224,8 @@ // Input into the Omnibox has started/stopped. SetInputInProgress(bool input_in_progress); - // The browser theme has changed, the NTP should be updated accordingly. - ThemeChanged(ThemeBackgroundInfo value); + // The NTP theme has changed; update accordingly. + ThemeChanged(NtpTheme them); // A background image was selected from the file upload dialog. LocalBackgroundSelected();
diff --git a/chrome/common/search.typemap b/chrome/common/search.typemap index 0f7ae511..d26da6b 100644 --- a/chrome/common/search.typemap +++ b/chrome/common/search.typemap
@@ -21,5 +21,5 @@ "chrome.mojom.OmniboxFocusState=::OmniboxFocusState", "chrome.mojom.OmniboxFocusChangeReason=::OmniboxFocusChangeReason", "chrome.mojom.InstantMostVisitedInfo=::InstantMostVisitedInfo", - "chrome.mojom.ThemeBackgroundInfo=::ThemeBackgroundInfo", + "chrome.mojom.NtpTheme=::NtpTheme", ]
diff --git a/chrome/common/search/instant_types.cc b/chrome/common/search/instant_types.cc index f94c1be9..3f518db 100644 --- a/chrome/common/search/instant_types.cc +++ b/chrome/common/search/instant_types.cc
@@ -4,14 +4,13 @@ #include "chrome/common/search/instant_types.h" -ThemeBackgroundInfo::ThemeBackgroundInfo() = default; +NtpTheme::NtpTheme() = default; -ThemeBackgroundInfo::ThemeBackgroundInfo(const ThemeBackgroundInfo& other) = - default; +NtpTheme::NtpTheme(const NtpTheme& other) = default; -ThemeBackgroundInfo::~ThemeBackgroundInfo() = default; +NtpTheme::~NtpTheme() = default; -bool ThemeBackgroundInfo::operator==(const ThemeBackgroundInfo& rhs) const { +bool NtpTheme::operator==(const NtpTheme& rhs) const { return using_default_theme == rhs.using_default_theme && using_dark_colors == rhs.using_dark_colors && custom_background_url == rhs.custom_background_url &&
diff --git a/chrome/common/search/instant_types.h b/chrome/common/search/instant_types.h index 99916b21..1ba2b5c 100644 --- a/chrome/common/search/instant_types.h +++ b/chrome/common/search/instant_types.h
@@ -44,13 +44,13 @@ THEME_BKGRND_IMAGE_LAST = THEME_BKGRND_IMAGE_REPEAT, }; -// Theme background settings for the NTP. -struct ThemeBackgroundInfo { - ThemeBackgroundInfo(); - ThemeBackgroundInfo(const ThemeBackgroundInfo& other); - ~ThemeBackgroundInfo(); +// Theme settings for the NTP. +struct NtpTheme { + NtpTheme(); + NtpTheme(const NtpTheme& other); + ~NtpTheme(); - bool operator==(const ThemeBackgroundInfo& rhs) const; + bool operator==(const NtpTheme& rhs) const; // True if the default theme is selected. bool using_default_theme = true;
diff --git a/chrome/common/search/mock_embedded_search_client.h b/chrome/common/search/mock_embedded_search_client.h index f5008ea9..21d5991 100644 --- a/chrome/common/search/mock_embedded_search_client.h +++ b/chrome/common/search/mock_embedded_search_client.h
@@ -6,6 +6,7 @@ #define CHROME_COMMON_SEARCH_MOCK_EMBEDDED_SEARCH_CLIENT_H_ #include "chrome/common/search.mojom.h" +#include "chrome/common/search/instant_types.h" #include "testing/gmock/include/gmock/gmock.h" class MockEmbeddedSearchClient : public chrome::mojom::EmbeddedSearchClient { @@ -17,7 +18,7 @@ MOCK_METHOD2(FocusChanged, void(OmniboxFocusState, OmniboxFocusChangeReason)); MOCK_METHOD1(MostVisitedInfoChanged, void(const InstantMostVisitedInfo&)); MOCK_METHOD1(SetInputInProgress, void(bool)); - MOCK_METHOD1(ThemeChanged, void(const ThemeBackgroundInfo&)); + MOCK_METHOD1(ThemeChanged, void(const NtpTheme&)); MOCK_METHOD0(LocalBackgroundSelected, void()); };
diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc index f2576ab..5c270d29 100644 --- a/chrome/renderer/searchbox/searchbox.cc +++ b/chrome/renderer/searchbox/searchbox.cc
@@ -281,8 +281,8 @@ item); } -const ThemeBackgroundInfo* SearchBox::GetThemeBackgroundInfo() const { - return base::OptionalOrNullptr(theme_info_); +const NtpTheme* SearchBox::GetNtpTheme() const { + return base::OptionalOrNullptr(theme_); } void SearchBox::Paste(const base::string16& text) { @@ -569,12 +569,12 @@ } } -void SearchBox::ThemeChanged(const ThemeBackgroundInfo& theme_info) { +void SearchBox::ThemeChanged(const NtpTheme& theme) { // Do not send duplicate notifications. - if (theme_info_ == theme_info) + if (theme_ == theme) return; - theme_info_ = theme_info; + theme_ = theme; if (can_run_js_in_renderframe_) SearchBoxExtension::DispatchThemeChange(render_frame()->GetWebFrame()); }
diff --git a/chrome/renderer/searchbox/searchbox.h b/chrome/renderer/searchbox/searchbox.h index c7755aab..c4e0d4d1 100644 --- a/chrome/renderer/searchbox/searchbox.h +++ b/chrome/renderer/searchbox/searchbox.h
@@ -95,7 +95,7 @@ void Paste(const base::string16& text); // Will return null if the theme info hasn't been set yet. - const ThemeBackgroundInfo* GetThemeBackgroundInfo() const; + const NtpTheme* GetNtpTheme() const; // Sends FocusOmnibox(OMNIBOX_FOCUS_INVISIBLE) to the browser. void StartCapturingKeyStrokes(); @@ -220,7 +220,7 @@ void MostVisitedInfoChanged( const InstantMostVisitedInfo& most_visited_info) override; void SetInputInProgress(bool input_in_progress) override; - void ThemeChanged(const ThemeBackgroundInfo& theme_info) override; + void ThemeChanged(const NtpTheme& theme) override; void LocalBackgroundSelected() override; void AddCustomLinkResult(bool success); @@ -264,7 +264,7 @@ // comparing most visited items. InstantMostVisitedInfo most_visited_info_; bool has_received_most_visited_; - base::Optional<ThemeBackgroundInfo> theme_info_; + base::Optional<NtpTheme> theme_; base::WeakPtrFactory<SearchBox> weak_ptr_factory_{this};
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc index 5412c556..fdaf0cc 100644 --- a/chrome/renderer/searchbox/searchbox_extension.cc +++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -240,9 +240,8 @@ return true; } -v8::Local<v8::Object> GenerateThemeBackgroundInfo( - v8::Isolate* isolate, - const ThemeBackgroundInfo& theme_info) { +v8::Local<v8::Object> GenerateNtpTheme(v8::Isolate* isolate, + const NtpTheme& theme_info) { gin::DataObjectBuilder builder(isolate); // True if the theme is the system default and no custom theme has been @@ -710,7 +709,7 @@ static bool IsInputInProgress(); static v8::Local<v8::Value> GetMostVisited(v8::Isolate* isolate); static bool GetMostVisitedAvailable(v8::Isolate* isolate); - static v8::Local<v8::Value> GetThemeBackgroundInfo(v8::Isolate* isolate); + static v8::Local<v8::Value> GetNtpTheme(v8::Isolate* isolate); static bool GetIsCustomLinks(); static bool GetIsUsingMostVisited(); static bool GetAreShortcutsVisible(); @@ -790,8 +789,10 @@ .SetProperty("mostVisited", &NewTabPageBindings::GetMostVisited) .SetProperty("mostVisitedAvailable", &NewTabPageBindings::GetMostVisitedAvailable) - .SetProperty("themeBackgroundInfo", - &NewTabPageBindings::GetThemeBackgroundInfo) + .SetProperty("ntpTheme", &NewTabPageBindings::GetNtpTheme) + // TODO(https://crbug.com/1020450): remove "themeBackgroundInfo" legacy + // name when we're sure no third-party NTP needs it. + .SetProperty("themeBackgroundInfo", &NewTabPageBindings::GetNtpTheme) .SetProperty("isCustomLinks", &NewTabPageBindings::GetIsCustomLinks) .SetProperty("isUsingMostVisited", &NewTabPageBindings::GetIsUsingMostVisited) @@ -908,15 +909,14 @@ } // static -v8::Local<v8::Value> NewTabPageBindings::GetThemeBackgroundInfo( - v8::Isolate* isolate) { +v8::Local<v8::Value> NewTabPageBindings::GetNtpTheme(v8::Isolate* isolate) { const SearchBox* search_box = GetSearchBoxForCurrentContext(); if (!search_box) return v8::Null(isolate); - const ThemeBackgroundInfo* theme_info = search_box->GetThemeBackgroundInfo(); + const NtpTheme* theme_info = search_box->GetNtpTheme(); if (!theme_info) return v8::Null(isolate); - return GenerateThemeBackgroundInfo(isolate, *theme_info); + return GenerateNtpTheme(isolate, *theme_info); } // static
diff --git a/chrome/services/app_service/BUILD.gn b/chrome/services/app_service/BUILD.gn index 77d9de0..f2d1a135 100644 --- a/chrome/services/app_service/BUILD.gn +++ b/chrome/services/app_service/BUILD.gn
@@ -12,6 +12,7 @@ "//base", "//components/prefs", "//mojo/public/cpp/bindings", + "//services/preferences/public/cpp", "//services/service_manager/public/cpp", ]
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn index b89022f..27586075 100644 --- a/chrome/test/BUILD.gn +++ b/chrome/test/BUILD.gn
@@ -2352,6 +2352,7 @@ "../browser/ui/views/frame/browser_frame_ash_browsertest.cc", "../browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc", "../browser/ui/views/frame/immersive_mode_controller_ash_browsertest.cc", + "../browser/ui/views/frame/system_menu_model_builder_browsertest_chromeos.cc", "../browser/ui/views/frame/top_controls_slide_controller_chromeos_browsertest.cc", "../browser/ui/views/plugin_vm/plugin_vm_launcher_view_browsertest.cc", "../browser/ui/views/web_apps/web_app_ash_interactive_ui_test.cc",
diff --git a/chrome/test/data/extensions/api_test/autotest_private/test.js b/chrome/test/data/extensions/api_test/autotest_private/test.js index ac15733d..89fba4a 100644 --- a/chrome/test/data/extensions/api_test/autotest_private/test.js +++ b/chrome/test/data/extensions/api_test/autotest_private/test.js
@@ -13,6 +13,10 @@ return accelerator; }; +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + var defaultTests = [ // logout/restart/shutdown don't do anything as we don't want to kill the // browser with these tests. @@ -646,16 +650,35 @@ window.captionButtonVisibleStatus, kMinimizeMask | kMaximizeRestoreMask | kCloseMask | kLeftSnappedMask | kRightSnappedMask); + chrome.test.assertEq('Normal', window.frameMode); + chrome.test.assertTrue(window.isFrameVisible); var change = new Object(); - change.eventType = 'WMEventMaximize'; + change.eventType = 'WMEventFullscreen'; chrome.autotestPrivate.setAppWindowState( window.id, change, function(state) { - chrome.test.assertEq(state, 'Maximized'); - chrome.test.assertNoLastError(); - chrome.test.succeed(); + chrome.test.assertEq(state, 'Fullscreen'); + chrome.autotestPrivate.getAppWindowList(async function(list) { + var window = list[browserFrameIndex]; + chrome.test.assertEq('Immersive', window.frameMode); + chrome.test.assertTrue(window.isFrameVisible); + // Hide animation finishes in 400ms. Wait 2x for safety. + await sleep(800); + chrome.autotestPrivate.getAppWindowList(function(list) { + var window = list[browserFrameIndex]; + chrome.test.assertEq('Immersive', window.frameMode); + chrome.test.assertFalse(window.isFrameVisible); + // The frame should still have the same buttons. + chrome.test.assertEq( + window.captionButtonVisibleStatus, + kMinimizeMask | kMaximizeRestoreMask | kCloseMask | + kLeftSnappedMask | kRightSnappedMask); + chrome.test.assertNoLastError(); + chrome.test.succeed(); + }); + }); }); } chrome.test.assertTrue(-1 != browserFrameIndex); @@ -833,9 +856,6 @@ function arcAppTracingNormal() { chrome.autotestPrivate.arcAppTracingStart(async function() { chrome.test.assertNoLastError(); - function sleep(ms) { - return new Promise(resolve => setTimeout(resolve, ms)); - } // We generate 15 frames in test. await sleep(250); chrome.autotestPrivate.arcAppTracingStopAndAnalyze(
diff --git a/chrome/test/data/extensions/api_test/declarative_net_request/dynamic_rules/background.js b/chrome/test/data/extensions/api_test/declarative_net_request/dynamic_rules/background.js index d27c1cb9..ea432fe 100644 --- a/chrome/test/data/extensions/api_test/declarative_net_request/dynamic_rules/background.js +++ b/chrome/test/data/extensions/api_test/declarative_net_request/dynamic_rules/background.js
@@ -2,8 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -var addDynamicRules = chrome.declarativeNetRequest.addDynamicRules; -var removeDynamicRules = chrome.declarativeNetRequest.removeDynamicRules; +var updateDynamicRules = chrome.declarativeNetRequest.updateDynamicRules; var getDynamicRules = chrome.declarativeNetRequest.getDynamicRules; var ruleLimit = chrome.declarativeNetRequest.MAX_NUMBER_OF_DYNAMIC_RULES; @@ -43,26 +42,26 @@ }, function addRulesEmpty() { - addDynamicRules(currentRules, verifyCurrentRulesCallback); + updateDynamicRules([], currentRules, verifyCurrentRulesCallback); }, function addRules() { currentRules = [createRuleWithID(1), createRuleWithID(2), createRuleWithID(3)]; - addDynamicRules(currentRules, verifyCurrentRulesCallback); + updateDynamicRules([], currentRules, verifyCurrentRulesCallback); }, function removeRules() { // Remove rule with id 1, 2. // Also ensure rule ids which are not present are ignored. currentRules = currentRules.filter(rule => rule.id === 3); - removeDynamicRules([4, 5, 2, 1], verifyCurrentRulesCallback); + updateDynamicRules([4, 5, 2, 1], [], verifyCurrentRulesCallback); }, // Ensure we fail on adding a rule with a duplicate ID. function duplicateID() { - addDynamicRules( - currentRules, + updateDynamicRules( + [], currentRules, chrome.test.callbackFail('Rule with id 3 does not have a unique ID.')); }, @@ -76,13 +75,13 @@ currentRules = newRules.concat(currentRules); chrome.test.assertEq(ruleLimit, currentRules.length); - addDynamicRules(newRules, verifyCurrentRulesCallback); + updateDynamicRules([], newRules, verifyCurrentRulesCallback); }, // Ensure we can't add more than |ruleLimit| rules. function ruleLimitError() { - addDynamicRules( - [createRuleWithID(1)], + updateDynamicRules( + [], [createRuleWithID(1)], chrome.test.callbackFail('Dynamic rule count exceeded.')); } ]);
diff --git a/chrome/test/data/extensions/api_test/declarative_net_request/header_removal/background.js b/chrome/test/data/extensions/api_test/declarative_net_request/header_removal/background.js index b1747bf..3e6dc64 100644 --- a/chrome/test/data/extensions/api_test/declarative_net_request/header_removal/background.js +++ b/chrome/test/data/extensions/api_test/declarative_net_request/header_removal/background.js
@@ -230,7 +230,7 @@ // Clears the current state by removing rules specified in |ruleIds| and // clearing all cookies. function clearState(ruleIds, callback) { - chrome.declarativeNetRequest.removeDynamicRules(ruleIds, function() { + chrome.declarativeNetRequest.updateDynamicRules(ruleIds, [], function() { chrome.test.assertNoLastError(); checkAndResetCookies().then(callback); }); @@ -261,7 +261,7 @@ function addRulesAndTestCookieRemoval() { var rules = [removeCookieRule]; - chrome.declarativeNetRequest.addDynamicRules(rules, function() { + chrome.declarativeNetRequest.updateDynamicRules([], rules, function() { chrome.test.assertNoLastError(); checkCookieHeaderRemoved(true); }); @@ -273,7 +273,7 @@ function addRulesAndTestSetCookieRemoval() { var rules = [removeSetCookieRule]; - chrome.declarativeNetRequest.addDynamicRules(rules, function() { + chrome.declarativeNetRequest.updateDynamicRules([], rules, function() { chrome.test.assertNoLastError(); checkSetCookieHeaderRemoved(true); }); @@ -288,7 +288,7 @@ function testAddWebRequestCookieWithRules() { var rules = [removeCookieRule]; - chrome.declarativeNetRequest.addDynamicRules(rules, function() { + chrome.declarativeNetRequest.updateDynamicRules([], rules, function() { checkAddWebRequestCookie(true); }); }, @@ -299,13 +299,13 @@ function testAddWebRequestSetCookieWithRules() { var rules = [removeSetCookieRule]; - chrome.declarativeNetRequest.addDynamicRules(rules, function() { + chrome.declarativeNetRequest.updateDynamicRules([], rules, function() { checkAddWebRequestSetCookie(true); }); }, function testAddWebRequestCookieWithAllowRule() { - chrome.declarativeNetRequest.addDynamicRules([allowRule], () => { + chrome.declarativeNetRequest.updateDynamicRules([], [allowRule], () => { checkAddWebRequestSetCookie(false); }); },
diff --git a/chrome/test/data/extensions/api_test/mime_handler_view/index.js b/chrome/test/data/extensions/api_test/mime_handler_view/index.js index 3e48dcd1..becddd0 100644 --- a/chrome/test/data/extensions/api_test/mime_handler_view/index.js +++ b/chrome/test/data/extensions/api_test/mime_handler_view/index.js
@@ -234,6 +234,28 @@ () => document.body.webkitRequestFullscreen()); }, + function testFullscreenEscape() { + checkStreamDetails('testFullscreenEscape.csv', false); + var calls = 0; + var windowId; + window.addEventListener('webkitfullscreenchange', async e => { + switch(calls) { + case 0: // On fullscreen entered. + chrome.test.assertTrue(document.webkitIsFullScreen); + chrome.test.assertEq(document.body, document.webkitFullscreenElement); + break; + case 1: // On fullscreen exited. + chrome.test.assertFalse(document.webkitIsFullScreen); + chrome.test.assertEq(null, document.webkitFullscreenElement); + chrome.test.succeed(); + break; + } + calls++; + }); + chrome.test.runWithUserGesture( + () => document.body.webkitRequestFullscreen()); + }, + function testBackgroundPage() { checkStreamDetails('testBackgroundPage.csv', false); chrome.runtime.getBackgroundPage(backgroundPage => {
diff --git a/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv b/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv new file mode 100644 index 0000000..1466c1f --- /dev/null +++ b/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv
@@ -0,0 +1 @@ +Some text to render.
diff --git a/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv.mock-http-headers b/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv.mock-http-headers new file mode 100644 index 0000000..2eef2e8 --- /dev/null +++ b/chrome/test/data/extensions/api_test/mime_handler_view/testFullscreenEscape.csv.mock-http-headers
@@ -0,0 +1,2 @@ +HTTP/1.0 200 OK +Content-Type: text/csv
diff --git a/chrome/test/data/local_ntp/customize_menu_browsertest.js b/chrome/test/data/local_ntp/customize_menu_browsertest.js index c509bc84..55e7867 100644 --- a/chrome/test/data/local_ntp/customize_menu_browsertest.js +++ b/chrome/test/data/local_ntp/customize_menu_browsertest.js
@@ -126,10 +126,10 @@ /** * Themed properties for testing to be used instead of - * chrome.embeddedSearch.newTabPage.themeBackgroundInfo. + * chrome.embeddedSearch.newTabPage.ntpTheme. * @type {?Object} */ -test.customizeMenu.mockThemeBackgroundInfo = {}; +test.customizeMenu.mockNtpTheme = {}; /** * Sets up the page for each individual test. @@ -156,7 +156,7 @@ test.customizeMenu.toggleMostVisitedOrCustomLinksCount = 0; test.customizeMenu.toggleShortcutsVisibilityCount = 0; test.customizeMenu.timesCustomBackgroundWasSet = 0; - test.customizeMenu.mockThemeBackgroundInfo = {}; + test.customizeMenu.mockNtpTheme = {}; }; // ******************************* SIMPLE TESTS ******************************* @@ -724,8 +724,8 @@ /** * Test that at theme info is not visible when no theme id is available. */ -test.customizeMenu.testColors_ThemeInfo_NoThemeID = function() { - test.customizeMenu.mockThemeBackgroundInfo = {themeName: 'test theme name'}; +test.customizeMenu.testColors_NtpTheme_NoThemeID = function() { + test.customizeMenu.mockNtpTheme = {themeName: 'test theme name'}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -735,8 +735,8 @@ /** * Test that at theme info is not visible when no theme name is available. */ -test.customizeMenu.testColors_ThemeInfo_NoThemeName = function() { - test.customizeMenu.mockThemeBackgroundInfo = {themeId: 'test theme id'}; +test.customizeMenu.testColors_NtpTheme_NoThemeName = function() { + test.customizeMenu.mockNtpTheme = {themeId: 'test theme id'}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -746,8 +746,8 @@ /** * Test that at theme info is visible. */ -test.customizeMenu.testColors_ThemeInfo_Visible = function() { - test.customizeMenu.mockThemeBackgroundInfo = { +test.customizeMenu.testColors_NtpTheme_Visible = function() { + test.customizeMenu.mockNtpTheme = { themeId: 'test theme id', themeName: 'test theme name' }; @@ -760,8 +760,8 @@ /** * Test that at theme uninstall triggers correct calls. */ -test.customizeMenu.testColors_ThemeInfo_Uninstall = function() { - test.customizeMenu.mockThemeBackgroundInfo = { +test.customizeMenu.testColors_NtpTheme_Uninstall = function() { + test.customizeMenu.mockNtpTheme = { themeId: 'test theme id', themeName: 'test theme name' }; @@ -779,7 +779,7 @@ * Test preselect default tile. */ test.customizeMenu.testColors_PreselectDefault = function() { - test.customizeMenu.mockThemeBackgroundInfo = {usingDefaultTheme: true}; + test.customizeMenu.mockNtpTheme = {usingDefaultTheme: true}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -796,10 +796,7 @@ * Test preselect color tile. */ test.customizeMenu.testColors_PreselectColor = function() { - test.customizeMenu.mockThemeBackgroundInfo = { - usingDefaultTheme: false, - colorId: 1 - }; + test.customizeMenu.mockNtpTheme = {usingDefaultTheme: false, colorId: 1}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -812,18 +809,14 @@ .getElementsByClassName('selected')[0] .firstChild; assertTrue( - parseInt(tile.dataset.id) === - test.customizeMenu.mockThemeBackgroundInfo.colorId); + parseInt(tile.dataset.id) === test.customizeMenu.mockNtpTheme.colorId); }; /** * Test no preselect when color id is invalid. */ test.customizeMenu.testColors_NoPreselectInvalidColorId = function() { - test.customizeMenu.mockThemeBackgroundInfo = { - usingDefaultTheme: false, - colorId: -1 - }; + test.customizeMenu.mockNtpTheme = {usingDefaultTheme: false, colorId: -1}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -838,7 +831,7 @@ * Test no preselect when color id not specified. */ test.customizeMenu.testColors_NoPreselectNoColorId = function() { - test.customizeMenu.mockThemeBackgroundInfo = {usingDefaultTheme: false}; + test.customizeMenu.mockNtpTheme = {usingDefaultTheme: false}; init(); $(test.customizeMenu.IDS.EDIT_BG).click(); $(test.customizeMenu.IDS.COLORS_BUTTON).click(); @@ -854,7 +847,7 @@ */ test.customizeMenu.testColors_PreselectColorPicker = function() { configData.chromeColorsCustomColorPicker = true; - test.customizeMenu.mockThemeBackgroundInfo = { + test.customizeMenu.mockNtpTheme = { usingDefaultTheme: false, colorId: 0, colorDark: [100, 100, 100], @@ -1110,12 +1103,10 @@ // We want to keep some EmbeddedSearchAPI functions, so save and add them to // our mock API. const getColorsInfo = chrome.embeddedSearch.newTabPage.getColorsInfo; - let themeBackgroundInfo = - chrome.embeddedSearch.newTabPage.themeBackgroundInfo; + let ntpTheme = chrome.embeddedSearch.newTabPage.ntpTheme; // Override theme background properties with testing values. - for (const property in test.customizeMenu.mockThemeBackgroundInfo) { - themeBackgroundInfo[property] = - test.customizeMenu.mockThemeBackgroundInfo[property]; + for (const property in test.customizeMenu.mockNtpTheme) { + ntpTheme[property] = test.customizeMenu.mockNtpTheme[property]; }; test.customizeMenu.stubs.replace(chrome.embeddedSearch, 'newTabPage', { @@ -1131,7 +1122,7 @@ selectLocalBackgroundImage: () => {}, setBackgroundURL: timesCustomBackgroundWasSet, setBackgroundInfo: timesCustomBackgroundWasSet, - themeBackgroundInfo: themeBackgroundInfo, + ntpTheme: ntpTheme, toggleMostVisitedOrCustomLinks: toggleMostVisitedOrCustomLinks, toggleShortcutsVisibility: toggleShortcutsVisibility, useDefaultTheme: useDefaultTheme,
diff --git a/chrome/test/data/pdf/basic_plugin_test.js b/chrome/test/data/pdf/basic_plugin_test.js index ac2e129e..34e7fa14 100644 --- a/chrome/test/data/pdf/basic_plugin_test.js +++ b/chrome/test/data/pdf/basic_plugin_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + /** * These tests require that the PDF plugin be available to run correctly. */
diff --git a/chrome/test/data/pdf/beep_test.js b/chrome/test/data/pdf/beep_test.js index f3d55648..6e0de30e 100644 --- a/chrome/test/data/pdf/beep_test.js +++ b/chrome/test/data/pdf/beep_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + const tests = [ /** * Test that the JS was able to call back via "app.beep()"
diff --git a/chrome/test/data/pdf/bookmarks_test.js b/chrome/test/data/pdf/bookmarks_test.js index faf5f46..3c139752 100644 --- a/chrome/test/data/pdf/bookmarks_test.js +++ b/chrome/test/data/pdf/bookmarks_test.js
@@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + import {createBookmarksForTest} from './test_util.js'; const tests = [
diff --git a/chrome/test/data/pdf/layout_test.js b/chrome/test/data/pdf/layout_test.js index ddbc0e7..8fd656fb 100644 --- a/chrome/test/data/pdf/layout_test.js +++ b/chrome/test/data/pdf/layout_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + // Tests common to all PDFs. const tests = [ function testLayoutOptions() {
diff --git a/chrome/test/data/pdf/navigator_test.js b/chrome/test/data/pdf/navigator_test.js index 8b9acdf..e700d34 100644 --- a/chrome/test/data/pdf/navigator_test.js +++ b/chrome/test/data/pdf/navigator_test.js
@@ -4,6 +4,7 @@ import {PdfNavigator} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/navigator.js'; import {OpenPdfParamsParser} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/open_pdf_params_parser.js'; +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; import {Viewport} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/viewport.js'; import {MockDocumentDimensions, MockSizer, MockViewportChangedCallback, MockWindow} from './test_util.js';
diff --git a/chrome/test/data/pdf/nobeep_test.js b/chrome/test/data/pdf/nobeep_test.js index 8c81aa3..012350f 100644 --- a/chrome/test/data/pdf/nobeep_test.js +++ b/chrome/test/data/pdf/nobeep_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + const tests = [ /** * Test that blocked JS was not able to call back via "app.beep()"
diff --git a/chrome/test/data/pdf/params_parser_test.js b/chrome/test/data/pdf/params_parser_test.js index 94751170..c7187733 100644 --- a/chrome/test/data/pdf/params_parser_test.js +++ b/chrome/test/data/pdf/params_parser_test.js
@@ -4,6 +4,8 @@ import {OpenPdfParamsParser} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/open_pdf_params_parser.js'; import {FittingType} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_fitting_type.js'; +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + const tests = [ /**
diff --git a/chrome/test/data/pdf/redirects_fail_test.js b/chrome/test/data/pdf/redirects_fail_test.js index 3db429f..c88afaf 100644 --- a/chrome/test/data/pdf/redirects_fail_test.js +++ b/chrome/test/data/pdf/redirects_fail_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + // Load a plugin with the given paramaters. function createPluginForUrl(streamUrl, url, headers, progressCallback) { const plugin = document.createElement('embed');
diff --git a/chrome/test/data/pdf/title_test.js b/chrome/test/data/pdf/title_test.js index 1e62ba5..1ecc07d4 100644 --- a/chrome/test/data/pdf/title_test.js +++ b/chrome/test/data/pdf/title_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + const tests = [ /** * Test that the correct title is displayed for test-title.pdf.
diff --git a/chrome/test/data/pdf/touch_handling_test.js b/chrome/test/data/pdf/touch_handling_test.js index e5a718b4..5a96291 100644 --- a/chrome/test/data/pdf/touch_handling_test.js +++ b/chrome/test/data/pdf/touch_handling_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + function sendTouchStart(touches) { let id = 0; const touchList = touches.map(function(xy) {
diff --git a/chrome/test/data/pdf/two_iframes.html b/chrome/test/data/pdf/two_iframes.html new file mode 100644 index 0000000..69dd1f1 --- /dev/null +++ b/chrome/test/data/pdf/two_iframes.html
@@ -0,0 +1,15 @@ +<html> + <head> + <script> + function onload() { + document.getElementById('iframe1').srcdoc = + '<body onload="document.getElementById(\'text_area\').focus();">' + + '<textarea id=text_area>Some text.</textarea></body>'; + } + </script> + </head> + <body onload='onload();'> + <iframe id=iframe1></iframe> + <iframe id=iframe2></iframe> + </body> +</html>
diff --git a/chrome/test/data/pdf/whitespace_title_test.js b/chrome/test/data/pdf/whitespace_title_test.js index 588c7371..fa32e92aa 100644 --- a/chrome/test/data/pdf/whitespace_title_test.js +++ b/chrome/test/data/pdf/whitespace_title_test.js
@@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_scripting_api.js'; + const tests = [ /** * Test that the correct title is displayed for test-whitespace-title.pdf.
diff --git a/chrome/test/data/webui/bookmarks/bookmarks_browsertest.js b/chrome/test/data/webui/bookmarks/bookmarks_browsertest.js index cb28144..2e00027 100644 --- a/chrome/test/data/webui/bookmarks/bookmarks_browsertest.js +++ b/chrome/test/data/webui/bookmarks/bookmarks_browsertest.js
@@ -6,70 +6,71 @@ * @fileoverview Test suite for the bookmarks page. */ GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']); -GEN('#include "chrome/browser/prefs/incognito_mode_prefs.h"'); GEN('#include "chrome/browser/ui/webui/bookmarks/bookmarks_browsertest.h"'); -function BookmarksBrowserTest() {} +const BookmarksBrowserTest = class extends PolymerTest { + /** @override */ + get browsePreload() { + return 'chrome://bookmarks'; + } -BookmarksBrowserTest.prototype = { - __proto__: PolymerTest.prototype, + /** @override */ + get typedefCppFixture() { + return 'BookmarksBrowserTest'; + } - browsePreload: 'chrome://bookmarks', - - typedefCppFixture: 'BookmarksBrowserTest', - - extraLibraries: [ - ...PolymerTest.prototype.extraLibraries, - '../test_store.js', - 'test_command_manager.js', - 'test_store.js', - 'test_timer_proxy.js', - 'test_util.js', - ], - - /** override */ - runAccessibilityChecks: true, + /** @override */ + get extraLibraries() { + return [ + ...super.extraLibraries, + '../test_store.js', + 'test_command_manager.js', + 'test_store.js', + 'test_timer_proxy.js', + 'test_util.js', + ]; + } }; -function BookmarksActionsTest() {} - -BookmarksActionsTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'actions_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksActionsTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'actions_test.js', + ]); + } }; TEST_F('BookmarksActionsTest', 'All', function() { mocha.run(); }); -function BookmarksAppTest() {} - -BookmarksAppTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - '../test_util.js', - 'app_test.js', - '//ui/webui/resources/js/util.js', - ]), +// eslint-disable-next-line no-var +var BookmarksAppTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + '../test_util.js', + 'app_test.js', + '//ui/webui/resources/js/util.js', + ]); + } }; TEST_F('BookmarksAppTest', 'All', function() { mocha.run(); }); -function BookmarksCommandManagerTest() {} - -BookmarksCommandManagerTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - '../test_util.js', - 'command_manager_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksCommandManagerTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + '../test_util.js', + 'command_manager_test.js', + ]); + } }; // https://crbug.com/1010381: Flaky. @@ -77,14 +78,14 @@ mocha.run(); }); -function BookmarksDNDManagerTest() {} - -BookmarksDNDManagerTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'dnd_manager_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksDNDManagerTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'dnd_manager_test.js', + ]); + } }; // http://crbug.com/803570 : Flaky on Win 7 (dbg) @@ -98,163 +99,162 @@ mocha.run(); }); -function BookmarksEditDialogTest() {} - -BookmarksEditDialogTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'edit_dialog_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksEditDialogTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'edit_dialog_test.js', + ]); + } }; TEST_F('BookmarksEditDialogTest', 'All', function() { mocha.run(); }); -function BookmarksItemTest() {} - -BookmarksItemTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'item_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksItemTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'item_test.js', + ]); + } }; TEST_F('BookmarksItemTest', 'All', function() { mocha.run(); }); -function BookmarksListTest() {} - -BookmarksListTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - '../test_util.js', - 'list_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksListTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + '../test_util.js', + 'list_test.js', + ]); + } }; TEST_F('BookmarksListTest', 'All', function() { mocha.run(); }); -function BookmarksReducersTest() {} - -BookmarksReducersTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'reducers_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksReducersTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'reducers_test.js', + ]); + } }; TEST_F('BookmarksReducersTest', 'All', function() { mocha.run(); }); -function BookmarksRouterTest() {} - -BookmarksRouterTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - '../test_util.js', - 'router_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksRouterTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + '../test_util.js', + 'router_test.js', + ]); + } }; TEST_F('BookmarksRouterTest', 'All', function() { mocha.run(); }); -function BookmarksFolderNodeTest() {} - -BookmarksFolderNodeTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'folder_node_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksFolderNodeTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'folder_node_test.js', + ]); + } }; TEST_F('BookmarksFolderNodeTest', 'All', function() { mocha.run(); }); -function BookmarksPolicyTest() {} - -BookmarksPolicyTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - testGenPreamble: function() { - GEN('SetIncognitoAvailability(IncognitoModePrefs::DISABLED);'); - GEN('SetCanEditBookmarks(false);'); - }, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'policy_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksPolicyTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + '../test_browser_proxy.js', + 'test_browser_proxy.js', + 'policy_test.js', + '//ui/webui/resources/js/cr.js', + ]); + } }; TEST_F('BookmarksPolicyTest', 'All', function() { mocha.run(); }); -function BookmarksStoreTest() {} - -BookmarksStoreTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'store_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksStoreTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'store_test.js', + ]); + } }; TEST_F('BookmarksStoreTest', 'All', function() { mocha.run(); }); -function BookmarksToolbarTest() {} - -BookmarksToolbarTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'toolbar_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksToolbarTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'toolbar_test.js', + ]); + } }; TEST_F('BookmarksToolbarTest', 'All', function() { mocha.run(); }); -function BookmarksUtilTest() {} - -BookmarksUtilTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'util_test.js', - ]), +// eslint-disable-next-line no-var +var BookmarksUtilTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'util_test.js', + ]); + } }; TEST_F('BookmarksUtilTest', 'All', function() { mocha.run(); }); -function BookmarksExtensionAPITest() {} +// eslint-disable-next-line no-var +var BookmarksExtensionAPITest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'extension_api_test.js', + ]); + } -BookmarksExtensionAPITest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'extension_api_test.js', - ]), - - testGenPreamble: () => { + /** @override */ + testGenPreamble() { GEN('SetupExtensionAPITest();'); } }; @@ -263,16 +263,17 @@ mocha.run(); }); -function BookmarksExtensionAPIEditDisabledTest() {} +// eslint-disable-next-line no-var +var BookmarksExtensionAPIEditDisabledTest = class extends BookmarksBrowserTest { + /** @override */ + get extraLibraries() { + return super.extraLibraries.concat([ + 'extension_api_test_edit_disabled.js', + ]); + } -BookmarksExtensionAPIEditDisabledTest.prototype = { - __proto__: BookmarksBrowserTest.prototype, - - extraLibraries: BookmarksBrowserTest.prototype.extraLibraries.concat([ - 'extension_api_test_edit_disabled.js', - ]), - - testGenPreamble: () => { + /** @override */ + testGenPreamble() { GEN('SetupExtensionAPIEditDisabledTest();'); } };
diff --git a/chrome/test/data/webui/bookmarks/policy_test.js b/chrome/test/data/webui/bookmarks/policy_test.js index 23c91c0..769e65c 100644 --- a/chrome/test/data/webui/bookmarks/policy_test.js +++ b/chrome/test/data/webui/bookmarks/policy_test.js
@@ -5,6 +5,8 @@ suite('Bookmarks policies', function() { let store; let app; + /** @type {?bookmarks.BrowserProxy} */ + let testBrowserProxy; setup(function() { const nodes = testTree(createFolder('1', [ @@ -20,6 +22,8 @@ store.expectAction('set-can-edit'); store.replaceSingleton(); + testBrowserProxy = new bookmarks.TestBookmarksBrowserProxy(); + bookmarks.BrowserProxy.instance_ = testBrowserProxy; app = document.createElement('bookmarks-app'); replaceBody(app); }); @@ -28,13 +32,18 @@ const commandManager = bookmarks.CommandManager.getInstance(); // Incognito is disabled during testGenPreamble(). Wait for the front-end to // load the config. - const action = await store.waitForAction('set-incognito-availability'); + const whenIncognitoSet = await Promise.all([ + testBrowserProxy.whenCalled('getIncognitoAvailability'), + store.waitForAction('set-incognito-availability') + ]); + assertEquals( IncognitoAvailability.DISABLED, store.data.prefs.incognitoAvailability); assertFalse( commandManager.canExecute(Command.OPEN_INCOGNITO, new Set(['11']))); - await cr.sendWithPromise('testSetIncognito', IncognitoAvailability.ENABLED); + cr.webUIListenerCallback( + 'incognito-availability-changed', IncognitoAvailability.ENABLED); assertEquals( IncognitoAvailability.ENABLED, store.data.prefs.incognitoAvailability); assertTrue( @@ -43,11 +52,14 @@ test('canEdit updates when changed', async function() { const commandManager = bookmarks.CommandManager.getInstance(); - const action = await store.waitForAction('set-can-edit'); + const whenCanEditSet = await Promise.all([ + testBrowserProxy.whenCalled('getCanEditBookmarks'), + store.waitForAction('set-can-edit') + ]); assertFalse(store.data.prefs.canEdit); assertFalse(commandManager.canExecute(Command.DELETE, new Set(['11']))); - await cr.sendWithPromise('testSetCanEdit', true); + cr.webUIListenerCallback('can-edit-bookmarks-changed', true); assertTrue(store.data.prefs.canEdit); assertTrue(commandManager.canExecute(Command.DELETE, new Set(['11']))); });
diff --git a/chrome/test/data/webui/bookmarks/test_browser_proxy.js b/chrome/test/data/webui/bookmarks/test_browser_proxy.js new file mode 100644 index 0000000..5366f01 --- /dev/null +++ b/chrome/test/data/webui/bookmarks/test_browser_proxy.js
@@ -0,0 +1,34 @@ +// 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. + +cr.define('bookmarks', function() { + /** + * Test version of the bookmarks browser proxy. + */ + class TestBookmarksBrowserProxy extends TestBrowserProxy { + constructor() { + super(['getIncognitoAvailability', 'getCanEditBookmarks']); + } + + getIncognitoAvailability() { + this.methodCalled('getIncognitoAvailability'); + return Promise.resolve(IncognitoAvailability.DISABLED); + } + + getCanEditBookmarks() { + this.methodCalled('getCanEditBookmarks'); + return Promise.resolve(false); + } + + getPluralString(messageName, itemCount) { + return Promise.resolve('test'); + } + + recordInHistogram(histogram, bucket, maxBucket) {} + } + + return { + TestBookmarksBrowserProxy: TestBookmarksBrowserProxy, + }; +});
diff --git a/chrome/test/data/webui/print_preview/advanced_dialog_test.js b/chrome/test/data/webui/print_preview/advanced_dialog_test.js index a8326f2..5b1d3cf 100644 --- a/chrome/test/data/webui/print_preview/advanced_dialog_test.js +++ b/chrome/test/data/webui/print_preview/advanced_dialog_test.js
@@ -2,9 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('advanced_dialog_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType} from 'chrome://print/print_preview.js'; +import {getCddTemplateWithAdvancedSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; + + window.advanced_dialog_test = {}; + advanced_dialog_test.suiteName = 'AdvancedDialogTest'; /** @enum {string} */ - const TestNames = { + advanced_dialog_test.TestNames = { AdvancedSettings1Option: 'advanced settings 1 option', AdvancedSettings2Options: 'advanced settings 2 options', AdvancedSettingsApply: 'advanced settings apply', @@ -13,12 +21,11 @@ AdvancedSettingsFilter: 'advanced settings filter', }; - const suiteName = 'AdvancedDialogTest'; - suite(suiteName, function() { + suite(advanced_dialog_test.suiteName, function() { /** @type {?PrintPreviewAdvancedSettingsDialogElement} */ let dialog = null; - /** @type {?print_preview.Destination} */ + /** @type {?Destination} */ let destination = null; /** @type {string} */ @@ -30,10 +37,10 @@ /** @override */ setup(function() { // Create destination - destination = new print_preview.Destination( - printerId, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, printerName, - print_preview.DestinationConnectionStatus.ONLINE); + destination = new Destination( + printerId, DestinationType.GOOGLE, + DestinationOrigin.COOKIES, printerName, + DestinationConnectionStatus.ONLINE); PolymerTest.clearBody(); const model = document.createElement('print-preview-model'); document.body.appendChild(model); @@ -43,7 +50,7 @@ // Set up settings. Only need the vendor items. dialog.settings = model.settings; - test_util.fakeDataBind(model, dialog, 'settings'); + fakeDataBind(model, dialog, 'settings'); }); /** @@ -52,13 +59,13 @@ */ function setupDialog(count) { const template = - print_preview_test_utils.getCddTemplateWithAdvancedSettings( + getCddTemplateWithAdvancedSettings( count, printerId, printerName); destination.capabilities = template.capabilities; dialog.destination = destination; document.body.appendChild(dialog); - Polymer.dom.flush(); + flush(); } /** @@ -95,28 +102,31 @@ // Tests that the search box does not appear when there is only one option, // and that the vendor item is correctly displayed. - test(assert(TestNames.AdvancedSettings1Option), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettings1Option), + function() { setupDialog(1); verifyListWithItemCount(1); }); // Tests that the search box appears when there are two options, and that // the items are correctly displayed. - test(assert(TestNames.AdvancedSettings2Options), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettings2Options), + function() { setupDialog(2); verifyListWithItemCount(2); }); // Tests that the advanced settings dialog correctly updates the settings // value for vendor items when the apply button is clicked. - test(assert(TestNames.AdvancedSettingsApply), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettingsApply), + function() { setupDialog(3); setItemValues(); assertFalse(dialog.getSetting('vendorItems').setFromUi); const buttons = dialog.shadowRoot.querySelectorAll('cr-button'); assertEquals(2, buttons.length); - const whenDialogClose = test_util.eventToPromise('close', dialog); + const whenDialogClose = eventToPromise('close', dialog); // Click apply button. buttons[1].click(); @@ -132,7 +142,8 @@ // Tests that the advanced settings dialog updates the settings value for // vendor items if Enter is pressed on a cr-input. - test(assert(TestNames.AdvancedSettingsApplyWithEnter), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettingsApplyWithEnter), + function() { setupDialog(3); setItemValues(); @@ -145,9 +156,8 @@ typedItemInput.dispatchEvent( new CustomEvent('input', {composed: true, bubbles: true})); - const whenDialogClose = test_util.eventToPromise('close', dialog); - MockInteractions.keyEventOn( - typedItemInput, 'keydown', 'Enter', [], 'Enter'); + const whenDialogClose = eventToPromise('close', dialog); + keyEventOn(typedItemInput, 'keydown', 'Enter', [], 'Enter'); return whenDialogClose.then(() => { // Check that the setting has been set. @@ -160,13 +170,14 @@ // Tests that the advanced settings dialog does not update the settings // value for vendor items when the close button is clicked. - test(assert(TestNames.AdvancedSettingsClose), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettingsClose), + function() { setupDialog(3); setItemValues(); const buttons = dialog.shadowRoot.querySelectorAll('cr-button'); assertEquals(2, buttons.length); - const whenDialogClose = test_util.eventToPromise('close', dialog); + const whenDialogClose = eventToPromise('close', dialog); // Click close button. buttons[0].click(); @@ -181,7 +192,8 @@ // Tests that the dialog correctly shows and hides settings based on the // value of the search query. - test(assert(TestNames.AdvancedSettingsFilter), function() { + test(assert(advanced_dialog_test.TestNames.AdvancedSettingsFilter), + function() { setupDialog(3); const searchBox = dialog.$.searchBox; const items = dialog.shadowRoot.querySelectorAll( @@ -210,9 +222,3 @@ assertFalse(noMatchHint.hidden); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/advanced_item_test.js b/chrome/test/data/webui/print_preview/advanced_item_test.js index fabf5e28..0e1a6c8 100644 --- a/chrome/test/data/webui/print_preview/advanced_item_test.js +++ b/chrome/test/data/webui/print_preview/advanced_item_test.js
@@ -2,9 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('advanced_item_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {getCddTemplateWithAdvancedSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.advanced_item_test = {}; + advanced_item_test.suiteName = 'AdvancedItemTest'; /** @enum {string} */ - const TestNames = { + advanced_item_test.TestNames = { DisplaySelect: 'display select', DisplayInput: 'display input', DisplayCheckbox: 'display checkbox', @@ -15,8 +22,7 @@ QueryOption: 'query option', }; - const suiteName = 'AdvancedItemTest'; - suite(suiteName, function() { + suite(advanced_item_test.suiteName, function() { /** @type {?PrintPreviewAdvancedSettingsItemElement} */ let item = null; @@ -29,19 +35,18 @@ item = document.createElement('print-preview-advanced-settings-item'); // Create capability. - item.capability = print_preview_test_utils - .getCddTemplateWithAdvancedSettings(2, 'FooDevice') + item.capability = getCddTemplateWithAdvancedSettings(2, 'FooDevice') .capabilities.printer.vendor_capability[1]; item.settings = model.settings; - test_util.fakeDataBind(model, item, 'settings'); + fakeDataBind(model, item, 'settings'); model.set('settings.vendorItems.available', true); document.body.appendChild(item); - Polymer.dom.flush(); + flush(); }); // Test that a select capability is displayed correctly. - test(assert(TestNames.DisplaySelect), function() { + test(assert(advanced_item_test.TestNames.DisplaySelect), function() { const label = item.$$('.label'); assertEquals('Paper Type', label.textContent); @@ -57,12 +62,11 @@ assertTrue(item.$$('cr-checkbox').parentElement.hidden); }); - test(assert(TestNames.DisplayInput), function() { + test(assert(advanced_item_test.TestNames.DisplayInput), function() { // Create capability - item.capability = print_preview_test_utils - .getCddTemplateWithAdvancedSettings(3, 'FooDevice') + item.capability = getCddTemplateWithAdvancedSettings(3, 'FooDevice') .capabilities.printer.vendor_capability[2]; - Polymer.dom.flush(); + flush(); const label = item.$$('.label'); assertEquals('Watermark', label.textContent); @@ -77,12 +81,11 @@ assertTrue(item.$$('cr-checkbox').parentElement.hidden); }); - test(assert(TestNames.DisplayCheckbox), function() { + test(assert(advanced_item_test.TestNames.DisplayCheckbox), function() { // Create capability - item.capability = print_preview_test_utils - .getCddTemplateWithAdvancedSettings(4, 'FooDevice') + item.capability = getCddTemplateWithAdvancedSettings(4, 'FooDevice') .capabilities.printer.vendor_capability[3]; - Polymer.dom.flush(); + flush(); const label = item.$$('.label'); assertEquals('Staple', label.textContent); @@ -99,7 +102,7 @@ // Test that a select capability updates correctly when the setting is // updated (e.g. when sticky settings are set). - test(assert(TestNames.UpdateSelect), function() { + test(assert(advanced_item_test.TestNames.UpdateSelect), function() { // Check that the default option is selected. const select = item.$$('select'); assertEquals(0, select.selectedIndex); @@ -111,12 +114,11 @@ // Test that an input capability updates correctly when the setting is // updated (e.g. when sticky settings are set). - test(assert(TestNames.UpdateInput), function() { + test(assert(advanced_item_test.TestNames.UpdateInput), function() { // Create capability - item.capability = print_preview_test_utils - .getCddTemplateWithAdvancedSettings(3, 'FooDevice') + item.capability = getCddTemplateWithAdvancedSettings(3, 'FooDevice') .capabilities.printer.vendor_capability[2]; - Polymer.dom.flush(); + flush(); // Check that the default value is set. const input = item.$$('cr-input'); @@ -129,12 +131,11 @@ // Test that an checkbox capability updates correctly when the setting is // updated (e.g. when sticky settings are set). - test(assert(TestNames.UpdateCheckbox), function() { + test(assert(advanced_item_test.TestNames.UpdateCheckbox), function() { // Create capability - item.capability = print_preview_test_utils - .getCddTemplateWithAdvancedSettings(4, 'FooDevice') + item.capability = getCddTemplateWithAdvancedSettings(4, 'FooDevice') .capabilities.printer.vendor_capability[3]; - Polymer.dom.flush(); + flush(); // Check that checkbox is unset. const checkbox = item.$$('cr-checkbox'); @@ -147,7 +148,7 @@ // Test that the setting is displayed correctly when the search query // matches its display name. - test(assert(TestNames.QueryName), function() { + test(assert(advanced_item_test.TestNames.QueryName), function() { const query = /(Type)/i; assertTrue(item.hasMatch(query)); item.updateHighlighting(query); @@ -170,7 +171,7 @@ // Test that the setting is displayed correctly when the search query // matches one of the select options. - test(assert(TestNames.QueryOption), function() { + test(assert(advanced_item_test.TestNames.QueryOption), function() { const query = /(cycle)/i; assertTrue(item.hasMatch(query)); item.updateHighlighting(query); @@ -189,9 +190,3 @@ assertEquals('cycle', searchBubbleHits[0].textContent); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/button_strip_interactive_test.js b/chrome/test/data/webui/print_preview/button_strip_interactive_test.js index f2ea256..ae2d989 100644 --- a/chrome/test/data/webui/print_preview/button_strip_interactive_test.js +++ b/chrome/test/data/webui/print_preview/button_strip_interactive_test.js
@@ -2,15 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('button_strip_interactive_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, State} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; + + window.button_strip_interactive_test = {}; + button_strip_interactive_test.suiteName = 'ButtonStripInteractiveTest'; /** @enum {string} */ - const TestNames = { + button_strip_interactive_test.TestNames = { FocusPrintOnReady: 'focus print on ready', }; - const suiteName = 'ButtonStripInteractiveTest'; - - suite(suiteName, function() { + suite(button_strip_interactive_test.suiteName, function() { /** @type {?PrintPreviewButtonStripElement} */ let buttonStrip = null; @@ -19,30 +22,25 @@ PolymerTest.clearBody(); buttonStrip = document.createElement('print-preview-button-strip'); - buttonStrip.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); - buttonStrip.state = print_preview.State.NOT_READY; + buttonStrip.destination = new Destination( + 'FooDevice', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooName', + DestinationConnectionStatus.ONLINE); + buttonStrip.state = State.NOT_READY; buttonStrip.firstLoad = true; document.body.appendChild(buttonStrip); }); // Tests that the print button is automatically focused when the destination // is ready. - test(assert(TestNames.FocusPrintOnReady), function() { + test(assert(button_strip_interactive_test.TestNames.FocusPrintOnReady), + function() { const printButton = buttonStrip.$$('.action-button'); assertTrue(!!printButton); - const whenFocusDone = test_util.eventToPromise('focus', printButton); + const whenFocusDone = eventToPromise('focus', printButton); // Simulate initialization finishing. - buttonStrip.state = print_preview.State.READY; + buttonStrip.state = State.READY; return whenFocusDone; }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/button_strip_test.js b/chrome/test/data/webui/print_preview/button_strip_test.js index 889d243..9a565e1 100644 --- a/chrome/test/data/webui/print_preview/button_strip_test.js +++ b/chrome/test/data/webui/print_preview/button_strip_test.js
@@ -2,16 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('button_strip_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isWindows} from 'chrome://resources/js/cr.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, State} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; + + window.button_strip_test = {}; + button_strip_test.suiteName = 'ButtonStripTest'; /** @enum {string} */ - const TestNames = { + button_strip_test.TestNames = { ButtonStripChangesForState: 'button strip changes for state', ButtonOrder: 'button order', ButtonStripFiresEvents: 'button strip fires events', }; - const suiteName = 'ButtonStripTest'; - suite(suiteName, function() { + suite(button_strip_test.suiteName, function() { /** @type {?PrintPreviewButtonStripElement} */ let buttonStrip = null; @@ -20,36 +25,37 @@ PolymerTest.clearBody(); buttonStrip = document.createElement('print-preview-button-strip'); - buttonStrip.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); - buttonStrip.state = print_preview.State.READY; + buttonStrip.destination = new Destination( + 'FooDevice', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooName', + DestinationConnectionStatus.ONLINE); + buttonStrip.state = State.READY; document.body.appendChild(buttonStrip); }); // Tests that the correct message is shown for non-READY states, and that // the print button is disabled appropriately. - test(assert(TestNames.ButtonStripChangesForState), function() { + test(assert(button_strip_test.TestNames.ButtonStripChangesForState), + function() { const printButton = buttonStrip.$$('.action-button'); assertFalse(printButton.disabled); - buttonStrip.state = print_preview.State.NOT_READY; + buttonStrip.state = State.NOT_READY; assertTrue(printButton.disabled); - buttonStrip.state = print_preview.State.PRINTING; + buttonStrip.state = State.PRINTING; assertTrue(printButton.disabled); - buttonStrip.state = print_preview.State.ERROR; + buttonStrip.state = State.ERROR; assertTrue(printButton.disabled); - buttonStrip.state = print_preview.State.FATAL_ERROR; + buttonStrip.state = State.FATAL_ERROR; assertTrue(printButton.disabled); }); // Tests that the buttons are in the correct order for different platforms. // See https://crbug.com/880562. - test(assert(TestNames.ButtonOrder), function() { + test(assert(button_strip_test.TestNames.ButtonOrder), function() { // Verify that there are only 2 buttons. assertEquals( 2, buttonStrip.shadowRoot.querySelectorAll('cr-button').length); @@ -59,7 +65,7 @@ const printButton = buttonStrip.$$('cr-button.action-button'); const cancelButton = buttonStrip.$$('cr-button.cancel-button'); - if (cr.isWindows) { + if (isWindows) { // On Windows, the print button is on the left. assertEquals(firstButton, printButton); assertEquals(lastButton, cancelButton); @@ -71,24 +77,19 @@ // Tests that the button strip fires print-requested and cancel-requested // events. - test(assert(TestNames.ButtonStripFiresEvents), function() { + test(assert(button_strip_test.TestNames.ButtonStripFiresEvents), + function() { const printButton = buttonStrip.$$('cr-button.action-button'); const cancelButton = buttonStrip.$$('cr-button.cancel-button'); const whenPrintRequested = - test_util.eventToPromise('print-requested', buttonStrip); + eventToPromise('print-requested', buttonStrip); printButton.click(); return whenPrintRequested.then(() => { const whenCancelRequested = - test_util.eventToPromise('cancel-requested', buttonStrip); + eventToPromise('cancel-requested', buttonStrip); cancelButton.click(); return whenCancelRequested; }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/cloud_print_interface_stub.js b/chrome/test/data/webui/print_preview/cloud_print_interface_stub.js index 7b78e02a..56eda3f 100644 --- a/chrome/test/data/webui/print_preview/cloud_print_interface_stub.js +++ b/chrome/test/data/webui/print_preview/cloud_print_interface_stub.js
@@ -2,22 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { +import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; +import {NativeEventTarget as EventTarget} from 'chrome://resources/js/cr/event_target.m.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {CloudPrintInterfaceEventType, createDestinationKey, DestinationOrigin} from 'chrome://print/print_preview.js'; + /** * Test version of the cloud print interface. - * @implements {cloudprint.CloudPrintInterface} + * @implements {CloudPrintInterface} */ - class CloudPrintInterfaceStub extends TestBrowserProxy { + export class CloudPrintInterfaceStub extends TestBrowserProxy { constructor() { super(['printer', 'search', 'submit']); - /** @private {!cr.EventTarget} */ - this.eventTarget_ = new cr.EventTarget(); + /** @private {!EventTarget} */ + this.eventTarget_ = new EventTarget(); /** @private {boolean} */ this.searchInProgress_ = false; - /** @private {!Map<string, !print_preview.Destination>} */ + /** @private {!Map<string, !Destination>} */ this.cloudPrintersMap_ = new Map(); /** @private {boolean} */ @@ -43,7 +47,7 @@ } /** - * @param {!print_preview.Destination} printer The destination to return + * @param {!Destination} printer The destination to return * when the printer is requested. */ setPrinter(printer) { @@ -79,7 +83,7 @@ this.users_.includes(account) ? account : (this.users_[0] || ''); if (activeUser) { this.eventTarget_.dispatchEvent(new CustomEvent( - cloudprint.CloudPrintInterfaceEventType.UPDATE_USERS, + CloudPrintInterfaceEventType.UPDATE_USERS, {detail: {users: this.users_, activeUser: activeUser}})); this.initialized_ = true; } @@ -92,9 +96,9 @@ }); const searchDoneEvent = - new CustomEvent(cloudprint.CloudPrintInterfaceEventType.SEARCH_DONE, { + new CustomEvent(CloudPrintInterfaceEventType.SEARCH_DONE, { detail: { - origin: print_preview.DestinationOrigin.COOKIES, + origin: DestinationOrigin.COOKIES, printers: printers, isRecent: true, user: account, @@ -117,27 +121,27 @@ this.methodCalled( 'printer', {id: printerId, origin: origin, account: account}); const printer = this.cloudPrintersMap_.get( - print_preview.createDestinationKey(printerId, origin, account)); + createDestinationKey(printerId, origin, account)); if (!this.initialized_) { const activeUser = this.users_.includes(account) ? account : (this.users_[0] || ''); if (activeUser) { this.eventTarget_.dispatchEvent(new CustomEvent( - cloudprint.CloudPrintInterfaceEventType.UPDATE_USERS, + CloudPrintInterfaceEventType.UPDATE_USERS, {detail: {users: this.users_, activeUser: activeUser}})); this.initialized_ = true; } } if (printer) { printer.capabilities = - print_preview_test_utils.getCddTemplate(printerId); + getCddTemplate(printerId); this.eventTarget_.dispatchEvent(new CustomEvent( - cloudprint.CloudPrintInterfaceEventType.PRINTER_DONE, + CloudPrintInterfaceEventType.PRINTER_DONE, {detail: printer})); } else { this.eventTarget_.dispatchEvent(new CustomEvent( - cloudprint.CloudPrintInterfaceEventType.PRINTER_FAILED, { + CloudPrintInterfaceEventType.PRINTER_FAILED, { detail: { origin: origin, destinationId: printerId, @@ -157,8 +161,3 @@ }); } } - - return { - CloudPrintInterfaceStub: CloudPrintInterfaceStub, - }; -});
diff --git a/chrome/test/data/webui/print_preview/color_settings_test.js b/chrome/test/data/webui/print_preview/color_settings_test.js index 956b2f4..194b1def 100644 --- a/chrome/test/data/webui/print_preview/color_settings_test.js +++ b/chrome/test/data/webui/print_preview/color_settings_test.js
@@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('color_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; + suite('ColorSettingsTest', function() { /** @type {?PrintPreviewColorSettingsElement} */ let colorSection = null; @@ -19,7 +24,7 @@ colorSection = document.createElement('print-preview-color-settings'); colorSection.settings = model.settings; colorSection.disabled = false; - test_util.fakeDataBind(model, colorSection, 'settings'); + fakeDataBind(model, colorSection, 'settings'); model.set('settings.color.available', true); document.body.appendChild(colorSection); }); @@ -30,7 +35,7 @@ assertEquals('color', select.value); colorSection.setSetting('color', false); - await test_util.eventToPromise('process-select-change', colorSection); + await eventToPromise('process-select-change', colorSection); assertEquals('bw', select.value); }); @@ -44,12 +49,12 @@ assertEquals(2, select.options.length); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption(colorSection, 'bw'); + await selectOption(colorSection, 'bw'); assertFalse(colorSection.getSettingValue('color')); assertTrue(colorSection.getSetting('color').setFromUi); }); - if (cr.isChromeOS) { + if (isChromeOS) { // Tests that if the setting is enforced by enterprise policy it is // disabled. test('disabled by policy', function() { @@ -62,4 +67,3 @@ }); } }); -});
diff --git a/chrome/test/data/webui/print_preview/copies_settings_test.js b/chrome/test/data/webui/print_preview/copies_settings_test.js index 25174b0..145eddb 100644 --- a/chrome/test/data/webui/print_preview/copies_settings_test.js +++ b/chrome/test/data/webui/print_preview/copies_settings_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('copies_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {triggerInputEvent} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('CopiesSettingsTest', function() { /** @type {?PrintPreviewCopiesSettingsElement} */ let copiesSection = null; @@ -16,7 +20,7 @@ copiesSection = document.createElement('print-preview-copies-settings'); copiesSection.settings = model.settings; copiesSection.disabled = false; - test_util.fakeDataBind(model, copiesSection, 'settings'); + fakeDataBind(model, copiesSection, 'settings'); document.body.appendChild(copiesSection); }); @@ -30,17 +34,17 @@ // Set copies empty. const copiesInput = copiesSection.$$('print-preview-number-settings-section').getInput(); - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '', copiesSection); assertTrue(collateSection.hidden); // Set copies valid again. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '3', copiesSection); assertFalse(collateSection.hidden); // Set copies invalid. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '0', copiesSection); assertTrue(collateSection.hidden); }); @@ -53,20 +57,20 @@ assertEquals('1', copiesInput.value); assertFalse(copiesSection.getSetting('copies').setFromUi); - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '2', copiesSection); assertEquals(2, copiesSection.getSettingValue('copies')); assertTrue(copiesSection.getSetting('copies').valid); assertTrue(copiesSection.getSetting('copies').setFromUi); // Empty entry. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '', copiesSection); assertEquals(2, copiesSection.getSettingValue('copies')); assertTrue(copiesSection.getSetting('copies').valid); // Invalid entry. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( copiesInput, '0', copiesSection); assertEquals(1, copiesSection.getSettingValue('copies')); assertFalse(copiesSection.getSetting('copies').valid); @@ -80,7 +84,7 @@ assertTrue(collateCheckbox.checked); assertFalse(copiesSection.getSetting('collate').setFromUi); - MockInteractions.tap(collateCheckbox); + collateCheckbox.click(); assertFalse(collateCheckbox.checked); collateCheckbox.dispatchEvent(new CustomEvent('change')); assertFalse(copiesSection.getSettingValue('collate')); @@ -102,4 +106,3 @@ assertFalse(collateCheckbox.checked); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/custom_margins_test.js b/chrome/test/data/webui/print_preview/custom_margins_test.js index e574996..16bf22f 100644 --- a/chrome/test/data/webui/print_preview/custom_margins_test.js +++ b/chrome/test/data/webui/print_preview/custom_margins_test.js
@@ -2,9 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('custom_margins_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {CustomMarginsOrientation, Margins, MarginsType, MeasurementSystem, MeasurementSystemUnitType, Size, State} from 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.custom_margins_test = {}; + custom_margins_test.suiteName = 'CustomMarginsTest'; /** @enum {string} */ - const TestNames = { + custom_margins_test.TestNames = { ControlsCheck: 'controls check', SetFromStickySettings: 'set from sticky settings', DragControls: 'drag controls', @@ -20,18 +26,17 @@ ControlsDisabledOnError: 'controls disabled on error', }; - const suiteName = 'CustomMarginsTest'; - suite(suiteName, function() { + suite(custom_margins_test.suiteName, function() { /** @type {?PrintPreviewMarginControlContainerElement} */ let container = null; /** @type {?PrintPreviewModelElement} */ let model = null; - /** @type {!Array<!print_preview.CustomMarginsOrientation>} */ + /** @type {!Array<!CustomMarginsOrientation>} */ let sides = []; - /** @type {!print_preview.MeasurementSystem} */ + /** @type {!MeasurementSystem} */ let measurementSystem = null; /** @type {number} */ @@ -49,28 +54,28 @@ /** @override */ setup(function() { PolymerTest.clearBody(); - measurementSystem = new print_preview.MeasurementSystem( - ',', '.', print_preview.MeasurementSystemUnitType.IMPERIAL); + measurementSystem = new MeasurementSystem( + ',', '.', MeasurementSystemUnitType.IMPERIAL); model = document.createElement('print-preview-model'); document.body.appendChild(model); model.set('settings.mediaSize.available', true); sides = [ - print_preview.CustomMarginsOrientation.TOP, - print_preview.CustomMarginsOrientation.RIGHT, - print_preview.CustomMarginsOrientation.BOTTOM, - print_preview.CustomMarginsOrientation.LEFT + CustomMarginsOrientation.TOP, + CustomMarginsOrientation.RIGHT, + CustomMarginsOrientation.BOTTOM, + CustomMarginsOrientation.LEFT ]; container = document.createElement('print-preview-margin-control-container'); container.previewLoaded = false; // 8.5 x 11, in points - container.pageSize = new print_preview.Size(612, 794); - container.documentMargins = new print_preview.Margins( + container.pageSize = new Size(612, 794); + container.documentMargins = new Margins( defaultMarginPts, defaultMarginPts, defaultMarginPts, defaultMarginPts); - container.state = print_preview.State.NOT_READY; + container.state = State.NOT_READY; }); /** @return {!Array<!PrintPreviewMarginControlElement>} */ @@ -89,19 +94,19 @@ // Wait for the control elements to be created before updating the state. container.measurementSystem = measurementSystem; document.body.appendChild(container); - const controlsAdded = test_util.eventToPromise('dom-change', container); + const controlsAdded = eventToPromise('dom-change', container); return controlsAdded.then(() => { // 8.5 x 11, in pixels const controls = getControls(); assertEquals(4, controls.length); container.settings = model.settings; - test_util.fakeDataBind(model, container, 'settings'); + fakeDataBind(model, container, 'settings'); - container.state = print_preview.State.READY; - container.updateClippingMask(new print_preview.Size(850, 1100)); + container.state = State.READY; + container.updateClippingMask(new Size(850, 1100)); container.updateScaleTransform(pixelsPerInch / pointsPerInch); container.previewLoaded = true; - Polymer.dom.flush(); + flush(); }); } @@ -112,7 +117,7 @@ */ function getAllTransitions(controls) { return Promise.all(Array.from(controls).map( - control => test_util.eventToPromise('transitionend', control))); + control => eventToPromise('transitionend', control))); } /** @@ -131,19 +136,19 @@ let xEnd = 0; let yEnd = 0; switch (control.side) { - case print_preview.CustomMarginsOrientation.TOP: + case CustomMarginsOrientation.TOP: yStart = start; yEnd = end; break; - case print_preview.CustomMarginsOrientation.RIGHT: + case CustomMarginsOrientation.RIGHT: xStart = control.clipSize.width - start; xEnd = control.clipSize.width - end; break; - case print_preview.CustomMarginsOrientation.BOTTOM: + case CustomMarginsOrientation.BOTTOM: yStart = control.clipSize.height - start; yEnd = control.clipSize.height - end; break; - case print_preview.CustomMarginsOrientation.LEFT: + case CustomMarginsOrientation.LEFT: xStart = start; xEnd = end; break; @@ -181,19 +186,19 @@ } assertEquals( currentValuePts, container.getSettingValue('customMargins')[key]); - controlTextbox = control.$.input; + const controlTextbox = control.$.input; controlTextbox.value = input; controlTextbox.dispatchEvent( new CustomEvent('input', {composed: true, bubbles: true})); if (!invalid) { - return test_util.eventToPromise('text-change', control).then(() => { + return eventToPromise('text-change', control).then(() => { assertEquals( newValuePts, container.getSettingValue('customMargins')[key]); assertFalse(control.invalid); }); } else { - return test_util.eventToPromise('input-change', control).then(() => { + return eventToPromise('input-change', control).then(() => { assertTrue(control.invalid); }); } @@ -202,11 +207,11 @@ /* * Initializes the settings custom margins to some test values, and returns * a map with the values. - * @return {!Map<!print_preview.CustomMarginsOrientation, + * @return {!Map<!CustomMarginsOrientation, * number>} */ function setupCustomMargins() { - const orientationEnum = print_preview.CustomMarginsOrientation; + const orientationEnum = CustomMarginsOrientation; const marginValues = new Map([ [orientationEnum.TOP, 72], [orientationEnum.RIGHT, 36], [orientationEnum.BOTTOM, 108], [orientationEnum.LEFT, 18] @@ -231,7 +236,7 @@ const marginValues = setupCustomMargins(); return finishSetup().then(() => { // Simulate setting custom margins. - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); // Validate control positions are set based on the custom values. const controls = getControls(); @@ -248,7 +253,7 @@ // Margins should be reset to default and custom margins values should // be cleared. expectEquals( - print_preview.MarginsType.DEFAULT, + MarginsType.DEFAULT, container.getSettingValue('margins')); expectEquals( '{}', JSON.stringify(container.getSettingValue('customMargins'))); @@ -264,7 +269,7 @@ // Test that controls correctly appear when custom margins are selected and // disappear when the preview is loading. - test(assert(TestNames.ControlsCheck), function() { + test(assert(custom_margins_test.TestNames.ControlsCheck), function() { return finishSetup() .then(() => { const controls = getControls(); @@ -278,7 +283,7 @@ const onTransitionEnd = getAllTransitions(controls); // Controls become visible when margin type CUSTOM is selected. model.set( - 'settings.margins.value', print_preview.MarginsType.CUSTOM); + 'settings.margins.value', MarginsType.CUSTOM); // Wait for the opacity transitions to finish. return onTransitionEnd; @@ -329,15 +334,15 @@ // Tests that the margin controls can be correctly set from the sticky // settings. - test(assert(TestNames.SetFromStickySettings), function() { + test(assert(custom_margins_test.TestNames.SetFromStickySettings), function() { return finishSetup().then(() => { const controls = getControls(); // Simulate setting custom margins from sticky settings. - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); const marginValues = setupCustomMargins(); model.notifyPath('settings.customMargins.value'); - Polymer.dom.flush(); + flush(); // Validate control positions have been updated. controls.forEach((control, index) => { @@ -349,7 +354,7 @@ }); // Test that dragging margin controls updates the custom margins setting. - test(assert(TestNames.DragControls), function() { + test(assert(custom_margins_test.TestNames.DragControls), function() { /** * Tests that the control can be moved from its current position (assumed * to be the default margins) to newPositionInPts by dragging it. @@ -369,7 +374,7 @@ newPositionInPts * pixelsPerInch / pointsPerInch; const whenDragChanged = - test_util.eventToPromise('margin-drag-changed', container); + eventToPromise('margin-drag-changed', container); dragControl(control, oldPositionInPixels, newPositionInPixels); return whenDragChanged.then(function() { const newValue = container.getSettingValue('customMargins'); @@ -379,8 +384,8 @@ return finishSetup().then(() => { const controls = getControls(); - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); - Polymer.dom.flush(); + model.set('settings.margins.value', MarginsType.CUSTOM); + flush(); // Wait for an animation frame. The position of the controls is set in @@ -429,7 +434,7 @@ // Test that setting the margin controls with their textbox inputs updates // the custom margins setting. - test(assert(TestNames.SetControlsWithTextbox), function() { + test(assert(custom_margins_test.TestNames.SetControlsWithTextbox), function() { return finishSetup().then(() => { const controls = getControls(); // Set a shorter delay for testing so the test doesn't take too @@ -437,8 +442,8 @@ controls.forEach(c => { c.getInput().setAttribute('data-timeout-delay', 1); }); - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); - Polymer.dom.flush(); + model.set('settings.margins.value', MarginsType.CUSTOM); + flush(); // Verify entering a new value updates the settings. // Then verify entering an invalid value invalidates the control @@ -472,9 +477,10 @@ // the custom margins setting, using a metric measurement system with a ',' // as the decimal delimiter and '.' as the thousands delimiter. Regression // test for https://crbug.com/1005816. - test(assert(TestNames.SetControlsWithTextboxMetric), function() { - measurementSystem = new print_preview.MeasurementSystem( - '.', ',', print_preview.MeasurementSystemUnitType.METRIC); + test(assert(custom_margins_test.TestNames.SetControlsWithTextboxMetric), + function() { + measurementSystem = new MeasurementSystem( + '.', ',', MeasurementSystemUnitType.METRIC); return finishSetup().then(() => { const controls = getControls(); // Set a shorter delay for testing so the test doesn't take too @@ -482,8 +488,8 @@ controls.forEach(c => { c.getInput().setAttribute('data-timeout-delay', 1); }); - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); - Polymer.dom.flush(); + model.set('settings.margins.value', MarginsType.CUSTOM); + flush(); // Verify entering a new value updates the settings. // Then verify entering an invalid value invalidates the control @@ -527,12 +533,13 @@ // Test that if there is a custom margins sticky setting, it is restored // when margin setting changes. - test(assert(TestNames.RestoreStickyMarginsAfterDefault), function() { + test(assert(custom_margins_test.TestNames.RestoreStickyMarginsAfterDefault), + function() { const marginValues = setupCustomMargins(); return finishSetup().then(() => { // Simulate setting custom margins. const controls = getControls(); - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); // Validate control positions are set based on the custom values. controls.forEach((control, index) => { @@ -542,7 +549,7 @@ }); // Simulate setting minimum margins. - model.set('settings.margins.value', print_preview.MarginsType.MINIMUM); + model.set('settings.margins.value', MarginsType.MINIMUM); // Validate control positions still reflect the custom values. controls.forEach((control, index) => { @@ -554,13 +561,14 @@ }); // Test that if the media size changes, the custom margins are cleared. - test(assert(TestNames.MediaSizeClearsCustomMargins), function() { + test(assert(custom_margins_test.TestNames.MediaSizeClearsCustomMargins), + function() { return validateMarginsClearedForSetting( 'mediaSize', {height_microns: 200000, width_microns: 200000}) .then(() => { // Simulate setting custom margins again. model.set( - 'settings.margins.value', print_preview.MarginsType.CUSTOM); + 'settings.margins.value', MarginsType.CUSTOM); // Validate control positions are initialized based on the default // values. @@ -574,10 +582,11 @@ }); // Test that if the orientation changes, the custom margins are cleared. - test(assert(TestNames.LayoutClearsCustomMargins), function() { + test(assert(custom_margins_test.TestNames.LayoutClearsCustomMargins), + function() { return validateMarginsClearedForSetting('layout', true).then(() => { // Simulate setting custom margins again - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); // Validate control positions are initialized based on the default // values. @@ -593,7 +602,8 @@ // Test that if the margins are not available, the custom margins setting is // not updated based on the document margins - i.e. PDFs do not change the // custom margins state. - test(assert(TestNames.IgnoreDocumentMarginsFromPDF), function() { + test(assert(custom_margins_test.TestNames.IgnoreDocumentMarginsFromPDF), + function() { model.set('settings.margins.available', false); return finishSetup().then(() => { assertEquals( @@ -603,7 +613,8 @@ // Test that if margins are not available but the user changes the media // size, the custom margins are cleared. - test(assert(TestNames.MediaSizeClearsCustomMarginsPDF), function() { + test(assert(custom_margins_test.TestNames.MediaSizeClearsCustomMarginsPDF), + function() { model.set('settings.margins.available', false); return validateMarginsClearedForSetting( 'mediaSize', {height_microns: 200000, width_microns: 200000}); @@ -615,7 +626,9 @@ // Test that if the user focuses a textbox that is not visible, the // text-focus event is fired with the correct values to scroll by. - test(assert(TestNames.RequestScrollToOutOfBoundsTextbox), function() { + test(assert( + custom_margins_test.TestNames.RequestScrollToOutOfBoundsTextbox), + function() { return finishSetup() .then(() => { // Wait for the controls to be set up, which occurs in an @@ -627,15 +640,15 @@ // Controls become visible when margin type CUSTOM is selected. model.set( - 'settings.margins.value', print_preview.MarginsType.CUSTOM); + 'settings.margins.value', MarginsType.CUSTOM); container.notifyPath('settings.customMargins.value'); - Polymer.dom.flush(); + flush(); return onTransitionEnd; }) .then(() => { // Zoom in by 2x, so that some margin controls will not be visible. container.updateScaleTransform(pixelsPerInch * 2 / pointsPerInch); - Polymer.dom.flush(); + flush(); return whenAnimationFrameDone(); }) .then(() => { @@ -646,7 +659,7 @@ // the viewer is showing only the top left quarter of the page. const bottomControl = controls[2]; const whenEventFired = - test_util.eventToPromise('text-focus-position', container); + eventToPromise('text-focus-position', container); bottomControl.$.input.focus(); // Workaround for mac so that this does not need to be an // interactive test: manually fire the focus event from the control. @@ -669,27 +682,22 @@ // Tests that the margin controls can be correctly set from the sticky // settings. - test(assert(TestNames.ControlsDisabledOnError), function() { + test(assert(custom_margins_test.TestNames.ControlsDisabledOnError), + function() { return finishSetup().then(() => { // Simulate setting custom margins. - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); const controls = getControls(); controls.forEach(control => assertFalse(control.disabled)); - container.state = print_preview.State.ERROR; + container.state = State.ERROR; // Validate controls are disabled. controls.forEach(control => assertTrue(control.disabled)); - container.state = print_preview.State.READY; + container.state = State.READY; controls.forEach(control => assertFalse(control.disabled)); }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_dialog_interactive_test.js b/chrome/test/data/webui/print_preview/destination_dialog_interactive_test.js index cf94eb43..8d162a07 100644 --- a/chrome/test/data/webui/print_preview/destination_dialog_interactive_test.js +++ b/chrome/test/data/webui/print_preview/destination_dialog_interactive_test.js
@@ -2,26 +2,34 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_dialog_interactive_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, makeRecentDestination, NativeLayer, State} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {getDestinations, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {keyDownOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; + + window.destination_dialog_interactive_test = {}; + destination_dialog_interactive_test.suiteName = + 'DestinationDialogInteractiveTest'; /** @enum {string} */ - const TestNames = { + destination_dialog_interactive_test.TestNames = { FocusSearchBox: 'focus search box', FocusSearchBoxOnSignIn: 'focus search box on sign in', EscapeSearchBox: 'escape search box', }; - const suiteName = 'DestinationDialogInteractiveTest'; - - suite(suiteName, function() { + suite(destination_dialog_interactive_test.suiteName, function() { /** @type {?PrintPreviewDestinationDialogElement} */ let dialog = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; /** @override */ suiteSetup(function() { - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); }); /** @override */ @@ -29,15 +37,15 @@ PolymerTest.clearBody(); // Create destinations. - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); const localDestinations = []; - const destinations = print_preview_test_utils.getDestinations( + const destinations = getDestinations( nativeLayer, localDestinations); const recentDestinations = - [print_preview.makeRecentDestination(destinations[4])]; + [makeRecentDestination(destinations[4])]; nativeLayer.setLocalDestinations(localDestinations); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); + const cloudPrintInterface = new CloudPrintInterfaceStub(); const model = document.createElement('print-preview-model'); document.body.appendChild(model); @@ -46,9 +54,9 @@ const destinationSettings = document.createElement('print-preview-destination-settings'); destinationSettings.settings = model.settings; - destinationSettings.state = print_preview.State.READY; + destinationSettings.state = State.READY; destinationSettings.disabled = false; - test_util.fakeDataBind(model, destinationSettings, 'settings'); + fakeDataBind(model, destinationSettings, 'settings'); document.body.appendChild(destinationSettings); // Initialize @@ -65,10 +73,11 @@ // Tests that the search input text field is automatically focused when the // dialog is shown. - test(assert(TestNames.FocusSearchBox), function() { + test(assert(destination_dialog_interactive_test.TestNames.FocusSearchBox), + function() { const searchInput = dialog.$.searchBox.getSearchInput(); assertTrue(!!searchInput); - const whenFocusDone = test_util.eventToPromise('focus', searchInput); + const whenFocusDone = eventToPromise('focus', searchInput); dialog.destinationStore.startLoadAllDestinations(); dialog.show(); return whenFocusDone; @@ -77,12 +86,14 @@ // Tests that the search input text field is automatically focused when the // user signs in successfully after clicking the sign in link. See // https://crbug.com/924921 - test(assert(TestNames.FocusSearchBoxOnSignIn), function() { + test(assert( + destination_dialog_interactive_test.TestNames.FocusSearchBoxOnSignIn), + function() { const searchInput = dialog.$.searchBox.getSearchInput(); assertTrue(!!searchInput); const signInLink = dialog.$$('.sign-in'); assertTrue(!!signInLink); - const whenFocusDone = test_util.eventToPromise('focus', searchInput); + const whenFocusDone = eventToPromise('focus', searchInput); dialog.destinationStore.startLoadAllDestinations(); dialog.show(); return whenFocusDone @@ -98,7 +109,7 @@ assertEquals(signInLink, dialog.shadowRoot.activeElement); nativeLayer.setSignIn(['foo@chromium.org']); const whenSearchFocused = - test_util.eventToPromise('focus', searchInput); + eventToPromise('focus', searchInput); signInLink.click(); return whenSearchFocused; }) @@ -110,10 +121,11 @@ // Tests that pressing the escape key while the search box is focused // closes the dialog if and only if the query is empty. - test(assert(TestNames.EscapeSearchBox), function() { + test(assert(destination_dialog_interactive_test.TestNames.EscapeSearchBox), + function() { const searchInput = dialog.$.searchBox.getSearchInput(); assertTrue(!!searchInput); - const whenFocusDone = test_util.eventToPromise('focus', searchInput); + const whenFocusDone = eventToPromise('focus', searchInput); dialog.destinationStore.startLoadAllDestinations(); dialog.show(); return whenFocusDone @@ -122,7 +134,7 @@ // Put something in the search box. const whenSearchChanged = - test_util.eventToPromise('search-changed', dialog.$.searchBox); + eventToPromise('search-changed', dialog.$.searchBox); dialog.$.searchBox.setValue('query'); return whenSearchChanged; }) @@ -130,8 +142,8 @@ assertEquals('query', searchInput.value); // Simulate escape - const whenKeyDown = test_util.eventToPromise('keydown', dialog); - MockInteractions.keyDownOn(searchInput, 19, [], 'Escape'); + const whenKeyDown = eventToPromise('keydown', dialog); + keyDownOn(searchInput, 19, [], 'Escape'); return whenKeyDown; }) .then(() => { @@ -140,7 +152,7 @@ // Clear the search box. const whenSearchChanged = - test_util.eventToPromise('search-changed', dialog.$.searchBox); + eventToPromise('search-changed', dialog.$.searchBox); dialog.$.searchBox.setValue(''); return whenSearchChanged; }) @@ -148,8 +160,8 @@ assertEquals('', searchInput.value); // Simulate escape - const whenKeyDown = test_util.eventToPromise('keydown', dialog); - MockInteractions.keyDownOn(searchInput, 19, [], 'Escape'); + const whenKeyDown = eventToPromise('keydown', dialog); + keyDownOn(searchInput, 19, [], 'Escape'); return whenKeyDown; }) .then(() => { @@ -158,9 +170,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_dialog_test.js b/chrome/test/data/webui/print_preview/destination_dialog_test.js index 0339424..fbe100a 100644 --- a/chrome/test/data/webui/print_preview/destination_dialog_test.js +++ b/chrome/test/data/webui/print_preview/destination_dialog_test.js
@@ -2,54 +2,64 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_dialog_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationStore, InvitationStore, makeRecentDestination, NativeLayer, PluginProxy} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {createDestinationStore, getDestinations, getGoogleDriveDestination, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; + + window.destination_dialog_test = {}; + destination_dialog_test.suiteName = 'DestinationDialogTest'; /** @enum {string} */ - const TestNames = { + destination_dialog_test.TestNames = { PrinterList: 'PrinterList', ShowProvisionalDialog: 'ShowProvisionalDialog', UserAccounts: 'UserAccounts', }; - const suiteName = 'DestinationDialogTest'; - suite(suiteName, function() { + suite(destination_dialog_test.suiteName, function() { /** @type {?PrintPreviewDestinationDialogElement} */ let dialog = null; - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ let destinationStore = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {?print_preview.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let cloudPrintInterface = null; - /** @type {!Array<!print_preview.Destination>} */ + /** @type {!Array<!Destination>} */ let destinations = []; - /** @type {!Array<!print_preview.LocalDestinationInfo>} */ + /** @type {!Array<!LocalDestinationInfo>} */ const localDestinations = []; - /** @type {!Array<!print_preview.RecentDestination>} */ + /** @type {!Array<!RecentDestination>} */ let recentDestinations = []; /** @override */ suiteSetup(function() { - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); }); /** @override */ setup(function() { // Create data classes - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); - destinationStore = print_preview_test_utils.createDestinationStore(); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); + cloudPrintInterface = new CloudPrintInterfaceStub(); + destinationStore = createDestinationStore(); destinationStore.setCloudPrintInterface(cloudPrintInterface); - destinations = print_preview_test_utils.getDestinations( + destinations = getDestinations( nativeLayer, localDestinations); recentDestinations = - [print_preview.makeRecentDestination(destinations[4])]; + [makeRecentDestination(destinations[4])]; destinationStore.init( false /* isInAppKioskMode */, 'FooDevice' /* printerName */, '' /* serializedDefaultDestinationSelectionRulesStr */, @@ -61,7 +71,7 @@ dialog.activeUser = ''; dialog.users = []; dialog.destinationStore = destinationStore; - dialog.invitationStore = new print_preview.InvitationStore(); + dialog.invitationStore = new InvitationStore(); }); function finishSetup() { @@ -73,12 +83,12 @@ return nativeLayer.whenCalled('getPrinters'); }) .then(function() { - Polymer.dom.flush(); + flush(); }); } // Test that destinations are correctly displayed in the lists. - test(assert(TestNames.PrinterList), async () => { + test(assert(destination_dialog_test.TestNames.PrinterList), async () => { await finishSetup(); const list = dialog.$$('print-preview-destination-list'); @@ -90,7 +100,7 @@ assertEquals(6, printerItems.length); // Save as PDF shows up first. assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, getDisplayedName(printerItems[0])); assertEquals( 'rgb(32, 33, 36)', @@ -105,7 +115,8 @@ // Test that clicking a provisional destination shows the provisional // destinations dialog, and that the escape key closes only the provisional // dialog when it is open, not the destinations dialog. - test(assert(TestNames.ShowProvisionalDialog), async () => { + test(assert(destination_dialog_test.TestNames.ShowProvisionalDialog), + async () => { let provisionalDialog = null; const provisionalDestination = { extensionId: 'ABC123', @@ -119,7 +130,7 @@ // reload printers. nativeLayer.setExtensionDestinations([provisionalDestination]); await finishSetup(); - Polymer.dom.flush(); + flush(); provisionalDialog = dialog.$$('print-preview-provisional-destination-resolver'); assertFalse(provisionalDialog.$.dialog.open); @@ -136,15 +147,14 @@ // Click the provisional destination to select it. provisionalItem.click(); - Polymer.dom.flush(); + flush(); assertTrue(provisionalDialog.$.dialog.open); // Send escape key on provisionalDialog. Destinations dialog should // not close. - const whenClosed = test_util.eventToPromise('close', provisionalDialog); - MockInteractions.keyEventOn( - provisionalDialog, 'keydown', 19, [], 'Escape'); - Polymer.dom.flush(); + const whenClosed = eventToPromise('close', provisionalDialog); + keyEventOn(provisionalDialog, 'keydown', 19, [], 'Escape'); + flush(); await whenClosed; assertFalse(provisionalDialog.$.dialog.open); @@ -180,7 +190,7 @@ assertEquals(numPrinters, printerItems.length); const drivePrinter = Array.from(printerItems).find(item => { return item.destination.id === - print_preview.Destination.GooglePromotedId.DOCS; + Destination.GooglePromotedId.DOCS; }); assertEquals(!!drivePrinter, account !== ''); if (drivePrinter) { @@ -189,15 +199,15 @@ } // Test that signing in and switching accounts works as expected. - test(assert(TestNames.UserAccounts), async () => { + test(assert(destination_dialog_test.TestNames.UserAccounts), async () => { // Set up the cloud print interface with Google Drive printer for a couple // different accounts. const user1 = 'foo@chromium.org'; const user2 = 'bar@chromium.org'; cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(user1)); + getGoogleDriveDestination(user1)); cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(user2)); + getGoogleDriveDestination(user2)); let userSelect = null; await finishSetup(); @@ -232,7 +242,7 @@ destinationStore.reloadUserCookieBasedDestinations(user1); dialog.activeUser = user1; dialog.users = [user1]; - Polymer.dom.flush(); + flush(); // Promo is hidden and select shows the signed in user. assertSignedInState(user1, 1); @@ -254,7 +264,7 @@ assertEquals(3, nativeLayer.getCallCount('getPrinters')); assertEquals(2, cloudPrintInterface.getCallCount('search')); dialog.users = [user1, user2]; - Polymer.dom.flush(); + flush(); // Promo is hidden and select shows the signed in user. assertSignedInState(user1, 2); @@ -263,24 +273,24 @@ assertNumPrintersWithDriveAccount(7, user1); // Select the second account. - const whenEventFired = test_util.eventToPromise('account-change', dialog); + const whenEventFired = eventToPromise('account-change', dialog); userSelect.value = user2; userSelect.dispatchEvent(new CustomEvent('change')); await whenEventFired; - Polymer.dom.flush(); + flush(); // This will all be done by app.js and user_manager.js in response // to the account-change event. destinationStore.setActiveUser(user2); dialog.activeUser = user2; - const whenInserted = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED, + const whenInserted = eventToPromise( + DestinationStore.EventType.DESTINATIONS_INSERTED, destinationStore); destinationStore.reloadUserCookieBasedDestinations(user2); await whenInserted; - Polymer.dom.flush(); + flush(); assertSignedInState(user2, 2); @@ -291,9 +301,3 @@ assertEquals(3, cloudPrintInterface.getCallCount('search')); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_item_test.js b/chrome/test/data/webui/print_preview/destination_item_test.js index a51273b..605428a 100644 --- a/chrome/test/data/webui/print_preview/destination_item_test.js +++ b/chrome/test/data/webui/print_preview/destination_item_test.js
@@ -2,9 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_item_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType} from 'chrome://print/print_preview.js'; +import {createDestinationWithCertificateStatus} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.destination_item_test = {}; + destination_item_test.suiteName = 'DestinationItemTest'; /** @enum {string} */ - const TestNames = { + destination_item_test.TestNames = { Online: 'online', Offline: 'offline', BadCertificate: 'bad certificate', @@ -12,8 +17,7 @@ QueryDescription: 'query description', }; - const suiteName = 'DestinationItemTest'; - suite(suiteName, function() { + suite(destination_item_test.suiteName, function() { /** @type {?PrintPreviewDestinationListItemElement} */ let item = null; @@ -29,17 +33,17 @@ item = document.createElement('print-preview-destination-list-item'); // Create destination - item.destination = new print_preview.Destination( - printerId, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, printerName, - print_preview.DestinationConnectionStatus.ONLINE); + item.destination = new Destination( + printerId, DestinationType.GOOGLE, + DestinationOrigin.COOKIES, printerName, + DestinationConnectionStatus.ONLINE); item.searchQuery = null; document.body.appendChild(item); }); // Test that the destination is displayed correctly for the basic case of an // online destination with no search query. - test(assert(TestNames.Online), function() { + test(assert(destination_item_test.TestNames.Online), function() { const name = item.$$('.name'); assertEquals(printerName, name.textContent); assertEquals('1', window.getComputedStyle(name).opacity); @@ -51,7 +55,7 @@ // Test that the destination is opaque and the correct status shows up if // the destination is stale. - test(assert(TestNames.Offline), function() { + test(assert(destination_item_test.TestNames.Offline), function() { const now = new Date(); const twoMonthsAgo = new Date(now.getTime()); let month = twoMonthsAgo.getMonth() - 2; @@ -60,10 +64,10 @@ twoMonthsAgo.setFullYear(now.getFullYear() - 1); } twoMonthsAgo.setMonth(month); - item.destination = new print_preview.Destination( - printerId, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, printerName, - print_preview.DestinationConnectionStatus.OFFLINE, + item.destination = new Destination( + printerId, DestinationType.GOOGLE, + DestinationOrigin.COOKIES, printerName, + DestinationConnectionStatus.OFFLINE, {lastAccessTime: twoMonthsAgo.getTime()}); const name = item.$$('.name'); @@ -79,10 +83,10 @@ // Test that the destination is opaque and the correct status shows up if // the destination has a bad cloud print certificate. - test(assert(TestNames.BadCertificate), function() { + test(assert(destination_item_test.TestNames.BadCertificate), function() { loadTimeData.overrideValues({isEnterpriseManaged: false}); item.destination = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( printerId, printerName, true); const name = item.$$('.name'); @@ -98,7 +102,7 @@ // Test that the destination is displayed correctly when the search query // matches its display name. - test(assert(TestNames.QueryName), function() { + test(assert(destination_item_test.TestNames.QueryName), function() { item.searchQuery = /(Foo)/i; const name = item.$$('.name'); @@ -115,15 +119,15 @@ // Test that the destination is displayed correctly when the search query // matches its description. - test(assert(TestNames.QueryDescription), function() { + test(assert(destination_item_test.TestNames.QueryDescription), function() { const params = { description: 'ABCPrinterBrand Model 123', location: 'Building 789 Floor 6', }; - item.destination = new print_preview.Destination( - printerId, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, printerName, - print_preview.DestinationConnectionStatus.ONLINE, params); + item.destination = new Destination( + printerId, DestinationType.GOOGLE, + DestinationOrigin.COOKIES, printerName, + DestinationConnectionStatus.ONLINE, params); item.searchQuery = /(ABC)/i; // No highlighting on name. @@ -140,9 +144,3 @@ assertEquals('ABC', searchHits[0].textContent); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_list_test.js b/chrome/test/data/webui/print_preview/destination_list_test.js index ce61011c..c3915dc 100644 --- a/chrome/test/data/webui/print_preview/destination_list_test.js +++ b/chrome/test/data/webui/print_preview/destination_list_test.js
@@ -2,16 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_list_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; + + window.destination_list_test = {}; + destination_list_test.suiteName = 'DestinationListTest'; /** @enum {string} */ - const TestNames = { + destination_list_test.TestNames = { FilterDestinations: 'FilterDestinations', FireDestinationSelected: 'FireDestinationSelected', }; - const suiteName = 'DestinationListTest'; - - suite(suiteName, function() { + suite(destination_list_test.suiteName, function() { /** @type {?PrintPreviewDestinationListElement} */ let list = null; @@ -19,30 +24,30 @@ setup(function() { // Create destinations const destinations = [ - new print_preview.Destination( - 'id1', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'One', - print_preview.DestinationConnectionStatus.ONLINE, + new Destination( + 'id1', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'One', + DestinationConnectionStatus.ONLINE, {description: 'ABC'}), - new print_preview.Destination( - 'id2', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'Two', - print_preview.DestinationConnectionStatus.ONLINE, + new Destination( + 'id2', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'Two', + DestinationConnectionStatus.ONLINE, {description: 'XYZ'}), - new print_preview.Destination( - 'id3', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'Three', - print_preview.DestinationConnectionStatus.ONLINE, + new Destination( + 'id3', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'Three', + DestinationConnectionStatus.ONLINE, {description: 'ABC', tags: ['__cp__location=123']}), - new print_preview.Destination( - 'id4', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'Four', - print_preview.DestinationConnectionStatus.ONLINE, + new Destination( + 'id4', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'Four', + DestinationConnectionStatus.ONLINE, {description: 'XYZ', tags: ['__cp__location=123']}), - new print_preview.Destination( - 'id5', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'Five', - print_preview.DestinationConnectionStatus.ONLINE, + new Destination( + 'id5', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'Five', + DestinationConnectionStatus.ONLINE, {description: 'XYZ', tags: ['__cp__location=123']}) ]; @@ -55,12 +60,13 @@ list.searchQuery = null; list.destinations = destinations; list.loadingDestinations = false; - Polymer.dom.flush(); + flush(); }); // Tests that the list correctly shows and hides destinations based on the // value of the search query. - test(assert(TestNames.FilterDestinations), function() { + test(assert(destination_list_test.TestNames.FilterDestinations), + function() { const items = list.shadowRoot.querySelectorAll( 'print-preview-destination-list-item'); const noMatchHint = list.$$('.no-destinations-message'); @@ -72,7 +78,7 @@ // Searching for "e" should show "One", "Three", and "Five". list.searchQuery = /(e)/i; - Polymer.dom.flush(); + flush(); assertEquals(undefined, Array.from(items).find(item => { return !item.hidden && (item.destination.displayName == 'Two' || @@ -82,7 +88,7 @@ // Searching for "ABC" should show "One" and "Three". list.searchQuery = /(ABC)/i; - Polymer.dom.flush(); + flush(); assertEquals(undefined, Array.from(items).find(item => { return !item.hidden && item.destination.displayName != 'One' && item.destination.displayName != 'Three'; @@ -91,7 +97,7 @@ // Searching for "F" should show "Four" and "Five" list.searchQuery = /(F)/i; - Polymer.dom.flush(); + flush(); assertEquals(undefined, Array.from(items).find(item => { return !item.hidden && item.destination.displayName != 'Four' && item.destination.displayName != 'Five'; @@ -101,13 +107,13 @@ // Searching for UVW should show no destinations and display the "no // match" hint. list.searchQuery = /(UVW)/i; - Polymer.dom.flush(); + flush(); items.forEach(item => assertTrue(item.hidden)); assertFalse(noMatchHint.hidden); // Searching for 123 should show destinations "Three", "Four", and "Five". list.searchQuery = /(123)/i; - Polymer.dom.flush(); + flush(); assertEquals(undefined, Array.from(items).find(item => { return !item.hidden && (item.destination.displayName == 'One' || @@ -117,24 +123,25 @@ // Clearing the query restores the original state. list.searchQuery = /()/i; - Polymer.dom.flush(); + flush(); items.forEach(item => assertFalse(item.hidden)); assertTrue(noMatchHint.hidden); }); // Tests that the list correctly fires the destination selected event when // the destination is clicked or the enter key is pressed. - test(assert(TestNames.FireDestinationSelected), function() { + test(assert(destination_list_test.TestNames.FireDestinationSelected), + function() { const items = list.shadowRoot.querySelectorAll( 'print-preview-destination-list-item'); - let whenDestinationSelected = test_util.eventToPromise( + let whenDestinationSelected = eventToPromise( 'destination-selected', list); items[0].click(); return whenDestinationSelected.then(event => { assertEquals(items[0], event.detail); - whenDestinationSelected = test_util.eventToPromise( + whenDestinationSelected = eventToPromise( 'destination-selected', list); - MockInteractions.keyEventOn( + keyEventOn( items[1], 'keydown', 13, undefined, 'Enter'); return whenDestinationSelected; }).then(event => { @@ -142,9 +149,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_search_test.js b/chrome/test/data/webui/print_preview/destination_search_test.js index 5ee5ec78..5ad8073 100644 --- a/chrome/test/data/webui/print_preview/destination_search_test.js +++ b/chrome/test/data/webui/print_preview/destination_search_test.js
@@ -2,42 +2,44 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_search_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, DestinationStore, InvitationStore, NativeLayer} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {createDestinationStore, getCddTemplate, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.destination_search_test = {}; + destination_search_test.suiteName = 'DestinationSearchTest'; /** @enum {string} */ - const TestNames = { - ReceiveSuccessfulSetup: 'receive successful setup', - ResolutionFails: 'resolution fails', - ReceiveFailedSetup: 'receive failed setup', + destination_search_test.TestNames = { + GetCapabilitiesSucceeds: 'get capabilities succeeds', GetCapabilitiesFails: 'get capabilities fails', - CloudKioskPrinter: 'cloud kiosk printer', - ReceiveSuccessfulSetupWithPolicies: - 'receive successful setup with policies', }; - const suiteName = 'DestinationSearchTest'; - suite(suiteName, function() { + suite(destination_search_test.suiteName, function() { /** @type {?PrintPreviewDestinationDialogElement} */ let dialog = null; - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ let destinationStore = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; /** @override */ suiteSetup(function() { - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); }); /** @override */ setup(function() { // Create data classes - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); - destinationStore = print_preview_test_utils.createDestinationStore(); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); + destinationStore = createDestinationStore(); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate('FooDevice', 'FooName')); + getCddTemplate('FooDevice', 'FooName')); destinationStore.init( false /* isInAppKioskMode */, 'FooDevice' /* printerName */, '' /* serializedDefaultDestinationSelectionRulesStr */, @@ -48,18 +50,18 @@ dialog.users = []; dialog.activeUser = ''; dialog.destinationStore = destinationStore; - dialog.invitationStore = new print_preview.InvitationStore(); + dialog.invitationStore = new InvitationStore(); PolymerTest.clearBody(); document.body.appendChild(dialog); return nativeLayer.whenCalled('getPrinterCapabilities').then(function() { dialog.show(); - Polymer.dom.flush(); + flush(); nativeLayer.reset(); }); }); /** - * @param {!print_preview.Destination} destination The destination to + * @param {!Destination} destination The destination to * simulate selection of. */ function simulateDestinationSelect(destination) { @@ -79,45 +81,36 @@ * @param {string} destId The ID for the destination. */ function requestSetup(destId) { - const origin = cr.isChromeOS ? print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL; - - const dest = new print_preview.Destination( - destId, print_preview.DestinationType.LOCAL, origin, 'displayName', - print_preview.DestinationConnectionStatus.ONLINE); + const dest = new Destination( + destId, DestinationType.LOCAL, DestinationOrigin.LOCAL, 'displayName', + DestinationConnectionStatus.ONLINE); // Add the destination to the list. dialog.updateDestinations_([dest]); simulateDestinationSelect(dest); } - // Tests that a destination is selected if the user clicks on it and setup - // (for CrOS) or capabilities fetch (for non-Cros) succeeds. - test(assert(TestNames.ReceiveSuccessfulSetup), function() { + // Tests that a destination is selected if the user clicks on it and + // capabilities fetch succeeds. + test(assert(destination_search_test.TestNames.GetCapabilitiesSucceeds), + function() { const destId = '00112233DEADBEEF'; const response = { printerId: destId, capabilities: - print_preview_test_utils.getCddTemplate(destId).capabilities, + getCddTemplate(destId).capabilities, success: true, }; - if (cr.isChromeOS) { - nativeLayer.setSetupPrinterResponse(response); - } else { - nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(destId)); - } + nativeLayer.setLocalDestinationCapabilities(getCddTemplate(destId)); - const waiter = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + const waiter = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, destinationStore); requestSetup(destId); - const callback = - cr.isChromeOS ? 'setupPrinter' : 'getPrinterCapabilities'; - return Promise.all([nativeLayer.whenCalled(callback), waiter]) - .then(function(results) { - const actualId = - cr.isChromeOS ? results[0] : results[0].destinationId; + return Promise.all([ + nativeLayer.whenCalled('getPrinterCapabilities'), waiter + ]).then(function(results) { + const actualId = results[0].destinationId; assertEquals(destId, actualId); // After setup or capabilities fetch succeeds, the destination // should be selected. @@ -126,52 +119,13 @@ }); }); - // Test what happens when the setupPrinter request is rejected. ChromeOS - // only. - test(assert(TestNames.ResolutionFails), function() { - const destId = '001122DEADBEEF'; - const originalDestination = destinationStore.selectedDestination; - nativeLayer.setSetupPrinterResponse( - {printerId: destId, success: false}, true); - requestSetup(destId); - return nativeLayer.whenCalled('setupPrinter').then(function(actualId) { - assertEquals(destId, actualId); - // The selected printer should not have changed, since a printer - // cannot be selected until setup succeeds. - assertEquals(originalDestination, destinationStore.selectedDestination); - }); - }); - - // Test what happens when the setupPrinter request is resolved with a - // failed status. Chrome OS only. - test(assert(TestNames.ReceiveFailedSetup), function() { - const originalDestination = destinationStore.selectedDestination; - const destId = '00112233DEADBEEF'; - const response = { - printerId: destId, - capabilities: - print_preview_test_utils.getCddTemplate(destId).capabilities, - success: false, - }; - nativeLayer.setSetupPrinterResponse(response); - requestSetup(destId); - return nativeLayer.whenCalled('setupPrinter') - .then(function(actualDestId) { - assertEquals(destId, actualDestId); - // The selected printer should not have changed, since a printer - // cannot be selected until setup succeeds. - assertEquals( - originalDestination, destinationStore.selectedDestination); - }); - }); - // Tests what happens when capabilities cannot be retrieved for the chosen // destination. The destination will still be selected in this case. - // non-Chrome OS only. - test(assert(TestNames.GetCapabilitiesFails), function() { + test(assert(destination_search_test.TestNames.GetCapabilitiesFails), + function() { const destId = '001122DEADBEEF'; nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(destId), true); + getCddTemplate(destId), true); requestSetup(destId); return nativeLayer.whenCalled('getPrinterCapabilities') .then(function(args) { @@ -181,63 +135,4 @@ assertEquals(destId, destinationStore.selectedDestination.id); }); }); - - // Test what happens when a simulated cloud kiosk printer is selected. - test(assert(TestNames.CloudKioskPrinter), function() { - const printerId = 'cloud-printer-id'; - - // Create cloud destination. - const cloudDest = new print_preview.Destination( - printerId, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.DEVICE, 'displayName', - print_preview.DestinationConnectionStatus.ONLINE); - cloudDest.capabilities = - print_preview_test_utils.getCddTemplate(printerId, 'displayName') - .capabilities; - - // Place destination in the local list as happens for Kiosk printers. - dialog.updateDestinations_([cloudDest]); - simulateDestinationSelect(cloudDest); - - // Verify that the destination has been selected. - assertEquals(printerId, destinationStore.selectedDestination.id); - }); - - // Tests that if policies are set correctly if they are present - // for a destination. ChromeOS only. - test(assert(TestNames.ReceiveSuccessfulSetupWithPolicies), function() { - const destId = '00112233DEADBEEF'; - const response = { - printerId: destId, - capabilities: - print_preview_test_utils.getCddTemplate(destId).capabilities, - policies: { - allowedColorModes: print_preview.ColorModeRestriction.MONOCHROME, - allowedDuplexModes: print_preview.DuplexModeRestriction.DUPLEX, - }, - success: true, - }; - nativeLayer.setSetupPrinterResponse(response); - requestSetup(destId); - return nativeLayer.whenCalled('setupPrinter').then(function(actualId) { - assertEquals(destId, actualId); - const selectedDestination = destinationStore.selectedDestination; - assertNotEquals(null, selectedDestination); - assertEquals(destId, selectedDestination.id); - assertNotEquals(null, selectedDestination.capabilities); - assertNotEquals(null, selectedDestination.policies); - assertEquals( - print_preview.ColorModeRestriction.MONOCHROME, - selectedDestination.policies.allowedColorModes); - assertEquals( - print_preview.DuplexModeRestriction.DUPLEX, - selectedDestination.policies.allowedDuplexModes); - }); - }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_search_test_chromeos.js b/chrome/test/data/webui/print_preview/destination_search_test_chromeos.js new file mode 100644 index 0000000..212b919 --- /dev/null +++ b/chrome/test/data/webui/print_preview/destination_search_test_chromeos.js
@@ -0,0 +1,223 @@ +// Copyright 2018 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. + +import {assert} from 'chrome://resources/js/assert.m.js'; +import {ColorModeRestriction, Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, DestinationStore, DuplexModeRestriction, InvitationStore, NativeLayer} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {createDestinationStore, getCddTemplate, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.destination_search_test_chromeos = {}; + destination_search_test_chromeos.suiteName = 'DestinationSearchTest'; + /** @enum {string} */ + destination_search_test_chromeos.TestNames = { + ReceiveSuccessfulSetup: 'receive successful setup', + ResolutionFails: 'resolution fails', + ReceiveFailedSetup: 'receive failed setup', + CloudKioskPrinter: 'cloud kiosk printer', + ReceiveSuccessfulSetupWithPolicies: + 'receive successful setup with policies', + }; + + suite(destination_search_test_chromeos.suiteName, function() { + /** @type {?PrintPreviewDestinationDialogElement} */ + let dialog = null; + + /** @type {?DestinationStore} */ + let destinationStore = null; + + /** @type {?NativeLayer} */ + let nativeLayer = null; + + /** @override */ + suiteSetup(function() { + setupTestListenerElement(); + }); + + /** @override */ + setup(function() { + // Create data classes + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); + destinationStore = createDestinationStore(); + nativeLayer.setLocalDestinationCapabilities( + getCddTemplate('FooDevice', 'FooName')); + destinationStore.init( + false /* isInAppKioskMode */, 'FooDevice' /* printerName */, + '' /* serializedDefaultDestinationSelectionRulesStr */, + [] /* recentDestinations */); + + // Set up dialog + dialog = document.createElement('print-preview-destination-dialog'); + dialog.users = []; + dialog.activeUser = ''; + dialog.destinationStore = destinationStore; + dialog.invitationStore = new InvitationStore(); + PolymerTest.clearBody(); + document.body.appendChild(dialog); + return nativeLayer.whenCalled('getPrinterCapabilities').then(function() { + dialog.show(); + flush(); + nativeLayer.reset(); + }); + }); + + /** + * @param {!Destination} destination The destination to + * simulate selection of. + */ + function simulateDestinationSelect(destination) { + // Fake destinationListItem. + const item = + document.createElement('print-preview-destination-list-item'); + item.destination = destination; + + // Get print list and fire event. + const list = dialog.$$('print-preview-destination-list'); + list.fire('destination-selected', item); + } + + /** + * Adds a destination to the dialog and simulates selection of the + * destination. + * @param {string} destId The ID for the destination. + */ + function requestSetup(destId) { + const dest = new Destination( + destId, DestinationType.LOCAL, DestinationOrigin.CROS, 'displayName', + DestinationConnectionStatus.ONLINE); + + // Add the destination to the list. + dialog.updateDestinations_([dest]); + simulateDestinationSelect(dest); + } + + // Tests that a destination is selected if the user clicks on it and setup + // (for CrOS) or capabilities fetch (for non-Cros) succeeds. + test(assert( + destination_search_test_chromeos.TestNames.ReceiveSuccessfulSetup), + function() { + const destId = '00112233DEADBEEF'; + const response = { + printerId: destId, + capabilities: + getCddTemplate(destId).capabilities, + success: true, + }; + nativeLayer.setSetupPrinterResponse(response); + + const waiter = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, + destinationStore); + requestSetup(destId); + return Promise.all([nativeLayer.whenCalled('setupPrinter'), waiter]) + .then(function(results) { + const actualId = results[0]; + assertEquals(destId, actualId); + // After setup or capabilities fetch succeeds, the destination + // should be selected. + assertNotEquals(null, destinationStore.selectedDestination); + assertEquals(destId, destinationStore.selectedDestination.id); + }); + }); + + // Test what happens when the setupPrinter request is rejected. + test( + assert(destination_search_test_chromeos.TestNames.ResolutionFails), + function() { + const destId = '001122DEADBEEF'; + const originalDestination = destinationStore.selectedDestination; + nativeLayer.setSetupPrinterResponse( + {printerId: destId, success: false}, true); + requestSetup(destId); + return nativeLayer.whenCalled('setupPrinter').then(function(actualId) { + assertEquals(destId, actualId); + // The selected printer should not have changed, since a printer + // cannot be selected until setup succeeds. + assertEquals(originalDestination, destinationStore.selectedDestination); + }); + }); + + // Test what happens when the setupPrinter request is resolved with a + // failed status. Chrome OS only. + test(assert(destination_search_test_chromeos.TestNames.ReceiveFailedSetup), + function() { + const originalDestination = destinationStore.selectedDestination; + const destId = '00112233DEADBEEF'; + const response = { + printerId: destId, + capabilities: + getCddTemplate(destId).capabilities, + success: false, + }; + nativeLayer.setSetupPrinterResponse(response); + requestSetup(destId); + return nativeLayer.whenCalled('setupPrinter') + .then(function(actualDestId) { + assertEquals(destId, actualDestId); + // The selected printer should not have changed, since a printer + // cannot be selected until setup succeeds. + assertEquals( + originalDestination, destinationStore.selectedDestination); + }); + }); + + // Test what happens when a simulated cloud kiosk printer is selected. + test(assert(destination_search_test_chromeos.TestNames.CloudKioskPrinter), + function() { + const printerId = 'cloud-printer-id'; + + // Create cloud destination. + const cloudDest = new Destination( + printerId, DestinationType.GOOGLE, + DestinationOrigin.DEVICE, 'displayName', + DestinationConnectionStatus.ONLINE); + cloudDest.capabilities = + getCddTemplate(printerId, 'displayName') + .capabilities; + + // Place destination in the local list as happens for Kiosk printers. + dialog.updateDestinations_([cloudDest]); + simulateDestinationSelect(cloudDest); + + // Verify that the destination has been selected. + assertEquals(printerId, destinationStore.selectedDestination.id); + }); + + // Tests that if policies are set correctly if they are present + // for a destination. + test(assert( + destination_search_test_chromeos.TestNames + .ReceiveSuccessfulSetupWithPolicies), + function() { + const destId = '00112233DEADBEEF'; + const response = { + printerId: destId, + capabilities: + getCddTemplate(destId).capabilities, + policies: { + allowedColorModes: ColorModeRestriction.MONOCHROME, + allowedDuplexModes: DuplexModeRestriction.DUPLEX, + }, + success: true, + }; + nativeLayer.setSetupPrinterResponse(response); + requestSetup(destId); + return nativeLayer.whenCalled('setupPrinter').then(function(actualId) { + assertEquals(destId, actualId); + const selectedDestination = destinationStore.selectedDestination; + assertNotEquals(null, selectedDestination); + assertEquals(destId, selectedDestination.id); + assertNotEquals(null, selectedDestination.capabilities); + assertNotEquals(null, selectedDestination.policies); + assertEquals( + ColorModeRestriction.MONOCHROME, + selectedDestination.policies.allowedColorModes); + assertEquals( + DuplexModeRestriction.DUPLEX, + selectedDestination.policies.allowedDuplexModes); + }); + }); + });
diff --git a/chrome/test/data/webui/print_preview/destination_select_test.js b/chrome/test/data/webui/print_preview/destination_select_test.js index e734773f..a0cea46 100644 --- a/chrome/test/data/webui/print_preview/destination_select_test.js +++ b/chrome/test/data/webui/print_preview/destination_select_test.js
@@ -2,14 +2,18 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_select_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, getSelectDropdownBackground} from 'chrome://print/print_preview.js'; +import {getGoogleDriveDestination, selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.destination_select_test = {}; + destination_select_test.suiteName = 'DestinationSelectTest'; /** @enum {string} */ - const TestNames = { + destination_select_test.TestNames = { ChangeIcon: 'change icon', }; - const suiteName = 'DestinationSelectTest'; - suite(suiteName, function() { + suite(destination_select_test.suiteName, function() { /** @type {?PrintPreviewDestinationSelectElement} */ let destinationSelect = null; @@ -29,7 +33,7 @@ // Local printer without stickied icon { id: 'ID1', - origin: print_preview.DestinationOrigin.LOCAL, + origin: DestinationOrigin.LOCAL, account: '', capabilities: null, displayName: 'One', @@ -39,7 +43,7 @@ // Shared cloud printer with stickied icon { id: 'ID2', - origin: print_preview.DestinationOrigin.COOKIES, + origin: DestinationOrigin.COOKIES, account: account, capabilities: null, displayName: 'Two', @@ -50,7 +54,7 @@ // Shared cloud printer without stickied icon { id: 'ID3', - origin: print_preview.DestinationOrigin.COOKIES, + origin: DestinationOrigin.COOKIES, account: account, capabilities: null, displayName: 'Three', @@ -70,20 +74,19 @@ assertEquals(expected, icon); } - test(assert(TestNames.ChangeIcon), function() { - const destination = new print_preview.Destination( - 'ID1', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'One', - print_preview.DestinationConnectionStatus.ONLINE); + test(assert(destination_select_test.TestNames.ChangeIcon), function() { + const destination = new Destination( + 'ID1', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'One', + DestinationConnectionStatus.ONLINE); destinationSelect.destination = destination; destinationSelect.updateDestination(); const selectEl = destinationSelect.$$('.md-select'); compareIcon(selectEl, 'print'); - const driveId = print_preview.Destination.GooglePromotedId.DOCS; - const cookieOrigin = print_preview.DestinationOrigin.COOKIES; + const driveId = Destination.GooglePromotedId.DOCS; + const cookieOrigin = DestinationOrigin.COOKIES; - return print_preview_test_utils - .selectOption( + return selectOption( destinationSelect, `${driveId}/${cookieOrigin}/${account}`) .then(() => { // Icon updates early based on the ID. @@ -91,13 +94,13 @@ // Update the destination. destinationSelect.destination = - print_preview_test_utils.getGoogleDriveDestination(account); + getGoogleDriveDestination(account); // Still Save to Drive icon. compareIcon(selectEl, 'save-to-drive'); // Select a destination that has a sticky icon value. - return print_preview_test_utils.selectOption( + return selectOption( destinationSelect, `ID2/${cookieOrigin}/${account}`); }) .then(() => { @@ -105,15 +108,15 @@ compareIcon(selectEl, 'printer-shared'); // Update destination. - destinationSelect.destination = new print_preview.Destination( - 'ID2', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'Two', - print_preview.DestinationConnectionStatus.ONLINE, + destinationSelect.destination = new Destination( + 'ID2', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'Two', + DestinationConnectionStatus.ONLINE, {account: account}); compareIcon(selectEl, 'printer-shared'); // Select a destination that doesn't have a sticky icon value. - return print_preview_test_utils.selectOption( + return selectOption( destinationSelect, `ID3/${cookieOrigin}/${account}`); }) .then(() => { @@ -121,10 +124,10 @@ compareIcon(selectEl, 'print'); // Update destination. - destinationSelect.destination = new print_preview.Destination( - 'ID3', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'Three', - print_preview.DestinationConnectionStatus.ONLINE, + destinationSelect.destination = new Destination( + 'ID3', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'Three', + DestinationConnectionStatus.ONLINE, {account: account}); // Icon updates based on full destination information. @@ -132,9 +135,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_settings_test.js b/chrome/test/data/webui/print_preview/destination_settings_test.js index c41ba115..0fcc94b1 100644 --- a/chrome/test/data/webui/print_preview/destination_settings_test.js +++ b/chrome/test/data/webui/print_preview/destination_settings_test.js
@@ -2,9 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationErrorType, DestinationOrigin, DestinationState, DestinationStore, DestinationType, Error, makeRecentDestination, NativeLayer, State} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {eventToPromise, fakeDataBind, waitBeforeNextRender} from 'chrome://test/test_util.m.js'; +import {setupTestListenerElement, getDestinations, getGoogleDriveDestination, getSaveAsPdfDestination} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; + + window.destination_settings_test = {}; + destination_settings_test.suiteName = 'DestinationSettingsTest'; /** @enum {string} */ - const TestNames = { + destination_settings_test.TestNames = { ChangeDropdownState: 'change dropdown state', NoRecentDestinations: 'no recent destinations', RecentDestinations: 'recent destinations', @@ -19,21 +29,20 @@ ResetDestinationOnSignOut: 'reset destination on sign out', }; - const suiteName = 'DestinationSettingsTest'; - suite(suiteName, function() { + suite(destination_settings_test.suiteName, function() { /** @type {?PrintPreviewDestinationSettingsElement} */ let destinationSettings = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {?print_preview.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let cloudPrintInterface = null; - /** @type {!Array<!print_preview.RecentDestination>} */ + /** @type {!Array<!RecentDestination>} */ let recentDestinations = []; - /** @type {!Array<!print_preview.Destination>} */ + /** @type {!Array<!Destination>} */ let destinations = []; /** @type {!Array<string>} */ @@ -44,7 +53,7 @@ /** @override */ suiteSetup(function() { - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); }); /** @override */ @@ -52,13 +61,13 @@ PolymerTest.clearBody(); // Stub out native layer and cloud print interface. - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); const localDestinations = []; - destinations = print_preview_test_utils.getDestinations( + destinations = getDestinations( nativeLayer, localDestinations); nativeLayer.setLocalDestinations(localDestinations); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); + cloudPrintInterface = new CloudPrintInterfaceStub(); const model = document.createElement('print-preview-model'); document.body.appendChild(model); @@ -66,15 +75,16 @@ destinationSettings = document.createElement('print-preview-destination-settings'); destinationSettings.settings = model.settings; - destinationSettings.state = print_preview.State.NOT_READY; + destinationSettings.state = State.NOT_READY; destinationSettings.disabled = true; - test_util.fakeDataBind(model, destinationSettings, 'settings'); + fakeDataBind(model, destinationSettings, 'settings'); document.body.appendChild(destinationSettings); }); // Tests that the dropdown is enabled or disabled correctly based on // the state. - test(assert(TestNames.ChangeDropdownState), function() { + test(assert(destination_settings_test.TestNames.ChangeDropdownState), + function() { const dropdown = destinationSettings.$.destinationSelect; // Initial state: No destination store means that there is no destination // yet, so the dropdown is hidden. @@ -89,9 +99,8 @@ [] /* userAccounts */, true /* syncAvailable */); assertTrue(dropdown.hidden); - return test_util - .eventToPromise( - print_preview.DestinationStore.EventType + return eventToPromise( + DestinationStore.EventType .SELECTED_DESTINATION_CAPABILITIES_READY, destinationSettings.destinationStore_) .then(() => { @@ -101,61 +110,61 @@ // prevent brief losses of focus when the destination changes. assertFalse(dropdown.disabled); assertFalse(dropdown.hidden); - destinationSettings.state = print_preview.State.READY; + destinationSettings.state = State.READY; destinationSettings.disabled = false; // Simulate setting a setting to an invalid value. Dropdown is // disabled due to validation error on another control. - destinationSettings.state = print_preview.State.ERROR; + destinationSettings.state = State.ERROR; destinationSettings.disabled = true; assertTrue(dropdown.disabled); // Simulate the user fixing the validation error, and then selecting // an invalid printer. Dropdown is enabled, so that the user can fix // the error. - destinationSettings.state = print_preview.State.READY; + destinationSettings.state = State.READY; destinationSettings.disabled = false; destinationSettings.destinationStore_.dispatchEvent(new CustomEvent( - print_preview.DestinationStore.EventType.ERROR, - {detail: print_preview.DestinationErrorType.INVALID})); - Polymer.dom.flush(); + DestinationStore.EventType.ERROR, + {detail: DestinationErrorType.INVALID})); + flush(); assertEquals( - print_preview.DestinationState.ERROR, + DestinationState.ERROR, destinationSettings.destinationState); assertEquals( - print_preview.Error.INVALID_PRINTER, destinationSettings.error); - destinationSettings.state = print_preview.State.ERROR; + Error.INVALID_PRINTER, destinationSettings.error); + destinationSettings.state = State.ERROR; destinationSettings.disabled = true; assertFalse(dropdown.disabled); - if (cr.isChromeOS) { + if (isChromeOS) { // Simulate the user having no printers. destinationSettings.destinationStore_.dispatchEvent( new CustomEvent( - print_preview.DestinationStore.EventType.ERROR, { + DestinationStore.EventType.ERROR, { detail: - print_preview.DestinationErrorType.NO_DESTINATIONS + DestinationErrorType.NO_DESTINATIONS })); - Polymer.dom.flush(); + flush(); assertEquals( - print_preview.DestinationState.ERROR, + DestinationState.ERROR, destinationSettings.destinationState); assertEquals( - print_preview.Error.NO_DESTINATIONS, + Error.NO_DESTINATIONS, destinationSettings.error); - destinationSettings.state = print_preview.State.FATAL_ERROR; + destinationSettings.state = State.FATAL_ERROR; destinationSettings.disabled = true; assertTrue(dropdown.disabled); } }); }); - /** @return {!print_preview.DestinationOrigin} */ + /** @return {!DestinationOrigin} */ function getLocalOrigin() { - return cr.isChromeOS ? print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL; + return isChromeOS ? DestinationOrigin.CROS : + DestinationOrigin.LOCAL; } /** @@ -171,16 +180,16 @@ '' /* printerName */, '' /* serializedDefaultDestinationSelectionRulesStr */, initialAccounts, true /* syncAvailable */); - destinationSettings.state = print_preview.State.READY; + destinationSettings.state = State.READY; destinationSettings.disabled = false; } /** Simulates a user signing in to Chrome. */ function signIn() { cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(defaultUser)); - cr.webUIListenerCallback('user-accounts-updated', [defaultUser]); - Polymer.dom.flush(); + getGoogleDriveDestination(defaultUser)); + window.cr.webUIListenerCallback('user-accounts-updated', [defaultUser]); + flush(); } /** @@ -209,21 +218,22 @@ // Tests that the dropdown contains the appropriate destinations when there // are no recent destinations. - test(assert(TestNames.NoRecentDestinations), function() { + test(assert(destination_settings_test.TestNames.NoRecentDestinations), + function() { initialize(); return nativeLayer.whenCalled('getPrinterCapabilities') .then(() => { // This will result in the destination store setting the Save as PDF // destination. assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, destinationSettings.destination.id); assertFalse(destinationSettings.$.destinationSelect.disabled); assertDropdownItems(['Save as PDF/local/']); // If the user is signed in, Save to Drive should be displayed. signIn(); - return test_util.waitBeforeNextRender(destinationSettings); + return waitBeforeNextRender(destinationSettings); }) .then(() => { assertDropdownItems([ @@ -235,9 +245,10 @@ // Tests that the dropdown contains the appropriate destinations when there // are 3 recent destinations. - test(assert(TestNames.RecentDestinations), function() { + test(assert(destination_settings_test.TestNames.RecentDestinations), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); initialize(); @@ -269,13 +280,14 @@ // Tests that the dropdown contains the appropriate destinations when Save // as PDF is one of the recent destinations. - test(assert(TestNames.SaveAsPdfRecent), function() { + test(assert(destination_settings_test.TestNames.SaveAsPdfRecent), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); recentDestinations.splice( 1, 1, - print_preview.makeRecentDestination( - print_preview_test_utils.getSaveAsPdfDestination())); + makeRecentDestination( + getSaveAsPdfDestination())); initialize(); return nativeLayer.whenCalled('getPrinterCapabilities') @@ -303,13 +315,14 @@ // Tests that the dropdown contains the appropriate destinations when // Google Drive is in the recent destinations. - test(assert(TestNames.GoogleDriveRecent), function() { + test(assert(destination_settings_test.TestNames.GoogleDriveRecent), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); recentDestinations.splice( 1, 1, - print_preview.makeRecentDestination( - print_preview_test_utils.getGoogleDriveDestination(defaultUser))); + makeRecentDestination( + getGoogleDriveDestination(defaultUser))); initialize(); return nativeLayer.whenCalled('getPrinterCapabilities') @@ -341,13 +354,14 @@ // Tests that selecting the Save as PDF destination results in the // DESTINATION_SELECT event firing, with Save as PDF set as the current // destination. - test(assert(TestNames.SelectSaveAsPdf), function() { + test(assert(destination_settings_test.TestNames.SelectSaveAsPdf), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); recentDestinations.splice( 1, 1, - print_preview.makeRecentDestination( - print_preview_test_utils.getSaveAsPdfDestination())); + makeRecentDestination( + getSaveAsPdfDestination())); initialize(); const dropdown = destinationSettings.$.destinationSelect; @@ -367,8 +381,8 @@ assertEquals('ID1', destinationSettings.destination.id); // Simulate selection of Save as PDF printer. - const whenDestinationSelect = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + const whenDestinationSelect = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, destinationSettings.destinationStore_); dropdown.fire('selected-option-change', 'Save as PDF/local/'); @@ -377,7 +391,7 @@ }) .then(() => { assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, destinationSettings.destination.id); }); }); @@ -385,13 +399,14 @@ // Tests that selecting the Google Drive destination results in the // DESTINATION_SELECT event firing, with Google Drive set as the current // destination. - test(assert(TestNames.SelectGoogleDrive), function() { + test(assert(destination_settings_test.TestNames.SelectGoogleDrive), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); recentDestinations.splice( 1, 1, - print_preview.makeRecentDestination( - print_preview_test_utils.getGoogleDriveDestination(defaultUser))); + makeRecentDestination( + getGoogleDriveDestination(defaultUser))); initialize(); const dropdown = destinationSettings.$.destinationSelect; @@ -415,8 +430,8 @@ assertEquals('ID1', destinationSettings.destination.id); // Simulate selection of Google Drive printer. - const whenDestinationSelect = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + const whenDestinationSelect = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, destinationSettings.destinationStore_); dropdown.fire( 'selected-option-change', @@ -425,7 +440,7 @@ }) .then(() => { assertEquals( - print_preview.Destination.GooglePromotedId.DOCS, + Destination.GooglePromotedId.DOCS, destinationSettings.destination.id); }); }); @@ -433,9 +448,10 @@ // Tests that selecting a recent destination results in the // DESTINATION_SELECT event firing, with the recent destination set as the // current destination. - test(assert(TestNames.SelectRecentDestination), function() { + test(assert(destination_settings_test.TestNames.SelectRecentDestination), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); initialize(); const dropdown = destinationSettings.$.destinationSelect; @@ -453,8 +469,8 @@ ]); // Simulate selection of Save as PDF printer. - const whenDestinationSelect = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + const whenDestinationSelect = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, destinationSettings.destinationStore_); dropdown.fire( 'selected-option-change', makeLocalDestinationKey('ID2')); @@ -466,9 +482,9 @@ }); // Tests that selecting the 'see more' option opens the dialog. - test(assert(TestNames.OpenDialog), function() { + test(assert(destination_settings_test.TestNames.OpenDialog), function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); initialize(); const dropdown = destinationSettings.$.destinationSelect; @@ -486,7 +502,7 @@ ]); dropdown.fire('selected-option-change', 'seeMore'); - return test_util.waitBeforeNextRender(destinationSettings); + return waitBeforeNextRender(destinationSettings); }) .then(() => { assertTrue( @@ -495,35 +511,37 @@ }); }); - test(assert(TestNames.TwoAccountsRecentDestinations), function() { + test(assert( + destination_settings_test.TestNames.TwoAccountsRecentDestinations), + function() { const account2 = 'bar@chromium.org'; const driveUser1 = - print_preview_test_utils.getGoogleDriveDestination(defaultUser); + getGoogleDriveDestination(defaultUser); const driveUser2 = - print_preview_test_utils.getGoogleDriveDestination(account2); - const cloudPrinterUser1 = new print_preview.Destination( - 'FooCloud', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooCloudName', - print_preview.DestinationConnectionStatus.ONLINE, + getGoogleDriveDestination(account2); + const cloudPrinterUser1 = new Destination( + 'FooCloud', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooCloudName', + DestinationConnectionStatus.ONLINE, {account: defaultUser}); - const cloudPrinterUser2 = new print_preview.Destination( - 'BarCloud', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'BarCloudName', - print_preview.DestinationConnectionStatus.ONLINE, + const cloudPrinterUser2 = new Destination( + 'BarCloud', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'BarCloudName', + DestinationConnectionStatus.ONLINE, {account: account2}); cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(defaultUser)); + getGoogleDriveDestination(defaultUser)); cloudPrintInterface.setPrinter(driveUser2); cloudPrintInterface.setPrinter(cloudPrinterUser1); cloudPrintInterface.setPrinter(cloudPrinterUser2); recentDestinations = [ cloudPrinterUser1, cloudPrinterUser2, destinations[0] - ].map(destination => print_preview.makeRecentDestination(destination)); + ].map(destination => makeRecentDestination(destination)); initialAccounts = [defaultUser, account2]; initialize(); - Polymer.dom.flush(); + flush(); const dropdown = destinationSettings.$.destinationSelect; @@ -541,18 +559,18 @@ ]); dropdown.fire('selected-option-change', 'seeMore'); - return test_util.waitBeforeNextRender(destinationSettings); + return waitBeforeNextRender(destinationSettings); }) .then(() => { const dialog = destinationSettings.$$('print-preview-destination-dialog'); assertTrue(dialog.isOpen()); - const whenAdded = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATIONS_INSERTED, + const whenAdded = eventToPromise( + DestinationStore.EventType.DESTINATIONS_INSERTED, destinationSettings.destinationStore_); // Simulate setting a new account. dialog.fire('account-change', account2); - Polymer.dom.flush(); + flush(); return whenAdded; }) .then(() => { @@ -580,14 +598,15 @@ function selectDestination(destination) { destinationSettings.destinationStore_.selectDestination(destination); - Polymer.dom.flush(); + flush(); } /** * Tests that the destination being set correctly updates the recent * destinations array. */ - test(assert(TestNames.UpdateRecentDestinations), function() { + test(assert(destination_settings_test.TestNames.UpdateRecentDestinations), + function() { // Recent destinations start out empty. assertRecentDestinations([]); assertEquals(0, nativeLayer.getCallCount('getPrinterCapabilities')); @@ -615,7 +634,7 @@ new CustomEvent('selected-option-change', { detail: 'Save as PDF/local/', })); - Polymer.dom.flush(); + flush(); assertRecentDestinations(['Save as PDF', 'ID1']); // No additional capabilities call, since the destination was // previously selected. @@ -642,22 +661,23 @@ // Tests that the dropdown resets the destination if the user signs out of // the account associated with the curret one. - test(assert(TestNames.ResetDestinationOnSignOut), function() { + test(assert(destination_settings_test.TestNames.ResetDestinationOnSignOut), + function() { recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); const driveDestination = - print_preview_test_utils.getGoogleDriveDestination(defaultUser); + getGoogleDriveDestination(defaultUser); recentDestinations.splice( - 0, 1, print_preview.makeRecentDestination(driveDestination)); + 0, 1, makeRecentDestination(driveDestination)); cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(defaultUser)); + getGoogleDriveDestination(defaultUser)); initialAccounts = [defaultUser]; initialize(); return cloudPrintInterface.whenCalled('printer') .then(() => { assertEquals( - print_preview.Destination.GooglePromotedId.DOCS, + Destination.GooglePromotedId.DOCS, destinationSettings.destination.id); assertFalse(destinationSettings.$.destinationSelect.disabled); assertDropdownItems([ @@ -668,8 +688,8 @@ ]); // Sign out. - cr.webUIListenerCallback('user-accounts-updated', []); - Polymer.dom.flush(); + window.cr.webUIListenerCallback('user-accounts-updated', []); + flush(); return nativeLayer.whenCalled('getPrinterCapabilities'); }) @@ -687,15 +707,9 @@ signIn(); assertEquals('ID2', destinationSettings.destination.id); - cr.webUIListenerCallback('user-accounts-updated', []); - Polymer.dom.flush(); + window.cr.webUIListenerCallback('user-accounts-updated', []); + flush(); assertEquals('ID2', destinationSettings.destination.id); }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/destination_store_test.js b/chrome/test/data/webui/print_preview/destination_store_test.js index 52aa289..7c74d04 100644 --- a/chrome/test/data/webui/print_preview/destination_store_test.js +++ b/chrome/test/data/webui/print_preview/destination_store_test.js
@@ -2,9 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('destination_store_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationErrorType, DestinationOrigin, DestinationStore, DestinationType, makeRecentDestination, NativeLayer, PluginProxy, PrinterType} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {createDestinationStore, createDestinationWithCertificateStatus, getCddTemplate, getDefaultInitialSettings, getDestinations, getGoogleDriveDestination, getSaveAsPdfDestination, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; + + window.destination_store_test = {}; + destination_store_test.suiteName = 'DestinationStoreTest'; /** @enum {string} */ - const TestNames = { + destination_store_test.TestNames = { SingleRecentDestination: 'single recent destination', MultipleRecentDestinations: 'multiple recent destinations', MultipleRecentDestinationsOneRequest: @@ -19,27 +29,26 @@ LoadAndSelectDestination: 'select loaded destination', }; - const suiteName = 'DestinationStoreTest'; - suite(suiteName, function() { - /** @type {?print_preview.DestinationStore} */ + suite(destination_store_test.suiteName, function() { + /** @type {?DestinationStore} */ let destinationStore = null; - /** @type {?print_preview.NativeLayerStub} */ + /** @type {?NativeLayerStub} */ let nativeLayer = null; /** @type {?cloudprint.CloudPrintInterface} */ let cloudPrintInterface = null; - /** @type {?print_preview.NativeInitialSettngs} */ + /** @type {?NativeInitialSettngs} */ let initialSettings = null; - /** @type {!Array<!print_preview.LocalDestinationInfo>} */ + /** @type {!Array<!LocalDestinationInfo>} */ let localDestinations = []; - /** @type {!Array<!print_preview.Destination>} */ + /** @type {!Array<!Destination>} */ let cloudDestinations = []; - /** @type {!Array<!print_preview.Destination>} */ + /** @type {!Array<!Destination>} */ let destinations = []; /** @type {number} */ @@ -50,16 +59,15 @@ // Clear the UI. PolymerTest.clearBody(); - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); - initialSettings = print_preview_test_utils.getDefaultInitialSettings(); + initialSettings = getDefaultInitialSettings(); initialSettings.userAccounts = []; localDestinations = []; - destinations = print_preview_test_utils.getDestinations( - nativeLayer, localDestinations); + destinations = getDestinations(nativeLayer, localDestinations); }); /* @@ -75,16 +83,16 @@ nativeLayer.setLocalDestinations(localDestinations); // Create cloud print interface. - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); + cloudPrintInterface = new CloudPrintInterfaceStub(); cloudDestinations.forEach(cloudDestination => { cloudPrintInterface.setPrinter(cloudDestination); }); // Create destination store. - destinationStore = print_preview_test_utils.createDestinationStore(); + destinationStore = createDestinationStore(); destinationStore.setCloudPrintInterface(cloudPrintInterface); destinationStore.addEventListener( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + DestinationStore.EventType.DESTINATION_SELECT, function() { numPrintersSelected++; }); @@ -97,8 +105,8 @@ const recentDestinations = initialSettings.serializedAppStateStr ? JSON.parse(initialSettings.serializedAppStateStr).recentDestinations : []; - const whenCapabilitiesReady = test_util.eventToPromise( - print_preview.DestinationStore.EventType + const whenCapabilitiesReady = eventToPromise( + DestinationStore.EventType .SELECTED_DESTINATION_CAPABILITIES_READY, destinationStore); destinationStore.init( @@ -114,9 +122,10 @@ * Tests that if the user has a single valid recent destination the * destination is automatically reselected. */ - test(assert(TestNames.SingleRecentDestination), function() { + test(assert(destination_store_test.TestNames.SingleRecentDestination), + function() { const recentDestination = - print_preview.makeRecentDestination(destinations[0]); + makeRecentDestination(destinations[0]); initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, recentDestinations: [recentDestination], @@ -124,7 +133,7 @@ return setInitialSettings().then(function(args) { assertEquals('ID1', args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals('ID1', destinationStore.selectedDestination.id); }); }); @@ -134,9 +143,10 @@ * recent destination is automatically reselected and its capabilities are * fetched. */ - test(assert(TestNames.MultipleRecentDestinations), function() { + test(assert(destination_store_test.TestNames.MultipleRecentDestinations), + function() { const recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, @@ -147,7 +157,7 @@ // Should have loaded ID1 as the selected printer, since it was most // recent. assertEquals('ID1', args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals('ID1', destinationStore.selectedDestination.id); // Only the most recent printer should have been added to the store. const reportedPrinters = destinationStore.destinations(); @@ -166,9 +176,11 @@ * correct destination is selected for the preview request. * For crbug.com/666595. */ - test(assert(TestNames.MultipleRecentDestinationsOneRequest), function() { + test(assert( + destination_store_test.TestNames.MultipleRecentDestinationsOneRequest), + function() { const recentDestinations = destinations.slice(0, 3).map( - destination => print_preview.makeRecentDestination(destination)); + destination => makeRecentDestination(destination)); initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, @@ -179,7 +191,7 @@ // Should have loaded ID1 as the selected printer, since it was most // recent. assertEquals('ID1', args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals('ID1', destinationStore.selectedDestination.id); // Most recent printer + Save as PDF are in the store automatically. @@ -197,7 +209,9 @@ * Tests that if there are default destination selection rules they are * respected and a matching destination is automatically selected. */ - test(assert(TestNames.DefaultDestinationSelectionRules), function() { + test(assert( + destination_store_test.TestNames.DefaultDestinationSelectionRules), + function() { initialSettings.serializedDefaultDestinationSelectionRulesStr = JSON.stringify({namePattern: '.*Four.*'}); initialSettings.serializedAppStateStr = ''; @@ -205,7 +219,7 @@ // Should have loaded ID4 as the selected printer, since it matches // the rules. assertEquals('ID4', args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals('ID4', destinationStore.selectedDestination.id); }); }); @@ -215,7 +229,8 @@ * default printer is automatically selected even if the user has recent * destinations. */ - test(assert(TestNames.SystemDefaultPrinterPolicy), function() { + test(assert(destination_store_test.TestNames.SystemDefaultPrinterPolicy), + function() { // Set the policy in loadTimeData. loadTimeData.overrideValues({useSystemDefaultPrinter: true}); @@ -223,7 +238,7 @@ const recentDestinations = []; destinations.slice(0, 3).forEach(destination => { recentDestinations.push( - print_preview.makeRecentDestination(destination)); + makeRecentDestination(destination)); }); initialSettings.serializedAppStateStr = JSON.stringify({ @@ -234,8 +249,8 @@ return Promise .all([ setInitialSettings(), - test_util.eventToPromise( - print_preview.DestinationStore.EventType + eventToPromise( + DestinationStore.EventType .SELECTED_DESTINATION_CAPABILITIES_READY, destinationStore), ]) @@ -252,7 +267,8 @@ * is in app kiosk mode (so no PDF printer), the first destination returned * from printer fetch is selected. */ - test(assert(TestNames.KioskModeSelectsFirstPrinter), function() { + test(assert(destination_store_test.TestNames.KioskModeSelectsFirstPrinter), + function() { initialSettings.serializedDefaultDestinationSelectionRulesStr = ''; initialSettings.serializedAppStateStr = ''; initialSettings.isInAppKioskMode = true; @@ -261,7 +277,7 @@ return setInitialSettings().then(function(args) { // Should have loaded the first destination as the selected printer. assertEquals(destinations[0].id, args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals( destinations[0].id, destinationStore.selectedDestination.id); }); @@ -274,7 +290,8 @@ * destinations found, the NO_DESTINATIONS error is fired and the selected * destination is null. */ - test(assert(TestNames.NoPrintersShowsError), function() { + test(assert(destination_store_test.TestNames.NoPrintersShowsError), + function() { initialSettings.serializedDefaultDestinationSelectionRulesStr = ''; initialSettings.serializedAppStateStr = ''; initialSettings.isInAppKioskMode = true; @@ -284,14 +301,14 @@ return Promise .all([ setInitialSettings(true), - test_util.eventToPromise( - print_preview.DestinationStore.EventType.ERROR, + eventToPromise( + DestinationStore.EventType.ERROR, destinationStore), ]) .then(function(argsArray) { const errorEvent = argsArray[1]; assertEquals( - print_preview.DestinationErrorType.NO_DESTINATIONS, + DestinationErrorType.NO_DESTINATIONS, errorEvent.detail); assertEquals(null, destinationStore.selectedDestination); }); @@ -301,12 +318,13 @@ * Tests that if the user has a recent destination that triggers a cloud * print error this does not disable the dialog. */ - test(assert(TestNames.UnreachableRecentCloudPrinter), function() { + test(assert(destination_store_test.TestNames.UnreachableRecentCloudPrinter), + function() { const cloudPrinter = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( 'BarDevice', 'BarName', false); const recentDestination = - print_preview.makeRecentDestination(cloudPrinter); + makeRecentDestination(cloudPrinter); initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, recentDestinations: [recentDestination], @@ -315,7 +333,7 @@ return setInitialSettings().then(function(args) { assertEquals('FooDevice', args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals('FooDevice', destinationStore.selectedDestination.id); }); }); @@ -325,26 +343,26 @@ * store (PDF printer), the DestinationStore does not try to select a * printer again later. Regression test for https://crbug.com/927162. */ - test(assert(TestNames.RecentSaveAsPdf), function() { - const pdfPrinter = print_preview_test_utils.getSaveAsPdfDestination(); - const recentDestination = print_preview.makeRecentDestination(pdfPrinter); + test(assert(destination_store_test.TestNames.RecentSaveAsPdf), function() { + const pdfPrinter = getSaveAsPdfDestination(); + const recentDestination = makeRecentDestination(pdfPrinter); initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, recentDestinations: [recentDestination], }); - print_preview.DestinationStore.AUTO_SELECT_TIMEOUT_ = 0; + DestinationStore.AUTO_SELECT_TIMEOUT_ = 0; return setInitialSettings() .then(function() { assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, destinationStore.selectedDestination.id); return new Promise(resolve => setTimeout(resolve)); }) .then(function() { // Should still have Save as PDF. assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, destinationStore.selectedDestination.id); }); }); @@ -353,22 +371,24 @@ * Tests that if there are recent destinations from different accounts, only * destinations associated with the most recent account are fetched. */ - test(assert(TestNames.MultipleRecentDestinationsAccounts), function() { + test(assert( + destination_store_test.TestNames.MultipleRecentDestinationsAccounts), + function() { const account1 = 'foo@chromium.org'; const account2 = 'bar@chromium.org'; const driveUser1 = - print_preview_test_utils.getGoogleDriveDestination(account1); + getGoogleDriveDestination(account1); const driveUser2 = - print_preview_test_utils.getGoogleDriveDestination(account2); - const cloudPrinterUser1 = new print_preview.Destination( - 'FooCloud', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooCloudName', - print_preview.DestinationConnectionStatus.ONLINE, + getGoogleDriveDestination(account2); + const cloudPrinterUser1 = new Destination( + 'FooCloud', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooCloudName', + DestinationConnectionStatus.ONLINE, {account: account1}); const recentDestinations = [ - print_preview.makeRecentDestination(driveUser1), - print_preview.makeRecentDestination(driveUser2), - print_preview.makeRecentDestination(cloudPrinterUser1), + makeRecentDestination(driveUser1), + makeRecentDestination(driveUser2), + makeRecentDestination(cloudPrinterUser1), ]; cloudDestinations = [driveUser1, driveUser2, cloudPrinterUser1]; initialSettings.serializedAppStateStr = JSON.stringify({ @@ -382,7 +402,7 @@ // Should have loaded Google Drive as the selected printer, since it // was most recent. assertEquals( - print_preview.Destination.GooglePromotedId.DOCS, + Destination.GooglePromotedId.DOCS, destinationStore.selectedDestination.id); // Only the most recent printer + Save as PDF are in the store. @@ -399,7 +419,7 @@ const loadedPrintersAccount2 = destinationStore.destinations(account2); assertEquals(1, loadedPrintersAccount2.length); assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, loadedPrintersAccount2[0].id); }); }); @@ -408,8 +428,9 @@ * Tests that if the user has a single valid recent destination the * destination is automatically reselected. */ - test(assert(TestNames.LoadAndSelectDestination), function() { - destinations = print_preview_test_utils.getDestinations( + test(assert(destination_store_test.TestNames.LoadAndSelectDestination), + function() { + destinations = getDestinations( nativeLayer, localDestinations); initialSettings.printerName = ''; const id1 = 'ID1'; @@ -419,24 +440,23 @@ return setInitialSettings() .then(function(args) { assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, args.destinationId); - assertEquals(print_preview.PrinterType.LOCAL, args.type); + assertEquals(PrinterType.LOCAL, args.type); assertEquals( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, + Destination.GooglePromotedId.SAVE_AS_PDF, destinationStore.selectedDestination.id); // Update destination with ID 1 so that it has policies. const localDestinationInfo = {deviceName: id1, printerName: name1}; - if (cr.isChromeOS) { + if (isChromeOS) { localDestinationInfo.policies = { - allowedColorModes: - print_preview.ColorModeRestriction.MONOCHROME, - defaultColorMode: print_preview.ColorModeRestriction.MONOCHROME, + allowedColorModes: 0x1, // ColorModeRestriction.MONOCHROME + defaultColorMode: 0x1, // ColorModeRestriction.MONOCHROME }; } nativeLayer.setLocalDestinationCapabilities({ printer: localDestinationInfo, - capabilities: print_preview_test_utils.getCddTemplate(id1, name1), + capabilities: getCddTemplate(id1, name1), }); destinationStore.startLoadAllDestinations(); return nativeLayer.whenCalled('getPrinters'); @@ -446,7 +466,7 @@ destinationStore.destinations().find(d => d.id === id1); // No capabilities or policies yet. assertFalse(!!destination.capabilities); - if (cr.isChromeOS) { + if (isChromeOS) { assertEquals(null, destination.policies); } destinationStore.selectDestination(destination); @@ -456,16 +476,10 @@ assertEquals(destination, destinationStore.selectedDestination); // Capabilities are updated. assertTrue(!!destination.capabilities); - if (cr.isChromeOS) { + if (isChromeOS) { // Policies are updated. assertTrue(!!destination.policies); } }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/dpi_settings_test.js b/chrome/test/data/webui/print_preview/dpi_settings_test.js index c93c0d0..1cd205f 100644 --- a/chrome/test/data/webui/print_preview/dpi_settings_test.js +++ b/chrome/test/data/webui/print_preview/dpi_settings_test.js
@@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('dpi_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('DpiSettingsTest', function() { /** @type {?PrintPreviewDpiSettingsElement} */ let dpiSection = null; - const dpiCapability = print_preview_test_utils.getCddTemplate('FooPrinter') - .capabilities.printer.dpi; + const dpiCapability = getCddTemplate('FooPrinter').capabilities.printer.dpi; const expectedCapabilityWithLabels = - print_preview_test_utils.getCddTemplate('FooPrinter') - .capabilities.printer.dpi; + getCddTemplate('FooPrinter').capabilities.printer.dpi; expectedCapabilityWithLabels.option.forEach(option => { option.name = option.horizontal_dpi.toString() + ' dpi'; }); @@ -28,7 +30,7 @@ dpiSection.capability = dpiCapability; dpiSection.disabled = false; model.set('settings.dpi.available', true); - test_util.fakeDataBind(model, dpiSection, 'settings'); + fakeDataBind(model, dpiSection, 'settings'); document.body.appendChild(dpiSection); }); @@ -76,4 +78,3 @@ highQualityWithLabel, JSON.parse(settingsSelect.selectedValue)); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/duplex_settings_test.js b/chrome/test/data/webui/print_preview/duplex_settings_test.js index b92d760..c4daafb 100644 --- a/chrome/test/data/webui/print_preview/duplex_settings_test.js +++ b/chrome/test/data/webui/print_preview/duplex_settings_test.js
@@ -2,7 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('duplex_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {DuplexMode} from 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + suite('DuplexSettingsTest', function() { /** @type {?PrintPreviewDuplexSettingsElement} */ let duplexSection = null; @@ -22,9 +28,9 @@ duplexSection = document.createElement('print-preview-duplex-settings'); duplexSection.settings = model.settings; duplexSection.disabled = false; - test_util.fakeDataBind(model, duplexSection, 'settings'); + fakeDataBind(model, duplexSection, 'settings'); document.body.appendChild(duplexSection); - Polymer.dom.flush(); + flush(); }); // Tests that making short edge unavailable prevents the collapse from @@ -52,12 +58,12 @@ assertTrue(collapse.opened); const select = duplexSection.$$('select'); - assertEquals(print_preview.DuplexMode.LONG_EDGE.toString(), select.value); + assertEquals(DuplexMode.LONG_EDGE.toString(), select.value); duplexSection.setSetting('duplexShortEdge', true); - await test_util.eventToPromise('process-select-change', duplexSection); + await eventToPromise('process-select-change', duplexSection); assertEquals( - print_preview.DuplexMode.SHORT_EDGE.toString(), select.value); + DuplexMode.SHORT_EDGE.toString(), select.value); }); // Tests that checking the box or selecting a new option in the dropdown @@ -81,19 +87,19 @@ assertFalse(duplexSection.getSetting('duplexShortEdge').setFromUi); const select = duplexSection.$$('select'); - assertEquals(print_preview.DuplexMode.LONG_EDGE.toString(), select.value); + assertEquals(DuplexMode.LONG_EDGE.toString(), select.value); assertEquals(2, select.options.length); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption( - duplexSection, print_preview.DuplexMode.SHORT_EDGE.toString()); + await selectOption( + duplexSection, DuplexMode.SHORT_EDGE.toString()); assertTrue(duplexSection.getSettingValue('duplex')); assertTrue(duplexSection.getSettingValue('duplexShortEdge')); assertTrue(duplexSection.getSetting('duplex').setFromUi); assertTrue(duplexSection.getSetting('duplexShortEdge').setFromUi); }); - if (cr.isChromeOS) { + if (isChromeOS) { // Tests that if settings are enforced by enterprise policy the // appropriate UI is disabled. test('disabled by policy', function() { @@ -114,4 +120,3 @@ }); } }); -});
diff --git a/chrome/test/data/webui/print_preview/header_test.js b/chrome/test/data/webui/print_preview/header_test.js index 2cc35a1..2548dad 100644 --- a/chrome/test/data/webui/print_preview/header_test.js +++ b/chrome/test/data/webui/print_preview/header_test.js
@@ -2,9 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('header_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, Error, State} from 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; + + window.header_test = {}; + header_test.suiteName = 'HeaderTest'; /** @enum {string} */ - const TestNames = { + header_test.TestNames = { HeaderPrinterTypes: 'header printer types', HeaderWithDuplex: 'header with duplex', HeaderWithCopies: 'header with copies', @@ -13,8 +18,7 @@ EnterprisePolicy: 'enterprise policy', }; - const suiteName = 'HeaderTest'; - suite(suiteName, function() { + suite(header_test.suiteName, function() { /** @type {?PrintPreviewHeaderElement} */ let header = null; @@ -29,30 +33,30 @@ model.set('settings.duplex.available', true); model.set('settings.duplex.value', false); - header.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); - header.state = print_preview.State.READY; + header.destination = new Destination( + 'FooDevice', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooName', + DestinationConnectionStatus.ONLINE); + header.state = State.READY; header.managed = false; - test_util.fakeDataBind(model, header, 'settings'); + fakeDataBind(model, header, 'settings'); document.body.appendChild(header); }); function setPdfDestination() { header.set( 'destination', - new print_preview.Destination( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, - print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, + new Destination( + Destination.GooglePromotedId.SAVE_AS_PDF, + DestinationType.LOCAL, + DestinationOrigin.LOCAL, loadTimeData.getString('printToPDF'), - print_preview.DestinationConnectionStatus.ONLINE)); + DestinationConnectionStatus.ONLINE)); } // Tests that the 4 different messages (non-virtual printer singular and // plural, virtual printer singular and plural) all show up as expected. - test(assert(TestNames.HeaderPrinterTypes), function() { + test(assert(header_test.TestNames.HeaderPrinterTypes), function() { const summary = header.$$('.summary'); assertEquals('1 sheet of paper', summary.textContent.trim()); header.setSetting('pages', [1, 2, 3]); @@ -68,7 +72,7 @@ }); // Tests that the message is correctly adjusted with a duplex printer. - test(assert(TestNames.HeaderWithDuplex), function() { + test(assert(header_test.TestNames.HeaderWithDuplex), function() { const summary = header.$$('.summary'); assertEquals('1 sheet of paper', summary.textContent.trim()); header.setSetting('pages', [1, 2, 3]); @@ -80,7 +84,7 @@ }); // Tests that the message is correctly adjusted with multiple copies. - test(assert(TestNames.HeaderWithCopies), function() { + test(assert(header_test.TestNames.HeaderWithCopies), function() { const summary = header.$$('.summary'); assertEquals('1 sheet of paper', summary.textContent.trim()); header.setSetting('copies', 4); @@ -95,40 +99,34 @@ // Tests that the correct message is shown for non-READY states, and that // the print button is disabled appropriately. - test(assert(TestNames.HeaderChangesForState), function() { + test(assert(header_test.TestNames.HeaderChangesForState), function() { const summary = header.$$('.summary'); assertEquals('1 sheet of paper', summary.textContent.trim()); - header.state = print_preview.State.NOT_READY; + header.state = State.NOT_READY; assertEquals('', summary.textContent.trim()); - header.state = print_preview.State.PRINTING; + header.state = State.PRINTING; assertEquals( loadTimeData.getString('printing'), summary.textContent.trim()); setPdfDestination(); assertEquals( loadTimeData.getString('saving'), summary.textContent.trim()); - header.state = print_preview.State.ERROR; + header.state = State.ERROR; assertEquals('', summary.textContent.trim()); const testError = 'Error printing to cloud print'; header.cloudPrintErrorMessage = testError; - header.error = print_preview.Error.CLOUD_PRINT_ERROR; - header.state = print_preview.State.FATAL_ERROR; + header.error = Error.CLOUD_PRINT_ERROR; + header.state = State.FATAL_ERROR; assertEquals(testError, summary.textContent.trim()); }); // Tests that enterprise badge shows up if any setting is managed. - test(assert(TestNames.EnterprisePolicy), function() { + test(assert(header_test.TestNames.EnterprisePolicy), function() { assertTrue(header.$$('iron-icon').hidden); header.managed = true; assertFalse(header.$$('iron-icon').hidden); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/invalid_settings_browsertest.js b/chrome/test/data/webui/print_preview/invalid_settings_browsertest.js index 0fb606b..2bfd299 100644 --- a/chrome/test/data/webui/print_preview/invalid_settings_browsertest.js +++ b/chrome/test/data/webui/print_preview/invalid_settings_browsertest.js
@@ -2,27 +2,36 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('invalid_settings_browsertest', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationStore, DestinationType, makeRecentDestination, NativeLayer, PluginProxy, ScalingType, setCloudPrintInterfaceForTesting, State, whenReady} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {eventToPromise, waitBeforeNextRender} from 'chrome://test/test_util.m.js'; +import {createDestinationWithCertificateStatus, getCddTemplate, getDefaultMediaSize, getDefaultOrientation} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {isWindows} from 'chrome://resources/js/cr.m.js'; + + window.invalid_settings_browsertest = {}; + invalid_settings_browsertest.suiteName = 'InvalidSettingsBrowserTest'; /** @enum {string} */ - const TestNames = { + invalid_settings_browsertest.TestNames = { NoPDFPluginError: 'no pdf plugin error', InvalidSettingsError: 'invalid settings error', InvalidCertificateError: 'invalid certificate error', InvalidCertificateErrorReselectDestination: 'invalid certificate reselect', }; - const suiteName = 'InvalidSettingsBrowserTest'; - suite(suiteName, function() { + suite(invalid_settings_browsertest.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {?cloudprint.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let cloudPrintInterface = null; - /** @type {!print_preview.NativeInitialSettings} */ + /** @type {!NativeInitialSettings} */ const initialSettings = { isInKioskAutoPrintMode: false, isInAppKioskMode: false, @@ -39,7 +48,7 @@ serializedDefaultDestinationSelectionRulesStr: null }; - /** @type {!Array<!print_preview.LocalDestinationInfo>} */ + /** @type {!Array<!LocalDestinationInfo>} */ let localDestinationInfos = [ {printerName: 'FooName', deviceName: 'FooDevice'}, {printerName: 'BarName', deviceName: 'BarDevice'}, @@ -47,10 +56,10 @@ /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); - cloudprint.setCloudPrintInterfaceForTesting(cloudPrintInterface); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); + cloudPrintInterface = new CloudPrintInterfaceStub(); + setCloudPrintInterfaceForTesting(cloudPrintInterface); PolymerTest.clearBody(); }); @@ -67,12 +76,12 @@ nativeLayer.setLocalDestinations(localDestinationInfos); if (initialSettings.printerName) { nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate( + getCddTemplate( initialSettings.printerName)); } - const pluginProxy = new print_preview.PDFPluginStub(); + const pluginProxy = new PDFPluginStub(); pluginProxy.setPluginCompatible(pluginCompatible); - print_preview.PluginProxy.setInstance(pluginProxy); + PluginProxy.setInstance(pluginProxy); page = document.createElement('print-preview-app'); document.body.appendChild(page); @@ -85,15 +94,15 @@ * in |printers|. printers[0] will be set as the most recent destination, * and printers[1] will be the second most recent destination. Sets up * cloud print interface, user info, and runs createPage(). - * @param {!Array<!print_preview.Destination>} printers + * @param {!Array<!Destination>} printers */ function setupInvalidCertificateTest(printers) { initialSettings.printerName = ''; initialSettings.serializedAppStateStr = JSON.stringify({ version: 2, recentDestinations: [ - print_preview.makeRecentDestination(printers[0]), - print_preview.makeRecentDestination(printers[1]), + makeRecentDestination(printers[0]), + makeRecentDestination(printers[1]), ], }); initialSettings.cloudPrintURL = 'cloudprint URL'; @@ -109,14 +118,15 @@ // Test that error message is displayed when plugin doesn't exist. // TODO (rbpotter): Fix this test so that it works again with calling // appendChild() before setting checkPluginCompatibility. - test(assert(TestNames.NoPDFPluginError), function() { + test(assert(invalid_settings_browsertest.TestNames.NoPDFPluginError), + function() { createPage(false); const previewArea = page.$.previewArea; return nativeLayer.whenCalled('getInitialSettings').then(function() { const overlayEl = previewArea.$$('.preview-area-overlay-layer'); const messageEl = previewArea.$$('.preview-area-message'); - assertEquals(print_preview.State.FATAL_ERROR, page.state); + assertEquals(State.FATAL_ERROR, page.state); // Make sure the overlay is visible. assertFalse(overlayEl.classList.contains('invisible')); @@ -136,9 +146,10 @@ // preview area displays an invalid printer error message and printing // is disabled. Verifies that the user can recover from this error by // selecting a different, valid printer. - test(assert(TestNames.InvalidSettingsError), function() { + test(assert(invalid_settings_browsertest.TestNames.InvalidSettingsError), + function() { createPage(true); - const barDevice = print_preview_test_utils.getCddTemplate('BarDevice'); + const barDevice = getCddTemplate('BarDevice'); nativeLayer.setLocalDestinationCapabilities(barDevice); // FooDevice is the default printer, so will be selected for the initial @@ -159,13 +170,13 @@ const destinationSettings = sidebar.$$('print-preview-destination-settings'); - return test_util.waitBeforeNextRender(page) + return waitBeforeNextRender(page) .then(() => { const parentElement = sidebar.$$('print-preview-button-strip'); printButton = parentElement.$$('.action-button'); return Promise.all([ - print_preview.Model.whenReady(), + whenReady(), nativeLayer.whenCalled('getInitialSettings'), ]); }) @@ -182,7 +193,7 @@ // FooDevice was set as an invalid printer. assertFalse(overlay.classList.contains('invisible')); assertTrue(messageEl.textContent.includes(expectedMessage)); - assertEquals(print_preview.State.ERROR, page.state); + assertEquals(State.ERROR, page.state); // Verify that the print button is disabled assertTrue(printButton.disabled); @@ -211,7 +222,7 @@ // Has active print button and successfully 'prints', indicating assertFalse(printButton.disabled); - assertEquals(print_preview.State.READY, page.state); + assertEquals(State.READY, page.state); printButton.click(); // This should result in a call to print. return nativeLayer.whenCalled('print'); @@ -226,12 +237,12 @@ const ticket = JSON.parse(printTicket); assertEquals(barDevice.printer.deviceName, ticket.deviceName); assertEquals( - print_preview_test_utils.getDefaultOrientation(barDevice) == + getDefaultOrientation(barDevice) == 'LANDSCAPE', ticket.landscape); assertEquals(1, ticket.copies); const mediaDefault = - print_preview_test_utils.getDefaultMediaSize(barDevice); + getDefaultMediaSize(barDevice); assertEquals( mediaDefault.width_microns, ticket.mediaSize.width_microns); assertEquals( @@ -246,12 +257,13 @@ // recovered by selecting a new destination. Verifies this works when the // invalid printer is the most recent destination and is selected by // default. - test(assert(TestNames.InvalidCertificateError), function() { + test(assert(invalid_settings_browsertest.TestNames.InvalidCertificateError), + function() { const invalidPrinter = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( 'FooDevice', 'FooName', true); const validPrinter = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( 'BarDevice', 'BarName', false); setupInvalidCertificateTest([invalidPrinter, validPrinter]); @@ -273,18 +285,18 @@ .$$('print-preview-number-settings-section'); const layoutSettings = sidebar.$$('print-preview-layout-settings'); - return test_util.waitBeforeNextRender(page) + return waitBeforeNextRender(page) .then(() => { const parentElement = sidebar.$$('print-preview-button-strip'); printButton = parentElement.$$('.action-button'); return Promise.all([ - print_preview.Model.whenReady(), + whenReady(), nativeLayer.whenCalled('getInitialSettings'), ]); }) .then(function() { // Set this to enable the scaling input. - page.setSetting('scalingType', print_preview.ScalingType.CUSTOM); + page.setSetting('scalingType', ScalingType.CUSTOM); destinationSettings.destinationStore_.startLoadCloudDestinations(); @@ -302,7 +314,7 @@ // Verify the state is invalid and that some settings sections are // also disabled, so there is no way to regenerate the preview. - assertEquals(print_preview.State.ERROR, page.state); + assertEquals(State.ERROR, page.state); assertTrue(layoutSettings.$$('select').disabled); assertTrue(scalingSettings.$$('cr-input').disabled); @@ -322,7 +334,7 @@ .then(function() { // Has active print button, indicating recovery from error state. assertFalse(printButton.disabled); - assertEquals(print_preview.State.READY, page.state); + assertEquals(State.READY, page.state); // Settings sections are now active. assertFalse(layoutSettings.$$('select').disabled); @@ -343,13 +355,14 @@ // recovered by selecting a new destination. Tests that even if destination // was previously selected, the error is cleared. test( - assert(TestNames.InvalidCertificateErrorReselectDestination), + assert(invalid_settings_browsertest.TestNames + .InvalidCertificateErrorReselectDestination), function() { const invalidPrinter = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( 'FooDevice', 'FooName', true); const validPrinter = - print_preview_test_utils.createDestinationWithCertificateStatus( + createDestinationWithCertificateStatus( 'BarDevice', 'BarName', false); setupInvalidCertificateTest([validPrinter, invalidPrinter]); @@ -362,12 +375,12 @@ const destinationSettings = sidebar.$$('print-preview-destination-settings'); - return test_util.waitBeforeNextRender(page) + return waitBeforeNextRender(page) .then(() => { const parentElement = sidebar.$$('print-preview-button-strip'); printButton = parentElement.$$('.action-button'); return Promise.all([ - print_preview.Model.whenReady(), + whenReady(), nativeLayer.whenCalled('getInitialSettings'), ]); }) @@ -381,13 +394,13 @@ .then(function() { // Has active print button. assertFalse(printButton.disabled); - assertEquals(print_preview.State.READY, page.state); + assertEquals(State.READY, page.state); // No error message. assertTrue(overlayEl.classList.contains('invisible')); // Select the invalid destination and wait for the event. - const whenInvalid = test_util.eventToPromise( - print_preview.DestinationStore.EventType.ERROR, + const whenInvalid = eventToPromise( + DestinationStore.EventType.ERROR, destinationSettings.destinationStore_); destinationSettings.destinationStore_.selectDestination( invalidPrinter); @@ -396,14 +409,14 @@ .then(function() { // Should have error message. assertFalse(overlayEl.classList.contains('invisible')); - assertEquals(print_preview.State.ERROR, page.state); + assertEquals(State.ERROR, page.state); // Reset nativeLayer.reset(); // Reselect the valid cloud destination. - const whenSelected = test_util.eventToPromise( - print_preview.DestinationStore.EventType.DESTINATION_SELECT, + const whenSelected = eventToPromise( + DestinationStore.EventType.DESTINATION_SELECT, destinationSettings.destinationStore_); destinationSettings.destinationStore_.selectDestination( validPrinter); @@ -416,9 +429,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/key_event_test.js b/chrome/test/data/webui/print_preview/key_event_test.js index 9845705..1c31fce 100644 --- a/chrome/test/data/webui/print_preview/key_event_test.js +++ b/chrome/test/data/webui/print_preview/key_event_test.js
@@ -2,9 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('key_event_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {NativeLayer, PluginProxy} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {eventToPromise, flushTasks} from 'chrome://test/test_util.m.js'; +import {getCddTemplateWithAdvancedSettings, getDefaultInitialSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; +import {isChromeOS, isMac, isWindows} from 'chrome://resources/js/cr.m.js'; + + window.key_event_test = {}; + key_event_test.suiteName = 'KeyEventTest'; /** @enum {string} */ - const TestNames = { + key_event_test.TestNames = { EnterTriggersPrint: 'enter triggers print', NumpadEnterTriggersPrint: 'numpad enter triggers print', EnterOnInputTriggersPrint: 'enter on input triggers print', @@ -16,8 +27,7 @@ CtrlShiftPOpensSystemDialog: 'ctrl shift p opens system dialog', }; - const suiteName = 'KeyEventTest'; - suite(suiteName, function() { + suite(key_event_test.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; @@ -27,17 +37,17 @@ /** @override */ setup(function() { const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); - nativeLayer = new print_preview.NativeLayerStub(); + getDefaultInitialSettings(); + nativeLayer = new NativeLayerStub(); nativeLayer.setInitialSettings(initialSettings); // Use advanced settings so that we can test with the cr-button. nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplateWithAdvancedSettings( + getCddTemplateWithAdvancedSettings( 1, initialSettings.printerName)); nativeLayer.setPageCount(3); - print_preview.NativeLayer.setInstance(nativeLayer); - const pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + NativeLayer.setInstance(nativeLayer); + const pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); PolymerTest.clearBody(); page = document.createElement('print-preview-app'); @@ -51,29 +61,30 @@ nativeLayer.whenCalled('getPrinterCapabilities') ]) .then(function() { - Polymer.dom.flush(); + flush(); }); }); // Tests that the enter key triggers a call to print. - test(assert(TestNames.EnterTriggersPrint), function() { + test(assert(key_event_test.TestNames.EnterTriggersPrint), function() { const whenPrintCalled = nativeLayer.whenCalled('print'); - MockInteractions.keyEventOn(page, 'keydown', 'Enter', [], 'Enter'); + keyEventOn(page, 'keydown', 'Enter', [], 'Enter'); return whenPrintCalled; }); // Tests that the numpad enter key triggers a call to print. - test(assert(TestNames.NumpadEnterTriggersPrint), function() { + test(assert(key_event_test.TestNames.NumpadEnterTriggersPrint), function() { const whenPrintCalled = nativeLayer.whenCalled('print'); - MockInteractions.keyEventOn(page, 'keydown', 'NumpadEnter', [], 'Enter'); + keyEventOn(page, 'keydown', 'NumpadEnter', [], 'Enter'); return whenPrintCalled; }); // Tests that the enter key triggers a call to print if an input is the // source of the event. - test(assert(TestNames.EnterOnInputTriggersPrint), function() { + test(assert(key_event_test.TestNames.EnterOnInputTriggersPrint), + function() { const whenPrintCalled = nativeLayer.whenCalled('print'); - MockInteractions.keyEventOn( + keyEventOn( page.$$('print-preview-sidebar') .$$('print-preview-copies-settings') .$$('print-preview-number-settings-section') @@ -85,9 +96,10 @@ // Tests that the enter key does not trigger a call to print if the event // comes from a dropdown. - test(assert(TestNames.EnterOnDropdownDoesNotPrint), function() { - const whenKeyEventFired = test_util.eventToPromise('keydown', page); - MockInteractions.keyEventOn( + test(assert(key_event_test.TestNames.EnterOnDropdownDoesNotPrint), + function() { + const whenKeyEventFired = eventToPromise('keydown', page); + keyEventOn( page.$$('print-preview-sidebar') .$$('print-preview-layout-settings') .$$('.md-select'), @@ -98,28 +110,30 @@ // Tests that the enter key does not trigger a call to print if the event // comes from a button. - test(assert(TestNames.EnterOnButtonDoesNotPrint), async () => { + test(assert(key_event_test.TestNames.EnterOnButtonDoesNotPrint), + async () => { const moreSettingsElement = page.$$('print-preview-sidebar').$$('print-preview-more-settings'); moreSettingsElement.$.label.click(); const button = page.$$('print-preview-sidebar') .$$('print-preview-advanced-options-settings') .$$('cr-button'); - const whenKeyEventFired = test_util.eventToPromise('keydown', button); - MockInteractions.keyEventOn(button, 'keydown', 'Enter', [], 'Enter'); + const whenKeyEventFired = eventToPromise('keydown', button); + keyEventOn(button, 'keydown', 'Enter', [], 'Enter'); await whenKeyEventFired; - await test_util.flushTasks(); + await flushTasks(); assertEquals(0, nativeLayer.getCallCount('print')); }); // Tests that the enter key does not trigger a call to print if the event // comes from a checkbox. - test(assert(TestNames.EnterOnCheckboxDoesNotPrint), function() { + test(assert(key_event_test.TestNames.EnterOnCheckboxDoesNotPrint), + function() { const moreSettingsElement = page.$$('print-preview-sidebar').$$('print-preview-more-settings'); moreSettingsElement.$.label.click(); - const whenKeyEventFired = test_util.eventToPromise('keydown', page); - MockInteractions.keyEventOn( + const whenKeyEventFired = eventToPromise('keydown', page); + keyEventOn( page.$$('print-preview-sidebar') .$$('print-preview-other-options-settings') .$$('cr-checkbox'), @@ -129,50 +143,47 @@ }); // Tests that escape closes the dialog only on Mac. - test(assert(TestNames.EscapeClosesDialogOnMacOnly), function() { - const promise = cr.isMac ? + test(assert(key_event_test.TestNames.EscapeClosesDialogOnMacOnly), + function() { + const promise = isMac ? nativeLayer.whenCalled('dialogClose') : - test_util.eventToPromise('keydown', page).then(() => { + eventToPromise('keydown', page).then(() => { assertEquals(0, nativeLayer.getCallCount('dialogClose')); }); - MockInteractions.keyEventOn(page, 'keydown', 'Escape', [], 'Escape'); + keyEventOn(page, 'keydown', 'Escape', [], 'Escape'); return promise; }); // Tests that Cmd + Period closes the dialog only on Mac - test(assert(TestNames.CmdPeriodClosesDialogOnMacOnly), function() { - const promise = cr.isMac ? + test(assert(key_event_test.TestNames.CmdPeriodClosesDialogOnMacOnly), + function() { + const promise = isMac ? nativeLayer.whenCalled('dialogClose') : - test_util.eventToPromise('keydown', page).then(() => { + eventToPromise('keydown', page).then(() => { assertEquals(0, nativeLayer.getCallCount('dialogClose')); }); - MockInteractions.keyEventOn( + keyEventOn( page, 'keydown', 'Period', ['meta'], 'Period'); return promise; }); // Tests that Ctrl+Shift+P opens the system dialog. - test(assert(TestNames.CtrlShiftPOpensSystemDialog), function() { + test(assert(key_event_test.TestNames.CtrlShiftPOpensSystemDialog), + function() { let promise = null; - if (cr.isChromeOS) { + if (isChromeOS) { // Chrome OS doesn't have a system dialog. Just make sure the key event // does not trigger a crash. promise = Promise.resolve(); - } else if (cr.isWindows) { + } else if (isWindows) { promise = nativeLayer.whenCalled('print').then((printTicket) => { assertTrue(JSON.parse(printTicket).showSystemDialog); }); } else { promise = nativeLayer.whenCalled('showSystemDialog'); } - const modifiers = cr.isMac ? ['meta', 'alt'] : ['ctrl', 'shift']; - MockInteractions.keyEventOn(page, 'keydown', 'KeyP', modifiers, 'KeyP'); + const modifiers = isMac ? ['meta', 'alt'] : ['ctrl', 'shift']; + keyEventOn(page, 'keydown', 'KeyP', modifiers, 'KeyP'); return promise; }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/layout_settings_test.js b/chrome/test/data/webui/print_preview/layout_settings_test.js index 467ce10..175c07cc 100644 --- a/chrome/test/data/webui/print_preview/layout_settings_test.js +++ b/chrome/test/data/webui/print_preview/layout_settings_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('layout_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('LayoutSettingsTest', function() { let layoutSection = null; @@ -15,7 +19,7 @@ layoutSection = document.createElement('print-preview-layout-settings'); layoutSection.settings = model.settings; layoutSection.disabled = false; - test_util.fakeDataBind(model, layoutSection, 'settings'); + fakeDataBind(model, layoutSection, 'settings'); document.body.appendChild(layoutSection); }); @@ -25,7 +29,7 @@ assertEquals('portrait', select.value); layoutSection.setSetting('layout', true); - await test_util.eventToPromise('process-select-change', layoutSection); + await eventToPromise('process-select-change', layoutSection); assertEquals('landscape', select.value); }); @@ -39,9 +43,8 @@ assertEquals(2, select.options.length); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption(layoutSection, 'landscape'); + await selectOption(layoutSection, 'landscape'); assertTrue(layoutSection.getSettingValue('layout')); assertTrue(layoutSection.getSetting('layout').setFromUi); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/link_container_test.js b/chrome/test/data/webui/print_preview/link_container_test.js index 7954e0d2..d36eaf15 100644 --- a/chrome/test/data/webui/print_preview/link_container_test.js +++ b/chrome/test/data/webui/print_preview/link_container_test.js
@@ -2,17 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('link_container_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {isMac, isWindows} from 'chrome://resources/js/cr.m.js'; + + window.link_container_test = {}; + link_container_test.suiteName = 'LinkContainerTest'; /** @enum {string} */ - const TestNames = { + link_container_test.TestNames = { HideInAppKioskMode: 'hide in app kiosk mode', SystemDialogLinkClick: 'system dialog link click', InvalidState: 'invalid state', OpenInPreviewLinkClick: 'open in preview link click', }; - const suiteName = 'LinkContainerTest'; - suite(suiteName, function() { + suite(link_container_test.suiteName, function() { /** @type {?PrintPreviewLinkContainerElement} */ let linkContainer = null; @@ -23,20 +29,18 @@ document.body.appendChild(linkContainer); /** Set inputs to some defaults. */ - const fooDestination = new print_preview.Destination( - 'FooPrinter', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'Foo Printer', - print_preview.DestinationConnectionStatus.ONLINE); + const fooDestination = new Destination( + 'FooPrinter', DestinationType.LOCAL, DestinationOrigin.LOCAL, + 'Foo Printer', DestinationConnectionStatus.ONLINE); fooDestination.capabilities = - print_preview_test_utils.getCddTemplate(fooDestination.id) - .capabilities; + getCddTemplate(fooDestination.id).capabilities; linkContainer.destination = fooDestination; linkContainer.appKioskMode = false; linkContainer.disabled = false; }); /** Tests that the system dialog link is hidden in App Kiosk mode. */ - test(assert(TestNames.HideInAppKioskMode), function() { + test(assert(link_container_test.TestNames.HideInAppKioskMode), function() { const systemDialogLink = linkContainer.$.systemDialogLink; assertFalse(systemDialogLink.hidden); linkContainer.set('appKioskMode', true); @@ -47,15 +51,16 @@ * Test that clicking the system dialog link click results in an event * firing, and the throbber appears on non-Windows. */ - test(assert(TestNames.SystemDialogLinkClick), function() { + test(assert(link_container_test.TestNames.SystemDialogLinkClick), + function() { const promise = - test_util.eventToPromise('print-with-system-dialog', linkContainer); + eventToPromise('print-with-system-dialog', linkContainer); const throbber = linkContainer.$.systemDialogThrobber; assertTrue(throbber.hidden); linkContainer.$.systemDialogLink.click(); return promise.then(function() { - assertEquals(cr.isWindows, throbber.hidden); + assertEquals(isWindows, throbber.hidden); }); }); @@ -64,10 +69,10 @@ * (if it exists), and that the system dialog link is disabled on Windows * and enabled on other platforms. */ - test(assert(TestNames.InvalidState), function() { + test(assert(link_container_test.TestNames.InvalidState), function() { const systemDialogLink = linkContainer.$.systemDialogLink; const openInPreviewLink = - cr.isMac ? linkContainer.$.openPdfInPreviewLink : null; + isMac ? linkContainer.$.openPdfInPreviewLink : null; const validateLinkState = (link, disabled) => { assertFalse(link.hidden); @@ -76,15 +81,15 @@ }; validateLinkState(systemDialogLink, false); - if (cr.isMac) { + if (isMac) { validateLinkState(openInPreviewLink, false); } // Set disabled to true, indicating that there is a validation error or // printer error. linkContainer.disabled = true; - validateLinkState(systemDialogLink, cr.isWindows); - if (cr.isMac) { + validateLinkState(systemDialogLink, isWindows); + if (isMac) { validateLinkState(openInPreviewLink, true); } }); @@ -93,11 +98,12 @@ * Test that clicking the open in preview link correctly results in a * property change and that the throbber appears. Mac only. */ - test(assert(TestNames.OpenInPreviewLinkClick), function() { + test(assert(link_container_test.TestNames.OpenInPreviewLinkClick), + function() { const throbber = linkContainer.$.openPdfInPreviewThrobber; assertTrue(throbber.hidden); const promise = - test_util.eventToPromise('open-pdf-in-preview', linkContainer); + eventToPromise('open-pdf-in-preview', linkContainer); linkContainer.$.openPdfInPreviewLink.click(); return promise.then(function() { @@ -105,9 +111,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/margins_settings_test.js b/chrome/test/data/webui/print_preview/margins_settings_test.js index e55b1ca..1ee0753f 100644 --- a/chrome/test/data/webui/print_preview/margins_settings_test.js +++ b/chrome/test/data/webui/print_preview/margins_settings_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('margins_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {MarginsType} from 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('MarginsSettingsTest', function() { let marginsSection = null; @@ -18,8 +22,8 @@ document.body.appendChild(marginsSection); marginsSection.settings = model.settings; marginsSection.disabled = false; - test_util.fakeDataBind(model, marginsSection, 'settings'); - marginsTypeEnum = print_preview.MarginsType; + fakeDataBind(model, marginsSection, 'settings'); + marginsTypeEnum = MarginsType; }); // Tests that setting the setting updates the UI. @@ -28,7 +32,7 @@ assertEquals(marginsTypeEnum.DEFAULT.toString(), select.value); marginsSection.setSetting('margins', marginsTypeEnum.MINIMUM); - await test_util.eventToPromise('process-select-change', marginsSection); + await eventToPromise('process-select-change', marginsSection); assertEquals(marginsTypeEnum.MINIMUM.toString(), select.value); }); @@ -43,7 +47,7 @@ assertFalse(marginsSection.getSetting('margins').setFromUi); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption( + await selectOption( marginsSection, marginsTypeEnum.MINIMUM.toString()); assertEquals( marginsTypeEnum.MINIMUM, marginsSection.getSettingValue('margins')); @@ -63,4 +67,3 @@ assertFalse(select.disabled); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/media_size_settings_test.js b/chrome/test/data/webui/print_preview/media_size_settings_test.js index adfe9ef..bc19c84 100644 --- a/chrome/test/data/webui/print_preview/media_size_settings_test.js +++ b/chrome/test/data/webui/print_preview/media_size_settings_test.js
@@ -2,14 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('media_size_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('MediaSizeSettingsTest', function() { /** @type {?PrintPreviewMediaSizeSettingsElement} */ let mediaSizeSection = null; const mediaSizeCapability = - print_preview_test_utils.getCddTemplate('FooPrinter') - .capabilities.printer.media_size; + getCddTemplate('FooPrinter').capabilities.printer.media_size; /** @override */ setup(function() { PolymerTest.clearBody(); @@ -22,7 +25,7 @@ mediaSizeSection.capability = mediaSizeCapability; mediaSizeSection.disabled = false; model.set('settings.mediaSize.available', true); - test_util.fakeDataBind(model, mediaSizeSection, 'settings'); + fakeDataBind(model, mediaSizeSection, 'settings'); document.body.appendChild(mediaSizeSection); }); @@ -67,4 +70,3 @@ assertDeepEquals(letterOption, JSON.parse(settingsSelect.selectedValue)); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/model_settings_availability_test.js b/chrome/test/data/webui/print_preview/model_settings_availability_test.js index 204f775..e6a340b 100644 --- a/chrome/test/data/webui/print_preview/model_settings_availability_test.js +++ b/chrome/test/data/webui/print_preview/model_settings_availability_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('model_settings_availability_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS, isMac, isWindows} from 'chrome://resources/js/cr.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, DuplexType, Margins, MarginsType, Size} from 'chrome://print/print_preview.js'; +import {getCddTemplate, getGoogleDriveDestination, getSaveAsPdfDestination} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('ModelSettingsAvailabilityTest', function() { let model = null; @@ -24,17 +28,17 @@ title: 'title', }; - model.pageSize = new print_preview.Size(612, 792); - model.margins = new print_preview.Margins(72, 72, 72, 72); + model.pageSize = new Size(612, 792); + model.margins = new Margins(72, 72, 72, 72); // Create a test destination. - model.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); + model.destination = new Destination( + 'FooDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'FooName', + DestinationConnectionStatus.ONLINE); model.set( 'destination.capabilities', - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities); model.applyStickySettings(); }); @@ -46,7 +50,7 @@ // Remove copies capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.copies; model.set('destination.capabilities', capabilities); @@ -56,7 +60,7 @@ // Copies is restored. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; model.set('destination.capabilities', capabilities); assertTrue(model.settings.copies.available); @@ -68,7 +72,7 @@ // Remove collate capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.collate; model.set('destination.capabilities', capabilities); @@ -78,7 +82,7 @@ // Copies is restored. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; model.set('destination.capabilities', capabilities); assertTrue(model.settings.collate.available); @@ -96,7 +100,7 @@ {option: [{type: 'LANDSCAPE', is_default: true}]}, ].forEach(layoutCap => { const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.page_orientation = layoutCap; // Layout section should now be hidden. @@ -106,7 +110,7 @@ // Reset full capabilities const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; model.set('destination.capabilities', capabilities); assertTrue(model.settings.layout.available); @@ -173,7 +177,7 @@ expectedValue: true, }].forEach(capabilityAndValue => { const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.color = capabilityAndValue.colorCap; model.set('destination.capabilities', capabilities); @@ -213,7 +217,7 @@ expectedValue: true, }].forEach(capabilityAndValue => { const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.color = capabilityAndValue.colorCap; model.set('destination.capabilities', capabilities); @@ -224,13 +228,9 @@ // Google Drive always has an unavailableValue of true. model.set( - 'destination', - print_preview_test_utils.getGoogleDriveDestination( - 'foo@chromium.org')); + 'destination', getGoogleDriveDestination('foo@chromium.org')); const capabilities = - print_preview_test_utils - .getCddTemplate(print_preview.Destination.GooglePromotedId.DOCS) - .capabilities; + getCddTemplate(Destination.GooglePromotedId.DOCS).capabilities; delete capabilities.printer.color; model.set('destination.capabilities', capabilities); assertFalse(model.settings.color.available); @@ -239,9 +239,9 @@ }); function setSaveAsPdfDestination() { - const saveAsPdf = print_preview_test_utils.getSaveAsPdfDestination(); + const saveAsPdf = getSaveAsPdfDestination(); saveAsPdf.capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; model.set('destination', saveAsPdf); } @@ -252,7 +252,7 @@ // Remove capability. const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.media_size; @@ -311,7 +311,7 @@ // Remove capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.dpi; @@ -322,7 +322,7 @@ // Does not show up for only 1 option. Unavailable value should be set to // the only available option. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.dpi.option.pop(); model.set('destination.capabilities', capabilities); @@ -449,11 +449,11 @@ assertTrue(model.settings.headerFooter.available); // Set margins to NONE - model.set('settings.margins.value', print_preview.MarginsType.NO_MARGINS); + model.set('settings.margins.value', MarginsType.NO_MARGINS); assertFalse(model.settings.headerFooter.available); // Custom margins of 0. - model.set('settings.margins.value', print_preview.MarginsType.CUSTOM); + model.set('settings.margins.value', MarginsType.CUSTOM); model.set( 'settings.customMargins.value', {marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}); @@ -479,7 +479,7 @@ // Small paper sizes const capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.media_size = { 'option': [ @@ -498,7 +498,7 @@ ] }; model.set('destination.capabilities', capabilities); - model.set('settings.margins.value', print_preview.MarginsType.DEFAULT); + model.set('settings.margins.value', MarginsType.DEFAULT); // Header/footer should be available for default big label with // default margins. @@ -549,7 +549,7 @@ // Remove duplex capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.duplex; model.set('destination.capabilities', capabilities); @@ -558,11 +558,11 @@ // Set a duplex capability with only 1 type, no duplex. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.duplex; capabilities.printer.duplex = { - option: [{type: print_preview.DuplexType.NO_DUPLEX, is_default: true}] + option: [{type: DuplexType.NO_DUPLEX, is_default: true}] }; model.set('destination.capabilities', capabilities); assertFalse(model.settings.duplex.available); @@ -570,13 +570,13 @@ // Set a duplex capability with 2 types, long edge and no duplex. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.duplex; capabilities.printer.duplex = { option: [ - {type: print_preview.DuplexType.NO_DUPLEX}, - {type: print_preview.DuplexType.LONG_EDGE, is_default: true} + {type: DuplexType.NO_DUPLEX}, + {type: DuplexType.LONG_EDGE, is_default: true} ] }; model.set('destination.capabilities', capabilities); @@ -592,7 +592,7 @@ // Available on non-Windows and Mac for PDFs. model.set('documentSettings.isModifiable', false); assertEquals( - !cr.isWindows && !cr.isMac, model.settings.rasterize.available); + !isWindows && !isMac, model.settings.rasterize.available); assertFalse(model.settings.rasterize.setFromUi); // Unavailable for ARC. @@ -644,7 +644,7 @@ assertFalse(model.settings.pagesPerSheet.available); }); - if (cr.isChromeOS) { + if (isChromeOS) { test('pin', function() { // Make device unmanaged. loadTimeData.overrideValues({isEnterpriseManaged: false}); @@ -656,13 +656,13 @@ // Set capabilities again to update pin availability. model.set( 'destination.capabilities', - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities); assertTrue(model.settings.pin.available); // Remove pin capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.pin; model.set('destination.capabilities', capabilities); @@ -670,7 +670,7 @@ // Set not supported pin capability. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.pin.supported = false; model.set('destination.capabilities', capabilities); @@ -683,7 +683,7 @@ // Remove pin capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.pin; model.set('destination.capabilities', capabilities); @@ -691,7 +691,7 @@ // Set not supported pin capability. capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.pin.supported = false; model.set('destination.capabilities', capabilities); @@ -700,4 +700,3 @@ }); } }); -});
diff --git a/chrome/test/data/webui/print_preview/model_settings_policy_test.js b/chrome/test/data/webui/print_preview/model_settings_policy_test.js index ae3a1f4..7cd4566 100644 --- a/chrome/test/data/webui/print_preview/model_settings_policy_test.js +++ b/chrome/test/data/webui/print_preview/model_settings_policy_test.js
@@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('model_settings_policy_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {BackgroundGraphicsModeRestriction, ColorModeRestriction, Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, DuplexModeRestriction, Margins, MarginsType, PinModeRestriction, Size} from 'chrome://print/print_preview.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('ModelSettingsPolicyTest', function() { let model = null; @@ -22,32 +25,32 @@ title: 'title', }; - model.pageSize = new print_preview.Size(612, 792); - model.margins = new print_preview.Margins(72, 72, 72, 72); + model.pageSize = new Size(612, 792); + model.margins = new Margins(72, 72, 72, 72); // Create a test destination. - model.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); + model.destination = new Destination( + 'FooDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'FooName', + DestinationConnectionStatus.ONLINE); model.set( 'destination.capabilities', - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities); }); test('color managed', function() { // Remove color capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.color; [{ // Policy has no effect, setting unavailable colorCap: {option: [{type: 'STANDARD_COLOR', is_default: true}]}, - colorPolicy: print_preview.ColorModeRestriction.COLOR, - colorDefault: print_preview.ColorModeRestriction.COLOR, + colorPolicy: ColorModeRestriction.COLOR, + colorDefault: ColorModeRestriction.COLOR, expectedValue: true, expectedAvailable: false, expectedManaged: false, @@ -56,8 +59,8 @@ { // Policy contradicts actual capabilities, setting unavailable. colorCap: {option: [{type: 'STANDARD_COLOR', is_default: true}]}, - colorPolicy: print_preview.ColorModeRestriction.MONOCHROME, - colorDefault: print_preview.ColorModeRestriction.MONOCHROME, + colorPolicy: ColorModeRestriction.MONOCHROME, + colorDefault: ColorModeRestriction.MONOCHROME, expectedValue: true, expectedAvailable: false, expectedManaged: false, @@ -71,9 +74,9 @@ {type: 'STANDARD_COLOR'} ] }, - colorPolicy: print_preview.ColorModeRestriction.COLOR, + colorPolicy: ColorModeRestriction.COLOR, // Default mismatches restriction and is ignored. - colorDefault: print_preview.ColorModeRestriction.MONOCHROME, + colorDefault: ColorModeRestriction.MONOCHROME, expectedValue: true, expectedAvailable: true, expectedManaged: true, @@ -87,14 +90,14 @@ {type: 'STANDARD_COLOR'} ] }, - colorDefault: print_preview.ColorModeRestriction.COLOR, + colorDefault: ColorModeRestriction.COLOR, expectedValue: true, expectedAvailable: true, expectedManaged: false, expectedEnforced: false, }].forEach(subtestParams => { capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.color = subtestParams.colorCap; const policies = { @@ -119,15 +122,15 @@ test('duplex managed', function() { // Remove duplex capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.duplex; [{ // Policy has no effect. duplexCap: {option: [{type: 'NO_DUPLEX', is_default: true}]}, - duplexPolicy: print_preview.DuplexModeRestriction.SIMPLEX, - duplexDefault: print_preview.DuplexModeRestriction.SIMPLEX, + duplexPolicy: DuplexModeRestriction.SIMPLEX, + duplexDefault: DuplexModeRestriction.SIMPLEX, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -139,8 +142,8 @@ { // Policy contradicts actual capabilities and is ignored. duplexCap: {option: [{type: 'NO_DUPLEX', is_default: true}]}, - duplexPolicy: print_preview.DuplexModeRestriction.DUPLEX, - duplexDefault: print_preview.DuplexModeRestriction.LONG_EDGE, + duplexPolicy: DuplexModeRestriction.DUPLEX, + duplexDefault: DuplexModeRestriction.LONG_EDGE, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -157,9 +160,9 @@ {type: 'SHORT_EDGE'} ] }, - duplexPolicy: print_preview.DuplexModeRestriction.DUPLEX, + duplexPolicy: DuplexModeRestriction.DUPLEX, // Default mismatches restriction and is ignored. - duplexDefault: print_preview.DuplexModeRestriction.SIMPLEX, + duplexDefault: DuplexModeRestriction.SIMPLEX, expectedValue: true, expectedAvailable: true, expectedManaged: true, @@ -176,9 +179,9 @@ {type: 'SHORT_EDGE'} ] }, - duplexPolicy: print_preview.DuplexModeRestriction.SHORT_EDGE, + duplexPolicy: DuplexModeRestriction.SHORT_EDGE, // Default mismatches restriction and is ignored. - duplexDefault: print_preview.DuplexModeRestriction.LONG_EDGE, + duplexDefault: DuplexModeRestriction.LONG_EDGE, expectedValue: true, expectedAvailable: true, expectedManaged: true, @@ -195,7 +198,7 @@ {type: 'SHORT_EDGE'} ] }, - duplexDefault: print_preview.DuplexModeRestriction.LONG_EDGE, + duplexDefault: DuplexModeRestriction.LONG_EDGE, expectedValue: true, expectedAvailable: true, expectedManaged: false, @@ -205,7 +208,7 @@ expectedShortEdgeEnforced: false, }].forEach(subtestParams => { capabilities = - print_preview_test_utils.getCddTemplate('FooPrinter').capabilities; + getCddTemplate('FooPrinter').capabilities; capabilities.printer.duplex = subtestParams.duplexCap; const policies = { allowedDuplexModes: subtestParams.duplexPolicy, @@ -238,7 +241,7 @@ test('pin managed', function() { // Remove pin capability. let capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; delete capabilities.printer.pin; @@ -257,8 +260,8 @@ { // Policy has no effect, setting unavailable. pinCap: {}, - pinPolicy: print_preview.PinModeRestriction.PIN, - pinDefault: print_preview.PinModeRestriction.PIN, + pinPolicy: PinModeRestriction.PIN, + pinDefault: PinModeRestriction.PIN, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -267,8 +270,8 @@ { // Policy has no effect, setting is not supported. pinCap: {supported: false}, - pinPolicy: print_preview.PinModeRestriction.UNSET, - pinDefault: print_preview.PinModeRestriction.PIN, + pinPolicy: PinModeRestriction.UNSET, + pinDefault: PinModeRestriction.PIN, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -277,7 +280,7 @@ { // Policy is UNSECURE, setting is not available. pinCap: {supported: true}, - pinPolicy: print_preview.PinModeRestriction.NO_PIN, + pinPolicy: PinModeRestriction.NO_PIN, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -286,8 +289,8 @@ { // No restriction policy, setting is modifiable. pinCap: {supported: true}, - pinPolicy: print_preview.PinModeRestriction.UNSET, - pinDefault: print_preview.PinModeRestriction.NO_PIN, + pinPolicy: PinModeRestriction.UNSET, + pinDefault: PinModeRestriction.NO_PIN, expectedValue: false, expectedAvailable: true, expectedManaged: false, @@ -296,9 +299,9 @@ { // Policy overrides default. pinCap: {supported: true}, - pinPolicy: print_preview.PinModeRestriction.PIN, + pinPolicy: PinModeRestriction.PIN, // Default mismatches restriction and is ignored. - pinDefault: print_preview.PinModeRestriction.NO_PIN, + pinDefault: PinModeRestriction.NO_PIN, expectedValue: true, expectedAvailable: true, expectedManaged: true, @@ -307,14 +310,14 @@ { // Default defined by policy but setting is modifiable. pinCap: {supported: true}, - pinDefault: print_preview.PinModeRestriction.PIN, + pinDefault: PinModeRestriction.PIN, expectedValue: true, expectedAvailable: true, expectedManaged: false, expectedEnforced: false, }].forEach(subtestParams => { capabilities = - print_preview_test_utils.getCddTemplate(model.destination.id) + getCddTemplate(model.destination.id) .capabilities; capabilities.printer.pin = subtestParams.pinCap; const policies = { @@ -349,9 +352,9 @@ // content. documentIsModifiable: false, backgroundGraphicsPolicy: - print_preview.BackgroundGraphicsModeRestriction.UNSET, + BackgroundGraphicsModeRestriction.UNSET, backgroundGraphicsDefault: - print_preview.BackgroundGraphicsModeRestriction.ENABLED, + BackgroundGraphicsModeRestriction.ENABLED, expectedValue: false, expectedAvailable: false, expectedManaged: false, @@ -361,7 +364,7 @@ // Policy is DISABLED, setting is not modifiable. documentIsModifiable: true, backgroundGraphicsPolicy: - print_preview.BackgroundGraphicsModeRestriction.DISABLED, + BackgroundGraphicsModeRestriction.DISABLED, expectedValue: false, expectedAvailable: true, expectedManaged: true, @@ -371,9 +374,9 @@ // No restriction policy, setting is modifiable. documentIsModifiable: true, backgroundGraphicsPolicy: - print_preview.BackgroundGraphicsModeRestriction.UNSET, + BackgroundGraphicsModeRestriction.UNSET, backgroundGraphicsDefault: - print_preview.BackgroundGraphicsModeRestriction.DISABLED, + BackgroundGraphicsModeRestriction.DISABLED, expectedValue: false, expectedAvailable: true, expectedManaged: false, @@ -383,10 +386,10 @@ // Policy overrides default. documentIsModifiable: true, backgroundGraphicsPolicy: - print_preview.BackgroundGraphicsModeRestriction.ENABLED, + BackgroundGraphicsModeRestriction.ENABLED, // Default mismatches restriction and is ignored. backgroundGraphicsDefault: - print_preview.BackgroundGraphicsModeRestriction.DISABLED, + BackgroundGraphicsModeRestriction.DISABLED, expectedValue: true, expectedAvailable: true, expectedManaged: true, @@ -396,7 +399,7 @@ // Default defined by policy but setting is modifiable. documentIsModifiable: true, backgroundGraphicsDefault: - print_preview.BackgroundGraphicsModeRestriction.ENABLED, + BackgroundGraphicsModeRestriction.ENABLED, expectedValue: true, expectedAvailable: true, expectedManaged: false, @@ -426,4 +429,3 @@ }); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/model_test.js b/chrome/test/data/webui/print_preview/model_test.js index 78b5f170..4da7226 100644 --- a/chrome/test/data/webui/print_preview/model_test.js +++ b/chrome/test/data/webui/print_preview/model_test.js
@@ -2,9 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('model_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, DuplexMode, MarginsType, PrinterType, ScalingType, Size} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {getCddTemplateWithAdvancedSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.model_test = {}; + model_test.suiteName = 'ModelTest'; /** @enum {string} */ - const TestNames = { + model_test.TestNames = { SetStickySettings: 'set sticky settings', SetPolicySettings: 'set policy settings', GetPrintTicket: 'get print ticket', @@ -12,8 +20,7 @@ ChangeDestination: 'change destination' }; - const suiteName = 'ModelTest'; - suite(suiteName, function() { + suite(model_test.suiteName, function() { let model = null; /** @override */ @@ -27,7 +34,7 @@ * Tests state restoration with all boolean settings set to true, scaling = * 90, dpi = 100, custom square paper, and custom margins. */ - test(assert(TestNames.SetStickySettings), function() { + test(assert(model_test.TestNames.SetStickySettings), function() { // Default state of the model. const stickySettingsDefault = { version: 2, @@ -36,8 +43,8 @@ mediaSize: {}, marginsType: 0, /* default */ scaling: '100', - scalingType: print_preview.ScalingType.DEFAULT, - scalingTypePdf: print_preview.ScalingType.DEFAULT, + scalingType: ScalingType.DEFAULT, + scalingTypePdf: ScalingType.DEFAULT, isHeaderFooterEnabled: true, isCssBackgroundEnabled: false, isCollateEnabled: true, @@ -47,7 +54,7 @@ isColorEnabled: true, vendorOptions: {}, }; - if (cr.isChromeOS) { + if (isChromeOS) { stickySettingsDefault.isPinEnabled = false; stickySettingsDefault.pinValue = ''; } @@ -60,8 +67,8 @@ mediaSize: {width_microns: 43180, height_microns: 21590}, marginsType: 2, /* none */ scaling: '85', - scalingType: print_preview.ScalingType.CUSTOM, - scalingTypePdf: print_preview.ScalingType.FIT_TO_PAGE, + scalingType: ScalingType.CUSTOM, + scalingTypePdf: ScalingType.FIT_TO_PAGE, isHeaderFooterEnabled: false, isCssBackgroundEnabled: true, isCollateEnabled: false, @@ -74,7 +81,7 @@ printArea: 6, }, }; - if (cr.isChromeOS) { + if (isChromeOS) { stickySettingsChange.isPinEnabled = true; stickySettingsChange.pinValue = '0000'; } @@ -91,7 +98,7 @@ */ const testStickySetting = function(setting, field) { const promise = - test_util.eventToPromise('sticky-setting-changed', model); + eventToPromise('sticky-setting-changed', model); model.setSetting(setting, stickySettingsChange[field]); settingsSet.push(field); return promise.then( @@ -113,7 +120,7 @@ } }); const restorePromise = - test_util.eventToPromise('sticky-setting-changed', model); + eventToPromise('sticky-setting-changed', model); model.setSetting(setting, stickySettingsDefault[field]); return restorePromise; }); @@ -141,7 +148,7 @@ .then(() => testStickySetting('scalingType', 'scalingType')) .then(() => testStickySetting('scalingTypePdf', 'scalingTypePdf')) .then(() => testStickySetting('vendorItems', 'vendorOptions')); - if (cr.isChromeOS) { + if (isChromeOS) { promise = promise.then(() => testStickySetting('pin', 'isPinEnabled')) .then(() => testStickySetting('pinValue', 'pinValue')); } @@ -152,7 +159,7 @@ * Tests that setSetting() won't change the value if there is already a * policy for that setting. */ - test(assert(TestNames.SetPolicySettings), function() { + test(assert(model_test.TestNames.SetPolicySettings), function() { model.setSetting('headerFooter', false); assertFalse(model.settings.headerFooter.value); @@ -177,7 +184,7 @@ assertTrue(model.settings.headerFooter.value); }); - /** @param {!print_preview.Destination} testDestination */ + /** @param {!Destination} testDestination */ function toggleSettings(testDestination) { const settingsChange = { pages: [2], @@ -186,7 +193,7 @@ layout: true, color: false, mediaSize: testDestination.capabilities.printer.media_size.option[1], - margins: print_preview.MarginsType.CUSTOM, + margins: MarginsType.CUSTOM, customMargins: { marginTop: 100, marginRight: 200, @@ -198,8 +205,8 @@ vertical_dpi: 100, }, scaling: '90', - scalingType: print_preview.ScalingType.CUSTOM, - scalingTypePdf: print_preview.ScalingType.CUSTOM, + scalingType: ScalingType.CUSTOM, + scalingTypePdf: ScalingType.CUSTOM, duplex: true, duplexShortEdge: true, cssBackground: true, @@ -212,7 +219,7 @@ }, ranges: [{from: 2, to: 2}], }; - if (cr.isChromeOS) { + if (isChromeOS) { settingsChange.pin = true; settingsChange.pinValue = '0000'; } @@ -234,7 +241,7 @@ pageCount: 3, title: 'title', }; - model.pageSize = new print_preview.Size(612, 792); + model.pageSize = new Size(612, 792); // Update pages accordingly. model.set('settings.pages.value', [1, 2, 3]); @@ -252,17 +259,16 @@ * Tests that toggling each setting results in the expected change to the * print ticket. */ - test(assert(TestNames.GetPrintTicket), function() { - const origin = cr.isChromeOS ? print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL; - const testDestination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.LOCAL, origin, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); + test(assert(model_test.TestNames.GetPrintTicket), function() { + const origin = isChromeOS ? DestinationOrigin.CROS : + DestinationOrigin.LOCAL; + const testDestination = new Destination( + 'FooDevice', DestinationType.LOCAL, origin, 'FooName', + DestinationConnectionStatus.ONLINE); testDestination.capabilities = - print_preview_test_utils.getCddTemplateWithAdvancedSettings(2) - .capabilities; + getCddTemplateWithAdvancedSettings(2).capabilities; - if (cr.isChromeOS) { + if (isChromeOS) { // Make device managed. It's used for testing pin setting behavior. loadTimeData.overrideValues({isEnterpriseManaged: true}); } @@ -277,18 +283,18 @@ landscape: false, color: testDestination.getNativeColorModel(true), headerFooterEnabled: false, // Only used in print preview - marginsType: print_preview.MarginsType.DEFAULT, - duplex: print_preview.DuplexMode.SIMPLEX, + marginsType: MarginsType.DEFAULT, + duplex: DuplexMode.SIMPLEX, copies: 1, collate: true, shouldPrintBackgrounds: false, shouldPrintSelectionOnly: false, previewModifiable: true, printToGoogleDrive: false, - printerType: print_preview.PrinterType.LOCAL_PRINTER, + printerType: PrinterType.LOCAL_PRINTER, rasterizePDF: false, scaleFactor: 100, - scalingType: print_preview.ScalingType.DEFAULT, + scalingType: ScalingType.DEFAULT, pagesPerSheet: 1, dpiHorizontal: 200, dpiVertical: 200, @@ -298,7 +304,7 @@ pageHeight: 792, showSystemDialog: false, }; - if (cr.isChromeOS) { + if (isChromeOS) { expectedDefaultTicketObject.advancedSettings = { printArea: 4, paperType: 0, @@ -315,18 +321,18 @@ landscape: true, color: testDestination.getNativeColorModel(false), headerFooterEnabled: false, - marginsType: print_preview.MarginsType.CUSTOM, - duplex: print_preview.DuplexMode.SHORT_EDGE, + marginsType: MarginsType.CUSTOM, + duplex: DuplexMode.SHORT_EDGE, copies: 2, collate: false, shouldPrintBackgrounds: true, shouldPrintSelectionOnly: false, // Only for Print Preview. previewModifiable: true, printToGoogleDrive: false, - printerType: print_preview.PrinterType.LOCAL_PRINTER, + printerType: PrinterType.LOCAL_PRINTER, rasterizePDF: true, scaleFactor: 90, - scalingType: print_preview.ScalingType.CUSTOM, + scalingType: ScalingType.CUSTOM, pagesPerSheet: 1, dpiHorizontal: 100, dpiVertical: 100, @@ -342,7 +348,7 @@ marginLeft: 400, }, }; - if (cr.isChromeOS) { + if (isChromeOS) { expectedNewTicketObject.pinValue = '0000'; expectedNewTicketObject.advancedSettings = { printArea: 6, @@ -357,17 +363,16 @@ * Tests that toggling each setting results in the expected change to the * cloud job print ticket. */ - test(assert(TestNames.GetCloudPrintTicket), function() { + test(assert(model_test.TestNames.GetCloudPrintTicket), function() { initializeModel(); // Create a test cloud destination. - const testDestination = new print_preview.Destination( - 'FooCloudDevice', print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, 'FooCloudName', - print_preview.DestinationConnectionStatus.ONLINE); + const testDestination = new Destination( + 'FooCloudDevice', DestinationType.GOOGLE, + DestinationOrigin.COOKIES, 'FooCloudName', + DestinationConnectionStatus.ONLINE); testDestination.capabilities = - print_preview_test_utils.getCddTemplateWithAdvancedSettings(2) - .capabilities; + getCddTemplateWithAdvancedSettings(2).capabilities; model.destination = testDestination; const defaultTicket = model.createCloudJobTicket(testDestination); @@ -427,14 +432,13 @@ expectEquals(expectedNewTicket, newTicket); }); - test(assert(TestNames.ChangeDestination), function() { - const testDestination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); + test(assert(model_test.TestNames.ChangeDestination), function() { + const testDestination = new Destination( + 'FooDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'FooName', + DestinationConnectionStatus.ONLINE); testDestination.capabilities = - print_preview_test_utils.getCddTemplateWithAdvancedSettings(2) - .capabilities; + getCddTemplateWithAdvancedSettings(2).capabilities; // Make black and white printing the default. testDestination.capabilities.printer.color = { option: [ @@ -443,10 +447,10 @@ ] }; - const testDestination2 = new print_preview.Destination( - 'BarDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'BarName', - print_preview.DestinationConnectionStatus.ONLINE); + const testDestination2 = new Destination( + 'BarDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'BarName', + DestinationConnectionStatus.ONLINE); testDestination2.capabilities = Object.assign({}, testDestination.capabilities); @@ -486,10 +490,10 @@ assertEquals(oldSettings, newSettings); // Create a printer with different capabilities. - const testDestination3 = new print_preview.Destination( - 'Device1', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'One', - print_preview.DestinationConnectionStatus.ONLINE); + const testDestination3 = new Destination( + 'Device1', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'One', + DestinationConnectionStatus.ONLINE); testDestination3.capabilities = Object.assign({}, testDestination.capabilities); testDestination3.capabilities.printer.media_size = { @@ -521,7 +525,7 @@ }; model.destination = testDestination3; - Polymer.dom.flush(); + flush(); // Verify things changed. const updatedSettings = JSON.stringify(model.settings); @@ -532,9 +536,3 @@ assertEquals(false, model.getSettingValue('duplex')); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/native_layer_stub.js b/chrome/test/data/webui/print_preview/native_layer_stub.js index c630dc8..46349c11 100644 --- a/chrome/test/data/webui/print_preview/native_layer_stub.js +++ b/chrome/test/data/webui/print_preview/native_layer_stub.js
@@ -2,11 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { +import {Destination, PrinterType} from 'chrome://print/print_preview.js'; +import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; +import {getPdfPrinter} from 'chrome://test/print_preview/print_preview_test_utils.js'; + /** * Test version of the native layer. */ - class NativeLayerStub extends TestBrowserProxy { + export class NativeLayerStub extends TestBrowserProxy { constructor() { super([ 'dialogClose', @@ -23,7 +26,7 @@ ]); /** - * @private {!print_preview.NativeInitialSettings} The initial settings + * @private {!NativeInitialSettings} The initial settings * to be used for the response to a |getInitialSettings| call. */ this.initialSettings_ = null; @@ -32,27 +35,27 @@ this.accounts_ = null; /** - * @private {!Array<!print_preview.LocalDestinationInfo>} Local + * @private {!Array<!LocalDestinationInfo>} Local * destination list to be used for the response to |getPrinters|. */ this.localDestinationInfos_ = []; /** - * @private {!Array<!print_preview.ProvisionalDestinationInfo>} Local + * @private {!Array<!ProvisionalDestinationInfo>} Local * destination list to be used for the response to |getPrinters|. */ this.extensionDestinationInfos_ = []; /** * @private {!Map<string, - * !Promise<!print_preview.CapabilitiesResponse>} + * !Promise<!CapabilitiesResponse>} * A map from destination IDs to the responses to be sent when * |getPrinterCapabilities| is called for the ID. */ this.localDestinationCapabilities_ = new Map(); /** - * @private {!print_preview.PrinterSetupResponse} The response to be sent + * @private {!PrinterSetupResponse} The response to be sent * on a |setupPrinter| call. */ this.setupPrinterResponse_ = null; @@ -71,7 +74,7 @@ /** @private {number} The number of total pages in the document. */ this.pageCount_ = 1; - /** @private {?print_preview.PageLayoutInfo} Page layout information */ + /** @private {?PageLayoutInfo} Page layout information */ this.pageLayoutInfo_ = null; } @@ -94,12 +97,12 @@ /** @override */ getPrinters(type) { this.methodCalled('getPrinters', type); - if (type == print_preview.PrinterType.LOCAL_PRINTER && + if (type == PrinterType.LOCAL_PRINTER && this.localDestinationInfos_.length > 0) { cr.webUIListenerCallback( 'printers-added', type, this.localDestinationInfos_); } else if ( - type == print_preview.PrinterType.EXTENSION_PRINTER && + type == PrinterType.EXTENSION_PRINTER && this.extensionDestinationInfos_.length > 0) { cr.webUIListenerCallback( 'printers-added', type, this.extensionDestinationInfos_); @@ -154,13 +157,13 @@ this.methodCalled( 'getPrinterCapabilities', {destinationId: printerId, printerType: type}); - if (printerId == print_preview.Destination.GooglePromotedId.SAVE_AS_PDF) { + if (printerId == Destination.GooglePromotedId.SAVE_AS_PDF) { return Promise.resolve({ deviceName: 'Save as PDF', - capabilities: print_preview_test_utils.getPdfPrinter(), + capabilities: getPdfPrinter(), }); } - if (type != print_preview.PrinterType.LOCAL_PRINTER) { + if (type != PrinterType.LOCAL_PRINTER) { return Promise.reject(); } return this.localDestinationCapabilities_.get(printerId) || @@ -171,7 +174,7 @@ print(printTicket) { this.methodCalled('print', printTicket); if (JSON.parse(printTicket).printerType == - print_preview.PrinterType.CLOUD_PRINTER) { + PrinterType.CLOUD_PRINTER) { return Promise.resolve('sample data'); } return Promise.resolve(); @@ -227,7 +230,7 @@ } /** - * @param {!print_preview.NativeInitialSettings} settings The settings + * @param {!NativeInitialSettings} settings The settings * to return as a response to |getInitialSettings|. */ setInitialSettings(settings) { @@ -235,7 +238,7 @@ } /** - * @param {!Array<!print_preview.LocalDestinationInfo>} localDestinations + * @param {!Array<!LocalDestinationInfo>} localDestinations * The local destinations to return as a response to |getPrinters|. */ setLocalDestinations(localDestinations) { @@ -243,7 +246,7 @@ } /** - * @param {!Array<!print_preview.ProvisionalDestinationInfo>} + * @param {!Array<!ProvisionalDestinationInfo>} * extensionDestinations The extension destinations to return as a * response to |getPrinters|. */ @@ -252,7 +255,7 @@ } /** - * @param {!print_preview.CapabilitiesResponse} response The + * @param {!CapabilitiesResponse} response The * response to send for the destination whose ID is in the response. * @param {?boolean} opt_reject Whether to reject the callback for this * destination. Defaults to false (will resolve callback) if not @@ -265,7 +268,7 @@ } /** - * @param {!print_preview.PrinterSetupResponse} The response to send when + * @param {!PrinterSetupResponse} The response to send when * |setupPrinter| is called. * @param {?boolean} opt_reject Whether printSetup requests should be * rejected. Defaults to false (will resolve callback) if not provided. @@ -284,13 +287,8 @@ this.badPrinterId_ = id; } - /** @param {!print_preview.PageLayoutInfo} pageLayoutInfo */ + /** @param {!PageLayoutInfo} pageLayoutInfo */ setPageLayoutInfo(pageLayoutInfo) { this.pageLayoutInfo_ = pageLayoutInfo; } } - - return { - NativeLayerStub: NativeLayerStub, - }; -});
diff --git a/chrome/test/data/webui/print_preview/number_settings_section_interactive_test.js b/chrome/test/data/webui/print_preview/number_settings_section_interactive_test.js index 0380297..02e2c7f8 100644 --- a/chrome/test/data/webui/print_preview/number_settings_section_interactive_test.js +++ b/chrome/test/data/webui/print_preview/number_settings_section_interactive_test.js
@@ -2,14 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('number_settings_section_interactive_test', function() { +import 'chrome://print/print_preview.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {triggerInputEvent} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.number_settings_section_interactive_test = {}; + number_settings_section_interactive_test.suiteName = + 'NumberSettingsSectionInteractiveTest'; /** @enum {string} */ - const TestNames = { + number_settings_section_interactive_test.TestNames = { BlurResetsEmptyInput: 'blur resets empty input', }; - const suiteName = 'NumberSettingsSectionInteractiveTest'; - suite(suiteName, function() { + suite(number_settings_section_interactive_test.suiteName, function() { /** @type {?PrintPreviewNumberSettingsSectionElement} */ let numberSettings = null; @@ -28,7 +33,8 @@ // Verifies that blurring the input will reset it to the default if it is // empty, but not if it contains an invalid value. - test(assert(TestNames.BlurResetsEmptyInput), async () => { + test(assert(number_settings_section_interactive_test.TestNames + .BlurResetsEmptyInput), async () => { // Initial value is 10. const crInput = numberSettings.getInput(); const input = crInput.inputElement; @@ -36,8 +42,7 @@ // Set something invalid in the input. input.focus(); - await print_preview_test_utils.triggerInputEvent( - input, '0', numberSettings); + await triggerInputEvent(input, '0', numberSettings); assertEquals('0', input.value); assertTrue(crInput.invalid); @@ -50,8 +55,7 @@ // Clear the input. input.focus(); - await print_preview_test_utils.triggerInputEvent( - input, '', numberSettings); + await triggerInputEvent(input, '', numberSettings); assertEquals('', input.value); assertFalse(crInput.invalid); @@ -61,9 +65,3 @@ assertFalse(crInput.invalid); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/number_settings_section_test.js b/chrome/test/data/webui/print_preview/number_settings_section_test.js index 12c2db9..d216ee7 100644 --- a/chrome/test/data/webui/print_preview/number_settings_section_test.js +++ b/chrome/test/data/webui/print_preview/number_settings_section_test.js
@@ -2,14 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('number_settings_section_test', function() { +import 'chrome://print/print_preview.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; + + window.number_settings_section_test = {}; + number_settings_section_test.suiteName = 'NumberSettingsSectionTest'; /** @enum {string} */ - const TestNames = { + number_settings_section_test.TestNames = { BlocksInvalidKeys: 'blocks invalid keys', }; - const suiteName = 'NumberSettingsSectionTest'; - suite(suiteName, function() { + suite(number_settings_section_test.suiteName, function() { let numberSettings = null; let parentElement = null; @@ -29,7 +34,8 @@ }); // Test that key events that would result in invalid values are blocked. - test(assert(TestNames.BlocksInvalidKeys), function() { + test(assert(number_settings_section_test.TestNames.BlocksInvalidKeys), + function() { const input = numberSettings.$.userValue; /** * @param {number} code Code for the keyboard event that will be fired. @@ -38,9 +44,8 @@ * is received by |parentElement|. */ const sendKeyDownAndReturnPromise = (code, key) => { - const whenKeyDown = test_util.eventToPromise('keydown', parentElement); - MockInteractions.keyEventOn( - input.inputElement, 'keydown', code, undefined, key); + const whenKeyDown = eventToPromise('keydown', parentElement); + keyEventOn(input.inputElement, 'keydown', code, undefined, key); return whenKeyDown; }; @@ -71,9 +76,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/other_options_settings_test.js b/chrome/test/data/webui/print_preview/other_options_settings_test.js index 9a25ff4..30ce4be 100644 --- a/chrome/test/data/webui/print_preview/other_options_settings_test.js +++ b/chrome/test/data/webui/print_preview/other_options_settings_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('other_options_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + suite('OtherOptionsSettingsTest', function() { /** @type {?PrintPreviewOtherOptionsSettingsElement} */ let otherOptionsSection = null; @@ -28,9 +32,9 @@ document.createElement('print-preview-other-options-settings'); otherOptionsSection.settings = model.settings; otherOptionsSection.disabled = false; - test_util.fakeDataBind(model, otherOptionsSection, 'settings'); + fakeDataBind(model, otherOptionsSection, 'settings'); document.body.appendChild(otherOptionsSection); - Polymer.dom.flush(); + flush(); }); /** @@ -66,8 +70,7 @@ assertFalse(optionSetting.setFromUi); element.checked = false; element.dispatchEvent(new CustomEvent('change')); - return test_util - .eventToPromise('update-checkbox-setting', otherOptionsSection) + return eventToPromise('update-checkbox-setting', otherOptionsSection) .then(function(event) { assertEquals(element.id, event.detail); assertFalse(optionSetting.value); @@ -106,4 +109,3 @@ }); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/pages_per_sheet_settings_test.js b/chrome/test/data/webui/print_preview/pages_per_sheet_settings_test.js index 7b5a972..d16d1737 100644 --- a/chrome/test/data/webui/print_preview/pages_per_sheet_settings_test.js +++ b/chrome/test/data/webui/print_preview/pages_per_sheet_settings_test.js
@@ -2,7 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('pages_per_sheet_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {MarginsType} from 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('PagesPerSheetSettingsTest', function() { let pagesPerSheetSection = null; @@ -16,7 +20,7 @@ document.createElement('print-preview-pages-per-sheet-settings'); pagesPerSheetSection.settings = model.settings; pagesPerSheetSection.disabled = false; - test_util.fakeDataBind(model, pagesPerSheetSection, 'settings'); + fakeDataBind(model, pagesPerSheetSection, 'settings'); document.body.appendChild(pagesPerSheetSection); }); @@ -26,7 +30,7 @@ assertEquals('1', select.value); pagesPerSheetSection.setSetting('pagesPerSheet', 4); - await test_util.eventToPromise( + await eventToPromise( 'process-select-change', pagesPerSheetSection); assertEquals('4', select.value); }); @@ -34,14 +38,14 @@ // Tests that setting the pages per sheet setting resets margins to DEFAULT. test('resets margins setting', async () => { pagesPerSheetSection.setSetting( - 'margins', print_preview.MarginsType.NO_MARGINS); + 'margins', MarginsType.NO_MARGINS); assertEquals(1, pagesPerSheetSection.getSettingValue('pagesPerSheet')); pagesPerSheetSection.setSetting('pagesPerSheet', 4); - await test_util.eventToPromise( + await eventToPromise( 'process-select-change', pagesPerSheetSection); assertEquals(4, pagesPerSheetSection.getSettingValue('pagesPerSheet')); assertEquals( - print_preview.MarginsType.DEFAULT, + MarginsType.DEFAULT, pagesPerSheetSection.getSettingValue('margins')); }); @@ -55,9 +59,8 @@ assertEquals(6, select.options.length); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption(pagesPerSheetSection, '2'); + await selectOption(pagesPerSheetSection, '2'); assertEquals(2, pagesPerSheetSection.getSettingValue('pagesPerSheet')); assertTrue(pagesPerSheetSection.getSetting('pagesPerSheet').setFromUi); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/pages_settings_test.js b/chrome/test/data/webui/print_preview/pages_settings_test.js index b90500c..b008da7 100644 --- a/chrome/test/data/webui/print_preview/pages_settings_test.js +++ b/chrome/test/data/webui/print_preview/pages_settings_test.js
@@ -2,9 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('pages_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption, triggerInputEvent} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.pages_settings_test = {}; + pages_settings_test.suiteName = 'PagesSettingsTest'; /** @enum {string} */ - const TestNames = { + pages_settings_test.TestNames = { PagesDropdown: 'pages dropdown', ValidPageRanges: 'valid page ranges', InvalidPageRanges: 'invalid page ranges', @@ -14,8 +21,7 @@ EnterOnInputTriggersPrint: 'enter on input triggers print', }; - const suiteName = 'PagesSettingsTest'; - suite(suiteName, function() { + suite(pages_settings_test.suiteName, function() { /** @type {?PrintPreviewPagesSettingsElement} */ let pagesSection = null; @@ -34,7 +40,7 @@ pagesSection = document.createElement('print-preview-pages-settings'); pagesSection.settings = model.settings; pagesSection.disabled = false; - test_util.fakeDataBind(model, pagesSection, 'settings'); + fakeDataBind(model, pagesSection, 'settings'); document.body.appendChild(pagesSection); }); @@ -45,7 +51,7 @@ */ function setCustomInput(inputString) { const pagesInput = pagesSection.$.pageSettingsCustomInput.inputElement; - return print_preview_test_utils.triggerInputEvent( + return triggerInputEvent( pagesInput, inputString, pagesSection); } @@ -76,7 +82,7 @@ // Verifies that the pages setting updates correctly when the dropdown // changes. - test(assert(TestNames.PagesDropdown), async () => { + test(assert(pages_settings_test.TestNames.PagesDropdown), async () => { pagesSection.pageCount = 3; // Default value is all pages. @@ -90,7 +96,7 @@ assertFalse(customInputCollapse.opened); // Set selection of pages 1 and 2. - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); assertTrue(customInputCollapse.opened); @@ -99,14 +105,14 @@ assertTrue(pagesSection.getSetting('ranges').setFromUi); // Re-select "all". - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.ALL.toString()); assertFalse(customInputCollapse.opened); validateState([1, 2, 3], [], '', false); // Re-select custom. The previously entered value should be // restored. - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); assertTrue(customInputCollapse.opened); validateState([1, 2], [{from: 1, to: 2}], '', false); @@ -118,11 +124,11 @@ }); // Tests that the page ranges set are valid for different user inputs. - test(assert(TestNames.ValidPageRanges), async () => { + test(assert(pages_settings_test.TestNames.ValidPageRanges), async () => { pagesSection.pageCount = 100; const tenToHundred = Array.from({length: 91}, (x, i) => i + 10); - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); await setCustomInput('1, 2, 3, 1, 56'); validateState( @@ -165,11 +171,11 @@ // Tests that the correct error messages are shown for different user // inputs. - test(assert(TestNames.InvalidPageRanges), async () => { + test(assert(pages_settings_test.TestNames.InvalidPageRanges), async () => { pagesSection.pageCount = 100; const syntaxError = 'Invalid page range, use e.g. 1-5, 8, 11-13'; - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); await setCustomInput('10-100000'); validateState(oneToHundred, [], limitError + '100', true); @@ -202,9 +208,9 @@ // Tests that the pages are set correctly for different values of pages per // sheet, and that ranges remain fixed (since they are used for generating // the print preview ticket). - test(assert(TestNames.NupChangesPages), async () => { + test(assert(pages_settings_test.TestNames.NupChangesPages), async () => { pagesSection.pageCount = 100; - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); await setCustomInput('1, 2, 3, 1, 56'); let expectedRanges = [{from: 1, to: 3}, {from: 56, to: 56}]; @@ -236,7 +242,7 @@ // input does not show an error message but does not reset the preview, and // changing focus from an empty input in either case fills in the dropdown // with the full page range. - test(assert(TestNames.ClearInput), async () => { + test(assert(pages_settings_test.TestNames.ClearInput), async () => { pagesSection.pageCount = 3; const input = pagesSection.$.pageSettingsCustomInput.inputElement; const select = pagesSection.$$('select'); @@ -246,8 +252,8 @@ // Selecting custom focuses the input. await Promise.all([ - print_preview_test_utils.selectOption(pagesSection, customValue), - test_util.eventToPromise('focus', input) + selectOption(pagesSection, customValue), + eventToPromise('focus', input) ]); input.focus(); @@ -258,7 +264,7 @@ await setCustomInput(''); assertEquals(customValue, select.value); validateState([1, 2], [{from: 1, to: 2}], '', false); - let whenBlurred = test_util.eventToPromise('blur', input); + let whenBlurred = eventToPromise('blur', input); input.blur(); await whenBlurred; @@ -276,7 +282,7 @@ await setCustomInput(''); assertEquals(customValue, select.value); validateState([1, 2, 3], [], '', false); - whenBlurred = test_util.eventToPromise('blur', input); + whenBlurred = eventToPromise('blur', input); input.blur(); // Blurring an invalid value that has been cleared should reset the @@ -293,20 +299,20 @@ await setCustomInput('', 3); select.focus(); - await print_preview_test_utils.selectOption(pagesSection, allValue); - Polymer.dom.flush(); + await selectOption(pagesSection, allValue); + flush(); assertEquals(allValue, select.value); validateState([1, 2, 3], [], '', false); // Reselect custom. This should focus the input. await Promise.all([ - print_preview_test_utils.selectOption(pagesSection, customValue), - test_util.eventToPromise('focus', input), + selectOption(pagesSection, customValue), + eventToPromise('focus', input), ]); // Input has been cleared. assertEquals('', input.value); validateState([1, 2, 3], [], '', false); - whenBlurred = test_util.eventToPromise('blur', input); + whenBlurred = eventToPromise('blur', input); input.blur(); await whenBlurred; @@ -321,7 +327,9 @@ // Verifies that the input is never disabled when the validity of the // setting changes. - test(assert(TestNames.InputNotDisabledOnValidityChange), async () => { + test( + assert(pages_settings_test.TestNames.InputNotDisabledOnValidityChange), + async () => { pagesSection.pageCount = 3; // In the real UI, the print preview app listens for this event from this // section and others and sets disabled to true if any change from true to @@ -335,7 +343,7 @@ }); const input = pagesSection.$.pageSettingsCustomInput.inputElement; - await print_preview_test_utils.selectOption( + await selectOption( pagesSection, pagesSection.pagesValueEnum_.CUSTOM.toString()); await setCustomInput('1'); validateState([1], [{from: 1, to: 1}], '', false); @@ -363,21 +371,23 @@ // Verifies that the enter key event is bubbled to the pages settings // element, so that it will be bubbled to the print preview app to trigger a // print. - test(assert(TestNames.EnterOnInputTriggersPrint), async () => { + test( + assert(pages_settings_test.TestNames.EnterOnInputTriggersPrint), + async () => { pagesSection.pageCount = 3; const input = pagesSection.$.pageSettingsCustomInput.inputElement; const whenPrintReceived = - test_util.eventToPromise('keydown', pagesSection); + eventToPromise('keydown', pagesSection); // Setup an empty input by selecting custom.. const customValue = pagesSection.pagesValueEnum_.CUSTOM.toString(); const pagesSelect = pagesSection.$$('select'); await Promise.all([ - print_preview_test_utils.selectOption(pagesSection, customValue), - test_util.eventToPromise('focus', input) + selectOption(pagesSection, customValue), + eventToPromise('focus', input) ]); assertEquals(customValue, pagesSelect.value); - MockInteractions.keyEventOn(input, 'keydown', 13, [], 'Enter'); + keyEventOn(input, 'keydown', 13, [], 'Enter'); await whenPrintReceived; // Keep custom selected, but pages to print should still be all. @@ -388,17 +398,11 @@ await setCustomInput('1'); assertEquals(customValue, pagesSelect.value); const whenSecondPrintReceived = - test_util.eventToPromise('keydown', pagesSection); - MockInteractions.keyEventOn(input, 'keydown', 13, [], 'Enter'); + eventToPromise('keydown', pagesSection); + keyEventOn(input, 'keydown', 13, [], 'Enter'); await whenSecondPrintReceived; assertEquals(customValue, pagesSelect.value); validateState([1], [{from: 1, to: 1}], '', false); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/pin_settings_test.js b/chrome/test/data/webui/print_preview/pin_settings_test.js index b6aa6d5..fa62e32 100644 --- a/chrome/test/data/webui/print_preview/pin_settings_test.js +++ b/chrome/test/data/webui/print_preview/pin_settings_test.js
@@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('pin_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {State} from 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {triggerInputEvent} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + suite('PinSettingsTest', function() { /** @type {?PrintPreviewPinSettingsElement} */ let pinSection = null; @@ -22,11 +27,11 @@ pinSection = document.createElement('print-preview-pin-settings'); pinSection.settings = model.settings; - pinSection.state = print_preview.State.READY; + pinSection.state = State.READY; pinSection.disabled = false; - test_util.fakeDataBind(model, pinSection, 'settings'); + fakeDataBind(model, pinSection, 'settings'); document.body.appendChild(pinSection); - Polymer.dom.flush(); + flush(); }); // Tests that checking the box or entering the pin value updates the @@ -52,7 +57,7 @@ assertFalse(pinSection.getSetting('pinValue').setFromUi); // Verify that entering the pin value in the input sets the setting. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '0000', pinSection); assertTrue(pinSection.getSettingValue('pin')); assertEquals('0000', pinSection.getSettingValue('pinValue')); @@ -70,7 +75,7 @@ // Verify that entering the non-digit pin value in the input updates the // setting validity and doesn't update its value. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, 'aaaa', pinSection); assertTrue(pinSection.getSettingValue('pin')); assertEquals('', pinSection.getSettingValue('pinValue')); @@ -93,7 +98,7 @@ // Verify that entering too short pin value in the input updates the // setting validity and doesn't update its value. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '000', pinSection); assertTrue(pinSection.getSettingValue('pin')); assertEquals('', pinSection.getSettingValue('pinValue')); @@ -119,7 +124,7 @@ assertEquals(false, pinSection.getSetting('pinValue').valid); // Verify that entering the pin value in the input sets the setting. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '0000', pinSection); assertTrue(pinSection.getSettingValue('pin')); assertEquals('0000', pinSection.getSettingValue('pinValue')); @@ -127,7 +132,7 @@ // Verify that entering empty pin value in the input updates the // setting validity and its value. - await print_preview_test_utils.triggerInputEvent(input, '', pinSection); + await triggerInputEvent(input, '', pinSection); assertTrue(pinSection.getSettingValue('pin')); assertEquals('', pinSection.getSettingValue('pinValue')); assertEquals(false, pinSection.getSetting('pinValue').valid); @@ -158,4 +163,3 @@ assertFalse(input.disabled); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/plugin_stub.js b/chrome/test/data/webui/print_preview/plugin_stub.js index bebed6c..9ab1b71 100644 --- a/chrome/test/data/webui/print_preview/plugin_stub.js +++ b/chrome/test/data/webui/print_preview/plugin_stub.js
@@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {TestBrowserProxy} from 'chrome://test/test_browser_proxy.m.js'; + /** * Test version of the PluginProxy. */ - class PDFPluginStub extends TestBrowserProxy { + export class PDFPluginStub extends TestBrowserProxy { constructor() { super(['loadPreviewPage']); @@ -147,6 +149,3 @@ this.viewportChangedCallback_.apply(this, arguments); } } - - return {PDFPluginStub: PDFPluginStub}; -});
diff --git a/chrome/test/data/webui/print_preview/policy_test.js b/chrome/test/data/webui/print_preview/policy_test.js index 9f9f8a70..0dc9d46 100644 --- a/chrome/test/data/webui/print_preview/policy_test.js +++ b/chrome/test/data/webui/print_preview/policy_test.js
@@ -2,34 +2,41 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('policy_tests', function() { +import {NativeLayer, PluginProxy} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate, getDefaultInitialSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.policy_tests = {}; + policy_tests.suiteName = 'PolicyTest'; /** @enum {string} */ - const TestNames = { + policy_tests.TestNames = { EnableHeaderFooterByPref: 'enable header and footer by pref', DisableHeaderFooterByPref: 'disable header and footer by pref', EnableHeaderFooterByPolicy: 'enable header and footer by policy', DisableHeaderFooterByPolicy: 'disable header and footer by policy', }; - const suiteName = 'PolicyTest'; - suite(suiteName, function() { + suite(policy_tests.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; /** - * @param {!print_preview.NativeInitialSettings} initialSettings + * @param {!NativeInitialSettings} initialSettings * @return {!Promise} A Promise that resolves once initial settings are done * loading. */ function loadInitialSettings(initialSettings) { - const nativeLayer = new print_preview.NativeLayerStub(); + const nativeLayer = new NativeLayerStub(); nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(initialSettings.printerName)); + getCddTemplate(initialSettings.printerName)); nativeLayer.setPageCount(3); - print_preview.NativeLayer.setInstance(nativeLayer); - const pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + NativeLayer.setInstance(nativeLayer); + const pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); PolymerTest.clearBody(); page = document.createElement('print-preview-app'); @@ -43,7 +50,7 @@ nativeLayer.whenCalled('getPrinterCapabilities') ]) .then(function() { - Polymer.dom.flush(); + flush(); }); } @@ -59,7 +66,7 @@ */ function doSetup(headerFooter, isHeaderFooterManaged) { const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); + getDefaultInitialSettings(); initialSettings.headerFooter = headerFooter; initialSettings.isHeaderFooterManaged = isHeaderFooterManaged; // We want to make sure sticky settings get overridden. @@ -86,7 +93,7 @@ * Tests that 'printing.print_header_footer' pref checks the header/footer * checkbox. */ - test(assert(TestNames.EnableHeaderFooterByPref), function() { + test(assert(policy_tests.TestNames.EnableHeaderFooterByPref), function() { doSetup(true, false).then(function() { toggleMoreSettings(); assertFalse(getCheckbox().disabled); @@ -98,7 +105,7 @@ * Tests that 'printing.print_header_footer' pref unchecks the header/footer * checkbox. */ - test(assert(TestNames.DisableHeaderFooterByPref), function() { + test(assert(policy_tests.TestNames.DisableHeaderFooterByPref), function() { doSetup(false, false).then(function() { toggleMoreSettings(); assertFalse(getCheckbox().disabled); @@ -110,7 +117,7 @@ * Tests that 'force enable header/footer' policy disables the header/footer * checkbox and checks it. */ - test(assert(TestNames.EnableHeaderFooterByPolicy), function() { + test(assert(policy_tests.TestNames.EnableHeaderFooterByPolicy), function() { doSetup(true, true).then(function() { toggleMoreSettings(); assertTrue(getCheckbox().disabled); @@ -122,7 +129,9 @@ * Tests that 'force enable header/footer' policy disables the header/footer * checkbox and unchecks it. */ - test(assert(TestNames.DisableHeaderFooterByPolicy), function() { + test( + assert(policy_tests.TestNames.DisableHeaderFooterByPolicy), + function() { doSetup(false, true).then(function() { toggleMoreSettings(); assertTrue(getCheckbox().disabled); @@ -130,9 +139,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/preview_area_test.js b/chrome/test/data/webui/print_preview/preview_area_test.js index 6fb201fc..4ac26208 100644 --- a/chrome/test/data/webui/print_preview/preview_area_test.js +++ b/chrome/test/data/webui/print_preview/preview_area_test.js
@@ -2,30 +2,37 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('preview_area_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, Error, Margins, MeasurementSystem, MeasurementSystemUnitType, NativeLayer, PluginProxy, PreviewAreaState, Size, State} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; + + window.preview_area_test = {}; + preview_area_test.suiteName = 'PreviewAreaTest'; /** @enum {string} */ - const TestNames = { + preview_area_test.TestNames = { StateChanges: 'state changes', ViewportSizeChanges: 'viewport size changes', }; - const suiteName = 'PreviewAreaTest'; - suite(suiteName, function() { + suite(preview_area_test.suiteName, function() { /** @type {?PrintPreviewPreviewAreaElement} */ let previewArea = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; let pluginProxy = null; /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); nativeLayer.setPageCount(3); - pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); PolymerTest.clearBody(); const model = document.createElement('print-preview-model'); @@ -34,30 +41,30 @@ previewArea = document.createElement('print-preview-preview-area'); document.body.appendChild(previewArea); previewArea.settings = model.settings; - test_util.fakeDataBind(model, previewArea, 'settings'); - previewArea.destination = new print_preview.Destination( - 'FooDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'FooName', - print_preview.DestinationConnectionStatus.ONLINE); + fakeDataBind(model, previewArea, 'settings'); + previewArea.destination = new Destination( + 'FooDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'FooName', + DestinationConnectionStatus.ONLINE); previewArea.destination.capabiliites = - print_preview_test_utils.getCddTemplate('FooDevice'); - previewArea.error = print_preview.Error.NONE; - previewArea.state = print_preview.State.NOT_READY; + getCddTemplate('FooDevice'); + previewArea.error = Error.NONE; + previewArea.state = State.NOT_READY; previewArea.documentModifiable = true; - previewArea.measurementSystem = new print_preview.MeasurementSystem( - ',', '.', print_preview.MeasurementSystemUnitType.IMPERIAL); + previewArea.measurementSystem = new MeasurementSystem( + ',', '.', MeasurementSystemUnitType.IMPERIAL); - previewArea.pageSize = new print_preview.Size(612, 794); - previewArea.margins = new print_preview.Margins(10, 10, 10, 10); + previewArea.pageSize = new Size(612, 794); + previewArea.margins = new Margins(10, 10, 10, 10); }); /** Validate some preview area state transitions work as expected. */ - test(assert(TestNames.StateChanges), function() { + test(assert(preview_area_test.TestNames.StateChanges), function() { // Simulate starting the preview. const whenPreviewStarted = nativeLayer.whenCalled('getPreview'); - previewArea.state = print_preview.State.READY; + previewArea.state = State.READY; assertEquals( - print_preview.PreviewAreaState.LOADING, previewArea.previewState); + PreviewAreaState.LOADING, previewArea.previewState); assertFalse(previewArea.$$('.preview-area-overlay-layer') .classList.contains('invisible')); const message = @@ -68,7 +75,7 @@ return whenPreviewStarted.then(() => { assertEquals( - print_preview.PreviewAreaState.DISPLAY_PREVIEW, + PreviewAreaState.DISPLAY_PREVIEW, previewArea.previewState); assertEquals(3, pluginProxy.getCallCount('loadPreviewPage')); assertTrue(previewArea.$$('.preview-area-overlay-layer') @@ -76,14 +83,14 @@ // If destination capabilities fetch fails, the invalid printer error // will be set by the destination settings. - previewArea.destination = new print_preview.Destination( - 'InvalidDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'InvalidName', - print_preview.DestinationConnectionStatus.ONLINE); - previewArea.state = print_preview.State.ERROR; - previewArea.error = print_preview.Error.INVALID_PRINTER; + previewArea.destination = new Destination( + 'InvalidDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'InvalidName', + DestinationConnectionStatus.ONLINE); + previewArea.state = State.ERROR; + previewArea.error = Error.INVALID_PRINTER; assertEquals( - print_preview.PreviewAreaState.ERROR, previewArea.previewState); + PreviewAreaState.ERROR, previewArea.previewState); assertFalse(previewArea.$$('.preview-area-overlay-layer') .classList.contains('invisible')); assertEquals( @@ -95,15 +102,15 @@ }); /** Validate preview area sets tabindex correctly based on viewport size. */ - test(assert(TestNames.ViewportSizeChanges), function() { + test(assert(preview_area_test.TestNames.ViewportSizeChanges), function() { // Simulate starting the preview. const whenPreviewStarted = nativeLayer.whenCalled('getPreview'); - previewArea.state = print_preview.State.READY; + previewArea.state = State.READY; previewArea.startPreview(); return whenPreviewStarted.then(() => { assertEquals( - print_preview.PreviewAreaState.DISPLAY_PREVIEW, + PreviewAreaState.DISPLAY_PREVIEW, previewArea.previewState); assertTrue(previewArea.$$('.preview-area-overlay-layer') .classList.contains('invisible')); @@ -127,9 +134,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/preview_generation_test.js b/chrome/test/data/webui/print_preview/preview_generation_test.js index 331490b..6deccf9 100644 --- a/chrome/test/data/webui/print_preview/preview_generation_test.js +++ b/chrome/test/data/webui/print_preview/preview_generation_test.js
@@ -2,9 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('preview_generation_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {ColorMode, Destination, DestinationConnectionStatus, DestinationOrigin, DestinationState, DestinationType, Margins, MarginsType, NativeLayer, PluginProxy, ScalingType} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate, getDefaultInitialSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.preview_generation_test = {}; + preview_generation_test.suiteName = 'PreviewGenerationTest'; /** @enum {string} */ - const TestNames = { + preview_generation_test.TestNames = { Color: 'color', CssBackground: 'css background', HeaderFooter: 'header/footer', @@ -31,27 +38,26 @@ * expectedTicketId: number, * expectedTicketScaleFactor: number, * expectedScalingValue: string, - * expectedScalingType: !print_preview.ScalingType, + * expectedScalingType: !ScalingType, * }} */ let ValidateScalingChangeParams; - const suiteName = 'PreviewGenerationTest'; - suite(suiteName, function() { + suite(preview_generation_test.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {!print_preview.NativeInitialSettings} */ + /** @type {!NativeInitialSettings} */ const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); + getDefaultInitialSettings(); /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); PolymerTest.clearBody(); }); @@ -64,17 +70,17 @@ function initialize() { nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(initialSettings.printerName)); + getCddTemplate(initialSettings.printerName)); nativeLayer.setPageCount(3); - const pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + const pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); page = document.createElement('print-preview-app'); document.body.appendChild(page); const previewArea = page.$.previewArea; const documentInfo = page.$$('print-preview-document-info'); documentInfo.documentSettings.pageCount = 3; - documentInfo.margins = new print_preview.Margins(10, 10, 10, 10); + documentInfo.margins = new Margins(10, 10, 10, 10); return Promise .all([ @@ -139,53 +145,53 @@ } /** Validate changing the color updates the preview. */ - test(assert(TestNames.Color), function() { + test(assert(preview_generation_test.TestNames.Color), function() { return testSimpleSetting( - 'color', true, false, 'color', print_preview.ColorMode.COLOR, - print_preview.ColorMode.GRAY); + 'color', true, false, 'color', ColorMode.COLOR, + ColorMode.GRAY); }); /** Validate changing the background setting updates the preview. */ - test(assert(TestNames.CssBackground), function() { + test(assert(preview_generation_test.TestNames.CssBackground), function() { return testSimpleSetting( 'cssBackground', false, true, 'shouldPrintBackgrounds', false, true); }); /** Validate changing the header/footer setting updates the preview. */ - test(assert(TestNames.HeaderFooter), function() { + test(assert(preview_generation_test.TestNames.HeaderFooter), function() { return testSimpleSetting( 'headerFooter', true, false, 'headerFooterEnabled', true, false); }); /** Validate changing the orientation updates the preview. */ - test(assert(TestNames.Layout), function() { + test(assert(preview_generation_test.TestNames.Layout), function() { return testSimpleSetting('layout', false, true, 'landscape', false, true); }); /** Validate changing the margins updates the preview. */ - test(assert(TestNames.Margins), function() { + test(assert(preview_generation_test.TestNames.Margins), function() { return testSimpleSetting( - 'margins', print_preview.MarginsType.DEFAULT, - print_preview.MarginsType.MINIMUM, 'marginsType', - print_preview.MarginsType.DEFAULT, print_preview.MarginsType.MINIMUM); + 'margins', MarginsType.DEFAULT, + MarginsType.MINIMUM, 'marginsType', + MarginsType.DEFAULT, MarginsType.MINIMUM); }); /** * Validate changing the custom margins updates the preview, only after all * values have been set. */ - test(assert(TestNames.CustomMargins), function() { + test(assert(preview_generation_test.TestNames.CustomMargins), function() { return initialize() .then(function(args) { const originalTicket = JSON.parse(args.printTicket); assertEquals( - print_preview.MarginsType.DEFAULT, originalTicket.marginsType); + MarginsType.DEFAULT, originalTicket.marginsType); // Custom margins should not be set in the ticket. assertEquals(undefined, originalTicket.marginsCustom); assertEquals(0, originalTicket.requestID); // This should do nothing. - page.setSetting('margins', print_preview.MarginsType.CUSTOM); + page.setSetting('margins', MarginsType.CUSTOM); // Sets only 1 side, not valid. page.setSetting('customMargins', {marginTop: 25}); // 2 sides, still not valid. @@ -202,16 +208,16 @@ }) .then(function(args) { const ticket = JSON.parse(args.printTicket); - assertEquals(print_preview.MarginsType.CUSTOM, ticket.marginsType); + assertEquals(MarginsType.CUSTOM, ticket.marginsType); assertEquals(25, ticket.marginsCustom.marginTop); assertEquals(40, ticket.marginsCustom.marginRight); assertEquals(20, ticket.marginsCustom.marginBottom); assertEquals(50, ticket.marginsCustom.marginLeft); assertEquals(1, ticket.requestID); - page.setSetting('margins', print_preview.MarginsType.DEFAULT); + page.setSetting('margins', MarginsType.DEFAULT); // Set setting to something invalid and then set margins to CUSTOM. page.setSetting('customMargins', {marginTop: 25, marginRight: 40}); - page.setSetting('margins', print_preview.MarginsType.CUSTOM); + page.setSetting('margins', MarginsType.CUSTOM); nativeLayer.resetResolver('getPreview'); page.setSetting('customMargins', { marginTop: 25, @@ -223,7 +229,7 @@ }) .then(function(args) { const ticket = JSON.parse(args.printTicket); - assertEquals(print_preview.MarginsType.CUSTOM, ticket.marginsType); + assertEquals(MarginsType.CUSTOM, ticket.marginsType); assertEquals(25, ticket.marginsCustom.marginTop); assertEquals(40, ticket.marginsCustom.marginRight); assertEquals(20, ticket.marginsCustom.marginBottom); @@ -237,29 +243,29 @@ /** * Validate changing the pages per sheet updates the preview, and resets - * margins to print_preview.MarginsType.DEFAULT. + * margins to MarginsType.DEFAULT. */ - test(assert(TestNames.ChangeMarginsByPagesPerSheet), function() { - const MarginsTypeEnum = print_preview.MarginsType; + test(assert(preview_generation_test.TestNames.ChangeMarginsByPagesPerSheet), + function() { return initialize() .then(function(args) { const originalTicket = JSON.parse(args.printTicket); assertEquals(0, originalTicket.requestID); assertEquals( - MarginsTypeEnum.DEFAULT, originalTicket['marginsType']); + MarginsType.DEFAULT, originalTicket['marginsType']); assertEquals( - MarginsTypeEnum.DEFAULT, page.getSettingValue('margins')); + MarginsType.DEFAULT, page.getSettingValue('margins')); assertEquals(1, page.getSettingValue('pagesPerSheet')); assertEquals(1, originalTicket['pagesPerSheet']); nativeLayer.resetResolver('getPreview'); - page.setSetting('margins', MarginsTypeEnum.MINIMUM); + page.setSetting('margins', MarginsType.MINIMUM); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { assertEquals( - MarginsTypeEnum.MINIMUM, page.getSettingValue('margins')); + MarginsType.MINIMUM, page.getSettingValue('margins')); const ticket = JSON.parse(args.printTicket); - assertEquals(MarginsTypeEnum.MINIMUM, ticket['marginsType']); + assertEquals(MarginsType.MINIMUM, ticket['marginsType']); nativeLayer.resetResolver('getPreview'); assertEquals(1, ticket.requestID); page.setSetting('pagesPerSheet', 4); @@ -267,19 +273,19 @@ }) .then(function(args) { assertEquals( - MarginsTypeEnum.DEFAULT, page.getSettingValue('margins')); + MarginsType.DEFAULT, page.getSettingValue('margins')); assertEquals(4, page.getSettingValue('pagesPerSheet')); const ticket = JSON.parse(args.printTicket); - assertEquals(MarginsTypeEnum.DEFAULT, ticket['marginsType']); + assertEquals(MarginsType.DEFAULT, ticket['marginsType']); assertEquals(4, ticket['pagesPerSheet']); assertEquals(2, ticket.requestID); }); }); /** Validate changing the paper size updates the preview. */ - test(assert(TestNames.MediaSize), function() { + test(assert(preview_generation_test.TestNames.MediaSize), function() { const mediaSizeCapability = - print_preview_test_utils.getCddTemplate('FooDevice') + getCddTemplate('FooDevice') .capabilities.printer.media_size; const letterOption = mediaSizeCapability.option[0]; const squareOption = mediaSizeCapability.option[1]; @@ -321,7 +327,7 @@ }); /** Validate changing the page range updates the preview. */ - test(assert(TestNames.PageRange), function() { + test(assert(preview_generation_test.TestNames.PageRange), function() { return initialize() .then(function(args) { const originalTicket = JSON.parse(args.printTicket); @@ -345,7 +351,7 @@ }); /** Validate changing the selection only setting updates the preview. */ - test(assert(TestNames.SelectionOnly), function() { + test(assert(preview_generation_test.TestNames.SelectionOnly), function() { // Set has selection to true so that the setting is available. initialSettings.hasSelection = true; return testSimpleSetting( @@ -354,12 +360,12 @@ }); /** Validate changing the pages per sheet updates the preview. */ - test(assert(TestNames.PagesPerSheet), function() { + test(assert(preview_generation_test.TestNames.PagesPerSheet), function() { return testSimpleSetting('pagesPerSheet', 1, 2, 'pagesPerSheet', 1, 2); }); /** Validate changing the scaling updates the preview. */ - test(assert(TestNames.Scaling), function() { + test(assert(preview_generation_test.TestNames.Scaling), function() { return initialize() .then(function(args) { validateScalingChange({ @@ -368,11 +374,11 @@ expectedTicketId: 0, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); nativeLayer.resetResolver('getPreview'); // DEFAULT -> CUSTOM - page.setSetting('scalingType', print_preview.ScalingType.CUSTOM); + page.setSetting('scalingType', ScalingType.CUSTOM); // Need to set custom value != 100 for preview to regenerate. page.setSetting('scaling', '90'); return nativeLayer.whenCalled('getPreview'); @@ -384,13 +390,13 @@ expectedTicketId: 1, expectedTicketScaleFactor: 90, expectedScalingValue: '90', - expectedScalingType: print_preview.ScalingType.CUSTOM, + expectedScalingType: ScalingType.CUSTOM, }); nativeLayer.resetResolver('getPreview'); // CUSTOM -> DEFAULT // This should regenerate the preview, since the custom value is not // 100. - page.setSetting('scalingType', print_preview.ScalingType.DEFAULT); + page.setSetting('scalingType', ScalingType.DEFAULT); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -400,11 +406,11 @@ expectedTicketId: 2, expectedTicketScaleFactor: 100, expectedScalingValue: '90', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); nativeLayer.resetResolver('getPreview'); // DEFAULT -> CUSTOM - page.setSetting('scalingType', print_preview.ScalingType.CUSTOM); + page.setSetting('scalingType', ScalingType.CUSTOM); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -414,7 +420,7 @@ expectedTicketId: 3, expectedTicketScaleFactor: 90, expectedScalingValue: '90', - expectedScalingType: print_preview.ScalingType.CUSTOM, + expectedScalingType: ScalingType.CUSTOM, }); nativeLayer.resetResolver('getPreview'); // CUSTOM 90 -> CUSTOM 80 @@ -429,13 +435,13 @@ expectedTicketId: 4, expectedTicketScaleFactor: 80, expectedScalingValue: '80', - expectedScalingType: print_preview.ScalingType.CUSTOM, + expectedScalingType: ScalingType.CUSTOM, }); }); }); /** Validate changing the scalingTypePdf setting updates the preview. */ - test(assert(TestNames.ScalingPdf), function() { + test(assert(preview_generation_test.TestNames.ScalingPdf), function() { // Set PDF document so setting is available. initialSettings.previewModifiable = false; initialSettings.previewIsPdf = true; @@ -447,12 +453,12 @@ expectedTicketId: 0, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); nativeLayer.resetResolver('getPreview'); // DEFAULT -> FIT_TO_PAGE page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.FIT_TO_PAGE); + 'scalingTypePdf', ScalingType.FIT_TO_PAGE); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -462,11 +468,11 @@ expectedTicketId: 1, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.FIT_TO_PAGE, + expectedScalingType: ScalingType.FIT_TO_PAGE, }); nativeLayer.resetResolver('getPreview'); // FIT_TO_PAGE -> CUSTOM - page.setSetting('scalingTypePdf', print_preview.ScalingType.CUSTOM); + page.setSetting('scalingTypePdf', ScalingType.CUSTOM); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -476,12 +482,12 @@ expectedTicketId: 2, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.CUSTOM, + expectedScalingType: ScalingType.CUSTOM, }); nativeLayer.resetResolver('getPreview'); // CUSTOM -> FIT_TO_PAGE page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.FIT_TO_PAGE); + 'scalingTypePdf', ScalingType.FIT_TO_PAGE); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -491,12 +497,12 @@ expectedTicketId: 3, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.FIT_TO_PAGE, + expectedScalingType: ScalingType.FIT_TO_PAGE, }); nativeLayer.resetResolver('getPreview'); // FIT_TO_PAGE -> DEFAULT page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.DEFAULT); + 'scalingTypePdf', ScalingType.DEFAULT); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -506,12 +512,12 @@ expectedTicketId: 4, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); nativeLayer.resetResolver('getPreview'); // DEFAULT -> FIT_TO_PAPER page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.FIT_TO_PAPER); + 'scalingTypePdf', ScalingType.FIT_TO_PAPER); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -521,12 +527,12 @@ expectedTicketId: 5, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.FIT_TO_PAPER, + expectedScalingType: ScalingType.FIT_TO_PAPER, }); nativeLayer.resetResolver('getPreview'); // FIT_TO_PAPER -> DEFAULT page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.DEFAULT); + 'scalingTypePdf', ScalingType.DEFAULT); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -536,11 +542,11 @@ expectedTicketId: 6, expectedTicketScaleFactor: 100, expectedScalingValue: '100', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); nativeLayer.resetResolver('getPreview'); // DEFAULT -> CUSTOM - page.setSetting('scalingTypePdf', print_preview.ScalingType.CUSTOM); + page.setSetting('scalingTypePdf', ScalingType.CUSTOM); // Need to set custom value != 100 for preview to regenerate. page.setSetting('scaling', '120'); return nativeLayer.whenCalled('getPreview'); @@ -555,12 +561,12 @@ expectedTicketId: 7, expectedTicketScaleFactor: 120, expectedScalingValue: '120', - expectedScalingType: print_preview.ScalingType.CUSTOM, + expectedScalingType: ScalingType.CUSTOM, }); nativeLayer.resetResolver('getPreview'); // CUSTOM -> DEFAULT page.setSetting( - 'scalingTypePdf', print_preview.ScalingType.DEFAULT); + 'scalingTypePdf', ScalingType.DEFAULT); return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -570,7 +576,7 @@ expectedTicketId: 8, expectedTicketScaleFactor: 100, expectedScalingValue: '120', - expectedScalingType: print_preview.ScalingType.DEFAULT, + expectedScalingType: ScalingType.DEFAULT, }); }); }); @@ -579,7 +585,7 @@ * Validate changing the rasterize setting updates the preview. Only runs * on Linux and CrOS as setting is not available on other platforms. */ - test(assert(TestNames.Rasterize), function() { + test(assert(preview_generation_test.TestNames.Rasterize), function() { // Set PDF document so setting is available. initialSettings.previewModifiable = false; return testSimpleSetting( @@ -590,18 +596,18 @@ * Validate changing the destination updates the preview, if it results * in a settings change. */ - test(assert(TestNames.Destination), function() { + test(assert(preview_generation_test.TestNames.Destination), function() { return initialize() .then(function(args) { const originalTicket = JSON.parse(args.printTicket); assertEquals('FooDevice', page.destination_.id); assertEquals('FooDevice', originalTicket.deviceName); - const barDestination = new print_preview.Destination( - 'BarDevice', print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, 'BarName', - print_preview.DestinationConnectionStatus.ONLINE); + const barDestination = new Destination( + 'BarDevice', DestinationType.LOCAL, + DestinationOrigin.LOCAL, 'BarName', + DestinationConnectionStatus.ONLINE); const capabilities = - print_preview_test_utils.getCddTemplate(barDestination.id) + getCddTemplate(barDestination.id) .capabilities; capabilities.printer.media_size = { option: [ @@ -615,9 +621,9 @@ }; barDestination.capabilities = capabilities; nativeLayer.resetResolver('getPreview'); - page.destinationState_ = print_preview.DestinationState.SELECTED; + page.destinationState_ = DestinationState.SELECTED; page.set('destination_', barDestination); - page.destinationState_ = print_preview.DestinationState.UPDATED; + page.destinationState_ = DestinationState.UPDATED; return nativeLayer.whenCalled('getPreview'); }) .then(function(args) { @@ -631,11 +637,13 @@ * Validate that if the document layout has 0 default margins, the * header/footer setting is set to false. */ - test(assert(TestNames.ZeroDefaultMarginsClearsHeaderFooter), async () => { + test(assert( + preview_generation_test.TestNames.ZeroDefaultMarginsClearsHeaderFooter), + async () => { /** * @param {Object} ticket The parsed print ticket * @param {number} expectedId The expected ticket request ID - * @param {!print_preview.MarginsType} expectedMargins + * @param {!MarginsType} expectedMargins * The expected ticket margins type * @param {boolean} expectedHeaderFooter The expected ticket * header/footer value @@ -660,18 +668,17 @@ printableAreaHeight: 792, }); - const MarginsTypeEnum = print_preview.MarginsType; let previewArgs = await initialize(); let ticket = JSON.parse(previewArgs.printTicket); // The ticket recorded here is the original, which requests default // margins with headers and footers (Print Preview defaults). - assertMarginsFooter(ticket, 0, MarginsTypeEnum.DEFAULT, true); + assertMarginsFooter(ticket, 0, MarginsType.DEFAULT, true); // After getting the new layout, a second request should have been // sent. assertEquals(2, nativeLayer.getCallCount('getPreview')); - assertEquals(MarginsTypeEnum.DEFAULT, page.getSettingValue('margins')); + assertEquals(MarginsType.DEFAULT, page.getSettingValue('margins')); assertFalse(page.getSettingValue('headerFooter')); // Check the last ticket sent by the preview area. It should not @@ -679,32 +686,26 @@ // should have been turned off). const previewArea = page.$$('print-preview-preview-area'); assertMarginsFooter( - previewArea.lastTicket_, 1, MarginsTypeEnum.DEFAULT, false); + previewArea.lastTicket_, 1, MarginsType.DEFAULT, false); nativeLayer.resetResolver('getPreview'); - page.setSetting('margins', MarginsTypeEnum.MINIMUM); + page.setSetting('margins', MarginsType.MINIMUM); previewArgs = await nativeLayer.whenCalled('getPreview'); // Setting minimum margins allows space for the headers and footers, // so they should be enabled again. ticket = JSON.parse(previewArgs.printTicket); - assertMarginsFooter(ticket, 2, MarginsTypeEnum.MINIMUM, true); - assertEquals(MarginsTypeEnum.MINIMUM, page.getSettingValue('margins')); + assertMarginsFooter(ticket, 2, MarginsType.MINIMUM, true); + assertEquals(MarginsType.MINIMUM, page.getSettingValue('margins')); assertTrue(page.getSettingValue('headerFooter')); nativeLayer.resetResolver('getPreview'); - page.setSetting('margins', MarginsTypeEnum.DEFAULT); + page.setSetting('margins', MarginsType.DEFAULT); previewArgs = await nativeLayer.whenCalled('getPreview'); // With default margins, there is no space for headers/footers, so // they are removed. ticket = JSON.parse(previewArgs.printTicket); - assertMarginsFooter(ticket, 3, MarginsTypeEnum.DEFAULT, false); - assertEquals(MarginsTypeEnum.DEFAULT, page.getSettingValue('margins')); + assertMarginsFooter(ticket, 3, MarginsType.DEFAULT, false); + assertEquals(MarginsType.DEFAULT, page.getSettingValue('margins')); assertEquals(false, page.getSettingValue('headerFooter')); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/print_button_test.js b/chrome/test/data/webui/print_preview/print_button_test.js index 415fdb6..552f3a2 100644 --- a/chrome/test/data/webui/print_preview/print_button_test.js +++ b/chrome/test/data/webui/print_preview/print_button_test.js
@@ -2,19 +2,25 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_button_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {NativeLayer, PluginProxy} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate, getDefaultInitialSettings, getPdfPrinter} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.print_button_test = {}; + print_button_test.suiteName = 'PrintButtonTest'; /** @enum {string} */ - const TestNames = { + print_button_test.TestNames = { LocalPrintHidePreview: 'local print hide preview', PDFPrintVisiblePreview: 'pdf print visible preview', }; - const suiteName = 'PrintButtonTest'; - suite(suiteName, function() { + suite(print_button_test.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; /** @type {boolean} */ @@ -23,14 +29,13 @@ /** @type {boolean} */ let previewHidden = false; - /** @type {!print_preview.NativeInitialSettings} */ - const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); + /** @type {!NativeInitialSettings} */ + const initialSettings = getDefaultInitialSettings(); /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); PolymerTest.clearBody(); nativeLayer.setInitialSettings(initialSettings); const localDestinationInfos = [ @@ -38,14 +43,14 @@ ]; nativeLayer.setLocalDestinations(localDestinationInfos); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate( + getCddTemplate( initialSettings.printerName)); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getPdfPrinter()); + getPdfPrinter()); - const pluginProxy = new print_preview.PDFPluginStub(); + const pluginProxy = new PDFPluginStub(); pluginProxy.setPluginCompatible(true); - print_preview.PluginProxy.setInstance(pluginProxy); + PluginProxy.setInstance(pluginProxy); page = document.createElement('print-preview-app'); document.body.appendChild(page); @@ -82,7 +87,7 @@ // Tests that hidePreview() is called before print() if a local printer is // selected and the user clicks print while the preview is loading. - test(assert(TestNames.LocalPrintHidePreview), function() { + test(assert(print_button_test.TestNames.LocalPrintHidePreview), function() { printBeforePreviewReady = true; return waitForInitialPreview().then(function() { @@ -99,7 +104,7 @@ // Tests that hidePreview() is not called if Save as PDF is selected and // the user clicks print while the preview is loading. - test(assert(TestNames.PDFPrintVisiblePreview), function() { + test(assert(print_button_test.TestNames.PDFPrintVisiblePreview), function() { printBeforePreviewReady = false; return waitForInitialPreview() @@ -131,9 +136,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/print_preview_app_test.js b/chrome/test/data/webui/print_preview/print_preview_app_test.js index 96ee612..a3921ca 100644 --- a/chrome/test/data/webui/print_preview/print_preview_app_test.js +++ b/chrome/test/data/webui/print_preview/print_preview_app_test.js
@@ -2,28 +2,35 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview_app_test', function() { +import {NativeLayer, CloudPrintInterface, setCloudPrintInterfaceForTesting, PluginProxy, Destination, DuplexMode } from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate, getGoogleDriveDestination} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; + + window.print_preview_app_test = {}; + print_preview_app_test.suiteName = 'PrintPreviewAppTest'; /** @enum {string} */ - const TestNames = { + print_preview_app_test.TestNames = { PrintToGoogleDrive: 'print to google drive', PrintPresets: 'print presets', }; - const suiteName = 'PrintPreviewAppTest'; - suite(suiteName, function() { + suite(print_preview_app_test.suiteName, function() { /** @type {?PrintPreviewAppElement} */ let page = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {?cloudprint.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let cloudPrintInterface = null; - /** @type {?print_preview.PluginProxy} */ + /** @type {?PluginProxy} */ let pluginProxy = null; - /** @type {!print_preview.NativeInitialSettings} */ + /** @type {!NativeInitialSettings} */ const initialSettings = { isInKioskAutoPrintMode: false, isInAppKioskMode: false, @@ -45,15 +52,15 @@ setup(function() { // Stub out the native layer, the cloud print interface, and the plugin. PolymerTest.clearBody(); - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(initialSettings.printerName)); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); - cloudprint.setCloudPrintInterfaceForTesting(cloudPrintInterface); - pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + getCddTemplate(initialSettings.printerName)); + cloudPrintInterface = new CloudPrintInterfaceStub(); + setCloudPrintInterfaceForTesting(cloudPrintInterface); + pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); page = document.createElement('print-preview-app'); document.body.appendChild(page); @@ -62,12 +69,13 @@ }); // Regression test for https://crbug.com/936029 - test(assert(TestNames.PrintToGoogleDrive), async () => { + test(assert(print_preview_app_test.TestNames.PrintToGoogleDrive), + async () => { // Set up the UI to have Google Drive as the printer. - page.destination_ = print_preview_test_utils.getGoogleDriveDestination( + page.destination_ = getGoogleDriveDestination( 'foo@chromium.org'); page.destination_.capabilities = - print_preview_test_utils.getCddTemplate(page.destination_.id); + getCddTemplate(page.destination_.id); // Trigger print. const sidebar = page.$$('print-preview-sidebar'); @@ -79,27 +87,22 @@ assertEquals('sample data', args.data); assertEquals('DocumentABC123', args.documentTitle); assertEquals( - print_preview.Destination.GooglePromotedId.DOCS, args.destination.id); + Destination.GooglePromotedId.DOCS, args.destination.id); assertEquals('1.0', JSON.parse(args.printTicket).version); }); - test(assert(TestNames.PrintPresets), function() { + test(assert(print_preview_app_test.TestNames.PrintPresets), function() { assertEquals(1, page.settings.copies.value); assertFalse(page.settings.duplex.value); // Send preset values of duplex LONG_EDGE and 2 copies. const copies = 2; - const duplex = print_preview.DuplexMode.LONG_EDGE; - cr.webUIListenerCallback('print-preset-options', true, copies, duplex); + const duplex = DuplexMode.LONG_EDGE; + window.cr.webUIListenerCallback( + 'print-preset-options', true, copies, duplex); assertEquals(copies, page.getSettingValue('copies')); assertTrue(page.getSettingValue('duplex')); assertFalse(page.getSetting('duplex').setFromUi); assertFalse(page.getSetting('copies').setFromUi); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/print_preview_interactive_ui_tests.js b/chrome/test/data/webui/print_preview/print_preview_interactive_ui_tests.js index d2e5142..b7c475c 100644 --- a/chrome/test/data/webui/print_preview/print_preview_interactive_ui_tests.js +++ b/chrome/test/data/webui/print_preview/print_preview_interactive_ui_tests.js
@@ -6,6 +6,7 @@ // Polymer BrowserTest fixture. GEN_INCLUDE(['//chrome/test/data/webui/polymer_interactive_ui_test.js']); +GEN('#include "services/network/public/cpp/features.h"'); const PrintPreviewInteractiveUITest = class extends PolymerInteractiveUITest { /** @override */ @@ -16,11 +17,16 @@ /** @override */ get extraLibraries() { return [ - ...super.extraLibraries, - '//ui/webui/resources/js/assert.js', + '//third_party/mocha/mocha.js', + '//chrome/test/data/webui/mocha_adapter.js', ]; } + /** @override */ + get featureList() { + return {enabled: ['network::features::kOutOfBlinkCors']}; + } + // The name of the mocha suite. Should be overridden by subclasses. get suiteName() { return null; @@ -37,15 +43,7 @@ class extends PrintPreviewInteractiveUITest { /** @override */ get browsePreload() { - return 'chrome://print/ui/button_strip.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//chrome/test/data/webui/test_util.js', - 'button_strip_interactive_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/button_strip_interactive_test.js'; } /** @override */ @@ -72,19 +70,7 @@ class extends PrintPreviewInteractiveUITest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//chrome/test/data/webui/test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'destination_dialog_interactive_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_dialog_interactive_test.js'; } /** @override */ @@ -120,16 +106,7 @@ class extends PrintPreviewInteractiveUITest { /** @override */ get browsePreload() { - return 'chrome://print/ui/pages_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'pages_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/pages_settings_test.js'; } /** @override */ @@ -160,16 +137,7 @@ class extends PrintPreviewInteractiveUITest { /** @override */ get browsePreload() { - return 'chrome://print/ui/number_settings_section.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'number_settings_section_interactive_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/number_settings_section_interactive_test.js'; } /** @override */ @@ -190,17 +158,7 @@ class extends PrintPreviewInteractiveUITest { /** @override */ get browsePreload() { - return 'chrome://print/ui/scaling_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/util.js', - '../test_util.js', - 'print_preview_test_utils.js', - 'scaling_settings_interactive_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/scaling_settings_interactive_test.js'; } /** @override */
diff --git a/chrome/test/data/webui/print_preview/print_preview_sidebar_test.js b/chrome/test/data/webui/print_preview/print_preview_sidebar_test.js index b9a67d2..69187eb 100644 --- a/chrome/test/data/webui/print_preview/print_preview_sidebar_test.js +++ b/chrome/test/data/webui/print_preview/print_preview_sidebar_test.js
@@ -2,21 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview_sidebar_test', function() { +import {NativeLayer, CloudPrintInterface, setCloudPrintInterfaceForTesting} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {getCddTemplate} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; + + window.print_preview_sidebar_test = {}; + print_preview_sidebar_test.suiteName = 'PrintPreviewSidebarTest'; /** @enum {string} */ - const TestNames = { + print_preview_sidebar_test.TestNames = { SettingsSectionsVisibilityChange: 'settings sections visibility change', }; - const suiteName = 'PrintPreviewSidebarTest'; - suite(suiteName, function() { + suite(print_preview_sidebar_test.suiteName, function() { /** @type {?PrintPreviewSidebarElement} */ let sidebar = null; /** @type {?PrintPreviewModelElement} */ let model = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; /** @type {?cloudprint.CloudPrintInterface} */ @@ -25,11 +32,11 @@ /** @override */ setup(function() { // Stub out the native layer and cloud print interface - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate('FooDevice')); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); + getCddTemplate('FooDevice')); + cloudPrintInterface = new CloudPrintInterfaceStub(); PolymerTest.clearBody(); model = document.createElement('print-preview-model'); @@ -37,7 +44,7 @@ sidebar = document.createElement('print-preview-sidebar'); sidebar.settings = model.settings; - test_util.fakeDataBind(model, sidebar, 'settings'); + fakeDataBind(model, sidebar, 'settings'); document.body.appendChild(sidebar); sidebar.init(false, 'FooDevice', null); sidebar.cloudPrintInterface = cloudPrintInterface; @@ -45,7 +52,9 @@ return nativeLayer.whenCalled('getPrinterCapabilities'); }); - test(assert(TestNames.SettingsSectionsVisibilityChange), function() { + test(assert( + print_preview_sidebar_test.TestNames.SettingsSectionsVisibilityChange), + function() { const moreSettingsElement = sidebar.$$('print-preview-more-settings'); moreSettingsElement.$.label.click(); const camelToKebab = s => s.replace(/([A-Z])/g, '-$1').toLowerCase(); @@ -63,9 +72,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/print_preview_test_utils.js b/chrome/test/data/webui/print_preview/print_preview_test_utils.js index e64146a7..f48a2f55 100644 --- a/chrome/test/data/webui/print_preview/print_preview_test_utils.js +++ b/chrome/test/data/webui/print_preview/print_preview_test_utils.js
@@ -2,9 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('print_preview_test_utils', function() { - /** @return {!print_preview.NativeInitialSettings} */ - function getDefaultInitialSettings() { +import {Destination, DestinationCertificateStatus, DestinationConnectionStatus, DestinationOrigin, DestinationStore, DestinationType} from 'chrome://print/print_preview.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + /** @return {!NativeInitialSettings} */ + export function getDefaultInitialSettings() { return { isInKioskAutoPrintMode: false, isInAppKioskMode: false, @@ -26,9 +31,9 @@ /** * @param {string} printerId * @param {string=} opt_printerName Defaults to an empty string. - * @return {!print_preview.PrinterCapabilitiesResponse} + * @return {!PrinterCapabilitiesResponse} */ - function getCddTemplate(printerId, opt_printerName) { + export function getCddTemplate(printerId, opt_printerName) { const template = { printer: { deviceName: printerId, @@ -84,7 +89,7 @@ } } }; - if (cr.isChromeOS) { + if (isChromeOS) { template.capabilities.printer.pin = {supported: true}; } return template; @@ -98,12 +103,11 @@ * @param {number} numSettings * @param {string} printerId * @param {string=} opt_printerName Defaults to an empty string. - * @return {!print_preview.PrinterCapabilitiesResponse} + * @return {!PrinterCapabilitiesResponse} */ - function getCddTemplateWithAdvancedSettings( + export function getCddTemplateWithAdvancedSettings( numSettings, printerId, opt_printerName) { - const template = - print_preview_test_utils.getCddTemplate(printerId, opt_printerName); + const template = getCddTemplate(printerId, opt_printerName); if (numSettings < 1) { return template; } @@ -174,27 +178,27 @@ * @param {string} id Printer id * @param {string} name Printer display name * @param {boolean} invalid Whether printer has an invalid certificate. - * @return {!print_preview.Destination} + * @return {!Destination} */ - function createDestinationWithCertificateStatus(id, name, invalid) { + export function createDestinationWithCertificateStatus(id, name, invalid) { const tags = { certificateStatus: invalid ? - print_preview.DestinationCertificateStatus.NO : - print_preview.DestinationCertificateStatus.UNKNOWN, + DestinationCertificateStatus.NO : + DestinationCertificateStatus.UNKNOWN, account: 'foo@chromium.org', }; - const dest = new print_preview.Destination( - id, print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, name, - print_preview.DestinationConnectionStatus.ONLINE, tags); + const dest = new Destination( + id, DestinationType.GOOGLE, + DestinationOrigin.COOKIES, name, + DestinationConnectionStatus.ONLINE, tags); return dest; } /** - * @return {!print_preview.PrinterCapabilitiesResponse} The capabilities of + * @return {!PrinterCapabilitiesResponse} The capabilities of * the Save as PDF destination. */ - function getPdfPrinter() { + export function getPdfPrinter() { return { printer: { deviceName: 'Save as PDF', @@ -224,12 +228,12 @@ /** * Get the default media size for |device|. - * @param {!print_preview.PrinterCapabilitiesResponse} device + * @param {!PrinterCapabilitiesResponse} device * @return {{width_microns: number, * height_microns: number}} The width and height of the default * media. */ - function getDefaultMediaSize(device) { + export function getDefaultMediaSize(device) { const size = device.capabilities.printer.media_size.option.find( opt => opt.is_default); return { @@ -240,10 +244,10 @@ /** * Get the default page orientation for |device|. - * @param {!print_preview.PrinterCapabilitiesResponse} device + * @param {!PrinterCapabilitiesResponse} device * @return {string} The default orientation. */ - function getDefaultOrientation(device) { + export function getDefaultOrientation(device) { return device.capabilities.printer.page_orientation.option .find(opt => opt.is_default) .type; @@ -252,14 +256,14 @@ /** * Creates 5 local destinations, adds them to |localDestinations| and * sets the capabilities in |nativeLayer|, if it is non-null. - * @param {?print_preview.NativeLayerStub} nativeLayer - * @param {!Array<!print_preview.LocalDestinationInfo>} localDestinations - * @return {!Array<!print_preview.Destination>} + * @param {?NativeLayerStub} nativeLayer + * @param {!Array<!LocalDestinationInfo>} localDestinations + * @return {!Array<!Destination>} */ - function getDestinations(nativeLayer, localDestinations) { + export function getDestinations(nativeLayer, localDestinations) { const destinations = []; - const origin = cr.isChromeOS ? print_preview.DestinationOrigin.CROS : - print_preview.DestinationOrigin.LOCAL; + const origin = isChromeOS ? DestinationOrigin.CROS : + DestinationOrigin.LOCAL; // Five destinations. FooDevice is the system default. [{deviceName: 'ID1', printerName: 'One'}, {deviceName: 'ID2', printerName: 'Two'}, @@ -267,15 +271,14 @@ {deviceName: 'ID4', printerName: 'Four'}, {deviceName: 'FooDevice', printerName: 'FooName'}] .forEach((info, index) => { - const destination = new print_preview.Destination( - info.deviceName, print_preview.DestinationType.LOCAL, origin, + const destination = new Destination( + info.deviceName, DestinationType.LOCAL, origin, info.printerName, - print_preview.DestinationConnectionStatus.ONLINE); + DestinationConnectionStatus.ONLINE); if (nativeLayer) { nativeLayer.setLocalDestinationCapabilities({ printer: info, - capabilities: print_preview_test_utils.getCddTemplate( - info.deviceName, info.printerName), + capabilities: getCddTemplate(info.deviceName, info.printerName), }); } localDestinations.push(info); @@ -286,9 +289,9 @@ /** * Returns a media size capability with custom and localized names. - * @return {!{ option: Array<!print_preview.SelectOption> }} + * @return {!{ option: Array<!SelectOption> }} */ - function getMediaSizeCapabilityWithCustomNames() { + export function getMediaSizeCapabilityWithCustomNames() { const customLocalizedMediaName = 'Vendor defined localized media name'; const customMediaName = 'Vendor defined media name'; @@ -320,14 +323,14 @@ * @return {!Promise} Promise that resolves when the input-change event has * fired. */ - function triggerInputEvent(inputElement, input, parentElement) { + export function triggerInputEvent(inputElement, input, parentElement) { inputElement.value = input; inputElement.dispatchEvent( new CustomEvent('input', {composed: true, bubbles: true})); - return test_util.eventToPromise('input-change', parentElement); + return eventToPromise('input-change', parentElement); } - function setupTestListenerElement() { + export function setupTestListenerElement() { const domModule = document.createElement('dom-module'); domModule.setAttribute('id', 'test-listener-element'); domModule.appendChild(document.createElement('template')); @@ -338,36 +341,36 @@ }); } - /** @return {!print_preview.DestinationStore} */ - function createDestinationStore() { + /** @return {!DestinationStore} */ + export function createDestinationStore() { const testListenerElement = document.createElement('test-listener-element'); document.body.appendChild(testListenerElement); - return new print_preview.DestinationStore( + return new DestinationStore( testListenerElement.addWebUIListener.bind(testListenerElement)); } /** * @param {string} account The user account the destination should be * associated with. - * @return {!print_preview.Destination} The Google Drive destination. + * @return {!Destination} The Google Drive destination. */ - function getGoogleDriveDestination(account) { - return new print_preview.Destination( - print_preview.Destination.GooglePromotedId.DOCS, - print_preview.DestinationType.GOOGLE, - print_preview.DestinationOrigin.COOKIES, - print_preview.Destination.GooglePromotedId.DOCS, - print_preview.DestinationConnectionStatus.ONLINE, {account: account}); + export function getGoogleDriveDestination(account) { + return new Destination( + Destination.GooglePromotedId.DOCS, + DestinationType.GOOGLE, + DestinationOrigin.COOKIES, + Destination.GooglePromotedId.DOCS, + DestinationConnectionStatus.ONLINE, {account: account}); } - /** @return {!print_preview.Destination} The Save as PDF destination. */ - function getSaveAsPdfDestination() { - return new print_preview.Destination( - print_preview.Destination.GooglePromotedId.SAVE_AS_PDF, - print_preview.DestinationType.LOCAL, - print_preview.DestinationOrigin.LOCAL, + /** @return {!Destination} The Save as PDF destination. */ + export function getSaveAsPdfDestination() { + return new Destination( + Destination.GooglePromotedId.SAVE_AS_PDF, + DestinationType.LOCAL, + DestinationOrigin.LOCAL, loadTimeData.getString('printToPDF'), - print_preview.DestinationConnectionStatus.ONLINE); + DestinationConnectionStatus.ONLINE); } /** @@ -377,30 +380,9 @@ * @return {!Promise} Promise that resolves when the option has been * selected and the process-select-change event has fired. */ - function selectOption(section, option) { + export function selectOption(section, option) { const select = section.$$('select'); select.value = option; select.dispatchEvent(new CustomEvent('change')); - return test_util.eventToPromise('process-select-change', section); + return eventToPromise('process-select-change', section); } - - return { - createDestinationStore: createDestinationStore, - createDestinationWithCertificateStatus: - createDestinationWithCertificateStatus, - getCddTemplate: getCddTemplate, - getCddTemplateWithAdvancedSettings: getCddTemplateWithAdvancedSettings, - getDefaultInitialSettings: getDefaultInitialSettings, - getDefaultMediaSize: getDefaultMediaSize, - getDefaultOrientation: getDefaultOrientation, - getDestinations: getDestinations, - getGoogleDriveDestination: getGoogleDriveDestination, - getMediaSizeCapabilityWithCustomNames: - getMediaSizeCapabilityWithCustomNames, - getPdfPrinter: getPdfPrinter, - getSaveAsPdfDestination: getSaveAsPdfDestination, - selectOption: selectOption, - setupTestListenerElement: setupTestListenerElement, - triggerInputEvent: triggerInputEvent, - }; -});
diff --git a/chrome/test/data/webui/print_preview/print_preview_ui_browsertest.js b/chrome/test/data/webui/print_preview/print_preview_ui_browsertest.js index 74a2f146..b04b3d6 100644 --- a/chrome/test/data/webui/print_preview/print_preview_ui_browsertest.js +++ b/chrome/test/data/webui/print_preview/print_preview_ui_browsertest.js
@@ -5,6 +5,7 @@ /** @fileoverview Runs the Print Preview tests. */ GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']); +GEN('#include "services/network/public/cpp/features.h"'); const PrintPreviewTest = class extends PolymerTest { /** @override */ @@ -15,8 +16,8 @@ /** @override */ get extraLibraries() { return [ - ...super.extraLibraries, - '//ui/webui/resources/js/assert.js', + '//third_party/mocha/mocha.js', + '//chrome/test/data/webui/mocha_adapter.js', ]; } @@ -25,6 +26,11 @@ return null; } + /** @override */ + get featureList() { + return {enabled: ['network::features::kOutOfBlinkCors']}; + } + /** @param {string} testName The name of the test to run. */ runMochaTest(testName) { runMochaTest(this.suiteName, testName); @@ -35,20 +41,7 @@ var PrintPreviewAppTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'print_preview_app_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/print_preview_app_test.js'; } /** @override */ @@ -69,19 +62,7 @@ var PrintPreviewSidebarTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/sidebar.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'print_preview_sidebar_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/print_preview_sidebar_test.js'; } /** @override */ @@ -100,16 +81,7 @@ var PrintPreviewPagesSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/pages_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'pages_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/pages_settings_test.js'; } /** @override */ @@ -138,19 +110,7 @@ var PrintPreviewPolicyTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'policy_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/policy_test.js'; } /** @override */ @@ -179,16 +139,7 @@ var PrintPreviewSettingsSelectTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/settings_select.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'settings_select_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/settings_select_test.js'; } }; @@ -200,15 +151,7 @@ var PrintPreviewSelectBehaviorTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/select_behavior.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'select_behavior_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/select_behavior_test.js'; } /** @override */ @@ -225,15 +168,7 @@ var PrintPreviewNumberSettingsSectionTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/number_settings_section.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'number_settings_section_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/number_settings_section_test.js'; } /** @override */ @@ -252,18 +187,7 @@ var PrintPreviewRestoreStateTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'restore_state_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/restore_state_test.js'; } /** @override */ @@ -288,16 +212,7 @@ var PrintPreviewModelTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/data/model.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'model_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/model_test.js'; } /** @override */ @@ -330,7 +245,7 @@ var PrintPreviewModelSettingsAvailabilityTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/data/model.html'; + return 'chrome://print/test_loader.html?module=print_preview/model_settings_availability_test.js'; } /** @override */ @@ -352,16 +267,7 @@ var PrintPreviewModelSettingsPolicyTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/data/model.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'model_settings_policy_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/model_settings_policy_test.js'; } }; @@ -374,18 +280,7 @@ var PrintPreviewPreviewGenerationTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'preview_generation_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/preview_generation_test.js'; } /** @override */ @@ -471,16 +366,7 @@ var PrintPreviewLinkContainerTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/link_container.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'link_container_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/link_container_test.js'; } /** @override */ @@ -513,19 +399,7 @@ var PrintPreviewSystemDialogBrowserTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'system_dialog_browsertest.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/system_dialog_browsertest.js'; } /** @override */ @@ -553,21 +427,7 @@ var PrintPreviewInvalidSettingsBrowserTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/cr/event_target.js', - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'invalid_settings_browsertest.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/invalid_settings_browsertest.js'; } /** @override */ @@ -607,20 +467,7 @@ var PrintPreviewDestinationStoreTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/data/destination_store.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/web_ui_listener_behavior.js', - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'destination_store_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_store_test.js'; } /** @override */ @@ -706,21 +553,7 @@ var PrintPreviewDestinationDialogTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_dialog.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/web_ui_listener_behavior.js', - '//ui/webui/resources/js/cr/event_target.js', - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'destination_dialog_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_dialog_test.js'; } /** @override */ @@ -749,16 +582,7 @@ var PrintPreviewAdvancedDialogTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/advanced_settings_dialog.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'advanced_dialog_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/advanced_dialog_test.js'; } /** @override */ @@ -800,19 +624,7 @@ var PrintPreviewPreviewAreaTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/preview_area.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'preview_area_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/preview_area_test.js'; } /** @override */ @@ -833,16 +645,7 @@ var PrintPreviewCustomMarginsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/margin_control_container.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'custom_margins_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/custom_margins_test.js'; } /** @override */ @@ -919,23 +722,58 @@ this.runMochaTest(custom_margins_test.TestNames.ControlsDisabledOnError); }); +GEN('#if defined(OS_CHROMEOS)'); +// eslint-disable-next-line no-var +var PrintPreviewDestinationSearchTestChromeOS = class extends PrintPreviewTest { + /** @override */ + get browsePreload() { + return 'chrome://print/test_loader.html?module=print_preview/destination_search_test_chromeos.js'; + } + + /** @override */ + get suiteName() { + return destination_search_test_chromeos.suiteName; + } +}; + +TEST_F( + 'PrintPreviewDestinationSearchTestChromeOS', + 'ReceiveSuccessfulSetup', function() { + this.runMochaTest( + destination_search_test_chromeos.TestNames.ReceiveSuccessfulSetup); + }); + +TEST_F('PrintPreviewDestinationSearchTestChromeOS', + 'ResolutionFails', function() { + this.runMochaTest(destination_search_test_chromeos.TestNames.ResolutionFails); +}); + +TEST_F('PrintPreviewDestinationSearchTestChromeOS', + 'ReceiveFailedSetup', function() { + this.runMochaTest( + destination_search_test_chromeos.TestNames.ReceiveFailedSetup); +}); + +TEST_F( + 'PrintPreviewDestinationSearchTestChromeOS', + 'ReceiveSuccessfultSetupWithPolicies', + function() { + this.runMochaTest( + destination_search_test_chromeos.TestNames.ResolutionFails); + }); + +TEST_F('PrintPreviewDestinationSearchTestChromeOS', 'CloudKioskPrinter', + function() { + this.runMochaTest( + destination_search_test_chromeos.TestNames.CloudKioskPrinter); +}); + +GEN('#else'); // eslint-disable-next-line no-var var PrintPreviewDestinationSearchTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_dialog.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/web_ui_listener_behavior.js', - '../test_util.js', - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'destination_search_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_search_test.js'; } /** @override */ @@ -945,49 +783,21 @@ }; TEST_F( - 'PrintPreviewDestinationSearchTest', 'ReceiveSuccessfulSetup', function() { + 'PrintPreviewDestinationSearchTest', 'GetCapabilitiesSucceeds', function() { this.runMochaTest( - destination_search_test.TestNames.ReceiveSuccessfulSetup); + destination_search_test.TestNames.GetCapabilitiesSucceeds); }); -GEN('#if defined(OS_CHROMEOS)'); -TEST_F('PrintPreviewDestinationSearchTest', 'ResolutionFails', function() { - this.runMochaTest(destination_search_test.TestNames.ResolutionFails); -}); - -TEST_F('PrintPreviewDestinationSearchTest', 'ReceiveFailedSetup', function() { - this.runMochaTest(destination_search_test.TestNames.ReceiveFailedSetup); -}); - -TEST_F( - 'PrintPreviewDestinationSearchTest', 'ReceiveSuccessfultSetupWithPolicies', - function() { - this.runMochaTest(destination_search_test.TestNames.ResolutionFails); - }); - -GEN('#else'); // !defined(OS_CHROMEOS) TEST_F('PrintPreviewDestinationSearchTest', 'GetCapabilitiesFails', function() { this.runMochaTest(destination_search_test.TestNames.GetCapabilitiesFails); }); -GEN('#endif'); // defined(OS_CHROMEOS) - -TEST_F('PrintPreviewDestinationSearchTest', 'CloudKioskPrinter', function() { - this.runMochaTest(destination_search_test.TestNames.CloudKioskPrinter); -}); +GEN('#endif'); // eslint-disable-next-line no-var var PrintPreviewHeaderTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/header.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'header_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/header_test.js'; } /** @override */ @@ -1020,15 +830,7 @@ var PrintPreviewButtonStripTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/button_strip.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'button_strip_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/button_strip_test.js'; } /** @override */ @@ -1053,15 +855,7 @@ var PrintPreviewDestinationItemTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_list_item.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - 'print_preview_test_utils.js', - 'destination_item_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_item_test.js'; } /** @override */ @@ -1094,16 +888,7 @@ var PrintPreviewAdvancedItemTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/advanced_settings_item.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'advanced_item_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/advanced_item_test.js'; } /** @override */ @@ -1140,15 +925,7 @@ var PrintPreviewDestinationListTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_list.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'destination_list_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_list_test.js'; } /** @override */ @@ -1171,18 +948,7 @@ var PrintPreviewPrintButtonTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'print_button_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/print_button_test.js'; } /** @override */ @@ -1203,19 +969,7 @@ var PrintPreviewKeyEventTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/app.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'native_layer_stub.js', - 'plugin_stub.js', - 'print_preview_test_utils.js', - 'key_event_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/key_event_test.js'; } /** @override */ @@ -1266,16 +1020,7 @@ var PrintPreviewDestinationSelectTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_select.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'destination_select_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_select_test.js'; } /** @override */ @@ -1292,21 +1037,7 @@ var PrintPreviewDestinationSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/destination_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '//ui/webui/resources/js/web_ui_listener_behavior.js', - '../test_browser_proxy.js', - '../test_util.js', - 'cloud_print_interface_stub.js', - 'print_preview_test_utils.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'destination_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/destination_settings_test.js'; } /** @override */ @@ -1383,16 +1114,7 @@ var PrintPreviewScalingSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/scaling_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'scaling_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/scaling_settings_test.js'; } /** @override */ @@ -1423,16 +1145,7 @@ var PrintPreviewCopiesSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/copies_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'copies_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/copies_settings_test.js'; } }; @@ -1444,16 +1157,7 @@ var PrintPreviewMediaSizeSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/media_size_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'media_size_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/media_size_settings_test.js'; } }; @@ -1465,16 +1169,7 @@ var PrintPreviewDpiSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/dpi_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'dpi_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/dpi_settings_test.js'; } }; @@ -1486,16 +1181,7 @@ var PrintPreviewOtherOptionsSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/other_options_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'other_options_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/other_options_settings_test.js'; } }; @@ -1507,16 +1193,7 @@ var PrintPreviewLayoutSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/layout_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'layout_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/layout_settings_test.js'; } }; @@ -1528,16 +1205,7 @@ var PrintPreviewColorSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/color_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'color_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/color_settings_test.js'; } }; @@ -1549,16 +1217,7 @@ var PrintPreviewMarginsSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/margins_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'margins_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/margins_settings_test.js'; } }; @@ -1570,16 +1229,7 @@ var PrintPreviewPagesPerSheetSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/pages_per_sheet_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'pages_per_sheet_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/pages_per_sheet_settings_test.js'; } }; @@ -1591,16 +1241,7 @@ var PrintPreviewDuplexSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/duplex_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'duplex_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/duplex_settings_test.js'; } }; @@ -1613,16 +1254,7 @@ var PrintPreviewPinSettingsTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/ui/pin_settings.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - 'print_preview_test_utils.js', - 'pin_settings_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/pin_settings_test.js'; } }; @@ -1635,19 +1267,7 @@ var PrintPreviewUserManagerTest = class extends PrintPreviewTest { /** @override */ get browsePreload() { - return 'chrome://print/data/user_manager.html'; - } - - /** @override */ - get extraLibraries() { - return super.extraLibraries.concat([ - '../test_util.js', - '../test_browser_proxy.js', - 'cloud_print_interface_stub.js', - 'native_layer_stub.js', - 'print_preview_test_utils.js', - 'user_manager_test.js', - ]); + return 'chrome://print/test_loader.html?module=print_preview/user_manager_test.js'; } };
diff --git a/chrome/test/data/webui/print_preview/restore_state_test.js b/chrome/test/data/webui/print_preview/restore_state_test.js index 058468f..12de8831d 100644 --- a/chrome/test/data/webui/print_preview/restore_state_test.js +++ b/chrome/test/data/webui/print_preview/restore_state_test.js
@@ -2,31 +2,37 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('restore_state_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {isChromeOS} from 'chrome://resources/js/cr.m.js'; +import {NativeLayer, PluginProxy, getInstance, MarginsType, ScalingType} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {getCddTemplate, getCddTemplateWithAdvancedSettings, getDefaultInitialSettings} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.restore_state_test = {}; + restore_state_test.suiteName = 'RestoreStateTest'; /** @enum {string} */ - const TestNames = { + restore_state_test.TestNames = { RestoreTrueValues: 'restore true values', RestoreFalseValues: 'restore false values', SaveValues: 'save values', }; - const suiteName = 'RestoreStateTest'; - suite(suiteName, function() { + suite(restore_state_test.suiteName, function() { let page = null; let nativeLayer = null; - const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); + const initialSettings = getDefaultInitialSettings(); /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); PolymerTest.clearBody(); }); /** - * @param {!print_preview.SerializedSettings} stickySettings Settings + * @param {!SerializedSettings} stickySettings Settings * to verify. */ function verifyStickySettingsApplied(stickySettings) { @@ -66,7 +72,7 @@ } /** - * @param {!print_preview.SerializedSettings} stickySettings + * @param {!SerializedSettings} stickySettings * @return {!Promise} Promise that resolves when initialization is done and * settings have been verified. */ @@ -75,10 +81,10 @@ nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplateWithAdvancedSettings( + getCddTemplateWithAdvancedSettings( 2, initialSettings.printerName)); - const pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + const pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); page = document.createElement('print-preview-app'); document.body.appendChild(page); @@ -97,7 +103,7 @@ * Tests state restoration with all boolean settings set to true, scaling = * 90, dpi = 100, custom square paper, and custom margins. */ - test(assert(TestNames.RestoreTrueValues), function() { + test(assert(restore_state_test.TestNames.RestoreTrueValues), function() { const stickySettings = { version: 2, recentDestinations: [], @@ -115,8 +121,8 @@ }, marginsType: 3, /* custom */ scaling: '90', - scalingType: print_preview.ScalingType.CUSTOM, - scalingTypePdf: print_preview.ScalingType.FIT_TO_PAGE, + scalingType: ScalingType.CUSTOM, + scalingTypePdf: ScalingType.FIT_TO_PAGE, isHeaderFooterEnabled: true, isCssBackgroundEnabled: true, isCollateEnabled: true, @@ -125,7 +131,7 @@ isLandscapeEnabled: true, isColorEnabled: true, }; - if (cr.isChromeOS) { + if (isChromeOS) { stickySettings.pin = true; stickySettings.pinValue = '0000'; } @@ -136,7 +142,7 @@ * Tests state restoration with all boolean settings set to false, scaling = * 120, dpi = 200, letter paper and default margins. */ - test(assert(TestNames.RestoreFalseValues), function() { + test(assert(restore_state_test.TestNames.RestoreFalseValues), function() { const stickySettings = { version: 2, recentDestinations: [], @@ -155,8 +161,8 @@ }, marginsType: 0, /* default */ scaling: '120', - scalingType: print_preview.ScalingType.DEFAULT, - scalingTypePdf: print_preview.ScalingType.DEFAULT, + scalingType: ScalingType.DEFAULT, + scalingTypePdf: ScalingType.DEFAULT, isHeaderFooterEnabled: false, isCssBackgroundEnabled: false, isCollateEnabled: false, @@ -165,7 +171,7 @@ isLandscapeEnabled: false, isColorEnabled: false, }; - if (cr.isChromeOS) { + if (isChromeOS) { stickySettings.pin = false; stickySettings.pinValue = ''; } @@ -176,7 +182,7 @@ * Tests that setting the settings values results in the correct serialized * values being sent to the native layer. */ - test(assert(TestNames.SaveValues), function() { + test(assert(restore_state_test.TestNames.SaveValues), function() { /** * Array of section names, setting names, keys for serialized state, and * values for testing. @@ -219,7 +225,7 @@ section: 'print-preview-margins-settings', settingName: 'margins', key: 'marginsType', - value: print_preview.MarginsType.MINIMUM, + value: MarginsType.MINIMUM, }, { section: 'print-preview-dpi-settings', @@ -231,13 +237,13 @@ section: 'print-preview-scaling-settings', settingName: 'scalingType', key: 'scalingType', - value: print_preview.ScalingType.CUSTOM, + value: ScalingType.CUSTOM, }, { section: 'print-preview-scaling-settings', settingName: 'scalingTypePdf', key: 'scalingTypePdf', - value: print_preview.ScalingType.CUSTOM, + value: ScalingType.CUSTOM, }, { section: 'print-preview-scaling-settings', @@ -279,7 +285,7 @@ }, } ]; - if (cr.isChromeOS) { + if (isChromeOS) { testData.push( { section: 'print-preview-pin-settings', @@ -298,12 +304,12 @@ // Setup nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(initialSettings.printerName)); + getCddTemplate(initialSettings.printerName)); page = document.createElement('print-preview-app'); document.body.appendChild(page); const previewArea = page.$$('print-preview-preview-area'); - previewArea.plugin_ = new print_preview.PDFPluginStub( + previewArea.plugin_ = new PDFPluginStub( previewArea.onPluginLoad_.bind(previewArea)); return nativeLayer.whenCalled('getInitialSettings') @@ -319,7 +325,7 @@ // Since advanced options settings doesn't set this setting in // production, just use the model instead of creating the dialog. const element = testValue.settingName === 'vendorItems' ? - print_preview.Model.getInstance() : + getInstance() : page.$$('print-preview-sidebar').$$(testValue.section); element.setSetting(testValue.settingName, testValue.value); }); @@ -338,9 +344,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/scaling_settings_interactive_test.js b/chrome/test/data/webui/print_preview/scaling_settings_interactive_test.js index 95c464c..666defd 100644 --- a/chrome/test/data/webui/print_preview/scaling_settings_interactive_test.js +++ b/chrome/test/data/webui/print_preview/scaling_settings_interactive_test.js
@@ -2,14 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('scaling_settings_interactive_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {ScalingType} from 'chrome://print/print_preview.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {getDeepActiveElement} from 'chrome://resources/js/util.m.js'; + + window.scaling_settings_interactive_test = {}; + scaling_settings_interactive_test.suiteName = + 'ScalingSettingsInteractiveTest'; /** @enum {string} */ - const TestNames = { + scaling_settings_interactive_test.TestNames = { AutoFocusInput: 'auto focus input', }; - const suiteName = 'ScalingSettingsInteractiveTest'; - suite(suiteName, function() { + suite(scaling_settings_interactive_test.suiteName, function() { /** @type {?PrintPreviewScalingSettingsElement} */ let scalingSection = null; @@ -27,11 +34,12 @@ scalingSection.settings = model.settings; scalingSection.disabled = false; scalingSection.isPdf = false; - test_util.fakeDataBind(model, scalingSection, 'settings'); + fakeDataBind(model, scalingSection, 'settings'); document.body.appendChild(scalingSection); }); - test(assert(TestNames.AutoFocusInput), async () => { + test(assert(scaling_settings_interactive_test.TestNames.AutoFocusInput), + async () => { const scalingInput = scalingSection.$$('print-preview-number-settings-section') .$.userValue.inputElement; @@ -40,14 +48,14 @@ assertFalse(collapse.opened); assertEquals( - print_preview.ScalingType.DEFAULT, + ScalingType.DEFAULT, scalingSection.getSettingValue('scalingType')); // Select custom with the dropdown. This should autofocus the input. await Promise.all([ - print_preview_test_utils.selectOption( + selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM.toString()), - test_util.eventToPromise('transitionend', collapse), + eventToPromise('transitionend', collapse), ]); assertTrue(collapse.opened); assertEquals(scalingInput, getDeepActiveElement()); @@ -55,27 +63,21 @@ // Blur and select default. scalingInput.blur(); await Promise.all([ - print_preview_test_utils.selectOption( + selectOption( scalingSection, scalingSection.ScalingValue.DEFAULT.toString()), - test_util.eventToPromise('transitionend', collapse), + eventToPromise('transitionend', collapse), ]); assertEquals( - print_preview.ScalingType.DEFAULT, + ScalingType.DEFAULT, scalingSection.getSettingValue('scalingType')); assertFalse(scalingSection.$$('iron-collapse').opened); // Set custom in JS, which happens when we set the sticky settings. This // should not autofocus the input. scalingSection.setSetting( - 'scalingType', print_preview.ScalingType.CUSTOM); - await test_util.eventToPromise('transitionend', collapse); + 'scalingType', ScalingType.CUSTOM); + await eventToPromise('transitionend', collapse); assertTrue(collapse.opened); assertNotEquals(scalingInput, getDeepActiveElement()); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/scaling_settings_test.js b/chrome/test/data/webui/print_preview/scaling_settings_test.js index 6dbce92..20d63c0 100644 --- a/chrome/test/data/webui/print_preview/scaling_settings_test.js +++ b/chrome/test/data/webui/print_preview/scaling_settings_test.js
@@ -2,16 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('scaling_settings_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {ScalingType} from 'chrome://print/print_preview.js'; +import {fakeDataBind} from 'chrome://test/test_util.m.js'; +import {selectOption, triggerInputEvent} from 'chrome://test/print_preview/print_preview_test_utils.js'; + + window.scaling_settings_test = {}; + scaling_settings_test.suiteName = 'ScalingSettingsTest'; /** @enum {string} */ - const TestNames = { + scaling_settings_test.TestNames = { ShowCorrectDropdownOptions: 'show correct dropdown options', SetScaling: 'set scaling', InputNotDisabledOnValidityChange: 'input not disabled on validity change', }; - const suiteName = 'ScalingSettingsTest'; - suite(suiteName, function() { + suite(scaling_settings_test.suiteName, function() { /** @type {?PrintPreviewScalingSettingsElement} */ let scalingSection = null; @@ -28,11 +33,11 @@ scalingSection.settings = model.settings; scalingSection.disabled = false; setDocumentPdf(false); - test_util.fakeDataBind(model, scalingSection, 'settings'); + fakeDataBind(model, scalingSection, 'settings'); document.body.appendChild(scalingSection); }); - test(assert(TestNames.ShowCorrectDropdownOptions), function() { + test(assert(scaling_settings_test.TestNames.ShowCorrectDropdownOptions), function() { // Not a PDF document -> No fit to page or fit to paper options. const fitToPageOption = scalingSection.$$( `[value="${scalingSection.ScalingValue.FIT_TO_PAGE}"]`); @@ -58,9 +63,9 @@ /** * @param {string} expectedScaling The expected scaling value. * @param {boolean} valid Whether the scaling setting is valid. - * @param {print_preview.ScalingType} scalingType Expected scaling type for + * @param {ScalingType} scalingType Expected scaling type for * modifiable content. - * @param {print_preview.ScalingType} scalingTypePdf Expected scaling type + * @param {ScalingType} scalingTypePdf Expected scaling type * for PDFs. * @param {string} scalingDisplayValue The value that should be displayed in * the UI for scaling. @@ -80,9 +85,9 @@ scalingSection.$$('print-preview-number-settings-section').getInput(); const expectedCollapseOpened = (scalingSection.getSettingValue('scalingType') === - print_preview.ScalingType.CUSTOM) || + ScalingType.CUSTOM) || (scalingSection.getSettingValue('scalingTypePdf') === - print_preview.ScalingType.CUSTOM); + ScalingType.CUSTOM); const collapse = scalingSection.$$('iron-collapse'); assertEquals(!valid, scalingInput.invalid); assertEquals(scalingDisplayValue, scalingInput.value); @@ -100,7 +105,7 @@ // Verifies that setting the scaling value using the dropdown and/or the // custom input works correctly. - test(assert(TestNames.SetScaling), async () => { + test(assert(scaling_settings_test.TestNames.SetScaling), async () => { // Default is 100 const scalingInput = scalingSection.$$('print-preview-number-settings-section') @@ -112,107 +117,107 @@ // Default is 100 validateState( - '100', true, print_preview.ScalingType.DEFAULT, - print_preview.ScalingType.DEFAULT, '100'); + '100', true, ScalingType.DEFAULT, + ScalingType.DEFAULT, '100'); assertFalse(scalingSection.getSetting('scaling').setFromUi); assertFalse(scalingSection.getSetting('scalingType').setFromUi); assertFalse(scalingSection.getSetting('scalingTypePdf').setFromUi); // Select custom - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM.toString()); validateState( - '100', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '100'); + '100', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '100'); assertTrue(scalingSection.getSetting('scalingType').setFromUi); assertTrue(scalingSection.getSetting('scalingTypePdf').setFromUi); - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( scalingInput, '105', scalingSection); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '105'); assertTrue(scalingSection.getSetting('scaling').setFromUi); // Change to fit to page. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.FIT_TO_PAGE.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.FIT_TO_PAGE, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.FIT_TO_PAGE, '105'); // Change to fit to paper. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.FIT_TO_PAPER.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.FIT_TO_PAPER, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.FIT_TO_PAPER, '105'); // Go back to custom. Restores 105 value. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '105'); // Set scaling to something invalid. Should change setting validity // but not value. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( scalingInput, '5', scalingSection); validateState( - '105', false, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '5'); + '105', false, ScalingType.CUSTOM, + ScalingType.CUSTOM, '5'); // Select fit to page. Should clear the invalid value. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.FIT_TO_PAGE.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.FIT_TO_PAGE, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.FIT_TO_PAGE, '105'); // Custom scaling should set to last valid. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '105'); // Set scaling to something invalid. Should change setting validity // but not value. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( scalingInput, '500', scalingSection); validateState( - '105', false, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '500'); + '105', false, ScalingType.CUSTOM, + ScalingType.CUSTOM, '500'); // Pick default scaling. This should clear the error. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.DEFAULT.toString()); validateState( - '105', true, print_preview.ScalingType.DEFAULT, - print_preview.ScalingType.DEFAULT, '105'); + '105', true, ScalingType.DEFAULT, + ScalingType.DEFAULT, '105'); // Custom scaling should set to last valid. - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM.toString()); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '105'); + '105', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '105'); // Enter a blank value in the scaling field. This should not // change the stored value of scaling or scaling type, to avoid an // unnecessary preview regeneration. - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( scalingInput, '', scalingSection); validateState( - '105', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, ''); + '105', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, ''); }); // Verifies that the input is never disabled when the validity of the // setting changes. - test(assert(TestNames.InputNotDisabledOnValidityChange), async () => { + test(assert(scaling_settings_test.TestNames.InputNotDisabledOnValidityChange), async () => { const numberSection = scalingSection.$$('print-preview-number-settings-section'); const input = numberSection.getInput(); @@ -226,53 +231,47 @@ assertFalse(input.disabled); }); - await print_preview_test_utils.selectOption( + await selectOption( scalingSection, scalingSection.ScalingValue.CUSTOM); - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '90', scalingSection); validateState( - '90', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '90'); + '90', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '90'); // Set invalid input - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '9', scalingSection); validateState( - '90', false, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '9'); + '90', false, ScalingType.CUSTOM, + ScalingType.CUSTOM, '9'); // Restore valid input - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '90', scalingSection); validateState( - '90', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '90'); + '90', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '90'); // Invalid input again - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '9', scalingSection); validateState( - '90', false, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '9'); + '90', false, ScalingType.CUSTOM, + ScalingType.CUSTOM, '9'); // Clear input - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '', scalingSection); validateState( - '90', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, ''); + '90', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, ''); // Set valid input - await print_preview_test_utils.triggerInputEvent( + await triggerInputEvent( input, '50', scalingSection); validateState( - '50', true, print_preview.ScalingType.CUSTOM, - print_preview.ScalingType.CUSTOM, '50'); + '50', true, ScalingType.CUSTOM, + ScalingType.CUSTOM, '50'); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/select_behavior_test.js b/chrome/test/data/webui/print_preview/select_behavior_test.js index 8eebf38..cff0012 100644 --- a/chrome/test/data/webui/print_preview/select_behavior_test.js +++ b/chrome/test/data/webui/print_preview/select_behavior_test.js
@@ -2,14 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('select_behavior_test', function() { +import {SelectBehavior} from 'chrome://print/print_preview.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {eventToPromise} from 'chrome://test/test_util.m.js'; +import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + + window.select_behavior_test = {}; + select_behavior_test.suiteName = 'SelectBehaviorTest'; /** @enum {string} */ - const TestNames = { + select_behavior_test.TestNames = { CallProcessSelectChange: 'call process select change', }; - const suiteName = 'SelectBehaviorTest'; - suite(suiteName, function() { + suite(select_behavior_test.suiteName, function() { /** @type {?TestSelectElement} */ let testSelect = null; @@ -18,52 +23,43 @@ /** @override */ setup(function() { - // In release mode tests, we need to wait for the page to actually import - // the select_behavior.html file, since the tests do not navigate there - // directly. Wait for an element that implements the behavior to be - // defined. - const whenReady = ((typeof print_preview !== 'undefined') && - !!print_preview.SelectBehavior) ? - Promise.resolve() : - customElements.whenDefined('print-preview-layout-settings'); - return whenReady.then(() => { - document.body.innerHTML = ` - <dom-module id="test-select"> - <template> - <select value="{{selectedValue::change}}"> - <option value="0" selected>0</option> - <option value="1">1</option> - <option value="2">2</option> - </select> - </template> - </dom-module> - `; + document.body.innerHTML = ` + <dom-module id="test-select"> + <template> + <select value="{{selectedValue::change}}"> + <option value="0" selected>0</option> + <option value="1">1</option> + <option value="2">2</option> + </select> + </template> + </dom-module> + `; - Polymer({ - is: 'test-select', - behaviors: [print_preview.SelectBehavior], + Polymer({ + is: 'test-select', + behaviors: [SelectBehavior], - onProcessSelectChange: function(value) { - settingValue = value; - this.fire('process-select-change-called', value); - }, - }); - - PolymerTest.clearBody(); - testSelect = document.createElement('test-select'); - document.body.appendChild(testSelect); - testSelect.selectedValue = '0'; + onProcessSelectChange: function(value) { + settingValue = value; + this.fire('process-select-change-called', value); + }, }); + + PolymerTest.clearBody(); + testSelect = document.createElement('test-select'); + document.body.appendChild(testSelect); + testSelect.selectedValue = '0'; }); // Tests that onProcessSelectChange() is called when the select value is // set programmatically or by changing the select element. - test(assert(TestNames.CallProcessSelectChange), function() { + test(assert(select_behavior_test.TestNames.CallProcessSelectChange), + function() { const select = testSelect.$$('select'); assertEquals('0', testSelect.selectedValue); assertEquals('0', select.value); let whenProcessSelectCalled = - test_util.eventToPromise('process-select-change-called', testSelect); + eventToPromise('process-select-change-called', testSelect); testSelect.selectedValue = '1'; // Should be debounced so settingValue has not changed yet. assertEquals('0', settingValue); @@ -71,7 +67,7 @@ .then((e) => { assertEquals('1', e.detail); assertEquals('1', select.value); - whenProcessSelectCalled = test_util.eventToPromise( + whenProcessSelectCalled = eventToPromise( 'process-select-change-called', testSelect); select.value = '0'; select.dispatchEvent(new CustomEvent('change')); @@ -84,9 +80,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/settings_select_test.js b/chrome/test/data/webui/print_preview/settings_select_test.js index 36173bb..b85a505a 100644 --- a/chrome/test/data/webui/print_preview/settings_select_test.js +++ b/chrome/test/data/webui/print_preview/settings_select_test.js
@@ -2,7 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('settings_select_test', function() { +import 'chrome://print/print_preview.js'; +import {assert} from 'chrome://resources/js/assert.m.js'; +import {eventToPromise, fakeDataBind} from 'chrome://test/test_util.m.js'; +import {getMediaSizeCapabilityWithCustomNames, selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; + suite('SettingsSelectTest', function() { /** @type {?PrintPreviewSettingsSelectElement} */ let settingsSelect = null; @@ -19,7 +24,7 @@ settingsSelect = document.createElement('print-preview-settings-select'); settingsSelect.settings = model.settings; settingsSelect.disabled = false; - test_util.fakeDataBind(model, settingsSelect, 'settings'); + fakeDataBind(model, settingsSelect, 'settings'); document.body.appendChild(settingsSelect); }); @@ -29,14 +34,13 @@ // Set a capability with custom paper sizes. settingsSelect.settingName = 'mediaSize'; - settingsSelect.capability = - print_preview_test_utils.getMediaSizeCapabilityWithCustomNames(); + settingsSelect.capability = getMediaSizeCapabilityWithCustomNames(); const customLocalizedMediaName = settingsSelect.capability.option[0] .custom_display_name_localized[0] .value; const customMediaName = settingsSelect.capability.option[1].custom_display_name; - Polymer.dom.flush(); + flush(); const select = settingsSelect.$$('select'); // Verify that the selected option and names are as expected. @@ -67,7 +71,7 @@ {name: 'orange', color: 'orange', size: 5, is_default: true}, ], }; - Polymer.dom.flush(); + flush(); const option0 = JSON.stringify(settingsSelect.capability.option[0]); const option1 = JSON.stringify(settingsSelect.capability.option[1]); const select = settingsSelect.$$('select'); @@ -87,7 +91,7 @@ assertEquals(option1, select.options[1].value); // Verify that selecting an new option in the dropdown sets the setting. - await print_preview_test_utils.selectOption(settingsSelect, option0); + await selectOption(settingsSelect, option0); assertEquals( option0, JSON.stringify(settingsSelect.getSettingValue('fruit'))); assertTrue(settingsSelect.getSetting('fruit').setFromUi); @@ -95,10 +99,9 @@ // Verify that selecting from outside works. settingsSelect.selectValue(option1); - await test_util.eventToPromise('process-select-change', settingsSelect); + await eventToPromise('process-select-change', settingsSelect); assertEquals( option1, JSON.stringify(settingsSelect.getSettingValue('fruit'))); assertEquals(1, select.selectedIndex); }); }); -});
diff --git a/chrome/test/data/webui/print_preview/system_dialog_browsertest.js b/chrome/test/data/webui/print_preview/system_dialog_browsertest.js index f540284..97981316 100644 --- a/chrome/test/data/webui/print_preview/system_dialog_browsertest.js +++ b/chrome/test/data/webui/print_preview/system_dialog_browsertest.js
@@ -2,19 +2,27 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('system_dialog_browsertest', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, NativeLayer, PluginProxy, whenReady} from 'chrome://print/print_preview.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {PDFPluginStub} from 'chrome://test/print_preview/plugin_stub.js'; +import {eventToPromise, waitBeforeNextRender} from 'chrome://test/test_util.m.js'; +import {getCddTemplate, getDefaultInitialSettings, selectOption} from 'chrome://test/print_preview/print_preview_test_utils.js'; +import {isWindows} from 'chrome://resources/js/cr.m.js'; + + window.system_dialog_browsertest = {}; + system_dialog_browsertest.suiteName = 'SystemDialogBrowserTest'; /** @enum {string} */ - const TestNames = { + system_dialog_browsertest.TestNames = { LinkTriggersLocalPrint: 'link triggers local print', InvalidSettingsDisableLink: 'invalid settings disable link', }; - const suiteName = 'SystemDialogBrowserTest'; - suite(suiteName, function() { + suite(system_dialog_browsertest.suiteName, function() { /** @type {?PrintPreviewSidebarElement} */ let sidebar = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; /** @type {?PrintPreviewLinkContainerElement} */ @@ -28,17 +36,17 @@ /** @override */ setup(function() { - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); PolymerTest.clearBody(); const initialSettings = - print_preview_test_utils.getDefaultInitialSettings(); + getDefaultInitialSettings(); nativeLayer.setInitialSettings(initialSettings); nativeLayer.setLocalDestinationCapabilities( - print_preview_test_utils.getCddTemplate(initialSettings.printerName)); - const pluginProxy = new print_preview.PDFPluginStub(); - print_preview.PluginProxy.setInstance(pluginProxy); + getCddTemplate(initialSettings.printerName)); + const pluginProxy = new PDFPluginStub(); + PluginProxy.setInstance(pluginProxy); const page = document.createElement('print-preview-app'); document.body.appendChild(page); @@ -46,8 +54,8 @@ sidebar = page.$$('print-preview-sidebar'); return Promise .all([ - test_util.waitBeforeNextRender(page), - print_preview.Model.whenReady(), + waitBeforeNextRender(page), + whenReady(), nativeLayer.whenCalled('getInitialSettings'), nativeLayer.whenCalled('getPrinterCapabilities'), ]) @@ -57,14 +65,15 @@ }) .then(function() { assertEquals('FooDevice', page.destination_.id); - link = cr.isWindows ? linkContainer.$.systemDialogLink : - linkContainer.$.openPdfInPreviewLink; + link = isWindows ? linkContainer.$.systemDialogLink : + linkContainer.$.openPdfInPreviewLink; printTicketKey = - cr.isWindows ? 'showSystemDialog' : 'OpenPDFInPreview'; + isWindows ? 'showSystemDialog' : 'OpenPDFInPreview'; }); }); - test(assert(TestNames.LinkTriggersLocalPrint), function() { + test(assert(system_dialog_browsertest.TestNames.LinkTriggersLocalPrint), + function() { assertFalse(linkContainer.disabled); assertFalse(link.hidden); link.click(); @@ -75,7 +84,8 @@ }); }); - test(assert(TestNames.InvalidSettingsDisableLink), function() { + test(assert(system_dialog_browsertest.TestNames.InvalidSettingsDisableLink), + function() { assertFalse(linkContainer.disabled); assertFalse(link.hidden); @@ -87,8 +97,7 @@ let previewCalls = 0; // Set scaling settings to custom. - return print_preview_test_utils - .selectOption( + return selectOption( scalingSettings, scalingSettings.ScalingValue.CUSTOM.toString()) .then(() => { previewCalls = nativeLayer.getCallCount('getPreview'); @@ -101,7 +110,7 @@ scalingSettingsInput.dispatchEvent( new CustomEvent('input', {composed: true, bubbles: true})); - return test_util.eventToPromise('input-change', scalingSettings); + return eventToPromise('input-change', scalingSettings); }) .then(() => { // Expect disabled print button @@ -117,9 +126,3 @@ }); }); }); - - return { - suiteName: suiteName, - TestNames: TestNames, - }; -});
diff --git a/chrome/test/data/webui/print_preview/user_manager_test.js b/chrome/test/data/webui/print_preview/user_manager_test.js index 89ba3e972..59add90 100644 --- a/chrome/test/data/webui/print_preview/user_manager_test.js +++ b/chrome/test/data/webui/print_preview/user_manager_test.js
@@ -2,18 +2,23 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -cr.define('user_manager_test', function() { +import {assert} from 'chrome://resources/js/assert.m.js'; +import {DestinationStore, InvitationStore, NativeLayer} from 'chrome://print/print_preview.js'; +import {CloudPrintInterfaceStub} from 'chrome://test/print_preview/cloud_print_interface_stub.js'; +import {NativeLayerStub} from 'chrome://test/print_preview/native_layer_stub.js'; +import {createDestinationStore, getDestinations, getGoogleDriveDestination, setupTestListenerElement} from 'chrome://test/print_preview/print_preview_test_utils.js'; + suite('UserManagerTest', function() { /** @type {?PrintPreviewUserManagerElement} */ let userManager = null; - /** @type {?print_preview.DestinationStore} */ + /** @type {?DestinationStore} */ let destinationStore = null; - /** @type {?print_preview.NativeLayer} */ + /** @type {?NativeLayer} */ let nativeLayer = null; - /** @type {?print_preview.CloudPrintInterface} */ + /** @type {?CloudPrintInterface} */ let cloudPrintInterface = null; const account1 = 'foo@chromium.org'; @@ -21,7 +26,7 @@ /** @override */ suiteSetup(function() { - print_preview_test_utils.setupTestListenerElement(); + setupTestListenerElement(); }); /** @override */ @@ -29,17 +34,17 @@ PolymerTest.clearBody(); // Create data classes - nativeLayer = new print_preview.NativeLayerStub(); - print_preview.NativeLayer.setInstance(nativeLayer); - cloudPrintInterface = new print_preview.CloudPrintInterfaceStub(); + nativeLayer = new NativeLayerStub(); + NativeLayer.setInstance(nativeLayer); + cloudPrintInterface = new CloudPrintInterfaceStub(); userManager = document.createElement('print-preview-user-manager'); // Initialize destination store. - destinationStore = print_preview_test_utils.createDestinationStore(); + destinationStore = createDestinationStore(); destinationStore.setCloudPrintInterface(cloudPrintInterface); const localDestinations = []; - const destinations = print_preview_test_utils.getDestinations( + const destinations = getDestinations( nativeLayer, localDestinations); destinationStore.init( false /* isInAppKioskMode */, 'FooDevice' /* printerName */, @@ -49,7 +54,7 @@ // Set up user manager userManager.appKioskMode = false; userManager.destinationStore = destinationStore; - userManager.invitationStore = new print_preview.InvitationStore(); + userManager.invitationStore = new InvitationStore(); userManager.shouldReloadCookies = false; document.body.appendChild(userManager); }); @@ -58,9 +63,9 @@ test('update users', function() { // Set up a cloud printer for each account. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account1)); + getGoogleDriveDestination(account1)); cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account2)); + getGoogleDriveDestination(account2)); assertTrue(userManager.cloudPrintDisabled); @@ -122,7 +127,7 @@ // This should update the list of users and the active user and // trigger a call to search. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account1)); + getGoogleDriveDestination(account1)); cr.webUIListenerCallback('check-for-account-update'); return cloudPrintInterface.whenCalled('search'); }) @@ -133,7 +138,7 @@ // Simulate signing in to a second account. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account2)); + getGoogleDriveDestination(account2)); cr.webUIListenerCallback('check-for-account-update'); return cloudPrintInterface.whenCalled('search'); }) @@ -168,7 +173,7 @@ // This should update the list of users and the active user and // trigger a call to search. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account1)); + getGoogleDriveDestination(account1)); cr.webUIListenerCallback('check-for-account-update'); return cloudPrintInterface.whenCalled('search'); }) @@ -179,7 +184,7 @@ // Simulate signing in to a second account. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account2)); + getGoogleDriveDestination(account2)); cr.webUIListenerCallback('check-for-account-update'); return cloudPrintInterface.whenCalled('search'); }) @@ -193,9 +198,9 @@ test('update active user', function() { // Set up a cloud printer for each account. cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account1)); + getGoogleDriveDestination(account1)); cloudPrintInterface.setPrinter( - print_preview_test_utils.getGoogleDriveDestination(account2)); + getGoogleDriveDestination(account2)); userManager.cloudPrintInterface = cloudPrintInterface; userManager.initUserAccounts( [account1, account2], true /* syncAvailable */); @@ -226,4 +231,3 @@ }); }); }); -});
diff --git a/chromeos/network/network_device_handler_impl.cc b/chromeos/network/network_device_handler_impl.cc index e00ea26..e5ff753 100644 --- a/chromeos/network/network_device_handler_impl.cc +++ b/chromeos/network/network_device_handler_impl.cc
@@ -586,7 +586,7 @@ const std::string& shill_error_message) { HandleShillCallFailure(device_path, error_callback, shill_error_name, shill_error_message); - if (shill_error_name == NetworkDeviceHandler::kErrorNotSupported && + if (shill_error_name == shill::kErrorResultNotSupported && mac_address_source == usb_ethernet_mac_address_source_) { mac_address_change_not_supported_.insert(device_mac_address); ApplyUsbEthernetMacAddressSourceToShill();
diff --git a/chromeos/network/network_device_handler_unittest.cc b/chromeos/network/network_device_handler_unittest.cc index 6f820b4..0c793c4 100644 --- a/chromeos/network/network_device_handler_unittest.cc +++ b/chromeos/network/network_device_handler_unittest.cc
@@ -310,8 +310,8 @@ shill::kUsbEthernetMacAddressSourceProperty, base::Value(kSourceToOverride), /*notify_changed=*/true); - device_test->SetUsbEthernetMacAddressSourceError(kUsbEthernetDevicePath, - "not-supported"); + device_test->SetUsbEthernetMacAddressSourceError( + kUsbEthernetDevicePath, shill::kErrorResultNotSupported); network_device_handler_->SetUsbEthernetMacAddressSource("some_source1"); base::RunLoop().RunUntilIdle(); @@ -356,8 +356,8 @@ device_test->SetDeviceProperty(kUsbEthernetDevicePath2, shill::kLinkUpProperty, base::Value(true), /*notify_changed=*/true); - device_test->SetUsbEthernetMacAddressSourceError(kUsbEthernetDevicePath2, - "not-supported"); + device_test->SetUsbEthernetMacAddressSourceError( + kUsbEthernetDevicePath2, shill::kErrorResultNotSupported); constexpr char kUsbEthernetDevicePath3[] = "usb_ethernet_device3"; device_test->AddDevice(kUsbEthernetDevicePath3, shill::kTypeEthernet, "eth3");
diff --git a/chromeos/profiles/broadwell.afdo.newest.txt b/chromeos/profiles/broadwell.afdo.newest.txt index 5da2d2c..e55a546 100644 --- a/chromeos/profiles/broadwell.afdo.newest.txt +++ b/chromeos/profiles/broadwell.afdo.newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-broadwell-80-3943.1-1572873357-benchmark-80.0.3961.0-r1-redacted.afdo.xz \ No newline at end of file +chromeos-chrome-amd64-broadwell-80-3904.92-1573478033-benchmark-80.0.3964.0-r1-redacted.afdo.xz \ No newline at end of file
diff --git a/chromeos/profiles/orderfile.newest.txt b/chromeos/profiles/orderfile.newest.txt index 939d530..e656449 100644 --- a/chromeos/profiles/orderfile.newest.txt +++ b/chromeos/profiles/orderfile.newest.txt
@@ -1 +1 @@ -chromeos-chrome-orderfile-field-80-3943.1-1572866479-benchmark-80.0.3954.0-r1.orderfile.xz \ No newline at end of file +chromeos-chrome-orderfile-field-80-3943.1-1572866479-benchmark-80.0.3961.0-r1.orderfile.xz \ No newline at end of file
diff --git a/chromeos/profiles/silvermont.afdo.newest.txt b/chromeos/profiles/silvermont.afdo.newest.txt index 3e19076..78f76b8 100644 --- a/chromeos/profiles/silvermont.afdo.newest.txt +++ b/chromeos/profiles/silvermont.afdo.newest.txt
@@ -1 +1 @@ -chromeos-chrome-amd64-silvermont-80-3943.1-1572866479-benchmark-80.0.3961.0-r1-redacted.afdo.xz \ No newline at end of file +chromeos-chrome-amd64-silvermont-80-3943.1-1572866479-benchmark-80.0.3964.0-r1-redacted.afdo.xz \ No newline at end of file
diff --git a/components/arc/mojom/intent_helper.mojom b/components/arc/mojom/intent_helper.mojom index 72c4f8d4..f4431c31 100644 --- a/components/arc/mojom/intent_helper.mojom +++ b/components/arc/mojom/intent_helper.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: 32 +// Next MinVersion: 33 module arc.mojom; @@ -274,7 +274,7 @@ // user preference. The |intent_info| is used to generate the components set // and match for setting the preferred activity. // This is used to sync the preferred app setting from Chrome OS. - [MinVersion=31] AddPreferredApp@17(string package_name, + [MinVersion=32] AddPreferredApp@17(string package_name, IntentFilter intent_filter, IntentInfo intent_info);
diff --git a/components/arc/session/arc_vm_client_adapter.cc b/components/arc/session/arc_vm_client_adapter.cc index f4751aa1..702ed062 100644 --- a/components/arc/session/arc_vm_client_adapter.cc +++ b/components/arc/session/arc_vm_client_adapter.cc
@@ -41,6 +41,7 @@ #include "components/arc/arc_features.h" #include "components/arc/arc_util.h" #include "components/arc/session/arc_session.h" +#include "components/arc/session/arc_vm_client_adapter_util.h" #include "components/version_info/version_info.h" namespace arc { @@ -52,8 +53,11 @@ constexpr const char kCrosSystemPath[] = "/usr/bin/crossystem"; constexpr const char kDlcPath[] = "/run/imageloader/arcvm-dlc/package/root"; constexpr const char kFstab[] = "fstab"; +constexpr const char kGeneratedPropertyFilesPath[] = + "/run/arcvm/host_generated"; constexpr const char kHomeDirectory[] = "/home"; constexpr const char kKernel[] = "vmlinux"; +constexpr const char kPropertyFilesPath[] = "/usr/share/arcvm/properties"; constexpr const char kRootFs[] = "system.raw.img"; constexpr const char kVendorImage[] = "vendor.raw.img"; @@ -72,6 +76,7 @@ const base::FilePath& vendor_image_path() const { return vendor_image_path_; } const base::FilePath& guest_kernel_path() const { return guest_kernel_path_; } const base::FilePath& fstab_path() const { return fstab_path_; } + bool property_files_expanded() const { return property_files_expanded_; } static FileSystemStatus GetFileSystemStatusBlocking() { return FileSystemStatus(); @@ -79,6 +84,10 @@ static bool IsAndroidDebuggableForTesting(const base::FilePath& json_path) { return IsAndroidDebuggable(json_path); } + static bool ExpandPropertyFilesForTesting(const base::FilePath& source_path, + const base::FilePath& dest_path) { + return ExpandPropertyFiles(source_path, dest_path); + } private: FileSystemStatus() @@ -88,7 +97,10 @@ system_image_path_(SelectDlcOrBuiltin(base::FilePath(kRootFs))), vendor_image_path_(SelectDlcOrBuiltin(base::FilePath(kVendorImage))), guest_kernel_path_(SelectDlcOrBuiltin(base::FilePath(kKernel))), - fstab_path_(SelectDlcOrBuiltin(base::FilePath(kFstab))) {} + fstab_path_(SelectDlcOrBuiltin(base::FilePath(kFstab))), + property_files_expanded_( + ExpandPropertyFiles(base::FilePath(kPropertyFilesPath), + base::FilePath(kGeneratedPropertyFilesPath))) {} // Parse a JSON file which is like the following and returns a result: // { @@ -148,12 +160,29 @@ return base::FilePath(kBuiltinPath).Append(file); } + // Copies two prop files in /usr/share/arcvm to /run/arcvm/host_generated with + // or without modifications (depending on whether the board is unibuild). + // Returns true if the copy is successful. + static bool ExpandPropertyFiles(const base::FilePath& source_path, + const base::FilePath& dest_path) { + CrosConfig config; + for (const char* file : {"default.prop", "build.prop"}) { + if (!ExpandPropertyFile(source_path.Append(file), dest_path.Append(file), + &config)) { + LOG(ERROR) << "Failed to expand " << source_path.Append(file); + return false; + } + } + return true; + } + bool is_android_debuggable_; bool is_host_rootfs_writable_; base::FilePath system_image_path_; base::FilePath vendor_image_path_; base::FilePath guest_kernel_path_; base::FilePath fstab_path_; + bool property_files_expanded_; DISALLOW_COPY_AND_ASSIGN(FileSystemStatus); }; @@ -557,6 +586,11 @@ const base::FilePath& data_disk_path, FileSystemStatus file_system_status) { VLOG(2) << "Got file system status"; + if (!file_system_status.property_files_expanded()) { + // TODO(yusukes): Once build_image and push_to_device.py are updated, run + // the |callback| with false here and return. + } + if (serial_number_.empty()) { LOG(ERROR) << "Serial number is not set"; std::move(callback).Run(false); @@ -667,4 +701,10 @@ return FileSystemStatus::IsAndroidDebuggableForTesting(json_path); } +bool ExpandPropertyFilesForTesting(const base::FilePath& source_path, + const base::FilePath& dest_path) { + return FileSystemStatus::ExpandPropertyFilesForTesting(source_path, + dest_path); +} + } // namespace arc
diff --git a/components/arc/session/arc_vm_client_adapter.h b/components/arc/session/arc_vm_client_adapter.h index 01365514..04c9248 100644 --- a/components/arc/session/arc_vm_client_adapter.h +++ b/components/arc/session/arc_vm_client_adapter.h
@@ -22,6 +22,8 @@ // Function(s) below are for testing. bool IsAndroidDebuggableForTesting(const base::FilePath& json_path); +bool ExpandPropertyFilesForTesting(const base::FilePath& source_path, + const base::FilePath& dest_path); } // namespace arc
diff --git a/components/arc/session/arc_vm_client_adapter_unittest.cc b/components/arc/session/arc_vm_client_adapter_unittest.cc index cfdde6b..b44195c 100644 --- a/components/arc/session/arc_vm_client_adapter_unittest.cc +++ b/components/arc/session/arc_vm_client_adapter_unittest.cc
@@ -681,5 +681,47 @@ EXPECT_FALSE(IsAndroidDebuggableForTesting(path)); } +TEST_F(ArcVmClientAdapterTest, ExpandPropertyFilesForTesting_NoSource) { + // Both source and dest are not found. + EXPECT_FALSE(ExpandPropertyFilesForTesting(base::FilePath("/nonexistent1"), + base::FilePath("/nonexistent2"))); + + // Both source and dest exist, but the source directory is empty. + base::FilePath source_dir; + ASSERT_TRUE(base::CreateTemporaryDirInDir(GetTempDir(), "test", &source_dir)); + base::FilePath dest_dir; + ASSERT_TRUE(base::CreateTemporaryDirInDir(GetTempDir(), "test", &dest_dir)); + EXPECT_FALSE(ExpandPropertyFilesForTesting(source_dir, dest_dir)); + + // Add default.prop to the source, but not build.prop. + base::FilePath default_prop = source_dir.Append("default.prop"); + constexpr const char kDefaultProp[] = "ro.foo=bar\n"; + base::WriteFile(default_prop, kDefaultProp, strlen(kDefaultProp)); + EXPECT_FALSE(ExpandPropertyFilesForTesting(source_dir, dest_dir)); + + // Add build.prop too. Then the call should succeed. + base::FilePath build_prop = source_dir.Append("build.prop"); + constexpr const char kBuildProp[] = "ro.baz=boo\n"; + base::WriteFile(build_prop, kBuildProp, strlen(kBuildProp)); + EXPECT_TRUE(ExpandPropertyFilesForTesting(source_dir, dest_dir)); + + // Verify two dest files are there. + EXPECT_TRUE(base::PathExists(dest_dir.Append("default.prop"))); + EXPECT_TRUE(base::PathExists(dest_dir.Append("build.prop"))); + + // Verify their content. + // Note: ExpandPropertyFile() adds a trailing LF. + std::string content; + EXPECT_TRUE( + base::ReadFileToString(dest_dir.Append("default.prop"), &content)); + EXPECT_EQ(std::string(kDefaultProp) + "\n", content); + EXPECT_TRUE(base::ReadFileToString(dest_dir.Append("build.prop"), &content)); + EXPECT_EQ(std::string(kBuildProp) + "\n", content); + + // Finally, test the case where source is valid but the dest is not. + EXPECT_FALSE(ExpandPropertyFilesForTesting(source_dir, + base::FilePath("/nonexistent"))); +} + } // namespace } // namespace arc
diff --git a/components/exo/wayland/zcr_remote_shell.cc b/components/exo/wayland/zcr_remote_shell.cc index e1029bbe..f6f68fc 100644 --- a/components/exo/wayland/zcr_remote_shell.cc +++ b/components/exo/wayland/zcr_remote_shell.cc
@@ -373,14 +373,24 @@ void remote_surface_set_window_type(wl_client* client, wl_resource* resource, uint32_t type) { - if (type == ZCR_REMOTE_SURFACE_V1_WINDOW_TYPE_SYSTEM_UI) { - auto* widget = GetUserDataAs<ShellSurfaceBase>(resource)->GetWidget(); - if (widget) { - widget->GetNativeWindow()->SetProperty(ash::kHideInOverviewKey, true); + auto* widget = GetUserDataAs<ShellSurfaceBase>(resource)->GetWidget(); + if (!widget) + return; + switch (type) { + case ZCR_REMOTE_SURFACE_V1_WINDOW_TYPE_NORMAL: + widget->GetNativeWindow()->SetProperty(ash::kHideInOverviewKey, false); + break; + case ZCR_REMOTE_SURFACE_V1_WINDOW_TYPE_SYSTEM_UI: + // TODO(takise): Consider removing this as this window type was added for + // the old assistant and is not longer used. + widget->GetNativeWindow()->SetProperty(ash::kHideInOverviewKey, true); wm::SetWindowVisibilityAnimationType( widget->GetNativeWindow(), wm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); - } + break; + case ZCR_REMOTE_SURFACE_V1_WINDOW_TYPE_HIDDEN_IN_OVERVIEW: + widget->GetNativeWindow()->SetProperty(ash::kHideInOverviewKey, true); + break; } }
diff --git a/components/exo/wayland/zcr_remote_shell.h b/components/exo/wayland/zcr_remote_shell.h index 8441b1d5..2b823f7c 100644 --- a/components/exo/wayland/zcr_remote_shell.h +++ b/components/exo/wayland/zcr_remote_shell.h
@@ -22,7 +22,7 @@ namespace exo { namespace wayland { -constexpr uint32_t kZcrRemoteShellVersion = 23; +constexpr uint32_t kZcrRemoteShellVersion = 24; void bind_remote_shell(wl_client* client, void* data,
diff --git a/components/history/core/browser/browsing_history_service_unittest.cc b/components/history/core/browser/browsing_history_service_unittest.cc index 1b7116ee..ab99e99 100644 --- a/components/history/core/browser/browsing_history_service_unittest.cc +++ b/components/history/core/browser/browsing_history_service_unittest.cc
@@ -543,7 +543,7 @@ /*reached_beginning*/ false, /*has_synced_results*/ true, {{kUrl3, 3, kRemote}}, QueryHistory(1)); - local_history()->DeleteURL(GURL(kUrl1)); + local_history()->DeleteURLs({GURL(kUrl1)}); VerifyQueryResult(/*reached_beginning*/ true, /*has_synced_results*/ true, {{kUrl2, 2, kRemote}, {kUrl1, 1, kLocal}}, ContinueQuery()); }
diff --git a/components/history/core/browser/history_backend_unittest.cc b/components/history/core/browser/history_backend_unittest.cc index ed5f11282..900463a 100644 --- a/components/history/core/browser/history_backend_unittest.cc +++ b/components/history/core/browser/history_backend_unittest.cc
@@ -3597,7 +3597,7 @@ // This won't actually delete the URL, rather it'll empty out the visits. // This triggers blocking on the BookmarkModel. - service->DeleteURL(url); + service->DeleteURLs({url}); } // Test DeleteFTSIndexDatabases deletes expected files.
diff --git a/components/history/core/browser/history_service.cc b/components/history/core/browser/history_service.cc index 0421893..e3f7644c 100644 --- a/components/history/core/browser/history_service.cc +++ b/components/history/core/browser/history_service.cc
@@ -1027,15 +1027,6 @@ history_client_->NotifyProfileError(init_status, diagnostics); } -void HistoryService::DeleteURL(const GURL& url) { - TRACE_EVENT0("browser", "HistoryService::DeleteURL"); - DCHECK(backend_task_runner_) << "History service being called after cleanup"; - DCHECK(thread_checker_.CalledOnValidThread()); - // We will update the visited links when we observe the delete notifications. - ScheduleTask(PRIORITY_NORMAL, base::BindOnce(&HistoryBackend::DeleteURL, - history_backend_, url)); -} - void HistoryService::DeleteURLs(const std::vector<GURL>& urls) { TRACE_EVENT0("browser", "HistoryService::DeleteURLs"); DCHECK(backend_task_runner_) << "History service being called after cleanup"; @@ -1170,7 +1161,7 @@ /*restrict_urls=*/{url}, base::Time(), base::Time::Max(), base::DoNothing(), partial_traffic_annotation); } - DeleteURL(url); + DeleteURLs({url}); } void HistoryService::OnDBLoaded() {
diff --git a/components/history/core/browser/history_service.h b/components/history/core/browser/history_service.h index 5600f42..8f8d187 100644 --- a/components/history/core/browser/history_service.h +++ b/components/history/core/browser/history_service.h
@@ -335,9 +335,6 @@ // Database management operations -------------------------------------------- - // Delete all the information related to a single url. - void DeleteURL(const GURL& url); - // Delete all the information related to a list of urls. (Deleting // URLs one by one is slow as it has to flush to disk each time.) void DeleteURLs(const std::vector<GURL>& urls);
diff --git a/components/history/core/browser/top_sites_impl_unittest.cc b/components/history/core/browser/top_sites_impl_unittest.cc index f06649b4..635da57 100644 --- a/components/history/core/browser/top_sites_impl_unittest.cc +++ b/components/history/core/browser/top_sites_impl_unittest.cc
@@ -174,7 +174,7 @@ } // Delets a url. - void DeleteURL(const GURL& url) { history_service()->DeleteURL(url); } + void DeleteURL(const GURL& url) { history_service()->DeleteURLs({url}); } // Recreates top sites. This forces top sites to reread from the db. void RecreateTopSitesAndBlock() {
diff --git a/components/omnibox/browser/history_provider.cc b/components/omnibox/browser/history_provider.cc index 9969cc8..cc69086 100644 --- a/components/omnibox/browser/history_provider.cc +++ b/components/omnibox/browser/history_provider.cc
@@ -28,7 +28,7 @@ // and indices to drop any data they might have stored pertaining to the URL. DCHECK(history_service); DCHECK(match.destination_url.is_valid()); - history_service->DeleteURL(match.destination_url); + history_service->DeleteURLs({match.destination_url}); DeleteMatchFromMatches(match); }
diff --git a/components/omnibox/browser/shortcuts_provider.cc b/components/omnibox/browser/shortcuts_provider.cc index f40652c..d5d608e1 100644 --- a/components/omnibox/browser/shortcuts_provider.cc +++ b/components/omnibox/browser/shortcuts_provider.cc
@@ -157,7 +157,7 @@ // second call to DeleteShortcutsWithURL(), which is harmless. history::HistoryService* const history_service = client_->GetHistoryService(); DCHECK(history_service); - history_service->DeleteURL(url); + history_service->DeleteURLs({url}); } ShortcutsProvider::~ShortcutsProvider() {
diff --git a/components/pdf/browser/pdf_web_contents_helper.cc b/components/pdf/browser/pdf_web_contents_helper.cc index 3bce50e..5414ed7 100644 --- a/components/pdf/browser/pdf_web_contents_helper.cc +++ b/components/pdf/browser/pdf_web_contents_helper.cc
@@ -94,11 +94,11 @@ if (touch_selection_controller_client_manager_) { gfx::SelectionBound start; gfx::SelectionBound end; - start.SetEdgeTop(ConvertToRoot(selection_left_)); - start.SetEdgeBottom(ConvertToRoot(gfx::PointF( + start.SetEdgeStart(ConvertToRoot(selection_left_)); + start.SetEdgeEnd(ConvertToRoot(gfx::PointF( selection_left_.x(), selection_left_.y() + selection_left_height_))); - end.SetEdgeTop(ConvertToRoot(selection_right_)); - end.SetEdgeBottom(ConvertToRoot(gfx::PointF( + end.SetEdgeStart(ConvertToRoot(selection_right_)); + end.SetEdgeEnd(ConvertToRoot(gfx::PointF( selection_right_.x(), selection_right_.y() + selection_right_height_))); // Don't do left/right comparison after setting type.
diff --git a/components/policy/core/common/cloud/cloud_policy_client.cc b/components/policy/core/common/cloud/cloud_policy_client.cc index 56db1d4..50a0fc5 100644 --- a/components/policy/core/common/cloud/cloud_policy_client.cc +++ b/components/policy/core/common/cloud/cloud_policy_client.cc
@@ -555,6 +555,28 @@ request_jobs_.push_back(service_->CreateJob(std::move(config))); } +void CloudPolicyClient::UploadChromeOsUserReport( + std::unique_ptr<enterprise_management::ChromeOsUserReportRequest> + chrome_os_user_report, + const CloudPolicyClient::StatusCallback& callback) { + CHECK(is_registered()); + DCHECK(chrome_os_user_report); + std::unique_ptr<DMServerJobConfiguration> config = + std::make_unique<DMServerJobConfiguration>( + DeviceManagementService::JobConfiguration::TYPE_CHROME_OS_USER_REPORT, + this, + /*critical=*/false, DMAuth::FromDMToken(dm_token_), + /*oauth_token=*/base::nullopt, + base::BindRepeating(&CloudPolicyClient::OnReportUploadCompleted, + weak_ptr_factory_.GetWeakPtr(), callback)); + + em::DeviceManagementRequest* request = config->request(); + request->set_allocated_chrome_os_user_report_request( + chrome_os_user_report.release()); + + request_jobs_.push_back(service_->CreateJob(std::move(config))); +} + void CloudPolicyClient::UploadRealtimeReport(base::Value report, const StatusCallback& callback) { CHECK(is_registered());
diff --git a/components/policy/core/common/cloud/cloud_policy_client.h b/components/policy/core/common/cloud/cloud_policy_client.h index 3039f2a..d37acde0 100644 --- a/components/policy/core/common/cloud/cloud_policy_client.h +++ b/components/policy/core/common/cloud/cloud_policy_client.h
@@ -263,6 +263,14 @@ chrome_desktop_report, const StatusCallback& callback); + // Uploads Chrome OS User report to the server. The user dm token must be set + // properly. |chrome_os_user_report| will be included in the upload request. + // The |callback| will be called when the operation completes. + virtual void UploadChromeOsUserReport( + std::unique_ptr<enterprise_management::ChromeOsUserReportRequest> + chrome_os_user_report, + const StatusCallback& callback); + // Uploads |report| using the real-time reporting API. As above, the client // must be in a registered state. The |callback| will be called when the // operation completes.
diff --git a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc index 16ef0349..ae47b24 100644 --- a/components/policy/core/common/cloud/cloud_policy_client_unittest.cc +++ b/components/policy/core/common/cloud/cloud_policy_client_unittest.cc
@@ -235,6 +235,7 @@ upload_status_request_.mutable_child_status_report_request(); chrome_desktop_report_request_.mutable_chrome_desktop_report_request(); + chrome_os_user_report_request_.mutable_chrome_os_user_report_request(); remote_command_request_.mutable_remote_command_request() ->set_last_command_unique_id(kLastCommandId); @@ -459,6 +460,16 @@ chrome_desktop_report_response_))); } + void ExpectChromeOsUserReport() { + EXPECT_CALL(service_, StartJob(_)) + .WillOnce(DoAll( + service_.CaptureJobType(&job_type_), + service_.CaptureQueryParams(&query_params_), + service_.CaptureRequest(&job_request_), + service_.StartJobAsync(net::OK, DeviceManagementService::kSuccess, + chrome_os_user_report_response_))); + } + void ExpectRealtimeReport() { EXPECT_CALL(service_, StartJob(_)) .WillOnce(DoAll(service_.CaptureJobType(&job_type_), @@ -559,6 +570,7 @@ em::DeviceManagementRequest upload_enrollment_id_request_; em::DeviceManagementRequest upload_status_request_; em::DeviceManagementRequest chrome_desktop_report_request_; + em::DeviceManagementRequest chrome_os_user_report_request_; em::DeviceManagementRequest remote_command_request_; em::DeviceManagementRequest attribute_update_permission_request_; em::DeviceManagementRequest attribute_update_request_; @@ -574,6 +586,7 @@ em::DeviceManagementResponse upload_certificate_response_; em::DeviceManagementResponse upload_status_response_; em::DeviceManagementResponse chrome_desktop_report_response_; + em::DeviceManagementResponse chrome_os_user_report_response_; em::DeviceManagementResponse attribute_update_permission_response_; em::DeviceManagementResponse attribute_update_response_; em::DeviceManagementResponse gcm_id_update_response_; @@ -1446,6 +1459,26 @@ EXPECT_EQ(DM_STATUS_SUCCESS, client_->status()); } +TEST_F(CloudPolicyClientTest, UploadChromeOsUserReport) { + RegisterClient(); + + ExpectChromeOsUserReport(); + EXPECT_CALL(callback_observer_, OnCallbackComplete(true)).Times(1); + CloudPolicyClient::StatusCallback callback = + base::Bind(&MockStatusCallbackObserver::OnCallbackComplete, + base::Unretained(&callback_observer_)); + std::unique_ptr<em::ChromeOsUserReportRequest> chrome_os_user_report = + std::make_unique<em::ChromeOsUserReportRequest>(); + client_->UploadChromeOsUserReport(std::move(chrome_os_user_report), callback); + base::RunLoop().RunUntilIdle(); + EXPECT_EQ( + DeviceManagementService::JobConfiguration::TYPE_CHROME_OS_USER_REPORT, + job_type_); + EXPECT_EQ(job_request_.SerializePartialAsString(), + chrome_os_user_report_request_.SerializePartialAsString()); + EXPECT_EQ(DM_STATUS_SUCCESS, client_->status()); +} + #if defined(OS_WIN) || defined(OS_MACOSX) || \ defined(OS_LINUX) && !defined(OS_CHROMEOS) TEST_F(CloudPolicyClientTest, UploadRealtimeReport) {
diff --git a/components/policy/core/common/cloud/cloud_policy_constants.cc b/components/policy/core/common/cloud/cloud_policy_constants.cc index ff3397a9..ee91c374 100644 --- a/components/policy/core/common/cloud/cloud_policy_constants.cc +++ b/components/policy/core/common/cloud/cloud_policy_constants.cc
@@ -60,6 +60,7 @@ const char kValueRequestAppInstallReport[] = "app_install_report"; const char kValueRequestTokenEnrollment[] = "register_browser"; const char kValueRequestChromeDesktopReport[] = "chrome_desktop_report"; +const char kValueRequestChromeOsUserReport[] = "chrome_os_user_report"; const char kValueRequestInitialEnrollmentStateRetrieval[] = "device_initial_enrollment_state"; const char kValueRequestUploadPolicyValidationReport[] =
diff --git a/components/policy/core/common/cloud/cloud_policy_constants.h b/components/policy/core/common/cloud/cloud_policy_constants.h index 518ece5c..c11b8782 100644 --- a/components/policy/core/common/cloud/cloud_policy_constants.h +++ b/components/policy/core/common/cloud/cloud_policy_constants.h
@@ -58,6 +58,7 @@ POLICY_EXPORT extern const char kValueRequestInitialEnrollmentStateRetrieval[]; POLICY_EXPORT extern const char kValueRequestUploadPolicyValidationReport[]; POLICY_EXPORT extern const char kValueRequestPublicSamlUser[]; +POLICY_EXPORT extern const char kValueRequestChromeOsUserReport[]; // Policy type strings for the policy_type field in PolicyFetchRequest. POLICY_EXPORT extern const char kChromeDevicePolicyType[];
diff --git a/components/policy/core/common/cloud/device_management_service.cc b/components/policy/core/common/cloud/device_management_service.cc index 0294351e..4793efe 100644 --- a/components/policy/core/common/cloud/device_management_service.cc +++ b/components/policy/core/common/cloud/device_management_service.cc
@@ -187,6 +187,8 @@ return "UploadrealtimeReport"; case DeviceManagementService::JobConfiguration::TYPE_REQUEST_SAML_URL: return "PublicSamlUserRequest"; + case DeviceManagementService::JobConfiguration::TYPE_CHROME_OS_USER_REPORT: + return "ChromeOsUserReport"; } NOTREACHED() << "Invalid job type " << type; return "";
diff --git a/components/policy/core/common/cloud/device_management_service.h b/components/policy/core/common/cloud/device_management_service.h index 8a41868..06ce3409 100644 --- a/components/policy/core/common/cloud/device_management_service.h +++ b/components/policy/core/common/cloud/device_management_service.h
@@ -164,6 +164,7 @@ TYPE_UPLOAD_POLICY_VALIDATION_REPORT = 21, TYPE_UPLOAD_REAL_TIME_REPORT = 22, TYPE_REQUEST_SAML_URL = 23, + TYPE_CHROME_OS_USER_REPORT = 24, }; // The set of HTTP query parmaters of the request.
diff --git a/components/policy/core/common/cloud/dmserver_job_configurations.cc b/components/policy/core/common/cloud/dmserver_job_configurations.cc index bb6e6d4..79e3e81 100644 --- a/components/policy/core/common/cloud/dmserver_job_configurations.cc +++ b/components/policy/core/common/cloud/dmserver_job_configurations.cc
@@ -81,6 +81,9 @@ case DeviceManagementService::JobConfiguration:: TYPE_UPLOAD_REAL_TIME_REPORT: NOTREACHED() << "Not a DMServer request type" << type; + break; + case DeviceManagementService::JobConfiguration::TYPE_CHROME_OS_USER_REPORT: + return dm_protocol::kValueRequestChromeOsUserReport; } NOTREACHED() << "Invalid job type " << type; return "";
diff --git a/components/policy/proto/chrome_device_policy.proto b/components/policy/proto/chrome_device_policy.proto index 0d8a926f..0eda211 100644 --- a/components/policy/proto/chrome_device_policy.proto +++ b/components/policy/proto/chrome_device_policy.proto
@@ -1578,7 +1578,7 @@ optional LoginScreenLocalesProto login_screen_locales = 49; optional LoginScreenInputMethodsProto login_screen_input_methods = 50; optional DeviceEcryptfsMigrationStrategyProto - device_ecryptfs_migration_strategy = 51; + device_ecryptfs_migration_strategy = 51 [deprecated = true]; optional DeviceSecondFactorAuthenticationProto device_second_factor_authentication = 52; optional CastReceiverNameProto cast_receiver_name = 53;
diff --git a/components/safe_browsing/db/v4_local_database_manager.cc b/components/safe_browsing/db/v4_local_database_manager.cc index b4fa60e..305f95d 100644 --- a/components/safe_browsing/db/v4_local_database_manager.cc +++ b/components/safe_browsing/db/v4_local_database_manager.cc
@@ -400,8 +400,10 @@ if (!enabled_ || !CanCheckUrl(url) || !AreAllStoresAvailableNow(stores_to_check)) { // NOTE(vakh): If Safe Browsing isn't enabled yet, or if the URL isn't a - // navigation URL, or if the allowlist isn't ready yet, return NO_MATCH. - return AsyncMatch::NO_MATCH; + // navigation URL, or if the allowlist isn't ready yet, return MATCH. + // The full URL check won't be performed, but hash-based check will still + // be done. + return AsyncMatch::MATCH; } std::unique_ptr<PendingCheck> check = std::make_unique<PendingCheck>(
diff --git a/components/safe_browsing/db/v4_local_database_manager_unittest.cc b/components/safe_browsing/db/v4_local_database_manager_unittest.cc index f175936..0ea490b 100644 --- a/components/safe_browsing/db/v4_local_database_manager_unittest.cc +++ b/components/safe_browsing/db/v4_local_database_manager_unittest.cc
@@ -789,7 +789,7 @@ EXPECT_FALSE(client.callback_called()); } -// When allowlist is unavailable, all URLS should be considered no-match. +// When allowlist is unavailable, all URLS should be considered MATCH. TEST_F(V4LocalDatabaseManagerTest, TestCheckUrlForHCAllowlistUnavailable) { base::test::ScopedFeatureList feature_list; feature_list.InitWithFeatures({safe_browsing::kRealTimeUrlLookupEnabled}, {}); @@ -809,7 +809,7 @@ /* expected_sb_threat_type= */ SB_THREAT_TYPE_HIGH_CONFIDENCE_ALLOWLIST); const GURL url_check("https://example.com/safe"); - EXPECT_EQ(AsyncMatch::NO_MATCH, + EXPECT_EQ(AsyncMatch::MATCH, v4_local_database_manager_->CheckUrlForHighConfidenceAllowlist( url_check, &client));
diff --git a/components/services/storage/public/cpp/BUILD.gn b/components/services/storage/public/cpp/BUILD.gn new file mode 100644 index 0000000..f0e0cea --- /dev/null +++ b/components/services/storage/public/cpp/BUILD.gn
@@ -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. + +component("cpp") { + output_name = "storage_service_public" + + public = [ + "constants.h", + ] + + sources = [ + "constants.cc", + ] + + public_deps = [ + "//base", + ] + + defines = [ "IS_STORAGE_SERVICE_PUBLIC_IMPL" ] +}
diff --git a/components/services/storage/public/cpp/constants.cc b/components/services/storage/public/cpp/constants.cc new file mode 100644 index 0000000..5f67232 --- /dev/null +++ b/components/services/storage/public/cpp/constants.cc
@@ -0,0 +1,17 @@ +// 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. + +#include "components/services/storage/public/cpp/constants.h" + +namespace storage { + +// The path where Local Storage data is persisted on disk, relative to a storage +// partition's root directory. +const base::FilePath::CharType kLocalStoragePath[] = + FILE_PATH_LITERAL("Local Storage"); + +// The name of the Leveldb database to use for databases persisted on disk. +const char kLocalStorageLeveldbName[] = "leveldb"; + +} // namespace storage
diff --git a/components/services/storage/public/cpp/constants.h b/components/services/storage/public/cpp/constants.h new file mode 100644 index 0000000..77df2623 --- /dev/null +++ b/components/services/storage/public/cpp/constants.h
@@ -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. + +#ifndef COMPONENTS_SERVICES_STORAGE_PUBLIC_CPP_CONSTANTS_H_ +#define COMPONENTS_SERVICES_STORAGE_PUBLIC_CPP_CONSTANTS_H_ + +#include "base/component_export.h" +#include "base/files/file_path.h" + +namespace storage { + +COMPONENT_EXPORT(STORAGE_SERVICE_PUBLIC) +extern const base::FilePath::CharType kLocalStoragePath[]; + +COMPONENT_EXPORT(STORAGE_SERVICE_PUBLIC) +extern const char kLocalStorageLeveldbName[]; + +} // namespace storage + +#endif // COMPONENTS_SERVICES_STORAGE_PUBLIC_CPP_CONSTANTS_H_
diff --git a/components/sync/protocol/sharing_remote_copy_message.proto b/components/sync/protocol/sharing_remote_copy_message.proto index c4743f1..92f2f72 100644 --- a/components/sync/protocol/sharing_remote_copy_message.proto +++ b/components/sync/protocol/sharing_remote_copy_message.proto
@@ -11,12 +11,6 @@ // Message to pass content for the remote copy feature. message RemoteCopyMessage { - // The content to write to the clipboard. Required. - oneof content { - // Plain text. - string text = 1; - - // The URL of an image to download and write to the clipboard. - string image_url = 2; - } + // optional + string text = 1; }
diff --git a/components/sync/syncable/directory.cc b/components/sync/syncable/directory.cc index 71c1a8b..93d1328 100644 --- a/components/sync/syncable/directory.cc +++ b/components/sync/syncable/directory.cc
@@ -88,7 +88,7 @@ bool Directory::SaveChangesSnapshot::HasUnsavedMetahandleChanges() const { return !dirty_metas.empty() || !metahandles_to_purge.empty() || - !delete_journals.empty() || !delete_journals_to_purge.empty(); + !delete_journals_to_purge.empty(); } Directory::Kernel::Kernel( @@ -638,9 +638,7 @@ } void Directory::DeleteEntry(const ScopedKernelLock& lock, - bool save_to_journal, - EntryKernel* entry_ptr, - OwnedEntryKernelSet* entries_to_journal) { + EntryKernel* entry_ptr) { int64_t handle = entry_ptr->ref(META_HANDLE); kernel_->metahandles_to_purge.insert(handle); @@ -671,10 +669,6 @@ num_erased = kernel_->server_tags_map.erase(entry->ref(UNIQUE_SERVER_TAG)); DCHECK_EQ(1u, num_erased); } - - if (save_to_journal) { - entries_to_journal->insert(std::move(entry)); - } } void Directory::PurgeEntriesWithTypeIn(ModelTypeSet disabled_types, @@ -686,8 +680,6 @@ WriteTransaction trans(FROM_HERE, PURGE_ENTRIES, this); - OwnedEntryKernelSet entries_to_journal; - { ScopedKernelLock lock(this); @@ -721,18 +713,11 @@ types_to_unapply.Has(server_type)) { UnapplyEntry(entry); } else { - bool save_to_journal = - (types_to_journal.Has(local_type) || - types_to_journal.Has(server_type)) && - (delete_journal_->IsDeleteJournalEnabled(local_type) || - delete_journal_->IsDeleteJournalEnabled(server_type)); - DeleteEntry(lock, save_to_journal, entry, &entries_to_journal); + DeleteEntry(lock, entry); } } } - delete_journal_->AddJournalBatch(&trans, entries_to_journal); - // Ensure meta tracking for these data types reflects the purged state. for (ModelType type : disabled_types) { kernel_->persisted_info.transaction_version[type] = 0; @@ -803,7 +788,6 @@ snapshot.metahandles_to_purge.end()); // Restore delete journals. - delete_journal_->AddJournalBatch(&trans, snapshot.delete_journals); delete_journal_->PurgeDeleteJournals(&trans, snapshot.delete_journals_to_purge); }
diff --git a/components/sync/syncable/directory.h b/components/sync/syncable/directory.h index 129c5f4..f43f72b8 100644 --- a/components/sync/syncable/directory.h +++ b/components/sync/syncable/directory.h
@@ -144,7 +144,6 @@ PersistedKernelInfo kernel_info; OwnedEntryKernelSet dirty_metas; MetahandleSet metahandles_to_purge; - OwnedEntryKernelSet delete_journals; MetahandleSet delete_journals_to_purge; }; @@ -586,10 +585,7 @@ // Helper methods used by PurgeDisabledTypes. void UnapplyEntry(EntryKernel* entry); - void DeleteEntry(const ScopedKernelLock& lock, - bool save_to_journal, - EntryKernel* entry, - OwnedEntryKernelSet* entries_to_journal); + void DeleteEntry(const ScopedKernelLock& lock, EntryKernel* entry); // A private version of the public GetMetaHandlesOfType for when you already // have a ScopedKernelLock.
diff --git a/components/sync/syncable/directory_backing_store.cc b/components/sync/syncable/directory_backing_store.cc index ead2463..d745cea7 100644 --- a/components/sync/syncable/directory_backing_store.cc +++ b/components/sync/syncable/directory_backing_store.cc
@@ -361,11 +361,6 @@ PrepareSaveEntryStatement(DELETE_JOURNAL_TABLE, &save_delete_journal_statement_); - for (auto i = snapshot.delete_journals.begin(); - i != snapshot.delete_journals.end(); ++i) { - if (!SaveEntryToDB(&save_delete_journal_statement_, **i)) - return false; - } if (!DeleteEntries(DELETE_JOURNAL_TABLE, snapshot.delete_journals_to_purge)) return false;
diff --git a/components/sync/syncable/directory_unittest.cc b/components/sync/syncable/directory_unittest.cc index 067f729..e46e5b00 100644 --- a/components/sync/syncable/directory_unittest.cc +++ b/components/sync/syncable/directory_unittest.cc
@@ -1665,11 +1665,6 @@ snapshot.metahandles_to_purge.clear(); EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); - snapshot.delete_journals.insert(std::make_unique<EntryKernel>()); - EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); - snapshot.delete_journals.clear(); - - EXPECT_FALSE(snapshot.HasUnsavedMetahandleChanges()); snapshot.delete_journals_to_purge.insert(1); EXPECT_TRUE(snapshot.HasUnsavedMetahandleChanges()); snapshot.delete_journals_to_purge.clear();
diff --git a/components/sync/syncable/model_neutral_mutable_entry.cc b/components/sync/syncable/model_neutral_mutable_entry.cc index 784b5232..b489b62c 100644 --- a/components/sync/syncable/model_neutral_mutable_entry.cc +++ b/components/sync/syncable/model_neutral_mutable_entry.cc
@@ -237,21 +237,6 @@ kernel_->put(SERVER_IS_DEL, value); MarkDirty(); } - - if (!value || kernel_->ref(IS_UNAPPLIED_UPDATE)) { - // Update delete journal for existence status change on server side here - // instead of in PutIsDel() because IS_DEL may not be updated due to - // early returns when processing updates. And because - // UpdateDeleteJournalForServerDelete() checks for SERVER_IS_DEL, it has - // to be called on sync thread. - - // Please note that the delete journal applies only to the deletions - // originating on the server side (hence the IS_UNAPPLIED_UPDATE check), - // but it still makes sense to remove the entry from the delete journal - // when it gets undeleted locally. - dir()->delete_journal()->UpdateDeleteJournalForServerDelete( - base_write_transaction(), old_value, *kernel_); - } } void ModelNeutralMutableEntry::PutServerNonUniqueName(
diff --git a/components/sync/syncable/syncable_delete_journal.cc b/components/sync/syncable/syncable_delete_journal.cc index 117e759..5e50c7c 100644 --- a/components/sync/syncable/syncable_delete_journal.cc +++ b/components/sync/syncable/syncable_delete_journal.cc
@@ -20,47 +20,6 @@ DeleteJournal::~DeleteJournal() {} -void DeleteJournal::UpdateDeleteJournalForServerDelete( - BaseTransaction* trans, - bool was_deleted, - const EntryKernel& entry) { - DCHECK(trans); - - // Should be sufficient to check server type only but check for local - // type too because of incomplete test setup. - if (!(IsDeleteJournalEnabled(entry.GetServerModelType()) || - IsDeleteJournalEnabled( - GetModelTypeFromSpecifics(entry.ref(SPECIFICS))))) { - return; - } - - auto it = delete_journals_.find(&entry); - - if (entry.ref(SERVER_IS_DEL)) { - if (it == delete_journals_.end()) { - // New delete. - auto entry_copy = std::make_unique<EntryKernel>(entry); - delete_journals_to_purge_.erase(entry_copy->ref(META_HANDLE)); - AddEntryToJournalIndex(&delete_journals_, std::move(entry_copy)); - } - } else { - // Undelete. This could happen in two cases: - // * An entry was deleted then undeleted, i.e. server delete was - // overwritten because of entry has unsynced data locally. - // * A data type was broken, i.e. encountered unrecoverable error, in last - // sync session and all its entries were duplicated in delete journals. - // On restart, entries are recreated from downloads and recreation calls - // UpdateDeleteJournals() to remove live entries from delete journals, - // thus only deleted entries remain in journals. - if (it != delete_journals_.end()) { - delete_journals_to_purge_.insert((*it).first->ref(META_HANDLE)); - delete_journals_.erase(it); - } else if (was_deleted) { - delete_journals_to_purge_.insert(entry.ref(META_HANDLE)); - } - } -} - void DeleteJournal::PurgeDeleteJournals(BaseTransaction* trans, const MetahandleSet& to_purge) { DCHECK(trans); @@ -83,30 +42,6 @@ delete_journals_to_purge_.clear(); } -void DeleteJournal::AddJournalBatch(BaseTransaction* trans, - const OwnedEntryKernelSet& entries) { - DCHECK(trans); - EntryKernel needle; - for (auto& entry : entries) { - needle.put(ID, entry->ref(ID)); - if (delete_journals_.find(&needle) == delete_journals_.end()) { - auto entry_copy = std::make_unique<EntryKernel>(*entry); - AddEntryToJournalIndex(&delete_journals_, std::move(entry_copy)); - } - delete_journals_to_purge_.erase(entry->ref(META_HANDLE)); - } -} - -/* static */ -bool DeleteJournal::IsDeleteJournalEnabled(ModelType type) { - switch (type) { - case BOOKMARKS: - return true; - default: - return false; - } -} - // static void DeleteJournal::AddEntryToJournalIndex(JournalIndex* journal_index, std::unique_ptr<EntryKernel> entry) {
diff --git a/components/sync/syncable/syncable_delete_journal.h b/components/sync/syncable/syncable_delete_journal.h index dbe3e6f..b4140707f 100644 --- a/components/sync/syncable/syncable_delete_journal.h +++ b/components/sync/syncable/syncable_delete_journal.h
@@ -45,12 +45,6 @@ explicit DeleteJournal(std::unique_ptr<JournalIndex> initial_journal); ~DeleteJournal(); - // Add/remove |entry| to/from |delete_journals_| according to its - // SERVER_IS_DEL field and |was_deleted|. Called on sync thread. - void UpdateDeleteJournalForServerDelete(BaseTransaction* trans, - bool was_deleted, - const EntryKernel& entry); - // Purge entries of specified type in |delete_journals_| if their handles are // in |to_purge|. This should be called after model association and // |to_purge| should contain handles of the entries whose deletions are @@ -63,18 +57,6 @@ void TakeSnapshotAndClear(BaseTransaction* trans, MetahandleSet* journals_to_purge); - // Add |entries| to |delete_journals_| regardless of their SERVER_IS_DEL - // value. This is used to: - // * restore delete journals from snapshot if snapshot failed to save. - // * batch add entries of a data type with unrecoverable error to delete - // journal before purging them. - // Called on sync thread. - void AddJournalBatch(BaseTransaction* trans, - const OwnedEntryKernelSet& entries); - - // Return true if delete journals of |type| are maintained. - static bool IsDeleteJournalEnabled(ModelType type); - // Adds entry to JournalIndex if it doesn't already exist. static void AddEntryToJournalIndex(JournalIndex* journal_index, std::unique_ptr<EntryKernel> entry); @@ -86,6 +68,7 @@ // in case of unrecoverable error, all purged entries are moved here for // bookkeeping to prevent back-from-dead entries that are deleted elsewhere // when sync's down. + // TODO(crbug.com/854684): We never read from this; get rid of it. JournalIndex delete_journals_; // Contains meta handles of deleted entries that have been persisted or
diff --git a/components/url_formatter/spoof_checks/idn_spoof_checker.cc b/components/url_formatter/spoof_checks/idn_spoof_checker.cc index fdcdcde..5f979a1 100644 --- a/components/url_formatter/spoof_checks/idn_spoof_checker.cc +++ b/components/url_formatter/spoof_checks/idn_spoof_checker.cc
@@ -386,6 +386,7 @@ // U+2F00 (Kangxi Radical One) is similar, but it's normalized to // U+4E00 so it's not explicitly checked here. R"([^\p{scx=kana}\p{scx=hira}\p{scx=hani}])" + R"([\u4e00\u3127]|)" R"([\u4e00\u3127])" R"([^\p{scx=kana}\p{scx=hira}\p{scx=hani}]|)"
diff --git a/components/url_formatter/spoof_checks/idn_spoof_checker_unittest.cc b/components/url_formatter/spoof_checks/idn_spoof_checker_unittest.cc index 4e8363f..0004c00 100644 --- a/components/url_formatter/spoof_checks/idn_spoof_checker_unittest.cc +++ b/components/url_formatter/spoof_checks/idn_spoof_checker_unittest.cc
@@ -752,8 +752,9 @@ false}, // Deva digit + Beng digit {"xn--e4b0x.co.in", L"\x0967\x09e7.co.in", false}, - // U+4E00 (CJK Ideograph One) is not a digit - {"xn--d12-s18d.cn", L"d12\x4e00.cn", true}, + // U+4E00 (CJK Ideograph One) is not a digit, but it's not allowed next to + // non-Kana scripts including numbers. + {"xn--d12-s18d.cn", L"d12\x4e00.cn", false}, // One that's really long that will force a buffer realloc {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaa", @@ -1082,6 +1083,9 @@ // U+4E00 and U+3127 should be blocked when next to non-CJK. {"xn--ipaddress-w75n.com", L"ip一address.com", false}, {"xn--ipaddress-wx5h.com", L"ipㄧaddress.com", false}, + // U+4E00 at the beginning and end of a string. + {"xn--google-gg5e.com", L"googleㄧ.com", false}, + {"xn--google-9f5e.com", L"ㄧgoogle.com", false}, // These are allowed because 一 is not immediately next to non-CJK. {"xn--gamer-fg1hz05u.com", L"一生gamer.com", true}, {"xn--gamer-kg1hy05u.com", L"gamer生一.com", true},
diff --git a/content/BUILD.gn b/content/BUILD.gn index ee7f2d1..d5a0c31 100644 --- a/content/BUILD.gn +++ b/content/BUILD.gn
@@ -126,6 +126,7 @@ ] deps = [ "//content/browser/process_internals:mojo_bindings_js", + "//gpu/ipc/common:vulkan_interface_js", "//url/mojom:url_mojom_origin_js", ] }
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index 78340fe..3d1920f 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn
@@ -70,6 +70,7 @@ "//components/services/filesystem:lib", "//components/services/quarantine:quarantine", "//components/services/storage", + "//components/services/storage/public/cpp", "//components/system_media_controls", "//components/tracing", "//components/tracing:startup_tracing", @@ -791,8 +792,6 @@ "dom_storage/dom_storage_context_wrapper.h", "dom_storage/dom_storage_database.cc", "dom_storage/dom_storage_database.h", - "dom_storage/dom_storage_task_runner.cc", - "dom_storage/dom_storage_task_runner.h", "dom_storage/dom_storage_types.h", "dom_storage/local_storage_context_mojo.cc", "dom_storage/local_storage_context_mojo.h",
diff --git a/content/browser/android/ime_adapter_android.cc b/content/browser/android/ime_adapter_android.cc index a9f3634..606c2732 100644 --- a/content/browser/android/ime_adapter_android.cc +++ b/content/browser/android/ime_adapter_android.cc
@@ -213,11 +213,11 @@ selection_start.type() == gfx::SelectionBound::CENTER; const jboolean is_insertion_marker_visible = selection_start.visible(); const jfloat insertion_marker_horizontal = - has_insertion_marker ? selection_start.edge_top().x() : 0.0f; + has_insertion_marker ? selection_start.edge_start().x() : 0.0f; const jfloat insertion_marker_top = - has_insertion_marker ? selection_start.edge_top().y() : 0.0f; + has_insertion_marker ? selection_start.edge_start().y() : 0.0f; const jfloat insertion_marker_bottom = - has_insertion_marker ? selection_start.edge_bottom().y() : 0.0f; + has_insertion_marker ? selection_start.edge_end().y() : 0.0f; Java_ImeAdapterImpl_updateFrameInfo( env, obj, dip_scale, content_offset_ypix, has_insertion_marker,
diff --git a/content/browser/devtools/protocol/system_info_handler.cc b/content/browser/devtools/protocol/system_info_handler.cc index 1f6266b..2f6f4ab 100644 --- a/content/browser/devtools/protocol/system_info_handler.cc +++ b/content/browser/devtools/protocol/system_info_handler.cc
@@ -88,6 +88,11 @@ dictionary_->setDouble(name, value.InSecondsF()); } + void AddBinary(const char* name, + const base::span<const uint8_t>& value) override { + // TODO(penghuang): send vulkan info to devtool + } + void BeginGPUDevice() override {} void EndGPUDevice() override {}
diff --git a/content/browser/dom_storage/dom_storage_browsertest.cc b/content/browser/dom_storage/dom_storage_browsertest.cc index f412e33d..86345a6 100644 --- a/content/browser/dom_storage/dom_storage_browsertest.cc +++ b/content/browser/dom_storage/dom_storage_browsertest.cc
@@ -8,9 +8,9 @@ #include "base/test/bind_test_util.h" #include "base/threading/thread_restrictions.h" #include "build/build_config.h" +#include "components/services/storage/public/cpp/constants.h" #include "content/browser/dom_storage/dom_storage_context_wrapper.h" #include "content/browser/dom_storage/dom_storage_database.h" -#include "content/browser/dom_storage/dom_storage_task_runner.h" #include "content/browser/dom_storage/dom_storage_types.h" #include "content/browser/dom_storage/local_storage_context_mojo.h" #include "content/browser/dom_storage/session_storage_context_mojo.h" @@ -56,13 +56,15 @@ } } + StoragePartition* partition() { + return BrowserContext::GetDefaultStoragePartition( + shell()->web_contents()->GetBrowserContext()); + } + std::vector<StorageUsageInfo> GetUsage() { - auto* context = BrowserContext::GetDefaultStoragePartition( - shell()->web_contents()->GetBrowserContext()) - ->GetDOMStorageContext(); base::RunLoop loop; std::vector<StorageUsageInfo> usage; - context->GetLocalStorageUsage( + partition()->GetDOMStorageContext()->GetLocalStorageUsage( base::BindLambdaForTesting([&](const std::vector<StorageUsageInfo>& u) { usage = u; loop.Quit(); @@ -72,19 +74,15 @@ } void DeletePhysicalOrigin(url::Origin origin) { - auto* context = BrowserContext::GetDefaultStoragePartition( - shell()->web_contents()->GetBrowserContext()) - ->GetDOMStorageContext(); base::RunLoop loop; - context->DeleteLocalStorage(origin, loop.QuitClosure()); + partition()->GetDOMStorageContext()->DeleteLocalStorage(origin, + loop.QuitClosure()); loop.Run(); } DOMStorageContextWrapper* context_wrapper() { return static_cast<DOMStorageContextWrapper*>( - BrowserContext::GetDefaultStoragePartition( - shell()->web_contents()->GetBrowserContext()) - ->GetDOMStorageContext()); + partition()->GetDOMStorageContext()); } base::SequencedTaskRunner* mojo_task_runner() { @@ -97,10 +95,6 @@ return context_wrapper()->mojo_session_state_; } - base::FilePath legacy_localstorage_path() { - return context()->old_localstorage_path_; - } - void EnsureConnected() { base::RunLoop run_loop; mojo_task_runner()->PostTask( @@ -187,12 +181,14 @@ #endif IN_PROC_BROWSER_TEST_F(DOMStorageBrowserTest, DataMigrates) { - base::FilePath db_path = legacy_localstorage_path().Append( + const base::FilePath legacy_local_storage_path = + partition()->GetPath().Append(storage::kLocalStoragePath); + base::FilePath db_path = legacy_local_storage_path.Append( LocalStorageContextMojo::LegacyDatabaseFileNameFromOrigin( url::Origin::Create(GetTestUrl("dom_storage", "store_data.html")))); { base::ScopedAllowBlockingForTesting allow_blocking; - EXPECT_TRUE(base::CreateDirectory(legacy_localstorage_path())); + EXPECT_TRUE(base::CreateDirectory(legacy_local_storage_path)); DOMStorageDatabase db(db_path); DOMStorageValuesMap data; data[base::ASCIIToUTF16("foo")] =
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.cc b/content/browser/dom_storage/dom_storage_context_wrapper.cc index a1c97f86..289fe11e 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper.cc
@@ -7,11 +7,9 @@ #include <string> #include <vector> -#include "base/barrier_closure.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" -#include "base/files/file_enumerator.h" #include "base/files/file_path.h" #include "base/location.h" #include "base/memory/weak_ptr.h" @@ -21,7 +19,7 @@ #include "base/task/post_task.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" -#include "content/browser/dom_storage/dom_storage_task_runner.h" +#include "components/services/storage/public/cpp/constants.h" #include "content/browser/dom_storage/local_storage_context_mojo.h" #include "content/browser/dom_storage/session_storage_context_mojo.h" #include "content/browser/dom_storage/session_storage_namespace_impl.h" @@ -33,7 +31,6 @@ #include "content/public/common/content_client.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" -#include "sql/database.h" #include "storage/browser/quota/special_storage_policy.h" #include "third_party/blink/public/common/features.h" #include "url/origin.h" @@ -41,43 +38,8 @@ namespace content { namespace { -const char kLocalStorageDirectory[] = "Local Storage"; const char kSessionStorageDirectory[] = "Session Storage"; -void GetLegacyLocalStorageUsage( - const base::FilePath& directory, - scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, - DOMStorageContext::GetLocalStorageUsageCallback callback) { - std::vector<StorageUsageInfo> infos; - base::FileEnumerator enumerator(directory, false, - base::FileEnumerator::FILES); - for (base::FilePath path = enumerator.Next(); !path.empty(); - path = enumerator.Next()) { - if (path.MatchesExtension( - LocalStorageContextMojo::kLegacyDatabaseFileExtension)) { - base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); - infos.emplace_back( - LocalStorageContextMojo::OriginFromLegacyDatabaseFileName(path), - find_info.GetSize(), find_info.GetLastModifiedTime()); - } - } - reply_task_runner->PostTask( - FROM_HERE, base::BindOnce(std::move(callback), std::move(infos))); -} - -void InvokeLocalStorageUsageCallbackHelper( - DOMStorageContext::GetLocalStorageUsageCallback callback, - std::unique_ptr<std::vector<StorageUsageInfo>> infos) { - std::move(callback).Run(*infos); -} - -void CollectLocalStorageUsage(std::vector<StorageUsageInfo>* out_info, - base::OnceClosure done_callback, - const std::vector<StorageUsageInfo>& in_info) { - out_info->insert(out_info->end(), in_info.begin(), in_info.end()); - std::move(done_callback).Run(); -} - void GotMojoCallback( scoped_refptr<base::SingleThreadTaskRunner> reply_task_runner, base::OnceClosure callback) { @@ -110,31 +72,16 @@ if (!profile_path.empty()) data_path = profile_path.Append(local_partition_path); - scoped_refptr<base::SequencedTaskRunner> primary_sequence = - base::CreateSequencedTaskRunner( - {base::ThreadPool(), base::MayBlock(), - base::TaskPriority::USER_BLOCKING, - base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); - scoped_refptr<base::SequencedTaskRunner> commit_sequence = - base::CreateSequencedTaskRunner( - {base::ThreadPool(), base::MayBlock(), - base::TaskPriority::BEST_EFFORT, - base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); auto mojo_task_runner = base::CreateSingleThreadTaskRunner({BrowserThread::IO}); - base::FilePath legacy_localstorage_path = - data_path.empty() ? data_path - : data_path.AppendASCII(kLocalStorageDirectory); - base::FilePath new_localstorage_path = - profile_path.empty() - ? base::FilePath() - : base::FilePath().AppendASCII(kLocalStorageDirectory); LocalStorageContextMojo* mojo_local_state = new LocalStorageContextMojo( data_path, mojo_task_runner, - new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence), - std::move(commit_sequence)), - legacy_localstorage_path, new_localstorage_path, special_storage_policy); + base::CreateSequencedTaskRunner( + {base::ThreadPool(), base::MayBlock(), + base::TaskPriority::USER_BLOCKING, + base::TaskShutdownBehavior::BLOCK_SHUTDOWN}), + special_storage_policy); SessionStorageContextMojo* mojo_session_state = nullptr; mojo_session_state = new SessionStorageContextMojo( data_path, @@ -155,19 +102,16 @@ std::string(kSessionStorageDirectory)); return base::WrapRefCounted(new DOMStorageContextWrapper( - std::move(legacy_localstorage_path), mojo_task_runner, mojo_local_state, - mojo_session_state)); + mojo_task_runner, mojo_local_state, mojo_session_state)); } DOMStorageContextWrapper::DOMStorageContextWrapper( - base::FilePath legacy_local_storage_path, scoped_refptr<base::SequencedTaskRunner> mojo_task_runner, LocalStorageContextMojo* mojo_local_storage_context, SessionStorageContextMojo* mojo_session_storage_context) : mojo_state_(mojo_local_storage_context), mojo_session_state_(mojo_session_storage_context), - mojo_task_runner_(std::move(mojo_task_runner)), - legacy_localstorage_path_(std::move(legacy_local_storage_path)) { + mojo_task_runner_(std::move(mojo_task_runner)) { memory_pressure_listener_.reset(new base::MemoryPressureListener( base::BindRepeating(&DOMStorageContextWrapper::OnMemoryPressure, base::Unretained(this)))); @@ -186,13 +130,7 @@ std::move(callback).Run(std::vector<StorageUsageInfo>()); return; } - auto infos = std::make_unique<std::vector<StorageUsageInfo>>(); - auto* infos_ptr = infos.get(); - base::RepeatingClosure got_local_storage_usage = base::BarrierClosure( - 2, base::BindOnce(&InvokeLocalStorageUsageCallbackHelper, - std::move(callback), std::move(infos))); - auto collect_callback = base::BindRepeating( - CollectLocalStorageUsage, infos_ptr, std::move(got_local_storage_usage)); + // base::Unretained is safe here, because the mojo_state_ won't be deleted // until a ShutdownAndDelete task has been ran on the mojo_task_runner_, and // as soon as that task is posted, mojo_state_ is set to null, preventing @@ -203,12 +141,7 @@ base::Unretained(mojo_state_), base::BindOnce(&GotMojoLocalStorageUsage, base::ThreadTaskRunnerHandle::Get(), - collect_callback))); - mojo_state_->legacy_task_runner()->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::BindOnce(&GetLegacyLocalStorageUsage, legacy_localstorage_path_, - base::ThreadTaskRunnerHandle::Get(), - std::move(collect_callback))); + std::move(callback)))); } void DOMStorageContextWrapper::GetSessionStorageUsage( @@ -251,15 +184,6 @@ base::Unretained(mojo_state_), origin, base::BindOnce(&GotMojoCallback, base::ThreadTaskRunnerHandle::Get(), std::move(callback)))); - if (!legacy_localstorage_path_.empty()) { - mojo_state_->legacy_task_runner()->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::BindOnce( - base::IgnoreResult(&sql::Database::Delete), - legacy_localstorage_path_.Append( - LocalStorageContextMojo::LegacyDatabaseFileNameFromOrigin( - origin)))); - } } void DOMStorageContextWrapper::PerformLocalStorageCleanup(
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper.h b/content/browser/dom_storage/dom_storage_context_wrapper.h index 7fb85e4..137f35f5 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper.h +++ b/content/browser/dom_storage/dom_storage_context_wrapper.h
@@ -65,7 +65,6 @@ storage::SpecialStoragePolicy* special_storage_policy); DOMStorageContextWrapper( - base::FilePath legacy_local_storage_path, scoped_refptr<base::SequencedTaskRunner> mojo_task_runner, LocalStorageContextMojo* mojo_local_storage_context, SessionStorageContextMojo* mojo_session_storage_context); @@ -162,8 +161,6 @@ GUARDED_BY(alive_namespaces_lock_); mutable base::Lock alive_namespaces_lock_; - base::FilePath legacy_localstorage_path_; - // To receive memory pressure signals. std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
diff --git a/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc b/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc index c3b023b3..7ae0ddb 100644 --- a/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc +++ b/content/browser/dom_storage/dom_storage_context_wrapper_unittest.cc
@@ -38,8 +38,8 @@ /*leveldb_name=*/""); session_storage_context->PretendToConnectForTesting(); context_ = new DOMStorageContextWrapper( - /*legacy_local_storage_path=*/base::FilePath(), fake_mojo_task_runner_, - /*mojo_local_storage_context=*/nullptr, session_storage_context); + fake_mojo_task_runner_, /*mojo_local_storage_context=*/nullptr, + session_storage_context); } void TearDown() override {
diff --git a/content/browser/dom_storage/dom_storage_task_runner.cc b/content/browser/dom_storage/dom_storage_task_runner.cc deleted file mode 100644 index ef2c501..0000000 --- a/content/browser/dom_storage/dom_storage_task_runner.cc +++ /dev/null
@@ -1,100 +0,0 @@ -// Copyright 2013 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 "content/browser/dom_storage/dom_storage_task_runner.h" - -#include <utility> - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/location.h" -#include "base/logging.h" - -namespace content { - -// DOMStorageWorkerPoolTaskRunner - -DOMStorageWorkerPoolTaskRunner::DOMStorageWorkerPoolTaskRunner( - scoped_refptr<base::SequencedTaskRunner> primary_sequence, - scoped_refptr<base::SequencedTaskRunner> commit_sequence) - : primary_sequence_(std::move(primary_sequence)), - commit_sequence_(std::move(commit_sequence)) {} - -DOMStorageWorkerPoolTaskRunner::~DOMStorageWorkerPoolTaskRunner() = default; - -bool DOMStorageWorkerPoolTaskRunner::RunsTasksInCurrentSequence() const { - return primary_sequence_->RunsTasksInCurrentSequence() || - commit_sequence_->RunsTasksInCurrentSequence(); -} - -bool DOMStorageWorkerPoolTaskRunner::PostDelayedTask( - const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) { - return primary_sequence_->PostDelayedTask(from_here, std::move(task), delay); -} - -bool DOMStorageWorkerPoolTaskRunner::PostShutdownBlockingTask( - const base::Location& from_here, - SequenceID sequence_id, - base::OnceClosure task) { - return GetSequencedTaskRunner(sequence_id) - ->PostTask(from_here, std::move(task)); -} - -void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnPrimarySequence() const { - DCHECK(primary_sequence_->RunsTasksInCurrentSequence()); -} - -void DOMStorageWorkerPoolTaskRunner::AssertIsRunningOnCommitSequence() const { - DCHECK(commit_sequence_->RunsTasksInCurrentSequence()); -} - -scoped_refptr<base::SequencedTaskRunner> -DOMStorageWorkerPoolTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { - if (sequence_id == PRIMARY_SEQUENCE) - return primary_sequence_; - DCHECK_EQ(COMMIT_SEQUENCE, sequence_id); - return commit_sequence_; -} - -// MockDOMStorageTaskRunner - -MockDOMStorageTaskRunner::MockDOMStorageTaskRunner( - scoped_refptr<base::SequencedTaskRunner> task_runner) - : task_runner_(std::move(task_runner)) {} - -MockDOMStorageTaskRunner::~MockDOMStorageTaskRunner() = default; - -bool MockDOMStorageTaskRunner::RunsTasksInCurrentSequence() const { - return task_runner_->RunsTasksInCurrentSequence(); -} - -bool MockDOMStorageTaskRunner::PostDelayedTask(const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) { - return task_runner_->PostTask(from_here, std::move(task)); -} - -bool MockDOMStorageTaskRunner::PostShutdownBlockingTask( - const base::Location& from_here, - SequenceID sequence_id, - base::OnceClosure task) { - return task_runner_->PostTask(from_here, std::move(task)); -} - -void MockDOMStorageTaskRunner::AssertIsRunningOnPrimarySequence() const { - DCHECK(RunsTasksInCurrentSequence()); -} - -void MockDOMStorageTaskRunner::AssertIsRunningOnCommitSequence() const { - DCHECK(RunsTasksInCurrentSequence()); -} - -scoped_refptr<base::SequencedTaskRunner> -MockDOMStorageTaskRunner::GetSequencedTaskRunner(SequenceID sequence_id) { - return task_runner_; -} - -} // namespace content
diff --git a/content/browser/dom_storage/dom_storage_task_runner.h b/content/browser/dom_storage/dom_storage_task_runner.h deleted file mode 100644 index c8a41f25..0000000 --- a/content/browser/dom_storage/dom_storage_task_runner.h +++ /dev/null
@@ -1,129 +0,0 @@ -// Copyright 2013 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 CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ -#define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_ - -#include "base/callback.h" -#include "base/memory/ref_counted.h" -#include "base/sequence_checker.h" -#include "base/sequenced_task_runner.h" -#include "base/time/time.h" -#include "content/common/content_export.h" - -namespace content { - -// DOMStorage uses two task sequences (primary vs commit) to avoid -// primary access from queuing up behind commits to disk. -// * Initialization, shutdown, and administrative tasks are performed as -// shutdown-blocking primary sequence tasks. -// * Tasks directly related to the javascript'able interface are performed -// as shutdown-blocking primary sequence tasks. -// TODO(michaeln): Skip tasks for reading during shutdown. -// * Internal tasks related to committing changes to disk are performed as -// shutdown-blocking commit sequence tasks. -class CONTENT_EXPORT DOMStorageTaskRunner - : public base::TaskRunner { - public: - enum SequenceID { - PRIMARY_SEQUENCE, - COMMIT_SEQUENCE - }; - - // The PostTask() and PostDelayedTask() methods defined by TaskRunner - // post shutdown-blocking tasks on the primary sequence. - bool PostDelayedTask(const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) override = 0; - - // Posts a shutdown blocking task to |sequence_id|. - virtual bool PostShutdownBlockingTask(const base::Location& from_here, - SequenceID sequence_id, - base::OnceClosure task) = 0; - - virtual void AssertIsRunningOnPrimarySequence() const = 0; - virtual void AssertIsRunningOnCommitSequence() const = 0; - - virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( - SequenceID sequence_id) = 0; - - protected: - ~DOMStorageTaskRunner() override {} -}; - -// A DOMStorageTaskRunner which manages a primary and a commit sequence. -class CONTENT_EXPORT DOMStorageWorkerPoolTaskRunner : - public DOMStorageTaskRunner { - public: - // |primary_sequence| and |commit_sequence| should have - // TaskShutdownBehaviour::BLOCK_SHUTDOWN semantics. - DOMStorageWorkerPoolTaskRunner( - scoped_refptr<base::SequencedTaskRunner> primary_sequence, - scoped_refptr<base::SequencedTaskRunner> commit_sequence); - - bool RunsTasksInCurrentSequence() const override; - - bool PostDelayedTask(const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) override; - - bool PostShutdownBlockingTask(const base::Location& from_here, - SequenceID sequence_id, - base::OnceClosure task) override; - - void AssertIsRunningOnPrimarySequence() const override; - void AssertIsRunningOnCommitSequence() const override; - - scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( - SequenceID sequence_id) override; - - protected: - ~DOMStorageWorkerPoolTaskRunner() override; - - private: - scoped_refptr<base::SequencedTaskRunner> primary_sequence_; - scoped_refptr<base::SequencedTaskRunner> commit_sequence_; - - DISALLOW_COPY_AND_ASSIGN(DOMStorageWorkerPoolTaskRunner); -}; - -// A derived class used in unit tests that ignores all delays so -// we don't block in unit tests waiting for timeouts to expire. -// There is no distinction between [non]-shutdown-blocking or -// the primary sequence vs the commit sequence in the mock, -// all tasks are scheduled on |task_runner| with zero delay. -class CONTENT_EXPORT MockDOMStorageTaskRunner : - public DOMStorageTaskRunner { - public: - explicit MockDOMStorageTaskRunner( - scoped_refptr<base::SequencedTaskRunner> task_runner); - - bool RunsTasksInCurrentSequence() const override; - - bool PostDelayedTask(const base::Location& from_here, - base::OnceClosure task, - base::TimeDelta delay) override; - - bool PostShutdownBlockingTask(const base::Location& from_here, - SequenceID sequence_id, - base::OnceClosure task) override; - - void AssertIsRunningOnPrimarySequence() const override; - void AssertIsRunningOnCommitSequence() const override; - - scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner( - SequenceID sequence_id) override; - - protected: - ~MockDOMStorageTaskRunner() override; - - private: - const scoped_refptr<base::SequencedTaskRunner> task_runner_; - - DISALLOW_COPY_AND_ASSIGN(MockDOMStorageTaskRunner); -}; - -} // namespace content - -#endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_TASK_RUNNER_H_
diff --git a/content/browser/dom_storage/local_storage_context_mojo.cc b/content/browser/dom_storage/local_storage_context_mojo.cc index 5d8aa003..f818b7d 100644 --- a/content/browser/dom_storage/local_storage_context_mojo.cc +++ b/content/browser/dom_storage/local_storage_context_mojo.cc
@@ -14,6 +14,8 @@ #include "base/barrier_closure.h" #include "base/bind.h" +#include "base/files/file_enumerator.h" +#include "base/files/file_path.h" #include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_macros.h" #include "base/optional.h" @@ -24,10 +26,12 @@ #include "base/strings/stringprintf.h" #include "base/system/sys_info.h" #include "base/task/post_task.h" +#include "base/task_runner_util.h" #include "base/trace_event/memory_dump_manager.h" #include "build/build_config.h" #include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/dom_storage_database.h" +#include "components/services/storage/public/cpp/constants.h" #include "content/browser/dom_storage/dom_storage_database.h" #include "content/browser/dom_storage/dom_storage_types.h" #include "content/browser/dom_storage/local_storage_database.pb.h" @@ -202,6 +206,39 @@ } } +const base::FilePath::CharType kLegacyDatabaseFileExtension[] = + FILE_PATH_LITERAL(".localstorage"); + +std::vector<StorageUsageInfo> GetLegacyLocalStorageUsage( + const base::FilePath& directory) { + std::vector<StorageUsageInfo> infos; + base::FileEnumerator enumerator(directory, false, + base::FileEnumerator::FILES); + for (base::FilePath path = enumerator.Next(); !path.empty(); + path = enumerator.Next()) { + if (path.MatchesExtension(kLegacyDatabaseFileExtension)) { + base::FileEnumerator::FileInfo find_info = enumerator.GetInfo(); + infos.emplace_back( + LocalStorageContextMojo::OriginFromLegacyDatabaseFileName(path), + find_info.GetSize(), find_info.GetLastModifiedTime()); + } + } + return infos; +} + +void InvokeLocalStorageUsageCallbackHelper( + LocalStorageContextMojo::GetStorageUsageCallback callback, + std::unique_ptr<std::vector<StorageUsageInfo>> infos) { + std::move(callback).Run(*infos); +} + +void CollectLocalStorageUsage(std::vector<StorageUsageInfo>* out_info, + base::OnceClosure done_callback, + std::vector<StorageUsageInfo> in_info) { + out_info->insert(out_info->end(), in_info.begin(), in_info.end()); + std::move(done_callback).Run(); +} + } // namespace class LocalStorageContextMojo::StorageAreaHolder final @@ -285,25 +322,23 @@ // Delete any old database that might still exist if we successfully wrote // data to LevelDB, and our LevelDB is actually disk backed. if (status.ok() && !deleted_old_data_ && !context_->directory_.empty() && - context_->task_runner_ && !context_->old_localstorage_path_.empty()) { + context_->legacy_task_runner_) { deleted_old_data_ = true; - context_->task_runner_->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::BindOnce(base::IgnoreResult(&sql::Database::Delete), - sql_db_path())); + context_->legacy_task_runner_->PostTask( + FROM_HERE, base::BindOnce(base::IgnoreResult(&sql::Database::Delete), + sql_db_path())); } context_->OnCommitResult(status); } void MigrateData(StorageAreaImpl::ValueMapCallback callback) override { - if (context_->task_runner_ && !context_->old_localstorage_path_.empty()) { - context_->task_runner_->PostShutdownBlockingTask( - FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, - base::BindOnce( - &MigrateStorageHelper, sql_db_path(), - base::ThreadTaskRunnerHandle::Get(), - base::BindOnce(&CallMigrationCalback, base::Passed(&callback)))); + if (context_->legacy_task_runner_ && !context_->directory_.empty()) { + context_->legacy_task_runner_->PostTask( + FROM_HERE, base::BindOnce(&MigrateStorageHelper, sql_db_path(), + base::ThreadTaskRunnerHandle::Get(), + base::BindOnce(&CallMigrationCalback, + base::Passed(&callback)))); return; } std::move(callback).Run(nullptr); @@ -378,9 +413,9 @@ private: base::FilePath sql_db_path() const { - if (context_->old_localstorage_path_.empty()) + if (context_->directory_.empty()) return base::FilePath(); - return context_->old_localstorage_path_.Append( + return context_->directory_.Append( LocalStorageContextMojo::LegacyDatabaseFileNameFromOrigin(origin_)); } @@ -396,10 +431,6 @@ bool has_bindings_ = false; }; -const base::FilePath::CharType - LocalStorageContextMojo::kLegacyDatabaseFileExtension[] = - FILE_PATH_LITERAL(".localstorage"); - // static base::FilePath LocalStorageContextMojo::LegacyDatabaseFileNameFromOrigin( const url::Origin& origin) { @@ -421,23 +452,20 @@ } LocalStorageContextMojo::LocalStorageContextMojo( - const base::FilePath& partition_directory, + const base::FilePath& storage_root, scoped_refptr<base::SequencedTaskRunner> task_runner, - scoped_refptr<DOMStorageTaskRunner> legacy_task_runner, - const base::FilePath& old_localstorage_path, - const base::FilePath& subdirectory, + scoped_refptr<base::SequencedTaskRunner> legacy_task_runner, scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy) - : directory_(subdirectory.empty() - ? base::FilePath() - : partition_directory.Append(subdirectory)), + : directory_(storage_root.empty() + ? storage_root + : storage_root.Append(storage::kLocalStoragePath)), special_storage_policy_(std::move(special_storage_policy)), leveldb_task_runner_(base::CreateSequencedTaskRunner( {base::ThreadPool(), base::MayBlock(), base::TaskShutdownBehavior::BLOCK_SHUTDOWN})), memory_dump_id_(base::StringPrintf("LocalStorage/0x%" PRIXPTR, reinterpret_cast<uintptr_t>(this))), - task_runner_(std::move(legacy_task_runner)), - old_localstorage_path_(old_localstorage_path), + legacy_task_runner_(std::move(legacy_task_runner)), is_low_end_device_(base::SysInfo::IsLowEndDevice()) { base::trace_event::MemoryDumpManager::GetInstance() ->RegisterDumpProviderWithSequencedTaskRunner( @@ -484,6 +512,14 @@ } else { std::move(callback).Run(); } + + if (!directory_.empty()) { + legacy_task_runner_->PostTask( + FROM_HERE, + base::BindOnce( + base::IgnoreResult(&sql::Database::Delete), + directory_.Append(LegacyDatabaseFileNameFromOrigin(origin)))); + } } void LocalStorageContextMojo::PerformStorageCleanup( @@ -739,8 +775,8 @@ in_memory_ = false; database_ = storage::AsyncDomStorageDatabase::OpenDirectory( - std::move(options), directory_, "leveldb", memory_dump_id_, - leveldb_task_runner_, + std::move(options), directory_, storage::kLocalStorageLeveldbName, + memory_dump_id_, leveldb_task_runner_, base::BindOnce(&LocalStorageContextMojo::OnDatabaseOpened, weak_ptr_factory_.GetWeakPtr())); return; @@ -872,7 +908,7 @@ // Destroy database, and try again. if (!in_memory_) { storage::DomStorageDatabase::Destroy( - directory_, "leveldb", leveldb_task_runner_, + directory_, storage::kLocalStorageLeveldbName, leveldb_task_runner_, base::BindOnce(&LocalStorageContextMojo::OnDBDestroyed, weak_ptr_factory_.GetWeakPtr(), recreate_in_memory)); } else { @@ -925,6 +961,25 @@ void LocalStorageContextMojo::RetrieveStorageUsage( GetStorageUsageCallback callback) { + auto infos = std::make_unique<std::vector<StorageUsageInfo>>(); + auto* infos_ptr = infos.get(); + base::RepeatingClosure got_local_storage_usage = base::BarrierClosure( + 2, base::BindOnce(&InvokeLocalStorageUsageCallbackHelper, + std::move(callback), std::move(infos))); + auto collect_callback = base::BindRepeating( + CollectLocalStorageUsage, infos_ptr, std::move(got_local_storage_usage)); + + // Grab metadata about pre-migration Local Storage data in the background + // while we query |database_| below. + if (directory_.empty()) { + collect_callback.Run({}); + } else { + base::PostTaskAndReplyWithResult( + legacy_task_runner_.get(), FROM_HERE, + base::BindOnce(&GetLegacyLocalStorageUsage, directory_), + base::BindOnce(collect_callback)); + } + if (!database_) { // If for whatever reason no leveldb database is available, no storage is // used, so return an array only containing the current areas. @@ -932,18 +987,18 @@ base::Time now = base::Time::Now(); for (const auto& it : areas_) result.emplace_back(it.first, 0, now); - std::move(callback).Run(std::move(result)); - return; + collect_callback.Run(std::move(result)); + } else { + database_->RunDatabaseTask( + base::BindOnce([](const storage::DomStorageDatabase& db) { + std::vector<storage::DomStorageDatabase::KeyValuePair> data; + db.GetPrefixed(base::make_span(kMetaPrefix), &data); + return data; + }), + base::BindOnce(&LocalStorageContextMojo::OnGotMetaData, + weak_ptr_factory_.GetWeakPtr(), + base::BindOnce(collect_callback))); } - - database_->RunDatabaseTask( - base::BindOnce([](const storage::DomStorageDatabase& db) { - std::vector<storage::DomStorageDatabase::KeyValuePair> data; - db.GetPrefixed(base::make_span(kMetaPrefix), &data); - return data; - }), - base::BindOnce(&LocalStorageContextMojo::OnGotMetaData, - weak_ptr_factory_.GetWeakPtr(), std::move(callback))); } void LocalStorageContextMojo::OnGotMetaData(
diff --git a/content/browser/dom_storage/local_storage_context_mojo.h b/content/browser/dom_storage/local_storage_context_mojo.h index d9e2ba3..a6a312f 100644 --- a/content/browser/dom_storage/local_storage_context_mojo.h +++ b/content/browser/dom_storage/local_storage_context_mojo.h
@@ -21,7 +21,6 @@ #include "components/services/storage/dom_storage/async_dom_storage_database.h" #include "components/services/storage/dom_storage/dom_storage_database.h" #include "components/services/storage/public/mojom/dom_storage_area.mojom.h" -#include "content/browser/dom_storage/dom_storage_task_runner.h" #include "content/common/content_export.h" #include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/pending_associated_remote.h" @@ -35,7 +34,6 @@ namespace content { -class DOMStorageTaskRunner; struct StorageUsageInfo; // Used for mojo-based LocalStorage implementation (can be disabled with @@ -50,19 +48,15 @@ using GetStorageUsageCallback = base::OnceCallback<void(std::vector<StorageUsageInfo>)>; - static const base::FilePath::CharType kLegacyDatabaseFileExtension[]; - static base::FilePath LegacyDatabaseFileNameFromOrigin( const url::Origin& origin); static url::Origin OriginFromLegacyDatabaseFileName( const base::FilePath& file_name); LocalStorageContextMojo( - const base::FilePath& partition_directory, + const base::FilePath& storage_root, scoped_refptr<base::SequencedTaskRunner> task_runner, - scoped_refptr<DOMStorageTaskRunner> legacy_task_runner, - const base::FilePath& old_localstorage_path, - const base::FilePath& subdirectory, + scoped_refptr<base::SequencedTaskRunner> legacy_task_runner, scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy); void OpenLocalStorage( @@ -103,10 +97,6 @@ // Converts a string from the old storage format to the new storage format. static std::vector<uint8_t> MigrateString(const base::string16& input); - scoped_refptr<DOMStorageTaskRunner> legacy_task_runner() { - return task_runner_; - } - // Access the underlying DomStorageDatabase. May be null if the database is // not yet open. const base::SequenceBound<storage::DomStorageDatabase>& @@ -199,8 +189,7 @@ std::map<url::Origin, std::unique_ptr<StorageAreaHolder>> areas_; // Used to access old data for migration. - scoped_refptr<DOMStorageTaskRunner> task_runner_; - base::FilePath old_localstorage_path_; + scoped_refptr<base::SequencedTaskRunner> legacy_task_runner_; bool is_low_end_device_; // Counts consecutive commit errors. If this number reaches a threshold, the
diff --git a/content/browser/dom_storage/local_storage_context_mojo_unittest.cc b/content/browser/dom_storage/local_storage_context_mojo_unittest.cc index 04cc3a2..f4c4c84e 100644 --- a/content/browser/dom_storage/local_storage_context_mojo_unittest.cc +++ b/content/browser/dom_storage/local_storage_context_mojo_unittest.cc
@@ -11,13 +11,14 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/run_loop.h" +#include "base/sequenced_task_runner.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" #include "base/test/bind_test_util.h" #include "build/build_config.h" +#include "components/services/storage/public/cpp/constants.h" #include "components/services/storage/public/mojom/key_value_pair.mojom.h" #include "content/browser/dom_storage/dom_storage_database.h" -#include "content/browser/dom_storage/dom_storage_task_runner.h" #include "content/browser/dom_storage/dom_storage_types.h" #include "content/browser/dom_storage/test/storage_area_test_util.h" #include "content/public/browser/browser_thread.h" @@ -108,9 +109,7 @@ class LocalStorageContextMojoTest : public testing::Test { public: LocalStorageContextMojoTest() - : task_runner_(new MockDOMStorageTaskRunner( - base::ThreadTaskRunnerHandle::Get().get())), - mock_special_storage_policy_(new MockSpecialStoragePolicy()) { + : mock_special_storage_policy_(new MockSpecialStoragePolicy()) { EXPECT_TRUE(temp_path_.CreateUniqueTempDir()); } @@ -125,12 +124,12 @@ EXPECT_TRUE(temp_path_.Delete()); } + const base::FilePath& storage_path() const { return temp_path_.GetPath(); } + LocalStorageContextMojo* context() { if (!context_) { context_ = new LocalStorageContextMojo( - temp_path_.GetPath(), base::ThreadTaskRunnerHandle::Get(), - task_runner_, temp_path_.GetPath(), - base::FilePath(FILE_PATH_LITERAL("leveldb")), + storage_path(), base::ThreadTaskRunnerHandle::Get(), task_runner_, special_storage_policy()); } @@ -230,8 +229,6 @@ : base::nullopt; } - const base::FilePath& temp_path() const { return temp_path_.GetPath(); } - // Pumps both the main-thread sequence and the background database sequence // until both are idle. void RunUntilIdle() { task_environment_.RunUntilIdle(); } @@ -282,7 +279,7 @@ base::FilePath FirstEntryInDir() { base::FileEnumerator enumerator( - temp_path(), false /* recursive */, + storage_path(), false /* recursive */, base::FileEnumerator::FILES | base::FileEnumerator::DIRECTORIES); return enumerator.Next(); } @@ -300,7 +297,8 @@ BrowserTaskEnvironment task_environment_; base::ScopedTempDir temp_path_; - scoped_refptr<MockDOMStorageTaskRunner> task_runner_; + scoped_refptr<base::SequencedTaskRunner> task_runner_{ + base::ThreadTaskRunnerHandle::Get()}; LocalStorageContextMojo* context_ = nullptr; @@ -696,7 +694,13 @@ key2.push_back(0xd83d); key2.push_back(0xde00); - base::FilePath old_db_path = temp_path().Append( + // We want to populate the Local Storage directory before the implementation + // has created it, so we have to create it ourselves here. + const base::FilePath local_storage_path = + storage_path().Append(storage::kLocalStoragePath); + ASSERT_TRUE(base::CreateDirectory(local_storage_path)); + + const base::FilePath old_db_path = local_storage_path.Append( LocalStorageContextMojo::LegacyDatabaseFileNameFromOrigin(origin1)); { DOMStorageDatabase db(old_db_path); @@ -852,8 +856,7 @@ TEST_F(LocalStorageContextMojoTest, InMemory) { auto* context = new LocalStorageContextMojo( - base::FilePath(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), base::FilePath(), nullptr); + base::FilePath(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); auto key = StdStringToUint8Vector("key"); auto value = StdStringToUint8Vector("value"); @@ -874,16 +877,15 @@ // Re-opening should get fresh data. context = new LocalStorageContextMojo( - base::FilePath(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), base::FilePath(), nullptr); + base::FilePath(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_FALSE(DoTestGet(context, key, &result)); context->ShutdownAndDelete(); } TEST_F(LocalStorageContextMojoTest, InMemoryInvalidPath) { auto* context = new LocalStorageContextMojo( - base::FilePath(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), base::FilePath(FILE_PATH_LITERAL("../../")), nullptr); + base::FilePath(FILE_PATH_LITERAL("../../")), + base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); auto key = StdStringToUint8Vector("key"); auto value = StdStringToUint8Vector("value"); @@ -905,10 +907,8 @@ } TEST_F(LocalStorageContextMojoTest, OnDisk) { - base::FilePath test_path(FILE_PATH_LITERAL("test_path")); auto* context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); auto key = StdStringToUint8Vector("key"); auto value = StdStringToUint8Vector("value"); @@ -922,24 +922,21 @@ RunUntilIdle(); // Should have created files. - EXPECT_EQ(test_path, FirstEntryInDir().BaseName()); + EXPECT_EQ(base::FilePath(storage::kLocalStoragePath), + FirstEntryInDir().BaseName()); // Should be able to re-open. context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_TRUE(DoTestGet(context, key, &result)); EXPECT_EQ(value, result); context->ShutdownAndDelete(); } TEST_F(LocalStorageContextMojoTest, InvalidVersionOnDisk) { - base::FilePath test_path(FILE_PATH_LITERAL("test_path")); - // Create context and add some data to it. auto* context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); auto key = StdStringToUint8Vector("key"); auto value = StdStringToUint8Vector("value"); @@ -959,17 +956,16 @@ leveldb_env::Options options; options.env = &env; base::FilePath db_path = - temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); + storage_path() + .Append(storage::kLocalStoragePath) + .AppendASCII(storage::kLocalStorageLeveldbName); ASSERT_TRUE(leveldb_env::OpenDB(options, db_path.AsUTF8Unsafe(), &db).ok()); ASSERT_TRUE(db->Put(leveldb::WriteOptions(), "VERSION", "argh").ok()); } // Make sure data is gone. - context = new LocalStorageContextMojo(temp_path(), - base::ThreadTaskRunnerHandle::Get(), - nullptr, base::FilePath(), - - test_path, nullptr); + context = new LocalStorageContextMojo( + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_FALSE(DoTestGet(context, key, &result)); // Write data again. @@ -981,20 +977,16 @@ // Data should have been preserved now. context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_TRUE(DoTestGet(context, key, &result)); EXPECT_EQ(value, result); context->ShutdownAndDelete(); } TEST_F(LocalStorageContextMojoTest, CorruptionOnDisk) { - base::FilePath test_path(FILE_PATH_LITERAL("test_path")); - // Create context and add some data to it. auto* context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); auto key = StdStringToUint8Vector("key"); auto value = StdStringToUint8Vector("value"); @@ -1008,8 +1000,9 @@ RunUntilIdle(); // Delete manifest files to mess up opening DB. - base::FilePath db_path = - temp_path().Append(test_path).Append(FILE_PATH_LITERAL("leveldb")); + base::FilePath db_path = storage_path() + .Append(storage::kLocalStoragePath) + .AppendASCII(storage::kLocalStorageLeveldbName); base::FileEnumerator file_enum(db_path, true, base::FileEnumerator::FILES, FILE_PATH_LITERAL("MANIFEST*")); for (base::FilePath name = file_enum.Next(); !name.empty(); @@ -1019,8 +1012,7 @@ // Make sure data is gone. context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_FALSE(DoTestGet(context, key, &result)); // Write data again. @@ -1032,18 +1024,15 @@ // Data should have been preserved now. context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); EXPECT_TRUE(DoTestGet(context, key, &result)); EXPECT_EQ(value, result); context->ShutdownAndDelete(); } TEST_F(LocalStorageContextMojoTest, RecreateOnCommitFailure) { - base::FilePath test_path(FILE_PATH_LITERAL("test_path")); auto* context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); base::Optional<base::RunLoop> open_loop; base::Optional<base::RunLoop> destruction_loop; @@ -1184,10 +1173,8 @@ } TEST_F(LocalStorageContextMojoTest, DontRecreateOnRepeatedCommitFailure) { - base::FilePath test_path(FILE_PATH_LITERAL("test_path")); auto* context = new LocalStorageContextMojo( - temp_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, - base::FilePath(), test_path, nullptr); + storage_path(), base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr); // Ensure that the opened database always fails on write. base::Optional<base::RunLoop> open_loop;
diff --git a/content/browser/dom_storage/session_storage_namespace_impl.cc b/content/browser/dom_storage/session_storage_namespace_impl.cc index 54487ba..8d8cd55 100644 --- a/content/browser/dom_storage/session_storage_namespace_impl.cc +++ b/content/browser/dom_storage/session_storage_namespace_impl.cc
@@ -13,7 +13,6 @@ #include "base/sequenced_task_runner.h" #include "base/task/post_task.h" #include "content/browser/dom_storage/dom_storage_context_wrapper.h" -#include "content/browser/dom_storage/dom_storage_task_runner.h" #include "content/browser/dom_storage/session_storage_context_mojo.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h"
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc index 81209f6..7da0bce4 100644 --- a/content/browser/frame_host/navigation_request.cc +++ b/content/browser/frame_host/navigation_request.cc
@@ -2474,7 +2474,9 @@ // about to go. service_worker_handle_->OnBeginNavigationCommit( render_frame_host_->GetProcess()->GetID(), - render_frame_host_->GetRoutingID(), &service_worker_provider_info); + render_frame_host_->GetRoutingID(), + render_frame_host_->cross_origin_embedder_policy(), + &service_worker_provider_info); } if (bundled_exchanges_handle_ &&
diff --git a/content/browser/gpu/gpu_internals_ui.cc b/content/browser/gpu/gpu_internals_ui.cc index 9ac4194c..454d4a8 100644 --- a/content/browser/gpu/gpu_internals_ui.cc +++ b/content/browser/gpu/gpu_internals_ui.cc
@@ -10,6 +10,7 @@ #include <string> #include <utility> +#include "base/base64.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" @@ -73,6 +74,8 @@ source->UseStringsJs(); source->AddResourcePath("gpu_internals.js", IDR_GPU_INTERNALS_JS); + source->AddResourcePath("vulkan_info.mojom.js", IDR_VULKAN_INFO_MOJO_JS); + source->AddResourcePath("vulkan_types.mojom.js", IDR_VULKAN_TYPES_MOJO_JS); source->SetDefaultResource(IDR_GPU_INTERNALS_HTML); return source; } @@ -327,6 +330,13 @@ info->Set("diagnostics", std::move(dx_info)); #endif +#if BUILDFLAG(ENABLE_VULKAN) + if (gpu_info.vulkan_info) { + auto blob = gpu_info.vulkan_info->Serialize(); + info->SetString("vulkanInfo", base::Base64Encode(blob)); + } +#endif + return info; }
diff --git a/content/browser/renderer_host/dwrite_font_proxy_impl_win.cc b/content/browser/renderer_host/dwrite_font_proxy_impl_win.cc index f670b0f..ad9c93b 100644 --- a/content/browser/renderer_host/dwrite_font_proxy_impl_win.cc +++ b/content/browser/renderer_host/dwrite_font_proxy_impl_win.cc
@@ -517,12 +517,15 @@ /* width */ 0, /* slant */ 0)); - if (!codepoint) + if (!codepoint || !collection_ || !factory_) return; sk_sp<SkFontMgr> font_mgr( SkFontMgr_New_DirectWrite(factory_.Get(), collection_.Get())); + if (!font_mgr) + return; + const char* bcp47_locales[] = {locale_name.c_str()}; int num_locales = locale_name.empty() ? 0 : 1; const char** locales = locale_name.empty() ? nullptr : bcp47_locales;
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc index 7d87da2..06454cfd 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc +++ b/content/browser/renderer_host/input/touch_selection_controller_client_aura_browsertest.cc
@@ -920,23 +920,23 @@ const ui::TouchSelectionController* controller = GetRenderWidgetHostViewAura()->selection_controller(); - gfx::PointF start_top = controller->start().edge_top(); + gfx::PointF start_top = controller->start().edge_start(); // The selection start should be uppper left, and selection end should be // upper right. - EXPECT_LT(controller->start().edge_top().x(), point.x()); - EXPECT_LT(controller->start().edge_bottom().x(), point.x()); + EXPECT_LT(controller->start().edge_start().x(), point.x()); + EXPECT_LT(controller->start().edge_end().x(), point.x()); - EXPECT_LT(point.x(), controller->end().edge_top().x()); - EXPECT_LT(point.x(), controller->end().edge_bottom().x()); + EXPECT_LT(point.x(), controller->end().edge_start().x()); + EXPECT_LT(point.x(), controller->end().edge_end().x()); // Handles are created below the selection. The top position should roughly // be within the handle size from the touch position. - float handle_size = controller->start().edge_bottom().y() - - controller->start().edge_top().y(); + float handle_size = + controller->start().edge_end().y() - controller->start().edge_start().y(); float handle_max_bottom = point.y() + handle_size; - EXPECT_GT(handle_max_bottom, controller->start().edge_top().y()); - EXPECT_GT(handle_max_bottom, controller->end().edge_top().y()); + EXPECT_GT(handle_max_bottom, controller->start().edge_start().y()); + EXPECT_GT(handle_max_bottom, controller->end().edge_start().y()); gfx::Point handle_point = gfx::ToRoundedPoint( rwhva->selection_controller()->GetStartHandleRect().CenterPoint()); @@ -970,8 +970,8 @@ selection_controller_client()->Wait(); // The handle should have moved to right. - EXPECT_EQ(start_top.y(), controller->start().edge_top().y()); - EXPECT_LT(start_top.x(), controller->start().edge_top().x()); + EXPECT_EQ(start_top.y(), controller->start().edge_start().y()); + EXPECT_LT(start_top.x(), controller->start().edge_start().x()); EXPECT_EQ(ui::TouchSelectionController::SELECTION_ACTIVE, rwhva->selection_controller()->active_status());
diff --git a/content/browser/renderer_host/input/touch_selection_controller_client_child_frame.cc b/content/browser/renderer_host/input/touch_selection_controller_client_child_frame.cc index 52bb340..eff2f748 100644 --- a/content/browser/renderer_host/input/touch_selection_controller_client_child_frame.cc +++ b/content/browser/renderer_host/input/touch_selection_controller_client_child_frame.cc
@@ -44,11 +44,11 @@ // TODO(wjmaclean): Get the transform between the views to lower the // overhead here, instead of calling the transform functions four times. transformed_selection_start.SetEdge( - rwhv_->TransformPointToRootCoordSpaceF(selection_start_.edge_top()), - rwhv_->TransformPointToRootCoordSpaceF(selection_start_.edge_bottom())); + rwhv_->TransformPointToRootCoordSpaceF(selection_start_.edge_start()), + rwhv_->TransformPointToRootCoordSpaceF(selection_start_.edge_end())); transformed_selection_end.SetEdge( - rwhv_->TransformPointToRootCoordSpaceF(selection_end_.edge_top()), - rwhv_->TransformPointToRootCoordSpaceF(selection_end_.edge_bottom())); + rwhv_->TransformPointToRootCoordSpaceF(selection_end_.edge_start()), + rwhv_->TransformPointToRootCoordSpaceF(selection_end_.edge_end())); manager_->UpdateClientSelectionBounds(transformed_selection_start, transformed_selection_end, this, this);
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 4549c3d..386c870 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -640,8 +640,8 @@ // Create a rectangle for the edge of the selection focus, which will be // the same as the caret position if the selection is collapsed. That's // what we want to try to keep centered on-screen if possible. - gfx::Rect gfx_caret_rect(region->focus.edge_top_rounded().x(), - region->focus.edge_top_rounded().y(), 1, + gfx::Rect gfx_caret_rect(region->focus.edge_start_rounded().x(), + region->focus.edge_start_rounded().y(), 1, region->focus.GetHeight()); gfx_caret_rect += view_bounds_in_window_dip_.OffsetFromOrigin(); gfx_caret_rect += window_frame_in_screen_dip_.OffsetFromOrigin();
diff --git a/content/browser/resources/gpu/gpu_internals.html b/content/browser/resources/gpu/gpu_internals.html index 7995d2b..788af89 100644 --- a/content/browser/resources/gpu/gpu_internals.html +++ b/content/browser/resources/gpu/gpu_internals.html
@@ -42,6 +42,9 @@ <script src="chrome://resources/js/cr/ui/tabs.js"></script> <script src="chrome://resources/js/load_time_data.js"></script> <script src="chrome://resources/js/util.js"></script> +<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script> +<script src="chrome://resources/gpu/ipc/common/vulkan_types.mojom-lite.js"></script> +<script src="chrome://resources/gpu/ipc/common/vulkan_info.mojom-lite.js"></script> <script src="gpu_internals.js"></script> <script src="strings.js"></script> </head>
diff --git a/content/browser/resources/gpu/gpu_internals.js b/content/browser/resources/gpu/gpu_internals.js index 855aa3e..62f96f6 100644 --- a/content/browser/resources/gpu/gpu_internals.js +++ b/content/browser/resources/gpu/gpu_internals.js
@@ -4,6 +4,7 @@ // <include src="browser_bridge.js"> // <include src="info_view.js"> +// <include src="vulkan_info.js"> let browserBridge;
diff --git a/content/browser/resources/gpu/info_view.css b/content/browser/resources/gpu/info_view.css index 730b2b8..c3efb62 100644 --- a/content/browser/resources/gpu/info_view.css +++ b/content/browser/resources/gpu/info_view.css
@@ -67,6 +67,10 @@ color: rgb(128, 128, 128); } +#vulkan-info-value { + white-space: pre; +} + #copy-to-clipboard { user-select: none; }
diff --git a/content/browser/resources/gpu/info_view.html b/content/browser/resources/gpu/info_view.html index 5cbdf82a..f2512630 100644 --- a/content/browser/resources/gpu/info_view.html +++ b/content/browser/resources/gpu/info_view.html
@@ -61,6 +61,11 @@ <div id="video-acceleration-info"></div> </div> + <div> + <h3>Vulkan Information</h3> + <div id="vulkan-info"></div> + </div> + <div class="diagnostics"> <h3>Diagnostics</h3> <div class="diagnostics-loading">... loading ...</div> @@ -112,7 +117,7 @@ <span class="row-title" jscontent="description">title</span> </td> <td jsdisplay="!(value instanceof Array)"> - <span jscontent="value">value</span> + <span jscontent="value" jsvalues=".id:id">value</span> </td> <td jsdisplay="value instanceof Array" colspan=2> <span jscontent="description" class="row-title"></span>
diff --git a/content/browser/resources/gpu/info_view.js b/content/browser/resources/gpu/info_view.js index 200b15a9ac..a73782e 100644 --- a/content/browser/resources/gpu/info_view.js +++ b/content/browser/resources/gpu/info_view.js
@@ -211,6 +211,19 @@ } else { diagnosticsDiv.hidden = true; } + + if (gpuInfo.vulkanInfo) { + const vulkanInfo = new gpu.VulkanInfo(gpuInfo.vulkanInfo); + const data = [{ + 'description': 'info', + 'value': vulkanInfo.toString(), + 'id': 'vulkan-info-value' + }]; + this.setTable_('vulkan-info', data); + } else { + this.setTable_('vulkan-info', []); + } + } else { this.setText_('basic-info', '... loading ...'); diagnosticsDiv.hidden = true;
diff --git a/content/browser/resources/gpu/vulkan_info.js b/content/browser/resources/gpu/vulkan_info.js new file mode 100644 index 0000000..72c60d2 --- /dev/null +++ b/content/browser/resources/gpu/vulkan_info.js
@@ -0,0 +1,19 @@ +// 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. + +cr.define('gpu', function() { + class VulkanInfo { + constructor(base64Data) { + const array = Uint8Array.from(atob(base64Data), c => c.charCodeAt(0)); + const dataView = new DataView(array.buffer); + this.vulkanInfo_ = gpu.mojom.VulkanInfo_Deserialize(dataView); + } + + toString() { + return JSON.stringify(this.vulkanInfo_, null, 2); + } + } + + return {VulkanInfo: VulkanInfo}; +});
diff --git a/content/browser/service_worker/service_worker_browsertest.cc b/content/browser/service_worker/service_worker_browsertest.cc index b408156..b546c89b 100644 --- a/content/browser/service_worker/service_worker_browsertest.cc +++ b/content/browser/service_worker/service_worker_browsertest.cc
@@ -3349,7 +3349,7 @@ } protected: - virtual const char* GetWorkerURL() { return kWorkerUrl; } + virtual std::string GetWorkerURL() { return kWorkerUrl; } void RegisterAndActivateServiceWorker() { scoped_refptr<WorkerActivatedObserver> observer = @@ -3595,7 +3595,7 @@ class ServiceWorkerCacheStorageFullCodeCacheFromInstallEventTest : public ServiceWorkerV8CodeCacheForCacheStorageTest { public: - const char* GetWorkerURL() override { + std::string GetWorkerURL() override { return "/service_worker/install_event_caches_script.js"; } }; @@ -3619,7 +3619,7 @@ "CacheStorageCodeCacheHint"); } - const char* GetWorkerURL() override { + std::string GetWorkerURL() override { return "/service_worker/install_event_caches_script_with_hint.js"; } }; @@ -3633,6 +3633,34 @@ WaitUntilSideDataSizeIs(0); } +class ServiceWorkerCacheStorageFullCodeCacheFromInstallEventOpaqueResponseTest + : public ServiceWorkerV8CodeCacheForCacheStorageTest { + public: + ServiceWorkerCacheStorageFullCodeCacheFromInstallEventOpaqueResponseTest() {} + + void SetUpOnMainThread() override { + host_resolver()->AddRule("*", "127.0.0.1"); + ServiceWorkerV8CodeCacheForCacheStorageTest::SetUpOnMainThread(); + } + + std::string GetWorkerURL() override { + GURL cross_origin_script = embedded_test_server()->GetURL( + "bar.com", "/service_worker/v8_cache_test.js"); + return "/service_worker/" + "install_event_caches_no_cors_script.js?script_url=" + + cross_origin_script.spec(); + } +}; + +IN_PROC_BROWSER_TEST_F( + ServiceWorkerCacheStorageFullCodeCacheFromInstallEventOpaqueResponseTest, + FullCodeCacheGenerated) { + RegisterAndActivateServiceWorker(); + // The full code cache should not be generated when the script is an opaque + // response. + WaitUntilSideDataSizeIs(0); +} + // ServiceWorkerDisableWebSecurityTests check the behavior when the web security // is disabled. If '--disable-web-security' flag is set, we don't check the // origin equality in Blink. So the Service Worker related APIs should succeed
diff --git a/content/browser/service_worker/service_worker_navigation_handle.cc b/content/browser/service_worker/service_worker_navigation_handle.cc index f9ba18a..788e1eb 100644 --- a/content/browser/service_worker/service_worker_navigation_handle.cc +++ b/content/browser/service_worker/service_worker_navigation_handle.cc
@@ -43,6 +43,7 @@ void ServiceWorkerNavigationHandle::OnBeginNavigationCommit( int render_process_id, int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy, blink::mojom::ServiceWorkerProviderInfoForClientPtr* out_provider_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); // We may have failed to pre-create the provider host. @@ -52,16 +53,18 @@ FROM_HERE, base::BindOnce( &ServiceWorkerNavigationHandleCore::OnBeginNavigationCommit, - base::Unretained(core_), render_process_id, render_frame_id)); + base::Unretained(core_), render_process_id, render_frame_id, + cross_origin_embedder_policy)); *out_provider_info = std::move(provider_info_); } -void ServiceWorkerNavigationHandle::OnBeginWorkerCommit() { +void ServiceWorkerNavigationHandle::OnBeginWorkerCommit( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy) { DCHECK_CURRENTLY_ON(BrowserThread::UI); ServiceWorkerContextWrapper::RunOrPostTaskOnCoreThread( FROM_HERE, base::BindOnce(&ServiceWorkerNavigationHandleCore::OnBeginWorkerCommit, - base::Unretained(core_))); + base::Unretained(core_), cross_origin_embedder_policy)); } } // namespace content
diff --git a/content/browser/service_worker/service_worker_navigation_handle.h b/content/browser/service_worker/service_worker_navigation_handle.h index 50b4dc72..ff9d6a5 100644 --- a/content/browser/service_worker/service_worker_navigation_handle.h +++ b/content/browser/service_worker/service_worker_navigation_handle.h
@@ -8,6 +8,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "content/common/content_export.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h" namespace content { @@ -61,17 +62,24 @@ blink::mojom::ServiceWorkerProviderInfoForClientPtr provider_info); // Called when the navigation is ready to commit. - // Provides |render_process_id| and |render_frame_id| to the pre-created - // provider host. Fills in |out_provider_info| so the caller can send it to - // the renderer process as part of the navigation commit IPC. + // Provides |render_process_id|, |render_frame_id|, and + // |cross_origin_embedder_policy| to the pre-created provider host. Fills in + // |out_provider_info| so the caller can send it to the renderer process as + // part of the navigation commit IPC. // |out_provider_info| can be filled as null if we failed to pre-create the // provider host for some security reasons. void OnBeginNavigationCommit( int render_process_id, int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy, blink::mojom::ServiceWorkerProviderInfoForClientPtr* out_provider_info); - void OnBeginWorkerCommit(); + // Similar to OnBeginNavigationCommit() for shared workers (and dedicated + // workers when PlzDedicatedWorker is on). + // |cross_origin_embedder_policy| is passed to the pre-created provider + // host. + void OnBeginWorkerCommit( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy); blink::mojom::ServiceWorkerProviderInfoForClientPtr TakeProviderInfo() { return std::move(provider_info_);
diff --git a/content/browser/service_worker/service_worker_navigation_handle_core.cc b/content/browser/service_worker/service_worker_navigation_handle_core.cc index a80292bb..d5a589d4 100644 --- a/content/browser/service_worker/service_worker_navigation_handle_core.cc +++ b/content/browser/service_worker/service_worker_navigation_handle_core.cc
@@ -45,16 +45,20 @@ void ServiceWorkerNavigationHandleCore::OnBeginNavigationCommit( int render_process_id, - int render_frame_id) { + int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy) { DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); - if (provider_host_) - provider_host_->OnBeginNavigationCommit(render_process_id, render_frame_id); + if (provider_host_) { + provider_host_->OnBeginNavigationCommit(render_process_id, render_frame_id, + cross_origin_embedder_policy); + } } -void ServiceWorkerNavigationHandleCore::OnBeginWorkerCommit() { +void ServiceWorkerNavigationHandleCore::OnBeginWorkerCommit( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy) { DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); if (provider_host_) - provider_host_->CompleteWebWorkerPreparation(); + provider_host_->CompleteWebWorkerPreparation(cross_origin_embedder_policy); } } // namespace content
diff --git a/content/browser/service_worker/service_worker_navigation_handle_core.h b/content/browser/service_worker/service_worker_navigation_handle_core.h index b21b881..5d39a1b 100644 --- a/content/browser/service_worker/service_worker_navigation_handle_core.h +++ b/content/browser/service_worker/service_worker_navigation_handle_core.h
@@ -14,6 +14,7 @@ #include "content/browser/service_worker/service_worker_controllee_request_handler.h" #include "content/browser/service_worker/service_worker_provider_host.h" #include "content/common/content_export.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "third_party/blink/public/mojom/service_worker/service_worker_provider.mojom.h" namespace content { @@ -40,11 +41,14 @@ base::WeakPtr<ServiceWorkerProviderHost> provider_host, blink::mojom::ServiceWorkerProviderInfoForClientPtr provider_info); - // Called when the navigation is ready to commit, set the 2 IDs for the - // pre-created provider host. - void OnBeginNavigationCommit(int render_process_id, int render_frame_id); - - void OnBeginWorkerCommit(); + // Called by corresponding methods in ServiceWorkerNavigationHandle. See + // comments in the header of ServiceWorkerNavigationHandle for details. + void OnBeginNavigationCommit( + int render_process_id, + int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy); + void OnBeginWorkerCommit( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy); ServiceWorkerContextWrapper* context_wrapper() const { return context_wrapper_.get();
diff --git a/content/browser/service_worker/service_worker_provider_host.cc b/content/browser/service_worker/service_worker_provider_host.cc index 77a191b..1e818a5e 100644 --- a/content/browser/service_worker/service_worker_provider_host.cc +++ b/content/browser/service_worker/service_worker_provider_host.cc
@@ -472,9 +472,21 @@ ServiceWorkerVersion::FetchHandlerExistence::DOES_NOT_EXIST) { return mojo::Remote<blink::mojom::ControllerServiceWorker>(); } + mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller; - controller_->controller()->Clone( - remote_controller.BindNewPipeAndPassReceiver()); + if (!is_response_committed()) { + // The receiver will be connected to the controller in + // OnBeginNavigationCommit() or CompleteWebWorkerPreparation(). The pair of + // Mojo endpoints is created on each main resource response including + // redirect. The final Mojo endpoint which is corresponding to the OK + // response will be sent to the service worker. + pending_controller_receiver_ = + remote_controller.BindNewPipeAndPassReceiver(); + } else { + controller_->controller()->Clone( + remote_controller.BindNewPipeAndPassReceiver(), + cross_origin_embedder_policy_.value()); + } return remote_controller; } @@ -769,8 +781,10 @@ SetControllerRegistration(registration, true /* notify_controllerchange */); } -void ServiceWorkerProviderHost::OnBeginNavigationCommit(int render_process_id, - int render_frame_id) { +void ServiceWorkerProviderHost::OnBeginNavigationCommit( + int render_process_id, + int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy) { DCHECK_CURRENTLY_ON(ServiceWorkerContext::GetCoreThreadId()); DCHECK_EQ(blink::mojom::ServiceWorkerProviderType::kForWindow, type_); @@ -782,6 +796,15 @@ DCHECK_NE(MSG_ROUTING_NONE, render_frame_id); frame_id_ = render_frame_id; + DCHECK(!cross_origin_embedder_policy_.has_value()); + cross_origin_embedder_policy_ = cross_origin_embedder_policy; + if (controller_ && controller_->fetch_handler_existence() == + ServiceWorkerVersion::FetchHandlerExistence::EXISTS) { + DCHECK(pending_controller_receiver_); + controller_->controller()->Clone(std::move(pending_controller_receiver_), + cross_origin_embedder_policy_.value()); + } + if (IsBackForwardCacheEnabled() && ServiceWorkerContext::IsServiceWorkerOnUIEnabled() && provider_type() == blink::mojom::ServiceWorkerProviderType::kForWindow) { @@ -813,10 +836,21 @@ broker_receiver_.Bind(std::move(broker_receiver)); } -void ServiceWorkerProviderHost::CompleteWebWorkerPreparation() { +void ServiceWorkerProviderHost::CompleteWebWorkerPreparation( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy) { using ServiceWorkerProviderType = blink::mojom::ServiceWorkerProviderType; DCHECK(provider_type() == ServiceWorkerProviderType::kForDedicatedWorker || provider_type() == ServiceWorkerProviderType::kForSharedWorker); + + DCHECK(!cross_origin_embedder_policy_.has_value()); + cross_origin_embedder_policy_ = cross_origin_embedder_policy; + if (controller_ && controller_->fetch_handler_existence() == + ServiceWorkerVersion::FetchHandlerExistence::EXISTS) { + DCHECK(pending_controller_receiver_); + controller_->controller()->Clone(std::move(pending_controller_receiver_), + cross_origin_embedder_policy_.value()); + } + TransitionToClientPhase(ClientPhase::kResponseCommitted); SetExecutionReady(); } @@ -1290,8 +1324,11 @@ void ServiceWorkerProviderHost::StartControllerComplete( mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> receiver, blink::ServiceWorkerStatusCode status) { - if (status == blink::ServiceWorkerStatusCode::kOk) - controller_->controller()->Clone(std::move(receiver)); + if (status == blink::ServiceWorkerStatusCode::kOk) { + DCHECK(is_response_committed()); + controller_->controller()->Clone(std::move(receiver), + cross_origin_embedder_policy_.value()); + } } void ServiceWorkerProviderHost::EnsureControllerServiceWorker(
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h index 265a8c6..db893e6a 100644 --- a/content/browser/service_worker/service_worker_provider_host.h +++ b/content/browser/service_worker/service_worker_provider_host.h
@@ -35,6 +35,7 @@ #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/network/public/mojom/fetch_api.mojom.h" +#include "services/network/public/mojom/network_context.mojom.h" #include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h" #include "third_party/blink/public/mojom/indexeddb/indexeddb.mojom-forward.h" #include "third_party/blink/public/mojom/locks/lock_manager.mojom-forward.h" @@ -344,9 +345,13 @@ scoped_refptr<ServiceWorkerRegistration> registration); // For service worker window clients. Called when the navigation is ready to - // commit in the browser process to complete the initialization for the - // pre-created instance. - void OnBeginNavigationCommit(int render_process_id, int render_frame_id); + // commit. Updates this host with information about the frame committed to. + // After this is called, is_response_committed() and is_execution_ready() + // return true. + void OnBeginNavigationCommit( + int render_process_id, + int render_frame_id, + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy); // For service worker execution contexts. Completes initialization of this // provider host. It is called once a renderer process has been found to host @@ -358,10 +363,13 @@ mojo::PendingReceiver<blink::mojom::BrowserInterfaceBroker> broker_receiver); + // For service worker clients that are shared workers or dedicated workers. // Called when the web worker main script resource has finished loading. + // Updates this host with information about the worker. // After this is called, is_response_committed() and is_execution_ready() // return true. - void CompleteWebWorkerPreparation(); + void CompleteWebWorkerPreparation( + network::mojom::CrossOriginEmbedderPolicy cross_origin_embedder_policy); // For service worker clients. The host keeps track of all the prospective // longest-matching registrations, in order to resolve .ready or respond to @@ -767,6 +775,19 @@ class PendingUpdateVersion; base::flat_set<PendingUpdateVersion> versions_to_update_; + // Mojo endpoint which will be be sent to the service worker just before + // the response is committed, where |cross_origin_embedder_policy_| is ready. + // We need to store this here because navigation code depends on having a + // mojo::Remote<ControllerServiceWorker> for making a SubresourceLoaderParams, + // which is created before the response header is ready. + mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> + pending_controller_receiver_; + + // For service worker clients. The embedder policy of the client. Set on + // response commit. + base::Optional<network::mojom::CrossOriginEmbedderPolicy> + cross_origin_embedder_policy_; + DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); };
diff --git a/content/browser/service_worker/service_worker_provider_host_unittest.cc b/content/browser/service_worker/service_worker_provider_host_unittest.cc index 1b909ef9..7809812 100644 --- a/content/browser/service_worker/service_worker_provider_host_unittest.cc +++ b/content/browser/service_worker/service_worker_provider_host_unittest.cc
@@ -193,8 +193,9 @@ // In production code this is called from NavigationRequest in the browser // process right before navigation commit. - host->OnBeginNavigationCommit(helper_->mock_render_process_id(), - 1 /* route_id */); + host->OnBeginNavigationCommit( + helper_->mock_render_process_id(), 1 /* route_id */, + network::mojom::CrossOriginEmbedderPolicy::kNone); } blink::mojom::ServiceWorkerErrorType Register( @@ -953,7 +954,8 @@ provider_type, std::move(host_receiver), std::move(client_remote)); host->UpdateUrls(url, url, url::Origin::Create(url)); EXPECT_FALSE(CanFindClientProviderHost(host.get())); - host->CompleteWebWorkerPreparation(); + host->CompleteWebWorkerPreparation( + network::mojom::CrossOriginEmbedderPolicy::kNone); EXPECT_TRUE(CanFindClientProviderHost(host.get())); } @@ -1038,7 +1040,8 @@ EXPECT_FALSE(host->is_execution_ready()); host->UpdateUrls(url, url, url::Origin::Create(url)); - host->CompleteWebWorkerPreparation(); + host->CompleteWebWorkerPreparation( + network::mojom::CrossOriginEmbedderPolicy::kNone); EXPECT_TRUE(host->is_response_committed()); EXPECT_TRUE(host->is_execution_ready());
diff --git a/content/browser/service_worker/service_worker_test_utils.cc b/content/browser/service_worker/service_worker_test_utils.cc index f7afb91..857d3c72 100644 --- a/content/browser/service_worker/service_worker_test_utils.cc +++ b/content/browser/service_worker/service_worker_test_utils.cc
@@ -264,7 +264,9 @@ // In production code this is called from NavigationRequest in the browser // process right before navigation commit. - host->OnBeginNavigationCommit(process_id, 1 /* route_id */); + host->OnBeginNavigationCommit( + process_id, 1 /* route_id */, + network::mojom::CrossOriginEmbedderPolicy::kNone); return host; }
diff --git a/content/browser/service_worker/service_worker_version_unittest.cc b/content/browser/service_worker/service_worker_version_unittest.cc index edd0fcf..c859ef9 100644 --- a/content/browser/service_worker/service_worker_version_unittest.cc +++ b/content/browser/service_worker/service_worker_version_unittest.cc
@@ -1206,11 +1206,16 @@ 1, helper_->mock_render_process_host()->foreground_service_worker_count()); + // This is necessary to make OnBeginNavigationCommit() work. + auto remote_controller = host->GetRemoteControllerServiceWorker(); + // Now begin the navigation commit with the same process id used by the // worker. This should cause the worker to stop being considered foreground // priority. - host->OnBeginNavigationCommit(version_->embedded_worker()->process_id(), - /* render_frame_id = */ 1); + host->OnBeginNavigationCommit( + version_->embedded_worker()->process_id(), + /* render_frame_id = */ 1, + network::mojom::CrossOriginEmbedderPolicy::kNone); // RenderProcessHost should be notified of foreground worker. base::RunLoop().RunUntilIdle();
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 8bb7713..15e5b38 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2288,6 +2288,19 @@ KeyboardEventProcessingResult WebContentsImpl::PreHandleKeyboardEvent( const NativeWebKeyboardEvent& event) { + auto* outermost_contents = GetOutermostWebContents(); + // TODO(wjmaclean): Generalize this to forward all key events to the outermost + // delegate's handler. + if (outermost_contents != this && IsFullscreenForCurrentTab() && + event.windows_key_code == ui::VKEY_ESCAPE) { + // When an inner WebContents has focus and is fullscreen, redirect <esc> + // key events to the outermost WebContents so it can be handled by that + // WebContents' delegate. + if (outermost_contents->PreHandleKeyboardEvent(event) == + KeyboardEventProcessingResult::HANDLED) { + return KeyboardEventProcessingResult::HANDLED; + } + } return delegate_ ? delegate_->PreHandleKeyboardEvent(this, event) : KeyboardEventProcessingResult::NOT_HANDLED; }
diff --git a/content/browser/webui/shared_resources_data_source.cc b/content/browser/webui/shared_resources_data_source.cc index 10ef15e..33423b6f 100644 --- a/content/browser/webui/shared_resources_data_source.cc +++ b/content/browser/webui/shared_resources_data_source.cc
@@ -99,6 +99,8 @@ "mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js"}, {IDR_URL_MOJO_HTML, "mojo/url/mojom/url.mojom.html"}, {IDR_URL_MOJO_JS, "mojo/url/mojom/url.mojom-lite.js"}, + {IDR_VULKAN_INFO_MOJO_JS, "gpu/ipc/common/vulkan_info.mojom-lite.js"}, + {IDR_VULKAN_TYPES_MOJO_JS, "gpu/ipc/common/vulkan_types.mojom-lite.js"}, }; }
diff --git a/content/browser/worker_host/worker_script_loader.cc b/content/browser/worker_host/worker_script_loader.cc index c7413ce3..9b2d14c 100644 --- a/content/browser/worker_host/worker_script_loader.cc +++ b/content/browser/worker_host/worker_script_loader.cc
@@ -316,10 +316,11 @@ DCHECK(!completed_); completed_ = true; - if (status.error_code == net::OK) { - if (service_worker_handle_) { - service_worker_handle_->OnBeginWorkerCommit(); - } + if (status.error_code == net::OK && service_worker_handle_) { + // TODO(https://crbug.com/999049): Parse the COEP header and pass it to + // the service worker handle. + service_worker_handle_->OnBeginWorkerCommit( + network::mojom::CrossOriginEmbedderPolicy::kNone); } client_->OnComplete(status);
diff --git a/content/content_resources.grd b/content/content_resources.grd index 2073609..b45b78783 100644 --- a/content/content_resources.grd +++ b/content/content_resources.grd
@@ -47,6 +47,8 @@ <include name="IDR_UNGUESSABLE_TOKEN_MOJO_JS" file="${root_gen_dir}/mojo/public/mojom/base/unguessable_token.mojom-lite.js" use_base_dir="false" type="BINDATA" compress="gzip" /> <include name="IDR_URL_MOJO_HTML" file="${root_gen_dir}/url/mojom/url.mojom.html" use_base_dir="false" type="BINDATA" compress="gzip" /> <include name="IDR_URL_MOJO_JS" file="${root_gen_dir}/url/mojom/url.mojom-lite.js" use_base_dir="false" type="BINDATA" compress="gzip" /> + <include name="IDR_VULKAN_INFO_MOJO_JS" file="${root_gen_dir}/gpu/ipc/common/vulkan_info.mojom-lite.js" use_base_dir="false" type="BINDATA" compress="gzip" /> + <include name="IDR_VULKAN_TYPES_MOJO_JS" file="${root_gen_dir}/gpu/ipc/common/vulkan_types.mojom-lite.js" use_base_dir="false" type="BINDATA" compress="gzip" /> </includes> </release> </grit>
diff --git a/content/public/browser/contacts_picker_properties_requested.h b/content/public/browser/contacts_picker_properties_requested.h index 9edf108..a4c1e1d 100644 --- a/content/public/browser/contacts_picker_properties_requested.h +++ b/content/public/browser/contacts_picker_properties_requested.h
@@ -18,7 +18,8 @@ PROPERTIES_EMAILS = 1 << 1, PROPERTIES_NAMES = 1 << 2, PROPERTIES_ADDRESSES = 1 << 3, - PROPERTIES_BOUNDARY = 1 << 4, + PROPERTIES_ICONS = 1 << 4, + PROPERTIES_BOUNDARY = 1 << 5, }; } // namespace content
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index 76736796..79f3e0d 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc
@@ -2205,6 +2205,10 @@ web_contents_impl->GetMainFrame()->GetRenderWidgetHost()); } +bool IsRenderWidgetHostFocused(const RenderWidgetHost* host) { + return static_cast<const RenderWidgetHostImpl*>(host)->is_focused(); +} + WebContents* GetFocusedWebContents(WebContents* web_contents) { WebContentsImpl* web_contents_impl = static_cast<WebContentsImpl*>(web_contents);
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h index cdb6bc7..b43743c 100644 --- a/content/public/test/browser_test_utils.h +++ b/content/public/test/browser_test_utils.h
@@ -982,6 +982,9 @@ // Returns the focused RenderWidgetHost. RenderWidgetHost* GetFocusedRenderWidgetHost(WebContents* web_contents); +// Returns whether or not the RenderWidgetHost thinks it is focused. +bool IsRenderWidgetHostFocused(const RenderWidgetHost*); + // Returns the focused WebContents. WebContents* GetFocusedWebContents(WebContents* web_contents);
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc index f840cfc..9ddf534 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc
@@ -527,16 +527,6 @@ //------------------------------------------------------------------------------ -scoped_refptr<base::SingleThreadTaskRunner> -RendererBlinkPlatformImpl::GetWebRtcWorkerThread() { - auto* rtc_dependency_factory = - blink::PeerConnectionDependencyFactory::GetInstance(); - rtc_dependency_factory->EnsureInitialized(); - return rtc_dependency_factory->GetWebRtcWorkerThread(); -} - -//------------------------------------------------------------------------------ - base::Optional<double> RendererBlinkPlatformImpl::GetWebRtcMaxCaptureFrameRate() { const std::string max_fps_str =
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h index f54e6c3..fc97f7a 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h
@@ -126,7 +126,6 @@ const media::AudioSourceParameters& params) override; viz::ContextProvider* SharedMainThreadContextProvider() override; bool RTCSmoothnessAlgorithmEnabled() override; - scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() override; base::Optional<double> GetWebRtcMaxCaptureFrameRate() override; scoped_refptr<media::AudioRendererSink> NewAudioRendererSink( blink::WebAudioDeviceSourceType source_type,
diff --git a/content/renderer/service_worker/service_worker_provider_context_unittest.cc b/content/renderer/service_worker/service_worker_provider_context_unittest.cc index 1a001580..e5ff370b 100644 --- a/content/renderer/service_worker/service_worker_provider_context_unittest.cc +++ b/content/renderer/service_worker/service_worker_provider_context_unittest.cc
@@ -197,8 +197,9 @@ if (fetch_event_callback_) std::move(fetch_event_callback_).Run(); } - void Clone(mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> - receiver) override { + void Clone( + mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> receiver, + network::mojom::CrossOriginEmbedderPolicy) override { receivers_.Add(this, std::move(receiver)); } @@ -450,7 +451,8 @@ FakeControllerServiceWorker fake_controller1; auto controller_info1 = blink::mojom::ControllerServiceWorkerInfo::New(); mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller1; - fake_controller1.Clone(remote_controller1.BindNewPipeAndPassReceiver()); + fake_controller1.Clone(remote_controller1.BindNewPipeAndPassReceiver(), + network::mojom::CrossOriginEmbedderPolicy::kNone); controller_info1->mode = blink::mojom::ControllerServiceWorkerMode::kControlled; controller_info1->object_info = std::move(object_info1); @@ -493,7 +495,8 @@ FakeControllerServiceWorker fake_controller2; auto controller_info2 = blink::mojom::ControllerServiceWorkerInfo::New(); mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller2; - fake_controller2.Clone(remote_controller2.BindNewPipeAndPassReceiver()); + fake_controller2.Clone(remote_controller2.BindNewPipeAndPassReceiver(), + network::mojom::CrossOriginEmbedderPolicy::kNone); controller_info2->mode = blink::mojom::ControllerServiceWorkerMode::kControlled; controller_info2->object_info = std::move(object_info2); @@ -582,7 +585,8 @@ FakeControllerServiceWorker fake_controller4; auto controller_info4 = blink::mojom::ControllerServiceWorkerInfo::New(); mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller4; - fake_controller4.Clone(remote_controller4.BindNewPipeAndPassReceiver()); + fake_controller4.Clone(remote_controller4.BindNewPipeAndPassReceiver(), + network::mojom::CrossOriginEmbedderPolicy::kNone); controller_info4->mode = blink::mojom::ControllerServiceWorkerMode::kControlled; controller_info4->object_info = std::move(object_info4); @@ -735,7 +739,8 @@ FakeControllerServiceWorker fake_controller; auto controller_info = blink::mojom::ControllerServiceWorkerInfo::New(); mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller; - fake_controller.Clone(remote_controller.BindNewPipeAndPassReceiver()); + fake_controller.Clone(remote_controller.BindNewPipeAndPassReceiver(), + network::mojom::CrossOriginEmbedderPolicy::kNone); controller_info->mode = blink::mojom::ControllerServiceWorkerMode::kControlled; controller_info->object_info = std::move(object_info); @@ -782,7 +787,8 @@ FakeControllerServiceWorker fake_controller; auto controller_info = blink::mojom::ControllerServiceWorkerInfo::New(); mojo::Remote<blink::mojom::ControllerServiceWorker> remote_controller; - fake_controller.Clone(remote_controller.BindNewPipeAndPassReceiver()); + fake_controller.Clone(remote_controller.BindNewPipeAndPassReceiver(), + network::mojom::CrossOriginEmbedderPolicy::kNone); controller_info->mode = blink::mojom::ControllerServiceWorkerMode::kControlled; controller_info->object_info = std::move(object_info);
diff --git a/content/renderer/service_worker/service_worker_subresource_loader_unittest.cc b/content/renderer/service_worker/service_worker_subresource_loader_unittest.cc index 44d68e7..c02ad26 100644 --- a/content/renderer/service_worker/service_worker_subresource_loader_unittest.cc +++ b/content/renderer/service_worker/service_worker_subresource_loader_unittest.cc
@@ -325,8 +325,9 @@ std::move(fetch_event_callback_).Run(); } - void Clone(mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> - receiver) override { + void Clone( + mojo::PendingReceiver<blink::mojom::ControllerServiceWorker> receiver, + network::mojom::CrossOriginEmbedderPolicy) override { receivers_.Add(this, std::move(receiver)); } @@ -421,7 +422,8 @@ get_controller_service_worker_count_++; if (!fake_controller_) return; - fake_controller_->Clone(std::move(receiver)); + fake_controller_->Clone(std::move(receiver), + network::mojom::CrossOriginEmbedderPolicy::kNone); } void CloneContainerHost( mojo::PendingReceiver<blink::mojom::ServiceWorkerContainerHost> receiver)
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 2bb1463..f957828 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn
@@ -1087,6 +1087,7 @@ "//components/payments/mojom", "//components/services/quarantine:test_support", "//components/services/storage", + "//components/services/storage/public/cpp", "//components/ukm:test_support", "//components/url_formatter:url_formatter", "//components/viz/test:test_support", @@ -1949,6 +1950,7 @@ "//components/rappor:test_support", "//components/services/storage", "//components/services/storage:test_support", + "//components/services/storage/public/cpp", "//components/system_media_controls:test_support", "//components/ukm:test_support", "//components/viz/client",
diff --git a/content/test/data/service_worker/install_event_caches_no_cors_script.js b/content/test/data/service_worker/install_event_caches_no_cors_script.js new file mode 100644 index 0000000..306547a --- /dev/null +++ b/content/test/data/service_worker/install_event_caches_no_cors_script.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. + +self.addEventListener('install', evt => { + evt.waitUntil(async function() { + const cache_name = 'cache_name'; + + const url = new URLSearchParams(self.location.search).get('script_url'); + + const cache = await caches.open(cache_name); + const response = await fetch(url, { mode: 'no-cors' }); + await cache.put(url, response); + }()); +});
diff --git a/extensions/DEPS b/extensions/DEPS index 4df158a..0341f1bb 100644 --- a/extensions/DEPS +++ b/extensions/DEPS
@@ -43,4 +43,8 @@ "mime_handler_view_browsertest.cc": [ "+components/printing/common", ], + "mime_handler_view_interactive_uitest.cc": [ + "+chrome/browser/ui/exclusive_access/fullscreen_controller_test.h", + "+chrome/test/base/interactive_test_utils.h", + ], }
diff --git a/extensions/browser/api/declarative_net_request/constants.h b/extensions/browser/api/declarative_net_request/constants.h index b71c3874..636dbaf 100644 --- a/extensions/browser/api/declarative_net_request/constants.h +++ b/extensions/browser/api/declarative_net_request/constants.h
@@ -76,12 +76,6 @@ kMaxValue = kErrorCreateMatcher_VersionMismatch, }; -// Whether dynamic rules are to be added or removed. -enum class DynamicRuleUpdateAction { - kAdd, - kRemove, -}; - // Schemes which can be used as part of url transforms. extern const char* const kAllowedTransformSchemes[4];
diff --git a/extensions/browser/api/declarative_net_request/declarative_net_request_api.cc b/extensions/browser/api/declarative_net_request/declarative_net_request_api.cc index bef8430..1f2d6a9 100644 --- a/extensions/browser/api/declarative_net_request/declarative_net_request_api.cc +++ b/extensions/browser/api/declarative_net_request/declarative_net_request_api.cc
@@ -176,9 +176,14 @@ ~DeclarativeNetRequestUpdateDynamicRulesFunction() = default; ExtensionFunction::ResponseAction -DeclarativeNetRequestUpdateDynamicRulesFunction::UpdateDynamicRules( - std::vector<api::declarative_net_request::Rule> rules, - declarative_net_request::DynamicRuleUpdateAction action) { +DeclarativeNetRequestUpdateDynamicRulesFunction::Run() { + using Params = dnr_api::UpdateDynamicRules::Params; + + base::string16 error; + std::unique_ptr<Params> params(Params::Create(*args_, &error)); + EXTENSION_FUNCTION_VALIDATE(params); + EXTENSION_FUNCTION_VALIDATE(error.empty()); + auto* rules_monitor_service = declarative_net_request::RulesMonitorService::Get(browser_context()); DCHECK(rules_monitor_service); @@ -188,8 +193,9 @@ &DeclarativeNetRequestUpdateDynamicRulesFunction::OnDynamicRulesUpdated, this); - rules_monitor_service->UpdateDynamicRules(*extension(), std::move(rules), - action, std::move(callback)); + rules_monitor_service->UpdateDynamicRules( + *extension(), std::move(params->rule_ids_to_remove), + std::move(params->rules_to_add), std::move(callback)); return RespondLater(); } @@ -209,52 +215,6 @@ Respond(NoArguments()); } -DeclarativeNetRequestAddDynamicRulesFunction:: - DeclarativeNetRequestAddDynamicRulesFunction() = default; -DeclarativeNetRequestAddDynamicRulesFunction:: - ~DeclarativeNetRequestAddDynamicRulesFunction() = default; - -ExtensionFunction::ResponseAction -DeclarativeNetRequestAddDynamicRulesFunction::Run() { - // Note: If need be, we should throttle calls to these extension functions. - using Params = dnr_api::AddDynamicRules::Params; - - base::string16 error; - std::unique_ptr<Params> params(Params::Create(*args_, &error)); - EXTENSION_FUNCTION_VALIDATE(params); - EXTENSION_FUNCTION_VALIDATE(error.empty()); - - return UpdateDynamicRules( - std::move(params->rules), - declarative_net_request::DynamicRuleUpdateAction::kAdd); -} - -DeclarativeNetRequestRemoveDynamicRulesFunction:: - DeclarativeNetRequestRemoveDynamicRulesFunction() = default; -DeclarativeNetRequestRemoveDynamicRulesFunction:: - ~DeclarativeNetRequestRemoveDynamicRulesFunction() = default; - -ExtensionFunction::ResponseAction -DeclarativeNetRequestRemoveDynamicRulesFunction::Run() { - using Params = dnr_api::RemoveDynamicRules::Params; - - base::string16 error; - std::unique_ptr<Params> params(Params::Create(*args_, &error)); - EXTENSION_FUNCTION_VALIDATE(params); - EXTENSION_FUNCTION_VALIDATE(error.empty()); - - std::vector<dnr_api::Rule> rules; - for (int id : params->rule_ids) { - dnr_api::Rule rule; - rule.id = id; - rules.push_back(std::move(rule)); - } - - return UpdateDynamicRules( - std::move(rules), - declarative_net_request::DynamicRuleUpdateAction::kRemove); -} - DeclarativeNetRequestGetDynamicRulesFunction:: DeclarativeNetRequestGetDynamicRulesFunction() = default; DeclarativeNetRequestGetDynamicRulesFunction::
diff --git a/extensions/browser/api/declarative_net_request/declarative_net_request_api.h b/extensions/browser/api/declarative_net_request/declarative_net_request_api.h index 5f5e3dc1..0940c99 100644 --- a/extensions/browser/api/declarative_net_request/declarative_net_request_api.h +++ b/extensions/browser/api/declarative_net_request/declarative_net_request_api.h
@@ -13,14 +13,7 @@ namespace extensions { -namespace api { namespace declarative_net_request { -struct Rule; -} // namespace declarative_net_request -} // namespace api - -namespace declarative_net_request { -enum class DynamicRuleUpdateAction; struct ReadJSONRulesResult; } // namespace declarative_net_request @@ -106,56 +99,24 @@ class DeclarativeNetRequestUpdateDynamicRulesFunction : public ExtensionFunction { - protected: + public: DeclarativeNetRequestUpdateDynamicRulesFunction(); + DECLARE_EXTENSION_FUNCTION("declarativeNetRequest.updateDynamicRules", + DECLARATIVENETREQUEST_UPDATEDYNAMICRULES) + + protected: ~DeclarativeNetRequestUpdateDynamicRulesFunction() override; - ExtensionFunction::ResponseAction UpdateDynamicRules( - std::vector<api::declarative_net_request::Rule> rules, - declarative_net_request::DynamicRuleUpdateAction action); - - private: // ExtensionFunction override: bool PreRunValidation(std::string* error) override; + ExtensionFunction::ResponseAction Run() override; + private: void OnDynamicRulesUpdated(base::Optional<std::string> error); DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestUpdateDynamicRulesFunction); }; -class DeclarativeNetRequestAddDynamicRulesFunction - : public DeclarativeNetRequestUpdateDynamicRulesFunction { - public: - DeclarativeNetRequestAddDynamicRulesFunction(); - DECLARE_EXTENSION_FUNCTION("declarativeNetRequest.addDynamicRules", - DECLARATIVENETREQUEST_ADDDYNAMICRULES) - - protected: - ~DeclarativeNetRequestAddDynamicRulesFunction() override; - - ExtensionFunction::ResponseAction Run() override; - - private: - DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestAddDynamicRulesFunction); -}; - -class DeclarativeNetRequestRemoveDynamicRulesFunction - : public DeclarativeNetRequestUpdateDynamicRulesFunction { - public: - DeclarativeNetRequestRemoveDynamicRulesFunction(); - DECLARE_EXTENSION_FUNCTION("declarativeNetRequest.removeDynamicRules", - DECLARATIVENETREQUEST_REMOVEDYNAMICRULES) - - protected: - ~DeclarativeNetRequestRemoveDynamicRulesFunction() override; - - // ExtensionFunction override: - ExtensionFunction::ResponseAction Run() override; - - private: - DISALLOW_COPY_AND_ASSIGN(DeclarativeNetRequestRemoveDynamicRulesFunction); -}; - class DeclarativeNetRequestGetDynamicRulesFunction : public ExtensionFunction { public: DeclarativeNetRequestGetDynamicRulesFunction();
diff --git a/extensions/browser/api/declarative_net_request/file_sequence_helper.cc b/extensions/browser/api/declarative_net_request/file_sequence_helper.cc index 30ea47dc..b4e340f 100644 --- a/extensions/browser/api/declarative_net_request/file_sequence_helper.cc +++ b/extensions/browser/api/declarative_net_request/file_sequence_helper.cc
@@ -4,6 +4,7 @@ #include "extensions/browser/api/declarative_net_request/file_sequence_helper.h" +#include <set> #include <utility> #include "base/bind.h" @@ -125,30 +126,6 @@ DISALLOW_COPY_AND_ASSIGN(ReindexHelper); }; -std::vector<dnr_api::Rule> AddRulesToVector( - std::vector<dnr_api::Rule> current_rules, - std::vector<dnr_api::Rule> new_rules) { - std::vector<dnr_api::Rule> result = std::move(current_rules); - result.insert(result.end(), std::make_move_iterator(new_rules.begin()), - std::make_move_iterator(new_rules.end())); - return result; -} - -std::vector<dnr_api::Rule> RemoveRulesFromVector( - std::vector<dnr_api::Rule> current_rules, - std::vector<dnr_api::Rule> to_remove_rules) { - std::set<int> ids_to_remove; - for (const auto& rule : to_remove_rules) - ids_to_remove.insert(rule.id); - - std::vector<dnr_api::Rule> result = std::move(current_rules); - base::EraseIf(result, [&ids_to_remove](const dnr_api::Rule& rule) { - return base::Contains(ids_to_remove, rule.id); - }); - - return result; -} - UpdateDynamicRulesStatus GetStatusForLoadRulesetError( RulesetMatcher::LoadRulesetResult result) { using Result = RulesetMatcher::LoadRulesetResult; @@ -174,8 +151,8 @@ // Helper to create the new list of dynamic rules. Returns false on failure and // populates |error| and |status|. bool GetNewDynamicRules(const RulesetSource& source, - std::vector<dnr_api::Rule> rules, - DynamicRuleUpdateAction action, + std::vector<int> rule_ids_to_remove, + std::vector<dnr_api::Rule> rules_to_add, std::vector<dnr_api::Rule>* new_rules, std::string* error, UpdateDynamicRulesStatus* status) { @@ -203,15 +180,18 @@ return false; } - switch (action) { - case DynamicRuleUpdateAction::kAdd: - *new_rules = AddRulesToVector(std::move(result.rules), std::move(rules)); - break; - case DynamicRuleUpdateAction::kRemove: - *new_rules = - RemoveRulesFromVector(std::move(result.rules), std::move(rules)); - break; - } + *new_rules = std::move(result.rules); + + // Remove old rules + std::set<int> ids_to_remove(rule_ids_to_remove.begin(), rule_ids_to_remove.end()); + base::EraseIf(*new_rules, [&ids_to_remove](const dnr_api::Rule& rule) { + return base::Contains(ids_to_remove, rule.id); + }); + + // Add new rules + new_rules->insert(new_rules->end(), + std::make_move_iterator(rules_to_add.begin()), + std::make_move_iterator(rules_to_add.end())); if (new_rules->size() > source.rule_count_limit()) { *status = UpdateDynamicRulesStatus::kErrorRuleCountExceeded; @@ -226,8 +206,8 @@ // failure and populates |error| and |status|. bool UpdateAndIndexDynamicRules( const RulesetSource& source, - std::vector<api::declarative_net_request::Rule> rules, - DynamicRuleUpdateAction action, + std::vector<int> rule_ids_to_remove, + std::vector<api::declarative_net_request::Rule> rules_to_add, int* ruleset_checksum, std::string* error, UpdateDynamicRulesStatus* status) { @@ -236,8 +216,8 @@ DCHECK(status); std::vector<dnr_api::Rule> new_rules; - if (!GetNewDynamicRules(source, std::move(rules), action, &new_rules, error, - status)) { + if (!GetNewDynamicRules(source, std::move(rule_ids_to_remove), + std::move(rules_to_add), &new_rules, error, status)) { return false; // |error| and |status| already populated. } @@ -387,8 +367,8 @@ void FileSequenceHelper::UpdateDynamicRules( LoadRequestData load_data, - std::vector<api::declarative_net_request::Rule> rules, - DynamicRuleUpdateAction action, + std::vector<int> rule_ids_to_remove, + std::vector<api::declarative_net_request::Rule> rules_to_add, UpdateDynamicRulesUICallback ui_callback) const { DCHECK(GetExtensionFileTaskRunner()->RunsTasksInCurrentSequence()); DCHECK_EQ(1u, load_data.rulesets.size()); @@ -412,9 +392,9 @@ int new_ruleset_checksum = -1; std::string error; UpdateDynamicRulesStatus status = UpdateDynamicRulesStatus::kSuccess; - if (!UpdateAndIndexDynamicRules(dynamic_ruleset.source(), std::move(rules), - action, &new_ruleset_checksum, &error, - &status)) { + if (!UpdateAndIndexDynamicRules( + dynamic_ruleset.source(), std::move(rule_ids_to_remove), + std::move(rules_to_add), &new_ruleset_checksum, &error, &status)) { DCHECK(!error.empty()); log_status_and_dispatch_callback(std::move(error), status); return;
diff --git a/extensions/browser/api/declarative_net_request/file_sequence_helper.h b/extensions/browser/api/declarative_net_request/file_sequence_helper.h index 0c39b29..63bf250 100644 --- a/extensions/browser/api/declarative_net_request/file_sequence_helper.h +++ b/extensions/browser/api/declarative_net_request/file_sequence_helper.h
@@ -123,10 +123,11 @@ // string. using UpdateDynamicRulesUICallback = base::OnceCallback<void(LoadRequestData, base::Optional<std::string>)>; - void UpdateDynamicRules(LoadRequestData load_data, - std::vector<api::declarative_net_request::Rule> rules, - DynamicRuleUpdateAction action, - UpdateDynamicRulesUICallback ui_callback) const; + void UpdateDynamicRules( + LoadRequestData load_data, + std::vector<int> rule_ids_to_remove, + std::vector<api::declarative_net_request::Rule> rules_to_add, + UpdateDynamicRulesUICallback ui_callback) const; private: // Callback invoked when the JSON rulesets are reindexed.
diff --git a/extensions/browser/api/declarative_net_request/file_sequence_helper_unittest.cc b/extensions/browser/api/declarative_net_request/file_sequence_helper_unittest.cc index bf4cfdb5..648bc67 100644 --- a/extensions/browser/api/declarative_net_request/file_sequence_helper_unittest.cc +++ b/extensions/browser/api/declarative_net_request/file_sequence_helper_unittest.cc
@@ -102,8 +102,8 @@ auto add_rules_task = base::BindOnce(&FileSequenceHelper::UpdateDynamicRules, base::Unretained(helper_.get()), std::move(data), - std::move(rules_to_add), DynamicRuleUpdateAction::kAdd, - std::move(add_rules_callback)); + /* rule_ids_to_remove */ std::vector<int>(), + std::move(rules_to_add), std::move(add_rules_callback)); base::HistogramTester tester; GetExtensionFileTaskRunner()->PostTask(FROM_HERE,
diff --git a/extensions/browser/api/declarative_net_request/rules_monitor_service.cc b/extensions/browser/api/declarative_net_request/rules_monitor_service.cc index 604d6be..7edbd79 100644 --- a/extensions/browser/api/declarative_net_request/rules_monitor_service.cc +++ b/extensions/browser/api/declarative_net_request/rules_monitor_service.cc
@@ -74,16 +74,17 @@ void UpdateDynamicRules( LoadRequestData load_data, - std::vector<dnr_api::Rule> rules, - DynamicRuleUpdateAction action, + std::vector<int> rule_ids_to_remove, + std::vector<dnr_api::Rule> rules_to_add, FileSequenceHelper::UpdateDynamicRulesUICallback ui_callback) const { // base::Unretained is safe here because we trigger the destruction of // |file_sequence_state_| on |file_task_runner_| from our destructor. Hence // it is guaranteed to be alive when |update_dynamic_rules_task| is run. - base::OnceClosure update_dynamic_rules_task = base::BindOnce( - &FileSequenceHelper::UpdateDynamicRules, - base::Unretained(file_sequence_helper_.get()), std::move(load_data), - std::move(rules), action, std::move(ui_callback)); + base::OnceClosure update_dynamic_rules_task = + base::BindOnce(&FileSequenceHelper::UpdateDynamicRules, + base::Unretained(file_sequence_helper_.get()), + std::move(load_data), std::move(rule_ids_to_remove), + std::move(rules_to_add), std::move(ui_callback)); file_task_runner_->PostTask(FROM_HERE, std::move(update_dynamic_rules_task)); } @@ -123,8 +124,8 @@ void RulesMonitorService::UpdateDynamicRules( const Extension& extension, - std::vector<api::declarative_net_request::Rule> rules, - DynamicRuleUpdateAction action, + std::vector<int> rule_ids_to_remove, + std::vector<api::declarative_net_request::Rule> rules_to_add, DynamicRuleUpdateUICallback callback) { DCHECK(HasRegisteredRuleset(extension.id())); @@ -137,9 +138,9 @@ auto update_rules_callback = base::BindOnce(&RulesMonitorService::OnDynamicRulesUpdated, weak_factory_.GetWeakPtr(), std::move(callback)); - file_sequence_bridge_->UpdateDynamicRules(std::move(data), std::move(rules), - action, - std::move(update_rules_callback)); + file_sequence_bridge_->UpdateDynamicRules( + std::move(data), std::move(rule_ids_to_remove), std::move(rules_to_add), + std::move(update_rules_callback)); } RulesMonitorService::RulesMonitorService(
diff --git a/extensions/browser/api/declarative_net_request/rules_monitor_service.h b/extensions/browser/api/declarative_net_request/rules_monitor_service.h index 2d3bc2d..739daa6 100644 --- a/extensions/browser/api/declarative_net_request/rules_monitor_service.h +++ b/extensions/browser/api/declarative_net_request/rules_monitor_service.h
@@ -69,10 +69,11 @@ // |callback| with an optional error. using DynamicRuleUpdateUICallback = base::OnceCallback<void(base::Optional<std::string> error)>; - void UpdateDynamicRules(const Extension& extension, - std::vector<api::declarative_net_request::Rule> rules, - DynamicRuleUpdateAction action, - DynamicRuleUpdateUICallback callback); + void UpdateDynamicRules( + const Extension& extension, + std::vector<int> rule_ids_to_remove, + std::vector<api::declarative_net_request::Rule> rules_to_add, + DynamicRuleUpdateUICallback callback); RulesetManager* ruleset_manager() { return &ruleset_manager_; }
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 5906339..29ec4c4 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h
@@ -1378,8 +1378,8 @@ PASSWORDSPRIVATE_CHANGESAVEDPASSWORD = 1315, AUTOTESTPRIVATE_SETWHITELISTEDPREF = 1316, SAFEBROWSINGPRIVATE_GETREFERRERCHAIN = 1317, - DECLARATIVENETREQUEST_ADDDYNAMICRULES = 1318, - DECLARATIVENETREQUEST_REMOVEDYNAMICRULES = 1319, + DELETED_DECLARATIVENETREQUEST_ADDDYNAMICRULES = 1318, + DELETED_DECLARATIVENETREQUEST_REMOVEDYNAMICRULES = 1319, DECLARATIVENETREQUEST_GETDYNAMICRULES = 1320, AUTOTESTPRIVATE_GETARCSTATE = 1321, AUTOTESTPRIVATE_ISTABLETMODEENABLED = 1322, @@ -1467,6 +1467,7 @@ TERMINALPRIVATE_GETCROSHSETTINGS = 1404, AUTOTESTPRIVATE_ENABLEASSISTANTANDWAITFORREADY = 1405, INPUTMETHODPRIVATE_FINISHCOMPOSINGTEXT = 1406, + DECLARATIVENETREQUEST_UPDATEDYNAMICRULES = 1407, // Last entry: Add new entries above, then run: // python tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc index 34e4df9..98d1f30 100644 --- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc +++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
@@ -221,9 +221,6 @@ params, owner_web_contents()->GetController().GetSessionStorageNamespaceMap()) .release()); - - registry_.AddInterface(base::BindRepeating( - &MimeHandlerViewGuest::FuseBeforeUnloadControl, base::Unretained(this))); } void MimeHandlerViewGuest::DidAttachToEmbedder() { @@ -458,13 +455,6 @@ } } -void MimeHandlerViewGuest::OnInterfaceRequestFromFrame( - content::RenderFrameHost* render_frame_host, - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) { - registry_.TryBindInterface(interface_name, interface_pipe); -} - void MimeHandlerViewGuest::ReadyToCommitNavigation( content::NavigationHandle* navigation_handle) { navigation_handle->RegisterSubresourceOverride(
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h index cc32574..2f4d6b51 100644 --- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h +++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -15,7 +15,6 @@ #include "extensions/common/api/mime_handler.mojom.h" #include "mojo/public/cpp/bindings/pending_receiver.h" #include "mojo/public/cpp/bindings/pending_remote.h" -#include "services/service_manager/public/cpp/binder_registry.h" namespace content { class WebContents; @@ -94,6 +93,9 @@ void SetPluginCanSave(bool can_save) { plugin_can_save_ = can_save; } + void FuseBeforeUnloadControl( + mojo::PendingReceiver<mime_handler::BeforeUnloadControl> receiver); + // Asks the plugin to do save. bool PluginDoSave(); @@ -174,16 +176,9 @@ // content::WebContentsObserver implementation. void DocumentOnLoadCompletedInMainFrame() final; - void OnInterfaceRequestFromFrame( - content::RenderFrameHost* render_frame_host, - const std::string& interface_name, - mojo::ScopedMessagePipeHandle* interface_pipe) final; void ReadyToCommitNavigation( content::NavigationHandle* navigation_handle) final; - void FuseBeforeUnloadControl( - mojo::PendingReceiver<mime_handler::BeforeUnloadControl> receiver); - std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_; std::unique_ptr<StreamContainer> stream_; @@ -191,8 +186,6 @@ int embedder_frame_routing_id_; int embedder_widget_routing_id_; - service_manager::BinderRegistry registry_; - bool is_guest_fullscreen_ = false; bool is_embedder_fullscreen_ = false; bool plugin_can_save_ = false;
diff --git a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_interactive_uitest.cc b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_interactive_uitest.cc index e5cc36c0..8b3692c 100644 --- a/extensions/browser/guest_view/mime_handler_view/mime_handler_view_interactive_uitest.cc +++ b/extensions/browser/guest_view/mime_handler_view/mime_handler_view_interactive_uitest.cc
@@ -11,11 +11,15 @@ #include "base/path_service.h" #include "base/run_loop.h" #include "base/test/scoped_feature_list.h" +#include "base/test/test_timeouts.h" #include "build/build_config.h" #include "chrome/browser/extensions/extension_apitest.h" +#include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h" +#include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/ui_test_utils.h" #include "components/guest_view/browser/test_guest_view_manager.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/render_widget_host_view.h" #include "content/public/common/content_features.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" @@ -26,6 +30,7 @@ #include "extensions/browser/guest_view/mime_handler_view/test_mime_handler_view_guest.h" #include "extensions/test/result_catcher.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#include "third_party/blink/public/platform/web_pointer_properties.h" using guest_view::GuestViewManager; using guest_view::GuestViewManagerDelegate; @@ -143,4 +148,75 @@ RunTest("testFullscreen.csv"); } +namespace { + +void WaitForFullscreenAnimation() { +#if defined(OS_MACOSX) + const int delay_in_ms = 1500; +#else + const int delay_in_ms = 100; +#endif + // Wait for Mac OS fullscreen animation. + base::RunLoop run_loop; + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), + base::TimeDelta::FromMilliseconds(delay_in_ms)); + run_loop.Run(); +} + +} // namespace + +IN_PROC_BROWSER_TEST_P(MimeHandlerViewTest, EscapeExitsFullscreen) { + // Only run this test in cross-process mode. + if (!GetParam()) + return; + + // Use the testing subclass of MimeHandlerViewGuest. + GetGuestViewManager()->RegisterTestGuestViewType<MimeHandlerViewGuest>( + base::BindRepeating(&TestMimeHandlerViewGuest::Create)); + + const Extension* extension = LoadTestExtension(); + ASSERT_TRUE(extension); + + ResultCatcher catcher; + + // Set observer to watch for fullscreen. + FullscreenNotificationObserver fullscreen_waiter(browser()); + + ui_test_utils::NavigateToURL( + browser(), embedded_test_server()->GetURL("/testFullscreenEscape.csv")); + + // Make sure we have a guestviewmanager. + auto* embedder_contents = browser()->tab_strip_model()->GetWebContentsAt(0); + auto* guest_contents = GetGuestViewManager()->WaitForSingleGuestCreated(); + auto* guest_rwh = + guest_contents->GetRenderWidgetHostView()->GetRenderWidgetHost(); + + // Wait for fullscreen mode. + fullscreen_waiter.Wait(); + WaitForFullscreenAnimation(); + + EXPECT_NE(guest_contents, content::GetFocusedWebContents(embedder_contents)); + EXPECT_FALSE(IsRenderWidgetHostFocused(guest_rwh)); + // Send a touch to focus the guest. We can't directly test that the correct + // RenderWidgetHost got focus, but the wait seems to work. + SimulateMouseClick(guest_contents, 0, blink::WebMouseEvent::Button::kLeft); + while (!IsRenderWidgetHostFocused(guest_rwh)) { + base::RunLoop run_loop; + base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); + run_loop.Run(); + } + EXPECT_EQ(guest_contents, content::GetFocusedWebContents(embedder_contents)); + + // Send <esc> to exit fullscreen. + ASSERT_TRUE(ui_test_utils::SendKeyPressSync(browser(), ui::VKEY_ESCAPE, false, + false, false, false)); + WaitForFullscreenAnimation(); + + // Now wait for the test to succeed, or timeout. + if (!catcher.GetNextResult()) + FAIL() << catcher.message(); +} + } // namespace extensions
diff --git a/extensions/common/api/declarative_net_request.idl b/extensions/common/api/declarative_net_request.idl index c4c928c..250257a6 100644 --- a/extensions/common/api/declarative_net_request.idl +++ b/extensions/common/api/declarative_net_request.idl
@@ -219,7 +219,7 @@ // The rule is specified in a JSON file within the extension's package. manifest, // The rule is a dynamic rule added by the extension using - // $(ref:declarativeNetRequest.addDynamicRules). + // $(ref:declarativeNetRequest.updateDynamicRules). dynamic }; @@ -268,28 +268,27 @@ interface Functions { - // Adds <code>rules</code> to the current set of dynamic rules for the - // extension. These rules are persisted across browser sessions. + // Modify the current set of dynamic rules for the extension. The rules + // with IDs listed in <code>rule_ids_to_remove</code> are first removed, + // and then the rules given in <code>rules_to_add</code> are added. This + // update happens as a single atomic operation: either all specified rules + // are added and removed, or an error is returned. + // These rules are persisted across browser sessions. + // Any ids in <code>rule_ids_to_remove</code> that are not present will be + // ignored. + // Note that static rules specified as part of the extension package can + // not be removed using this function. // Note: <a href="#property-MAX_NUMBER_OF_DYNAMIC_RULES"> // MAX_NUMBER_OF_DYNAMIC_RULES</a> is the maximum number of dynamic rules an // extension can add. - // |rules|: The rules to add. - // |callback|: Called once the given <code>rules</code> are added. In case - // of an error, $(ref:runtime.lastError) will be set to denote the error - // message and no rules will be added. This can happen for multiple reasons, - // such as invalid rule format, duplicate rule ID, rule count limit - // exceeded, internal errors, and others. - static void addDynamicRules(Rule[] rules, optional EmptyCallback callback); - - // Removes rules corresponding to <code>rule_ids</code> from the current set - // of dynamic rules for the extension. Any <code>rule_ids</code> not already - // present are ignored. Note that static rules specified as part of the - // extension package can not be removed using this function. - // |rule_ids|: The IDs of dynamic rules to remove. - // |callback|: Called once the rules are removed. In case of an error, - // $(ref:runtime.lastError) will be set to denote the error message and no - // rules will be removed. This may happen due to internal errors. - static void removeDynamicRules(long[] rule_ids, + // |rule_ids_to_remove|: The IDs of rules to remove. + // |rules_to_add|: The rules to add. + // |callback|: Called once the update is complete or has failed. In case of + // an error, $(ref:runtime.lastError) will be set to denote the error + // message and no change will be made to the rule set. This can happen for + // multiple reasons, such as invalid rule format, duplicate rule ID, rule + // count limit exceeded, internal errors, and others. + static void updateDynamicRules(long[] rule_ids_to_remove, Rule[] rules_to_add, optional EmptyCallback callback); // Returns the current set of dynamic rules for the extension.
diff --git a/extensions/renderer/resources/mime_handler_private_custom_bindings.js b/extensions/renderer/resources/mime_handler_private_custom_bindings.js index 9653886..3b396570 100644 --- a/extensions/renderer/resources/mime_handler_private_custom_bindings.js +++ b/extensions/renderer/resources/mime_handler_private_custom_bindings.js
@@ -24,7 +24,7 @@ new extensions.mimeHandler.BeforeUnloadControlPtr; Mojo.bindInterface( extensions.mimeHandler.BeforeUnloadControl.name, - mojo.makeRequest(beforeUnloadControlPtr).handle); + mojo.makeRequest(beforeUnloadControlPtr).handle, "context", true); // Stores a promise to the GetStreamInfo() result to avoid making additional // calls in response to getStreamInfo() calls.
diff --git a/gpu/config/BUILD.gn b/gpu/config/BUILD.gn index d595e1b..16eae23 100644 --- a/gpu/config/BUILD.gn +++ b/gpu/config/BUILD.gn
@@ -6,6 +6,7 @@ import("//build/config/chromecast_build.gni") import("//build/config/jumbo.gni") import("//build/config/ui.gni") +import("//gpu/vulkan/features.gni") group("config") { if (is_component_build) { @@ -89,6 +90,23 @@ } } +if (enable_vulkan) { + source_set("vulkan_info") { + sources = [ + "vulkan_info.cc", + "vulkan_info.h", + ] + + configs += [ "//gpu:gpu_implementation" ] + + deps = [ + "//gpu/ipc/common:vulkan_interface", + ] + + all_dependent_configs = [ "//third_party/vulkan:vulkan_config" ] + } +} + jumbo_source_set("config_sources") { # External code should depend on this via //gpu/config above rather than # depending on this directly or the component build will break. @@ -152,6 +170,10 @@ "//components/crash/core/common:crash_key", ] + if (enable_vulkan) { + public_deps += [ ":vulkan_info" ] + } + deps = [ ":process_json", "//base",
diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc index f5aab647..da699bb 100644 --- a/gpu/config/gpu_info.cc +++ b/gpu/config/gpu_info.cc
@@ -266,6 +266,10 @@ bool oop_rasterization_supported; bool subpixel_font_rendering; + +#if BUILDFLAG(ENABLE_VULKAN) + base::Optional<VulkanInfo> vulkan_info; +#endif }; // If this assert fails then most likely something below needs to be updated. @@ -336,6 +340,12 @@ #endif enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported); enumerator->AddBool("subpixelFontRendering", subpixel_font_rendering); +#if BUILDFLAG(ENABLE_VULKAN) + if (vulkan_info) { + auto blob = vulkan_info->Serialize(); + enumerator->AddBinary("vulkanInfo", base::span<const uint8_t>(blob)); + } +#endif enumerator->EndAuxAttributes(); }
diff --git a/gpu/config/gpu_info.h b/gpu/config/gpu_info.h index ed44414..cce6a597 100644 --- a/gpu/config/gpu_info.h +++ b/gpu/config/gpu_info.h
@@ -13,17 +13,24 @@ #include <string> #include <vector> +#include "base/containers/span.h" +#include "base/optional.h" #include "base/time/time.h" #include "base/version.h" #include "build/build_config.h" #include "gpu/config/dx_diag_node.h" #include "gpu/gpu_export.h" +#include "gpu/vulkan/buildflags.h" #include "ui/gfx/geometry/size.h" #if defined(USE_X11) typedef unsigned long VisualID; #endif +#if BUILDFLAG(ENABLE_VULKAN) +#include "gpu/config/vulkan_info.h" +#endif + namespace gpu { // These values are persisted to logs. Entries should not be renumbered and @@ -357,6 +364,10 @@ bool subpixel_font_rendering; +#if BUILDFLAG(ENABLE_VULKAN) + base::Optional<VulkanInfo> vulkan_info; +#endif + // Note: when adding new members, please remember to update EnumerateFields // in gpu_info.cc. @@ -376,6 +387,8 @@ virtual void AddBool(const char* name, bool value) = 0; virtual void AddTimeDeltaInSecondsF(const char* name, const base::TimeDelta& value) = 0; + virtual void AddBinary(const char* name, + const base::span<const uint8_t>& blob) = 0; // Markers indicating that a GPUDevice is being described. virtual void BeginGPUDevice() = 0;
diff --git a/gpu/config/gpu_info_unittest.cc b/gpu/config/gpu_info_unittest.cc index e30e5b2..f849760 100644 --- a/gpu/config/gpu_info_unittest.cc +++ b/gpu/config/gpu_info_unittest.cc
@@ -27,6 +27,9 @@ void AddBool(const char* name, bool value) override {} + void AddBinary(const char* name, + const base::span<const uint8_t>& blob) override {} + void AddTimeDeltaInSecondsF(const char* name, const base::TimeDelta& value) override {}
diff --git a/gpu/config/vulkan_info.cc b/gpu/config/vulkan_info.cc new file mode 100644 index 0000000..36e8207 --- /dev/null +++ b/gpu/config/vulkan_info.cc
@@ -0,0 +1,78 @@ +// 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. + +#include "gpu/config/vulkan_info.h" + +#include "gpu/ipc/common/vulkan_info.mojom.h" +#include "gpu/ipc/common/vulkan_info_mojom_traits.h" + +namespace gpu { + +VulkanPhysicalDeviceInfo::VulkanPhysicalDeviceInfo() = default; +VulkanPhysicalDeviceInfo::VulkanPhysicalDeviceInfo( + const VulkanPhysicalDeviceInfo& other) = default; +VulkanPhysicalDeviceInfo::~VulkanPhysicalDeviceInfo() = default; +VulkanPhysicalDeviceInfo& VulkanPhysicalDeviceInfo::operator=( + const VulkanPhysicalDeviceInfo& info) = default; + +VulkanInfo::VulkanInfo() = default; +VulkanInfo::~VulkanInfo() = default; + +VulkanInfo::VulkanInfo(const VulkanInfo& other) { + *this = other; +} + +VulkanInfo& VulkanInfo::operator=(const VulkanInfo& other) { + api_version = other.api_version; + used_api_version = other.used_api_version; + instance_extensions = other.instance_extensions; + instance_layers = other.instance_layers; + physical_devices = other.physical_devices; + SetEnabledInstanceExtensions(other.enabled_instance_extensions); + return *this; +} + +std::vector<uint8_t> VulkanInfo::Serialize() const { + return gpu::mojom::VulkanInfo::Serialize(this); +} + +void VulkanInfo::SetEnabledInstanceExtensions( + const std::vector<const char*>& extensions) { + enabled_instance_extensions.clear(); + for (const auto* const extension : extensions) { + bool found = false; + for (const auto& instance_extension : instance_extensions) { + if (strcmp(extension, instance_extension.extensionName) == 0) { + enabled_instance_extensions.push_back(instance_extension.extensionName); + found = true; + break; + } + } + if (!found) { + LOG(ERROR) << "The enabled extension '" << extension + << "' is not in instance_extensions!"; + } + } +} + +void VulkanInfo::SetEnabledInstanceExtensions( + const std::vector<base::StringPiece>& extensions) { + enabled_instance_extensions.clear(); + for (const auto& extension : extensions) { + bool found = false; + for (const auto& instance_extension : instance_extensions) { + if (extension == instance_extension.extensionName) { + enabled_instance_extensions.push_back(instance_extension.extensionName); + found = true; + break; + } + } + if (!found) { + LOG(ERROR) << "The enabled extension '" << extension + << "' is not in instance_extensions!"; + } + } +} + +} // namespace gpu
diff --git a/gpu/config/vulkan_info.h b/gpu/config/vulkan_info.h new file mode 100644 index 0000000..57b951ef --- /dev/null +++ b/gpu/config/vulkan_info.h
@@ -0,0 +1,62 @@ +// 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. + +#ifndef GPU_CONFIG_VULKAN_INFO_H_ +#define GPU_CONFIG_VULKAN_INFO_H_ + +#include <vulkan/vulkan.h> +#include <vector> + +#include "base/macros.h" +#include "base/strings/string_piece.h" +#include "gpu/gpu_export.h" +#include "ui/gfx/extension_set.h" + +namespace gpu { + +class GPU_EXPORT VulkanPhysicalDeviceInfo { + public: + VulkanPhysicalDeviceInfo(); + VulkanPhysicalDeviceInfo(const VulkanPhysicalDeviceInfo& other); + ~VulkanPhysicalDeviceInfo(); + VulkanPhysicalDeviceInfo& operator=(const VulkanPhysicalDeviceInfo& other); + + // This is a local variable in GPU process, it will not be sent via IPC. + VkPhysicalDevice device = VK_NULL_HANDLE; + + VkPhysicalDeviceProperties properties = {}; + std::vector<VkLayerProperties> layers; + + VkPhysicalDeviceFeatures features = {}; + // Extended physical device features: + bool feature_sampler_ycbcr_conversion = false; + bool feature_protected_memory = false; + + std::vector<VkQueueFamilyProperties> queue_families; +}; + +class GPU_EXPORT VulkanInfo { + public: + VulkanInfo(); + VulkanInfo(const VulkanInfo& other); + ~VulkanInfo(); + VulkanInfo& operator=(const VulkanInfo& other); + + std::vector<uint8_t> Serialize() const; + + void SetEnabledInstanceExtensions(const std::vector<const char*>& extensions); + void SetEnabledInstanceExtensions( + const std::vector<base::StringPiece>& extensions); + + uint32_t api_version = VK_MAKE_VERSION(1, 0, 0); + uint32_t used_api_version = VK_MAKE_VERSION(1, 0, 0); + std::vector<VkExtensionProperties> instance_extensions; + std::vector<const char*> enabled_instance_extensions; + std::vector<VkLayerProperties> instance_layers; + std::vector<VulkanPhysicalDeviceInfo> physical_devices; +}; + +} // namespace gpu + +#endif // GPU_CONFIG_VULKAN_INFO_H_
diff --git a/gpu/ipc/common/BUILD.gn b/gpu/ipc/common/BUILD.gn index 83f8fe1..7d77315d 100644 --- a/gpu/ipc/common/BUILD.gn +++ b/gpu/ipc/common/BUILD.gn
@@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/ui.gni") +import("//gpu/vulkan/features.gni") import("//mojo/public/tools/bindings/mojom.gni") import("//ui/ozone/ozone.gni") @@ -199,6 +200,17 @@ configs += [ "//gpu:gpu_implementation" ] } +source_set("vulkan_types") { + sources = [ + "vulkan_types.h", + ] + public_deps = [ + "//ui/gfx", + ] + all_dependent_configs = [ "//third_party/vulkan:vulkan_config" ] + configs += [ "//gpu:gpu_implementation" ] +} + mojom("interfaces") { generate_java = true sources = [ @@ -222,6 +234,11 @@ "//ui/gfx/geometry/mojom", "//ui/gfx/mojom", ] + + if (enable_vulkan) { + public_deps += [ ":vulkan_interface" ] + enabled_features = [ "supports_vulkan" ] + } } mojom("gpu_preferences_interface") { @@ -241,6 +258,19 @@ } } +mojom("vulkan_interface") { + generate_java = true + sources = [ + "vulkan_info.mojom", + "vulkan_types.mojom", + ] + + public_deps = [ + "//mojo/public/mojom/base", + ] + js_generate_struct_deserializers = true +} + mojom("test_interfaces") { testonly = true sources = [ @@ -251,6 +281,21 @@ ":gpu_preferences_interface", ":interfaces", ] + + if (enable_vulkan) { + public_deps += [ ":vulkan_interface" ] + } +} + +source_set("vulkan_types_mojom_traits") { + sources = [ + "vulkan_types_mojom_traits.h", + ] + + deps = [ + ":vulkan_interface_shared_cpp_sources", + ":vulkan_types", + ] } source_set("mojom_traits") { @@ -273,4 +318,7 @@ if (is_android) { sources += [ "vulkan_ycbcr_info_mojom_traits.h" ] } + if (enable_vulkan) { + deps += [ ":vulkan_types_mojom_traits" ] + } }
diff --git a/gpu/ipc/common/OWNERS b/gpu/ipc/common/OWNERS index 94f052bc..42610e03 100644 --- a/gpu/ipc/common/OWNERS +++ b/gpu/ipc/common/OWNERS
@@ -3,6 +3,8 @@ set noparent file://ipc/SECURITY_OWNERS +per-file generate_vulkan_types.py=file://gpu/OWNERS + # The following lines are redundant, they're just to silence the presubmit per-file *_messages*.h=set noparent per-file *_messages*.h=file://ipc/SECURITY_OWNERS
diff --git a/gpu/ipc/common/PRESUBMIT.py b/gpu/ipc/common/PRESUBMIT.py new file mode 100644 index 0000000..d30db35 --- /dev/null +++ b/gpu/ipc/common/PRESUBMIT.py
@@ -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. + +"""Enforces Vulkan types autogen matches script output. + +See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts +for more details on the presubmit API built into depot_tools. +""" + +import os.path + + +def CommonChecks(input_api, output_api): + generating_files = input_api.AffectedFiles( + file_filter=lambda x: os.path.basename(x.LocalPath()) in [ + 'generate_vulkan_types.py']) + generated_files = input_api.AffectedFiles( + file_filter=lambda x: os.path.basename(x.LocalPath()) in [ + 'vulkan_types.mojom', 'vulkan_types_mojom_traits.h', + 'vulkan_types_mojom_traits.cc', 'vulkan_types.typemap' + ]) + + + messages = [] + + if generated_files and not generating_files: + long_text = 'Changed files:\n' + for file in generated_files: + long_text += file.LocalPath() + '\n' + long_text += '\n' + messages.append(output_api.PresubmitError( + 'Vulkan types generated files changed but the generator ' + 'did not.', long_text=long_text)) + + with input_api.temporary_directory() as temp_dir: + commands = [] + if generating_files: + commands.append(input_api.Command(name='generate_vulkan_types', + cmd=[input_api.python_executable, + 'generate_vulkan_types.py', + '--check', + '--output-dir=' + temp_dir], + kwargs={}, + message=output_api.PresubmitError)) + if commands: + messages.extend(input_api.RunTests(commands)) + + return messages + +def CheckChangeOnUpload(input_api, output_api): + return CommonChecks(input_api, output_api) + +def CheckChangeOnCommit(input_api, output_api): + return CommonChecks(input_api, output_api)
diff --git a/gpu/ipc/common/generate_vulkan_types.py b/gpu/ipc/common/generate_vulkan_types.py new file mode 100755 index 0000000..ef27fab --- /dev/null +++ b/gpu/ipc/common/generate_vulkan_types.py
@@ -0,0 +1,598 @@ +#!/usr/bin/env python +# 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. + +import filecmp +import optparse +import os.path +import platform +import re +import subprocess +import sys + +_VULKAN_HEADER_FILE = "third_party/vulkan/include/vulkan/vulkan_core.h" + +_STRUCTS = [ + "VkExtensionProperties", + "VkLayerProperties", + "VkPhysicalDeviceProperties", + "VkPhysicalDeviceFeatures", + "VkQueueFamilyProperties", +] + +_SELF_LOCATION = os.path.dirname(os.path.abspath(__file__)) + +_MOJO_TYPES = set([ + "uint8", + "uint16", + "uint32", + "int8", + "int16", + "int32", + "float", + "string", +]) + +_VULKAN_BASIC_TYPE_MAP = set([ + "uint8_t", + "uint16_t", + "uint32_t", + "uint64_t", + "int8_t", + "int16_t", + "int32_t", + "int64_t", + "size_t", + "VkBool32", + "float", + "char", +]) + +# types to mojo type +_type_map = { + "uint8_t" : "uint8", + "uint16_t" : "uint16", + "uint32_t" : "uint32", + "uint64_t" : "uint64", + "int8_t" : "int8", + "int16_t" : "int16", + "int32_t" : "int32", + "int64_t" : "int64", + "size_t" : "uint64", + "VkBool32" : "bool", + "float" : "float", + "char" : "char", +} + +_structs = {} +_enums = {} +_defines = {} +_handles = set([]) +_generated_types = [] + + +def ValueNameToVALUE_NAME(name): + return re.sub( + r'(?<=[a-z])[A-Z]|(?<!^)[A-Z](?=[a-z])', r"_\g<0>", name).upper() + + +def ParseHandle(line): + if line.startswith("VK_DEFINE_HANDLE("): + name = line[len("VK_DEFINE_HANDLE("):-1] + elif line.startswith("VK_DEFINE_NON_DISPATCHABLE_HANDLE("): + name = line[len("VK_DEFINE_NON_DISPATCHABLE_HANDLE("):-1] + elif line.startswith("VK_DEFINE_DISPATCHABLE_HANDLE("): + name = line[len("VK_DEFINE_DISPATCHABLE_HANDLE("):-1] + else: + return + _handles.add(name) + + +def ParseTypedef(line): + # typedef Type1 Type1; + line = line.rstrip(';') + line = line.split() + if len(line) == 3: + typedef, t1, t2 = line + assert typedef == "typedef" + # We would like to use bool instead uint32 for VkBool32 + if t2 == "VkBool32": + return + if t1 in _type_map: + _type_map[t2] = _type_map[t1] + else: + assert t1 in _structs or t1 in _enums or t1 in _handles, \ + "Undefined type '%s'" % t1 + else: + pass + # skip typdef for function pointer + + +def ParseEnum(line, header_file): + # typedef enum kName { + # ... + # } kName; + name = line.split()[2] + + # Skip VkResult and NameBits + if name == "VkResult": + value_name_prefix = "VK" + elif name.endswith("FlagBits"): + value_name_prefix = ValueNameToVALUE_NAME(name[:-len("FlagBits")]) + elif name.endswith("FlagBitsKHR"): + value_name_prefix = ValueNameToVALUE_NAME(name[:-len("FlagBitsKHR")]) + else: + value_name_prefix = ValueNameToVALUE_NAME(name) + + values = [] + while True: + line = header_file.readline().strip() + # } kName; + if line == "} %s;" % name: + break + # VK_NAME = value, + value_name, value = line.rstrip(',').split(" = ") + if not value.isdigit(): + # Ignore VK_NAME_BEGIN_RANGE + # Ignore VK_NAME_END_RANGE + # Ignore VK_NAME_RANGE_SIZE + # Ignore VK_NAME_MAX_ENUM = 0x7FFFFFFF + continue + assert len(value_name_prefix) + 1 < len(value_name), \ + "Wrong enum value name `%s`" % value_name + mojom_value_name = value_name[len(value_name_prefix) + 1:] + values.append((value_name, value, mojom_value_name)) + assert name not in _enums, "enum '%s' has been defined." % name + _enums[name] = values + + +def ParseStruct(line, header_file): + # typedef struct kName { + # ... + # } kName; + name = line.split()[2] + + fields = [] + while True: + line = header_file.readline().strip() + # } kName; + if line == "} %s;" % name: + break + # type name; + # const type name; + # type name[L]; + line = line.rstrip(";") + field_type, field_name = line.rsplit(None, 1) + array_len = None + if '[' in field_name: + assert ']' in field_name + field_name, array_len = field_name.rstrip(']').split('[') + assert array_len.isdigit() or array_len in _defines + fields.append((field_name, field_type, array_len)) + assert name not in _structs, "struct '%s' has been defined." % name + _structs[name] = fields + + +def ParseDefine(line): + # not parse multi-line macros + if line.endswith('\\'): + return + # not parse #define NAME() ... + if '(' in line or ')' in line: + return + + define, name, value = line.split() + assert define == "#define" + assert name not in _defines, "macro '%s' has been defined." % name + _defines[name] = value + + +def ParseVulkanHeaderFile(path): + with open(path) as header_file: + while True: + line = header_file.readline() + if not line: + break + line = line.strip() + + if line.startswith("#define"): + ParseDefine(line) + elif line.startswith("typedef enum "): + ParseEnum(line, header_file) + elif line.startswith("typedef struct "): + ParseStruct(line, header_file) + elif line.startswith("typedef "): + ParseTypedef(line) + elif line.startswith("VK_DEFINE_"): + ParseHandle(line) + + +def WriteMojomEnum(name, mojom_file): + if name in _generated_types: + return + _generated_types.append(name) + + values = _enums[name] + mojom_file.write("\n") + mojom_file.write("enum %s {\n" % name) + for _, value, mojom_value_name in values: + mojom_file.write(" %s = %s,\n" % (mojom_value_name, value)) + mojom_file.write(" INVALID_VALUE = -1,\n") + mojom_file.write("};\n") + + +def WriteMojomStruct(name, mojom_file): + if name in _generated_types: + return + _generated_types.append(name) + + fields = _structs[name] + deps = [] + for field_name, field_type, array_len in fields: + if field_type in _structs or field_type in _enums: + deps.append(field_type) + WriteMojomTypes(deps, mojom_file) + + mojom_file.write("\n") + mojom_file.write("struct %s {\n" % name) + for field_name, field_type, array_len in fields: + if field_type in _type_map: + field_type = _type_map[field_type] + else: + assert field_type in _structs or field_type in _enums or \ + field_type in _handles, "Undefine type: '%s'" % field_type + if field_type == "char": + assert array_len + array_len = _defines[array_len] + mojom_file.write(" string %s;\n" % field_name) + elif not array_len: + mojom_file.write(" %s %s;\n" % (field_type, field_name)) + else: + if not array_len.isdigit(): + array_len = _defines[array_len] + assert array_len.isdigit(), "%s is not a digit." % array_len + mojom_file.write( + " array<%s, %s> %s;\n" % (field_type, array_len, field_name)) + mojom_file.write("};\n") + + +def WriteMojomTypes(types, mojom_file): + for t in types: + if t in _structs: + WriteMojomStruct(t, mojom_file) + elif t in _enums: + WriteMojomEnum(t, mojom_file) + else: + pass + + +def GenerateMojom(mojom_file): + mojom_file.write( +'''// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +module gpu.mojom; +''') + WriteMojomTypes(_STRUCTS, mojom_file) + + +def WriteStructTraits(name, traits_header_file, traits_source_file): + traits_header_file.write( +""" +template <> +struct StructTraits<gpu::mojom::%sDataView, %s> { +""" % (name, name) + ) + + fields = _structs[name] + for field_name, field_type, array_len in fields: + if field_type == "VkBool32": + field_type = "bool" + elif field_type == "VkDeviceSize": + field_type = "bool" + + if field_type == "char": + assert array_len + traits_header_file.write( +""" + static base::StringPiece %s(const %s& input) { + return input.%s; + } +""" % (field_name, name, field_name)) + elif array_len: + traits_header_file.write( +""" + static base::span<const %s> %s(const %s& input) { + return input.%s; + } +""" % (field_type, field_name, name, field_name)) + elif field_type in _structs: + traits_header_file.write( +""" + static const %s& %s(const %s& input) { + return input.%s; + } +""" % (field_type, field_name, name, field_name)) + else: + traits_header_file.write( +""" + static %s %s(const %s& input) { + return input.%s; + } +""" % (field_type, field_name, name, field_name)) + + traits_header_file.write( +""" + static bool Read(gpu::mojom::%sDataView data, %s* out); +""" % (name, name)) + + traits_source_file.write( +""" +// static +bool StructTraits<gpu::mojom::%sDataView, %s>::Read( + gpu::mojom::%sDataView data, %s* out) { +""" % (name, name, name, name)) + + fields = _structs[name] + for field_name, field_type, array_len in fields: + if field_type == "VkBool32": + field_type = "bool" + elif field_type == "VkDeviceSize": + field_type = "bool" + + if field_type == "char": + assert array_len + read_method = "Read%s%s" % (field_name[0].upper(), field_name[1:]) + traits_source_file.write( +""" + base::StringPiece %s; + if (!data.%s(&%s)) + return false; + %s.copy(out->%s, sizeof(out->%s)); +""" % (field_name, read_method, field_name, field_name, field_name, field_name)) + elif array_len: + read_method = "Read%s%s" % (field_name[0].upper(), field_name[1:]) + traits_source_file.write( +""" + base::span<%s> %s(out->%s); + if (!data.%s(&%s)) + return false; +""" % (field_type, field_name, field_name, read_method, field_name)) + elif field_type in _structs or field_type in _enums: + traits_source_file.write( +""" + if (!data.Read%s%s(&out->%s)) + return false; +""" % (field_name[0].upper(), field_name[1:], field_name)) + else: + traits_source_file.write( +""" + out->%s = data.%s(); +""" % (field_name, field_name)) + + + traits_source_file.write( +""" + return true; +} +""") + + + traits_header_file.write("};\n") + + +def WriteEnumTraits(name, traits_header_file): + traits_header_file.write( +""" +template <> +struct EnumTraits<gpu::mojom::%s, %s> { + static gpu::mojom::%s ToMojom(%s input) { + switch (input) { +""" % (name, name, name, name)) + + for value_name, _, mojom_value_name in _enums[name]: + traits_header_file.write( +""" + case %s::%s: + return gpu::mojom::%s::%s;""" + % (name, value_name, name, mojom_value_name)) + + traits_header_file.write( +""" + default: + NOTREACHED(); + return gpu::mojom::%s::INVALID_VALUE; + } + } + + static bool FromMojom(gpu::mojom::%s input, %s* out) { + switch (input) { +""" % (name, name, name)) + + for value_name, _, mojom_value_name in _enums[name]: + traits_header_file.write( +""" + case gpu::mojom::%s::%s: + *out = %s::%s; + return true;""" % (name, mojom_value_name, name, value_name)) + + traits_header_file.write( +""" + case gpu::mojom::%s::INVALID_VALUE: + NOTREACHED(); + return false; + + } + NOTREACHED(); + return false; + } +};""" % name) + + + +def GenerateTraitsFile(traits_header_file, traits_source_file): + traits_header_file.write( +"""// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +#ifndef GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_ +#define GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_ + +#include "base/containers/span.h" +#include "base/strings/string_piece.h" +#include "gpu/ipc/common/vulkan_types.h" +#include "gpu/ipc/common/vulkan_types.mojom-shared.h" + +namespace mojo { +""") + + traits_source_file.write( +"""// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +#include "gpu/ipc/common/vulkan_info_mojom_traits.h" + +namespace mojo { +""") + + for t in _generated_types: + if t in _structs: + WriteStructTraits(t, traits_header_file, traits_source_file) + elif t in _enums: + WriteEnumTraits(t, traits_header_file) + + traits_header_file.write( +""" +} // namespace mojo + +#endif // GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_""") + + traits_source_file.write( +""" +} // namespace mojo""") + + +def GenerateTypemapFile(typemap_file): + typemap_file.write( +"""# 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. + +# This file is auto-generated from +# gpu/ipc/common/generate_vulkan_types.py +# DO NOT EDIT! + +mojom = "//gpu/ipc/common/vulkan_types.mojom" +public_headers = [ "//gpu/ipc/common/vulkan_types.h" ] +traits_headers = [ "//gpu/ipc/common/vulkan_types_mojom_traits.h" ] +sources = [ + "//gpu/ipc/common/vulkan_types_mojom_traits.cc", +] +public_deps = [ + "//gpu/ipc/common:vulkan_types", +] +type_mappings = [ +""") + for t in _generated_types: + typemap_file.write(" \"gpu.mojom.%s=::%s\",\n" % (t, t)) + typemap_file.write("]\n") + + +def main(argv): + """This is the main function.""" + + parser = optparse.OptionParser() + parser.add_option( + "--output-dir", + help="Output directory for generated files. Defaults to this script's " + "directory.") + parser.add_option( + "-c", "--check", action="store_true", + help="Check if output files match generated files in chromium root " + "directory. Use this in PRESUBMIT scripts with --output-dir.") + + (options, _) = parser.parse_args(args=argv) + + # Support generating files for PRESUBMIT. + if options.output_dir: + output_dir = options.output_dir + else: + output_dir = _SELF_LOCATION + + def ClangFormat(filename): + formatter = "clang-format" + if platform.system() == "Windows": + formatter += ".bat" + subprocess.call([formatter, "-i", "-style=chromium", filename]) + + vulkan_header_file_path = os.path.join( + _SELF_LOCATION, "../../..", _VULKAN_HEADER_FILE) + ParseVulkanHeaderFile(vulkan_header_file_path) + + mojom_file_name = "vulkan_types.mojom" + mojom_file = open( + os.path.join(output_dir, mojom_file_name), 'wb') + GenerateMojom(mojom_file) + mojom_file.close() + ClangFormat(mojom_file.name) + + traits_header_file_name = "vulkan_types_mojom_traits.h" + traits_header_file = \ + open(os.path.join(output_dir, traits_header_file_name), 'wb') + traits_source_file_name = "vulkan_types_mojom_traits.cc" + traits_source_file = \ + open(os.path.join(output_dir, traits_source_file_name), 'wb') + GenerateTraitsFile(traits_header_file, traits_source_file) + traits_header_file.close() + ClangFormat(traits_header_file.name) + traits_source_file.close() + ClangFormat(traits_source_file.name) + + typemap_file_name = "vulkan_types.typemap" + typemap_file = open( + os.path.join(output_dir, typemap_file_name), 'wb') + GenerateTypemapFile(typemap_file) + typemap_file.close() + + check_failed_filenames = [] + if options.check: + for filename in [mojom_file_name, traits_header_file_name, + traits_source_file_name, typemap_file_name]: + if not filecmp.cmp(os.path.join(output_dir, filename), + os.path.join(_SELF_LOCATION, filename)): + check_failed_filenames.append(filename) + + if len(check_failed_filenames) > 0: + print 'Please run gpu/ipc/common/generate_vulkan_types.py' + print 'Failed check on generated files:' + for filename in check_failed_filenames: + print filename + return 1 + + return 0 + + +if __name__ == '__main__': + sys.exit(main(sys.argv))
diff --git a/gpu/ipc/common/gpu_info.mojom b/gpu/ipc/common/gpu_info.mojom index 5d4bacb2..9942b5e 100644 --- a/gpu/ipc/common/gpu_info.mojom +++ b/gpu/ipc/common/gpu_info.mojom
@@ -9,6 +9,9 @@ import "mojo/public/mojom/base/time.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; +[EnableIf=supports_vulkan] +import "gpu/ipc/common/vulkan_info.mojom"; + // gpu::GPUInfo::GPUDevice struct GpuDevice { uint32 vendor_id; @@ -173,4 +176,7 @@ uint64 rgba_visual; bool oop_rasterization_supported; bool subpixel_font_rendering; + + [EnableIf=supports_vulkan] + VulkanInfo? vulkan_info; };
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.cc b/gpu/ipc/common/gpu_info_mojom_traits.cc index d13bd07..248daaf 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.cc +++ b/gpu/ipc/common/gpu_info_mojom_traits.cc
@@ -8,6 +8,10 @@ #include "base/logging.h" #include "mojo/public/cpp/base/time_mojom_traits.h" +#if BUILDFLAG(ENABLE_VULKAN) +#include "gpu/ipc/common/vulkan_info_mojom_traits.h" +#endif + namespace mojo { // static @@ -413,7 +417,11 @@ data.ReadVideoEncodeAcceleratorSupportedProfiles( &out->video_encode_accelerator_supported_profiles) && data.ReadImageDecodeAcceleratorSupportedProfiles( - &out->image_decode_accelerator_supported_profiles); + &out->image_decode_accelerator_supported_profiles) && +#if BUILDFLAG(ENABLE_VULKAN) + data.ReadVulkanInfo(&out->vulkan_info) && +#endif + true; } } // namespace mojo
diff --git a/gpu/ipc/common/gpu_info_mojom_traits.h b/gpu/ipc/common/gpu_info_mojom_traits.h index 24bcb30..b8b2269 100644 --- a/gpu/ipc/common/gpu_info_mojom_traits.h +++ b/gpu/ipc/common/gpu_info_mojom_traits.h
@@ -395,6 +395,13 @@ static bool subpixel_font_rendering(const gpu::GPUInfo& input) { return input.subpixel_font_rendering; } + +#if BUILDFLAG(ENABLE_VULKAN) + static const base::Optional<gpu::VulkanInfo> vulkan_info( + const gpu::GPUInfo& input) { + return input.vulkan_info; + } +#endif }; } // namespace mojo
diff --git a/gpu/ipc/common/typemaps.gni b/gpu/ipc/common/typemaps.gni index 397b2b00..e27bfe23 100644 --- a/gpu/ipc/common/typemaps.gni +++ b/gpu/ipc/common/typemaps.gni
@@ -16,4 +16,6 @@ "//gpu/ipc/common/surface_handle.typemap", "//gpu/ipc/common/sync_token.typemap", "//gpu/ipc/common/vulkan_ycbcr_info.typemap", + "//gpu/ipc/common/vulkan_info.typemap", + "//gpu/ipc/common/vulkan_types.typemap", ]
diff --git a/gpu/ipc/common/vulkan_info.mojom b/gpu/ipc/common/vulkan_info.mojom new file mode 100644 index 0000000..f80cc07 --- /dev/null +++ b/gpu/ipc/common/vulkan_info.mojom
@@ -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. + +// gpu/config/vulkan_info.h +module gpu.mojom; + +import "gpu/ipc/common/vulkan_types.mojom"; + +struct VulkanPhysicalDeviceInfo { + VkPhysicalDeviceProperties properties; + array<VkLayerProperties> layers; + VkPhysicalDeviceFeatures features; + bool feature_sampler_ycbcr_conversion; + bool feature_protected_memory; + array<VkQueueFamilyProperties> queue_families; +}; + +struct VulkanInfo { + uint32 api_version; + uint32 used_api_version; + array<VkExtensionProperties> instance_extensions; + array<string> enabled_instance_extensions; + array<VkLayerProperties> instance_layers; + array<VulkanPhysicalDeviceInfo> physical_devices; +};
diff --git a/gpu/ipc/common/vulkan_info.typemap b/gpu/ipc/common/vulkan_info.typemap new file mode 100644 index 0000000..d61d109 --- /dev/null +++ b/gpu/ipc/common/vulkan_info.typemap
@@ -0,0 +1,16 @@ +# 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. + +mojom = "//gpu/ipc/common/vulkan_info.mojom" +public_headers = [ "//gpu/config/vulkan_info.h" ] +traits_headers = [ "//gpu/ipc/common/vulkan_info_mojom_traits.h" ] +public_deps = [ + # "//gpu/config", + "//gpu/ipc/common:vulkan_types", + "//gpu/ipc/common:vulkan_types_mojom_traits", +] +type_mappings = [ + "gpu.mojom.VulkanPhysicalDeviceInfo=::gpu::VulkanPhysicalDeviceInfo", + "gpu.mojom.VulkanInfo=::gpu::VulkanInfo", +]
diff --git a/gpu/ipc/common/vulkan_info_mojom_traits.h b/gpu/ipc/common/vulkan_info_mojom_traits.h new file mode 100644 index 0000000..9b67d96 --- /dev/null +++ b/gpu/ipc/common/vulkan_info_mojom_traits.h
@@ -0,0 +1,118 @@ +// 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. + +#ifndef GPU_IPC_COMMON_VULKAN_INFO_MOJOM_TRAITS_H_ +#define GPU_IPC_COMMON_VULKAN_INFO_MOJOM_TRAITS_H_ + +#include "base/containers/span.h" +#include "base/strings/string_piece.h" +#include "gpu/config/vulkan_info.h" +#include "gpu/ipc/common/vulkan_info.mojom-shared.h" +#include "gpu/ipc/common/vulkan_types_mojom_traits.h" + +namespace mojo { + +template <> +struct StructTraits<gpu::mojom::VulkanPhysicalDeviceInfoDataView, + gpu::VulkanPhysicalDeviceInfo> { + static const VkPhysicalDeviceProperties& properties( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.properties; + } + + static const std::vector<VkLayerProperties>& layers( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.layers; + } + + static const VkPhysicalDeviceFeatures& features( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.features; + } + + static bool feature_sampler_ycbcr_conversion( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.feature_sampler_ycbcr_conversion; + } + + static bool feature_protected_memory( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.feature_protected_memory; + } + + static const std::vector<VkQueueFamilyProperties>& queue_families( + const gpu::VulkanPhysicalDeviceInfo& input) { + return input.queue_families; + } + + static bool Read(gpu::mojom::VulkanPhysicalDeviceInfoDataView data, + gpu::VulkanPhysicalDeviceInfo* out) { + if (!data.ReadProperties(&out->properties)) + return false; + if (!data.ReadLayers(&out->layers)) + return false; + if (!data.ReadFeatures(&out->features)) + return false; + out->feature_sampler_ycbcr_conversion = + data.feature_sampler_ycbcr_conversion(); + out->feature_protected_memory = data.feature_protected_memory(); + if (!data.ReadQueueFamilies(&out->queue_families)) + return false; + return true; + } +}; + +template <> +struct StructTraits<gpu::mojom::VulkanInfoDataView, gpu::VulkanInfo> { + static uint32_t api_version(const gpu::VulkanInfo& input) { + return input.api_version; + } + + static uint32_t used_api_version(const gpu::VulkanInfo& input) { + return input.used_api_version; + } + + static const std::vector<VkExtensionProperties>& instance_extensions( + const gpu::VulkanInfo& input) { + return input.instance_extensions; + } + + static std::vector<base::StringPiece> enabled_instance_extensions( + const gpu::VulkanInfo& input) { + std::vector<base::StringPiece> extensions; + extensions.reserve(input.enabled_instance_extensions.size()); + for (const char* extension : input.enabled_instance_extensions) + extensions.emplace_back(extension); + return extensions; + } + + static const std::vector<VkLayerProperties>& instance_layers( + const gpu::VulkanInfo& input) { + return input.instance_layers; + } + + static const std::vector<gpu::VulkanPhysicalDeviceInfo>& physical_devices( + const gpu::VulkanInfo& input) { + return input.physical_devices; + } + + static bool Read(gpu::mojom::VulkanInfoDataView data, gpu::VulkanInfo* out) { + out->api_version = data.api_version(); + out->used_api_version = data.used_api_version(); + + if (!data.ReadInstanceExtensions(&out->instance_extensions)) + return false; + + std::vector<base::StringPiece> extensions; + if (!data.ReadEnabledInstanceExtensions(&extensions)) + return false; + out->SetEnabledInstanceExtensions(extensions); + return data.ReadInstanceLayers(&out->instance_layers) && + data.ReadPhysicalDevices(&out->physical_devices); + } +}; + +} // namespace mojo + +#endif // GPU_IPC_COMMON_VULKAN_INFO_MOJOM_TRAITS_H_
diff --git a/gpu/ipc/common/vulkan_types.h b/gpu/ipc/common/vulkan_types.h new file mode 100644 index 0000000..0d65cd9 --- /dev/null +++ b/gpu/ipc/common/vulkan_types.h
@@ -0,0 +1,10 @@ +// 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. + +#ifndef GPU_IPC_COMMON_VULKAN_TYPES_H_ +#define GPU_IPC_COMMON_VULKAN_TYPES_H_ + +#include <vulkan/vulkan.h> + +#endif // GPU_IPC_COMMON_VULKAN_TYPES_H_
diff --git a/gpu/ipc/common/vulkan_types.mojom b/gpu/ipc/common/vulkan_types.mojom new file mode 100644 index 0000000..8f13e182c --- /dev/null +++ b/gpu/ipc/common/vulkan_types.mojom
@@ -0,0 +1,232 @@ +// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +module gpu.mojom; + +struct VkExtensionProperties { + string extensionName; + uint32 specVersion; +}; + +struct VkLayerProperties { + string layerName; + uint32 specVersion; + uint32 implementationVersion; + string description; +}; + +enum VkPhysicalDeviceType { + OTHER = 0, + INTEGRATED_GPU = 1, + DISCRETE_GPU = 2, + VIRTUAL_GPU = 3, + CPU = 4, + INVALID_VALUE = -1, +}; + +struct VkPhysicalDeviceLimits { + uint32 maxImageDimension1D; + uint32 maxImageDimension2D; + uint32 maxImageDimension3D; + uint32 maxImageDimensionCube; + uint32 maxImageArrayLayers; + uint32 maxTexelBufferElements; + uint32 maxUniformBufferRange; + uint32 maxStorageBufferRange; + uint32 maxPushConstantsSize; + uint32 maxMemoryAllocationCount; + uint32 maxSamplerAllocationCount; + uint64 bufferImageGranularity; + uint64 sparseAddressSpaceSize; + uint32 maxBoundDescriptorSets; + uint32 maxPerStageDescriptorSamplers; + uint32 maxPerStageDescriptorUniformBuffers; + uint32 maxPerStageDescriptorStorageBuffers; + uint32 maxPerStageDescriptorSampledImages; + uint32 maxPerStageDescriptorStorageImages; + uint32 maxPerStageDescriptorInputAttachments; + uint32 maxPerStageResources; + uint32 maxDescriptorSetSamplers; + uint32 maxDescriptorSetUniformBuffers; + uint32 maxDescriptorSetUniformBuffersDynamic; + uint32 maxDescriptorSetStorageBuffers; + uint32 maxDescriptorSetStorageBuffersDynamic; + uint32 maxDescriptorSetSampledImages; + uint32 maxDescriptorSetStorageImages; + uint32 maxDescriptorSetInputAttachments; + uint32 maxVertexInputAttributes; + uint32 maxVertexInputBindings; + uint32 maxVertexInputAttributeOffset; + uint32 maxVertexInputBindingStride; + uint32 maxVertexOutputComponents; + uint32 maxTessellationGenerationLevel; + uint32 maxTessellationPatchSize; + uint32 maxTessellationControlPerVertexInputComponents; + uint32 maxTessellationControlPerVertexOutputComponents; + uint32 maxTessellationControlPerPatchOutputComponents; + uint32 maxTessellationControlTotalOutputComponents; + uint32 maxTessellationEvaluationInputComponents; + uint32 maxTessellationEvaluationOutputComponents; + uint32 maxGeometryShaderInvocations; + uint32 maxGeometryInputComponents; + uint32 maxGeometryOutputComponents; + uint32 maxGeometryOutputVertices; + uint32 maxGeometryTotalOutputComponents; + uint32 maxFragmentInputComponents; + uint32 maxFragmentOutputAttachments; + uint32 maxFragmentDualSrcAttachments; + uint32 maxFragmentCombinedOutputResources; + uint32 maxComputeSharedMemorySize; + array<uint32, 3> maxComputeWorkGroupCount; + uint32 maxComputeWorkGroupInvocations; + array<uint32, 3> maxComputeWorkGroupSize; + uint32 subPixelPrecisionBits; + uint32 subTexelPrecisionBits; + uint32 mipmapPrecisionBits; + uint32 maxDrawIndexedIndexValue; + uint32 maxDrawIndirectCount; + float maxSamplerLodBias; + float maxSamplerAnisotropy; + uint32 maxViewports; + array<uint32, 2> maxViewportDimensions; + array<float, 2> viewportBoundsRange; + uint32 viewportSubPixelBits; + uint64 minMemoryMapAlignment; + uint64 minTexelBufferOffsetAlignment; + uint64 minUniformBufferOffsetAlignment; + uint64 minStorageBufferOffsetAlignment; + int32 minTexelOffset; + uint32 maxTexelOffset; + int32 minTexelGatherOffset; + uint32 maxTexelGatherOffset; + float minInterpolationOffset; + float maxInterpolationOffset; + uint32 subPixelInterpolationOffsetBits; + uint32 maxFramebufferWidth; + uint32 maxFramebufferHeight; + uint32 maxFramebufferLayers; + uint32 framebufferColorSampleCounts; + uint32 framebufferDepthSampleCounts; + uint32 framebufferStencilSampleCounts; + uint32 framebufferNoAttachmentsSampleCounts; + uint32 maxColorAttachments; + uint32 sampledImageColorSampleCounts; + uint32 sampledImageIntegerSampleCounts; + uint32 sampledImageDepthSampleCounts; + uint32 sampledImageStencilSampleCounts; + uint32 storageImageSampleCounts; + uint32 maxSampleMaskWords; + bool timestampComputeAndGraphics; + float timestampPeriod; + uint32 maxClipDistances; + uint32 maxCullDistances; + uint32 maxCombinedClipAndCullDistances; + uint32 discreteQueuePriorities; + array<float, 2> pointSizeRange; + array<float, 2> lineWidthRange; + float pointSizeGranularity; + float lineWidthGranularity; + bool strictLines; + bool standardSampleLocations; + uint64 optimalBufferCopyOffsetAlignment; + uint64 optimalBufferCopyRowPitchAlignment; + uint64 nonCoherentAtomSize; +}; + +struct VkPhysicalDeviceSparseProperties { + bool residencyStandard2DBlockShape; + bool residencyStandard2DMultisampleBlockShape; + bool residencyStandard3DBlockShape; + bool residencyAlignedMipSize; + bool residencyNonResidentStrict; +}; + +struct VkPhysicalDeviceProperties { + uint32 apiVersion; + uint32 driverVersion; + uint32 vendorID; + uint32 deviceID; + VkPhysicalDeviceType deviceType; + string deviceName; + array<uint8, 16> pipelineCacheUUID; + VkPhysicalDeviceLimits limits; + VkPhysicalDeviceSparseProperties sparseProperties; +}; + +struct VkPhysicalDeviceFeatures { + bool robustBufferAccess; + bool fullDrawIndexUint32; + bool imageCubeArray; + bool independentBlend; + bool geometryShader; + bool tessellationShader; + bool sampleRateShading; + bool dualSrcBlend; + bool logicOp; + bool multiDrawIndirect; + bool drawIndirectFirstInstance; + bool depthClamp; + bool depthBiasClamp; + bool fillModeNonSolid; + bool depthBounds; + bool wideLines; + bool largePoints; + bool alphaToOne; + bool multiViewport; + bool samplerAnisotropy; + bool textureCompressionETC2; + bool textureCompressionASTC_LDR; + bool textureCompressionBC; + bool occlusionQueryPrecise; + bool pipelineStatisticsQuery; + bool vertexPipelineStoresAndAtomics; + bool fragmentStoresAndAtomics; + bool shaderTessellationAndGeometryPointSize; + bool shaderImageGatherExtended; + bool shaderStorageImageExtendedFormats; + bool shaderStorageImageMultisample; + bool shaderStorageImageReadWithoutFormat; + bool shaderStorageImageWriteWithoutFormat; + bool shaderUniformBufferArrayDynamicIndexing; + bool shaderSampledImageArrayDynamicIndexing; + bool shaderStorageBufferArrayDynamicIndexing; + bool shaderStorageImageArrayDynamicIndexing; + bool shaderClipDistance; + bool shaderCullDistance; + bool shaderFloat64; + bool shaderInt64; + bool shaderInt16; + bool shaderResourceResidency; + bool shaderResourceMinLod; + bool sparseBinding; + bool sparseResidencyBuffer; + bool sparseResidencyImage2D; + bool sparseResidencyImage3D; + bool sparseResidency2Samples; + bool sparseResidency4Samples; + bool sparseResidency8Samples; + bool sparseResidency16Samples; + bool sparseResidencyAliased; + bool variableMultisampleRate; + bool inheritedQueries; +}; + +struct VkExtent3D { + uint32 width; + uint32 height; + uint32 depth; +}; + +struct VkQueueFamilyProperties { + uint32 queueFlags; + uint32 queueCount; + uint32 timestampValidBits; + VkExtent3D minImageTransferGranularity; +};
diff --git a/gpu/ipc/common/vulkan_types.typemap b/gpu/ipc/common/vulkan_types.typemap new file mode 100644 index 0000000..9506337e --- /dev/null +++ b/gpu/ipc/common/vulkan_types.typemap
@@ -0,0 +1,28 @@ +# 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. + +# This file is auto-generated from +# gpu/ipc/common/generate_vulkan_types.py +# DO NOT EDIT! + +mojom = "//gpu/ipc/common/vulkan_types.mojom" +public_headers = [ "//gpu/ipc/common/vulkan_types.h" ] +traits_headers = [ "//gpu/ipc/common/vulkan_types_mojom_traits.h" ] +sources = [ + "//gpu/ipc/common/vulkan_types_mojom_traits.cc", +] +public_deps = [ + "//gpu/ipc/common:vulkan_types", +] +type_mappings = [ + "gpu.mojom.VkExtensionProperties=::VkExtensionProperties", + "gpu.mojom.VkLayerProperties=::VkLayerProperties", + "gpu.mojom.VkPhysicalDeviceProperties=::VkPhysicalDeviceProperties", + "gpu.mojom.VkPhysicalDeviceType=::VkPhysicalDeviceType", + "gpu.mojom.VkPhysicalDeviceLimits=::VkPhysicalDeviceLimits", + "gpu.mojom.VkPhysicalDeviceSparseProperties=::VkPhysicalDeviceSparseProperties", + "gpu.mojom.VkPhysicalDeviceFeatures=::VkPhysicalDeviceFeatures", + "gpu.mojom.VkQueueFamilyProperties=::VkQueueFamilyProperties", + "gpu.mojom.VkExtent3D=::VkExtent3D", +]
diff --git a/gpu/ipc/common/vulkan_types_mojom_traits.cc b/gpu/ipc/common/vulkan_types_mojom_traits.cc new file mode 100644 index 0000000..9dc3878 --- /dev/null +++ b/gpu/ipc/common/vulkan_types_mojom_traits.cc
@@ -0,0 +1,510 @@ +// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +#include "gpu/ipc/common/vulkan_info_mojom_traits.h" + +namespace mojo { + +// static +bool StructTraits< + gpu::mojom::VkExtensionPropertiesDataView, + VkExtensionProperties>::Read(gpu::mojom::VkExtensionPropertiesDataView data, + VkExtensionProperties* out) { + base::StringPiece extensionName; + if (!data.ReadExtensionName(&extensionName)) + return false; + extensionName.copy(out->extensionName, sizeof(out->extensionName)); + + out->specVersion = data.specVersion(); + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkLayerPropertiesDataView, VkLayerProperties>:: + Read(gpu::mojom::VkLayerPropertiesDataView data, VkLayerProperties* out) { + base::StringPiece layerName; + if (!data.ReadLayerName(&layerName)) + return false; + layerName.copy(out->layerName, sizeof(out->layerName)); + + out->specVersion = data.specVersion(); + + out->implementationVersion = data.implementationVersion(); + + base::StringPiece description; + if (!data.ReadDescription(&description)) + return false; + description.copy(out->description, sizeof(out->description)); + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkPhysicalDevicePropertiesDataView, + VkPhysicalDeviceProperties>:: + Read(gpu::mojom::VkPhysicalDevicePropertiesDataView data, + VkPhysicalDeviceProperties* out) { + out->apiVersion = data.apiVersion(); + + out->driverVersion = data.driverVersion(); + + out->vendorID = data.vendorID(); + + out->deviceID = data.deviceID(); + + if (!data.ReadDeviceType(&out->deviceType)) + return false; + + base::StringPiece deviceName; + if (!data.ReadDeviceName(&deviceName)) + return false; + deviceName.copy(out->deviceName, sizeof(out->deviceName)); + + base::span<uint8_t> pipelineCacheUUID(out->pipelineCacheUUID); + if (!data.ReadPipelineCacheUUID(&pipelineCacheUUID)) + return false; + + if (!data.ReadLimits(&out->limits)) + return false; + + if (!data.ReadSparseProperties(&out->sparseProperties)) + return false; + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkPhysicalDeviceLimitsDataView, + VkPhysicalDeviceLimits>:: + Read(gpu::mojom::VkPhysicalDeviceLimitsDataView data, + VkPhysicalDeviceLimits* out) { + out->maxImageDimension1D = data.maxImageDimension1D(); + + out->maxImageDimension2D = data.maxImageDimension2D(); + + out->maxImageDimension3D = data.maxImageDimension3D(); + + out->maxImageDimensionCube = data.maxImageDimensionCube(); + + out->maxImageArrayLayers = data.maxImageArrayLayers(); + + out->maxTexelBufferElements = data.maxTexelBufferElements(); + + out->maxUniformBufferRange = data.maxUniformBufferRange(); + + out->maxStorageBufferRange = data.maxStorageBufferRange(); + + out->maxPushConstantsSize = data.maxPushConstantsSize(); + + out->maxMemoryAllocationCount = data.maxMemoryAllocationCount(); + + out->maxSamplerAllocationCount = data.maxSamplerAllocationCount(); + + out->bufferImageGranularity = data.bufferImageGranularity(); + + out->sparseAddressSpaceSize = data.sparseAddressSpaceSize(); + + out->maxBoundDescriptorSets = data.maxBoundDescriptorSets(); + + out->maxPerStageDescriptorSamplers = data.maxPerStageDescriptorSamplers(); + + out->maxPerStageDescriptorUniformBuffers = + data.maxPerStageDescriptorUniformBuffers(); + + out->maxPerStageDescriptorStorageBuffers = + data.maxPerStageDescriptorStorageBuffers(); + + out->maxPerStageDescriptorSampledImages = + data.maxPerStageDescriptorSampledImages(); + + out->maxPerStageDescriptorStorageImages = + data.maxPerStageDescriptorStorageImages(); + + out->maxPerStageDescriptorInputAttachments = + data.maxPerStageDescriptorInputAttachments(); + + out->maxPerStageResources = data.maxPerStageResources(); + + out->maxDescriptorSetSamplers = data.maxDescriptorSetSamplers(); + + out->maxDescriptorSetUniformBuffers = data.maxDescriptorSetUniformBuffers(); + + out->maxDescriptorSetUniformBuffersDynamic = + data.maxDescriptorSetUniformBuffersDynamic(); + + out->maxDescriptorSetStorageBuffers = data.maxDescriptorSetStorageBuffers(); + + out->maxDescriptorSetStorageBuffersDynamic = + data.maxDescriptorSetStorageBuffersDynamic(); + + out->maxDescriptorSetSampledImages = data.maxDescriptorSetSampledImages(); + + out->maxDescriptorSetStorageImages = data.maxDescriptorSetStorageImages(); + + out->maxDescriptorSetInputAttachments = + data.maxDescriptorSetInputAttachments(); + + out->maxVertexInputAttributes = data.maxVertexInputAttributes(); + + out->maxVertexInputBindings = data.maxVertexInputBindings(); + + out->maxVertexInputAttributeOffset = data.maxVertexInputAttributeOffset(); + + out->maxVertexInputBindingStride = data.maxVertexInputBindingStride(); + + out->maxVertexOutputComponents = data.maxVertexOutputComponents(); + + out->maxTessellationGenerationLevel = data.maxTessellationGenerationLevel(); + + out->maxTessellationPatchSize = data.maxTessellationPatchSize(); + + out->maxTessellationControlPerVertexInputComponents = + data.maxTessellationControlPerVertexInputComponents(); + + out->maxTessellationControlPerVertexOutputComponents = + data.maxTessellationControlPerVertexOutputComponents(); + + out->maxTessellationControlPerPatchOutputComponents = + data.maxTessellationControlPerPatchOutputComponents(); + + out->maxTessellationControlTotalOutputComponents = + data.maxTessellationControlTotalOutputComponents(); + + out->maxTessellationEvaluationInputComponents = + data.maxTessellationEvaluationInputComponents(); + + out->maxTessellationEvaluationOutputComponents = + data.maxTessellationEvaluationOutputComponents(); + + out->maxGeometryShaderInvocations = data.maxGeometryShaderInvocations(); + + out->maxGeometryInputComponents = data.maxGeometryInputComponents(); + + out->maxGeometryOutputComponents = data.maxGeometryOutputComponents(); + + out->maxGeometryOutputVertices = data.maxGeometryOutputVertices(); + + out->maxGeometryTotalOutputComponents = + data.maxGeometryTotalOutputComponents(); + + out->maxFragmentInputComponents = data.maxFragmentInputComponents(); + + out->maxFragmentOutputAttachments = data.maxFragmentOutputAttachments(); + + out->maxFragmentDualSrcAttachments = data.maxFragmentDualSrcAttachments(); + + out->maxFragmentCombinedOutputResources = + data.maxFragmentCombinedOutputResources(); + + out->maxComputeSharedMemorySize = data.maxComputeSharedMemorySize(); + + base::span<uint32_t> maxComputeWorkGroupCount(out->maxComputeWorkGroupCount); + if (!data.ReadMaxComputeWorkGroupCount(&maxComputeWorkGroupCount)) + return false; + + out->maxComputeWorkGroupInvocations = data.maxComputeWorkGroupInvocations(); + + base::span<uint32_t> maxComputeWorkGroupSize(out->maxComputeWorkGroupSize); + if (!data.ReadMaxComputeWorkGroupSize(&maxComputeWorkGroupSize)) + return false; + + out->subPixelPrecisionBits = data.subPixelPrecisionBits(); + + out->subTexelPrecisionBits = data.subTexelPrecisionBits(); + + out->mipmapPrecisionBits = data.mipmapPrecisionBits(); + + out->maxDrawIndexedIndexValue = data.maxDrawIndexedIndexValue(); + + out->maxDrawIndirectCount = data.maxDrawIndirectCount(); + + out->maxSamplerLodBias = data.maxSamplerLodBias(); + + out->maxSamplerAnisotropy = data.maxSamplerAnisotropy(); + + out->maxViewports = data.maxViewports(); + + base::span<uint32_t> maxViewportDimensions(out->maxViewportDimensions); + if (!data.ReadMaxViewportDimensions(&maxViewportDimensions)) + return false; + + base::span<float> viewportBoundsRange(out->viewportBoundsRange); + if (!data.ReadViewportBoundsRange(&viewportBoundsRange)) + return false; + + out->viewportSubPixelBits = data.viewportSubPixelBits(); + + out->minMemoryMapAlignment = data.minMemoryMapAlignment(); + + out->minTexelBufferOffsetAlignment = data.minTexelBufferOffsetAlignment(); + + out->minUniformBufferOffsetAlignment = data.minUniformBufferOffsetAlignment(); + + out->minStorageBufferOffsetAlignment = data.minStorageBufferOffsetAlignment(); + + out->minTexelOffset = data.minTexelOffset(); + + out->maxTexelOffset = data.maxTexelOffset(); + + out->minTexelGatherOffset = data.minTexelGatherOffset(); + + out->maxTexelGatherOffset = data.maxTexelGatherOffset(); + + out->minInterpolationOffset = data.minInterpolationOffset(); + + out->maxInterpolationOffset = data.maxInterpolationOffset(); + + out->subPixelInterpolationOffsetBits = data.subPixelInterpolationOffsetBits(); + + out->maxFramebufferWidth = data.maxFramebufferWidth(); + + out->maxFramebufferHeight = data.maxFramebufferHeight(); + + out->maxFramebufferLayers = data.maxFramebufferLayers(); + + out->framebufferColorSampleCounts = data.framebufferColorSampleCounts(); + + out->framebufferDepthSampleCounts = data.framebufferDepthSampleCounts(); + + out->framebufferStencilSampleCounts = data.framebufferStencilSampleCounts(); + + out->framebufferNoAttachmentsSampleCounts = + data.framebufferNoAttachmentsSampleCounts(); + + out->maxColorAttachments = data.maxColorAttachments(); + + out->sampledImageColorSampleCounts = data.sampledImageColorSampleCounts(); + + out->sampledImageIntegerSampleCounts = data.sampledImageIntegerSampleCounts(); + + out->sampledImageDepthSampleCounts = data.sampledImageDepthSampleCounts(); + + out->sampledImageStencilSampleCounts = data.sampledImageStencilSampleCounts(); + + out->storageImageSampleCounts = data.storageImageSampleCounts(); + + out->maxSampleMaskWords = data.maxSampleMaskWords(); + + out->timestampComputeAndGraphics = data.timestampComputeAndGraphics(); + + out->timestampPeriod = data.timestampPeriod(); + + out->maxClipDistances = data.maxClipDistances(); + + out->maxCullDistances = data.maxCullDistances(); + + out->maxCombinedClipAndCullDistances = data.maxCombinedClipAndCullDistances(); + + out->discreteQueuePriorities = data.discreteQueuePriorities(); + + base::span<float> pointSizeRange(out->pointSizeRange); + if (!data.ReadPointSizeRange(&pointSizeRange)) + return false; + + base::span<float> lineWidthRange(out->lineWidthRange); + if (!data.ReadLineWidthRange(&lineWidthRange)) + return false; + + out->pointSizeGranularity = data.pointSizeGranularity(); + + out->lineWidthGranularity = data.lineWidthGranularity(); + + out->strictLines = data.strictLines(); + + out->standardSampleLocations = data.standardSampleLocations(); + + out->optimalBufferCopyOffsetAlignment = + data.optimalBufferCopyOffsetAlignment(); + + out->optimalBufferCopyRowPitchAlignment = + data.optimalBufferCopyRowPitchAlignment(); + + out->nonCoherentAtomSize = data.nonCoherentAtomSize(); + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkPhysicalDeviceSparsePropertiesDataView, + VkPhysicalDeviceSparseProperties>:: + Read(gpu::mojom::VkPhysicalDeviceSparsePropertiesDataView data, + VkPhysicalDeviceSparseProperties* out) { + out->residencyStandard2DBlockShape = data.residencyStandard2DBlockShape(); + + out->residencyStandard2DMultisampleBlockShape = + data.residencyStandard2DMultisampleBlockShape(); + + out->residencyStandard3DBlockShape = data.residencyStandard3DBlockShape(); + + out->residencyAlignedMipSize = data.residencyAlignedMipSize(); + + out->residencyNonResidentStrict = data.residencyNonResidentStrict(); + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkPhysicalDeviceFeaturesDataView, + VkPhysicalDeviceFeatures>:: + Read(gpu::mojom::VkPhysicalDeviceFeaturesDataView data, + VkPhysicalDeviceFeatures* out) { + out->robustBufferAccess = data.robustBufferAccess(); + + out->fullDrawIndexUint32 = data.fullDrawIndexUint32(); + + out->imageCubeArray = data.imageCubeArray(); + + out->independentBlend = data.independentBlend(); + + out->geometryShader = data.geometryShader(); + + out->tessellationShader = data.tessellationShader(); + + out->sampleRateShading = data.sampleRateShading(); + + out->dualSrcBlend = data.dualSrcBlend(); + + out->logicOp = data.logicOp(); + + out->multiDrawIndirect = data.multiDrawIndirect(); + + out->drawIndirectFirstInstance = data.drawIndirectFirstInstance(); + + out->depthClamp = data.depthClamp(); + + out->depthBiasClamp = data.depthBiasClamp(); + + out->fillModeNonSolid = data.fillModeNonSolid(); + + out->depthBounds = data.depthBounds(); + + out->wideLines = data.wideLines(); + + out->largePoints = data.largePoints(); + + out->alphaToOne = data.alphaToOne(); + + out->multiViewport = data.multiViewport(); + + out->samplerAnisotropy = data.samplerAnisotropy(); + + out->textureCompressionETC2 = data.textureCompressionETC2(); + + out->textureCompressionASTC_LDR = data.textureCompressionASTC_LDR(); + + out->textureCompressionBC = data.textureCompressionBC(); + + out->occlusionQueryPrecise = data.occlusionQueryPrecise(); + + out->pipelineStatisticsQuery = data.pipelineStatisticsQuery(); + + out->vertexPipelineStoresAndAtomics = data.vertexPipelineStoresAndAtomics(); + + out->fragmentStoresAndAtomics = data.fragmentStoresAndAtomics(); + + out->shaderTessellationAndGeometryPointSize = + data.shaderTessellationAndGeometryPointSize(); + + out->shaderImageGatherExtended = data.shaderImageGatherExtended(); + + out->shaderStorageImageExtendedFormats = + data.shaderStorageImageExtendedFormats(); + + out->shaderStorageImageMultisample = data.shaderStorageImageMultisample(); + + out->shaderStorageImageReadWithoutFormat = + data.shaderStorageImageReadWithoutFormat(); + + out->shaderStorageImageWriteWithoutFormat = + data.shaderStorageImageWriteWithoutFormat(); + + out->shaderUniformBufferArrayDynamicIndexing = + data.shaderUniformBufferArrayDynamicIndexing(); + + out->shaderSampledImageArrayDynamicIndexing = + data.shaderSampledImageArrayDynamicIndexing(); + + out->shaderStorageBufferArrayDynamicIndexing = + data.shaderStorageBufferArrayDynamicIndexing(); + + out->shaderStorageImageArrayDynamicIndexing = + data.shaderStorageImageArrayDynamicIndexing(); + + out->shaderClipDistance = data.shaderClipDistance(); + + out->shaderCullDistance = data.shaderCullDistance(); + + out->shaderFloat64 = data.shaderFloat64(); + + out->shaderInt64 = data.shaderInt64(); + + out->shaderInt16 = data.shaderInt16(); + + out->shaderResourceResidency = data.shaderResourceResidency(); + + out->shaderResourceMinLod = data.shaderResourceMinLod(); + + out->sparseBinding = data.sparseBinding(); + + out->sparseResidencyBuffer = data.sparseResidencyBuffer(); + + out->sparseResidencyImage2D = data.sparseResidencyImage2D(); + + out->sparseResidencyImage3D = data.sparseResidencyImage3D(); + + out->sparseResidency2Samples = data.sparseResidency2Samples(); + + out->sparseResidency4Samples = data.sparseResidency4Samples(); + + out->sparseResidency8Samples = data.sparseResidency8Samples(); + + out->sparseResidency16Samples = data.sparseResidency16Samples(); + + out->sparseResidencyAliased = data.sparseResidencyAliased(); + + out->variableMultisampleRate = data.variableMultisampleRate(); + + out->inheritedQueries = data.inheritedQueries(); + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkQueueFamilyPropertiesDataView, + VkQueueFamilyProperties>:: + Read(gpu::mojom::VkQueueFamilyPropertiesDataView data, + VkQueueFamilyProperties* out) { + out->queueFlags = data.queueFlags(); + + out->queueCount = data.queueCount(); + + out->timestampValidBits = data.timestampValidBits(); + + if (!data.ReadMinImageTransferGranularity(&out->minImageTransferGranularity)) + return false; + + return true; +} + +// static +bool StructTraits<gpu::mojom::VkExtent3DDataView, VkExtent3D>::Read( + gpu::mojom::VkExtent3DDataView data, + VkExtent3D* out) { + out->width = data.width(); + + out->height = data.height(); + + out->depth = data.depth(); + + return true; +} + +} // namespace mojo \ No newline at end of file
diff --git a/gpu/ipc/common/vulkan_types_mojom_traits.h b/gpu/ipc/common/vulkan_types_mojom_traits.h new file mode 100644 index 0000000..fa4aef9 --- /dev/null +++ b/gpu/ipc/common/vulkan_types_mojom_traits.h
@@ -0,0 +1,951 @@ +// 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. + +// This file is auto-generated from +// gpu/ipc/common/generate_vulkan_types.py +// It's formatted by clang-format using chromium coding style: +// clang-format -i -style=chromium filename +// DO NOT EDIT! + +#ifndef GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_ +#define GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_ + +#include "base/containers/span.h" +#include "base/strings/string_piece.h" +#include "gpu/ipc/common/vulkan_types.h" +#include "gpu/ipc/common/vulkan_types.mojom-shared.h" + +namespace mojo { + +template <> +struct StructTraits<gpu::mojom::VkExtensionPropertiesDataView, + VkExtensionProperties> { + static base::StringPiece extensionName(const VkExtensionProperties& input) { + return input.extensionName; + } + + static uint32_t specVersion(const VkExtensionProperties& input) { + return input.specVersion; + } + + static bool Read(gpu::mojom::VkExtensionPropertiesDataView data, + VkExtensionProperties* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkLayerPropertiesDataView, VkLayerProperties> { + static base::StringPiece layerName(const VkLayerProperties& input) { + return input.layerName; + } + + static uint32_t specVersion(const VkLayerProperties& input) { + return input.specVersion; + } + + static uint32_t implementationVersion(const VkLayerProperties& input) { + return input.implementationVersion; + } + + static base::StringPiece description(const VkLayerProperties& input) { + return input.description; + } + + static bool Read(gpu::mojom::VkLayerPropertiesDataView data, + VkLayerProperties* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkPhysicalDevicePropertiesDataView, + VkPhysicalDeviceProperties> { + static uint32_t apiVersion(const VkPhysicalDeviceProperties& input) { + return input.apiVersion; + } + + static uint32_t driverVersion(const VkPhysicalDeviceProperties& input) { + return input.driverVersion; + } + + static uint32_t vendorID(const VkPhysicalDeviceProperties& input) { + return input.vendorID; + } + + static uint32_t deviceID(const VkPhysicalDeviceProperties& input) { + return input.deviceID; + } + + static VkPhysicalDeviceType deviceType( + const VkPhysicalDeviceProperties& input) { + return input.deviceType; + } + + static base::StringPiece deviceName(const VkPhysicalDeviceProperties& input) { + return input.deviceName; + } + + static base::span<const uint8_t> pipelineCacheUUID( + const VkPhysicalDeviceProperties& input) { + return input.pipelineCacheUUID; + } + + static const VkPhysicalDeviceLimits& limits( + const VkPhysicalDeviceProperties& input) { + return input.limits; + } + + static const VkPhysicalDeviceSparseProperties& sparseProperties( + const VkPhysicalDeviceProperties& input) { + return input.sparseProperties; + } + + static bool Read(gpu::mojom::VkPhysicalDevicePropertiesDataView data, + VkPhysicalDeviceProperties* out); +}; + +template <> +struct EnumTraits<gpu::mojom::VkPhysicalDeviceType, VkPhysicalDeviceType> { + static gpu::mojom::VkPhysicalDeviceType ToMojom(VkPhysicalDeviceType input) { + switch (input) { + case VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_OTHER: + return gpu::mojom::VkPhysicalDeviceType::OTHER; + case VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU: + return gpu::mojom::VkPhysicalDeviceType::INTEGRATED_GPU; + case VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU: + return gpu::mojom::VkPhysicalDeviceType::DISCRETE_GPU; + case VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU: + return gpu::mojom::VkPhysicalDeviceType::VIRTUAL_GPU; + case VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU: + return gpu::mojom::VkPhysicalDeviceType::CPU; + default: + NOTREACHED(); + return gpu::mojom::VkPhysicalDeviceType::INVALID_VALUE; + } + } + + static bool FromMojom(gpu::mojom::VkPhysicalDeviceType input, + VkPhysicalDeviceType* out) { + switch (input) { + case gpu::mojom::VkPhysicalDeviceType::OTHER: + *out = VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_OTHER; + return true; + case gpu::mojom::VkPhysicalDeviceType::INTEGRATED_GPU: + *out = VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU; + return true; + case gpu::mojom::VkPhysicalDeviceType::DISCRETE_GPU: + *out = VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU; + return true; + case gpu::mojom::VkPhysicalDeviceType::VIRTUAL_GPU: + *out = VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU; + return true; + case gpu::mojom::VkPhysicalDeviceType::CPU: + *out = VkPhysicalDeviceType::VK_PHYSICAL_DEVICE_TYPE_CPU; + return true; + case gpu::mojom::VkPhysicalDeviceType::INVALID_VALUE: + NOTREACHED(); + return false; + } + NOTREACHED(); + return false; + } +}; +template <> +struct StructTraits<gpu::mojom::VkPhysicalDeviceLimitsDataView, + VkPhysicalDeviceLimits> { + static uint32_t maxImageDimension1D(const VkPhysicalDeviceLimits& input) { + return input.maxImageDimension1D; + } + + static uint32_t maxImageDimension2D(const VkPhysicalDeviceLimits& input) { + return input.maxImageDimension2D; + } + + static uint32_t maxImageDimension3D(const VkPhysicalDeviceLimits& input) { + return input.maxImageDimension3D; + } + + static uint32_t maxImageDimensionCube(const VkPhysicalDeviceLimits& input) { + return input.maxImageDimensionCube; + } + + static uint32_t maxImageArrayLayers(const VkPhysicalDeviceLimits& input) { + return input.maxImageArrayLayers; + } + + static uint32_t maxTexelBufferElements(const VkPhysicalDeviceLimits& input) { + return input.maxTexelBufferElements; + } + + static uint32_t maxUniformBufferRange(const VkPhysicalDeviceLimits& input) { + return input.maxUniformBufferRange; + } + + static uint32_t maxStorageBufferRange(const VkPhysicalDeviceLimits& input) { + return input.maxStorageBufferRange; + } + + static uint32_t maxPushConstantsSize(const VkPhysicalDeviceLimits& input) { + return input.maxPushConstantsSize; + } + + static uint32_t maxMemoryAllocationCount( + const VkPhysicalDeviceLimits& input) { + return input.maxMemoryAllocationCount; + } + + static uint32_t maxSamplerAllocationCount( + const VkPhysicalDeviceLimits& input) { + return input.maxSamplerAllocationCount; + } + + static bool bufferImageGranularity(const VkPhysicalDeviceLimits& input) { + return input.bufferImageGranularity; + } + + static bool sparseAddressSpaceSize(const VkPhysicalDeviceLimits& input) { + return input.sparseAddressSpaceSize; + } + + static uint32_t maxBoundDescriptorSets(const VkPhysicalDeviceLimits& input) { + return input.maxBoundDescriptorSets; + } + + static uint32_t maxPerStageDescriptorSamplers( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorSamplers; + } + + static uint32_t maxPerStageDescriptorUniformBuffers( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorUniformBuffers; + } + + static uint32_t maxPerStageDescriptorStorageBuffers( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorStorageBuffers; + } + + static uint32_t maxPerStageDescriptorSampledImages( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorSampledImages; + } + + static uint32_t maxPerStageDescriptorStorageImages( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorStorageImages; + } + + static uint32_t maxPerStageDescriptorInputAttachments( + const VkPhysicalDeviceLimits& input) { + return input.maxPerStageDescriptorInputAttachments; + } + + static uint32_t maxPerStageResources(const VkPhysicalDeviceLimits& input) { + return input.maxPerStageResources; + } + + static uint32_t maxDescriptorSetSamplers( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetSamplers; + } + + static uint32_t maxDescriptorSetUniformBuffers( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetUniformBuffers; + } + + static uint32_t maxDescriptorSetUniformBuffersDynamic( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetUniformBuffersDynamic; + } + + static uint32_t maxDescriptorSetStorageBuffers( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetStorageBuffers; + } + + static uint32_t maxDescriptorSetStorageBuffersDynamic( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetStorageBuffersDynamic; + } + + static uint32_t maxDescriptorSetSampledImages( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetSampledImages; + } + + static uint32_t maxDescriptorSetStorageImages( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetStorageImages; + } + + static uint32_t maxDescriptorSetInputAttachments( + const VkPhysicalDeviceLimits& input) { + return input.maxDescriptorSetInputAttachments; + } + + static uint32_t maxVertexInputAttributes( + const VkPhysicalDeviceLimits& input) { + return input.maxVertexInputAttributes; + } + + static uint32_t maxVertexInputBindings(const VkPhysicalDeviceLimits& input) { + return input.maxVertexInputBindings; + } + + static uint32_t maxVertexInputAttributeOffset( + const VkPhysicalDeviceLimits& input) { + return input.maxVertexInputAttributeOffset; + } + + static uint32_t maxVertexInputBindingStride( + const VkPhysicalDeviceLimits& input) { + return input.maxVertexInputBindingStride; + } + + static uint32_t maxVertexOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxVertexOutputComponents; + } + + static uint32_t maxTessellationGenerationLevel( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationGenerationLevel; + } + + static uint32_t maxTessellationPatchSize( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationPatchSize; + } + + static uint32_t maxTessellationControlPerVertexInputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationControlPerVertexInputComponents; + } + + static uint32_t maxTessellationControlPerVertexOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationControlPerVertexOutputComponents; + } + + static uint32_t maxTessellationControlPerPatchOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationControlPerPatchOutputComponents; + } + + static uint32_t maxTessellationControlTotalOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationControlTotalOutputComponents; + } + + static uint32_t maxTessellationEvaluationInputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationEvaluationInputComponents; + } + + static uint32_t maxTessellationEvaluationOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxTessellationEvaluationOutputComponents; + } + + static uint32_t maxGeometryShaderInvocations( + const VkPhysicalDeviceLimits& input) { + return input.maxGeometryShaderInvocations; + } + + static uint32_t maxGeometryInputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxGeometryInputComponents; + } + + static uint32_t maxGeometryOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxGeometryOutputComponents; + } + + static uint32_t maxGeometryOutputVertices( + const VkPhysicalDeviceLimits& input) { + return input.maxGeometryOutputVertices; + } + + static uint32_t maxGeometryTotalOutputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxGeometryTotalOutputComponents; + } + + static uint32_t maxFragmentInputComponents( + const VkPhysicalDeviceLimits& input) { + return input.maxFragmentInputComponents; + } + + static uint32_t maxFragmentOutputAttachments( + const VkPhysicalDeviceLimits& input) { + return input.maxFragmentOutputAttachments; + } + + static uint32_t maxFragmentDualSrcAttachments( + const VkPhysicalDeviceLimits& input) { + return input.maxFragmentDualSrcAttachments; + } + + static uint32_t maxFragmentCombinedOutputResources( + const VkPhysicalDeviceLimits& input) { + return input.maxFragmentCombinedOutputResources; + } + + static uint32_t maxComputeSharedMemorySize( + const VkPhysicalDeviceLimits& input) { + return input.maxComputeSharedMemorySize; + } + + static base::span<const uint32_t> maxComputeWorkGroupCount( + const VkPhysicalDeviceLimits& input) { + return input.maxComputeWorkGroupCount; + } + + static uint32_t maxComputeWorkGroupInvocations( + const VkPhysicalDeviceLimits& input) { + return input.maxComputeWorkGroupInvocations; + } + + static base::span<const uint32_t> maxComputeWorkGroupSize( + const VkPhysicalDeviceLimits& input) { + return input.maxComputeWorkGroupSize; + } + + static uint32_t subPixelPrecisionBits(const VkPhysicalDeviceLimits& input) { + return input.subPixelPrecisionBits; + } + + static uint32_t subTexelPrecisionBits(const VkPhysicalDeviceLimits& input) { + return input.subTexelPrecisionBits; + } + + static uint32_t mipmapPrecisionBits(const VkPhysicalDeviceLimits& input) { + return input.mipmapPrecisionBits; + } + + static uint32_t maxDrawIndexedIndexValue( + const VkPhysicalDeviceLimits& input) { + return input.maxDrawIndexedIndexValue; + } + + static uint32_t maxDrawIndirectCount(const VkPhysicalDeviceLimits& input) { + return input.maxDrawIndirectCount; + } + + static float maxSamplerLodBias(const VkPhysicalDeviceLimits& input) { + return input.maxSamplerLodBias; + } + + static float maxSamplerAnisotropy(const VkPhysicalDeviceLimits& input) { + return input.maxSamplerAnisotropy; + } + + static uint32_t maxViewports(const VkPhysicalDeviceLimits& input) { + return input.maxViewports; + } + + static base::span<const uint32_t> maxViewportDimensions( + const VkPhysicalDeviceLimits& input) { + return input.maxViewportDimensions; + } + + static base::span<const float> viewportBoundsRange( + const VkPhysicalDeviceLimits& input) { + return input.viewportBoundsRange; + } + + static uint32_t viewportSubPixelBits(const VkPhysicalDeviceLimits& input) { + return input.viewportSubPixelBits; + } + + static size_t minMemoryMapAlignment(const VkPhysicalDeviceLimits& input) { + return input.minMemoryMapAlignment; + } + + static bool minTexelBufferOffsetAlignment( + const VkPhysicalDeviceLimits& input) { + return input.minTexelBufferOffsetAlignment; + } + + static bool minUniformBufferOffsetAlignment( + const VkPhysicalDeviceLimits& input) { + return input.minUniformBufferOffsetAlignment; + } + + static bool minStorageBufferOffsetAlignment( + const VkPhysicalDeviceLimits& input) { + return input.minStorageBufferOffsetAlignment; + } + + static int32_t minTexelOffset(const VkPhysicalDeviceLimits& input) { + return input.minTexelOffset; + } + + static uint32_t maxTexelOffset(const VkPhysicalDeviceLimits& input) { + return input.maxTexelOffset; + } + + static int32_t minTexelGatherOffset(const VkPhysicalDeviceLimits& input) { + return input.minTexelGatherOffset; + } + + static uint32_t maxTexelGatherOffset(const VkPhysicalDeviceLimits& input) { + return input.maxTexelGatherOffset; + } + + static float minInterpolationOffset(const VkPhysicalDeviceLimits& input) { + return input.minInterpolationOffset; + } + + static float maxInterpolationOffset(const VkPhysicalDeviceLimits& input) { + return input.maxInterpolationOffset; + } + + static uint32_t subPixelInterpolationOffsetBits( + const VkPhysicalDeviceLimits& input) { + return input.subPixelInterpolationOffsetBits; + } + + static uint32_t maxFramebufferWidth(const VkPhysicalDeviceLimits& input) { + return input.maxFramebufferWidth; + } + + static uint32_t maxFramebufferHeight(const VkPhysicalDeviceLimits& input) { + return input.maxFramebufferHeight; + } + + static uint32_t maxFramebufferLayers(const VkPhysicalDeviceLimits& input) { + return input.maxFramebufferLayers; + } + + static VkSampleCountFlags framebufferColorSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.framebufferColorSampleCounts; + } + + static VkSampleCountFlags framebufferDepthSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.framebufferDepthSampleCounts; + } + + static VkSampleCountFlags framebufferStencilSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.framebufferStencilSampleCounts; + } + + static VkSampleCountFlags framebufferNoAttachmentsSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.framebufferNoAttachmentsSampleCounts; + } + + static uint32_t maxColorAttachments(const VkPhysicalDeviceLimits& input) { + return input.maxColorAttachments; + } + + static VkSampleCountFlags sampledImageColorSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.sampledImageColorSampleCounts; + } + + static VkSampleCountFlags sampledImageIntegerSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.sampledImageIntegerSampleCounts; + } + + static VkSampleCountFlags sampledImageDepthSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.sampledImageDepthSampleCounts; + } + + static VkSampleCountFlags sampledImageStencilSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.sampledImageStencilSampleCounts; + } + + static VkSampleCountFlags storageImageSampleCounts( + const VkPhysicalDeviceLimits& input) { + return input.storageImageSampleCounts; + } + + static uint32_t maxSampleMaskWords(const VkPhysicalDeviceLimits& input) { + return input.maxSampleMaskWords; + } + + static bool timestampComputeAndGraphics(const VkPhysicalDeviceLimits& input) { + return input.timestampComputeAndGraphics; + } + + static float timestampPeriod(const VkPhysicalDeviceLimits& input) { + return input.timestampPeriod; + } + + static uint32_t maxClipDistances(const VkPhysicalDeviceLimits& input) { + return input.maxClipDistances; + } + + static uint32_t maxCullDistances(const VkPhysicalDeviceLimits& input) { + return input.maxCullDistances; + } + + static uint32_t maxCombinedClipAndCullDistances( + const VkPhysicalDeviceLimits& input) { + return input.maxCombinedClipAndCullDistances; + } + + static uint32_t discreteQueuePriorities(const VkPhysicalDeviceLimits& input) { + return input.discreteQueuePriorities; + } + + static base::span<const float> pointSizeRange( + const VkPhysicalDeviceLimits& input) { + return input.pointSizeRange; + } + + static base::span<const float> lineWidthRange( + const VkPhysicalDeviceLimits& input) { + return input.lineWidthRange; + } + + static float pointSizeGranularity(const VkPhysicalDeviceLimits& input) { + return input.pointSizeGranularity; + } + + static float lineWidthGranularity(const VkPhysicalDeviceLimits& input) { + return input.lineWidthGranularity; + } + + static bool strictLines(const VkPhysicalDeviceLimits& input) { + return input.strictLines; + } + + static bool standardSampleLocations(const VkPhysicalDeviceLimits& input) { + return input.standardSampleLocations; + } + + static bool optimalBufferCopyOffsetAlignment( + const VkPhysicalDeviceLimits& input) { + return input.optimalBufferCopyOffsetAlignment; + } + + static bool optimalBufferCopyRowPitchAlignment( + const VkPhysicalDeviceLimits& input) { + return input.optimalBufferCopyRowPitchAlignment; + } + + static bool nonCoherentAtomSize(const VkPhysicalDeviceLimits& input) { + return input.nonCoherentAtomSize; + } + + static bool Read(gpu::mojom::VkPhysicalDeviceLimitsDataView data, + VkPhysicalDeviceLimits* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkPhysicalDeviceSparsePropertiesDataView, + VkPhysicalDeviceSparseProperties> { + static bool residencyStandard2DBlockShape( + const VkPhysicalDeviceSparseProperties& input) { + return input.residencyStandard2DBlockShape; + } + + static bool residencyStandard2DMultisampleBlockShape( + const VkPhysicalDeviceSparseProperties& input) { + return input.residencyStandard2DMultisampleBlockShape; + } + + static bool residencyStandard3DBlockShape( + const VkPhysicalDeviceSparseProperties& input) { + return input.residencyStandard3DBlockShape; + } + + static bool residencyAlignedMipSize( + const VkPhysicalDeviceSparseProperties& input) { + return input.residencyAlignedMipSize; + } + + static bool residencyNonResidentStrict( + const VkPhysicalDeviceSparseProperties& input) { + return input.residencyNonResidentStrict; + } + + static bool Read(gpu::mojom::VkPhysicalDeviceSparsePropertiesDataView data, + VkPhysicalDeviceSparseProperties* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkPhysicalDeviceFeaturesDataView, + VkPhysicalDeviceFeatures> { + static bool robustBufferAccess(const VkPhysicalDeviceFeatures& input) { + return input.robustBufferAccess; + } + + static bool fullDrawIndexUint32(const VkPhysicalDeviceFeatures& input) { + return input.fullDrawIndexUint32; + } + + static bool imageCubeArray(const VkPhysicalDeviceFeatures& input) { + return input.imageCubeArray; + } + + static bool independentBlend(const VkPhysicalDeviceFeatures& input) { + return input.independentBlend; + } + + static bool geometryShader(const VkPhysicalDeviceFeatures& input) { + return input.geometryShader; + } + + static bool tessellationShader(const VkPhysicalDeviceFeatures& input) { + return input.tessellationShader; + } + + static bool sampleRateShading(const VkPhysicalDeviceFeatures& input) { + return input.sampleRateShading; + } + + static bool dualSrcBlend(const VkPhysicalDeviceFeatures& input) { + return input.dualSrcBlend; + } + + static bool logicOp(const VkPhysicalDeviceFeatures& input) { + return input.logicOp; + } + + static bool multiDrawIndirect(const VkPhysicalDeviceFeatures& input) { + return input.multiDrawIndirect; + } + + static bool drawIndirectFirstInstance(const VkPhysicalDeviceFeatures& input) { + return input.drawIndirectFirstInstance; + } + + static bool depthClamp(const VkPhysicalDeviceFeatures& input) { + return input.depthClamp; + } + + static bool depthBiasClamp(const VkPhysicalDeviceFeatures& input) { + return input.depthBiasClamp; + } + + static bool fillModeNonSolid(const VkPhysicalDeviceFeatures& input) { + return input.fillModeNonSolid; + } + + static bool depthBounds(const VkPhysicalDeviceFeatures& input) { + return input.depthBounds; + } + + static bool wideLines(const VkPhysicalDeviceFeatures& input) { + return input.wideLines; + } + + static bool largePoints(const VkPhysicalDeviceFeatures& input) { + return input.largePoints; + } + + static bool alphaToOne(const VkPhysicalDeviceFeatures& input) { + return input.alphaToOne; + } + + static bool multiViewport(const VkPhysicalDeviceFeatures& input) { + return input.multiViewport; + } + + static bool samplerAnisotropy(const VkPhysicalDeviceFeatures& input) { + return input.samplerAnisotropy; + } + + static bool textureCompressionETC2(const VkPhysicalDeviceFeatures& input) { + return input.textureCompressionETC2; + } + + static bool textureCompressionASTC_LDR( + const VkPhysicalDeviceFeatures& input) { + return input.textureCompressionASTC_LDR; + } + + static bool textureCompressionBC(const VkPhysicalDeviceFeatures& input) { + return input.textureCompressionBC; + } + + static bool occlusionQueryPrecise(const VkPhysicalDeviceFeatures& input) { + return input.occlusionQueryPrecise; + } + + static bool pipelineStatisticsQuery(const VkPhysicalDeviceFeatures& input) { + return input.pipelineStatisticsQuery; + } + + static bool vertexPipelineStoresAndAtomics( + const VkPhysicalDeviceFeatures& input) { + return input.vertexPipelineStoresAndAtomics; + } + + static bool fragmentStoresAndAtomics(const VkPhysicalDeviceFeatures& input) { + return input.fragmentStoresAndAtomics; + } + + static bool shaderTessellationAndGeometryPointSize( + const VkPhysicalDeviceFeatures& input) { + return input.shaderTessellationAndGeometryPointSize; + } + + static bool shaderImageGatherExtended(const VkPhysicalDeviceFeatures& input) { + return input.shaderImageGatherExtended; + } + + static bool shaderStorageImageExtendedFormats( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageImageExtendedFormats; + } + + static bool shaderStorageImageMultisample( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageImageMultisample; + } + + static bool shaderStorageImageReadWithoutFormat( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageImageReadWithoutFormat; + } + + static bool shaderStorageImageWriteWithoutFormat( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageImageWriteWithoutFormat; + } + + static bool shaderUniformBufferArrayDynamicIndexing( + const VkPhysicalDeviceFeatures& input) { + return input.shaderUniformBufferArrayDynamicIndexing; + } + + static bool shaderSampledImageArrayDynamicIndexing( + const VkPhysicalDeviceFeatures& input) { + return input.shaderSampledImageArrayDynamicIndexing; + } + + static bool shaderStorageBufferArrayDynamicIndexing( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageBufferArrayDynamicIndexing; + } + + static bool shaderStorageImageArrayDynamicIndexing( + const VkPhysicalDeviceFeatures& input) { + return input.shaderStorageImageArrayDynamicIndexing; + } + + static bool shaderClipDistance(const VkPhysicalDeviceFeatures& input) { + return input.shaderClipDistance; + } + + static bool shaderCullDistance(const VkPhysicalDeviceFeatures& input) { + return input.shaderCullDistance; + } + + static bool shaderFloat64(const VkPhysicalDeviceFeatures& input) { + return input.shaderFloat64; + } + + static bool shaderInt64(const VkPhysicalDeviceFeatures& input) { + return input.shaderInt64; + } + + static bool shaderInt16(const VkPhysicalDeviceFeatures& input) { + return input.shaderInt16; + } + + static bool shaderResourceResidency(const VkPhysicalDeviceFeatures& input) { + return input.shaderResourceResidency; + } + + static bool shaderResourceMinLod(const VkPhysicalDeviceFeatures& input) { + return input.shaderResourceMinLod; + } + + static bool sparseBinding(const VkPhysicalDeviceFeatures& input) { + return input.sparseBinding; + } + + static bool sparseResidencyBuffer(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidencyBuffer; + } + + static bool sparseResidencyImage2D(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidencyImage2D; + } + + static bool sparseResidencyImage3D(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidencyImage3D; + } + + static bool sparseResidency2Samples(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidency2Samples; + } + + static bool sparseResidency4Samples(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidency4Samples; + } + + static bool sparseResidency8Samples(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidency8Samples; + } + + static bool sparseResidency16Samples(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidency16Samples; + } + + static bool sparseResidencyAliased(const VkPhysicalDeviceFeatures& input) { + return input.sparseResidencyAliased; + } + + static bool variableMultisampleRate(const VkPhysicalDeviceFeatures& input) { + return input.variableMultisampleRate; + } + + static bool inheritedQueries(const VkPhysicalDeviceFeatures& input) { + return input.inheritedQueries; + } + + static bool Read(gpu::mojom::VkPhysicalDeviceFeaturesDataView data, + VkPhysicalDeviceFeatures* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkQueueFamilyPropertiesDataView, + VkQueueFamilyProperties> { + static VkQueueFlags queueFlags(const VkQueueFamilyProperties& input) { + return input.queueFlags; + } + + static uint32_t queueCount(const VkQueueFamilyProperties& input) { + return input.queueCount; + } + + static uint32_t timestampValidBits(const VkQueueFamilyProperties& input) { + return input.timestampValidBits; + } + + static const VkExtent3D& minImageTransferGranularity( + const VkQueueFamilyProperties& input) { + return input.minImageTransferGranularity; + } + + static bool Read(gpu::mojom::VkQueueFamilyPropertiesDataView data, + VkQueueFamilyProperties* out); +}; + +template <> +struct StructTraits<gpu::mojom::VkExtent3DDataView, VkExtent3D> { + static uint32_t width(const VkExtent3D& input) { return input.width; } + + static uint32_t height(const VkExtent3D& input) { return input.height; } + + static uint32_t depth(const VkExtent3D& input) { return input.depth; } + + static bool Read(gpu::mojom::VkExtent3DDataView data, VkExtent3D* out); +}; + +} // namespace mojo + +#endif // GPU_IPC_COMMON_VULKAN_TYPES_MOJOM_TRAITS_H_ \ No newline at end of file
diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn index 892f58f..c3ca00c 100644 --- a/gpu/ipc/service/BUILD.gn +++ b/gpu/ipc/service/BUILD.gn
@@ -62,6 +62,7 @@ public_deps = [ "//base", "//components/viz/common", + "//gpu/config", "//ipc", "//ui/base", "//ui/display",
diff --git a/gpu/ipc/service/gpu_init.cc b/gpu/ipc/service/gpu_init.cc index 9ba7856..f61ea9e 100644 --- a/gpu/ipc/service/gpu_init.cc +++ b/gpu/ipc/service/gpu_init.cc
@@ -51,6 +51,7 @@ #if BUILDFLAG(ENABLE_VULKAN) #include "gpu/vulkan/init/vulkan_factory.h" #include "gpu/vulkan/vulkan_implementation.h" +#include "gpu/vulkan/vulkan_instance.h" #endif namespace gpu { @@ -659,6 +660,9 @@ gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone; gpu_feature_info_.status_values[gpu::GPU_FEATURE_TYPE_VULKAN] = gpu::kGpuFeatureStatusDisabled; + } else { + gpu_info_.vulkan_info = + vulkan_implementation_->GetVulkanInstance()->vulkan_info(); } #else gpu_preferences_.use_vulkan = gpu::VulkanImplementationName::kNone;
diff --git a/gpu/vulkan/BUILD.gn b/gpu/vulkan/BUILD.gn index 7d1331f..64500bfc 100644 --- a/gpu/vulkan/BUILD.gn +++ b/gpu/vulkan/BUILD.gn
@@ -43,8 +43,6 @@ "vulkan_function_pointers.h", "vulkan_implementation.cc", "vulkan_implementation.h", - "vulkan_info.cc", - "vulkan_info.h", "vulkan_instance.cc", "vulkan_instance.h", "vulkan_surface.cc", @@ -69,7 +67,9 @@ "//base", "//ui/gfx", ] - public_deps = [] + public_deps = [ + "//gpu/config:vulkan_info", + ] data_deps = [] if (is_posix) {
diff --git a/gpu/vulkan/PRESUBMIT.py b/gpu/vulkan/PRESUBMIT.py index c5f3fd89..8d61974 100644 --- a/gpu/vulkan/PRESUBMIT.py +++ b/gpu/vulkan/PRESUBMIT.py
@@ -22,7 +22,7 @@ messages = [] - if (len(generated_files) > 0 and len(generating_files) == 0): + if generated_files and not generating_files: long_text = 'Changed files:\n' for file in generated_files: long_text += file.LocalPath() + '\n' @@ -33,7 +33,7 @@ with input_api.temporary_directory() as temp_dir: commands = [] - if len(generating_files) > 0: + if generating_files: commands.append(input_api.Command(name='generate_bindings', cmd=[input_api.python_executable, 'generate_bindings.py', @@ -41,7 +41,7 @@ '--output-dir=' + temp_dir], kwargs={}, message=output_api.PresubmitError)) - if len(commands) > 0: + if commands: messages.extend(input_api.RunTests(commands)) return messages
diff --git a/gpu/vulkan/vulkan_device_queue.cc b/gpu/vulkan/vulkan_device_queue.cc index 0406917..55266dac 100644 --- a/gpu/vulkan/vulkan_device_queue.cc +++ b/gpu/vulkan/vulkan_device_queue.cc
@@ -8,10 +8,10 @@ #include <utility> #include <vector> +#include "gpu/config/vulkan_info.h" #include "gpu/vulkan/vulkan_command_pool.h" #include "gpu/vulkan/vulkan_fence_helper.h" #include "gpu/vulkan/vulkan_function_pointers.h" -#include "gpu/vulkan/vulkan_info.h" namespace gpu {
diff --git a/gpu/vulkan/vulkan_info.cc b/gpu/vulkan/vulkan_info.cc deleted file mode 100644 index 548a1233..0000000 --- a/gpu/vulkan/vulkan_info.cc +++ /dev/null
@@ -1,18 +0,0 @@ -// 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. - -#include "gpu/vulkan/vulkan_info.h" - -namespace gpu { - -VulkanInfo::VulkanInfo() = default; -VulkanInfo::~VulkanInfo() = default; -VulkanInfo::PhysicalDeviceInfo::PhysicalDeviceInfo() = default; -VulkanInfo::PhysicalDeviceInfo::PhysicalDeviceInfo( - const PhysicalDeviceInfo& other) = default; -VulkanInfo::PhysicalDeviceInfo::~PhysicalDeviceInfo() = default; -VulkanInfo::PhysicalDeviceInfo& VulkanInfo::PhysicalDeviceInfo::operator=( - const PhysicalDeviceInfo& info) = default; - -} // namespace gpu
diff --git a/gpu/vulkan/vulkan_info.h b/gpu/vulkan/vulkan_info.h deleted file mode 100644 index babd2f9..0000000 --- a/gpu/vulkan/vulkan_info.h +++ /dev/null
@@ -1,51 +0,0 @@ -// 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. - -#ifndef GPU_VULKAN_VULKAN_INFO_H_ -#define GPU_VULKAN_VULKAN_INFO_H_ - -#include <vulkan/vulkan.h> -#include <vector> - -#include "base/macros.h" -#include "gpu/vulkan/vulkan_export.h" -#include "ui/gfx/extension_set.h" - -namespace gpu { - -class VULKAN_EXPORT VulkanInfo { - public: - VulkanInfo(); - ~VulkanInfo(); - - class PhysicalDeviceInfo { - public: - PhysicalDeviceInfo(); - PhysicalDeviceInfo(const PhysicalDeviceInfo& other); - ~PhysicalDeviceInfo(); - PhysicalDeviceInfo& operator=(const PhysicalDeviceInfo& other); - - VkPhysicalDevice device = VK_NULL_HANDLE; - VkPhysicalDeviceProperties properties = {}; - std::vector<VkLayerProperties> layers; - - VkPhysicalDeviceFeatures features = {}; - // Extended physical device features: - bool feature_sampler_ycbcr_conversion = false; - bool feature_protected_memory = false; - - std::vector<VkQueueFamilyProperties> queue_families; - }; - - uint32_t api_version = VK_MAKE_VERSION(1, 0, 0); - uint32_t used_api_version = VK_MAKE_VERSION(1, 0, 0); - std::vector<VkExtensionProperties> instance_extensions; - std::vector<const char*> enabled_instance_extensions; - std::vector<VkLayerProperties> instance_layers; - std::vector<PhysicalDeviceInfo> physical_devices; -}; - -} // namespace gpu - -#endif // GPU_VULKAN_VULKAN_INFO_H_
diff --git a/gpu/vulkan/vulkan_instance.h b/gpu/vulkan/vulkan_instance.h index a4656d0..bd0092e 100644 --- a/gpu/vulkan/vulkan_instance.h +++ b/gpu/vulkan/vulkan_instance.h
@@ -10,8 +10,8 @@ #include "base/logging.h" #include "base/macros.h" +#include "gpu/config/vulkan_info.h" #include "gpu/vulkan/vulkan_export.h" -#include "gpu/vulkan/vulkan_info.h" #include "ui/gfx/extension_set.h" namespace gpu {
diff --git a/infra/config/buckets/ci.star b/infra/config/buckets/ci.star index 7fc53029..0dd671b6 100644 --- a/infra/config/buckets/ci.star +++ b/infra/config/buckets/ci.star
@@ -156,6 +156,7 @@ android_builder( name = 'Android ASAN (dbg)', + goma_backend = goma.backend.RBE_PROD, ) android_builder( @@ -185,11 +186,13 @@ android_builder( name = 'Android arm Builder (dbg)', + goma_backend = goma.backend.RBE_PROD, execution_timeout = 4 * time.hour, ) android_builder( name = 'Android arm64 Builder (dbg)', + goma_backend = goma.backend.RBE_PROD, goma_jobs = goma.jobs.MANY_JOBS_FOR_CI, execution_timeout = 4 * time.hour, )
diff --git a/infra/config/buckets/ci/goma.star b/infra/config/buckets/ci/goma.star index 6460cbc..bc25d78a 100644 --- a/infra/config/buckets/ci/goma.star +++ b/infra/config/buckets/ci/goma.star
@@ -480,6 +480,7 @@ goma_builder( name = 'chromeos-amd64-generic-rel (Goma RBE FYI)', builderless = True, + goma_backend = goma.backend.RBE_PROD, goma_enable_ats = True, )
diff --git a/infra/config/buckets/try.star b/infra/config/buckets/try.star index b8fd5c7..71929ac5 100644 --- a/infra/config/buckets/try.star +++ b/infra/config/buckets/try.star
@@ -237,10 +237,12 @@ android_builder( name = 'android-oreo-arm64-dbg', + goma_backend = goma.backend.RBE_PROD, ) android_builder( name = 'android-pie-arm64-dbg', + goma_backend = goma.backend.RBE_PROD, tryjob = tryjob( location_regexp = [ '.+/[+]/chrome/android/java/src/org/chromium/chrome/browser/vr/.+', @@ -256,6 +258,8 @@ android_builder( name = 'android-pie-arm64-rel', + goma_backend = goma.backend.RBE_PROD, + goma_jobs = goma.jobs.J300, tryjob = tryjob( experiment_percentage = 50, ), @@ -287,6 +291,7 @@ android_builder( name = 'android_arm64_dbg_recipe', + goma_backend = goma.backend.RBE_PROD, goma_jobs = goma.jobs.J300, tryjob = tryjob(), ) @@ -303,12 +308,14 @@ android_builder( name = 'android_clang_dbg_recipe', + goma_backend = goma.backend.RBE_PROD, goma_jobs = goma.jobs.J300, tryjob = tryjob(), ) android_builder( name = 'android_compile_dbg', + goma_backend = goma.backend.RBE_PROD, goma_jobs = goma.jobs.J150, tryjob = tryjob(), ) @@ -369,6 +376,7 @@ android_builder( name = 'android_n5x_swarming_dbg', + goma_backend = goma.backend.RBE_PROD, ) android_builder(
diff --git a/infra/config/consoles/chromium.goma.migration.star b/infra/config/consoles/chromium.goma.migration.star index 1f88caa..09e4a41 100644 --- a/infra/config/consoles/chromium.goma.migration.star +++ b/infra/config/consoles/chromium.goma.migration.star
@@ -692,6 +692,21 @@ short_name = 'tsan', ), luci.console_view_entry( + builder = 'ci/Android ASAN (dbg)', + category = 'week14b|android', + short_name = 'asanlsan', + ), + luci.console_view_entry( + builder = 'ci/Android arm Builder (dbg)', + category = 'week14b|android', + short_name = 'tsan', + ), + luci.console_view_entry( + builder = 'ci/Android arm64 Builder (dbg)', + category = 'week14b|android', + short_name = 'tsan', + ), + luci.console_view_entry( builder = 'ci/Win ASan Release', category = 'win|week1|asan', ),
diff --git a/infra/config/generated/cr-buildbucket.cfg b/infra/config/generated/cr-buildbucket.cfg index 52e3a97..5ba363b 100644 --- a/infra/config/generated/cr-buildbucket.cfg +++ b/infra/config/generated/cr-buildbucket.cfg
@@ -178,7 +178,7 @@ name: "chromium" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":150}" + properties_j: "$build/goma:{\"jobs\":150,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"chromium.android\"" > @@ -701,7 +701,7 @@ name: "chromium" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":150}" + properties_j: "$build/goma:{\"jobs\":150,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"chromium.android\"" > @@ -722,7 +722,7 @@ name: "chromium" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":500}" + properties_j: "$build/goma:{\"jobs\":500,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"chromium.android\"" > @@ -7533,7 +7533,7 @@ name: "chromium" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"enable_ats\":true}" + properties_j: "$build/goma:{\"enable_ats\":true,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"chromium.goma\"" > @@ -10289,6 +10289,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" + properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -10317,6 +10318,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" + properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -10345,6 +10347,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" + properties_j: "$build/goma:{\"jobs\":300,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -10733,7 +10736,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":300}" + properties_j: "$build/goma:{\"jobs\":300,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -10819,7 +10822,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":300}" + properties_j: "$build/goma:{\"jobs\":300,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -10848,7 +10851,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" - properties_j: "$build/goma:{\"jobs\":150}" + properties_j: "$build/goma:{\"jobs\":150,\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" > @@ -11050,6 +11053,7 @@ name: "chromium_trybot" cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build" cipd_version: "refs/heads/master" + properties_j: "$build/goma:{\"rpc_extra_params\":\"?prod\",\"server_host\":\"goma.chromium.org\"}" properties_j: "$kitchen:{\"devshell\":true,\"git_auth\":true}" properties_j: "mastername:\"tryserver.chromium.android\"" >
diff --git a/infra/config/generated/luci-milo.cfg b/infra/config/generated/luci-milo.cfg index f326a8c..ab6b8e89 100644 --- a/infra/config/generated/luci-milo.cfg +++ b/infra/config/generated/luci-milo.cfg
@@ -5198,6 +5198,21 @@ short_name: "tsan" > builders: < + name: "buildbucket/luci.chromium.ci/Android ASAN (dbg)" + category: "week14b|android" + short_name: "asanlsan" + > + builders: < + name: "buildbucket/luci.chromium.ci/Android arm Builder (dbg)" + category: "week14b|android" + short_name: "tsan" + > + builders: < + name: "buildbucket/luci.chromium.ci/Android arm64 Builder (dbg)" + category: "week14b|android" + short_name: "tsan" + > + builders: < name: "buildbucket/luci.chromium.ci/Win ASan Release" category: "win|week1|asan" >
diff --git a/infra/config/generated/tricium-prod.cfg b/infra/config/generated/tricium-prod.cfg index 906b97c..56990625 100644 --- a/infra/config/generated/tricium-prod.cfg +++ b/infra/config/generated/tricium-prod.cfg
@@ -52,6 +52,42 @@ } } +functions { + type: ANALYZER + name: "ClangTidy" + needs: GIT_FILE_DETAILS + provides: RESULTS + path_filters: "*.c" + path_filters: "*.cc" + path_filters: "*.cpp" + path_filters: "*.h" + owner: "gbiv@google.com" + monorail_component: "Infra>Platform>Tricium>Analyzer" + + impls { + runtime_platform: LINUX + provides_for_platform: LINUX + + recipe { + project: "chromium" + bucket: "try" + builder: "linux-clang-tidy-rel" + } + + # 5400sec == 90min. It takes 40mins to build tidy, which we want to stop + # doing before we launch this for real. 45ish minutes seems like a + # reasonable overall timeout, since the bot itself times out tidy after + # 30mins. It's generally expected to take around 5-10mins to get results + # back for reasonably-sized CLs. + deadline: 5400 + } +} + +selections { + function: "ClangTidy" + platform: LINUX +} + repos { gerrit_project { host: "chromium-review.googlesource.com"
diff --git a/infra/config/tricium-prod.cfg b/infra/config/tricium-prod.cfg index 906b97c..56990625 100644 --- a/infra/config/tricium-prod.cfg +++ b/infra/config/tricium-prod.cfg
@@ -52,6 +52,42 @@ } } +functions { + type: ANALYZER + name: "ClangTidy" + needs: GIT_FILE_DETAILS + provides: RESULTS + path_filters: "*.c" + path_filters: "*.cc" + path_filters: "*.cpp" + path_filters: "*.h" + owner: "gbiv@google.com" + monorail_component: "Infra>Platform>Tricium>Analyzer" + + impls { + runtime_platform: LINUX + provides_for_platform: LINUX + + recipe { + project: "chromium" + bucket: "try" + builder: "linux-clang-tidy-rel" + } + + # 5400sec == 90min. It takes 40mins to build tidy, which we want to stop + # doing before we launch this for real. 45ish minutes seems like a + # reasonable overall timeout, since the bot itself times out tidy after + # 30mins. It's generally expected to take around 5-10mins to get results + # back for reasonably-sized CLs. + deadline: 5400 + } +} + +selections { + function: "ClangTidy" + platform: LINUX +} + repos { gerrit_project { host: "chromium-review.googlesource.com"
diff --git a/ios/chrome/DEPS b/ios/chrome/DEPS index a4207c24..953d6241 100644 --- a/ios/chrome/DEPS +++ b/ios/chrome/DEPS
@@ -25,6 +25,10 @@ "+ios/web/common", "+ios/web/public", + # Chrome cannot use any ios/web APIs inside ios/web/public that are + # designed only for ios/web_view. + "-ios/web/public/web_view_only", + # All code in ios/chrome assumes that web::BrowserState* can be safely # casted to ios::ChromeBrowserState*. This mean that no code should use # web::TestBrowserState in ios/chrome.
diff --git a/ios/chrome/browser/flags/about_flags.mm b/ios/chrome/browser/flags/about_flags.mm index 3a7d4c8..38a777fea 100644 --- a/ios/chrome/browser/flags/about_flags.mm +++ b/ios/chrome/browser/flags/about_flags.mm
@@ -566,6 +566,9 @@ flag_descriptions::kEnablePersistentDownloadsName, flag_descriptions::kEnablePersistentDownloadsDescription, flags_ui::kOsIos, FEATURE_VALUE_TYPE(web::features::kEnablePersistentDownloads)}, + {"force-unstacked-tabstrip", flag_descriptions::kForceUnstackedTabstripName, + flag_descriptions::kForceUnstackedTabstripDescription, flags_ui::kOsIos, + FEATURE_VALUE_TYPE(kForceUnstackedTabstrip)}, }; // Add all switches from experimental flags to |command_line|.
diff --git a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc index 7645f727..bc4e36a 100644 --- a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc +++ b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.cc
@@ -201,6 +201,10 @@ const char kFindInPageiFrameDescription[] = "When enabled, Find In Page will search in iFrames."; +const char kForceUnstackedTabstripName[] = "Force unstacked tabstrip."; +const char kForceUnstackedTabstripDescription[] = + "When enabled, the tabstrip will draw unstacked, without tab collapsing."; + const char kFullscreenSmoothScrollingName[] = "Fullscreen Smooth Scrolling"; const char kFullscreenSmoothScrollingDescription[] = "When enabled, the web view's insets are updated for scoll events. If "
diff --git a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h index 5d85080f..9f59758 100644 --- a/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h +++ b/ios/chrome/browser/flags/ios_chrome_flag_descriptions.h
@@ -167,6 +167,10 @@ extern const char kFindInPageiFrameName[]; extern const char kFindInPageiFrameDescription[]; +// Title and description for the flag to force an unstacked tabstrip. +extern const char kForceUnstackedTabstripName[]; +extern const char kForceUnstackedTabstripDescription[]; + // Title and description for the command line switch used to determine the // active fullscreen viewport adjustment mode. extern const char kFullscreenSmoothScrollingName[];
diff --git a/ios/chrome/browser/ui/infobars/coordinators/infobar_save_card_coordinator.mm b/ios/chrome/browser/ui/infobars/coordinators/infobar_save_card_coordinator.mm index da5ef56..a3576f97 100644 --- a/ios/chrome/browser/ui/infobars/coordinators/infobar_save_card_coordinator.mm +++ b/ios/chrome/browser/ui/infobars/coordinators/infobar_save_card_coordinator.mm
@@ -12,6 +12,7 @@ #import "ios/chrome/browser/ui/infobars/coordinators/infobar_coordinator_implementation.h" #import "ios/chrome/browser/ui/infobars/infobar_container.h" #import "ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h" +#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #include "ui/gfx/image/image.h" #if !defined(__has_feature) || !__has_feature(objc_arc) @@ -154,8 +155,9 @@ self.modalViewController = [[InfobarSaveCardTableViewController alloc] initWithModalDelegate:self]; // TODO(crbug.com/1014652): Replace with Modal specific text. - self.modalViewController.title = - base::SysUTF16ToNSString(self.saveCardInfoBarDelegate->GetMessageText()); + self.modalViewController.title = @"Save Credit Card"; + self.modalViewController.cardIssuerIcon = + NativeImage(self.saveCardInfoBarDelegate->issuer_icon_id()); return YES; }
diff --git a/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h b/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h index eaf8a1b..6dc253b 100644 --- a/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h +++ b/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h
@@ -20,6 +20,9 @@ (ChromeTableViewControllerStyle)appBarStyle NS_UNAVAILABLE; +// Card Issuer icon image to be displayed. +@property(nonatomic, strong) UIImage* cardIssuerIcon; + @end #endif // IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_SAVE_CARD_TABLE_VIEW_CONTROLLER_H_
diff --git a/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.mm b/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.mm index 84564e6..f902e75c 100644 --- a/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.mm +++ b/ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.mm
@@ -4,12 +4,15 @@ #import "ios/chrome/browser/ui/infobars/modals/infobar_save_card_table_view_controller.h" +#include "base/mac/foundation_util.h" #include "base/metrics/user_metrics.h" #include "base/metrics/user_metrics_action.h" #include "ios/chrome/browser/infobars/infobar_metrics_recorder.h" #import "ios/chrome/browser/ui/infobars/modals/infobar_modal_constants.h" #import "ios/chrome/browser/ui/infobars/modals/infobar_modal_delegate.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_cells_constants.h" +#import "ios/chrome/browser/ui/table_view/cells/table_view_text_button_item.h" +#import "ios/chrome/browser/ui/table_view/cells/table_view_text_edit_item.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_styler.h" #import "ios/chrome/common/colors/semantic_color_names.h" @@ -17,9 +20,21 @@ #error "This file requires ARC support." #endif -@interface InfobarSaveCardTableViewController () +typedef NS_ENUM(NSInteger, SectionIdentifier) { + SectionIdentifierContent = kSectionIdentifierEnumZero, +}; -// InfobarPasswordModalDelegate for this ViewController. +typedef NS_ENUM(NSInteger, ItemType) { + ItemTypeCardLastDigits = kItemTypeEnumZero, + ItemTypeCardHolderName, + ItemTypeCardExpireMonth, + ItemTypeCardExpireYear, + ItemTypeCardSave, +}; + +@interface InfobarSaveCardTableViewController () <UITextFieldDelegate> + +// InfobarModalDelegate for this ViewController. @property(nonatomic, strong) id<InfobarModalDelegate> infobarModalDelegate; // Used to build and record metrics. @property(nonatomic, strong) InfobarMetricsRecorder* metricsRecorder; @@ -57,10 +72,201 @@ cancelButton.accessibilityIdentifier = kInfobarModalCancelButton; self.navigationItem.leftBarButtonItem = cancelButton; self.navigationController.navigationBar.prefersLargeTitles = NO; + + [self loadModel]; +} + +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; + [self.metricsRecorder recordModalEvent:MobileMessagesModalEvent::Presented]; +} + +- (void)viewDidDisappear:(BOOL)animated { + [self.infobarModalDelegate modalInfobarWasDismissed:self]; + [self.metricsRecorder recordModalEvent:MobileMessagesModalEvent::Dismissed]; + [super viewDidDisappear:animated]; +} + +- (void)viewDidLayoutSubviews { + [super viewDidLayoutSubviews]; + self.tableView.scrollEnabled = + self.tableView.contentSize.height > self.view.frame.size.height; +} + +#pragma mark - TableViewModel + +- (void)loadModel { + [super loadModel]; + + TableViewModel* model = self.tableViewModel; + [model addSectionWithIdentifier:SectionIdentifierContent]; + + // TODO(crbug.com/1014652): Use the real strings once they are exposed in the + // delegate. + TableViewTextEditItem* cardLastDigitsItem = + [self textEditItemWithType:ItemTypeCardExpireYear + textFieldName:@"Card Number" + textFieldValue:@"•••• 1234" + textFieldEnabled:NO]; + cardLastDigitsItem.identifyingIcon = self.cardIssuerIcon; + [model addItem:cardLastDigitsItem + toSectionWithIdentifier:SectionIdentifierContent]; + + // TODO(crbug.com/1014652): Use the real strings once they are exposed in the + // delegate. + TableViewTextEditItem* cardholderNameItem = + [self textEditItemWithType:ItemTypeCardExpireYear + textFieldName:@"Cardholder Name" + textFieldValue:@"Sergio Collazos" + textFieldEnabled:YES]; + [model addItem:cardholderNameItem + toSectionWithIdentifier:SectionIdentifierContent]; + + // TODO(crbug.com/1014652): Use the real strings once they are exposed in the + // delegate. + TableViewTextEditItem* expireMonthItem = + [self textEditItemWithType:ItemTypeCardExpireYear + textFieldName:@"Expiration Month" + textFieldValue:@"07" + textFieldEnabled:YES]; + [model addItem:expireMonthItem + toSectionWithIdentifier:SectionIdentifierContent]; + + // TODO(crbug.com/1014652): Use the real strings once they are exposed in the + // delegate. + TableViewTextEditItem* expireYearItem = + [self textEditItemWithType:ItemTypeCardExpireYear + textFieldName:@"Expiration Year" + textFieldValue:@"2020" + textFieldEnabled:YES]; + [model addItem:expireYearItem + toSectionWithIdentifier:SectionIdentifierContent]; + + // TODO(crbug.com/1014652): Use the real strings once they are exposed in the + // delegate. + TableViewTextButtonItem* saveCardButtonItem = + [[TableViewTextButtonItem alloc] initWithType:ItemTypeCardSave]; + saveCardButtonItem.textAlignment = NSTextAlignmentNatural; + // TODO(crbug.com/1014652): Implement TOS with Links. This might require a + // separate item. + saveCardButtonItem.text = @"TOS Agreement"; + saveCardButtonItem.buttonText = @"Save Credit Card"; + saveCardButtonItem.enabled = YES; + saveCardButtonItem.disableButtonIntrinsicWidth = YES; + [model addItem:saveCardButtonItem + toSectionWithIdentifier:SectionIdentifierContent]; +} + +#pragma mark - UITableViewDataSource + +- (UITableViewCell*)tableView:(UITableView*)tableView + cellForRowAtIndexPath:(NSIndexPath*)indexPath { + UITableViewCell* cell = [super tableView:tableView + cellForRowAtIndexPath:indexPath]; + ItemType itemType = static_cast<ItemType>( + [self.tableViewModel itemTypeForIndexPath:indexPath]); + + switch (itemType) { + case ItemTypeCardLastDigits: { + cell.selectionStyle = UITableViewCellSelectionStyleNone; + break; + } + case ItemTypeCardHolderName: { + TableViewTextEditCell* editCell = + base::mac::ObjCCast<TableViewTextEditCell>(cell); + [editCell.textField addTarget:self + action:@selector(nameEditDidBegin) + forControlEvents:UIControlEventEditingDidBegin]; + [editCell.textField addTarget:self + action:@selector(updateSaveCardButtonState) + forControlEvents:UIControlEventEditingChanged]; + editCell.selectionStyle = UITableViewCellSelectionStyleNone; + editCell.textField.delegate = self; + break; + } + case ItemTypeCardExpireMonth: { + TableViewTextEditCell* editCell = + base::mac::ObjCCast<TableViewTextEditCell>(cell); + [editCell.textField addTarget:self + action:@selector(monthEditDidBegin) + forControlEvents:UIControlEventEditingDidBegin]; + [editCell.textField addTarget:self + action:@selector(updateSaveCardButtonState) + forControlEvents:UIControlEventEditingChanged]; + editCell.selectionStyle = UITableViewCellSelectionStyleNone; + editCell.textField.delegate = self; + break; + } + case ItemTypeCardExpireYear: { + TableViewTextEditCell* editCell = + base::mac::ObjCCast<TableViewTextEditCell>(cell); + [editCell.textField addTarget:self + action:@selector(yearEditDidBegin) + forControlEvents:UIControlEventEditingDidBegin]; + [editCell.textField addTarget:self + action:@selector(updateSaveCardButtonState) + forControlEvents:UIControlEventEditingChanged]; + editCell.selectionStyle = UITableViewCellSelectionStyleNone; + editCell.textField.delegate = self; + break; + } + case ItemTypeCardSave: { + TableViewTextButtonCell* tableViewTextButtonCell = + base::mac::ObjCCastStrict<TableViewTextButtonCell>(cell); + [tableViewTextButtonCell.button + addTarget:self + action:@selector(saveCardButtonWasPressed:) + forControlEvents:UIControlEventTouchUpInside]; + break; + } + } + + return cell; +} + +#pragma mark - UITableViewDelegate + +- (CGFloat)tableView:(UITableView*)tableView + heightForFooterInSection:(NSInteger)section { + return 0; +} + +#pragma mark - UITextFieldDelegate + +- (BOOL)textFieldShouldReturn:(UITextField*)textField { + [textField resignFirstResponder]; + return YES; } #pragma mark - Private Methods +- (void)updateSaveCardButtonState { + // TODO(crbug.com/1014652): Implement + + // TODO(crbug.com/1014652):Ideally the InfobarDelegate should update the + // button text. Once we have a consumer protocol we should be able to create a + // delegate that asks the InfobarDelegate for the correct text. +} + +- (void)saveCardButtonWasPressed:(UIButton*)sender { + // TODO(crbug.com/1014652): Implement and record metrics. +} + +- (void)nameEditDidBegin { + // TODO(crbug.com/1014652): Implement, should only be needed to record + // SaveCard specific editing metrics. +} + +- (void)monthEditDidBegin { + // TODO(crbug.com/1014652): Implement, should only be needed to record + // SaveCard specific editing metrics. +} + +- (void)yearEditDidBegin { + // TODO(crbug.com/1014652): Implement, should only be needed to record + // SaveCard specific editing metrics. +} + - (void)dismissInfobarModal:(UIButton*)sender { base::RecordAction( base::UserMetricsAction("MobileMessagesModalCancelledTapped")); @@ -70,4 +276,21 @@ completion:nil]; } +#pragma mark - Helpers + +- (TableViewTextEditItem*)textEditItemWithType:(ItemType)type + textFieldName:(NSString*)name + textFieldValue:(NSString*)value + textFieldEnabled:(BOOL)enabled { + TableViewTextEditItem* textEditItem = + [[TableViewTextEditItem alloc] initWithType:type]; + textEditItem.textFieldName = name; + textEditItem.textFieldValue = value; + textEditItem.textFieldEnabled = enabled; + textEditItem.hideIcon = !enabled; + textEditItem.returnKeyType = UIReturnKeyDone; + + return textEditItem; +} + @end
diff --git a/ios/chrome/browser/ui/tabs/BUILD.gn b/ios/chrome/browser/ui/tabs/BUILD.gn index ca9ce3a..45308d3 100644 --- a/ios/chrome/browser/ui/tabs/BUILD.gn +++ b/ios/chrome/browser/ui/tabs/BUILD.gn
@@ -45,6 +45,7 @@ "//ios/chrome/browser/browser_state", "//ios/chrome/browser/drag_and_drop", "//ios/chrome/browser/snapshots", + "//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui/bubble", "//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/commands",
diff --git a/ios/chrome/browser/ui/tabs/tab_strip_controller.mm b/ios/chrome/browser/ui/tabs/tab_strip_controller.mm index 4a6fbfd8..de7bbdf 100644 --- a/ios/chrome/browser/ui/tabs/tab_strip_controller.mm +++ b/ios/chrome/browser/ui/tabs/tab_strip_controller.mm
@@ -37,6 +37,7 @@ #import "ios/chrome/browser/ui/tabs/tab_strip_view.h" #import "ios/chrome/browser/ui/tabs/tab_view.h" #include "ios/chrome/browser/ui/tabs/target_frame_cache.h" +#import "ios/chrome/browser/ui/ui_feature_flags.h" #import "ios/chrome/browser/ui/util/named_guide.h" #include "ios/chrome/browser/ui/util/rtl_geometry.h" #include "ios/chrome/browser/ui/util/ui_util.h" @@ -68,23 +69,23 @@ const NSTimeInterval kDragAndDropLongPressDuration = 0.4; // Tab dimensions. -const CGFloat kTabOverlap = 32.0; -const CGFloat kTabOverlapForCompactLayout = 30.0; +const CGFloat kTabOverlapStacked = 32.0; +const CGFloat kTabOverlapUnstacked = 30.0; const CGFloat kNewTabOverlap = 13.0; -const CGFloat kMaxTabWidth = 265.0; -const CGFloat kMaxTabWidthForCompactLayout = 225.0; +const CGFloat kMaxTabWidthStacked = 265.0; +const CGFloat kMaxTabWidthUnstacked = 225.0; // Tab Switcher button dimensions. const CGFloat kTabSwitcherButtonWidth = 46.0; const CGFloat kTabSwitcherButtonBackgroundWidth = 62.0; -const CGFloat kMinTabWidth = 200.0; -const CGFloat kMinTabWidthForCompactLayout = 160.0; +const CGFloat kMinTabWidthStacked = 200.0; +const CGFloat kMinTabWidthUnstacked = 160.0; const CGFloat kCollapsedTabOverlap = 5.0; -const NSUInteger kMaxNumCollapsedTabs = 3; -const NSUInteger kMaxNumCollapsedTabsForCompactLayout = 0; +const NSUInteger kMaxNumCollapsedTabsStacked = 3; +const NSUInteger kMaxNumCollapsedTabsUnstacked = 0; // Tabs with a visible width smaller than this draw as collapsed tabs.. const CGFloat kCollapsedTabWidthThreshold = 40.0; @@ -168,7 +169,7 @@ UIButton* _buttonNewTab; UIButton* _tabSwitcherButton; - // Background view of the tab switcher button. Only visible while in compact + // Background view of the tab switcher button. Only visible while in unstacked // layout. UIImageView* _tabSwitcherButtonBackgroundView; @@ -259,6 +260,13 @@ // YES if the controller has been disconnected. @property(nonatomic) BOOL disconnected; +// If set to |YES|, tabs at either end of the tabstrip are "collapsed" into a +// stack, such that the visible width of the tabstrip is constant. If set to +// |NO|, tabs are never collapsed and the tabstrip scrolls horizontally as a +// normal scroll view would. Changing this property causes the tabstrip to +// redraw and relayout. Defaults to |YES|. +@property(nonatomic, assign) BOOL useTabStacking; + // Initializes the tab array based on the the entries in the TabModel. Creates // one TabView per Tab and adds it to the tabstrip. A later call to // |-layoutTabs| is needed to properly place the tabs in the correct positions. @@ -367,14 +375,13 @@ // Returns the minimum tab view width depending on the current layout mode. - (CGFloat)minTabWidth; -// Automatically scroll the tab strip view to keep the newly inserted tab view -// visible. +// Automatically scroll the tab strip view to keep the given tab view visible. // This method must be called with a valid |tabIndex|. -- (void)autoScrollForNewTab:(NSUInteger)tabIndex; +- (void)scrollTabToVisible:(NSUInteger)tabIndex; // Updates the content offset of the tab strip view in order to keep the // selected tab view visible. -// Content offset adjustement is only needed/performed in compact mode or +// Content offset adjustement is only needed/performed in unstacked mode or // regular mode for newly opened webStates. // This method must be called with a valid |WebStateIndex|. - (void)updateContentOffsetForWebStateIndex:(int)WebStateIndex @@ -391,6 +398,9 @@ // for it. - (TabView*)tabViewForWebState:(web::WebState*)webState; +// Computes whether the tabstrip should use tab stacking. +- (BOOL)shouldUseTabStacking; + @end @implementation TabStripController @@ -427,6 +437,7 @@ _dispatcher = dispatcher; // |self.view| setup. + _useTabStacking = [self shouldUseTabStacking]; CGRect tabStripFrame = [UIApplication sharedApplication].keyWindow.bounds; tabStripFrame.size.height = kTabStripHeight; _view = [[UIView alloc] initWithFrame:tabStripFrame]; @@ -507,6 +518,15 @@ // Don't highlight the selected tab by default. self.highlightsSelectedTab = NO; + + // Register for VoiceOver notifications. + if (base::FeatureList::IsEnabled(kVoiceOverUnstackedTabstrip)) { + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(voiceOverStatusDidChange) + name:UIAccessibilityVoiceOverStatusDidChangeNotification + object:nil]; + } } return self; } @@ -521,6 +541,7 @@ _allWebStateObservationForwarder.reset(); _webStateListFaviconObserver.reset(); _tabModel.webStateList->RemoveObserver(_webStateListObserver.get()); + [[NSNotificationCenter defaultCenter] removeObserver:self]; self.disconnected = YES; } @@ -1323,28 +1344,26 @@ } #pragma mark - -#pragma mark - compact layout +#pragma mark - Unstacked layout - (NSUInteger)maxNumCollapsedTabs { - return IsCompactTablet() ? kMaxNumCollapsedTabsForCompactLayout - : kMaxNumCollapsedTabs; + return self.useTabStacking ? kMaxNumCollapsedTabsStacked + : kMaxNumCollapsedTabsUnstacked; } - (CGFloat)tabOverlap { - if (!IsCompactTablet()) - return kTabOverlap; - return kTabOverlapForCompactLayout; + return self.useTabStacking ? kTabOverlapStacked : kTabOverlapUnstacked; } - (CGFloat)maxTabWidth { - return IsCompactTablet() ? kMaxTabWidthForCompactLayout : kMaxTabWidth; + return self.useTabStacking ? kMaxTabWidthStacked : kMaxTabWidthUnstacked; } - (CGFloat)minTabWidth { - return IsCompactTablet() ? kMinTabWidthForCompactLayout : kMinTabWidth; + return self.useTabStacking ? kMinTabWidthStacked : kMinTabWidthUnstacked; } -- (void)autoScrollForNewTab:(NSUInteger)tabIndex { +- (void)scrollTabToVisible:(NSUInteger)tabIndex { DCHECK_NE(NSNotFound, static_cast<NSInteger>(tabIndex)); // The following code calculates the amount of scroll needed to make @@ -1388,6 +1407,8 @@ ([self tabOverlap] * (numNonClosingTabsToLeft - 1)), 0, _currentTabWidth, tabHeight); [_tabStripView scrollRectToVisible:scrollRect animated:YES]; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, + nil); } - (void)updateContentOffsetForWebStateIndex:(int)webStateIndex @@ -1395,11 +1416,11 @@ DCHECK_NE(WebStateList::kInvalidIndex, webStateIndex); if (isNewWebState) { - [self autoScrollForNewTab:webStateIndex]; + [self scrollTabToVisible:webStateIndex]; return; } - if (IsCompactTablet()) { + if (!self.useTabStacking) { if (webStateIndex == static_cast<int>([_tabArray count]) - 1) { const CGFloat tabStripAvailableSpace = _tabStripView.frame.size.width - _tabStripView.contentInset.right; @@ -1422,7 +1443,7 @@ - (void)updateScrollViewFrameForTabSwitcherButton { CGRect tabFrame = _tabStripView.frame; tabFrame.size.width = _view.bounds.size.width; - if (!IsCompactTablet()) { + if (self.useTabStacking) { tabFrame.size.width -= kTabSwitcherButtonWidth; _tabStripView.contentInset = UIEdgeInsetsZero; [_tabSwitcherButtonBackgroundView setHidden:YES]; @@ -1474,11 +1495,12 @@ const CGFloat tabHeight = CGRectGetHeight([_tabStripView bounds]); - // In compact layout mode the space used to layout the tabs is not - // constrained and uses the whole scroll view content size width. In regular - // layout mode the available space is constrained to the visible space. - CGFloat availableSpace = IsCompactTablet() ? _tabStripView.contentSize.width - : [self tabStripVisibleSpace]; + // In unstacked mode the space used to layout the tabs is not constrained and + // uses the whole scroll view content size width. In stacked mode the + // available space is constrained to the visible space. + CGFloat availableSpace = self.useTabStacking + ? [self tabStripVisibleSpace] + : _tabStripView.contentSize.width; // The array and model indexes of the selected tab. NSUInteger selectedModelIndex = @@ -1504,7 +1526,7 @@ // real frame. CGFloat virtualMinX = 0; CGFloat virtualMaxX = 0; - CGFloat offset = IsCompactTablet() ? 0 : [_tabStripView contentOffset].x; + CGFloat offset = self.useTabStacking ? [_tabStripView contentOffset].x : 0; // Keeps track of which tabs need to be animated. Using an autoreleased array // instead of scoped_nsobject because scoped_nsobject doesn't seem to work @@ -1740,16 +1762,6 @@ } } -- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { - [self updateScrollViewFrameForTabSwitcherButton]; - [self updateContentSizeAndRepositionViews]; - int selectedModelIndex = _tabModel.webStateList->active_index(); - if (selectedModelIndex != WebStateList::kInvalidIndex) { - [self updateContentOffsetForWebStateIndex:selectedModelIndex - isNewWebState:NO]; - } -} - - (void)setNeedsLayoutWithAnimation { _animateLayout = YES; [_tabStripView setNeedsLayout]; @@ -1815,4 +1827,41 @@ webState->GetNavigationManager()->LoadURLWithParams(params); } +#pragma mark - Tab Stacking + +- (BOOL)shouldUseTabStacking { + BOOL useTabStacking = !IsCompactTablet(); + if (base::FeatureList::IsEnabled(kVoiceOverUnstackedTabstrip) && + UIAccessibilityIsVoiceOverRunning()) { + useTabStacking = NO; + } + if (base::FeatureList::IsEnabled(kForceUnstackedTabstrip)) { + useTabStacking = NO; + } + return useTabStacking; +} + +- (void)setUseTabStacking:(BOOL)useTabStacking { + if (_useTabStacking == useTabStacking) { + return; + } + + _useTabStacking = useTabStacking; + [self updateScrollViewFrameForTabSwitcherButton]; + [self updateContentSizeAndRepositionViews]; + int selectedModelIndex = _tabModel.webStateList->active_index(); + if (selectedModelIndex != WebStateList::kInvalidIndex) { + [self updateContentOffsetForWebStateIndex:selectedModelIndex + isNewWebState:NO]; + } +} + +- (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection { + self.useTabStacking = [self shouldUseTabStacking]; +} + +- (void)voiceOverStatusDidChange { + self.useTabStacking = [self shouldUseTabStacking]; +} + @end
diff --git a/ios/chrome/browser/ui/ui_feature_flags.cc b/ios/chrome/browser/ui/ui_feature_flags.cc index 5795a8a..e419523 100644 --- a/ios/chrome/browser/ui/ui_feature_flags.cc +++ b/ios/chrome/browser/ui/ui_feature_flags.cc
@@ -33,3 +33,9 @@ const base::Feature kDisableAnimationOnLowBattery{ "DisableAnimationOnLowBattery", base::FEATURE_DISABLED_BY_DEFAULT}; + +const base::Feature kVoiceOverUnstackedTabstrip{ + "VoiceOverUnstackedTabstrip", base::FEATURE_DISABLED_BY_DEFAULT}; + +const base::Feature kForceUnstackedTabstrip{"ForceUnstackedTabstrip", + base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/ios/chrome/browser/ui/ui_feature_flags.h b/ios/chrome/browser/ui/ui_feature_flags.h index 979642d..e05a0fe 100644 --- a/ios/chrome/browser/ui/ui_feature_flags.h +++ b/ios/chrome/browser/ui/ui_feature_flags.h
@@ -37,4 +37,10 @@ // Feature flag disabling animation on low battery. extern const base::Feature kDisableAnimationOnLowBattery; +// Feature flag to use the unstacked tabstrip when voiceover is enabled. +extern const base::Feature kVoiceOverUnstackedTabstrip; + +// Feature flag to always force an unstacked tabstrip. +extern const base::Feature kForceUnstackedTabstrip; + #endif // IOS_CHROME_BROWSER_UI_UI_FEATURE_FLAGS_H_
diff --git a/ios/chrome/test/app/sync_test_util.mm b/ios/chrome/test/app/sync_test_util.mm index 36651d5..d915a94b 100644 --- a/ios/chrome/test/app/sync_test_util.mm +++ b/ios/chrome/test/app/sync_test_util.mm
@@ -339,7 +339,7 @@ ios::HistoryServiceFactory::GetForBrowserState( browser_state, ServiceAccessType::EXPLICIT_ACCESS); - history_service->DeleteURL(url); + history_service->DeleteURLs({url}); } void DeleteTypedUrlFromFakeSyncServer(std::string url) {
diff --git a/ios/web/BUILD.gn b/ios/web/BUILD.gn index 20598217..db5de05 100644 --- a/ios/web/BUILD.gn +++ b/ios/web/BUILD.gn
@@ -204,6 +204,7 @@ "//ios/web/favicon:unittests", "//ios/web/find_in_page:find_in_page_unittests", "//ios/web/js_messaging:unittests", + "//ios/web/public/web_view_only:unittests", "//ios/web/security:unittests", "//ios/web/session:unittests", "//ios/web/test:packed_resources",
diff --git a/ios/web/public/web_view_only/BUILD.gn b/ios/web/public/web_view_only/BUILD.gn new file mode 100644 index 0000000..a637a148 --- /dev/null +++ b/ios/web/public/web_view_only/BUILD.gn
@@ -0,0 +1,44 @@ +# 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. + +import("//ios/build/config.gni") + +source_set("web_view_only") { + configs += [ "//build/config/compiler:enable_arc" ] + + public_deps = [ + ":web_view_only_api_header", + ] + + deps = [ + "//ios/web/web_view_only", + ] + + visibility = [ + "//ios/web_view:*", + "//ios/web/web_view_only:unittests", + ] +} + +source_set("web_view_only_api_header") { + configs += [ "//build/config/compiler:enable_arc" ] + + sources = [ + "wk_web_view_configuration_util.h", + ] + + visibility = [ + ":*", + "//ios/web/web_view_only:*", + ] +} + +source_set("unittests") { + configs += [ "//build/config/compiler:enable_arc" ] + testonly = true + + deps = [ + "//ios/web/web_view_only:unittests", + ] +}
diff --git a/ios/web/public/web_view_only/README.md b/ios/web/public/web_view_only/README.md new file mode 100644 index 0000000..6f13a3081 --- /dev/null +++ b/ios/web/public/web_view_only/README.md
@@ -0,0 +1 @@ +This directory contains the APIs that is only allowed to be used in //ios/web_view. \ No newline at end of file
diff --git a/ios/web/public/web_view_only/wk_web_view_configuration_util.h b/ios/web/public/web_view_only/wk_web_view_configuration_util.h new file mode 100644 index 0000000..9cee0295 --- /dev/null +++ b/ios/web/public/web_view_only/wk_web_view_configuration_util.h
@@ -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. + +#ifndef IOS_WEB_PUBLIC_WEB_VIEW_ONLY_WK_WEB_VIEW_CONFIGURATION_UTIL_H_ +#define IOS_WEB_PUBLIC_WEB_VIEW_ONLY_WK_WEB_VIEW_CONFIGURATION_UTIL_H_ + +@class WKWebView; +@class WKWebViewConfiguration; + +namespace web { + +class WebState; + +// Creates the web view of |web_state| with given |configuration|. +// Returns the created web view. +// This must be called immediately after |web_state| is created +// e.g., with web::WebState::Create(). +// +// The goal of writing this function is to make it possible to construct +// CWVWebView from a WKWebViewConfiguration that is not originated from a +// //ios/web managed WKWebView (e.g. when handling window.open() from a normal +// WKWebView that is not //ios/web, such a WKWebViewConfiguration will be +// provided and necessary for creating a new web view). +WKWebView* EnsureWebViewCreatedWithConfiguration( + WebState* web_state, + WKWebViewConfiguration* configuration); + +} // namespace web + +#endif // IOS_WEB_PUBLIC_WEB_VIEW_ONLY_WK_WEB_VIEW_CONFIGURATION_UTIL_H_
diff --git a/ios/web/web_state/ui/crw_web_controller.h b/ios/web/web_state/ui/crw_web_controller.h index c0a45d75..d10135f8 100644 --- a/ios/web/web_state/ui/crw_web_controller.h +++ b/ios/web/web_state/ui/crw_web_controller.h
@@ -26,6 +26,7 @@ @class CRWWebViewContentView; @protocol CRWWebViewProxy; class GURL; +@class WKWebView; namespace web { class NavigationItem; @@ -189,6 +190,9 @@ - (void)takeSnapshotWithRect:(CGRect)rect completion:(void (^)(UIImage* snapshot))completion; +// Creates a web view if it's not yet created. Returns the web view. +- (WKWebView*)ensureWebViewCreated; + @end #pragma mark Testing
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm index 273fde2..154c8374 100644 --- a/ios/web/web_state/ui/crw_web_controller.mm +++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -1599,15 +1599,21 @@ } // Creates a web view if it's not yet created. -- (void)ensureWebViewCreated { +- (WKWebView*)ensureWebViewCreated { WKWebViewConfiguration* config = [self webViewConfigurationProvider].GetWebViewConfiguration(); - [self ensureWebViewCreatedWithConfiguration:config]; + return [self ensureWebViewCreatedWithConfiguration:config]; } // Creates a web view with given |config|. No-op if web view is already created. -- (void)ensureWebViewCreatedWithConfiguration:(WKWebViewConfiguration*)config { +- (WKWebView*)ensureWebViewCreatedWithConfiguration: + (WKWebViewConfiguration*)config { if (!self.webView) { + // This has to be called to ensure the container view of `self.webView` is + // created. Otherwise `self.webView.frame.size` will be CGSizeZero which + // fails a DCHECK later. + [self ensureContainerViewCreated]; + [self setWebView:[self webViewWithConfiguration:config]]; // The following is not called in -setWebView: as the latter used in unit // tests with fake web view, which cannot be added to view hierarchy. @@ -1651,6 +1657,8 @@ if (![self.legacyNativeController shouldLoadURLInNativeView:visibleURL]) [self displayWebView]; } + + return self.webView; } // Returns a new autoreleased web view created with given configuration.
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm index 7694748f..e46d30d 100644 --- a/ios/web/web_state/ui/crw_web_controller_unittest.mm +++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -415,6 +415,14 @@ EXPECT_EQ(web::WKNavigationState::FINISHED, web_controller().navigationState); } +// Tests that a web view is created after calling -[ensureWebViewCreated]. +TEST_P(CRWWebControllerTest, WebViewCreatedAfterEnsureWebViewCreated) { + [web_controller() removeWebView]; + WKWebView* web_view = [web_controller() ensureWebViewCreated]; + EXPECT_TRUE(web_view); + EXPECT_NSEQ(web_view, web_controller().jsInjector.webView); +} + INSTANTIATE_TEST_SUITES(CRWWebControllerTest); // Test fixture to test JavaScriptDialogPresenter.
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.h b/ios/web/web_state/ui/wk_web_view_configuration_provider.h index f0a50ba..68b18531 100644 --- a/ios/web/web_state/ui/wk_web_view_configuration_provider.h +++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.h
@@ -31,6 +31,25 @@ static web::WKWebViewConfigurationProvider& FromBrowserState( web::BrowserState* browser_state); + // Resets the configuration saved in this WKWebViewConfigurationProvider + // using the given |configuration|. First |configuration| is shallow cloned + // and then Chrome's configuration initialization logic will be applied to + // make it work for //ios/web. If |configuration| is nil, a new + // WKWebViewConfiguration object will be created and set. + // + // WARNING: This method should NOT be used + // for any |configuration| that is originated from a //ios/web managed + // WKWebView (e.g. you will get a WKWebViewConfiguration from a delegate + // method when window.open() is called in a //ios/web managed WKWebView), + // because such a |configuration| is based on the current //ios/web + // configuration which has already been initialized with the Chrome's + // configuration initialization logic when it was passed to a initializer of + // //ios/web. Which means, this method should only be used for a newly created + // |configuration| or a |configuration| originated from somewhere outside + // //ios/web. This method is mainly used by + // WKWebViewConfigurationProvider::GetWebViewConfiguration(). + void ResetWithWebViewConfiguration(WKWebViewConfiguration* configuration); + // Returns an autoreleased shallow copy of WKWebViewConfiguration associated // with browser state. Lazily creates the config. Configuration's // |preferences| will have scriptCanOpenWindowsAutomatically property set to @@ -59,7 +78,7 @@ explicit WKWebViewConfigurationProvider(BrowserState* browser_state); WKWebViewConfigurationProvider() = delete; CRWWebUISchemeHandler* scheme_handler_ = nil; - WKWebViewConfiguration* configuration_; + WKWebViewConfiguration* configuration_ = nil; CRWWKScriptMessageRouter* router_; BrowserState* browser_state_;
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm index 0d1196f4..0fa3b0b 100644 --- a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm +++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm
@@ -92,74 +92,85 @@ WKWebViewConfigurationProvider::~WKWebViewConfigurationProvider() = default; +void WKWebViewConfigurationProvider::ResetWithWebViewConfiguration( + WKWebViewConfiguration* configuration) { + DCHECK([NSThread isMainThread]); + + if (!configuration) { + configuration = [[WKWebViewConfiguration alloc] init]; + } else { + configuration = [configuration copy]; + } + configuration_ = configuration; + + if (browser_state_->IsOffTheRecord()) { + [configuration_ + setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; + } + + if (base::FeatureList::IsEnabled( + web::features::kIgnoresViewportScaleLimits)) { + [configuration_ setIgnoresViewportScaleLimits:YES]; + } + + if (@available(iOS 13, *)) { + @try { + // Disable system context menu on iOS 13 and later. Disabling + // "longPressActions" prevents the WKWebView ContextMenu from being + // displayed. + // https://github.com/WebKit/webkit/blob/1233effdb7826a5f03b3cdc0f67d713741e70976/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm#L307 + [configuration_ setValue:@NO forKey:@"longPressActionsEnabled"]; + } @catch (NSException* exception) { + NOTREACHED() << "Error setting value for longPressActionsEnabled"; + } + } + + [configuration_ setAllowsInlineMediaPlayback:YES]; + // setJavaScriptCanOpenWindowsAutomatically is required to support popups. + [[configuration_ preferences] setJavaScriptCanOpenWindowsAutomatically:YES]; + // Main frame script depends upon scripts injected into all frames, so the + // "AllFrames" scripts must be injected first. + [[configuration_ userContentController] + addUserScript:InternalGetDocumentStartScriptForAllFrames(browser_state_)]; + [[configuration_ userContentController] + addUserScript:InternalGetDocumentStartScriptForMainFrame(browser_state_)]; + [[configuration_ userContentController] + addUserScript:InternalGetDocumentEndScriptForAllFrames(browser_state_)]; + [[configuration_ userContentController] + addUserScript:InternalGetDocumentEndScriptForMainFrame(browser_state_)]; + + if (!scheme_handler_) { + scoped_refptr<network::SharedURLLoaderFactory> shared_loader_factory = + browser_state_->GetSharedURLLoaderFactory(); + scheme_handler_ = [[CRWWebUISchemeHandler alloc] + initWithURLLoaderFactory:shared_loader_factory]; + } + WebClient::Schemes schemes; + GetWebClient()->AddAdditionalSchemes(&schemes); + GetWebClient()->GetAdditionalWebUISchemes(&(schemes.standard_schemes)); + for (std::string scheme : schemes.standard_schemes) { + [configuration_ setURLSchemeHandler:scheme_handler_ + forURLScheme:base::SysUTF8ToNSString(scheme)]; + } + + for (auto& observer : observers_) + observer.DidCreateNewConfiguration(this, configuration_); + + // Workaround to force the creation of the WKWebsiteDataStore. This + // workaround need to be done here, because this method returns a copy of + // the already created configuration. + NSSet* data_types = [NSSet setWithObject:WKWebsiteDataTypeCookies]; + [configuration_.websiteDataStore + fetchDataRecordsOfTypes:data_types + completionHandler:^(NSArray<WKWebsiteDataRecord*>* records){ + }]; +} + WKWebViewConfiguration* WKWebViewConfigurationProvider::GetWebViewConfiguration() { DCHECK([NSThread isMainThread]); if (!configuration_) { - configuration_ = [[WKWebViewConfiguration alloc] init]; - if (browser_state_->IsOffTheRecord()) { - [configuration_ - setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; - } - - if (base::FeatureList::IsEnabled( - web::features::kIgnoresViewportScaleLimits)) { - [configuration_ setIgnoresViewportScaleLimits:YES]; - } - - if (@available(iOS 13, *)) { - @try { - // Disable system context menu on iOS 13 and later. Disabling - // "longPressActions" prevents the WKWebView ContextMenu from being - // displayed. - // https://github.com/WebKit/webkit/blob/1233effdb7826a5f03b3cdc0f67d713741e70976/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm#L307 - [configuration_ setValue:@NO forKey:@"longPressActionsEnabled"]; - } @catch (NSException* exception) { - NOTREACHED() << "Error setting value for longPressActionsEnabled"; - } - } - - [configuration_ setAllowsInlineMediaPlayback:YES]; - // setJavaScriptCanOpenWindowsAutomatically is required to support popups. - [[configuration_ preferences] setJavaScriptCanOpenWindowsAutomatically:YES]; - // Main frame script depends upon scripts injected into all frames, so the - // "AllFrames" scripts must be injected first. - [[configuration_ userContentController] - addUserScript:InternalGetDocumentStartScriptForAllFrames( - browser_state_)]; - [[configuration_ userContentController] - addUserScript:InternalGetDocumentStartScriptForMainFrame( - browser_state_)]; - [[configuration_ userContentController] - addUserScript:InternalGetDocumentEndScriptForAllFrames(browser_state_)]; - [[configuration_ userContentController] - addUserScript:InternalGetDocumentEndScriptForMainFrame(browser_state_)]; - - if (!scheme_handler_) { - scoped_refptr<network::SharedURLLoaderFactory> shared_loader_factory = - browser_state_->GetSharedURLLoaderFactory(); - scheme_handler_ = [[CRWWebUISchemeHandler alloc] - initWithURLLoaderFactory:shared_loader_factory]; - } - WebClient::Schemes schemes; - GetWebClient()->AddAdditionalSchemes(&schemes); - GetWebClient()->GetAdditionalWebUISchemes(&(schemes.standard_schemes)); - for (std::string scheme : schemes.standard_schemes) { - [configuration_ setURLSchemeHandler:scheme_handler_ - forURLScheme:base::SysUTF8ToNSString(scheme)]; - } - - for (auto& observer : observers_) - observer.DidCreateNewConfiguration(this, configuration_); - - // Workaround to force the creation of the WKWebsiteDataStore. This - // workaround need to be done here, because this method returns a copy of - // the already created configuration. - NSSet* data_types = [NSSet setWithObject:WKWebsiteDataTypeCookies]; - [configuration_.websiteDataStore - fetchDataRecordsOfTypes:data_types - completionHandler:^(NSArray<WKWebsiteDataRecord*>* records){ - }]; + ResetWithWebViewConfiguration(nil); } // This is a shallow copy to prevent callers from changing the internals of
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider_unittest.mm b/ios/web/web_state/ui/wk_web_view_configuration_provider_unittest.mm index 2c8eddd..70557590 100644 --- a/ios/web/web_state/ui/wk_web_view_configuration_provider_unittest.mm +++ b/ios/web/web_state/ui/wk_web_view_configuration_provider_unittest.mm
@@ -182,5 +182,34 @@ EXPECT_FALSE(observer.GetLastCreatedWKConfiguration()); } +// Tests that if -[ResetWithWebViewConfiguration:] copies and applies Chrome's +// initialization logic to the |config| that passed into that method +TEST_F(WKWebViewConfigurationProviderTest, ResetConfiguration) { + std::unique_ptr<TestBrowserState> browser_state = + std::make_unique<TestBrowserState>(); + WKWebViewConfigurationProvider* provider = &GetProvider(browser_state.get()); + + FakeWKConfigurationProviderObserver observer(provider); + ASSERT_FALSE(observer.GetLastCreatedWKConfiguration()); + + WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc] init]; + config.allowsInlineMediaPlayback = NO; + provider->ResetWithWebViewConfiguration(config); + WKWebViewConfiguration* actual = observer.GetLastCreatedWKConfiguration(); + ASSERT_TRUE(actual); + + // To check the configuration inside is reset. + EXPECT_EQ(config.preferences, actual.preferences); + + // To check Chrome's initialization logic has been applied to |actual|, + // where the |actual.allowsInlineMediaPlayback| should be overwriten by YES. + EXPECT_EQ(NO, config.allowsInlineMediaPlayback); + EXPECT_EQ(YES, actual.allowsInlineMediaPlayback); + + // Compares the POINTERS to make sure the |config| has been shallow cloned + // inside the |provider|. + EXPECT_NE(config, actual); +} + } // namespace } // namespace web
diff --git a/ios/web/web_view_only/BUILD.gn b/ios/web/web_view_only/BUILD.gn new file mode 100644 index 0000000..05e4d1f2 --- /dev/null +++ b/ios/web/web_view_only/BUILD.gn
@@ -0,0 +1,47 @@ +# 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. + +import("//ios/build/config.gni") + +source_set("web_view_only") { + configs += [ "//build/config/compiler:enable_arc" ] + + sources = [ + "wk_web_view_configuration_util.mm", + ] + + deps = [ + "//base", + "//ios/web/public/web_view_only:web_view_only_api_header", + "//ios/web/web_state:web_state_impl_header", + "//ios/web/web_state/ui", + "//ios/web/web_state/ui:wk_web_view_configuration_provider", + ] + + visibility = [ + ":*", + "//ios/web/public/web_view_only:*", + ] +} + +source_set("unittests") { + configs += [ "//build/config/compiler:enable_arc" ] + testonly = true + + sources = [ + "wk_web_view_configuration_util_unittests.mm", + ] + + deps = [ + "//base", + "//ios/web/public/web_view_only", + "//ios/web/test:test_support", + "//third_party/webrtc/rtc_base", + ] + + visibility = [ + ":*", + "//ios/web/public/web_view_only:*", + ] +}
diff --git a/ios/web/web_view_only/wk_web_view_configuration_util.mm b/ios/web/web_view_only/wk_web_view_configuration_util.mm new file mode 100644 index 0000000..62e2430 --- /dev/null +++ b/ios/web/web_view_only/wk_web_view_configuration_util.mm
@@ -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. + +#import "ios/web/public/web_view_only/wk_web_view_configuration_util.h" + +#import <WebKit/WebKit.h> + +#import "ios/web/web_state/ui/crw_web_controller.h" +#import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" +#import "ios/web/web_state/web_state_impl.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +namespace web { + +WKWebView* EnsureWebViewCreatedWithConfiguration( + WebState* web_state, + WKWebViewConfiguration* configuration) { + WebStateImpl* impl = static_cast<WebStateImpl*>(web_state); + BrowserState* browser_state = impl->GetBrowserState(); + CRWWebController* web_controller = impl->GetWebController(); + + WKWebViewConfigurationProvider& provider = + WKWebViewConfigurationProvider::FromBrowserState(browser_state); + provider.ResetWithWebViewConfiguration(configuration); + + // |web_controller| will get the |configuration| from the |provider| to create + // the webView to return. + return [web_controller ensureWebViewCreated]; +} + +} // namespace web
diff --git a/ios/web/web_view_only/wk_web_view_configuration_util_unittests.mm b/ios/web/web_view_only/wk_web_view_configuration_util_unittests.mm new file mode 100644 index 0000000..da65183 --- /dev/null +++ b/ios/web/web_view_only/wk_web_view_configuration_util_unittests.mm
@@ -0,0 +1,37 @@ +// 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. + +#import "ios/web/public/web_view_only/wk_web_view_configuration_util.h" + +#import <WebKit/WebKit.h> + +#import "ios/web/test/web_test_with_web_controller.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +namespace web { + +// Tests for all web_view_only APIs in //ios/web/public/web_view_only +using WebViewOnlyAPITest = web::WebTestWithWebController; + +// A test for web::EnsureWebViewCreatedWithConfiguration() +TEST_F(WebViewOnlyAPITest, EnsureWebViewCreatedWithConfiguration) { + WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc] init]; + const CGFloat kMinimumFontSize = 99; + config.preferences.minimumFontSize = kMinimumFontSize; + + [web_controller() removeWebView]; + WKWebView* web_view = + web::EnsureWebViewCreatedWithConfiguration(web_state(), config); + + ASSERT_TRUE(web_view); + EXPECT_EQ(kMinimumFontSize, + web_view.configuration.preferences.minimumFontSize); + + [web_controller() removeWebView]; +} + +} // namespace
diff --git a/ios/web_view/BUILD.gn b/ios/web_view/BUILD.gn index 5a4b392..b567cac 100644 --- a/ios/web_view/BUILD.gn +++ b/ios/web_view/BUILD.gn
@@ -320,6 +320,7 @@ "//ios/web/public/deprecated", "//ios/web/public/security", "//ios/web/public/js_messaging", + "//ios/web/public/web_view_only", "//net", "//net:extras", "//services/metrics/public/cpp:metrics_cpp",
diff --git a/ios/web_view/internal/cwv_web_view.mm b/ios/web_view/internal/cwv_web_view.mm index de2a9d1..70bcec2a 100644 --- a/ios/web_view/internal/cwv_web_view.mm +++ b/ios/web_view/internal/cwv_web_view.mm
@@ -8,6 +8,8 @@ #include <unordered_map> #include <utility> +#import <WebKit/WebKit.h> + #include "base/bind.h" #include "base/json/json_writer.h" #include "base/mac/foundation_util.h" @@ -34,6 +36,7 @@ #import "ios/web/public/web_state.h" #import "ios/web/public/web_state_delegate_bridge.h" #import "ios/web/public/web_state_observer_bridge.h" +#import "ios/web/public/web_view_only/wk_web_view_configuration_util.h" #include "ios/web_view/cwv_web_view_buildflags.h" #import "ios/web_view/internal/autofill/cwv_autofill_controller_internal.h" #import "ios/web_view/internal/cwv_favicon_internal.h" @@ -215,12 +218,25 @@ - (instancetype)initWithFrame:(CGRect)frame configuration:(CWVWebViewConfiguration*)configuration { + return [self initWithFrame:frame + configuration:configuration + WKConfiguration:nil + createdWKWebView:nil]; +} + +- (instancetype)initWithFrame:(CGRect)frame + configuration:(CWVWebViewConfiguration*)configuration + WKConfiguration:(WKWebViewConfiguration*)wkConfiguration + createdWKWebView:(WKWebView**)createdWebView { self = [super initWithFrame:frame]; if (self) { _configuration = configuration; [_configuration registerWebView:self]; _scrollView = [[CWVScrollView alloc] init]; - [self resetWebStateWithSessionStorage:nil]; + + [self resetWebStateWithSessionStorage:nil + WKConfiguration:wkConfiguration + createdWKWebView:createdWebView]; } return self; } @@ -586,7 +602,9 @@ [super decodeRestorableStateWithCoder:coder]; CRWSessionStorage* sessionStorage = [coder decodeObjectForKey:kSessionStorageKey]; - [self resetWebStateWithSessionStorage:sessionStorage]; + [self resetWebStateWithSessionStorage:sessionStorage + WKConfiguration:nil + createdWKWebView:nil]; } #pragma mark - Private methods @@ -605,8 +623,15 @@ // Creates a WebState instance and assigns it to |_webState|. // It replaces the old |_webState| if any. // The WebState is restored from |sessionStorage| if provided. -- (void)resetWebStateWithSessionStorage: - (nullable CRWSessionStorage*)sessionStorage { +// +// If |wkConfiguration| is provided, the underlying WKWebView is +// initialized with |wkConfiguration|, and assigned to +// |*createdWKWebView| if |createdWKWebView| is not nil. +// |*createdWKWebView| will be provided only if |wkConfiguration| is provided, +// otherwise it will always be reset to nil. +- (void)resetWebStateWithSessionStorage:(CRWSessionStorage*)sessionStorage + WKConfiguration:(WKWebViewConfiguration*)wkConfiguration + createdWKWebView:(WKWebView**)createdWebView { if (_webState) { if (_webStateObserver) { _webState->RemoveObserver(_webStateObserver.get()); @@ -632,6 +657,19 @@ _webState = web::WebState::Create(webStateCreateParams); } + // WARNING: NOTHING should be here between |web::WebState::Create()| and + // |web::EnsureWebViewCreatedWithConfiguration()|, as this is the requirement + // of |web::EnsureWebViewCreatedWithConfiguration()| + + WKWebView* webView = nil; + if (wkConfiguration) { + webView = web::EnsureWebViewCreatedWithConfiguration(_webState.get(), + wkConfiguration); + } + if (createdWebView) { + *createdWebView = webView; + } + WebViewHolder::CreateForWebState(_webState.get()); WebViewHolder::FromWebState(_webState.get())->set_web_view(self);
diff --git a/ios/web_view/public/cwv_web_view.h b/ios/web_view/public/cwv_web_view.h index 07522c3..a1d292f 100644 --- a/ios/web_view/public/cwv_web_view.h +++ b/ios/web_view/public/cwv_web_view.h
@@ -6,6 +6,7 @@ #define IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_H_ #import <UIKit/UIKit.h> +#import <WebKit/WebKit.h> #import "cwv_export.h" @@ -137,7 +138,22 @@ clientSecret:(NSString*)clientSecret; - (instancetype)initWithFrame:(CGRect)frame + configuration:(CWVWebViewConfiguration*)configuration; + +// If |wkConfiguration| is provided, the underlying WKWebView is +// initialized with |wkConfiguration|, and assigned to +// |*createdWKWebView| if |createdWKWebView| is not nil. +// |*createdWKWebView| will be provided only if |wkConfiguration| is provided, +// otherwise it will always be reset to nil. +// +// IMPORTANT: Use |*createdWKWebView| just as a return value of +// -[WKNavigationDelegate +// webView:createWebViewWithConfiguration:...], but for nothing +// else. e.g., You must not access its properties/methods. +- (instancetype)initWithFrame:(CGRect)frame configuration:(CWVWebViewConfiguration*)configuration + WKConfiguration:(nullable WKWebViewConfiguration*)wkConfiguration + createdWKWebView:(WKWebView* _Nullable* _Nullable)createdWebView NS_DESIGNATED_INITIALIZER; - (instancetype)initWithFrame:(CGRect)frame NS_UNAVAILABLE;
diff --git a/ios/web_view/test/BUILD.gn b/ios/web_view/test/BUILD.gn index 6be5a3f..1cc41808 100644 --- a/ios/web_view/test/BUILD.gn +++ b/ios/web_view/test/BUILD.gn
@@ -13,6 +13,7 @@ "scroll_view_kvo_inttest.mm", "ui_delegate_inttest.mm", "web_view_autofill_inttest.mm", + "web_view_from_wk_web_view_configuration_inttest.mm", "web_view_inttest.mm", "web_view_inttest_base.h", "web_view_inttest_base.mm",
diff --git a/ios/web_view/test/web_view_from_wk_web_view_configuration_inttest.mm b/ios/web_view/test/web_view_from_wk_web_view_configuration_inttest.mm new file mode 100644 index 0000000..52348a4 --- /dev/null +++ b/ios/web_view/test/web_view_from_wk_web_view_configuration_inttest.mm
@@ -0,0 +1,202 @@ +// 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. + +#import <ChromeWebView/ChromeWebView.h> +#import <Foundation/Foundation.h> + +#import "base/test/ios/wait_util.h" +#import "ios/web_view/test/observer.h" +#import "ios/web_view/test/web_view_inttest_base.h" +#import "ios/web_view/test/web_view_test_util.h" +#import "net/base/mac/url_conversions.h" +#include "net/test/embedded_test_server/embedded_test_server.h" +#include "testing/gtest_mac.h" +#include "url/gurl.h" + +#if !defined(__has_feature) || !__has_feature(objc_arc) +#error "This file requires ARC support." +#endif + +namespace ios_web_view { + +// Tests if a CWVWebView can be created from a WKWebViewConfiguration outside +// //ios/web +class WebViewFromWKWebViewConfigurationTest : public WebViewInttestBase { + public: + // This method is called by the delegate method called when window.open() is + // called, and the |webView| argument is the newly opened CWVWebView by the + // window.open() call in a normal WKWebView. Saves the |webView| for further + // tests and inserts it into the View Hierarchy tree. + void SetWebView(CWVWebView* webView) { + [web_view_ removeFromSuperview]; + web_view_ = webView; + UIViewController* view_controller = + [[[UIApplication sharedApplication] keyWindow] rootViewController]; + [view_controller.view addSubview:web_view_]; + } + + // This method is called by the delegate method called when window.open() is + // called, and the |returned_wk_web_view| argument is the internal WKWebView + // of the newly opened CWVWebView by the window.open() call in a normal + // WKWebView. Saves the |returned_wk_web_view| for further tests. + void SetReturnedWKWebView(WKWebView* returned_wk_web_view) { + returned_wk_web_view_ = returned_wk_web_view; + } + + protected: + WebViewFromWKWebViewConfigurationTest() { + // This |CWVWebView *web_view_| is inherited from the base class, but in + // this test case I don't hope to use it, because I need to test a newly + // opened CWVWebView by a window.open() call in a normal WKWebView, instead + // of this one directly generated by the base class from default + // configuration. + [web_view_ removeFromSuperview]; + web_view_ = nil; + } + + void GenerateTestPageUrls() { + window1_url_ = GetUrlForPageWithHtmlBody("<p>page1</p>"); + window2_url_ = GetUrlForPageWithHtmlBody("<p>page2</p>"); + } + + WKWebView* returned_wk_web_view_ = nil; + GURL window1_url_; + GURL window2_url_; +}; + +} // namespace ios_web_view + +@interface WKUIDelegateForTest : NSObject <WKUIDelegate> +- (instancetype)init NS_UNAVAILABLE; + +- (instancetype)initWithTest: + (ios_web_view::WebViewFromWKWebViewConfigurationTest*)test + NS_DESIGNATED_INITIALIZER; +@end + +@implementation WKUIDelegateForTest { + ios_web_view::WebViewFromWKWebViewConfigurationTest* _test; +} + +- (instancetype)initWithTest: + (ios_web_view::WebViewFromWKWebViewConfigurationTest*)test { + self = [super init]; + if (self) { + _test = test; + } + return self; +} + +- (WKWebView*)webView:(WKWebView*)webView + createWebViewWithConfiguration:(WKWebViewConfiguration*)configuration + forNavigationAction:(WKNavigationAction*)action + windowFeatures:(WKWindowFeatures*)windowFeatures { + WKWebView* created_web_view = nil; + _test->SetWebView([[CWVWebView alloc] + initWithFrame:UIScreen.mainScreen.bounds + configuration:[CWVWebViewConfiguration defaultConfiguration] + WKConfiguration:configuration + createdWKWebView:&created_web_view]); + _test->SetReturnedWKWebView(created_web_view); + return created_web_view; +} +@end + +@interface NavigationFinishedObserver + : NSObject <WKNavigationDelegate, CWVNavigationDelegate> +@property(nonatomic) BOOL navigationFinished; +@end + +@implementation NavigationFinishedObserver +- (void)webView:(WKWebView*)webView + didFinishNavigation:(WKNavigation*)navigation { + self.navigationFinished = YES; +} +- (void)webViewDidFinishNavigation:(CWVWebView*)webView { + self.navigationFinished = YES; +} +@end + +namespace ios_web_view { + +// Tests if a CWVWebView can be created from -[CWVWebView +// initWithFrame:configuration:WKConfiguration:createdWKWebView] +TEST_F(WebViewFromWKWebViewConfigurationTest, FromWKWebViewConfiguration) { + ASSERT_TRUE(test_server_->Start()); + + CGRect frame = UIScreen.mainScreen.bounds; + WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc] init]; + WKWebView* wk_web_view = [[WKWebView alloc] initWithFrame:frame + configuration:config]; + WKUIDelegateForTest* wk_ui_delegate_for_test = + [[WKUIDelegateForTest alloc] initWithTest:this]; + wk_web_view.UIDelegate = wk_ui_delegate_for_test; + + NavigationFinishedObserver* observer = + [[NavigationFinishedObserver alloc] init]; + UIViewController* view_controller = + [[[UIApplication sharedApplication] keyWindow] rootViewController]; + [view_controller.view addSubview:wk_web_view]; + + // Loads a page in wk_web_view and waits for its completion + GenerateTestPageUrls(); + wk_web_view.navigationDelegate = observer; + [wk_web_view loadRequest:[[NSURLRequest alloc] + initWithURL:net::NSURLWithGURL(window1_url_)]]; + using base::test::ios::kWaitForPageLoadTimeout; + ASSERT_TRUE( + base::test::ios::WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^{ + return observer.navigationFinished; + })); + wk_web_view.navigationDelegate = nil; + + // Checks if the page in window1 (wk_web_view) is loaded, by a line of + // JavaScript + __block BOOL is_js_evaluated = NO; + [wk_web_view evaluateJavaScript:@"document.body.innerText" + completionHandler:^(NSString* result, NSError* error) { + ASSERT_FALSE(error); + EXPECT_NSEQ(@"page1", result); + is_js_evaluated = YES; + }]; + using base::test::ios::kWaitForJSCompletionTimeout; + ASSERT_TRUE(base::test::ios::WaitUntilConditionOrTimeout( + kWaitForJSCompletionTimeout, ^{ + return is_js_evaluated; + })); + + // Opens a new CWVWebView from the wk_web_view + NSString* url_string = net::NSURLWithGURL(window2_url_).absoluteString; + NSString* script = + [NSString stringWithFormat:@"window.open('%@')", url_string]; + is_js_evaluated = NO; + [wk_web_view evaluateJavaScript:script + completionHandler:^(NSString* result, NSError* error) { + is_js_evaluated = YES; + }]; + ASSERT_TRUE(base::test::ios::WaitUntilConditionOrTimeout( + kWaitForJSCompletionTimeout, ^{ + return is_js_evaluated; + })); + ASSERT_TRUE(returned_wk_web_view_); + ASSERT_TRUE(web_view_); + + // Waits for the page in window2 (CWVWebView *web_view_) to be loaded + observer.navigationFinished = NO; + web_view_.navigationDelegate = observer; + ASSERT_TRUE( + base::test::ios::WaitUntilConditionOrTimeout(kWaitForPageLoadTimeout, ^{ + return observer.navigationFinished; + })); + web_view_.navigationDelegate = nil; + + // Checks if the page in web_view_ is loaded successfully + NSString* inner_text = + test::EvaluateJavaScript(web_view_, @"document.body.innerText", nil); + EXPECT_NSEQ(@"page2", inner_text); + + [wk_web_view removeFromSuperview]; +} + +} // namespace ios_web_view
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc index 6e358325..c9f0223 100644 --- a/media/base/media_switches.cc +++ b/media/base/media_switches.cc
@@ -313,6 +313,11 @@ const base::Feature kGlobalMediaControlsForCast{ "GlobalMediaControlsForCast", base::FEATURE_DISABLED_BY_DEFAULT}; +// Allow global media controls notifications to be dragged out into overlay +// notifications. It is no-op if kGlobalMediaControls is not enabled. +const base::Feature kGlobalMediaControlsOverlayControls{ + "GlobalMediaControlsOverlayControls", base::FEATURE_DISABLED_BY_DEFAULT}; + // Enable new cpu load estimator. Intended for evaluation in local // testing and origin-trial. // TODO(nisse): Delete once we have switched over to always using the
diff --git a/media/base/media_switches.h b/media/base/media_switches.h index 027a4d6..eeb3c198 100644 --- a/media/base/media_switches.h +++ b/media/base/media_switches.h
@@ -113,6 +113,7 @@ MEDIA_EXPORT extern const base::Feature kFallbackAfterDecodeError; MEDIA_EXPORT extern const base::Feature kGlobalMediaControls; MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsForCast; +MEDIA_EXPORT extern const base::Feature kGlobalMediaControlsOverlayControls; MEDIA_EXPORT extern const base::Feature kHardwareMediaKeyHandling; MEDIA_EXPORT extern const base::Feature kHardwareSecureDecryption; MEDIA_EXPORT extern const base::Feature kInternalMediaSession;
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc index 89a53086..d9f3f8d 100644 --- a/media/base/pipeline_impl.cc +++ b/media/base/pipeline_impl.cc
@@ -1148,6 +1148,7 @@ if (!IsRunning()) { DLOG(ERROR) << "Media pipeline isn't running. Ignoring Seek()."; + seek_cb.Run(PIPELINE_ERROR_INVALID_STATE); return; } @@ -1212,8 +1213,12 @@ DVLOG(2) << __func__ << "(" << playback_rate << ")"; DCHECK(thread_checker_.CalledOnValidThread()); - if (playback_rate < 0.0) + // Not checking IsRunning() so we can set the playback rate before Start(). + + if (playback_rate < 0.0) { + DVLOG(1) << __func__ << ": Invalid playback rate " << playback_rate; return; + } playback_rate_ = playback_rate; media_task_runner_->PostTask( @@ -1231,8 +1236,12 @@ DVLOG(2) << __func__ << "(" << volume << ")"; DCHECK(thread_checker_.CalledOnValidThread()); - if (volume < 0.0f) + // Not checking IsRunning() so we can set the volume before Start(). + + if (volume < 0.0f) { + DVLOG(1) << __func__ << ": Invalid volume " << volume; return; + } volume_ = volume; media_task_runner_->PostTask( @@ -1298,6 +1307,8 @@ DCHECK(cdm_context); DCHECK(cdm_attached_cb); + // Not checking IsRunning() so we can set the CDM before Start(). + media_task_runner_->PostTask( FROM_HERE, base::BindOnce(&RendererWrapper::SetCdm,
diff --git a/media/base/pipeline_impl_unittest.cc b/media/base/pipeline_impl_unittest.cc index 1cee0c3a..40847af 100644 --- a/media/base/pipeline_impl_unittest.cc +++ b/media/base/pipeline_impl_unittest.cc
@@ -368,24 +368,28 @@ DISALLOW_COPY_AND_ASSIGN(PipelineImplTest); }; -// Test that playback controls methods no-op when the pipeline hasn't been +// Test that playback controls methods can be set even before the pipeline is // started. -TEST_F(PipelineImplTest, NotStarted) { +TEST_F(PipelineImplTest, ControlMethods) { const base::TimeDelta kZero; EXPECT_FALSE(pipeline_->IsRunning()); - // Setting should still work. + // Initial value. EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); + // Invalid values cannot be set. pipeline_->SetPlaybackRate(-1.0); EXPECT_EQ(0.0f, pipeline_->GetPlaybackRate()); + // Valid settings should work. pipeline_->SetPlaybackRate(1.0); EXPECT_EQ(1.0f, pipeline_->GetPlaybackRate()); - // Setting should still work. + // Initial value. EXPECT_EQ(1.0f, pipeline_->GetVolume()); + // Invalid values cannot be set. pipeline_->SetVolume(-1.0f); EXPECT_EQ(1.0f, pipeline_->GetVolume()); + // Valid settings should work. pipeline_->SetVolume(0.0f); EXPECT_EQ(0.0f, pipeline_->GetVolume()); @@ -575,6 +579,7 @@ OnDemuxerError(); base::RunLoop().RunUntilIdle(); + EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_INVALID_STATE)); pipeline_->Seek( base::TimeDelta::FromMilliseconds(100), base::Bind(&CallbackHelper::OnSeek, base::Unretained(&callbacks_))); @@ -701,54 +706,6 @@ base::RunLoop().RunUntilIdle(); } -// Invoked function OnError. This asserts that the pipeline does not enqueue -// non-teardown related tasks while tearing down. -static void TestNoCallsAfterError( - PipelineImpl* pipeline, - base::test::SingleThreadTaskEnvironment* task_environment, - PipelineStatus /* status */) { - CHECK(pipeline); - CHECK(task_environment); - - // When we get to this stage, there should be no pending tasks. - EXPECT_EQ(0u, task_environment->GetPendingMainThreadTaskCount()); - - // Make calls on pipeline after error has occurred. - pipeline->SetPlaybackRate(0.5); - pipeline->SetVolume(0.5f); - - // No additional tasks should be queued as a result of these calls. - EXPECT_EQ(0u, task_environment->GetPendingMainThreadTaskCount()); -} - -TEST_F(PipelineImplTest, NoMessageDuringTearDownFromError) { - CreateAudioStream(); - SetDemuxerExpectations(); - StartPipelineAndExpect(PIPELINE_OK); - - // Trigger additional requests on the pipeline during tear down from error. - ON_CALL(callbacks_, OnError(_)) - .WillByDefault(Invoke([=](PipelineStatus status) { - TestNoCallsAfterError(pipeline_.get(), &task_environment_, status); - })); - - base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5); - - // Seek() isn't called as the demuxer errors out first. - EXPECT_CALL(*renderer_, OnFlush(_)).WillOnce(RunOnceClosure<0>()); - - EXPECT_CALL(*demuxer_, AbortPendingReads()); - EXPECT_CALL(*demuxer_, OnSeek(seek_time, _)) - .WillOnce(RunOnceCallback<1>(PIPELINE_ERROR_READ)); - EXPECT_CALL(*demuxer_, Stop()); - - pipeline_->Seek(seek_time, base::Bind(&CallbackHelper::OnSeek, - base::Unretained(&callbacks_))); - EXPECT_CALL(callbacks_, OnSeek(PIPELINE_ERROR_READ)) - .WillOnce(Stop(pipeline_.get())); - base::RunLoop().RunUntilIdle(); -} - TEST_F(PipelineImplTest, DestroyAfterStop) { CreateAudioStream(); SetDemuxerExpectations();
diff --git a/media/capture/video/chromeos/camera_device_delegate.cc b/media/capture/video/chromeos/camera_device_delegate.cc index 9e13371..f8d26165 100644 --- a/media/capture/video/chromeos/camera_device_delegate.cc +++ b/media/capture/video/chromeos/camera_device_delegate.cc
@@ -765,8 +765,15 @@ device_context_->GetState() == CameraDeviceContext::State::kCapturing); if (stream_type == StreamType::kPreviewOutput) { + // CCA uses the same stream for preview and video recording. Choose proper + // template here so the underlying camera HAL can set 3A tuning accordingly. + auto request_template = + camera_app_device_ && camera_app_device_->GetCaptureIntent() == + cros::mojom::CaptureIntent::VIDEO_RECORD + ? cros::mojom::Camera3RequestTemplate::CAMERA3_TEMPLATE_VIDEO_RECORD + : cros::mojom::Camera3RequestTemplate::CAMERA3_TEMPLATE_PREVIEW; device_ops_->ConstructDefaultRequestSettings( - cros::mojom::Camera3RequestTemplate::CAMERA3_TEMPLATE_PREVIEW, + request_template, base::BindOnce( &CameraDeviceDelegate::OnConstructedDefaultPreviewRequestSettings, GetWeakPtr()));
diff --git a/media/gpu/v4l2/v4l2_device.cc b/media/gpu/v4l2/v4l2_device.cc index c720c06e6..7ad3bc9 100644 --- a/media/gpu/v4l2/v4l2_device.cc +++ b/media/gpu/v4l2/v4l2_device.cc
@@ -1177,85 +1177,125 @@ } // static -VideoCodecProfile V4L2Device::V4L2VP9ProfileToVideoCodecProfile( - uint32_t profile) { - switch (profile) { - case V4L2_MPEG_VIDEO_VP9_PROFILE_0: - return VP9PROFILE_PROFILE0; - case V4L2_MPEG_VIDEO_VP9_PROFILE_1: - return VP9PROFILE_PROFILE1; - case V4L2_MPEG_VIDEO_VP9_PROFILE_2: - return VP9PROFILE_PROFILE2; - case V4L2_MPEG_VIDEO_VP9_PROFILE_3: - return VP9PROFILE_PROFILE3; +VideoCodecProfile V4L2Device::V4L2ProfileToVideoCodecProfile(VideoCodec codec, + uint32_t profile) { + switch (codec) { + case kCodecH264: + switch (profile) { + case V4L2_MPEG_VIDEO_H264_PROFILE_BASELINE: + case V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_BASELINE: + return H264PROFILE_BASELINE; + case V4L2_MPEG_VIDEO_H264_PROFILE_MAIN: + return H264PROFILE_MAIN; + case V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED: + return H264PROFILE_EXTENDED; + case V4L2_MPEG_VIDEO_H264_PROFILE_HIGH: + return H264PROFILE_HIGH; + } + break; + case kCodecVP8: + switch (profile) { + case V4L2_MPEG_VIDEO_VP8_PROFILE_0: + case V4L2_MPEG_VIDEO_VP8_PROFILE_1: + case V4L2_MPEG_VIDEO_VP8_PROFILE_2: + case V4L2_MPEG_VIDEO_VP8_PROFILE_3: + return VP8PROFILE_ANY; + } + break; + case kCodecVP9: + switch (profile) { + case V4L2_MPEG_VIDEO_VP9_PROFILE_0: + return VP9PROFILE_PROFILE0; + case V4L2_MPEG_VIDEO_VP9_PROFILE_1: + return VP9PROFILE_PROFILE1; + case V4L2_MPEG_VIDEO_VP9_PROFILE_2: + return VP9PROFILE_PROFILE2; + case V4L2_MPEG_VIDEO_VP9_PROFILE_3: + return VP9PROFILE_PROFILE3; + } + break; default: - VLOGF(2) << "Not a VP9 profile: " << profile; - return VIDEO_CODEC_PROFILE_UNKNOWN; + VLOGF(2) << "Unknown codec: " << codec; } + VLOGF(2) << "Unknown profile: " << profile; + return VIDEO_CODEC_PROFILE_UNKNOWN; } -// static std::vector<VideoCodecProfile> V4L2Device::V4L2PixFmtToVideoCodecProfiles( uint32_t pix_fmt, bool is_encoder) { - VideoCodecProfile min_profile, max_profile; - std::vector<VideoCodecProfile> profiles; + auto get_supported_profiles = [this]( + VideoCodec codec, + std::vector<VideoCodecProfile>* profiles) { + uint32_t query_id = 0; + switch (codec) { + case kCodecH264: + query_id = V4L2_CID_MPEG_VIDEO_H264_PROFILE; + break; + case kCodecVP8: + query_id = V4L2_CID_MPEG_VIDEO_VP8_PROFILE; + break; + case kCodecVP9: + query_id = V4L2_CID_MPEG_VIDEO_VP9_PROFILE; + break; + default: + return false; + } + v4l2_queryctrl query_ctrl = {}; + query_ctrl.id = query_id; + if (Ioctl(VIDIOC_QUERYCTRL, &query_ctrl) != 0) { + return false; + } + v4l2_querymenu query_menu = {}; + query_menu.id = query_ctrl.id; + for (query_menu.index = query_ctrl.minimum; + static_cast<int>(query_menu.index) <= query_ctrl.maximum; + query_menu.index++) { + if (Ioctl(VIDIOC_QUERYMENU, &query_menu) == 0) { + const VideoCodecProfile profile = + V4L2Device::V4L2ProfileToVideoCodecProfile(codec, query_menu.index); + if (profile != VIDEO_CODEC_PROFILE_UNKNOWN) + profiles->push_back(profile); + } + } + return true; + }; + + std::vector<VideoCodecProfile> profiles; switch (pix_fmt) { case V4L2_PIX_FMT_H264: case V4L2_PIX_FMT_H264_SLICE: - if (is_encoder) { - // TODO(posciak): need to query the device for supported H.264 profiles, - // for now choose Main as a sensible default. - min_profile = H264PROFILE_MAIN; - max_profile = H264PROFILE_MAIN; - } else { - min_profile = H264PROFILE_MIN; - max_profile = H264PROFILE_MAX; + if (!get_supported_profiles(kCodecH264, &profiles)) { + DLOG(WARNING) << "Driver doesn't support QUERY H264 profiles, " + << "use default values, Base, Main, High"; + profiles = { + H264PROFILE_BASELINE, + H264PROFILE_MAIN, + H264PROFILE_HIGH, + }; } break; - case V4L2_PIX_FMT_VP8: case V4L2_PIX_FMT_VP8_FRAME: - min_profile = VP8PROFILE_MIN; - max_profile = VP8PROFILE_MAX; + profiles = {VP8PROFILE_ANY}; break; - case V4L2_PIX_FMT_VP9: - case V4L2_PIX_FMT_VP9_FRAME: { - v4l2_queryctrl query_ctrl = {}; - query_ctrl.id = V4L2_CID_MPEG_VIDEO_VP9_PROFILE; - if (Ioctl(VIDIOC_QUERYCTRL, &query_ctrl) == 0) { - v4l2_querymenu query_menu = {}; - query_menu.id = query_ctrl.id; - for (query_menu.index = query_ctrl.minimum; - static_cast<int>(query_menu.index) <= query_ctrl.maximum; - query_menu.index++) { - if (Ioctl(VIDIOC_QUERYMENU, &query_menu) == 0) { - const VideoCodecProfile profile = - V4L2VP9ProfileToVideoCodecProfile(query_menu.index); - if (profile != VIDEO_CODEC_PROFILE_UNKNOWN) - profiles.push_back(profile); - } - } - return profiles; - } else { - // TODO(keiichiw): need a fallback here? - VLOGF(2) << "V4L2_CID_MPEG_VIDEO_VP9_PROFILE is not supported."; - min_profile = VP9PROFILE_PROFILE0; - max_profile = VP9PROFILE_PROFILE0; + case V4L2_PIX_FMT_VP9_FRAME: + if (!get_supported_profiles(kCodecVP9, &profiles)) { + DLOG(WARNING) << "Driver doesn't support QUERY VP9 profiles, " + << "use default values, Profile0"; + profiles = {VP9PROFILE_PROFILE0}; } break; - } - default: VLOGF(1) << "Unhandled pixelformat " << FourccToString(pix_fmt); - return profiles; + return {}; } - for (int profile = min_profile; profile <= max_profile; ++profile) - profiles.push_back(static_cast<VideoCodecProfile>(profile)); - + // Erase duplicated profiles. + std::sort(profiles.begin(), profiles.end()); + profiles.erase(std::unique(profiles.begin(), profiles.end()), profiles.end()); return profiles; }
diff --git a/media/gpu/v4l2/v4l2_device.h b/media/gpu/v4l2/v4l2_device.h index d9424ce..8e5fb187 100644 --- a/media/gpu/v4l2/v4l2_device.h +++ b/media/gpu/v4l2/v4l2_device.h
@@ -21,6 +21,7 @@ #include "base/memory/ref_counted.h" #include "base/optional.h" #include "base/sequence_checker.h" +#include "media/base/video_codecs.h" #include "media/base/video_decoder_config.h" #include "media/base/video_frame.h" #include "media/base/video_frame_layout.h" @@ -384,7 +385,8 @@ // If there is no corresponding single- or multi-planar format, returns 0. static uint32_t VideoCodecProfileToV4L2PixFmt(VideoCodecProfile profile, bool slice_based); - static VideoCodecProfile V4L2VP9ProfileToVideoCodecProfile(uint32_t profile); + static VideoCodecProfile V4L2ProfileToVideoCodecProfile(VideoCodec codec, + uint32_t profile); std::vector<VideoCodecProfile> V4L2PixFmtToVideoCodecProfiles( uint32_t pix_fmt, bool is_encoder);
diff --git a/mojo/public/js/interface_support.js b/mojo/public/js/interface_support.js index 2373f382..6d95bb8 100644 --- a/mojo/public/js/interface_support.js +++ b/mojo/public/js/interface_support.js
@@ -375,15 +375,6 @@ this.remote_ = remote; } - // TODO(ortuno): Remove once new names are used in the exposed interfaces. - /** - * @return {!T} - * @export - */ - createRequest() { - return this.remote_.bindNewPipeAndPassReceiver(); - } - /** * @return {!T} * @export @@ -727,18 +718,6 @@ this.helper_internal_.bindHandle(handle); } - // TODO(ortuno): Remove once new names are used in the exposed interfaces. - /** - * Returns a remote for this interface which sends messages directly to this - * object. Any number of proxies may be created to the same object. - * - * @return {!T} - * @export - */ - createProxy() { - return this.helper_internal_.bindNewPipeAndPassRemote(); - } - /** * @return {!T} * @export
diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h index 9a36c978..912a6b56 100644 --- a/net/base/net_error_list.h +++ b/net/base/net_error_list.h
@@ -965,5 +965,7 @@ // Failed to sort addresses according to RFC3484. NET_ERROR(DNS_SORT_ERROR, -806) -// Failed to resolve over HTTP, fallback to legacy -NET_ERROR(DNS_HTTP_FAILED, -807) +// Error -807 was removed (DNS_HTTP_FAILED) + +// Failed to resolve the hostname of a DNS-over-HTTPS server. +NET_ERROR(DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED, -808)
diff --git a/net/dns/context_host_resolver.cc b/net/dns/context_host_resolver.cc index c2c84ce..d6e7ead 100644 --- a/net/dns/context_host_resolver.cc +++ b/net/dns/context_host_resolver.cc
@@ -23,30 +23,22 @@ // Wrapper of ResolveHostRequests that on destruction will remove itself from // |ContextHostResolver::handed_out_requests_|. -class ContextHostResolver::WrappedRequest - : public HostResolver::ResolveHostRequest { +class ContextHostResolver::WrappedRequest { public: - WrappedRequest( - std::unique_ptr<HostResolverManager::CancellableRequest> inner_request, - ContextHostResolver* resolver, - bool shutting_down) - : inner_request_(std::move(inner_request)), - resolver_(resolver), - shutting_down_(shutting_down) { + WrappedRequest(ContextHostResolver* resolver, bool shutting_down) + : resolver_(resolver), shutting_down_(shutting_down) { DCHECK_CALLED_ON_VALID_SEQUENCE(resolver_->sequence_checker_); } - ~WrappedRequest() override { Cancel(); } + WrappedRequest(const WrappedRequest&) = delete; + WrappedRequest& operator=(const WrappedRequest&) = delete; + + virtual ~WrappedRequest() { DetachFromResolver(); } void Cancel() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); OnShutdown(); - - if (resolver_) { - DCHECK_EQ(1u, resolver_->handed_out_requests_.count(this)); - resolver_->handed_out_requests_.erase(this); - resolver_ = nullptr; - } + DetachFromResolver(); } void OnShutdown() { @@ -54,8 +46,8 @@ // Cannot destroy |inner_request_| because it is still allowed to call // Get...Results() methods if the request was already complete. - if (inner_request_) - inner_request_->Cancel(); + if (inner_request()) + inner_request()->Cancel(); shutting_down_ = true; @@ -63,10 +55,49 @@ // Start() from full cancellation on resolver destruction. } + virtual HostResolverManager::CancellableRequest* inner_request() = 0; + + ContextHostResolver* resolver() { return resolver_; } + bool shutting_down() { return shutting_down_; } + + private: + void DetachFromResolver() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + if (resolver_) { + DCHECK_EQ(1u, resolver_->handed_out_requests_.count(this)); + resolver_->handed_out_requests_.erase(this); + resolver_ = nullptr; + } + } + + // Resolver is expected to call Cancel() on destruction, clearing the pointer + // before it becomes invalid. + ContextHostResolver* resolver_; + bool shutting_down_ = false; + + SEQUENCE_CHECKER(sequence_checker_); +}; + +class ContextHostResolver::WrappedResolveHostRequest + : public WrappedRequest, + public HostResolver::ResolveHostRequest { + public: + WrappedResolveHostRequest( + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> + request, + ContextHostResolver* resolver, + bool shutting_down) + : WrappedRequest(resolver, shutting_down), + inner_request_(std::move(request)) {} + + WrappedResolveHostRequest(const WrappedResolveHostRequest&) = delete; + WrappedResolveHostRequest& operator=(const WrappedResolveHostRequest&) = + delete; + int Start(CompletionOnceCallback callback) override { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - if (!resolver_) { + if (!resolver()) { // Parent resolver has been destroyed. HostResolver generally disallows // calling Start() in this case, but this implementation returns // ERR_FAILED to allow testing the case. @@ -74,7 +105,7 @@ return ERR_FAILED; } - if (shutting_down_) { + if (shutting_down()) { // Shutting down but the resolver is not yet destroyed. inner_request_ = nullptr; return ERR_CONTEXT_SHUT_DOWN; @@ -143,17 +174,61 @@ inner_request_->ChangeRequestPriority(priority); } - private: - std::unique_ptr<HostResolverManager::CancellableRequest> inner_request_; + HostResolverManager::CancellableRequest* inner_request() override { + return inner_request_.get(); + } - // Resolver is expected to call Cancel() on destruction, clearing the pointer - // before it becomes invalid. - ContextHostResolver* resolver_; - bool shutting_down_ = false; + private: + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> + inner_request_; SEQUENCE_CHECKER(sequence_checker_); +}; - DISALLOW_COPY_AND_ASSIGN(WrappedRequest); +class ContextHostResolver::WrappedProbeRequest + : public WrappedRequest, + public HostResolver::ProbeRequest { + public: + WrappedProbeRequest( + std::unique_ptr<HostResolverManager::CancellableProbeRequest> + inner_request, + ContextHostResolver* resolver, + bool shutting_down) + : WrappedRequest(resolver, shutting_down), + inner_request_(std::move(inner_request)) {} + + WrappedProbeRequest(const WrappedProbeRequest&) = delete; + WrappedProbeRequest& operator=(const WrappedProbeRequest&) = delete; + + int Start() override { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + if (!resolver()) { + // Parent resolver has been destroyed. HostResolver generally disallows + // calling Start() in this case, but this implementation returns + // ERR_FAILED to allow testing the case. + inner_request_ = nullptr; + return ERR_FAILED; + } + + if (shutting_down()) { + // Shutting down but the resolver is not yet destroyed. + inner_request_ = nullptr; + return ERR_CONTEXT_SHUT_DOWN; + } + + DCHECK(inner_request_); + return inner_request_->Start(); + } + + HostResolverManager::CancellableRequest* inner_request() override { + return inner_request_.get(); + } + + private: + std::unique_ptr<HostResolverManager::CancellableProbeRequest> inner_request_; + + SEQUENCE_CHECKER(sequence_checker_); }; ContextHostResolver::ContextHostResolver(HostResolverManager* manager, @@ -196,13 +271,9 @@ active_request->OnShutdown(); DCHECK(context_); - manager_->CancelProbesForContext(context_); context_ = nullptr; shutting_down_ = true; - - // TODO(crbug.com/1006902): Cancel DoH prober requests too if using - // |context_|. } std::unique_ptr<HostResolver::ResolveHostRequest> @@ -213,15 +284,31 @@ const base::Optional<ResolveHostParameters>& optional_parameters) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - std::unique_ptr<HostResolverManager::CancellableRequest> inner_request; + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> + inner_request; if (!shutting_down_) { inner_request = manager_->CreateRequest(host, network_isolation_key, source_net_log, optional_parameters, context_, host_cache_.get()); } - auto request = std::make_unique<WrappedRequest>(std::move(inner_request), - this, shutting_down_); + auto request = std::make_unique<WrappedResolveHostRequest>( + std::move(inner_request), this, shutting_down_); + handed_out_requests_.insert(request.get()); + return request; +} + +std::unique_ptr<HostResolver::ProbeRequest> +ContextHostResolver::CreateDohProbeRequest() { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + + std::unique_ptr<HostResolverManager::CancellableProbeRequest> inner_request; + if (!shutting_down_) { + inner_request = manager_->CreateDohProbeRequest(context_); + } + + auto request = std::make_unique<WrappedProbeRequest>(std::move(inner_request), + this, shutting_down_); handed_out_requests_.insert(request.get()); return request; }
diff --git a/net/dns/context_host_resolver.h b/net/dns/context_host_resolver.h index df4fc6c..e930815 100644 --- a/net/dns/context_host_resolver.h +++ b/net/dns/context_host_resolver.h
@@ -50,6 +50,7 @@ const NetLogWithSource& net_log, const base::Optional<ResolveHostParameters>& optional_parameters) override; + std::unique_ptr<ProbeRequest> CreateDohProbeRequest() override; std::unique_ptr<MdnsListener> CreateMdnsListener( const HostPortPair& host, DnsQueryType query_type) override; @@ -74,6 +75,8 @@ private: class WrappedRequest; + class WrappedResolveHostRequest; + class WrappedProbeRequest; HostResolverManager* const manager_; std::unique_ptr<HostResolverManager> owned_manager_;
diff --git a/net/dns/context_host_resolver_unittest.cc b/net/dns/context_host_resolver_unittest.cc index 0e5ff30..e6f6984 100644 --- a/net/dns/context_host_resolver_unittest.cc +++ b/net/dns/context_host_resolver_unittest.cc
@@ -150,6 +150,29 @@ EXPECT_EQ(0u, resolver->GetNumActiveRequestsForTesting()); } +TEST_F(ContextHostResolverTest, DohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), HostCache::CreateDefaultCache()); + resolver->SetRequestContext(&context); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + ASSERT_FALSE(dns_client_->factory()->doh_probes_running()); + + EXPECT_THAT(request->Start(), test::IsError(ERR_IO_PENDING)); + EXPECT_TRUE(dns_client_->factory()->doh_probes_running()); + + request.reset(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + // Test that cancelling a resolver cancels its (and only its) requests. TEST_F(ContextHostResolverTest, DestroyResolver) { // Set up delayed results for "example.com" and "google.com". @@ -283,6 +306,27 @@ testing::ElementsAre(kEndpoint)); } +TEST_F(ContextHostResolverTest, DestroyResolver_DohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), nullptr /* host_cache */); + resolver->SetRequestContext(&context); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + request->Start(); + ASSERT_TRUE(dns_client_->factory()->doh_probes_running()); + + resolver.reset(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + // Test a request created before resolver destruction but not yet started. TEST_F(ContextHostResolverTest, DestroyResolver_DelayedStartRequest) { // Set up delayed result for "example.com". @@ -311,6 +355,25 @@ EXPECT_FALSE(request->GetAddressResults()); } +TEST_F(ContextHostResolverTest, DestroyResolver_DelayedStartDohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), nullptr /* host_cache */); + resolver->SetRequestContext(&context); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + resolver = nullptr; + + EXPECT_THAT(request->Start(), test::IsError(ERR_FAILED)); + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + TEST_F(ContextHostResolverTest, OnShutdown_PendingRequest) { // Set up delayed result for "example.com". MockDnsClientRuleList rules; @@ -345,6 +408,27 @@ EXPECT_FALSE(callback.have_result()); } +TEST_F(ContextHostResolverTest, OnShutdown_DohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), nullptr /* host_cache */); + resolver->SetRequestContext(&context); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + request->Start(); + ASSERT_TRUE(dns_client_->factory()->doh_probes_running()); + + resolver->OnShutdown(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + TEST_F(ContextHostResolverTest, OnShutdown_CompletedRequests) { MockDnsClientRuleList rules; rules.emplace_back("example.com", dns_protocol::kTypeA, false /* secure */, @@ -403,6 +487,24 @@ EXPECT_FALSE(request2->GetAddressResults()); } +TEST_F(ContextHostResolverTest, OnShutdown_SubsequentDohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), nullptr /* host_cache */); + resolver->SetRequestContext(&context); + resolver->OnShutdown(); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + EXPECT_THAT(request->Start(), test::IsError(ERR_CONTEXT_SHUT_DOWN)); + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + // Test a request created before shutdown but not yet started. TEST_F(ContextHostResolverTest, OnShutdown_DelayedStartRequest) { // Set up delayed result for "example.com". @@ -433,6 +535,25 @@ EXPECT_FALSE(request->GetAddressResults()); } +TEST_F(ContextHostResolverTest, OnShutdown_DelayedStartDohProbeRequest) { + // Set empty MockDnsClient rules to ensure DnsClient is mocked out. + MockDnsClientRuleList rules; + SetMockDnsRules(std::move(rules)); + + URLRequestContext context; + auto resolver = std::make_unique<ContextHostResolver>( + manager_.get(), nullptr /* host_cache */); + resolver->SetRequestContext(&context); + + std::unique_ptr<HostResolver::ProbeRequest> request = + resolver->CreateDohProbeRequest(); + + resolver->OnShutdown(); + + EXPECT_THAT(request->Start(), test::IsError(ERR_CONTEXT_SHUT_DOWN)); + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + TEST_F(ContextHostResolverTest, ResolveFromCache) { base::SimpleTestTickClock clock; clock.Advance(base::TimeDelta::FromDays(62)); // Arbitrary non-zero time.
diff --git a/net/dns/dns_client.cc b/net/dns/dns_client.cc index 9155d7c..0cf18057 100644 --- a/net/dns/dns_client.cc +++ b/net/dns/dns_client.cc
@@ -171,10 +171,12 @@ } void CancelProbesForContext(URLRequestContext* url_request_context) override { - if (url_request_context_for_probes_ != url_request_context || !factory_) + if (url_request_context_for_probes_ != url_request_context) return; - factory_->CancelDohProbes(); + if (factory_) + factory_->CancelDohProbes(); + delayed_probes_start_timer_.Stop(); url_request_context_for_probes_ = nullptr; }
diff --git a/net/dns/dns_test_util.cc b/net/dns/dns_test_util.cc index 753a54f..6ed94bc 100644 --- a/net/dns/dns_test_util.cc +++ b/net/dns/dns_test_util.cc
@@ -703,10 +703,20 @@ } void MockDnsClient::SetRequestContextForProbes( - URLRequestContext* url_request_context) {} + URLRequestContext* url_request_context) { + DCHECK(!probe_context_ || probe_context_ == url_request_context); + probe_context_ = url_request_context; + factory_->StartDohProbes(probe_context_, false /* network_change */); +} void MockDnsClient::CancelProbesForContext( - URLRequestContext* url_request_context) {} + URLRequestContext* url_request_context) { + if (probe_context_ != url_request_context) + return; + + factory_->CancelDohProbes(); + probe_context_ = nullptr; +} DnsTransactionFactory* MockDnsClient::GetTransactionFactory() { return GetEffectiveConfig() ? factory_.get() : nullptr; @@ -740,7 +750,7 @@ } void MockDnsClient::StartDohProbesForTesting() { - factory_->StartDohProbes(nullptr /* url_request_context */, + factory_->StartDohProbes(probe_context_ /* url_request_context */, false /* network_change */); }
diff --git a/net/dns/dns_test_util.h b/net/dns/dns_test_util.h index 1b6d5bb1..5d0e7f44 100644 --- a/net/dns/dns_test_util.h +++ b/net/dns/dns_test_util.h
@@ -379,6 +379,8 @@ doh_server_available_ = available; } + MockDnsTransactionFactory* factory() { return factory_.get(); } + private: base::Optional<DnsConfig> BuildEffectiveConfig(); @@ -387,6 +389,7 @@ int max_fallback_failures_ = DnsClient::kMaxInsecureFallbackFailures; bool ignore_system_config_changes_ = false; bool doh_server_available_ = true; + URLRequestContext* probe_context_ = nullptr; base::Optional<DnsConfig> config_; DnsConfigOverrides overrides_;
diff --git a/net/dns/dns_transaction.cc b/net/dns/dns_transaction.cc index 78193003..9bb49ef 100644 --- a/net/dns/dns_transaction.cc +++ b/net/dns/dns_transaction.cc
@@ -432,6 +432,10 @@ DCHECK_NE(net::ERR_IO_PENDING, net_error); std::string content_type; if (net_error != OK) { + // Update the error code if there was an issue resolving the secure + // server hostname. + if (IsDnsError(net_error)) + net_error = ERR_DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED; ResponseCompleted(net_error); return; }
diff --git a/net/dns/dns_transaction_unittest.cc b/net/dns/dns_transaction_unittest.cc index 3ec0ffe..89484d3 100644 --- a/net/dns/dns_transaction_unittest.cc +++ b/net/dns/dns_transaction_unittest.cc
@@ -1464,6 +1464,27 @@ EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get())); } +URLRequestJob* DohJobMakerCallbackFailLookup(URLRequest* request, + NetworkDelegate* network_delegate, + SocketDataProvider* data) { + URLRequestMockDohJob::MatchQueryData(request, data); + return new URLRequestFailedJob(request, network_delegate, + URLRequestFailedJob::START, + ERR_NAME_NOT_RESOLVED); +} + +TEST_F(DnsTransactionTest, HttpsPostLookupFailDohServerLookup) { + ConfigureDohServers(true /* use_post */); + AddQueryAndResponse(0, kT0HostName, kT0Qtype, kT0ResponseDatagram, + base::size(kT0ResponseDatagram), SYNCHRONOUS, + Transport::HTTPS, nullptr /* opt_rdata */, + DnsQuery::PaddingStrategy::BLOCK_LENGTH_128); + TransactionHelper helper0(kT0HostName, kT0Qtype, true /* secure */, + ERR_DNS_SECURE_RESOLVER_HOSTNAME_RESOLUTION_FAILED); + SetDohJobMakerCallback(base::BindRepeating(DohJobMakerCallbackFailLookup)); + EXPECT_TRUE(helper0.RunUntilDone(transaction_factory_.get())); +} + URLRequestJob* DohJobMakerCallbackFailStart(URLRequest* request, NetworkDelegate* network_delegate, SocketDataProvider* data) {
diff --git a/net/dns/host_resolver.cc b/net/dns/host_resolver.cc index 9e7028a..6b8d213 100644 --- a/net/dns/host_resolver.cc +++ b/net/dns/host_resolver.cc
@@ -26,12 +26,14 @@ namespace { -class FailingRequestImpl : public HostResolver::ResolveHostRequest { +class FailingRequestImpl : public HostResolver::ResolveHostRequest, + public HostResolver::ProbeRequest { public: explicit FailingRequestImpl(int error) : error_(error) {} ~FailingRequestImpl() override = default; int Start(CompletionOnceCallback callback) override { return error_; } + int Start() override { return error_; } const base::Optional<AddressList>& GetAddressResults() const override { static base::NoDestructor<base::Optional<AddressList>> nullopt_result; @@ -107,6 +109,14 @@ optional_parameters); } +std::unique_ptr<HostResolver::ProbeRequest> +HostResolver::CreateDohProbeRequest() { + // Should be overridden in any HostResolver implementation where this method + // may be called. + NOTREACHED(); + return nullptr; +} + std::unique_ptr<HostResolver::MdnsListener> HostResolver::CreateMdnsListener( const HostPortPair& host, DnsQueryType query_type) { @@ -234,4 +244,10 @@ return std::make_unique<FailingRequestImpl>(error); } +// static +std::unique_ptr<HostResolver::ProbeRequest> +HostResolver::CreateFailingProbeRequest(int error) { + return std::make_unique<FailingRequestImpl>(error); +} + } // namespace net
diff --git a/net/dns/host_resolver.h b/net/dns/host_resolver.h index 1cc8a820..ebe59fc 100644 --- a/net/dns/host_resolver.h +++ b/net/dns/host_resolver.h
@@ -122,6 +122,19 @@ virtual void ChangeRequestPriority(RequestPriority priority) {} }; + // Handler for an activation of probes controlled by a HostResolver. Created + // by HostResolver::CreateDohProbeRequest(). + class ProbeRequest { + public: + // Destruction cancels the request and all probes. + virtual ~ProbeRequest() {} + + // Activates async running of probes. Always returns ERR_IO_PENDING or an + // error from activating probes. No callback as probes will never "complete" + // until cancellation. + virtual int Start() = 0; + }; + // Parameter-grouping struct for additional optional parameters for creation // of HostResolverManagers and stand-alone HostResolvers. struct NET_EXPORT ManagerOptions { @@ -303,6 +316,10 @@ const NetLogWithSource& net_log, const base::Optional<ResolveHostParameters>& optional_parameters); + // Creates a request to probe configured DoH servers to find which can be used + // successfully. + virtual std::unique_ptr<ProbeRequest> CreateDohProbeRequest(); + // Create a listener to watch for updates to an MDNS result. virtual std::unique_ptr<MdnsListener> CreateMdnsListener( const HostPortPair& host, @@ -362,6 +379,7 @@ // Utility to create a request implementation that always fails with |error| // immediately on start. static std::unique_ptr<ResolveHostRequest> CreateFailingRequest(int error); + static std::unique_ptr<ProbeRequest> CreateFailingProbeRequest(int error); private: DISALLOW_COPY_AND_ASSIGN(HostResolver);
diff --git a/net/dns/host_resolver_manager.cc b/net/dns/host_resolver_manager.cc index c08cea7..416f482 100644 --- a/net/dns/host_resolver_manager.cc +++ b/net/dns/host_resolver_manager.cc
@@ -486,7 +486,7 @@ // cancellation is initiated by the Job (OnJobCancelled) vs by the end user // (~RequestImpl). class HostResolverManager::RequestImpl - : public CancellableRequest, + : public CancellableResolveHostRequest, public base::LinkNode<HostResolverManager::RequestImpl> { public: RequestImpl(const NetLogWithSource& source_net_log, @@ -733,6 +733,46 @@ DISALLOW_COPY_AND_ASSIGN(RequestImpl); }; +class HostResolverManager::ProbeRequestImpl : public CancellableProbeRequest { + public: + ProbeRequestImpl(URLRequestContext* context, + base::WeakPtr<HostResolverManager> resolver) + : context_(context), resolver_(resolver) { + DCHECK(context_); + } + + ProbeRequestImpl(const ProbeRequestImpl&) = delete; + ProbeRequestImpl& operator=(const ProbeRequestImpl&) = delete; + + ~ProbeRequestImpl() override { Cancel(); } + + void Cancel() override { + if (!needs_cancel_ || !resolver_) + return; + + resolver_->CancelProbesForContext(context_); + needs_cancel_ = false; + context_ = nullptr; + } + + // TODO(crbug.com/1013350): Make this actually start the probes once the logic + // for startup wait and watching for config changes is moved outside DnsClient + // to the caller of this Request object. + int Start() override { + DCHECK(resolver_); + DCHECK(!needs_cancel_); + + resolver_->SetRequestContextForProbes(context_); + needs_cancel_ = true; + return ERR_IO_PENDING; + } + + private: + URLRequestContext* context_; + base::WeakPtr<HostResolverManager> resolver_; + bool needs_cancel_ = false; +}; + //------------------------------------------------------------------------------ // Calls HostResolverProc in ThreadPool. Performs retries if necessary. @@ -2659,7 +2699,7 @@ system_dns_config_notifier_->RemoveObserver(this); } -std::unique_ptr<HostResolverManager::CancellableRequest> +std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> HostResolverManager::CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, @@ -2680,6 +2720,14 @@ request_context, host_cache, weak_ptr_factory_.GetWeakPtr()); } +std::unique_ptr<HostResolverManager::CancellableProbeRequest> +HostResolverManager::CreateDohProbeRequest(URLRequestContext* context) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + + return std::make_unique<ProbeRequestImpl>(context, + weak_ptr_factory_.GetWeakPtr()); +} + std::unique_ptr<HostResolver::MdnsListener> HostResolverManager::CreateMdnsListener(const HostPortPair& host, DnsQueryType query_type) { @@ -2755,23 +2803,6 @@ } } -void HostResolverManager::SetRequestContextForProbes( - URLRequestContext* url_request_context) { - DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - dns_client_->SetRequestContextForProbes(url_request_context); -} - -void HostResolverManager::CancelProbesForContext( - URLRequestContext* url_request_context) { - DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - - // If no DnsClient, there are no probes to cancel. - if (!dns_client_) - return; - - dns_client_->CancelProbesForContext(url_request_context); -} - void HostResolverManager::AddHostCacheInvalidator( HostCache::Invalidator* invalidator) { host_cache_invalidators_.AddObserver(invalidator); @@ -3696,6 +3727,22 @@ #endif } +void HostResolverManager::SetRequestContextForProbes( + URLRequestContext* url_request_context) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + DCHECK(dns_client_); + + dns_client_->SetRequestContextForProbes(url_request_context); +} + +void HostResolverManager::CancelProbesForContext( + URLRequestContext* url_request_context) { + DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + DCHECK(dns_client_); + + dns_client_->CancelProbesForContext(url_request_context); +} + void HostResolverManager::RequestImpl::Cancel() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); if (!job_)
diff --git a/net/dns/host_resolver_manager.h b/net/dns/host_resolver_manager.h index 62423e7b..96ddcd2 100644 --- a/net/dns/host_resolver_manager.h +++ b/net/dns/host_resolver_manager.h
@@ -91,18 +91,32 @@ public SystemDnsConfigChangeNotifier::Observer { public: using MdnsListener = HostResolver::MdnsListener; - using ResolveHostRequest = HostResolver::ResolveHostRequest; using ResolveHostParameters = HostResolver::ResolveHostParameters; using SecureDnsMode = DnsConfig::SecureDnsMode; - class CancellableRequest : public ResolveHostRequest { + // A request that allows explicit cancellation before destruction. Enables + // callers (e.g. ContextHostResolver) to implement cancellation of requests on + // the callers' destruction. + class CancellableRequest { public: + CancellableRequest() = default; + CancellableRequest(const CancellableRequest&) = delete; + CancellableRequest& operator=(const CancellableRequest&) = delete; + virtual ~CancellableRequest() = default; + // If running asynchronously, silently cancels the request as if destroyed. // Callbacks will never be invoked. Noop if request is already complete or // never started. virtual void Cancel() = 0; }; + // CancellableRequest versions of different request types. + class CancellableResolveHostRequest + : public CancellableRequest, + public HostResolver::ResolveHostRequest {}; + class CancellableProbeRequest : public CancellableRequest, + public HostResolver::ProbeRequest {}; + // Creates a HostResolver as specified by |options|. Blocking tasks are run in // ThreadPool. // @@ -129,13 +143,17 @@ // specifies any cache usage other than LOCAL_ONLY, there must be a 1:1 // correspondence between |request_context| and |host_cache|, and both should // come from the same ContextHostResolver. - std::unique_ptr<CancellableRequest> CreateRequest( + std::unique_ptr<CancellableResolveHostRequest> CreateRequest( const HostPortPair& host, const NetworkIsolationKey& network_isolation_key, const NetLogWithSource& net_log, const base::Optional<ResolveHostParameters>& optional_parameters, URLRequestContext* request_context, HostCache* host_cache); + // |request_context| is the context to use for the probes, and it is expected + // to be the context of the calling ContextHostResolver. + std::unique_ptr<CancellableProbeRequest> CreateDohProbeRequest( + URLRequestContext* request_context); std::unique_ptr<MdnsListener> CreateMdnsListener(const HostPortPair& host, DnsQueryType query_type); @@ -155,16 +173,6 @@ // read from the system for DnsClient resolution. void SetDnsConfigOverrides(DnsConfigOverrides overrides); - // Sets the URLRequestContext to use for issuing DoH probes. - // TODO(crbug.com/1006902): Convert DoH probes to an API more consistent with - // normal requests with a Request or cancellation handle to control start and - // cancel. - void SetRequestContextForProbes(URLRequestContext* url_request_context); - - // Iff |url_request_context| is being used for DoH probes, cancels the probes - // and clears the set context. - void CancelProbesForContext(URLRequestContext* url_request_context); - // Support for invalidating HostCaches on changes to network or DNS // configuration. HostCaches should register/deregister invalidators here // rather than attempting to listen for relevant network change signals @@ -235,6 +243,7 @@ class LoopbackProbeJob; class DnsTask; class RequestImpl; + class ProbeRequestImpl; using JobMap = std::map<JobKey, std::unique_ptr<Job>>; // Task types that a Job might run. @@ -443,6 +452,9 @@ void InvalidateCaches(); + void SetRequestContextForProbes(URLRequestContext* url_request_context); + void CancelProbesForContext(URLRequestContext* url_request_context); + // Used for multicast DNS tasks. Created on first use using // GetOrCreateMndsClient(). std::unique_ptr<MDnsSocketFactory> mdns_socket_factory_;
diff --git a/net/dns/host_resolver_manager_unittest.cc b/net/dns/host_resolver_manager_unittest.cc index e51cb48..4e104bc0 100644 --- a/net/dns/host_resolver_manager_unittest.cc +++ b/net/dns/host_resolver_manager_unittest.cc
@@ -262,13 +262,15 @@ ResolveHostResponseHelper() = default; explicit ResolveHostResponseHelper( - std::unique_ptr<HostResolverManager::CancellableRequest> request) + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> + request) : request_(std::move(request)) { result_error_ = request_->Start(base::BindOnce( &ResolveHostResponseHelper::OnComplete, base::Unretained(this))); } ResolveHostResponseHelper( - std::unique_ptr<HostResolverManager::CancellableRequest> request, + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> + request, Callback custom_callback) : request_(std::move(request)) { result_error_ = request_->Start( @@ -283,7 +285,9 @@ return result_error_; } - HostResolverManager::CancellableRequest* request() { return request_.get(); } + HostResolverManager::CancellableResolveHostRequest* request() { + return request_.get(); + } void CancelRequest() { DCHECK(request_); @@ -309,7 +313,7 @@ DCHECK(complete()); } - std::unique_ptr<HostResolverManager::CancellableRequest> request_; + std::unique_ptr<HostResolverManager::CancellableResolveHostRequest> request_; int result_error_ = ERR_IO_PENDING; base::RunLoop run_loop_; @@ -5036,6 +5040,17 @@ EXPECT_FALSE(response.complete()); } +TEST_F(HostResolverManagerDnsTest, ExplicitCancel_AfterManagerDestruction) { + ChangeDnsConfig(CreateValidDnsConfig()); + + ResolveHostResponseHelper response(resolver_->CreateRequest( + HostPortPair("4slow_4ok", 80), NetworkIsolationKey(), NetLogWithSource(), + base::nullopt, request_context_.get(), host_cache_.get())); + + DestroyResolver(); + response.request()->Cancel(); +} + TEST_F(HostResolverManagerDnsTest, ExplicitCancel_Completed) { ChangeDnsConfig(CreateValidDnsConfig()); @@ -8303,6 +8318,59 @@ HostPortPair("google.com", 5))); } +TEST_F(HostResolverManagerDnsTest, DohProbeRequest) { + ChangeDnsConfig(CreateValidDnsConfig()); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); + + std::unique_ptr<HostResolverManager::CancellableProbeRequest> request = + resolver_->CreateDohProbeRequest(request_context_.get()); + EXPECT_THAT(request->Start(), IsError(ERR_IO_PENDING)); + + EXPECT_TRUE(dns_client_->factory()->doh_probes_running()); + + request.reset(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + +TEST_F(HostResolverManagerDnsTest, DohProbeRequest_ExplicitCancel) { + ChangeDnsConfig(CreateValidDnsConfig()); + + std::unique_ptr<HostResolverManager::CancellableProbeRequest> request = + resolver_->CreateDohProbeRequest(request_context_.get()); + EXPECT_THAT(request->Start(), IsError(ERR_IO_PENDING)); + ASSERT_TRUE(dns_client_->factory()->doh_probes_running()); + + request->Cancel(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + +TEST_F(HostResolverManagerDnsTest, DohProbeRequest_ExplicitCancel_NotStarted) { + ChangeDnsConfig(CreateValidDnsConfig()); + + std::unique_ptr<HostResolverManager::CancellableProbeRequest> request = + resolver_->CreateDohProbeRequest(request_context_.get()); + + request->Cancel(); + + EXPECT_FALSE(dns_client_->factory()->doh_probes_running()); +} + +TEST_F(HostResolverManagerDnsTest, + DohProbeRequest_ExplicitCancel_AfterManagerDestruction) { + ChangeDnsConfig(CreateValidDnsConfig()); + + std::unique_ptr<HostResolverManager::CancellableProbeRequest> request = + resolver_->CreateDohProbeRequest(request_context_.get()); + EXPECT_THAT(request->Start(), IsError(ERR_IO_PENDING)); + ASSERT_TRUE(dns_client_->factory()->doh_probes_running()); + + DestroyResolver(); + request->Cancel(); +} + TEST_F(HostResolverManagerDnsTest, EsniQuery) { EsniContent c1, c2, c3; IPAddress a1(1, 2, 3, 4), a2(5, 6, 7, 8);
diff --git a/net/dns/mapped_host_resolver.cc b/net/dns/mapped_host_resolver.cc index 2ce6b7e3..8bbd2f9 100644 --- a/net/dns/mapped_host_resolver.cc +++ b/net/dns/mapped_host_resolver.cc
@@ -39,6 +39,11 @@ optional_parameters); } +std::unique_ptr<HostResolver::ProbeRequest> +MappedHostResolver::CreateDohProbeRequest() { + return impl_->CreateDohProbeRequest(); +} + HostCache* MappedHostResolver::GetHostCache() { return impl_->GetHostCache(); }
diff --git a/net/dns/mapped_host_resolver.h b/net/dns/mapped_host_resolver.h index d9cfdc6..c27161a 100644 --- a/net/dns/mapped_host_resolver.h +++ b/net/dns/mapped_host_resolver.h
@@ -56,6 +56,7 @@ const NetLogWithSource& net_log, const base::Optional<ResolveHostParameters>& optional_parameters) override; + std::unique_ptr<ProbeRequest> CreateDohProbeRequest() override; HostCache* GetHostCache() override; std::unique_ptr<base::Value> GetDnsConfigAsValue() const override; void SetRequestContext(URLRequestContext* request_context) override;
diff --git a/net/dns/mock_host_resolver.cc b/net/dns/mock_host_resolver.cc index e4441633..bcf5af66 100644 --- a/net/dns/mock_host_resolver.cc +++ b/net/dns/mock_host_resolver.cc
@@ -222,6 +222,33 @@ DISALLOW_COPY_AND_ASSIGN(RequestImpl); }; +class MockHostResolverBase::ProbeRequestImpl + : public HostResolver::ProbeRequest { + public: + explicit ProbeRequestImpl(base::WeakPtr<MockHostResolverBase> resolver) + : resolver_(std::move(resolver)) {} + + ProbeRequestImpl(const ProbeRequestImpl&) = delete; + ProbeRequestImpl& operator=(const ProbeRequestImpl&) = delete; + + ~ProbeRequestImpl() override { + if (resolver_ && resolver_->doh_probe_request_ == this) + resolver_->doh_probe_request_ = nullptr; + } + + int Start() override { + DCHECK(resolver_); + DCHECK(!resolver_->doh_probe_request_); + + resolver_->doh_probe_request_ = this; + + return ERR_IO_PENDING; + } + + private: + base::WeakPtr<MockHostResolverBase> resolver_; +}; + class MockHostResolverBase::MdnsListenerImpl : public HostResolver::MdnsListener { public: @@ -305,6 +332,8 @@ // Prevent future requests by clearing resolution rules and the cache. rules_map_.clear(); cache_ = nullptr; + + doh_probe_request_ = nullptr; } std::unique_ptr<HostResolver::ResolveHostRequest> @@ -317,6 +346,11 @@ optional_parameters, AsWeakPtr()); } +std::unique_ptr<HostResolver::ProbeRequest> +MockHostResolverBase::CreateDohProbeRequest() { + return std::make_unique<ProbeRequestImpl>(AsWeakPtr()); +} + std::unique_ptr<HostResolver::MdnsListener> MockHostResolverBase::CreateMdnsListener(const HostPortPair& host, DnsQueryType query_type) { @@ -921,7 +955,8 @@ // Implementation of ResolveHostRequest that tracks cancellations when the // request is destroyed after being started. class HangingHostResolver::RequestImpl - : public HostResolver::ResolveHostRequest { + : public HostResolver::ResolveHostRequest, + public HostResolver::ProbeRequest { public: explicit RequestImpl(base::WeakPtr<HangingHostResolver> resolver) : resolver_(resolver) {} @@ -931,7 +966,9 @@ resolver_->num_cancellations_++; } - int Start(CompletionOnceCallback callback) override { + int Start(CompletionOnceCallback callback) override { return Start(); } + + int Start() override { DCHECK(resolver_); is_running_ = true; return ERR_IO_PENDING; @@ -996,6 +1033,14 @@ return std::make_unique<RequestImpl>(weak_ptr_factory_.GetWeakPtr()); } +std::unique_ptr<HostResolver::ProbeRequest> +HangingHostResolver::CreateDohProbeRequest() { + if (shutting_down_) + return CreateFailingProbeRequest(ERR_CONTEXT_SHUT_DOWN); + + return std::make_unique<RequestImpl>(weak_ptr_factory_.GetWeakPtr()); +} + //----------------------------------------------------------------------------- ScopedDefaultHostResolverProc::ScopedDefaultHostResolverProc() = default;
diff --git a/net/dns/mock_host_resolver.h b/net/dns/mock_host_resolver.h index 2fca383d..51bf77d 100644 --- a/net/dns/mock_host_resolver.h +++ b/net/dns/mock_host_resolver.h
@@ -83,6 +83,7 @@ public base::SupportsWeakPtr<MockHostResolverBase> { private: class RequestImpl; + class ProbeRequestImpl; class MdnsListenerImpl; public: @@ -120,6 +121,7 @@ const NetLogWithSource& net_log, const base::Optional<ResolveHostParameters>& optional_parameters) override; + std::unique_ptr<ProbeRequest> CreateDohProbeRequest() override; std::unique_ptr<MdnsListener> CreateMdnsListener( const HostPortPair& host, DnsQueryType query_type) override; @@ -202,6 +204,8 @@ return last_secure_dns_mode_override_; } + bool IsDohProbeRunning() const { return !!doh_probe_request_; } + void TriggerMdnsListeners(const HostPortPair& host, DnsQueryType query_type, MdnsListener::Delegate::UpdateType update_type, @@ -281,6 +285,7 @@ // RemoveCancelledListener(). RequestMap requests_; size_t next_request_id_; + ProbeRequestImpl* doh_probe_request_ = nullptr; std::set<MdnsListenerImpl*> listeners_; size_t num_resolve_; @@ -474,12 +479,15 @@ const base::Optional<ResolveHostParameters>& optional_parameters) override; + std::unique_ptr<ProbeRequest> CreateDohProbeRequest() override; + // Use to detect cancellations since there's otherwise no externally-visible // differentiation between a cancelled and a hung task. int num_cancellations() const { return num_cancellations_; } private: class RequestImpl; + class ProbeRequestImpl; int num_cancellations_ = 0; bool shutting_down_ = false;
diff --git a/net/http/http_auth_challenge_tokenizer.h b/net/http/http_auth_challenge_tokenizer.h index fe8f6b0..5867c5b 100644 --- a/net/http/http_auth_challenge_tokenizer.h +++ b/net/http/http_auth_challenge_tokenizer.h
@@ -7,6 +7,7 @@ #include <string> +#include "base/strings/string_piece.h" #include "net/base/net_export.h" #include "net/http/http_util.h" @@ -32,10 +33,8 @@ } // Get the auth scheme of the challenge. - std::string::const_iterator scheme_begin() const { return scheme_begin_; } - std::string::const_iterator scheme_end() const { return scheme_end_; } - std::string scheme() const { - return std::string(scheme_begin_, scheme_end_); + base::StringPiece scheme() const { + return base::StringPiece(scheme_begin_, scheme_end_); } std::string::const_iterator params_begin() const { return params_begin_; }
diff --git a/net/http/http_auth_handler_basic.h b/net/http/http_auth_handler_basic.h index fea7024..6f4a009 100644 --- a/net/http/http_auth_handler_basic.h +++ b/net/http/http_auth_handler_basic.h
@@ -46,7 +46,7 @@ HttpAuthChallengeTokenizer* challenge) override; private: - ~HttpAuthHandlerBasic() override {} + ~HttpAuthHandlerBasic() override = default; bool ParseChallenge(HttpAuthChallengeTokenizer* challenge); };
diff --git a/net/http/http_auth_handler_factory.cc b/net/http/http_auth_handler_factory.cc index 34a9cb5e..147bd42 100644 --- a/net/http/http_auth_handler_factory.cc +++ b/net/http/http_auth_handler_factory.cc
@@ -200,7 +200,7 @@ const NetLogWithSource& net_log, HostResolver* host_resolver, std::unique_ptr<HttpAuthHandler>* handler) { - std::string scheme = challenge->scheme(); + auto scheme = challenge->scheme(); if (scheme.empty()) { handler->reset(); return ERR_INVALID_RESPONSE;
diff --git a/net/http/http_auth_multi_round_parse.cc b/net/http/http_auth_multi_round_parse.cc index 1d0edac0..081dcf9 100644 --- a/net/http/http_auth_multi_round_parse.cc +++ b/net/http/http_auth_multi_round_parse.cc
@@ -2,17 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "net/http/http_auth_multi_round_parse.h" + #include "base/base64.h" +#include "base/strings/string_piece.h" #include "base/strings/string_util.h" #include "net/http/http_auth_challenge_tokenizer.h" -#include "net/http/http_auth_multi_round_parse.h" namespace net { namespace { // Check that the scheme in the challenge matches the expected scheme -bool SchemeIsValid(const std::string& scheme, +bool SchemeIsValid(base::StringPiece scheme, HttpAuthChallengeTokenizer* challenge) { // There is no guarantee that challenge->scheme() is valid ASCII, but // LowerCaseEqualsASCII will do the right thing even if it isn't. @@ -23,7 +25,7 @@ } // namespace HttpAuth::AuthorizationResult ParseFirstRoundChallenge( - const std::string& scheme, + base::StringPiece scheme, HttpAuthChallengeTokenizer* challenge) { // Verify the challenge's auth-scheme. if (!SchemeIsValid(scheme, challenge)) @@ -37,7 +39,7 @@ } HttpAuth::AuthorizationResult ParseLaterRoundChallenge( - const std::string& scheme, + base::StringPiece scheme, HttpAuthChallengeTokenizer* challenge, std::string* encoded_token, std::string* decoded_token) {
diff --git a/net/http/http_auth_multi_round_parse.h b/net/http/http_auth_multi_round_parse.h index 2fb6347..e76b088 100644 --- a/net/http/http_auth_multi_round_parse.h +++ b/net/http/http_auth_multi_round_parse.h
@@ -7,6 +7,7 @@ #include <string> +#include "base/strings/string_piece.h" #include "net/base/net_export.h" #include "net/http/http_auth.h" @@ -15,11 +16,11 @@ class HttpAuthChallengeTokenizer; NET_EXPORT_PRIVATE HttpAuth::AuthorizationResult ParseFirstRoundChallenge( - const std::string& scheme, + base::StringPiece scheme, HttpAuthChallengeTokenizer* challenge); NET_EXPORT_PRIVATE HttpAuth::AuthorizationResult ParseLaterRoundChallenge( - const std::string& scheme, + base::StringPiece scheme, HttpAuthChallengeTokenizer* challenge, std::string* encoded_token, std::string* decoded_token);
diff --git a/remoting/host/BUILD.gn b/remoting/host/BUILD.gn index 936c3a6..f1b2b3c 100644 --- a/remoting/host/BUILD.gn +++ b/remoting/host/BUILD.gn
@@ -429,6 +429,7 @@ } if (is_win) { + libs += [ "crypt32.lib" ] deps += [ # On Windows, we use //media/gpu/MediaFoundationVideoEncodeAcceleratorWin # to detect whether HW encoder is supported by the system.
diff --git a/remoting/host/mac/permission_wizard.h b/remoting/host/mac/permission_wizard.h index e53e4bc..4fae04f 100644 --- a/remoting/host/mac/permission_wizard.h +++ b/remoting/host/mac/permission_wizard.h
@@ -25,7 +25,8 @@ class Impl; // Callback for the Delegate to inform this class whether a permission was - // granted. + // granted. Also used to inform the caller of Start() whether the wizard + // was completed successfully or cancelled. using ResultCallback = base::OnceCallback<void(bool granted)>; // Interface to delegate the permission-checks. This will be invoked to test @@ -54,6 +55,14 @@ PermissionWizard& operator=(const PermissionWizard&) = delete; ~PermissionWizard(); + // Sets an optional callback to be notified when the wizard finishes. If set, + // the callback will be run on the ui_task_runner provided to Start(). The + // result will be true if all permissions were granted (even if no pages were + // actually shown). Result is false if the user cancelled the wizard (which + // should only happen if a page was shown and the associated permission was + // not granted). + void SetCompletionCallback(ResultCallback callback); + void Start(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); private:
diff --git a/remoting/host/mac/permission_wizard.mm b/remoting/host/mac/permission_wizard.mm index 289361f8..5dd1d820 100644 --- a/remoting/host/mac/permission_wizard.mm +++ b/remoting/host/mac/permission_wizard.mm
@@ -60,6 +60,7 @@ explicit Impl(std::unique_ptr<PermissionWizard::Delegate> checker); ~Impl(); + void SetCompletionCallback(ResultCallback callback); void Start(); std::string GetBundleName(); @@ -69,6 +70,10 @@ void CheckAccessibilityPermission(base::TimeDelta delay); void CheckScreenRecordingPermission(base::TimeDelta delay); + // Called by PermissionWizardController to notify that the wizard was + // completed/cancelled. + void NotifyCompletion(bool result); + private: void CheckAccessibilityPermissionNow(); void CheckScreenRecordingPermissionNow(); @@ -78,6 +83,10 @@ PermissionWizardController* window_controller_ = nil; std::unique_ptr<Delegate> checker_; base::OneShotTimer timer_; + + // Notified when the wizard is completed/cancelled. May be null. + ResultCallback completion_callback_; + base::WeakPtrFactory<Impl> weak_factory_{this}; }; @@ -90,6 +99,10 @@ [window_controller_ release]; } +void PermissionWizard::Impl::SetCompletionCallback(ResultCallback callback) { + completion_callback_ = std::move(callback); +} + void PermissionWizard::Impl::Start() { NSWindow* window = [[[NSWindow alloc] initWithContentRect:ui::kWindowSizeDeterminedLater @@ -116,6 +129,11 @@ &Impl::CheckScreenRecordingPermissionNow); } +void PermissionWizard::Impl::NotifyCompletion(bool result) { + if (completion_callback_) + std::move(completion_callback_).Run(result); +} + void PermissionWizard::Impl::CheckAccessibilityPermissionNow() { checker_->CheckAccessibilityPermission(base::BindOnce( &Impl::OnPermissionCheckResult, weak_factory_.GetWeakPtr())); @@ -275,6 +293,7 @@ } - (void)onCancel:(id)sender { + _impl->NotifyCompletion(false); _cancelled = YES; [self hide]; } @@ -282,6 +301,7 @@ - (void)onNext:(id)sender { if (_page == WizardPage::ALL_SET) { // OK button closes the window. + _impl->NotifyCompletion(true); [self hide]; return; } @@ -360,7 +380,13 @@ break; case WizardPage::SCREEN_RECORDING: _page = WizardPage::ALL_SET; - [self updateUI]; + if ([self window].visible) { + [self updateUI]; + } else { + // If the wizard hasn't been shown yet, this means that all permissions + // were already granted, and the final ALL_SET page will not be shown. + _impl->NotifyCompletion(true); + } return; default: NOTREACHED(); @@ -461,6 +487,10 @@ ui_task_runner_->DeleteSoon(FROM_HERE, impl_.release()); } +void PermissionWizard::SetCompletionCallback(ResultCallback callback) { + impl_->SetCompletionCallback(std::move(callback)); +} + void PermissionWizard::Start( scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { ui_task_runner_ = ui_task_runner;
diff --git a/services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc b/services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc index 6ac373e..36e28a1 100644 --- a/services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc +++ b/services/device/generic_sensor/absolute_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_magnetometer.cc
@@ -7,7 +7,7 @@ #include <cmath> #include "base/logging.h" -#include "services/device/generic_sensor/generic_sensor_consts.h" +#include "base/numerics/math_constants.h" #include "services/device/generic_sensor/orientation_util.h" #include "services/device/generic_sensor/platform_sensor_fusion.h" @@ -34,7 +34,7 @@ double gravity_squared = (gravity_x * gravity_x + gravity_y * gravity_y + gravity_z * gravity_z); double free_fall_gravity_squared = - 0.01 * device::kMeanGravity * device::kMeanGravity; + 0.01 * base::kMeanGravityDouble * base::kMeanGravityDouble; if (gravity_squared < free_fall_gravity_squared) { // gravity less than 10% of normal value return false;
diff --git a/services/device/generic_sensor/generic_sensor_consts.h b/services/device/generic_sensor/generic_sensor_consts.h index e55d60a4..ccb1c67 100644 --- a/services/device/generic_sensor/generic_sensor_consts.h +++ b/services/device/generic_sensor/generic_sensor_consts.h
@@ -11,9 +11,6 @@ // to be effectively equal. constexpr double kEpsilon = 1e-8; -// Required for conversion from G/s^2 to m/s^2 -constexpr double kMeanGravity = 9.80665; - // Required for conversion from Gauss to uT. constexpr double kMicroteslaInGauss = 100.0;
diff --git a/services/device/generic_sensor/linux/sensor_data_linux.cc b/services/device/generic_sensor/linux/sensor_data_linux.cc index e68af0db..b541b66 100644 --- a/services/device/generic_sensor/linux/sensor_data_linux.cc +++ b/services/device/generic_sensor/linux/sensor_data_linux.cc
@@ -81,7 +81,7 @@ data->sensor_frequency_file_name = "in_accel_base_sampling_frequency"; data->apply_scaling_func = base::Bind( [](double scaling_value, double offset, SensorReading& reading) { - double scaling = kMeanGravity / scaling_value; + double scaling = base::kMeanGravityDouble / scaling_value; reading.accel.x = scaling * (reading.accel.x + offset); reading.accel.y = scaling * (reading.accel.y + offset); reading.accel.z = scaling * (reading.accel.z + offset); @@ -115,14 +115,14 @@ #if defined(OS_CHROMEOS) data->sensor_scale_name = "in_anglvel_base_scale"; data->sensor_frequency_file_name = "in_anglvel_base_frequency"; - data->apply_scaling_func = base::Bind( - [](double scaling_value, double offset, SensorReading& reading) { - double scaling = gfx::DegToRad(kMeanGravity) / scaling_value; - // Adapt CrOS reading values to generic sensor api specs. - reading.gyro.x = -scaling * (reading.gyro.x + offset); - reading.gyro.y = -scaling * (reading.gyro.y + offset); - reading.gyro.z = -scaling * (reading.gyro.z + offset); - }); + data->apply_scaling_func = base::Bind([](double scaling_value, double offset, + SensorReading& reading) { + double scaling = gfx::DegToRad(base::kMeanGravityDouble) / scaling_value; + // Adapt CrOS reading values to generic sensor api specs. + reading.gyro.x = -scaling * (reading.gyro.x + offset); + reading.gyro.y = -scaling * (reading.gyro.y + offset); + reading.gyro.z = -scaling * (reading.gyro.z + offset); + }); #else data->sensor_scale_name = "in_anglvel_scale"; data->sensor_offset_file_name = "in_anglvel_offset";
diff --git a/services/device/generic_sensor/platform_sensor_accelerometer_mac.cc b/services/device/generic_sensor/platform_sensor_accelerometer_mac.cc index 1d0afc6..34d80c6c 100644 --- a/services/device/generic_sensor/platform_sensor_accelerometer_mac.cc +++ b/services/device/generic_sensor/platform_sensor_accelerometer_mac.cc
@@ -9,15 +9,15 @@ #include <cmath> #include "base/bind.h" +#include "base/numerics/math_constants.h" #include "device/base/synchronization/shared_memory_seqlock_buffer.h" -#include "services/device/generic_sensor/generic_sensor_consts.h" #include "services/device/generic_sensor/platform_sensor_provider_mac.h" #include "services/device/public/cpp/generic_sensor/sensor_traits.h" #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h" namespace { -constexpr double kGravityThreshold = device::kMeanGravity * 0.01; +constexpr double kGravityThreshold = base::kMeanGravityDouble * 0.01; bool IsSignificantlyDifferent(const device::SensorReading& reading1, const device::SensorReading& reading2) { @@ -90,9 +90,9 @@ SensorReading reading; reading.accel.timestamp = (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); - reading.accel.x = axis_value[0] * kMeanGravity; - reading.accel.y = axis_value[1] * kMeanGravity; - reading.accel.z = axis_value[2] * kMeanGravity; + reading.accel.x = axis_value[0] * base::kMeanGravityDouble; + reading.accel.y = axis_value[1] * base::kMeanGravityDouble; + reading.accel.z = axis_value[2] * base::kMeanGravityDouble; if (IsSignificantlyDifferent(reading_, reading)) { reading_ = reading;
diff --git a/services/device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc b/services/device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc index 05e4bf06..f2060b8 100644 --- a/services/device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc +++ b/services/device/generic_sensor/platform_sensor_and_provider_unittest_linux.cc
@@ -8,6 +8,7 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/memory/ptr_util.h" +#include "base/numerics/math_constants.h" #include "base/run_loop.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" @@ -568,7 +569,7 @@ SensorReadingSharedBuffer* buffer = static_cast<SensorReadingSharedBuffer*>(mapping.get()); #if defined(OS_CHROMEOS) - double scaling = kMeanGravity / kAccelerometerScalingValue; + double scaling = base::kMeanGravityDouble / kAccelerometerScalingValue; EXPECT_THAT(buffer->reading.accel.x, scaling * sensor_values[0]); EXPECT_THAT(buffer->reading.accel.y, scaling * sensor_values[1]); EXPECT_THAT(buffer->reading.accel.z, scaling * sensor_values[2]); @@ -606,7 +607,7 @@ // CrOS has a different axes plane and scale, see crbug.com/501184. double sensor_values[3] = {0, 0, 1}; #else - double sensor_values[3] = {0, 0, -kMeanGravity}; + double sensor_values[3] = {0, 0, -base::kMeanGravityDouble}; #endif InitializeSupportedSensor(SensorType::ACCELEROMETER, kAccelerometerFrequencyValue, kZero, kZero, @@ -675,7 +676,8 @@ SensorReadingSharedBuffer* buffer = static_cast<SensorReadingSharedBuffer*>(mapping.get()); #if defined(OS_CHROMEOS) - double scaling = gfx::DegToRad(kMeanGravity) / kGyroscopeScalingValue; + double scaling = + gfx::DegToRad(base::kMeanGravityDouble) / kGyroscopeScalingValue; EXPECT_THAT(buffer->reading.gyro.x, -scaling * sensor_values[0]); EXPECT_THAT(buffer->reading.gyro.y, -scaling * sensor_values[1]); EXPECT_THAT(buffer->reading.gyro.z, -scaling * sensor_values[2]);
diff --git a/services/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc b/services/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc index 74fb67e..957b0779 100644 --- a/services/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc +++ b/services/device/generic_sensor/platform_sensor_and_provider_unittest_win.cc
@@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/metrics/statistics_recorder.h" +#include "base/numerics/math_constants.h" #include "base/run_loop.h" #include "base/test/bind_test_util.h" #include "base/test/metrics/histogram_tester.h" @@ -562,9 +563,9 @@ base::RunLoop().RunUntilIdle(); SensorReadingSharedBuffer* buffer = static_cast<SensorReadingSharedBuffer*>(mapping.get()); - EXPECT_THAT(buffer->reading.accel.x, -x_accel * kMeanGravity); - EXPECT_THAT(buffer->reading.accel.y, -y_accel * kMeanGravity); - EXPECT_THAT(buffer->reading.accel.z, -z_accel * kMeanGravity); + EXPECT_THAT(buffer->reading.accel.x, -x_accel * base::kMeanGravityDouble); + EXPECT_THAT(buffer->reading.accel.y, -y_accel * base::kMeanGravityDouble); + EXPECT_THAT(buffer->reading.accel.z, -z_accel * base::kMeanGravityDouble); EXPECT_TRUE(sensor->StopListening(client.get(), configuration)); }
diff --git a/services/device/generic_sensor/platform_sensor_reader_win.cc b/services/device/generic_sensor/platform_sensor_reader_win.cc index 336ab02..5ddbb0b 100644 --- a/services/device/generic_sensor/platform_sensor_reader_win.cc +++ b/services/device/generic_sensor/platform_sensor_reader_win.cc
@@ -14,6 +14,7 @@ #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/metrics/histogram_functions.h" +#include "base/numerics/math_constants.h" #include "base/stl_util.h" #include "base/threading/thread_task_runner_handle.h" #include "base/time/time.h" @@ -103,9 +104,9 @@ // https://msdn.microsoft.com/en-us/library/windows/hardware/dn642102(v=vs.85).aspx // Change sign of values, to report 'reaction force', and convert values // from G/s^2 to m/s^2 units. - reading->accel.x = -x * kMeanGravity; - reading->accel.y = -y * kMeanGravity; - reading->accel.z = -z * kMeanGravity; + reading->accel.x = -x * base::kMeanGravityDouble; + reading->accel.y = -y * base::kMeanGravityDouble; + reading->accel.z = -z * base::kMeanGravityDouble; return S_OK; }; return params;
diff --git a/services/device/generic_sensor/platform_sensor_reader_winrt.cc b/services/device/generic_sensor/platform_sensor_reader_winrt.cc index 94aa8702..366e9a2c 100644 --- a/services/device/generic_sensor/platform_sensor_reader_winrt.cc +++ b/services/device/generic_sensor/platform_sensor_reader_winrt.cc
@@ -7,6 +7,7 @@ #include <cmath> #include "base/metrics/histogram_functions.h" +#include "base/numerics/math_constants.h" #include "base/win/core_winrt_util.h" #include "services/device/generic_sensor/generic_sensor_consts.h" #include "services/device/public/mojom/sensor.mojom.h" @@ -445,9 +446,9 @@ // The generic sensor interface exposes acceleration simply as // m/s^2, so the data must be converted. SensorReading reading; - reading.accel.x = -x * kMeanGravity; - reading.accel.y = -y * kMeanGravity; - reading.accel.z = -z * kMeanGravity; + reading.accel.x = -x * base::kMeanGravityDouble; + reading.accel.y = -y * base::kMeanGravityDouble; + reading.accel.z = -z * base::kMeanGravityDouble; reading.accel.timestamp = timestamp_delta.InSecondsF(); client_->OnReadingUpdated(reading); @@ -794,4 +795,4 @@ return S_OK; } -} // namespace device \ No newline at end of file +} // namespace device
diff --git a/services/device/generic_sensor/platform_sensor_reader_winrt_unittests.cc b/services/device/generic_sensor/platform_sensor_reader_winrt_unittests.cc index ac140e1..13662ae 100644 --- a/services/device/generic_sensor/platform_sensor_reader_winrt_unittests.cc +++ b/services/device/generic_sensor/platform_sensor_reader_winrt_unittests.cc
@@ -6,6 +6,7 @@ #include <objbase.h> +#include "base/numerics/math_constants.h" #include "base/test/bind_test_util.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/task_environment.h" @@ -903,9 +904,9 @@ auto mock_client = std::make_unique<testing::NiceMock<MockClient>>(); EXPECT_CALL(*mock_client, OnReadingUpdated(::testing::_)) .WillOnce(testing::Invoke([&](const SensorReading& reading) { - EXPECT_EQ(-expected_x * kMeanGravity, reading.accel.x); - EXPECT_EQ(-expected_y * kMeanGravity, reading.accel.y); - EXPECT_EQ(-expected_z * kMeanGravity, reading.accel.z); + EXPECT_EQ(-expected_x * base::kMeanGravityDouble, reading.accel.x); + EXPECT_EQ(-expected_y * base::kMeanGravityDouble, reading.accel.y); + EXPECT_EQ(-expected_z * base::kMeanGravityDouble, reading.accel.z); })); sensor->SetClient(mock_client.get());
diff --git a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc index e5b1677b6..0b1617e 100644 --- a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc +++ b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.cc
@@ -7,7 +7,7 @@ #include <cmath> #include "base/logging.h" -#include "services/device/generic_sensor/generic_sensor_consts.h" +#include "base/numerics/math_constants.h" #include "services/device/generic_sensor/platform_sensor_fusion.h" #include "ui/gfx/geometry/angle_conversions.h" @@ -42,7 +42,8 @@ // the equations. *alpha_in_degrees = NAN; *beta_in_degrees = gfx::RadToDeg(std::atan2(-acceleration_y, acceleration_z)); - *gamma_in_degrees = gfx::RadToDeg(std::asin(acceleration_x / kMeanGravity)); + *gamma_in_degrees = + gfx::RadToDeg(std::asin(acceleration_x / base::kMeanGravityDouble)); // Convert beta and gamma to fit the intervals in the specification. Beta is // [-180, 180) and gamma is [-90, 90).
diff --git a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope_unittest.cc b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope_unittest.cc index e88825a..deed0eb 100644 --- a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope_unittest.cc +++ b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_and_gyroscope_unittest.cc
@@ -150,7 +150,7 @@ GryoscopeZReadingPositiveValues) { double accel_x = 0.0; double accel_y = 0.0; - double accel_z = device::kMeanGravity; + double accel_z = base::kMeanGravityDouble; double gyro_x = 0.0; double gyro_y = 0.0; double gyro_z = base::kPiDouble; @@ -174,7 +174,7 @@ GryoscopeZReadingNegativeValues) { double accel_x = 0.0; double accel_y = 0.0; - double accel_z = device::kMeanGravity; + double accel_z = base::kMeanGravityDouble; double gyro_x = 0.0; double gyro_y = 0.0; double gyro_z = -base::kPiDouble; @@ -238,8 +238,8 @@ gyro_timestamp += kTimestampIncrement; angle += kAngleIncrement; - accel_y = device::kMeanGravity * std::sin(angle); - accel_z = device::kMeanGravity * std::cos(angle); + accel_y = base::kMeanGravityDouble * std::sin(angle); + accel_z = base::kMeanGravityDouble * std::cos(angle); } // Test the device rotates around x-axis in 360 degrees with negative |gyro_x| @@ -261,8 +261,8 @@ angle += kAngleIncrement; // Here the |accel_y| is different from the above because the device // rotates around x-axis in the opposite direction. - accel_y = -device::kMeanGravity * std::sin(angle); - accel_z = device::kMeanGravity * std::cos(angle); + accel_y = -base::kMeanGravityDouble * std::sin(angle); + accel_z = base::kMeanGravityDouble * std::cos(angle); } } @@ -302,8 +302,8 @@ gyro_timestamp += kTimestampIncrement; angle += kAngleIncrement; - accel_x = -device::kMeanGravity * std::sin(angle); - accel_z = device::kMeanGravity * std::cos(angle); + accel_x = -base::kMeanGravityDouble * std::sin(angle); + accel_z = base::kMeanGravityDouble * std::cos(angle); } // Test the device rotates around y-axis in 360 degrees with negative |gyro_y| @@ -325,8 +325,8 @@ angle += kAngleIncrement; // Here the |accel_x| is different from the above because the device // rotates around y-axis in the opposite direction. - accel_x = device::kMeanGravity * std::sin(angle); - accel_z = device::kMeanGravity * std::cos(angle); + accel_x = base::kMeanGravityDouble * std::sin(angle); + accel_z = base::kMeanGravityDouble * std::cos(angle); } }
diff --git a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_unittest.cc b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_unittest.cc index 00f910c5..096ed5d1 100644 --- a/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_unittest.cc +++ b/services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer_unittest.cc
@@ -5,9 +5,9 @@ #include <cmath> #include "base/memory/ref_counted.h" +#include "base/numerics/math_constants.h" #include "base/test/task_environment.h" #include "services/device/generic_sensor/fake_platform_sensor_fusion.h" -#include "services/device/generic_sensor/generic_sensor_consts.h" #include "services/device/generic_sensor/relative_orientation_euler_angles_fusion_algorithm_using_accelerometer.h" #include "testing/gtest/include/gtest/gtest.h" @@ -79,7 +79,7 @@ NeutralOrientation) { double acceleration_x = 0.0; double acceleration_y = 0.0; - double acceleration_z = kMeanGravity; + double acceleration_z = base::kMeanGravityDouble; double expected_beta_in_degrees = 0.0; double expected_gamma_in_degrees = 0.0; @@ -95,7 +95,7 @@ UpsideDown) { double acceleration_x = 0.0; double acceleration_y = 0.0; - double acceleration_z = -kMeanGravity; + double acceleration_z = -base::kMeanGravityDouble; double expected_beta_in_degrees = -180.0; double expected_gamma_in_degrees = 0.0; @@ -109,8 +109,8 @@ TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BeforeUpsideDownBoundary) { double acceleration_x = 0.0; - double acceleration_y = -kMeanGravity / 2.0; - double acceleration_z = -kMeanGravity / 2.0; + double acceleration_y = -base::kMeanGravityDouble / 2.0; + double acceleration_z = -base::kMeanGravityDouble / 2.0; double expected_beta_in_degrees = 135.0; double expected_gamma_in_degrees = 0.0; @@ -124,7 +124,7 @@ TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, TopEdge) { double acceleration_x = 0.0; - double acceleration_y = kMeanGravity; + double acceleration_y = base::kMeanGravityDouble; double acceleration_z = 0.0; double expected_beta_in_degrees = -90.0; @@ -139,8 +139,8 @@ TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BeforeTopEdgeBoundary) { double acceleration_x = 0.0; - double acceleration_y = kMeanGravity / 2.0; - double acceleration_z = kMeanGravity / 2.0; + double acceleration_y = base::kMeanGravityDouble / 2.0; + double acceleration_z = base::kMeanGravityDouble / 2.0; double expected_beta_in_degrees = -45.0; double expected_gamma_in_degrees = 0.0; @@ -154,7 +154,7 @@ TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BottomEdge) { double acceleration_x = 0.0; - double acceleration_y = -kMeanGravity; + double acceleration_y = -base::kMeanGravityDouble; double acceleration_z = 0.0; double expected_beta_in_degrees = 90.0; @@ -169,8 +169,8 @@ TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BeforeBottomEdgeBoundary) { double acceleration_x = 0.0; - double acceleration_y = -kMeanGravity / 2.0; - double acceleration_z = kMeanGravity / 2.0; + double acceleration_y = -base::kMeanGravityDouble / 2.0; + double acceleration_z = base::kMeanGravityDouble / 2.0; double expected_beta_in_degrees = 45.0; double expected_gamma_in_degrees = 0.0; @@ -183,7 +183,7 @@ // Tests a device lying on its left-edge. TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, LeftEdge) { - double acceleration_x = -kMeanGravity; + double acceleration_x = -base::kMeanGravityDouble; double acceleration_y = 0.0; double acceleration_z = 0.0; @@ -199,9 +199,9 @@ // side. TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BeforeLeftEdgeBoundary) { - double acceleration_x = -kMeanGravity / std::sqrt(2.0); + double acceleration_x = -base::kMeanGravityDouble / std::sqrt(2.0); double acceleration_y = 0.0; - double acceleration_z = kMeanGravity / std::sqrt(2.0); + double acceleration_z = base::kMeanGravityDouble / std::sqrt(2.0); double expected_beta_in_degrees = 0.0; double expected_gamma_in_degrees = -45.0; @@ -215,7 +215,7 @@ // causes the gamma value to become negative. TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, RightEdge) { - double acceleration_x = kMeanGravity; + double acceleration_x = base::kMeanGravityDouble; double acceleration_y = 0.0; double acceleration_z = 0.0; @@ -231,9 +231,9 @@ // side. TEST_F(RelativeOrientationEulerAnglesFusionAlgorithmUsingAccelerometerTest, BeforeRightEdgeBoundary) { - double acceleration_x = kMeanGravity / std::sqrt(2.0); + double acceleration_x = base::kMeanGravityDouble / std::sqrt(2.0); double acceleration_y = 0.0; - double acceleration_z = kMeanGravity / std::sqrt(2.0); + double acceleration_z = base::kMeanGravityDouble / std::sqrt(2.0); double expected_beta_in_degrees = 0.0; double expected_gamma_in_degrees = 45.0;
diff --git a/services/network/mojo_host_resolver_impl.cc b/services/network/mojo_host_resolver_impl.cc index eded104d..bbd88ef 100644 --- a/services/network/mojo_host_resolver_impl.cc +++ b/services/network/mojo_host_resolver_impl.cc
@@ -13,6 +13,7 @@ #include "net/base/host_port_pair.h" #include "net/base/ip_address.h" #include "net/base/net_errors.h" +#include "net/base/network_isolation_key.h" #include "net/dns/host_resolver.h" #include "net/dns/public/dns_query_type.h" @@ -26,6 +27,7 @@ Job(MojoHostResolverImpl* resolver_service, net::HostResolver* resolver, const std::string& hostname, + const net::NetworkIsolationKey& network_isolation_key, bool is_ex, const net::NetLogWithSource& net_log, mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> @@ -63,13 +65,14 @@ void MojoHostResolverImpl::Resolve( const std::string& hostname, + const net::NetworkIsolationKey& network_isolation_key, bool is_ex, mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> client) { DCHECK(thread_checker_.CalledOnValidThread()); - pending_jobs_.emplace_front(this, resolver_, hostname, is_ex, net_log_, - std::move(client)); + pending_jobs_.emplace_front(this, resolver_, hostname, network_isolation_key, + is_ex, net_log_, std::move(client)); auto job = pending_jobs_.begin(); job->set_iter(job); job->Start(); @@ -84,6 +87,7 @@ MojoHostResolverImpl* resolver_service, net::HostResolver* resolver, const std::string& hostname, + const net::NetworkIsolationKey& network_isolation_key, bool is_ex, const net::NetLogWithSource& net_log, mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> @@ -97,8 +101,9 @@ net::HostResolver::ResolveHostParameters parameters; if (!is_ex) parameters.dns_query_type = net::DnsQueryType::A; - request_ = resolver->CreateRequest(net::HostPortPair(hostname_, 0), net_log, - parameters); + request_ = + resolver->CreateRequest(net::HostPortPair(hostname_, 0), + network_isolation_key, net_log, parameters); } void MojoHostResolverImpl::Job::Start() {
diff --git a/services/network/mojo_host_resolver_impl.h b/services/network/mojo_host_resolver_impl.h index 9fce4cf..b5c6021 100644 --- a/services/network/mojo_host_resolver_impl.h +++ b/services/network/mojo_host_resolver_impl.h
@@ -18,6 +18,7 @@ namespace net { class HostResolver; +class NetworkIsolationKey; } // namespace net namespace network { @@ -40,6 +41,7 @@ void Resolve( const std::string& hostname, + const net::NetworkIsolationKey& network_isolation_key, bool is_ex, mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> client);
diff --git a/services/network/mojo_host_resolver_impl_unittest.cc b/services/network/mojo_host_resolver_impl_unittest.cc index a811d2e2..cbc9321 100644 --- a/services/network/mojo_host_resolver_impl_unittest.cc +++ b/services/network/mojo_host_resolver_impl_unittest.cc
@@ -17,10 +17,13 @@ #include "net/base/address_family.h" #include "net/base/ip_address.h" #include "net/base/net_errors.h" +#include "net/base/network_isolation_key.h" #include "net/dns/mock_host_resolver.h" #include "net/test/gtest_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "url/gurl.h" +#include "url/origin.h" using net::test::IsError; using net::test::IsOk; @@ -135,8 +138,8 @@ client_remote; TestRequestClient client(client_remote.InitWithNewPipeAndPassReceiver()); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client_remote)); client.WaitForResult(); EXPECT_THAT(client.error_, IsOk()); @@ -150,8 +153,8 @@ mock_host_resolver_.set_synchronous_mode(true); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client_remote)); client.WaitForResult(); EXPECT_THAT(client.error_, IsOk()); @@ -168,10 +171,10 @@ mock_host_resolver_.set_ondemand_mode(true); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client1_remote)); - resolver_service_->Resolve("chromium.org", false /* is_ex */, - std::move(client2_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client1_remote)); + resolver_service_->Resolve("chromium.org", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client2_remote)); WaitForRequests(2); mock_host_resolver_.ResolveAllPending(); @@ -194,10 +197,10 @@ mock_host_resolver_.set_ondemand_mode(true); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client1_remote)); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client2_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client1_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client2_remote)); WaitForRequests(2); mock_host_resolver_.ResolveAllPending(); @@ -215,8 +218,8 @@ client_remote; TestRequestClient client(client_remote.InitWithNewPipeAndPassReceiver()); - resolver_service_->Resolve("failure.fail", false /* is_ex */, - std::move(client_remote)); + resolver_service_->Resolve("failure.fail", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client_remote)); client.WaitForResult(); EXPECT_THAT(client.error_, IsError(net::ERR_NAME_NOT_RESOLVED)); @@ -228,14 +231,34 @@ client_remote; TestRequestClient client(client_remote.InitWithNewPipeAndPassReceiver()); - resolver_service_->Resolve("example.com", true /* is_ex */, - std::move(client_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + true /* is_ex */, std::move(client_remote)); client.WaitForResult(); EXPECT_THAT(client.error_, IsOk()); EXPECT_THAT(client.results_, testing::ElementsAre(kExampleComAddressIpv6)); } +// Makes sure that the passed in NetworkIsolationKey is passed to the +// HostResolver. +TEST_F(MojoHostResolverImplTest, NetworkIsolationKeyUsed) { + const url::Origin kOrigin = url::Origin::Create(GURL("https://foo.test/")); + const net::NetworkIsolationKey kNetworkIsolationKey(kOrigin, kOrigin); + + mock_host_resolver_.set_ondemand_mode(true); + + mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> + client_remote; + TestRequestClient client(client_remote.InitWithNewPipeAndPassReceiver()); + + resolver_service_->Resolve("example.com", kNetworkIsolationKey, + false /* is_ex */, std::move(client_remote)); + base::RunLoop().RunUntilIdle(); + ASSERT_EQ(1u, mock_host_resolver_.num_resolve()); + EXPECT_EQ(kNetworkIsolationKey, + mock_host_resolver_.last_request_network_isolation_key()); +} + TEST_F(MojoHostResolverImplTest, DestroyClient) { mojo::PendingRemote<proxy_resolver::mojom::HostResolverRequestClient> client_remote; @@ -244,8 +267,8 @@ mock_host_resolver_.set_ondemand_mode(true); - resolver_service_->Resolve("example.com", false /* is_ex */, - std::move(client_remote)); + resolver_service_->Resolve("example.com", net::NetworkIsolationKey(), + false /* is_ex */, std::move(client_remote)); WaitForRequests(1); client.reset();
diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 9c6d3e2..160a006b 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc
@@ -472,6 +472,16 @@ std::move(receiver), &cors_origin_access_list_, nullptr)); } +void NetworkContext::ActivateDohProbes() { + DCHECK(IsPrimaryNetworkContext()); + DCHECK(url_request_context_->host_resolver()); + + doh_probes_request_.reset(); + doh_probes_request_ = + url_request_context_->host_resolver()->CreateDohProbeRequest(); + doh_probes_request_->Start(); +} + void NetworkContext::SetClient( mojo::PendingRemote<mojom::NetworkContextClient> client) { client_.reset();
diff --git a/services/network/network_context.h b/services/network/network_context.h index c240998..47d8a9e1 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h
@@ -169,6 +169,10 @@ mojom::URLLoaderFactoryParamsPtr params, scoped_refptr<ResourceSchedulerClient> resource_scheduler_client); + // Enables DoH probes to be sent using this context whenever the DNS + // configuration contains DoH servers. + void ActivateDohProbes(); + // mojom::NetworkContext implementation: void SetClient( mojo::PendingRemote<mojom::NetworkContextClient> client) override; @@ -603,6 +607,7 @@ std::unique_ptr<net::HostResolver>, base::UniquePtrComparator> host_resolvers_; + std::unique_ptr<net::HostResolver::ProbeRequest> doh_probes_request_; NetworkServiceProxyDelegate* proxy_delegate_ = nullptr;
diff --git a/services/network/network_context_unittest.cc b/services/network/network_context_unittest.cc index 400e2c6..ef8ee5b 100644 --- a/services/network/network_context_unittest.cc +++ b/services/network/network_context_unittest.cc
@@ -3247,6 +3247,27 @@ } #endif // defined(OS_IOS) +TEST_F(NetworkContextTest, StartDohProbes) { + auto resolver = std::make_unique<net::MockHostResolver>(); + mojom::NetworkContextParamsPtr params = CreateContextParams(); + params->primary_network_context = true; + std::unique_ptr<NetworkContext> network_context = + CreateContextWithParams(std::move(params)); + network_context->url_request_context()->set_host_resolver(resolver.get()); + + ASSERT_FALSE(resolver->IsDohProbeRunning()); + + network_context->ActivateDohProbes(); + EXPECT_TRUE(resolver->IsDohProbeRunning()); + + base::RunLoop().RunUntilIdle(); + EXPECT_TRUE(resolver->IsDohProbeRunning()); + + network_context.reset(); + + EXPECT_FALSE(resolver->IsDohProbeRunning()); +} + TEST_F(NetworkContextTest, PrivacyModeDisabledByDefault) { std::unique_ptr<NetworkContext> network_context = CreateContextWithParams(CreateContextParams());
diff --git a/services/network/network_service.cc b/services/network/network_service.cc index 9382954..6a121f6 100644 --- a/services/network/network_service.cc +++ b/services/network/network_service.cc
@@ -422,9 +422,7 @@ for (auto* network_context : network_contexts_) { if (!network_context->IsPrimaryNetworkContext()) continue; - - host_resolver_manager_->SetRequestContextForProbes( - network_context->url_request_context()); + network_context->ActivateDohProbes(); } // Configure DNS over HTTPS.
diff --git a/services/network/network_service_unittest.cc b/services/network/network_service_unittest.cc index 020b654..1393cff 100644 --- a/services/network/network_service_unittest.cc +++ b/services/network/network_service_unittest.cc
@@ -506,16 +506,24 @@ const std::string kServer3 = "https://grapefruit/resolver/query{?dns}"; const bool kServer3UsePost = false; + mojom::NetworkContextParamsPtr context_params = CreateContextParams(); + context_params->primary_network_context = true; + mojo::Remote<mojom::NetworkContext> network_context; + service()->CreateNetworkContext(network_context.BindNewPipeAndPassReceiver(), + std::move(context_params)); + // Create valid DnsConfig. net::DnsConfig config; config.nameservers.push_back(net::IPEndPoint()); auto dns_client = std::make_unique<net::MockDnsClient>( std::move(config), net::MockDnsClientRuleList()); dns_client->set_ignore_system_config_changes(true); - net::DnsClient* dns_client_ptr = dns_client.get(); + net::MockDnsClient* dns_client_ptr = dns_client.get(); service()->host_resolver_manager()->SetDnsClientForTesting( std::move(dns_client)); + ASSERT_FALSE(dns_client_ptr->factory()->doh_probes_running()); + // Enable DNS over HTTPS for one server. std::vector<mojom::DnsOverHttpsServerPtr> dns_over_https_servers_ptr; @@ -535,6 +543,7 @@ ASSERT_EQ(1u, dns_over_https_servers.size()); EXPECT_EQ(kServer1, dns_over_https_servers[0].server_template); EXPECT_EQ(kServer1UsePost, dns_over_https_servers[0].use_post); + EXPECT_TRUE(dns_client_ptr->factory()->doh_probes_running()); // Enable DNS over HTTPS for two servers. @@ -560,6 +569,7 @@ EXPECT_EQ(kServer2UsePost, dns_over_https_servers[0].use_post); EXPECT_EQ(kServer3, dns_over_https_servers[1].server_template); EXPECT_EQ(kServer3UsePost, dns_over_https_servers[1].use_post); + EXPECT_TRUE(dns_client_ptr->factory()->doh_probes_running()); } TEST_F(NetworkServiceTest, DisableDohUpgradeProviders) {
diff --git a/services/network/proxy_resolver_factory_mojo.cc b/services/network/proxy_resolver_factory_mojo.cc index eb65d944..aeeb254 100644 --- a/services/network/proxy_resolver_factory_mojo.cc +++ b/services/network/proxy_resolver_factory_mojo.cc
@@ -25,6 +25,7 @@ #include "net/base/ip_address.h" #include "net/base/load_states.h" #include "net/base/net_errors.h" +#include "net/base/network_isolation_key.h" #include "net/log/net_log.h" #include "net/log/net_log_capture_mode.h" #include "net/log/net_log_event_type.h" @@ -130,7 +131,9 @@ base::BindOnce(&DoMyIpAddressOnWorker, is_ex, std::move(client))); } else { // Request was for dnsResolve() or dnsResolveEx(). - host_resolver_.Resolve(hostname, is_ex, std::move(client)); + // TODO(mmenke): Pass in a NetworkIsolationKey(). + host_resolver_.Resolve(hostname, net::NetworkIsolationKey(), is_ex, + std::move(client)); } }
diff --git a/testing/variations/fieldtrial_testing_config.json b/testing/variations/fieldtrial_testing_config.json index c82e501e..c4b3f31 100644 --- a/testing/variations/fieldtrial_testing_config.json +++ b/testing/variations/fieldtrial_testing_config.json
@@ -4711,6 +4711,24 @@ ] } ], + "PreconnectOnDidFinishNavigation": [ + { + "platforms": [ + "android" + ], + "experiments": [ + { + "name": "Enabled_3_seconds", + "params": { + "delay_after_commit_in_ms": "3000" + }, + "enable_features": [ + "PreconnectOnDidFinishNavigation" + ] + } + ] + } + ], "PrefetchSRPAndroid": [ { "platforms": [
diff --git a/third_party/android_deps/BUILD.gn b/third_party/android_deps/BUILD.gn index 46846795..95b688d2 100644 --- a/third_party/android_deps/BUILD.gn +++ b/third_party/android_deps/BUILD.gn
@@ -163,6 +163,18 @@ } # This is generated, do not edit. Update BuildConfigGenerator.groovy instead. +java_prebuilt("androidx_concurrent_concurrent_futures_java") { + jar_path = + "libs/androidx_concurrent_concurrent_futures/concurrent-futures-1.0.0.jar" + output_name = "androidx_concurrent_concurrent_futures" + supports_android = true + deps = [ + ":androidx_annotation_annotation_java", + ":com_google_guava_listenablefuture_java", + ] +} + +# This is generated, do not edit. Update BuildConfigGenerator.groovy instead. android_aar_prebuilt("androidx_coordinatorlayout_coordinatorlayout_java") { aar_path = "libs/androidx_coordinatorlayout_coordinatorlayout/coordinatorlayout-1.0.0.aar" info_path = "libs/androidx_coordinatorlayout_coordinatorlayout/androidx_coordinatorlayout_coordinatorlayout.info" @@ -1064,6 +1076,13 @@ } # This is generated, do not edit. Update BuildConfigGenerator.groovy instead. +java_prebuilt("com_google_guava_listenablefuture_java") { + jar_path = "libs/com_google_guava_listenablefuture/listenablefuture-1.0.jar" + output_name = "com_google_guava_listenablefuture" + supports_android = true +} + +# This is generated, do not edit. Update BuildConfigGenerator.groovy instead. java_prebuilt("com_google_protobuf_protobuf_lite_java") { jar_path = "libs/com_google_protobuf_protobuf_lite/protobuf-lite-3.0.1.jar" output_name = "com_google_protobuf_protobuf_lite" @@ -1794,6 +1813,8 @@ ":org_checkerframework_checker_compat_qual_java", ":org_codehaus_mojo_animal_sniffer_annotations_java", ] + deps += [ ":com_google_guava_listenablefuture_java" ] + jar_excluded_patterns = [ "*/ListenableFuture.class" ] } # This is generated, do not edit. Update BuildConfigGenerator.groovy instead.
diff --git a/third_party/android_deps/additional_readme_paths.json b/third_party/android_deps/additional_readme_paths.json index 02291c1..910e0ca 100644 --- a/third_party/android_deps/additional_readme_paths.json +++ b/third_party/android_deps/additional_readme_paths.json
@@ -14,6 +14,7 @@ "libs/androidx_asynclayoutinflater_asynclayoutinflater", "libs/androidx_cardview_cardview", "libs/androidx_collection_collection", + "libs/androidx_concurrent_concurrent_futures", "libs/androidx_coordinatorlayout_coordinatorlayout", "libs/androidx_core_core", "libs/androidx_cursoradapter_cursoradapter", @@ -126,6 +127,7 @@ "libs/com_google_errorprone_javac_shaded", "libs/com_google_googlejavaformat_google_java_format", "libs/com_google_guava_guava", + "libs/com_google_guava_listenablefuture", "libs/com_google_j2objc_j2objc_annotations", "libs/com_google_protobuf_protobuf_lite", "libs/com_squareup_javapoet",
diff --git a/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/LICENSE b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/LICENSE
@@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.
diff --git a/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/OWNERS b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/OWNERS new file mode 100644 index 0000000..7b571d97 --- /dev/null +++ b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/OWNERS
@@ -0,0 +1 @@ +file://third_party/android_deps/OWNERS \ No newline at end of file
diff --git a/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/README.chromium b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/README.chromium new file mode 100644 index 0000000..22885a5 --- /dev/null +++ b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/README.chromium
@@ -0,0 +1,13 @@ +Name: AndroidX Futures +Short Name: concurrent-futures +URL: https://developer.android.com/topic/libraries/architecture/index.html +Version: 1.0.0 +License: Apache Version 2.0 +License File: LICENSE +Security Critical: yes + +Description: +Androidx implementation of Guava's ListenableFuture + +Local Modifications: +No modifications.
diff --git a/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/cipd.yaml b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/cipd.yaml new file mode 100644 index 0000000..043d62fd1 --- /dev/null +++ b/third_party/android_deps/libs/androidx_concurrent_concurrent_futures/cipd.yaml
@@ -0,0 +1,10 @@ +# Copyright 2018 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. + +# To create CIPD package run the following command. +# cipd create --pkg-def cipd.yaml -tag version:1.0.0-cr0 +package: chromium/third_party/android_deps/libs/androidx_concurrent_concurrent_futures +description: "AndroidX Futures" +data: +- file: concurrent-futures-1.0.0.jar
diff --git a/third_party/android_deps/libs/com_google_errorprone_javac_shaded/README.chromium b/third_party/android_deps/libs/com_google_errorprone_javac_shaded/README.chromium index 1f1a923..56b2ecc 100644 --- a/third_party/android_deps/libs/com_google_errorprone_javac_shaded/README.chromium +++ b/third_party/android_deps/libs/com_google_errorprone_javac_shaded/README.chromium
@@ -2,7 +2,7 @@ Short Name: javac-shaded URL: https://github.com/google/error-prone-javac Version: 9-dev-r4023-3 -License: GNU General Public License, version 2, with the Classpath Exception +License: GPL v2 with the classpath exception License File: NOT_SHIPPED Security Critical: no
diff --git a/third_party/android_deps/libs/com_google_guava_listenablefuture/LICENSE b/third_party/android_deps/libs/com_google_guava_listenablefuture/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/third_party/android_deps/libs/com_google_guava_listenablefuture/LICENSE
@@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License.
diff --git a/third_party/android_deps/libs/com_google_guava_listenablefuture/OWNERS b/third_party/android_deps/libs/com_google_guava_listenablefuture/OWNERS new file mode 100644 index 0000000..7b571d97 --- /dev/null +++ b/third_party/android_deps/libs/com_google_guava_listenablefuture/OWNERS
@@ -0,0 +1 @@ +file://third_party/android_deps/OWNERS \ No newline at end of file
diff --git a/third_party/android_deps/libs/com_google_guava_listenablefuture/README.chromium b/third_party/android_deps/libs/com_google_guava_listenablefuture/README.chromium new file mode 100644 index 0000000..44c01e67 --- /dev/null +++ b/third_party/android_deps/libs/com_google_guava_listenablefuture/README.chromium
@@ -0,0 +1,13 @@ +Name: Guava ListenableFuture only +Short Name: listenablefuture +URL: https://github.com/google/guava +Version: 1.0 +License: Apache 2.0 +License File: LICENSE +Security Critical: yes + +Description: +Contains Guava's com.google.common.util.concurrent.ListenableFuture class, without any of its other classes -- but is also available in a second "version" that omits the class to avoid conflicts with the copy in Guava itself. The idea is: - If users want only ListenableFuture, they depend on listenablefuture-1.0. - If users want all of Guava, they depend on guava, which, as of Guava 27.0, depends on listenablefuture-9999.0-empty-to-avoid-conflict-with-guava. The 9999.0-... version number is enough for some build systems (notably, Gradle) to select that empty artifact over the "real" listenablefuture-1.0 -- avoiding a conflict with the copy of ListenableFuture in guava itself. If users are using an older version of Guava or a build system other than Gradle, they may see class conflicts. If so, they can solve them by manually excluding the listenablefuture artifact or manually forcing their build systems to use 9999.0-.... + +Local Modifications: +No modifications.
diff --git a/third_party/android_deps/libs/com_google_guava_listenablefuture/cipd.yaml b/third_party/android_deps/libs/com_google_guava_listenablefuture/cipd.yaml new file mode 100644 index 0000000..f8f0fdb --- /dev/null +++ b/third_party/android_deps/libs/com_google_guava_listenablefuture/cipd.yaml
@@ -0,0 +1,10 @@ +# Copyright 2018 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. + +# To create CIPD package run the following command. +# cipd create --pkg-def cipd.yaml -tag version:1.0-cr0 +package: chromium/third_party/android_deps/libs/com_google_guava_listenablefuture +description: "Guava ListenableFuture only" +data: +- file: listenablefuture-1.0.jar
diff --git a/third_party/blink/common/BUILD.gn b/third_party/blink/common/BUILD.gn index ab8e121..c32c08f 100644 --- a/third_party/blink/common/BUILD.gn +++ b/third_party/blink/common/BUILD.gn
@@ -102,7 +102,6 @@ "//net", "//services/metrics/public/cpp:ukm_builders", "//services/network/public/cpp:cpp", - "//third_party/blink/public/mojom:mojom_platform_blink_headers", ] # iOS doesn't use and must not depend on //media
diff --git a/third_party/blink/common/logging/logging_utils.cc b/third_party/blink/common/logging/logging_utils.cc index cbe5692..1c587024 100644 --- a/third_party/blink/common/logging/logging_utils.cc +++ b/third_party/blink/common/logging/logging_utils.cc
@@ -4,7 +4,7 @@ #include "third_party/blink/public/common/logging/logging_utils.h" -#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h" +#include "third_party/blink/public/mojom/devtools/console_message.mojom.h" namespace blink {
diff --git a/third_party/blink/public/mojom/service_worker/controller_service_worker.mojom b/third_party/blink/public/mojom/service_worker/controller_service_worker.mojom index a5104b9..dca248b8 100644 --- a/third_party/blink/public/mojom/service_worker/controller_service_worker.mojom +++ b/third_party/blink/public/mojom/service_worker/controller_service_worker.mojom
@@ -6,6 +6,7 @@ import "mojo/public/mojom/base/time.mojom"; import "mojo/public/mojom/base/unguessable_token.mojom"; +import "services/network/public/mojom/network_context.mojom"; import "services/network/public/mojom/url_loader.mojom"; import "third_party/blink/public/mojom/service_worker/controller_service_worker_mode.mojom"; import "third_party/blink/public/mojom/service_worker/dispatch_fetch_event_params.mojom"; @@ -45,7 +46,10 @@ // TODO(kinuko): Add DispatchExtendableMessageEvent() as well. // Connects a new pipe to this controller instance. - Clone(pending_receiver<ControllerServiceWorker> receiver); + // |cross_origin_embedder_policy| is the policy for the client which uses the + // counterpart of |receiver|. + Clone(pending_receiver<ControllerServiceWorker> receiver, + network.mojom.CrossOriginEmbedderPolicy cross_origin_embedder_policy); }; // A convenient struct that packs necessary information for a service worker
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h index e2cc612..2471660d 100644 --- a/third_party/blink/public/platform/platform.h +++ b/third_party/blink/public/platform/platform.h
@@ -550,13 +550,6 @@ // WebRTC ---------------------------------------------------------- - // Returns the SingleThreadTaskRunner suitable for running WebRTC networking. - // An rtc::Thread will have already been created. - // May return null if WebRTC functionality is not implemented. - virtual scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() { - return nullptr; - } - // Checks if the default minimum starting volume value for the AGC is // overridden on the command line. virtual base::Optional<double> GetWebRtcMaxCaptureFrameRate() {
diff --git a/third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h b/third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h index 851ddd9a..cef6f21 100644 --- a/third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h +++ b/third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h
@@ -117,7 +117,10 @@ blink::WebRtcAudioDeviceImpl* GetWebRtcAudioDevice(); void EnsureInitialized(); - scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerThread() const; + + // Returns the SingleThreadTaskRunner suitable for running WebRTC networking. + // An rtc::Thread will have already been created. + scoped_refptr<base::SingleThreadTaskRunner> GetWebRtcWorkerTaskRunner(); // Returns the rtc::Thread instance associated with the WebRTC worker thread. // TODO(bugs.webrtc.org/9419): Remove once WebRTC can be built as a component.
diff --git a/third_party/blink/renderer/core/editing/compute_layer_selection.cc b/third_party/blink/renderer/core/editing/compute_layer_selection.cc index c7fd9bb..8e841a2 100644 --- a/third_party/blink/renderer/core/editing/compute_layer_selection.cc +++ b/third_party/blink/renderer/core/editing/compute_layer_selection.cc
@@ -108,14 +108,14 @@ } static PhysicalOffset GetSamplePointForVisibility( - const PhysicalOffset& edge_top_in_layer, - const PhysicalOffset& edge_bottom_in_layer, + const PhysicalOffset& edge_start_in_layer, + const PhysicalOffset& edge_end_in_layer, float zoom_factor) { - FloatSize diff(edge_top_in_layer - edge_bottom_in_layer); + FloatSize diff(edge_start_in_layer - edge_end_in_layer); // Adjust by ~1px to avoid integer snapping error. This logic is the same // as that in ComputeViewportSelectionBound in cc. diff.Scale(zoom_factor / diff.DiagonalLength()); - PhysicalOffset sample_point = edge_bottom_in_layer; + PhysicalOffset sample_point = edge_end_in_layer; sample_point += PhysicalOffset::FromFloatSizeRound(diff); return sample_point; } @@ -123,8 +123,8 @@ // Returns whether this position is not visible on the screen (because // clipped out). static bool IsVisible(const LayoutObject& rect_layout_object, - const PhysicalOffset& edge_top_in_layer, - const PhysicalOffset& edge_bottom_in_layer) { + const PhysicalOffset& edge_start_in_layer, + const PhysicalOffset& edge_end_in_layer) { Node* const node = rect_layout_object.GetNode(); if (!node) return true; @@ -139,7 +139,7 @@ return true; const PhysicalOffset sample_point = - GetSamplePointForVisibility(edge_top_in_layer, edge_bottom_in_layer, + GetSamplePointForVisibility(edge_start_in_layer, edge_end_in_layer, rect_layout_object.View()->ZoomFactor()); LayoutBox* const text_control_object = ToLayoutBox(layout_object); @@ -153,17 +153,17 @@ static cc::LayerSelectionBound ComputeSelectionBound( const LayoutObject& layout_object, const GraphicsLayer& graphics_layer, - const PhysicalOffset& edge_top_in_layer, - const PhysicalOffset& edge_bottom_in_layer) { + const PhysicalOffset& edge_start_in_layer, + const PhysicalOffset& edge_end_in_layer) { cc::LayerSelectionBound bound; - bound.edge_top = LocalToInvalidationBackingPoint( - edge_top_in_layer, layout_object, graphics_layer); - bound.edge_bottom = LocalToInvalidationBackingPoint( - edge_bottom_in_layer, layout_object, graphics_layer); + bound.edge_start = LocalToInvalidationBackingPoint( + edge_start_in_layer, layout_object, graphics_layer); + bound.edge_end = LocalToInvalidationBackingPoint( + edge_end_in_layer, layout_object, graphics_layer); bound.layer_id = graphics_layer.CcLayer()->id(); bound.hidden = - !IsVisible(layout_object, edge_top_in_layer, edge_bottom_in_layer); + !IsVisible(layout_object, edge_start_in_layer, edge_end_in_layer); return bound; } @@ -201,11 +201,11 @@ if (!graphics_layer) return base::nullopt; - PhysicalOffset edge_top_in_layer, edge_bottom_in_layer; - std::tie(edge_top_in_layer, edge_bottom_in_layer) = + PhysicalOffset edge_start_in_layer, edge_end_in_layer; + std::tie(edge_start_in_layer, edge_end_in_layer) = GetLocalSelectionStartpoints(local_caret_rect); cc::LayerSelectionBound bound = ComputeSelectionBound( - *layout_object, *graphics_layer, edge_top_in_layer, edge_bottom_in_layer); + *layout_object, *graphics_layer, edge_start_in_layer, edge_end_in_layer); if (selection.IsRange()) { bound.type = IsTextDirectionRTL(*position.AnchorNode(), *layout_object) ? gfx::SelectionBound::Type::RIGHT @@ -228,11 +228,11 @@ if (!graphics_layer) return base::nullopt; - PhysicalOffset edge_top_in_layer, edge_bottom_in_layer; - std::tie(edge_top_in_layer, edge_bottom_in_layer) = + PhysicalOffset edge_start_in_layer, edge_end_in_layer; + std::tie(edge_start_in_layer, edge_end_in_layer) = GetLocalSelectionEndpoints(local_caret_rect); cc::LayerSelectionBound bound = ComputeSelectionBound( - *layout_object, *graphics_layer, edge_top_in_layer, edge_bottom_in_layer); + *layout_object, *graphics_layer, edge_start_in_layer, edge_end_in_layer); if (selection.IsRange()) { bound.type = IsTextDirectionRTL(*position.AnchorNode(), *layout_object) ? gfx::SelectionBound::Type::LEFT
diff --git a/third_party/blink/renderer/core/editing/compute_layer_selection_test.cc b/third_party/blink/renderer/core/editing/compute_layer_selection_test.cc index d71ee8dc..294b40e8 100644 --- a/third_party/blink/renderer/core/editing/compute_layer_selection_test.cc +++ b/third_party/blink/renderer/core/editing/compute_layer_selection_test.cc
@@ -129,10 +129,10 @@ // Top-left corner should be around (1000, 905) - 10px centered in 20px // height. - EXPECT_EQ(gfx::Point(1000, 905), composited_selection.start.edge_top); - EXPECT_EQ(gfx::Point(1000, 915), composited_selection.start.edge_bottom); - EXPECT_EQ(gfx::Point(1369, 905), composited_selection.end.edge_top); - EXPECT_EQ(gfx::Point(1369, 915), composited_selection.end.edge_bottom); + EXPECT_EQ(gfx::Point(1000, 905), composited_selection.start.edge_start); + EXPECT_EQ(gfx::Point(1000, 915), composited_selection.start.edge_end); + EXPECT_EQ(gfx::Point(1369, 905), composited_selection.end.edge_start); + EXPECT_EQ(gfx::Point(1369, 915), composited_selection.end.edge_end); } TEST_F(ComputeLayerSelectionTest, PositionInScroller) { @@ -192,10 +192,10 @@ // Top-left corner should be around (1000, 905) - 10px centered in 20px // height. - EXPECT_EQ(gfx::Point(1000, 905), composited_selection.start.edge_top); - EXPECT_EQ(gfx::Point(1000, 915), composited_selection.start.edge_bottom); - EXPECT_EQ(gfx::Point(1369, 905), composited_selection.end.edge_top); - EXPECT_EQ(gfx::Point(1369, 915), composited_selection.end.edge_bottom); + EXPECT_EQ(gfx::Point(1000, 905), composited_selection.start.edge_start); + EXPECT_EQ(gfx::Point(1000, 915), composited_selection.start.edge_end); + EXPECT_EQ(gfx::Point(1369, 905), composited_selection.end.edge_start); + EXPECT_EQ(gfx::Point(1369, 915), composited_selection.end.edge_end); } // crbug.com/807930 @@ -207,10 +207,10 @@ FocusAndSelectAll(target, *target); const cc::LayerSelection& composited_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(composited_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(composited_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(composited_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(composited_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(composited_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(composited_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(composited_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(composited_selection.end.edge_end, gfx::Point(8, 28)); } // crbug.com/807930 @@ -221,10 +221,10 @@ FocusAndSelectAll(ToTextControl(GetDocument().QuerySelector("textarea"))); const cc::LayerSelection& composited_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(composited_selection.start.edge_top, gfx::Point(11, 11)); - EXPECT_EQ(composited_selection.start.edge_bottom, gfx::Point(11, 21)); - EXPECT_EQ(composited_selection.end.edge_top, gfx::Point(11, 21)); - EXPECT_EQ(composited_selection.end.edge_bottom, gfx::Point(11, 31)); + EXPECT_EQ(composited_selection.start.edge_start, gfx::Point(11, 11)); + EXPECT_EQ(composited_selection.start.edge_end, gfx::Point(11, 21)); + EXPECT_EQ(composited_selection.end.edge_start, gfx::Point(11, 21)); + EXPECT_EQ(composited_selection.end.edge_end, gfx::Point(11, 31)); } // crbug.com/815099 @@ -244,10 +244,10 @@ UpdateAllLifecyclePhasesForTest(); const cc::LayerSelection& composited_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(composited_selection.start.edge_top, gfx::Point(27, 8)); - EXPECT_EQ(composited_selection.start.edge_bottom, gfx::Point(27, 18)); - EXPECT_EQ(composited_selection.end.edge_top, gfx::Point(27, 8)); - EXPECT_EQ(composited_selection.end.edge_bottom, gfx::Point(27, 18)); + EXPECT_EQ(composited_selection.start.edge_start, gfx::Point(27, 8)); + EXPECT_EQ(composited_selection.start.edge_end, gfx::Point(27, 18)); + EXPECT_EQ(composited_selection.end.edge_start, gfx::Point(27, 8)); + EXPECT_EQ(composited_selection.end.edge_end, gfx::Point(27, 18)); } TEST_F(ComputeLayerSelectionTest, CaretAfterSoftWrap) { @@ -266,10 +266,10 @@ UpdateAllLifecyclePhasesForTest(); const cc::LayerSelection& composited_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(composited_selection.start.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(composited_selection.start.edge_bottom, gfx::Point(8, 28)); - EXPECT_EQ(composited_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(composited_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(composited_selection.start.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(composited_selection.start.edge_end, gfx::Point(8, 28)); + EXPECT_EQ(composited_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(composited_selection.end.edge_end, gfx::Point(8, 28)); } // crbug.com/834686 @@ -285,10 +285,10 @@ UpdateAllLifecyclePhasesForTest(); const cc::LayerSelection& composited_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(composited_selection.start.edge_top, gfx::Point(38, 8)); - EXPECT_EQ(composited_selection.start.edge_bottom, gfx::Point(38, 18)); - EXPECT_EQ(composited_selection.end.edge_top, gfx::Point(28, 18)); - EXPECT_EQ(composited_selection.end.edge_bottom, gfx::Point(28, 28)); + EXPECT_EQ(composited_selection.start.edge_start, gfx::Point(38, 8)); + EXPECT_EQ(composited_selection.start.edge_end, gfx::Point(38, 18)); + EXPECT_EQ(composited_selection.end.edge_start, gfx::Point(28, 18)); + EXPECT_EQ(composited_selection.end.edge_end, gfx::Point(28, 28)); } TEST_F(ComputeLayerSelectionTest, BlockEndBR1) { @@ -302,10 +302,10 @@ FocusAndSelectAll(target, *target); const cc::LayerSelection& layer_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(layer_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(layer_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_end, gfx::Point(8, 28)); } TEST_F(ComputeLayerSelectionTest, BlockEndBR2) { @@ -319,10 +319,10 @@ FocusAndSelectAll(target, *target); const cc::LayerSelection& layer_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(layer_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(layer_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_end, gfx::Point(8, 28)); } TEST_F(ComputeLayerSelectionTest, BlockEndBR3) { @@ -336,13 +336,13 @@ FocusAndSelectAll(target, *target); const cc::LayerSelection& layer_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(layer_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(layer_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_end, gfx::Point(8, 28)); } -// crbug.com/889799. Checking when edge_bottom on box boundary, bound is still +// crbug.com/889799. Checking when edge_end on box boundary, bound is still // visible. TEST_F(ComputeLayerSelectionTest, SamplePointOnBoundary) { SetBodyContent(R"HTML( @@ -380,10 +380,10 @@ Selection().CommitAppearanceIfNeeded(); const cc::LayerSelection& layer_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(layer_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(layer_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_end, gfx::Point(8, 28)); } // https://crbug.com/892584. @@ -400,10 +400,10 @@ Selection().CommitAppearanceIfNeeded(); const cc::LayerSelection& layer_selection = ComputeLayerSelection(Selection()); - EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8)); - EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18)); - EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28)); + EXPECT_EQ(layer_selection.start.edge_start, gfx::Point(8, 8)); + EXPECT_EQ(layer_selection.start.edge_end, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_start, gfx::Point(8, 18)); + EXPECT_EQ(layer_selection.end.edge_end, gfx::Point(8, 28)); } } // namespace blink
diff --git a/third_party/blink/renderer/core/exported/web_frame_test.cc b/third_party/blink/renderer/core/exported/web_frame_test.cc index 71b65dc..5908a62 100644 --- a/third_party/blink/renderer/core/exported/web_frame_test.cc +++ b/third_party/blink/renderer/core/exported/web_frame_test.cc
@@ -39,6 +39,8 @@ #include "build/build_config.h" #include "cc/input/overscroll_behavior.h" #include "cc/layers/picture_layer.h" +#include "cc/trees/layer_tree_host.h" +#include "cc/trees/scroll_and_scale_set.h" #include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/receiver.h" @@ -6136,39 +6138,39 @@ v8::Local<v8::Context> context = v8::Isolate::GetCurrent()->GetCurrentContext(); - const int start_edge_top_in_layer_x = expected_result.Get(context, 1) + const int start_edge_start_in_layer_x = expected_result.Get(context, 1) + .ToLocalChecked() + .As<v8::Int32>() + ->Value(); + const int start_edge_start_in_layer_y = expected_result.Get(context, 2) + .ToLocalChecked() + .As<v8::Int32>() + ->Value(); + const int start_edge_end_in_layer_x = expected_result.Get(context, 3) .ToLocalChecked() .As<v8::Int32>() ->Value(); - const int start_edge_top_in_layer_y = expected_result.Get(context, 2) + const int start_edge_end_in_layer_y = expected_result.Get(context, 4) .ToLocalChecked() .As<v8::Int32>() ->Value(); - const int start_edge_bottom_in_layer_x = expected_result.Get(context, 3) - .ToLocalChecked() - .As<v8::Int32>() - ->Value(); - const int start_edge_bottom_in_layer_y = expected_result.Get(context, 4) - .ToLocalChecked() - .As<v8::Int32>() - ->Value(); - const int end_edge_top_in_layer_x = expected_result.Get(context, 6) + const int end_edge_start_in_layer_x = expected_result.Get(context, 6) + .ToLocalChecked() + .As<v8::Int32>() + ->Value(); + const int end_edge_start_in_layer_y = expected_result.Get(context, 7) + .ToLocalChecked() + .As<v8::Int32>() + ->Value(); + const int end_edge_end_in_layer_x = expected_result.Get(context, 8) .ToLocalChecked() .As<v8::Int32>() ->Value(); - const int end_edge_top_in_layer_y = expected_result.Get(context, 7) + const int end_edge_end_in_layer_y = expected_result.Get(context, 9) .ToLocalChecked() .As<v8::Int32>() ->Value(); - const int end_edge_bottom_in_layer_x = expected_result.Get(context, 8) - .ToLocalChecked() - .As<v8::Int32>() - ->Value(); - const int end_edge_bottom_in_layer_y = expected_result.Get(context, 9) - .ToLocalChecked() - .As<v8::Int32>() - ->Value(); FloatPoint hit_point; @@ -6183,11 +6185,11 @@ ->Value()); } else { hit_point = - FloatPoint((start_edge_top_in_layer_x + start_edge_bottom_in_layer_x + - end_edge_top_in_layer_x + end_edge_bottom_in_layer_x) / + FloatPoint((start_edge_start_in_layer_x + start_edge_end_in_layer_x + + end_edge_start_in_layer_x + end_edge_end_in_layer_x) / 4, - (start_edge_top_in_layer_y + start_edge_bottom_in_layer_y + - end_edge_top_in_layer_y + end_edge_bottom_in_layer_y) / + (start_edge_start_in_layer_y + start_edge_end_in_layer_y + + end_edge_start_in_layer_y + end_edge_end_in_layer_y) / 4 + 3); } @@ -6222,9 +6224,9 @@ ->id(), selection.start.layer_id); - EXPECT_EQ(start_edge_top_in_layer_x, selection.start.edge_top.x()); - EXPECT_EQ(start_edge_top_in_layer_y, selection.start.edge_top.y()); - EXPECT_EQ(start_edge_bottom_in_layer_x, selection.start.edge_bottom.x()); + EXPECT_EQ(start_edge_start_in_layer_x, selection.start.edge_start.x()); + EXPECT_EQ(start_edge_start_in_layer_y, selection.start.edge_start.y()); + EXPECT_EQ(start_edge_end_in_layer_x, selection.start.edge_end.x()); blink::Node* layer_owner_node_for_end = V8Node::ToImplWithTypeCheck( v8::Isolate::GetCurrent(), @@ -6235,9 +6237,9 @@ GetExpectedLayerForSelection(layer_owner_node_for_end)->CcLayer()->id(), selection.end.layer_id); - EXPECT_EQ(end_edge_top_in_layer_x, selection.end.edge_top.x()); - EXPECT_EQ(end_edge_top_in_layer_y, selection.end.edge_top.y()); - EXPECT_EQ(end_edge_bottom_in_layer_x, selection.end.edge_bottom.x()); + EXPECT_EQ(end_edge_start_in_layer_x, selection.end.edge_start.x()); + EXPECT_EQ(end_edge_start_in_layer_y, selection.end.edge_start.y()); + EXPECT_EQ(end_edge_end_in_layer_x, selection.end.edge_end.x()); // Platform differences can introduce small stylistic deviations in // y-axis positioning, the details of which aren't relevant to @@ -6252,10 +6254,10 @@ } int y_bottom_deviation = - start_edge_bottom_in_layer_y - selection.start.edge_bottom.y(); + start_edge_end_in_layer_y - selection.start.edge_end.y(); EXPECT_GE(y_bottom_epsilon, std::abs(y_bottom_deviation)); EXPECT_EQ(y_bottom_deviation, - end_edge_bottom_in_layer_y - selection.end.edge_bottom.y()); + end_edge_end_in_layer_y - selection.end.edge_end.y()); if (expected_result.Length() >= 15) { bool start_hidden = expected_result.Get(context, 13) @@ -12762,7 +12764,11 @@ // Ensure a synthetic impl-side scroll offset propagates to the scrollable // area using the DidScroll callback. EXPECT_EQ(ScrollOffset(), scrollable_area->GetScrollOffset()); - cc_scroll_layer->SetScrollOffsetFromImplSide(gfx::ScrollOffset(0, 1)); + cc::ScrollAndScaleSet scroll_and_scale_set; + scroll_and_scale_set.scrolls.push_back( + {scrollable_area->GetCompositorElementId(), gfx::ScrollOffset(0, 1)}); + cc_scroll_layer->layer_tree_host()->ApplyScrollAndScale( + &scroll_and_scale_set); UpdateAllLifecyclePhases(web_view); EXPECT_EQ(ScrollOffset(0, 1), scrollable_area->GetScrollOffset());
diff --git a/third_party/blink/renderer/core/exported/web_layer_test.cc b/third_party/blink/renderer/core/exported/web_layer_test.cc index 109bed9..e4e461db 100644 --- a/third_party/blink/renderer/core/exported/web_layer_test.cc +++ b/third_party/blink/renderer/core/exported/web_layer_test.cc
@@ -5,6 +5,8 @@ #include "build/build_config.h" #include "cc/layers/picture_layer.h" #include "cc/trees/effect_node.h" +#include "cc/trees/layer_tree_host.h" +#include "cc/trees/scroll_and_scale_set.h" #include "cc/trees/transform_node.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/web/web_script_source.h" @@ -156,7 +158,11 @@ // Ensure a synthetic impl-side scroll offset propagates to the scrollable // area using the DidScroll callback. EXPECT_EQ(ScrollOffset(), scrollable_area->GetScrollOffset()); - overflow_scroll_layer->SetScrollOffsetFromImplSide(gfx::ScrollOffset(0, 1)); + cc::ScrollAndScaleSet scroll_and_scale_set; + scroll_and_scale_set.scrolls.push_back( + {scrollable_area->GetCompositorElementId(), gfx::ScrollOffset(0, 1)}); + overflow_scroll_layer->layer_tree_host()->ApplyScrollAndScale( + &scroll_and_scale_set); UpdateAllLifecyclePhases(); EXPECT_EQ(ScrollOffset(0, 1), scrollable_area->GetScrollOffset()); @@ -223,7 +229,10 @@ // Ensure a synthetic impl-side scroll offset propagates to the scrollable // area using the DidScroll callback. EXPECT_EQ(ScrollOffset(), scrollable_area->GetScrollOffset()); - scroll_layer->SetScrollOffsetFromImplSide(gfx::ScrollOffset(0, 1)); + cc::ScrollAndScaleSet scroll_and_scale_set; + scroll_and_scale_set.scrolls.push_back( + {scrollable_area->GetCompositorElementId(), gfx::ScrollOffset(0, 1)}); + scroll_layer->layer_tree_host()->ApplyScrollAndScale(&scroll_and_scale_set); UpdateAllLifecyclePhases(); EXPECT_EQ(ScrollOffset(0, 1), scrollable_area->GetScrollOffset()); }
diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc index d7005d1..3e4c4db 100644 --- a/third_party/blink/renderer/core/frame/local_frame_view.cc +++ b/third_party/blink/renderer/core/frame/local_frame_view.cc
@@ -2746,12 +2746,8 @@ return; if (!paint_artifact_compositor_) { - paint_artifact_compositor_ = - std::make_unique<PaintArtifactCompositor>(WTF::BindRepeating( - &ScrollingCoordinator::DidScroll, - // The layer being scrolled is destroyed before the - // ScrollingCoordinator. - WrapWeakPersistent(page->GetScrollingCoordinator()))); + paint_artifact_compositor_ = std::make_unique<PaintArtifactCompositor>( + page->GetScrollingCoordinator()->GetWeakPtr()); page->GetChromeClient().AttachRootLayer( paint_artifact_compositor_->RootLayer(), &GetFrame()); }
diff --git a/third_party/blink/renderer/core/frame/visual_viewport.cc b/third_party/blink/renderer/core/frame/visual_viewport.cc index 1f190f43..594504a 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport.cc +++ b/third_party/blink/renderer/core/frame/visual_viewport.cc
@@ -1056,10 +1056,6 @@ return GetPage().GetScrollbarTheme(); } -void VisualViewport::DidChangeScrollbarsHiddenIfOverlay(bool hidden) { - ScrollableArea::SetScrollbarsHiddenIfOverlay(hidden); -} - PaintArtifactCompositor* VisualViewport::GetPaintArtifactCompositor() const { if (MainFrame() && MainFrame()->View()) return MainFrame()->View()->GetPaintArtifactCompositor();
diff --git a/third_party/blink/renderer/core/frame/visual_viewport.h b/third_party/blink/renderer/core/frame/visual_viewport.h index 3e072ee..8d3dd04 100644 --- a/third_party/blink/renderer/core/frame/visual_viewport.h +++ b/third_party/blink/renderer/core/frame/visual_viewport.h
@@ -279,7 +279,6 @@ void EnqueueResizeEvent(); // cc::LayerClient implementation. - void DidChangeScrollbarsHiddenIfOverlay(bool) override; std::string LayerDebugName(const cc::Layer* layer) const override; std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( const cc::Layer* layer) override;
diff --git a/third_party/blink/renderer/core/html/forms/resources/time_picker.css b/third_party/blink/renderer/core/html/forms/resources/time_picker.css index 5e27f93..6c331c5 100644 --- a/third_party/blink/renderer/core/html/forms/resources/time_picker.css +++ b/third_party/blink/renderer/core/html/forms/resources/time_picker.css
@@ -103,6 +103,7 @@ background-color: Window; color: WindowText; forced-color-adjust: none; + scroll-margin: 0px; } .time-cell:hover {
diff --git a/third_party/blink/renderer/core/html/forms/resources/time_picker.js b/third_party/blink/renderer/core/html/forms/resources/time_picker.js index fafb8a5..8959e6b 100644 --- a/third_party/blink/renderer/core/html/forms/resources/time_picker.js +++ b/third_party/blink/renderer/core/html/forms/resources/time_picker.js
@@ -256,6 +256,8 @@ }; onWindowResize_ = (event) => { + // Scroll columns to the second half to allow scrolling up. + this.timeColumns_.scrollColumnsToMiddle(); this.timeColumns_.firstChild.focus(); }; @@ -376,6 +378,18 @@ } return new Time(hour, minute, second, millisecond); }; + + scrollColumnsToMiddle = () => { + this.hourColumn_.scrollTop = this.hourColumn_.scrollHeight / 2; + this.minuteColumn_.scrollTop = this.minuteColumn_.scrollHeight / 2; + if (this.secondColumn_) { + this.secondColumn_.scrollTop = this.secondColumn_.scrollHeight / 2; + } + if (this.millisecondColumn_) { + this.millisecondColumn_.scrollTop = + this.millisecondColumn_.scrollHeight / 2; + } + } } TimeColumns.ClassName = 'time-columns'; TimeColumns.Margin = 1; @@ -417,7 +431,7 @@ duplicateCells.push(duplicatedTimeCell); currentTime.next(this.columnType_); } - this.selectedTimeCell = cells[0]; + this.selectedTimeCell = duplicateCells[0]; this.middleTimeCell_ = duplicateCells[0]; this.append(...cells, ...duplicateCells); };
diff --git a/third_party/blink/renderer/core/layout/layout_inline.cc b/third_party/blink/renderer/core/layout/layout_inline.cc index bd469763..e011e82 100644 --- a/third_party/blink/renderer/core/layout/layout_inline.cc +++ b/third_party/blink/renderer/core/layout/layout_inline.cc
@@ -1379,9 +1379,11 @@ // fragment in that case. We'll do the same here (but correctly with respect // to writing-mode - Gecko has some issues there). // See crbug.com/641907 - if (const NGPaintFragment* fragment = FirstInlineFragment()) { - return PhysicalRect(fragment->InlineOffsetToContainerBox(), - fragment->Size()); + if (IsInLayoutNGInlineFormattingContext()) { + NGInlineCursor cursor; + cursor.MoveTo(*this); + if (cursor) + return cursor.CurrentRect(); } if (const InlineFlowBox* flow_box = FirstLineBox()) return FlipForWritingMode(flow_box->FrameRect());
diff --git a/third_party/blink/renderer/core/layout/layout_text.cc b/third_party/blink/renderer/core/layout/layout_text.cc index bab767fa..8f7bc62 100644 --- a/third_party/blink/renderer/core/layout/layout_text.cc +++ b/third_party/blink/renderer/core/layout/layout_text.cc
@@ -562,21 +562,19 @@ // Find fragments that have text for the specified range. DCHECK_LE(start, end); - auto fragments = NGPaintFragment::InlineFragmentsFor(this); const LayoutBlock* block_for_flipping = nullptr; if (UNLIKELY(HasFlippedBlocksWritingMode())) block_for_flipping = ContainingBlock(); - for (const NGPaintFragment* fragment : fragments) { - const auto& text_fragment = - To<NGPhysicalTextFragment>(fragment->PhysicalFragment()); - if (start > text_fragment.EndOffset() || - end < text_fragment.StartOffset()) + NGInlineCursor cursor; + for (cursor.MoveTo(*this); cursor; cursor.MoveToNextForSameLayoutObject()) { + const unsigned start_offset = cursor.CurrentTextStartOffset(); + const unsigned end_offset = cursor.CurrentTextEndOffset(); + if (start > end_offset || end < start_offset) continue; - const unsigned clamped_start = - std::max(start, text_fragment.StartOffset()); - const unsigned clamped_end = std::min(end, text_fragment.EndOffset()); - PhysicalRect rect = text_fragment.LocalRect(clamped_start, clamped_end); - rect.Move(fragment->InlineOffsetToContainerBox()); + const unsigned clamped_start = std::max(start, start_offset); + const unsigned clamped_end = std::min(end, end_offset); + PhysicalRect rect = cursor.CurrentLocalRect(clamped_start, clamped_end); + rect.Move(cursor.CurrentOffset()); const FloatQuad quad = LocalRectToAbsoluteQuad(rect); if (clamped_start < clamped_end) { quads.push_back(quad);
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.cc b/third_party/blink/renderer/core/layout/layout_text_control.cc index 6cabfb1..966bfa8 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.cc +++ b/third_party/blink/renderer/core/layout/layout_text_control.cc
@@ -70,22 +70,6 @@ } } -int LayoutTextControl::TextBlockLogicalHeight() const { - return (LogicalHeight() - BorderAndPaddingLogicalHeight()).ToInt(); -} - -int LayoutTextControl::TextBlockLogicalWidth() const { - Element* inner_editor = InnerEditorElement(); - DCHECK(inner_editor); - - LayoutUnit unit_width = LogicalWidth() - BorderAndPaddingLogicalWidth(); - if (inner_editor->GetLayoutObject()) - unit_width -= inner_editor->GetLayoutBox()->PaddingStart() + - inner_editor->GetLayoutBox()->PaddingEnd(); - - return unit_width.ToInt(); -} - int LayoutTextControl::ScrollbarThickness() const { // FIXME: We should get the size of the scrollbar from the LayoutTheme // instead. @@ -224,14 +208,6 @@ return font.Width(text_run); } -float LayoutTextControl::ScaleEmToUnits(int x) const { - // This matches the unitsPerEm value for MS Shell Dlg and Courier New from the - // "head" font table. - float units_per_em = 2048.0f; - return roundf(StyleRef().GetFont().GetFontDescription().ComputedSize() * x / - units_per_em); -} - void LayoutTextControl::ComputeIntrinsicLogicalWidths( LayoutUnit& min_logical_width, LayoutUnit& max_logical_width) const {
diff --git a/third_party/blink/renderer/core/layout/layout_text_control.h b/third_party/blink/renderer/core/layout/layout_text_control.h index 643c76a3..4c6b2bfb 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control.h +++ b/third_party/blink/renderer/core/layout/layout_text_control.h
@@ -60,14 +60,9 @@ const HitTestLocation&, const PhysicalOffset& accumulated_offset); - int TextBlockLogicalWidth() const; - int TextBlockLogicalHeight() const; - - float ScaleEmToUnits(int x) const; - static bool HasValidAvgCharWidth(const SimpleFontData*, const AtomicString& family); - virtual float GetAvgCharWidth(const AtomicString& family) const; + float GetAvgCharWidth(const AtomicString& family) const; virtual LayoutUnit PreferredContentLogicalWidth(float char_width) const = 0; virtual LayoutUnit ComputeControlLogicalHeight( LayoutUnit line_height,
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc index ef3a634..389150d1 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc +++ b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.cc
@@ -56,18 +56,6 @@ return true; } -float LayoutTextControlMultiLine::GetAvgCharWidth( - const AtomicString& family) const { - // Match the default system font to the width of MS Shell Dlg, the default - // font for textareas in Firefox, Safari Win and IE for some encodings (in - // IE, the default font is encoding specific). 1229 is the avgCharWidth - // value in the OS/2 table for Courier New. - if (LayoutTheme::GetTheme().NeedsHackForTextControlWithFontFamily(family)) - return ScaleEmToUnits(1229); - - return LayoutTextControl::GetAvgCharWidth(family); -} - LayoutUnit LayoutTextControlMultiLine::PreferredContentLogicalWidth( float char_width) const { int factor = ToHTMLTextAreaElement(GetNode())->cols();
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h index 67401f8..54fe62b 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h +++ b/third_party/blink/renderer/core/layout/layout_text_control_multi_line.h
@@ -44,7 +44,6 @@ const PhysicalOffset& accumulated_offset, HitTestAction) override; - float GetAvgCharWidth(const AtomicString& family) const override; LayoutUnit PreferredContentLogicalWidth(float char_width) const override; LayoutUnit ComputeControlLogicalHeight( LayoutUnit line_height,
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc b/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc index 8969f7c..a13e4ac 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc +++ b/third_party/blink/renderer/core/layout/layout_text_control_single_line.cc
@@ -208,18 +208,6 @@ return clip_rect; } -float LayoutTextControlSingleLine::GetAvgCharWidth( - const AtomicString& family) const { - // Match the default system font to the width of MS Shell Dlg, the default - // font for textareas in Firefox, Safari Win and IE for some encodings (in - // IE, the default font is encoding specific). 901 is the avgCharWidth value - // in the OS/2 table for MS Shell Dlg. - if (LayoutTheme::GetTheme().NeedsHackForTextControlWithFontFamily(family)) - return ScaleEmToUnits(901); - - return LayoutTextControl::GetAvgCharWidth(family); -} - LayoutUnit LayoutTextControlSingleLine::PreferredContentLogicalWidth( float char_width) const { int factor; @@ -233,13 +221,7 @@ float max_char_width = 0.f; const Font& font = StyleRef().GetFont(); AtomicString family = font.GetFontDescription().Family().Family(); - // Match the default system font to the width of MS Shell Dlg, the default - // font for textareas in Firefox, Safari Win and IE for some encodings (in - // IE, the default font is encoding specific). 4027 is the (xMax - xMin) - // value in the "head" font table for MS Shell Dlg. - if (LayoutTheme::GetTheme().NeedsHackForTextControlWithFontFamily(family)) - max_char_width = ScaleEmToUnits(4027); - else if (HasValidAvgCharWidth(font.PrimaryFont(), family)) + if (HasValidAvgCharWidth(font.PrimaryFont(), family)) max_char_width = roundf(font.PrimaryFont()->MaxCharWidth()); // For text inputs, IE adds some extra width.
diff --git a/third_party/blink/renderer/core/layout/layout_text_control_single_line.h b/third_party/blink/renderer/core/layout/layout_text_control_single_line.h index e13d7dc8..a49de23 100644 --- a/third_party/blink/renderer/core/layout/layout_text_control_single_line.h +++ b/third_party/blink/renderer/core/layout/layout_text_control_single_line.h
@@ -68,7 +68,6 @@ LayoutUnit ScrollHeight() const final; int TextBlockWidth() const; - float GetAvgCharWidth(const AtomicString& family) const final; LayoutUnit PreferredContentLogicalWidth(float char_width) const final; LayoutUnit ComputeControlLogicalHeight( LayoutUnit line_height,
diff --git a/third_party/blink/renderer/core/layout/layout_theme.h b/third_party/blink/renderer/core/layout/layout_theme.h index bd180253..0c92b958 100644 --- a/third_party/blink/renderer/core/layout/layout_theme.h +++ b/third_party/blink/renderer/core/layout/layout_theme.h
@@ -200,13 +200,6 @@ void SystemFont(CSSValueID system_font_id, FontDescription&); virtual Color SystemColor(CSSValueID, WebColorScheme color_scheme) const; - // Whether the default system font should have its average character width - // adjusted to match MS Shell Dlg. - virtual bool NeedsHackForTextControlWithFontFamily( - const AtomicString&) const { - return false; - } - virtual int MinimumMenuListSize(const ComputedStyle&) const { return 0; } virtual void AdjustSliderThumbSize(ComputedStyle&) const;
diff --git a/third_party/blink/renderer/core/layout/ng/layout_ng_block_flow_mixin.cc b/third_party/blink/renderer/core/layout/ng/layout_ng_block_flow_mixin.cc index d316b4c..de111c9 100644 --- a/third_party/blink/renderer/core/layout/ng/layout_ng_block_flow_mixin.cc +++ b/third_party/blink/renderer/core/layout/ng/layout_ng_block_flow_mixin.cc
@@ -205,6 +205,9 @@ if (PaintFragment()) return false; + if (Base::StyleRef().HasColumnRule()) + return false; + return Base::PaintedOutputOfObjectHasNoEffectRegardlessOfSize(); } @@ -283,12 +286,6 @@ } } - // |NGBoxFragmentPainter| currently doesn't support column rules. - if (UNLIKELY(Base::MultiColumnFlowThread())) { - Base::Paint(paint_info); - return; - } - if (const NGPaintFragment* paint_fragment = PaintFragment()) { NGBoxFragmentPainter(*paint_fragment).Paint(paint_info); return;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc index bd5750f..8340f28 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.cc
@@ -181,6 +181,7 @@ is_resuming_(IsResumingLayout(params.break_token)), exclusion_space_(params.space.ExclusionSpace()), early_break_(params.early_break) { + AdjustForFragmentation(BreakToken(), &border_scrollbar_padding_); container_builder_.SetIsNewFormattingContext( params.space.IsNewFormattingContext()); container_builder_.SetInitialFragmentGeometry(params.fragment_geometry); @@ -462,10 +463,7 @@ container_builder_.SetAdjoiningObjectTypes(adjoining_object_types); } - // If we are resuming from a break token our start border and padding is - // within a previous fragment. - LayoutUnit content_edge = - is_resuming_ ? LayoutUnit() : border_scrollbar_padding_.block_start; + LayoutUnit content_edge = border_scrollbar_padding_.block_start; NGPreviousInflowPosition previous_inflow_position = { LayoutUnit(), ConstraintSpace().MarginStrut(), @@ -1327,7 +1325,7 @@ NGConstraintSpace child_space = CreateConstraintSpaceForChild( child, child_data, {child_available_inline_size, child_available_size_.block_size}, - /* is_new_fc */ true); + /* is_new_fc */ true, opportunity.rect.start_offset.block_offset); // All formatting context roots (like this child) should start with an empty // exclusion space. @@ -2308,7 +2306,7 @@ const NGInflowChildData& child_data, const LogicalSize child_available_size, bool is_new_fc, - const base::Optional<LayoutUnit> forced_bfc_block_offset, + const base::Optional<LayoutUnit> child_bfc_block_offset, bool has_clearance_past_adjoining_floats) { const ComputedStyle& style = Style(); const ComputedStyle& child_style = child.Style(); @@ -2349,8 +2347,8 @@ // children. if (!has_bfc_block_offset && ConstraintSpace().ForcedBfcBlockOffset()) builder.SetForcedBfcBlockOffset(*ConstraintSpace().ForcedBfcBlockOffset()); - if (forced_bfc_block_offset) - builder.SetForcedBfcBlockOffset(*forced_bfc_block_offset); + if (child_bfc_block_offset && !is_new_fc) + builder.SetForcedBfcBlockOffset(*child_bfc_block_offset); if (has_bfc_block_offset && child.IsBlock()) { // Typically we aren't allowed to look at the previous layout result within @@ -2426,13 +2424,13 @@ } if (ConstraintSpace().HasBlockFragmentation()) { - LayoutUnit new_bfc_block_offset; + LayoutUnit fragmentainer_offset_delta; // If a block establishes a new formatting context, we must know our // position in the formatting context, to be able to adjust the // fragmentation line. if (is_new_fc) - new_bfc_block_offset = child_data.bfc_offset_estimate.block_offset; - SetupFragmentation(ConstraintSpace(), new_bfc_block_offset, &builder, + fragmentainer_offset_delta = *child_bfc_block_offset; + SetupFragmentation(ConstraintSpace(), fragmentainer_offset_delta, &builder, is_new_fc); builder.SetEarlyBreakAppeal(container_builder_.BreakAppeal()); }
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h index 8960f5b..aa57a475a 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h +++ b/third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm.h
@@ -113,7 +113,7 @@ const NGInflowChildData& child_data, const LogicalSize child_available_size, bool is_new_fc, - const base::Optional<LayoutUnit> forced_bfc_block_offset = base::nullopt, + const base::Optional<LayoutUnit> bfc_block_offset = base::nullopt, bool has_clearance_past_adjoining_floats = false); // @return Estimated BFC block offset for the "to be layout" child. @@ -337,7 +337,12 @@ // Returns kIndefiniteSize in all other cases. LayoutUnit CalculateMinimumBlockSize(const NGMarginStrut& end_margin_strut); + // Border + padding sum, resolved from the node's computed style. const NGBoxStrut border_padding_; + + // Border + scrollbar + padding sum for the fragment to be generated (most + // importantly, for non-first fragments, leading block border + scrollbar + + // padding is zero). NGBoxStrut border_scrollbar_padding_; LogicalSize child_available_size_;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc index f0a75462..d573ed0 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.cc
@@ -439,6 +439,11 @@ if (!cached_layout_result) return nullptr; + // The containing-block may have borders/scrollbars which might change + // between passes affecting the final position. + if (!cached_layout_result->CanUseOutOfFlowPositionedFirstTierCache()) + return nullptr; + // TODO(layout-dev): There are potentially more cases where we can reuse this // layout result. // E.g. when we have a fixed-length top position constraint (top: 5px), we @@ -841,6 +846,7 @@ } LayoutBlock* block = DynamicTo<LayoutBlock>(box_); + bool needs_full_invalidation = false; if (LIKELY(block && is_last_fragment)) { LayoutUnit intrinsic_block_size = layout_result.UnconstrainedIntrinsicBlockSize(); @@ -854,6 +860,11 @@ if (UNLIKELY(flow_thread)) { UpdateLegacyMultiColumnFlowThread(*this, flow_thread, constraint_space, physical_fragment); + + // Issue full invalidation, in case the number of column rules have + // changed. + if (Style().HasColumnRule()) + needs_full_invalidation = true; } BoxLayoutExtraInput input(*block); @@ -867,7 +878,11 @@ } box_->UpdateAfterLayout(); - box_->ClearNeedsLayout(); + + if (needs_full_invalidation) + box_->ClearNeedsLayoutWithFullPaintInvalidation(); + else + box_->ClearNeedsLayout(); // Overflow computation depends on this being set. if (LIKELY(block_flow))
diff --git a/third_party/blink/renderer/core/layout/ng/ng_block_node.h b/third_party/blink/renderer/core/layout/ng/ng_block_node.h index e08df07..d47760f 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_block_node.h +++ b/third_party/blink/renderer/core/layout/ng/ng_block_node.h
@@ -53,7 +53,11 @@ // // As OOF-positioned objects have their position, and size computed // pre-layout, we need a way to quickly determine if we need to perform this - // work. This method compares the containing-block size to determine this. + // work. + // + // We have this "first-tier" cache explicitly for this purpose. + // This method compares the containing-block size to determine if we can skip + // the position, and size calculation. // // If the containing-block size hasn't changed, and we are layout-clean we // can reuse the previous layout result.
diff --git a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc index c543aab..bbb0887 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.cc
@@ -95,6 +95,7 @@ params.fragment_geometry.padding), border_scrollbar_padding_(border_padding_ + params.fragment_geometry.scrollbar) { + AdjustForFragmentation(BreakToken(), &border_scrollbar_padding_); container_builder_.SetIsNewFormattingContext( params.space.IsNewFormattingContext()); container_builder_.SetInitialFragmentGeometry(params.fragment_geometry); @@ -135,9 +136,7 @@ container_builder_.SetIsBlockFragmentationContextRoot(); - // Omit leading border+padding+scrollbar for all fragments but the first. - if (!IsResumingLayout(BreakToken())) - intrinsic_block_size_ = border_scrollbar_padding_.block_start; + intrinsic_block_size_ = border_scrollbar_padding_.block_start; if (!LayoutChildren()) { // We need to discard this layout and do it again. We found an earlier break @@ -376,8 +375,8 @@ // fragmentation context. if (is_constrained_by_outer_fragmentation_context_ && column_size.block_size != kIndefiniteSize) { - column_size.block_size -= ConsumedBlockSizeInContentBox( - border_scrollbar_padding_.block_start, BreakToken()); + if (BreakToken()) + column_size.block_size -= BreakToken()->ConsumedBlockSize(); // Subtract the space already taken in the current fragment (spanners and // earlier column rows). @@ -858,14 +857,6 @@ return size - extra; } -LayoutUnit NGColumnLayoutAlgorithm::CurrentContentBlockOffset() const { - // If we're past the block-start border and padding, this is simple: - if (IsResumingLayout(BreakToken())) - return intrinsic_block_size_; - // Otherwise subtract those. - return intrinsic_block_size_ - border_scrollbar_padding_.block_start; -} - void NGColumnLayoutAlgorithm::FinishAfterBreakBeforeSpanner( scoped_refptr<const NGBlockBreakToken> next_column_token) { // We broke before the spanner. We're done here. Take up the remaining space
diff --git a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.h b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.h index 42b5e9d8..b910801 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.h +++ b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm.h
@@ -62,7 +62,9 @@ LayoutUnit current_column_size) const; LayoutUnit ConstrainColumnBlockSize(LayoutUnit size) const; - LayoutUnit CurrentContentBlockOffset() const; + LayoutUnit CurrentContentBlockOffset() const { + return intrinsic_block_size_ - border_scrollbar_padding_.block_start; + } // Finalize layout after breaking before a spanner. void FinishAfterBreakBeforeSpanner( @@ -87,8 +89,14 @@ // When set, this will specify where to break before or inside. const NGEarlyBreak* early_break_ = nullptr; + // Border + padding sum, resolved from the node's computed style. const NGBoxStrut border_padding_; - const NGBoxStrut border_scrollbar_padding_; + + // Border + scrollbar + padding sum for the fragment to be generated (most + // importantly, for non-first fragments, leading block border + scrollbar + + // padding is zero). + NGBoxStrut border_scrollbar_padding_; + LogicalSize content_box_size_; int used_column_count_; LayoutUnit column_inline_size_;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm_test.cc b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm_test.cc index e9c066b..51da712 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm_test.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_column_layout_algorithm_test.cc
@@ -2431,6 +2431,132 @@ EXPECT_EQ(expectation, dump); } +TEST_F(NGColumnLayoutAlgorithmTest, NewFcAtColumnBoundary) { + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="width:22px; height:100px;"></div> + <div style="display:flow-root; width:33px; height:50px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:22x100 + offset:110,0 size:100x50 + offset:0,0 size:33x50 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, NewFcWithMargin) { + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="width:22px; height:50px;"></div> + <div style="display:flow-root; margin-top:30px; width:33px; height:50px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:22x50 + offset:0,80 size:33x20 + offset:110,0 size:100x30 + offset:0,0 size:33x30 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, NewFcBelowFloat) { + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="float:left; width:22px; height:50px;"></div> + <div style="display:flow-root; margin-top:40px; width:88px; height:70px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:22x50 + offset:0,50 size:88x50 + offset:110,0 size:100x20 + offset:0,0 size:88x20 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + +TEST_F(NGColumnLayoutAlgorithmTest, NewFcWithMarginPastColumnBoundary) { + SetBodyInnerHTML(R"HTML( + <style> + #parent { + columns: 3; + column-fill: auto; + column-gap: 10px; + width: 320px; + height: 100px; + } + </style> + <div id="container"> + <div id="parent"> + <div style="width:22px; height:80px;"></div> + <div style="display:flow-root; margin-top:30px; width:33px; height:50px;"></div> + </div> + </div> + )HTML"); + + String dump = DumpFragmentTree(GetElementById("container")); + String expectation = R"DUMP(.:: LayoutNG Physical Fragment Tree ::. + offset:unplaced size:1000x100 + offset:0,0 size:320x100 + offset:0,0 size:100x100 + offset:0,0 size:22x80 + offset:110,0 size:100x50 + offset:0,0 size:33x50 +)DUMP"; + EXPECT_EQ(expectation, dump); +} + TEST_F(NGColumnLayoutAlgorithmTest, MinMax) { // The multicol container here contains two inline-blocks with a line break // opportunity between them. We'll test what min/max values we get for the
diff --git a/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h b/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h index 1eb27c61..e791c91 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h +++ b/third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h
@@ -251,8 +251,8 @@ DCHECK(!is_forced_bfc_block_offset_set_); is_forced_bfc_block_offset_set_ = true; #endif - if (LIKELY(!is_new_fc_)) - space_.EnsureRareData()->SetForcedBfcBlockOffset(forced_bfc_block_offset); + DCHECK(!is_new_fc_); + space_.EnsureRareData()->SetForcedBfcBlockOffset(forced_bfc_block_offset); } void SetClearanceOffset(LayoutUnit clearance_offset) {
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc index cd77c684..eb867db 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.cc
@@ -164,14 +164,14 @@ } void SetupFragmentation(const NGConstraintSpace& parent_space, - LayoutUnit new_bfc_block_offset, + LayoutUnit fragmentainer_offset_delta, NGConstraintSpaceBuilder* builder, bool is_new_fc) { DCHECK(parent_space.HasBlockFragmentation()); builder->SetFragmentainerBlockSize(parent_space.FragmentainerBlockSize()); - new_bfc_block_offset += parent_space.FragmentainerOffsetAtBfc(); - builder->SetFragmentainerOffsetAtBfc(new_bfc_block_offset); + builder->SetFragmentainerOffsetAtBfc(parent_space.FragmentainerOffsetAtBfc() + + fragmentainer_offset_delta); builder->SetFragmentationType(parent_space.BlockFragmentationType()); if (parent_space.IsInColumnBfc() && !is_new_fc)
diff --git a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h index c8ac752..469ab70 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h +++ b/third_party/blink/renderer/core/layout/ng/ng_fragmentation_utils.h
@@ -5,6 +5,7 @@ #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_FRAGMENTATION_UTILS_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_NG_FRAGMENTATION_UTILS_H_ +#include "third_party/blink/renderer/core/layout/ng/geometry/ng_box_strut.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment_builder.h" @@ -72,14 +73,26 @@ return space.FragmentainerBlockSize() - space.FragmentainerOffsetAtBfc(); } +// Adjust the border+scrollbar+padding strut for fragmentation. Leading +// border+scrollbar+padding should only take up space in the first fragment +// generated from a node. +inline void AdjustForFragmentation(const NGBlockBreakToken* break_token, + NGBoxStrut* border_scrollbar_padding) { + if (LIKELY(!break_token)) + return; + if (break_token->IsBreakBefore()) + return; + border_scrollbar_padding->block_start = LayoutUnit(); +} + // Set up a child's constraint space builder for block fragmentation. The child // participates in the same fragmentation context as parent_space. If the child -// establishes a new formatting context, new_bfc_block_offset must be set to the -// offset from the parent block formatting context, or, if the parent formatting -// context starts in a previous fragmentainer; the offset from the current -// fragmentainer block-start. +// establishes a new formatting context, |fragmentainer_offset_delta| must be +// set to the offset from the parent block formatting context, or, if the parent +// formatting context starts in a previous fragmentainer; the offset from the +// current fragmentainer block-start. void SetupFragmentation(const NGConstraintSpace& parent_space, - LayoutUnit new_bfc_block_offset, + LayoutUnit fragmentainer_offset_delta, NGConstraintSpaceBuilder*, bool is_new_fc);
diff --git a/third_party/blink/renderer/core/layout/ng/ng_layout_result.h b/third_party/blink/renderer/core/layout/ng/ng_layout_result.h index 46123a06..77ff5c5 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_layout_result.h +++ b/third_party/blink/renderer/core/layout/ng/ng_layout_result.h
@@ -68,6 +68,12 @@ : oof_positioned_offset_; } + // Returns if we can use the first-tier OOF-positioned cache. + bool CanUseOutOfFlowPositionedFirstTierCache() const { + DCHECK(physical_fragment_->IsOutOfFlowPositioned()); + return bitfields_.can_use_out_of_flow_positioned_first_tier_cache; + } + const NGUnpositionedListMarker UnpositionedListMarker() const { return HasRareData() ? rare_data_->unpositioned_list_marker : NGUnpositionedListMarker(); @@ -243,13 +249,18 @@ protected: friend class NGOutOfFlowLayoutPart; - void SetOutOfFlowPositionedOffset(const LogicalOffset& offset) { + void SetOutOfFlowPositionedOffset( + const LogicalOffset& offset, + bool can_use_out_of_flow_positioned_first_tier_cache) { // OOF-positioned nodes *must* always have an initial BFC-offset. DCHECK(layout_result_->physical_fragment_->IsOutOfFlowPositioned()); DCHECK_EQ(layout_result_->BfcLineOffset(), LayoutUnit()); DCHECK_EQ(layout_result_->BfcBlockOffset().value_or(LayoutUnit()), LayoutUnit()); + layout_result_->bitfields_ + .can_use_out_of_flow_positioned_first_tier_cache = + can_use_out_of_flow_positioned_first_tier_cache; layout_result_->bitfields_.has_oof_positioned_offset = true; if (layout_result_->HasRareData()) layout_result_->rare_data_->oof_positioned_offset = offset; @@ -376,6 +387,7 @@ : has_rare_data(false), has_rare_data_exclusion_space(false), has_oof_positioned_offset(false), + can_use_out_of_flow_positioned_first_tier_cache(false), is_bfc_block_offset_nullopt(false), has_forced_break(false), is_self_collapsing(is_self_collapsing), @@ -392,6 +404,7 @@ unsigned has_rare_data : 1; unsigned has_rare_data_exclusion_space : 1; unsigned has_oof_positioned_offset : 1; + unsigned can_use_out_of_flow_positioned_first_tier_cache : 1; unsigned is_bfc_block_offset_nullopt : 1; unsigned has_forced_break : 1;
diff --git a/third_party/blink/renderer/core/layout/ng/ng_length_utils.cc b/third_party/blink/renderer/core/layout/ng/ng_length_utils.cc index 61c2719..330e366 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_length_utils.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_length_utils.cc
@@ -8,7 +8,6 @@ #include "base/optional.h" #include "third_party/blink/renderer/core/layout/layout_box.h" #include "third_party/blink/renderer/core/layout/layout_table_cell.h" -#include "third_party/blink/renderer/core/layout/ng/ng_block_break_token.h" #include "third_party/blink/renderer/core/layout/ng/ng_block_node.h" #include "third_party/blink/renderer/core/layout/ng/ng_constraint_space.h" #include "third_party/blink/renderer/core/layout/ng/ng_constraint_space_builder.h" @@ -1272,18 +1271,4 @@ return base::nullopt; } -LayoutUnit ConsumedBlockSizeInContentBox( - LayoutUnit border_scrollbar_padding_block_start, - const NGBlockBreakToken* break_token) { - if (!break_token) - return LayoutUnit(); - LayoutUnit consumed_block_size = - break_token->ConsumedBlockSize() - border_scrollbar_padding_block_start; - // There are no valid break points inside borders and padding, but if the - // fragmentainer is actually shorter than the space taken up bby borders - // and/or padding, we may end up slicing them into multiple fragmentainers - // anyway - in which case the size we just calculated becomes negative. - return consumed_block_size.ClampNegativeToZero(); -} - } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/ng_length_utils.h b/third_party/blink/renderer/core/layout/ng/ng_length_utils.h index dc99463..ac1106b 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_length_utils.h +++ b/third_party/blink/renderer/core/layout/ng/ng_length_utils.h
@@ -24,7 +24,6 @@ class Length; struct MinMaxSizeInput; class NGConstraintSpace; -class NGBlockBreakToken; class NGBlockNode; class NGLayoutInputNode; @@ -483,11 +482,6 @@ const NGBoxStrut& border_scrollbar_padding, NGMinMaxSizeType); -// Return the sum of the block-size of the content-boxes in all preceding -// fragments. -LayoutUnit ConsumedBlockSizeInContentBox( - LayoutUnit border_scrollbar_padding_block_start, - const NGBlockBreakToken*); } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc index b438bd7b..00f24ea8 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc +++ b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.cc
@@ -90,7 +90,8 @@ container_builder_(container_builder), writing_mode_(container_style.GetWritingMode()), is_absolute_container_(is_absolute_container), - is_fixed_container_(is_fixed_container) { + is_fixed_container_(is_fixed_container), + allow_first_tier_oof_cache_(border_scrollbar.IsEmpty()) { if (!container_builder->HasOutOfFlowPositionedCandidates() && !To<LayoutBlock>(container_builder_->GetLayoutObject()) ->HasPositionedObjects()) @@ -460,10 +461,13 @@ // Determine if we need to actually run the full OOF-positioned sizing, and // positioning algorithm. // - // When this candidate has an inline container, the container may move without - // setting |NeedsLayout()| to the candidate and that there are cases where the - // cache validity cannot be determined. - if (!candidate.inline_container) { + // The first-tier cache compares the given available-size. However we can't + // reuse the result if the |ContainingBlockInfo::container_offset| may change. + // This can occur when: + // - The default containing-block has borders and/or scrollbars. + // - The candidate has an inline container (instead of the default + // containing-block). + if (allow_first_tier_oof_cache_ && !candidate.inline_container) { LogicalSize container_content_size_in_candidate_writing_mode = container_physical_content_size.ConvertToLogical( candidate_writing_mode); @@ -732,7 +736,8 @@ offset.inline_offset = *y; } - layout_result->GetMutableForOutOfFlow().SetOutOfFlowPositionedOffset(offset); + layout_result->GetMutableForOutOfFlow().SetOutOfFlowPositionedOffset( + offset, allow_first_tier_oof_cache_); return layout_result; } @@ -740,8 +745,8 @@ const NGLogicalOutOfFlowPositionedNode& candidate) { EPosition position = candidate.node.Style().GetPosition(); - // Candidates whose containing block is inline are always positioned - // inside closest parent block flow. + // Candidates whose containing block is inline are always positioned inside + // closest parent block flow. if (candidate.inline_container) { DCHECK( candidate.node.Style().GetPosition() == EPosition::kAbsolute && @@ -765,15 +770,13 @@ const LogicalSize& container_content_size_in_candidate_writing_mode, const base::Optional<LayoutUnit>& block_estimate, const NGLogicalOutOfFlowPosition& node_position) { - // As the |block_estimate| is always in the node's writing mode, we - // build the constraint space in the node's writing mode. + // As the |block_estimate| is always in the node's writing mode, we build the + // constraint space in the node's writing mode. WritingMode writing_mode = node.Style().GetWritingMode(); LayoutUnit inline_size = node_position.size.inline_size; - LayoutUnit block_size = - block_estimate - ? *block_estimate - : container_content_size_in_candidate_writing_mode.block_size; + LayoutUnit block_size = block_estimate.value_or( + container_content_size_in_candidate_writing_mode.block_size); LogicalSize available_size(inline_size, block_size);
diff --git a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h index 0564516..e8d9ad81 100644 --- a/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h +++ b/third_party/blink/renderer/core/layout/ng/ng_out_of_flow_layout_part.h
@@ -131,6 +131,7 @@ const WritingMode writing_mode_; bool is_absolute_container_; bool is_fixed_container_; + bool allow_first_tier_oof_cache_; }; } // namespace blink
diff --git a/third_party/blink/renderer/core/layout/table_layout_algorithm_auto.cc b/third_party/blink/renderer/core/layout/table_layout_algorithm_auto.cc index 61f5ae6..11d8591 100644 --- a/third_party/blink/renderer/core/layout/table_layout_algorithm_auto.cc +++ b/third_party/blink/renderer/core/layout/table_layout_algorithm_auto.cc
@@ -25,6 +25,8 @@ #include "third_party/blink/renderer/core/layout/layout_table_cell.h" #include "third_party/blink/renderer/core/layout/layout_table_col.h" #include "third_party/blink/renderer/core/layout/layout_table_section.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_cell_interface.h" +#include "third_party/blink/renderer/core/layout/ng/table/layout_ng_table_interface.h" #include "third_party/blink/renderer/core/layout/text_autosizer.h" #include "third_party/blink/renderer/platform/geometry/calculation_value.h" @@ -244,7 +246,7 @@ } // FIXME: This needs to be adapted for vertical writing modes. -static bool ShouldScaleColumnsForSelf(LayoutTable* table) { +static bool ShouldScaleColumnsForSelf(LayoutNGTableInterface* table) { // Normally, scale all columns to satisfy this from CSS2.2: // "A percentage value for a column width is relative to the table width. // If the table has 'width: auto', a percentage represents a constraint on the @@ -253,11 +255,12 @@ // A special case. If this table is not fixed width and contained inside // a cell, then don't bloat the maxwidth by examining percentage growth. while (true) { - const Length& tw = table->StyleRef().Width(); + const LayoutObject* layout_table = table->ToLayoutObject(); + const Length& tw = layout_table->StyleRef().Width(); if ((!tw.IsAuto() && !tw.IsPercentOrCalc()) || - table->IsOutOfFlowPositioned()) + layout_table->IsOutOfFlowPositioned()) return true; - LayoutBlock* cb = table->ContainingBlock(); + LayoutBlock* cb = layout_table->ContainingBlock(); while (!cb->IsLayoutView() && !cb->IsTableCell() && cb->StyleRef().Width().IsAuto() && !cb->IsOutOfFlowPositioned()) @@ -268,9 +271,15 @@ !cb->StyleRef().Width().IsPercentOrCalc())) return true; - LayoutTableCell* cell = To<LayoutTableCell>(cb); - table = cell->Table(); - if (cell->ColSpan() > 1 || table->IsLogicalWidthAuto()) + LayoutNGTableCellInterface* cell = + ToInterface<LayoutNGTableCellInterface>(cb); + table = cell->TableInterface(); + const Length& table_logical_width = + table->ToLayoutObject()->StyleRef().LogicalWidth(); + bool width_is_auto = (!table_logical_width.IsSpecified() || + !table_logical_width.IsPositive()) && + !table_logical_width.IsIntrinsic(); + if (cell->ColSpan() > 1 || width_is_auto) return false; } NOTREACHED();
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc index ebef85a6..aafee28 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.cc
@@ -98,8 +98,8 @@ return nullptr; } -void ScrollingCoordinator::DidScroll(const gfx::ScrollOffset& offset, - const CompositorElementId& element_id) { +void ScrollingCoordinator::DidScroll(CompositorElementId element_id, + const gfx::ScrollOffset& offset) { // Find the associated scrollable area using the element id and notify it of // the compositor-side scroll. We explicitly do not check the VisualViewport // which handles scroll offset differently (see: VisualViewport::didScroll). @@ -112,6 +112,16 @@ } } +void ScrollingCoordinator::DidChangeScrollbarsHidden( + CompositorElementId element_id, + bool hidden) { + // See the above function for the case of null scrollable area. + if (auto* scrollable = + ScrollableAreaWithElementIdInAllLocalFrames(element_id)) { + scrollable->SetScrollbarsHiddenIfOverlay(hidden); + } +} + void ScrollingCoordinator::UpdateAfterPaint(LocalFrameView* frame_view) { LocalFrame* frame = &frame_view->GetFrame(); DCHECK(frame->IsLocalRoot()); @@ -419,9 +429,6 @@ // scale so it actually can be smaller than its clip. scroll_contents_size = scroll_contents_size.ExpandedTo(container_size); - cc_layer->set_did_scroll_callback(WTF::BindRepeating( - &ScrollingCoordinator::DidScroll, WrapWeakPersistent(this))); - // This call has to go through the GraphicsLayer method to preserve // invalidation code there. graphics_layer->SetSize(gfx::Size(scroll_contents_size));
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h index d716d2c..486b677 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator.h
@@ -29,8 +29,10 @@ #include <memory> #include "base/macros.h" +#include "base/memory/weak_ptr.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/scroll/scroll_types.h" +#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/heap/handle.h" @@ -58,10 +60,11 @@ // reasons, touch action regions, and non-fast-scrollable regions into the // compositor, as well as creating and managing scrollbar layers. class CORE_EXPORT ScrollingCoordinator final - : public GarbageCollected<ScrollingCoordinator> { + : public GarbageCollected<ScrollingCoordinator>, + public CompositorScrollCallbacks { public: explicit ScrollingCoordinator(Page*); - ~ScrollingCoordinator(); + ~ScrollingCoordinator() override; void Trace(blink::Visitor*); // The LocalFrameView argument is optional, nullptr causes the the scrolling @@ -137,8 +140,13 @@ ScrollableArea* ScrollableAreaWithElementIdInAllLocalFrames( const CompositorElementId&); - // Callback for compositor-side layer scrolls. - void DidScroll(const gfx::ScrollOffset&, const CompositorElementId&); + // ScrollCallbacks implementation + void DidScroll(CompositorElementId, const gfx::ScrollOffset&) override; + void DidChangeScrollbarsHidden(CompositorElementId, bool hidden) override; + + base::WeakPtr<ScrollingCoordinator> GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); + } // For testing purposes only. This ScrollingCoordinator is reused between // web tests, and must be reset for the results to be valid. @@ -173,6 +181,8 @@ ScrollbarMap horizontal_scrollbars_; ScrollbarMap vertical_scrollbars_; + base::WeakPtrFactory<ScrollingCoordinator> weak_ptr_factory_{this}; + DISALLOW_COPY_AND_ASSIGN(ScrollingCoordinator); };
diff --git a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc index 027e24e..b355c46 100644 --- a/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc +++ b/third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_test.cc
@@ -27,6 +27,7 @@ #include "build/build_config.h" #include "cc/layers/picture_layer.h" #include "cc/trees/property_tree.h" +#include "cc/trees/scroll_and_scale_set.h" #include "cc/trees/scroll_node.h" #include "cc/trees/sticky_position_constraint.h" #include "testing/gtest/include/gtest/gtest.h" @@ -1498,8 +1499,10 @@ // Simulate 100px of scroll coming from the compositor thread during a commit. gfx::ScrollOffset compositor_delta(0, 100.f); - cc_layer->SetNeedsCommit(); - cc_layer->SetScrollOffsetFromImplSide(compositor_delta); + cc::ScrollAndScaleSet scroll_and_scale_set; + scroll_and_scale_set.scrolls.push_back( + {scroller->GetCompositorElementId(), compositor_delta}); + cc_layer->layer_tree_host()->ApplyScrollAndScale(&scroll_and_scale_set); EXPECT_EQ(compositor_delta.y(), scroller->GetScrollOffset().Height()); EXPECT_EQ(compositor_delta, cc_layer->CurrentScrollOffset());
diff --git a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc index 7fa8fec..faf731c 100644 --- a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc +++ b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.cc
@@ -2406,11 +2406,6 @@ return GetLayoutObject().GetFrameView()->IsTrackingPaintInvalidations(); } -void CompositedLayerMapping::SetOverlayScrollbarsHidden(bool hidden) { - if (ScrollableArea* scrollable_area = owning_layer_.GetScrollableArea()) - scrollable_area->SetScrollbarsHiddenIfOverlay(hidden); -} - void CompositedLayerMapping::GraphicsLayersDidChange() { LocalFrameView* frame_view = GetLayoutObject().GetFrameView(); DCHECK(frame_view);
diff --git a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h index 40e89258..a1046b8 100644 --- a/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h +++ b/third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h
@@ -184,7 +184,6 @@ bool ShouldThrottleRendering() const override; bool IsUnderSVGHiddenContainer() const override; bool IsTrackingRasterInvalidations() const override; - void SetOverlayScrollbarsHidden(bool) override; void GraphicsLayersDidChange() override; bool PaintBlockedByDisplayLockIncludingAncestors( DisplayLockContextLifecycleTarget) const override;
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc index aa974c40..4a9c9ad 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.cc
@@ -383,6 +383,12 @@ (!physical_box_fragment.Children().empty() || physical_box_fragment.HasItems()) && !paint_info.DescendantPaintingBlocked()) { + if (RuntimeEnabledFeatures::LayoutNGFragmentPaintEnabled()) { + if (UNLIKELY(paint_phase == PaintPhase::kForeground && + box_fragment_.Style().HasColumnRule())) + PaintColumnRules(paint_info, paint_offset); + } + if (paint_phase != PaintPhase::kFloat) { if (physical_box_fragment.ChildrenInline()) { DCHECK(paint_fragment_ || PhysicalFragment().HasItems()); @@ -844,6 +850,106 @@ paint_info.context.EndLayer(); } +void NGBoxFragmentPainter::PaintColumnRules( + const PaintInfo& paint_info, + const PhysicalOffset& paint_offset) { + const ComputedStyle& style = box_fragment_.Style(); + DCHECK(style.HasColumnRule()); + + // TODO(crbug.com/792437): Certain rule styles should be converted. + EBorderStyle rule_style = style.ColumnRuleStyle(); + + if (DrawingRecorder::UseCachedDrawingIfPossible(paint_info.context, + GetDisplayItemClient(), + DisplayItem::kColumnRules)) + return; + + DrawingRecorder recorder(paint_info.context, GetDisplayItemClient(), + DisplayItem::kColumnRules); + + const Color& rule_color = + LayoutObject::ResolveColor(style, GetCSSPropertyColumnRuleColor()); + LayoutUnit rule_thickness(style.ColumnRuleWidth()); + PhysicalRect previous_column; + bool past_first_column_in_row = false; + for (const NGLink& child : box_fragment_.Children()) { + if (!child->IsColumnBox()) { + // Column spanner. Continue in the next row, if there are 2 columns or + // more there. + past_first_column_in_row = false; + previous_column = PhysicalRect(); + continue; + } + + PhysicalRect current_column(child.offset, child->Size()); + if (!past_first_column_in_row) { + // Rules are painted *between* columns. Need to see if we have a second + // one before painting anything. + past_first_column_in_row = true; + previous_column = current_column; + continue; + } + + PhysicalRect rule; + BoxSide box_side; + if (previous_column.Y() == current_column.Y() || + previous_column.Bottom() == current_column.Bottom()) { + // Horizontal writing-mode. + DCHECK(style.IsHorizontalWritingMode()); + LayoutUnit center; + if (previous_column.X() < current_column.X()) { + // Left to right. + center = (previous_column.X() + current_column.Right()) / 2; + box_side = BoxSide::kLeft; + } else { + // Right to left. + center = (current_column.X() + previous_column.Right()) / 2; + box_side = BoxSide::kRight; + } + // The last column may be shorter than the previous ones, but otherwise + // they should be the same. + LayoutUnit rule_length = previous_column.Height(); + DCHECK_GE(rule_length, current_column.Height()); + rule.offset.top = previous_column.offset.top; + rule.size.height = rule_length; + rule.offset.left = center - rule_thickness / 2; + rule.size.width = rule_thickness; + } else { + // Vertical writing-mode. + LayoutUnit center; + if (previous_column.Y() < current_column.Y()) { + // Top to bottom. + center = (previous_column.Y() + current_column.Bottom()) / 2; + box_side = BoxSide::kTop; + } else { + // Bottom to top. + center = (current_column.Y() + previous_column.Bottom()) / 2; + box_side = BoxSide::kBottom; + } + // The last column may be shorter than the previous ones, but otherwise + // they should be the same. + LayoutUnit rule_length = previous_column.Width(); + DCHECK_GE(rule_length, current_column.Width()); + rule.offset.left = previous_column.offset.left; + rule.size.width = rule_length; + rule.offset.top = center - rule_thickness / 2; + rule.size.height = rule_thickness; + } + + // TODO(crbug.com/792435): The spec actually kind of says that the rules + // should be as tall as the entire multicol container, not just as tall as + // the column fragments (this difference matters when block-size is + // specified and columns are balanced). + + rule.Move(paint_offset); + ObjectPainter::DrawLineForBoxSide(paint_info.context, rule.X(), rule.Y(), + rule.Right(), rule.Bottom(), box_side, + rule_color, rule_style, 0, 0, true); + + previous_column = current_column; + } +} + // TODO(kojii): This logic is kept in sync with BoxPainter. Not much efforts to // eliminate LayoutObject dependency were done yet. void NGBoxFragmentPainter::PaintBackground(
diff --git a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h index e51594c1..74aaadda 100644 --- a/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h +++ b/third_party/blink/renderer/core/paint/ng/ng_box_fragment_painter.h
@@ -79,6 +79,7 @@ void PaintBoxDecorationBackgroundWithRect(const PaintInfo&, const PhysicalRect&, const DisplayItemClient&); + void PaintColumnRules(const PaintInfo&, const PhysicalOffset& paint_offset); bool BackgroundIsKnownToBeOpaque(const PaintInfo&); void PaintInternal(const PaintInfo&);
diff --git a/third_party/blink/renderer/core/style/computed_style.h b/third_party/blink/renderer/core/style/computed_style.h index 12422ac..ce51b07 100644 --- a/third_party/blink/renderer/core/style/computed_style.h +++ b/third_party/blink/renderer/core/style/computed_style.h
@@ -1261,6 +1261,12 @@ !ColumnRuleColorInternal().Alpha(); } bool ColumnRuleEquivalent(const ComputedStyle& other_style) const; + bool HasColumnRule() const { + if (LIKELY(!SpecifiesColumns())) + return false; + return ColumnRuleWidth() && !ColumnRuleIsTransparent() && + BorderStyleIsVisible(ColumnRuleStyle()); + } // Flex utility functions. bool ResolvedIsColumnFlexDirection() const {
diff --git a/third_party/blink/renderer/modules/cache_storage/cache.cc b/third_party/blink/renderer/modules/cache_storage/cache.cc index 871f835..e4b240c 100644 --- a/third_party/blink/renderer/modules/cache_storage/cache.cc +++ b/third_party/blink/renderer/modules/cache_storage/cache.cc
@@ -88,6 +88,13 @@ if (!RuntimeEnabledFeatures::CacheStorageCodeCacheHintEnabled()) return CodeCachePolicy::kAuto; + // We should never see an opaque response here. We should have bailed out + // from generating code cache when we failed to determine its mime type. + // It's important we don't look at the header hint for opaque responses since + // it could leak cross-origin information. + DCHECK_NE(response->GetResponse()->GetType(), + network::mojom::FetchResponseType::kOpaque); + String header_name( features::kCacheStorageCodeCacheHintHeaderName.Get().data()); String header_value;
diff --git a/third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc b/third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc index d3f3d00..e913a5c 100644 --- a/third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc +++ b/third_party/blink/renderer/modules/peerconnection/media_stream_video_webrtc_sink.cc
@@ -267,7 +267,8 @@ video_track_->set_enabled(track.IsEnabled()); source_adapter_ = base::MakeRefCounted<WebRtcVideoSourceAdapter>( - factory->GetWebRtcWorkerThread(), video_source_.get(), refresh_interval, + factory->GetWebRtcWorkerTaskRunner(), video_source_.get(), + refresh_interval, base::Bind(&MediaStreamVideoWebRtcSink::RequestRefreshFrame, weak_factory_.GetWeakPtr()), std::move(task_runner));
diff --git a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc index aceb314..796ef3f3 100644 --- a/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc +++ b/third_party/blink/renderer/modules/peerconnection/peer_connection_dependency_factory.cc
@@ -602,7 +602,7 @@ } scoped_refptr<base::SingleThreadTaskRunner> -PeerConnectionDependencyFactory::GetWebRtcWorkerThread() const { +PeerConnectionDependencyFactory::GetWebRtcWorkerTaskRunner() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); return chrome_worker_thread_.IsRunning() ? chrome_worker_thread_.task_runner() : nullptr;
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_certificate_generator.cc b/third_party/blink/renderer/modules/peerconnection/rtc_certificate_generator.cc index 20248ad..f3c70b0 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_certificate_generator.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_certificate_generator.cc
@@ -94,7 +94,7 @@ scoped_refptr<RTCCertificateGeneratorRequest> request = base::MakeRefCounted<RTCCertificateGeneratorRequest>( - task_runner, pc_dependency_factory->GetWebRtcWorkerThread()); + task_runner, pc_dependency_factory->GetWebRtcWorkerTaskRunner()); request->GenerateCertificateAsync(key_params, expires_ms, std::move(completion_callback)); }
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_dtls_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_dtls_transport.cc index a75d9abf..1edb1af 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_dtls_transport.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_dtls_transport.cc
@@ -7,7 +7,7 @@ #include <memory> #include "third_party/blink/public/common/features.h" -#include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h" #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/events/event.h" @@ -57,7 +57,9 @@ scoped_refptr<base::SingleThreadTaskRunner> proxy_thread = frame->GetTaskRunner(TaskType::kNetworking); scoped_refptr<base::SingleThreadTaskRunner> host_thread = - Platform::Current()->GetWebRtcWorkerThread(); + PeerConnectionDependencyFactory::GetInstance() + ->GetWebRtcWorkerTaskRunner(); + return DtlsTransportProxy::Create(*frame, proxy_thread, host_thread, native_transport, delegate); }
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc index 5f33bcaa..8020cf1 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_ice_transport.cc
@@ -122,8 +122,11 @@ LocalFrame* frame = To<Document>(context)->GetFrame(); scoped_refptr<base::SingleThreadTaskRunner> proxy_thread = frame->GetTaskRunner(TaskType::kNetworking); + + PeerConnectionDependencyFactory::GetInstance()->EnsureInitialized(); scoped_refptr<base::SingleThreadTaskRunner> host_thread = - Platform::Current()->GetWebRtcWorkerThread(); + PeerConnectionDependencyFactory::GetInstance() + ->GetWebRtcWorkerTaskRunner(); return MakeGarbageCollected<RTCIceTransport>( context, std::move(proxy_thread), std::move(host_thread), std::make_unique<DefaultIceTransportAdapterCrossThreadFactory>()); @@ -136,8 +139,11 @@ LocalFrame* frame = To<Document>(context)->GetFrame(); scoped_refptr<base::SingleThreadTaskRunner> proxy_thread = frame->GetTaskRunner(TaskType::kNetworking); + + PeerConnectionDependencyFactory::GetInstance()->EnsureInitialized(); scoped_refptr<base::SingleThreadTaskRunner> host_thread = - Platform::Current()->GetWebRtcWorkerThread(); + PeerConnectionDependencyFactory::GetInstance() + ->GetWebRtcWorkerTaskRunner(); return MakeGarbageCollected<RTCIceTransport>( context, std::move(proxy_thread), std::move(host_thread), std::make_unique<DtlsIceTransportAdapterCrossThreadFactory>(
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc index b70044bc..1ef5079 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.cc
@@ -3120,9 +3120,10 @@ void RTCPeerConnection::ChangeIceConnectionState( webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state) { - if (ice_connection_state_ == - webrtc::PeerConnectionInterface::kIceConnectionClosed || - ice_connection_state_ == ice_connection_state) { + if (closed_) { + return; + } + if (ice_connection_state_ == ice_connection_state) { return; } ice_connection_state_ = ice_connection_state;
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_quic_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_quic_transport.cc index 1b15dde..0a68497 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_quic_transport.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_quic_transport.cc
@@ -7,6 +7,7 @@ #include "net/quic/platform/impl/quic_chromium_clock.h" #include "net/quic/quic_chromium_alarm_factory.h" #include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h" #include "third_party/blink/renderer/bindings/core/v8/script_promise_resolver.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/dom_high_res_time_stamp.h" @@ -90,7 +91,8 @@ ExceptionState& exception_state) { return Create(context, transport, certificates, exception_state, std::make_unique<DefaultP2PQuicTransportFactory>( - Platform::Current()->GetWebRtcWorkerThread())); + PeerConnectionDependencyFactory::GetInstance() + ->GetWebRtcWorkerTaskRunner())); } RTCQuicTransport* RTCQuicTransport::Create(
diff --git a/third_party/blink/renderer/modules/peerconnection/rtc_sctp_transport.cc b/third_party/blink/renderer/modules/peerconnection/rtc_sctp_transport.cc index 017b59c..38607e9a 100644 --- a/third_party/blink/renderer/modules/peerconnection/rtc_sctp_transport.cc +++ b/third_party/blink/renderer/modules/peerconnection/rtc_sctp_transport.cc
@@ -7,7 +7,7 @@ #include <limits> #include <memory> -#include "third_party/blink/public/platform/platform.h" +#include "third_party/blink/public/web/modules/peerconnection/peer_connection_dependency_factory.h" #include "third_party/blink/public/web/web_local_frame.h" #include "third_party/blink/renderer/core/dom/document.h" #include "third_party/blink/renderer/core/dom/events/event.h" @@ -70,7 +70,8 @@ native_transport, To<Document>(context)->GetFrame()->GetTaskRunner( TaskType::kNetworking), - Platform::Current()->GetWebRtcWorkerThread()) {} + PeerConnectionDependencyFactory::GetInstance() + ->GetWebRtcWorkerTaskRunner()) {} RTCSctpTransport::RTCSctpTransport( ExecutionContext* context,
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc index 38db3be..942ce6b 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc +++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.cc
@@ -607,11 +607,16 @@ mojo::PendingReceiver<mojom::blink::ControllerServiceWorker> receiver) { DCHECK(IsContextThread()); DCHECK(controller_receivers_.empty()); + // This receiver won't get any FetchEvents because it's used only for + // bootstrapping, and the actual clients connect over Clone() later. kNone is + // passed as COEP value as a placeholder. + // // TODO(falken): Consider adding task types for "the handle fetch task source" // and "handle functional event task source" defined in the service worker // spec and use them when dispatching events. controller_receivers_.Add( this, std::move(receiver), + network::mojom::blink::CrossOriginEmbedderPolicy::kNone, GetThread()->GetTaskRunner(TaskType::kInternalDefault)); } @@ -1429,6 +1434,9 @@ "ServiceWorkerGlobalScope::DispatchFetchEventForSubresource", "url", params->request->url.ElidedString().Utf8(), "queued", RequestedTermination() ? "true" : "false"); + // TODO(https://crbug.com/999049): Retrieve the COEP value from + // controller_receivers_.current_context() and respect it on the corresponding + // respondWith(). if (RequestedTermination()) { timeout_timer_->PushPendingTask( WTF::Bind(&ServiceWorkerGlobalScope::DispatchFetchEventInternal, @@ -1441,10 +1449,12 @@ } void ServiceWorkerGlobalScope::Clone( - mojo::PendingReceiver<mojom::blink::ControllerServiceWorker> receiver) { + mojo::PendingReceiver<mojom::blink::ControllerServiceWorker> receiver, + network::mojom::blink::CrossOriginEmbedderPolicy + cross_origin_embedder_policy) { DCHECK(IsContextThread()); controller_receivers_.Add( - this, std::move(receiver), + this, std::move(receiver), cross_origin_embedder_policy, GetThread()->GetTaskRunner(TaskType::kInternalDefault)); }
diff --git a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h index a31bb47b..cc917cd 100644 --- a/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h +++ b/third_party/blink/renderer/modules/service_worker/service_worker_global_scope.h
@@ -38,6 +38,7 @@ #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/remote.h" +#include "services/network/public/mojom/network_context.mojom-blink-forward.h" #include "third_party/blink/public/mojom/cache_storage/cache_storage.mojom-blink-forward.h" #include "third_party/blink/public/mojom/service_worker/controller_service_worker.mojom-blink.h" #include "third_party/blink/public/mojom/service_worker/service_worker.mojom-blink.h" @@ -373,8 +374,10 @@ mojo::PendingRemote<mojom::blink::ServiceWorkerFetchResponseCallback> response_callback, DispatchFetchEventForSubresourceCallback callback) override; - void Clone(mojo::PendingReceiver<mojom::blink::ControllerServiceWorker> - reciever) override; + void Clone( + mojo::PendingReceiver<mojom::blink::ControllerServiceWorker> reciever, + network::mojom::blink::CrossOriginEmbedderPolicy + cross_origin_embedder_policy) override; // Implements mojom::blink::ServiceWorker. void InitializeGlobalScope( @@ -568,8 +571,13 @@ // the controllees. |controller_bindings_| should be destroyed before // |timeout_timer_| since the pipe needs to be disconnected before callbacks // passed by DispatchSomeEvent() get destructed, which may be stored in - // |timeout_timer_| - mojo::ReceiverSet<mojom::blink::ControllerServiceWorker> + // |timeout_timer_|. + // network::mojom::blink::CrossOriginEmbedderPolicy set as the context of + // mojo::ReceiverSet is the policy for the client which dispatches FetchEvents + // to the ControllerServiceWorker. It should be referred to before sending the + // response back to the client. + mojo::ReceiverSet<mojom::blink::ControllerServiceWorker, + network::mojom::blink::CrossOriginEmbedderPolicy> controller_receivers_; };
diff --git a/third_party/blink/renderer/modules/xr/xr_frame_provider.cc b/third_party/blink/renderer/modules/xr/xr_frame_provider.cc index 38c6bc7..f6bcb3eb 100644 --- a/third_party/blink/renderer/modules/xr/xr_frame_provider.cc +++ b/third_party/blink/renderer/modules/xr/xr_frame_provider.cc
@@ -13,7 +13,6 @@ #include "third_party/blink/renderer/core/frame/local_frame.h" #include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h" #include "third_party/blink/renderer/core/loader/document_loader.h" -#include "third_party/blink/renderer/modules/xr/type_converters.h" #include "third_party/blink/renderer/modules/xr/xr.h" #include "third_party/blink/renderer/modules/xr/xr_plane_detection_state.h" #include "third_party/blink/renderer/modules/xr/xr_session.h" @@ -49,16 +48,6 @@ Member<XRFrameProvider> frame_provider_; }; -std::unique_ptr<TransformationMatrix> getPoseMatrix( - const device::mojom::blink::VRPosePtr& pose) { - if (!pose) - return nullptr; - - return std::make_unique<TransformationMatrix>( - mojo::TypeConverter<TransformationMatrix, - device::mojom::blink::VRPosePtr>::Convert(pose)); -} - } // namespace XRFrameProvider::XRFrameProvider(XR* xr) @@ -400,18 +389,9 @@ // presentation frame as newly created presentation frame will get passed to // the input source select[/start/end] events. immersive_session_->UpdatePresentationFrameState( - high_res_now_ms, getPoseMatrix(frame_pose), frame_data, + high_res_now_ms, frame_pose, frame_data, frame_id_, is_immersive_frame_position_emulated_); - if (frame_pose) { - base::span<const device::mojom::blink::XRInputSourceStatePtr> - input_states; - if (frame_pose->input_state.has_value()) - input_states = frame_pose->input_state.value(); - - immersive_session_->OnInputStateChange(frame_id_, input_states); - } - // Check if immersive session is still set as OnInputStateChange may have // allowed a ForceEndSession to be triggered. if (!immersive_session_ || immersive_session_->ended()) @@ -469,18 +449,9 @@ // presentation frame as newly created presentation frame will get passed // to the input source select[/start/end] events. session->UpdatePresentationFrameState( - high_res_now_ms, getPoseMatrix(frame_pose), frame_data, + high_res_now_ms, frame_pose, frame_data, frame_id_, true /* Non-immersive positions are always emulated */); - if (frame_pose) { - base::span<const device::mojom::blink::XRInputSourceStatePtr> - input_states; - if (frame_pose->input_state.has_value()) - input_states = frame_pose->input_state.value(); - - session->OnInputStateChange(frame_id_, input_states); - } - // If the input state change caused this session to end, we should stop // processing. if (session->ended())
diff --git a/third_party/blink/renderer/modules/xr/xr_session.cc b/third_party/blink/renderer/modules/xr/xr_session.cc index c094840..e23f9f2 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.cc +++ b/third_party/blink/renderer/modules/xr/xr_session.cc
@@ -23,6 +23,7 @@ #include "third_party/blink/renderer/core/resize_observer/resize_observer_entry.h" #include "third_party/blink/renderer/modules/event_target_modules.h" #include "third_party/blink/renderer/modules/screen_orientation/screen_orientation.h" +#include "third_party/blink/renderer/modules/xr/type_converters.h" #include "third_party/blink/renderer/modules/xr/xr.h" #include "third_party/blink/renderer/modules/xr/xr_anchor_set.h" #include "third_party/blink/renderer/modules/xr/xr_bounded_reference_space.h" @@ -131,6 +132,16 @@ return base::nullopt; } +std::unique_ptr<TransformationMatrix> getPoseMatrix( + const device::mojom::blink::VRPosePtr& pose) { + if (!pose) + return nullptr; + + return std::make_unique<TransformationMatrix>( + mojo::TypeConverter<TransformationMatrix, + device::mojom::blink::VRPosePtr>::Convert(pose)); +} + } // namespace class XRSession::XRSessionResizeObserverDelegate final @@ -1191,8 +1202,9 @@ void XRSession::UpdatePresentationFrameState( double timestamp, - std::unique_ptr<TransformationMatrix> mojo_from_viewer, + const device::mojom::blink::VRPosePtr& frame_pose, const device::mojom::blink::XRFrameDataPtr& frame_data, + int16_t frame_id, bool emulated_position) { TRACE_EVENT0("gpu", __func__); DVLOG(2) << __func__ << " : frame_data valid? " @@ -1201,12 +1213,33 @@ if (ended_) return; - mojo_from_viewer_ = std::move(mojo_from_viewer); + mojo_from_viewer_ = getPoseMatrix(frame_pose); DVLOG(2) << __func__ << " : mojo_from_viewer_ valid? " << (mojo_from_viewer_ ? true : false); emulated_position_ = emulated_position; + UpdateWorldUnderstandingStateForFrame(timestamp, frame_data); + + // Process XR input sources + if (frame_pose) { + base::span<const device::mojom::blink::XRInputSourceStatePtr> input_states; + if (frame_pose->input_state.has_value()) + input_states = frame_pose->input_state.value(); + + OnInputStateChangeInternal(frame_id, input_states); + + // If this session uses input eventing, XR select events are handled via + // OnButtonEvent, so they need to be ignored here to avoid duplicate events. + if (!uses_input_eventing_) { + ProcessInputSourceEvents(input_states); + } + } +} + +void XRSession::UpdateWorldUnderstandingStateForFrame( + double timestamp, + const device::mojom::blink::XRFrameDataPtr& frame_data) { // Update objects that might change on per-frame basis. if (frame_data) { world_information_->ProcessPlaneInformation( @@ -1371,21 +1404,15 @@ void XRSession::OnButtonEvent( device::mojom::blink::XRInputSourceStatePtr input_state) { DCHECK(uses_input_eventing_); - OnInputStateChangeInternal(last_frame_id_, base::make_span(&input_state, 1), - true /* from_eventing */); -} - -void XRSession::OnInputStateChange( - int16_t frame_id, - base::span<const device::mojom::blink::XRInputSourceStatePtr> - input_states) { - OnInputStateChangeInternal(frame_id, input_states, false /* from_eventing */); + auto input_states = base::make_span(&input_state, 1); + OnInputStateChangeInternal(last_frame_id_, input_states); + ProcessInputSourceEvents(input_states); } void XRSession::OnInputStateChangeInternal( int16_t frame_id, - base::span<const device::mojom::blink::XRInputSourceStatePtr> input_states, - bool from_eventing) { + base::span<const device::mojom::blink::XRInputSourceStatePtr> + input_states) { // If we're in any state other than visible, input should not be processed if (visibility_state_ != XRVisibilityState::VISIBLE) { return; @@ -1444,21 +1471,17 @@ DispatchEvent(*XRInputSourcesChangeEvent::Create( event_type_names::kInputsourceschange, this, added, removed)); } +} - // Now that we've fired the input sources change event (if needed), update - // and fire events for any select state changes. +void XRSession::ProcessInputSourceEvents( + base::span<const device::mojom::blink::XRInputSourceStatePtr> + input_states) { for (const auto& input_state : input_states) { // If anything during the process of updating the select state caused us // to end our session, we should stop processing select state updates. if (ended_) break; - // If this data is not from eventing and we support it, ignore it's click - // states. - // If this data is from eventing, but we don't support it, then ignore it - if (from_eventing != uses_input_eventing_) - continue; - XRInputSource* input_source = input_sources_->GetWithSourceId(input_state->source_id); DCHECK(input_source);
diff --git a/third_party/blink/renderer/modules/xr/xr_session.h b/third_party/blink/renderer/modules/xr/xr_session.h index c880f85..4c574e0 100644 --- a/third_party/blink/renderer/modules/xr/xr_session.h +++ b/third_party/blink/renderer/modules/xr/xr_session.h
@@ -189,11 +189,6 @@ void OnFrame(double timestamp, const base::Optional<gpu::MailboxHolder>& output_mailbox_holder); - void OnInputStateChange( - int16_t frame_id, - base::span<const device::mojom::blink::XRInputSourceStatePtr> - input_states); - // XRInputSourceButtonListener void OnButtonEvent( device::mojom::blink::XRInputSourceStatePtr input_source) override; @@ -263,8 +258,9 @@ // presentation frames. void UpdatePresentationFrameState( double timestamp, - std::unique_ptr<TransformationMatrix> mojo_from_viewer, + const device::mojom::blink::VRPosePtr& frame_pose, const device::mojom::blink::XRFrameDataPtr& frame_data, + int16_t frame_id, bool emulated_position); // Notifies immersive session that the environment integration provider has @@ -292,8 +288,13 @@ void OnInputStateChangeInternal( int16_t frame_id, base::span<const device::mojom::blink::XRInputSourceStatePtr> - input_states, - bool from_eventing); + input_states); + void ProcessInputSourceEvents( + base::span<const device::mojom::blink::XRInputSourceStatePtr> + input_states); + void UpdateWorldUnderstandingStateForFrame( + double timestamp, + const device::mojom::blink::XRFrameDataPtr& frame_data); // XRSessionClient void OnChanged(device::mojom::blink::VRDisplayInfoPtr display_info) override;
diff --git a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h index 81005e0..c659ab8 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h +++ b/third_party/blink/renderer/platform/graphics/compositing/content_layer_client_impl.h
@@ -50,7 +50,6 @@ std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( const cc::Layer*) override; std::string LayerDebugName(const cc::Layer*) const override; - void DidChangeScrollbarsHiddenIfOverlay(bool) override {} // LayerAsJSONClient implementation void AppendAdditionalInfoAsJSON(LayerTreeFlags,
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc index fd1bd4f..0b42517f 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.cc
@@ -43,9 +43,8 @@ static int g_s_property_tree_sequence_number = 1; PaintArtifactCompositor::PaintArtifactCompositor( - base::RepeatingCallback<void(const gfx::ScrollOffset&, - const cc::ElementId&)> scroll_callback) - : scroll_callback_(std::move(scroll_callback)), + base::WeakPtr<CompositorScrollCallbacks> scroll_callbacks) + : scroll_callbacks_(std::move(scroll_callbacks)), tracks_raster_invalidations_(false), needs_update_(true) { root_layer_ = cc::Layer::Create(); @@ -238,7 +237,6 @@ // Set the layer's bounds equal to the container because the scroll layer // does not scroll. scroll_layer->SetBounds(static_cast<gfx::Size>(bounds)); - scroll_layer->set_did_scroll_callback(scroll_callback_); return scroll_layer; } @@ -1063,6 +1061,7 @@ if (extra_data_for_testing_enabled_) extra_data_for_testing_.reset(new ExtraDataForTesting); + host->property_trees()->scroll_tree.SetScrollCallbacks(scroll_callbacks_); root_layer_->set_property_tree_sequence_number( g_s_property_tree_sequence_number);
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h index e5f55f4..44d653c 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor.h
@@ -7,13 +7,13 @@ #include <memory> -#include "base/callback.h" #include "base/macros.h" #include "base/memory/ptr_util.h" #include "base/memory/scoped_refptr.h" #include "cc/layers/content_layer_client.h" #include "cc/layers/layer_collections.h" #include "cc/layers/picture_layer.h" +#include "cc/trees/property_tree.h" #include "third_party/blink/renderer/platform/graphics/compositing/layers_as_json.h" #include "third_party/blink/renderer/platform/graphics/compositing/property_tree_manager.h" #include "third_party/blink/renderer/platform/graphics/graphics_layer_client.h" @@ -21,15 +21,8 @@ #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/wtf/vector.h" -namespace cc { -struct ElementId; -class EffectTree; -class Layer; -} - namespace gfx { class Vector2dF; -class ScrollOffset; } namespace blink { @@ -40,6 +33,8 @@ class SynthesizedClip; struct PaintChunk; +using CompositorScrollCallbacks = cc::ScrollCallbacks; + class LayerListBuilder { public: void Add(scoped_refptr<cc::Layer>); @@ -115,8 +110,7 @@ public: PaintArtifactCompositor( - base::RepeatingCallback<void(const gfx::ScrollOffset&, - const cc::ElementId&)> scroll_callback); + base::WeakPtr<CompositorScrollCallbacks> scroll_callbacks); ~PaintArtifactCompositor(); struct ViewportProperties { @@ -326,9 +320,8 @@ cc::PropertyTrees* GetPropertyTreesForDirectUpdate(); - // Provides a callback for notifying blink of composited scrolling. - base::RepeatingCallback<void(const gfx::ScrollOffset&, const cc::ElementId&)> - scroll_callback_; + // For notifying blink of composited scrolling. + base::WeakPtr<CompositorScrollCallbacks> scroll_callbacks_; bool tracks_raster_invalidations_; bool needs_update_;
diff --git a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc index c98d8f2..71771715 100644 --- a/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc +++ b/third_party/blink/renderer/platform/graphics/compositing/paint_artifact_compositor_test.cc
@@ -65,19 +65,17 @@ chunk.properties = RefCountedPropertyTreeState(properties); } -class FakeScrollClient { - DISALLOW_NEW(); - +class MockScrollCallbacks : public CompositorScrollCallbacks { public: - FakeScrollClient() : did_scroll_count(0) {} + MOCK_METHOD2(DidScroll, void(CompositorElementId, const gfx::ScrollOffset&)); + MOCK_METHOD2(DidChangeScrollbarsHidden, void(CompositorElementId, bool)); - void DidScroll(const gfx::ScrollOffset& offset, const CompositorElementId&) { - did_scroll_count++; - last_scroll_offset = offset; + base::WeakPtr<MockScrollCallbacks> GetWeakPtr() { + return weak_ptr_factory_.GetWeakPtr(); } - gfx::ScrollOffset last_scroll_offset; - unsigned did_scroll_count; + private: + base::WeakPtrFactory<MockScrollCallbacks> weak_ptr_factory_{this}; }; class PaintArtifactCompositorTest : public testing::Test, @@ -89,9 +87,8 @@ void SetUp() override { // Delay constructing the compositor until after the feature is set. - paint_artifact_compositor_ = - std::make_unique<PaintArtifactCompositor>(WTF::BindRepeating( - &FakeScrollClient::DidScroll, WTF::Unretained(&scroll_client_))); + paint_artifact_compositor_ = std::make_unique<PaintArtifactCompositor>( + scroll_callbacks_.GetWeakPtr()); paint_artifact_compositor_->EnableExtraDataForTesting(); // Uses a LayerTreeHostClient that will make a LayerTreeFrameSink to allow @@ -178,8 +175,6 @@ layer->SetScrollable(gfx::Size(rect.Size())); layer->SetBounds(gfx::Size(rect.Size())); layer->SetElementId(scroll_node->GetCompositorElementId()); - layer->set_did_scroll_callback( - paint_artifact_compositor_->scroll_callback_); artifact.Chunk(scroll_offset, clip, effect) .ForeignLayer(layer, FloatPoint(rect.Location())); } @@ -276,10 +271,10 @@ return PaintArtifactCompositor::MightOverlap(a, b); } - FakeScrollClient& ScrollClient() { return scroll_client_; } + MockScrollCallbacks& ScrollCallbacks() { return scroll_callbacks_; } private: - FakeScrollClient scroll_client_; + MockScrollCallbacks scroll_callbacks_; std::unique_ptr<PaintArtifactCompositor> paint_artifact_compositor_; scoped_refptr<base::TestSimpleTaskRunner> task_runner_; base::ThreadTaskRunnerHandle task_runner_handle_; @@ -1088,10 +1083,15 @@ EXPECT_EQ(gfx::Vector2dF(3, 5), scroll_layer->offset_to_transform_parent()); EXPECT_EQ(scroll_layer->scroll_tree_index(), scroll_node.id); - EXPECT_EQ(0u, ScrollClient().did_scroll_count); - scroll_layer->SetScrollOffsetFromImplSide(gfx::ScrollOffset(1, 2)); - EXPECT_EQ(1u, ScrollClient().did_scroll_count); - EXPECT_EQ(gfx::ScrollOffset(1, 2), ScrollClient().last_scroll_offset); + EXPECT_CALL(ScrollCallbacks(), + DidScroll(scroll_node.element_id, gfx::ScrollOffset(1, 2))); + GetPropertyTrees().scroll_tree.NotifyDidScroll(scroll_node.element_id, + gfx::ScrollOffset(1, 2)); + + EXPECT_CALL(ScrollCallbacks(), + DidChangeScrollbarsHidden(scroll_node.element_id, true)); + GetPropertyTrees().scroll_tree.NotifyDidChangeScrollbarsHidden( + scroll_node.element_id, true); } TEST_P(PaintArtifactCompositorTest, TransformUnderScrollNode) {
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer.cc b/third_party/blink/renderer/platform/graphics/graphics_layer.cc index fb8d3fe2..691da24 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer.cc +++ b/third_party/blink/renderer/platform/graphics/graphics_layer.cc
@@ -844,10 +844,6 @@ return DebugName(layer).Utf8(); } -void GraphicsLayer::DidChangeScrollbarsHiddenIfOverlay(bool hidden) { - client_.SetOverlayScrollbarsHidden(hidden); -} - PaintController& GraphicsLayer::GetPaintController() const { CHECK(PaintsContentOrHitTest()); if (!paint_controller_)
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer.h b/third_party/blink/renderer/platform/graphics/graphics_layer.h index 59a13399..0b9f2ee 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer.h +++ b/third_party/blink/renderer/platform/graphics/graphics_layer.h
@@ -220,7 +220,6 @@ std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( const cc::Layer*) override; std::string LayerDebugName(const cc::Layer*) const override; - void DidChangeScrollbarsHiddenIfOverlay(bool) override; PaintController& GetPaintController() const;
diff --git a/third_party/blink/renderer/platform/graphics/graphics_layer_client.h b/third_party/blink/renderer/platform/graphics/graphics_layer_client.h index db93f28..091a8e66 100644 --- a/third_party/blink/renderer/platform/graphics/graphics_layer_client.h +++ b/third_party/blink/renderer/platform/graphics/graphics_layer_client.h
@@ -80,8 +80,6 @@ virtual bool IsTrackingRasterInvalidations() const { return false; } - virtual void SetOverlayScrollbarsHidden(bool) {} - virtual void GraphicsLayersDidChange() {} virtual String DebugName(const GraphicsLayer*) const = 0;
diff --git a/third_party/blink/renderer/platform/graphics/paint/scrollbar_display_item.cc b/third_party/blink/renderer/platform/graphics/paint/scrollbar_display_item.cc index 3d5c080..1ada87d 100644 --- a/third_party/blink/renderer/platform/graphics/paint/scrollbar_display_item.cc +++ b/third_party/blink/renderer/platform/graphics/paint/scrollbar_display_item.cc
@@ -31,7 +31,6 @@ return traced_value; } std::string LayerDebugName(const cc::Layer*) const override { return name_; } - void DidChangeScrollbarsHiddenIfOverlay(bool) override {} base::WeakPtr<cc::LayerClient> GetWeakPtr() { return weak_ptr_factory_.GetWeakPtr();
diff --git a/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc b/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc index dfa44f5..1a133a8e 100644 --- a/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc +++ b/third_party/blink/renderer/platform/peerconnection/rtc_video_encoder.cc
@@ -8,7 +8,6 @@ #include <memory> #include <vector> -#include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" #include "base/location.h" @@ -37,6 +36,7 @@ #include "third_party/blink/renderer/platform/webrtc/webrtc_video_frame_adapter.h" #include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/blink/renderer/platform/wtf/deque.h" +#include "third_party/blink/renderer/platform/wtf/functional.h" #include "third_party/blink/renderer/platform/wtf/text/wtf_string.h" #include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/libyuv/include/libyuv.h" @@ -842,8 +842,9 @@ } constexpr int kDummyIndex = -1; - frame->AddDestructionObserver(media::BindToCurrentLoop(base::BindOnce( - &RTCVideoEncoder::Impl::EncodeFrameFinished, this, kDummyIndex))); + frame->AddDestructionObserver(media::BindToCurrentLoop( + WTF::Bind(&RTCVideoEncoder::Impl::EncodeFrameFinished, + CrossThreadUnretained(this), kDummyIndex))); if (!failed_timestamp_match_) { DCHECK(std::find_if(pending_timestamps_.begin(), pending_timestamps_.end(), [&frame](const RTCTimestamps& entry) {
diff --git a/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc b/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc index ac34cd34..cd4a665 100644 --- a/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc +++ b/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.cc
@@ -7,13 +7,32 @@ #include <algorithm> #include <limits> -#include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" #include "base/logging.h" #include "base/stl_util.h" +#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h" +#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h" #include "third_party/webrtc/rtc_base/ref_counted_object.h" +namespace WTF { + +template <> +struct CrossThreadCopier<scoped_refptr<webrtc::AudioProcessorInterface>> + : public CrossThreadCopierPassThrough< + scoped_refptr<webrtc::AudioProcessorInterface>> { + STATIC_ONLY(CrossThreadCopier); +}; + +template <> +struct CrossThreadCopier<scoped_refptr<blink::WebRtcAudioSink::Adapter>> + : public CrossThreadCopierPassThrough< + scoped_refptr<blink::WebRtcAudioSink::Adapter>> { + STATIC_ONLY(CrossThreadCopier); +}; + +} // namespace WTF + namespace blink { WebRtcAudioSink::WebRtcAudioSink( @@ -26,8 +45,9 @@ std::move(track_source), std::move(signaling_task_runner), std::move(main_task_runner))), - fifo_(base::BindRepeating(&WebRtcAudioSink::DeliverRebufferedAudio, - base::Unretained(this))) { + fifo_(ConvertToBaseCallback( + CrossThreadBindRepeating(&WebRtcAudioSink::DeliverRebufferedAudio, + CrossThreadUnretained(this)))) { DVLOG(1) << "WebRtcAudioSink::WebRtcAudioSink()"; } @@ -52,10 +72,11 @@ void WebRtcAudioSink::OnEnabledChanged(bool enabled) { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); - adapter_->signaling_task_runner()->PostTask( - FROM_HERE, - base::BindOnce(base::IgnoreResult(&WebRtcAudioSink::Adapter::set_enabled), - adapter_, enabled)); + PostCrossThreadTask( + *adapter_->signaling_task_runner(), FROM_HERE, + CrossThreadBindOnce( + base::IgnoreResult(&WebRtcAudioSink::Adapter::set_enabled), adapter_, + enabled)); } void WebRtcAudioSink::OnData(const media::AudioBus& audio_bus, @@ -117,9 +138,9 @@ WebRtcAudioSink::Adapter::~Adapter() { if (audio_processor_) { - main_task_runner_->PostTask( - FROM_HERE, - base::BindOnce(&DereferenceOnMainThread, std::move(audio_processor_))); + PostCrossThreadTask(*main_task_runner_.get(), FROM_HERE, + CrossThreadBindOnce(&DereferenceOnMainThread, + std::move(audio_processor_))); } }
diff --git a/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.h b/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.h index 11b25d1..b405636d 100644 --- a/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.h +++ b/third_party/blink/renderer/platform/peerconnection/webrtc_audio_sink.h
@@ -150,6 +150,9 @@ DISALLOW_COPY_AND_ASSIGN(Adapter); }; + template <typename> + friend struct WTF::CrossThreadCopier; + // WebMediaStreamAudioSink implementation. void OnData(const media::AudioBus& audio_bus, base::TimeTicks estimated_capture_time) override;
diff --git a/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc b/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc index 9c5bc18e..80db35dd 100644 --- a/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc +++ b/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.cc
@@ -98,15 +98,22 @@ DVLOG(3) << "has_valid_update_rect = " << has_valid_update_rect; if (has_capture_counter) previous_capture_counter_ = capture_counter; - if (has_valid_update_rect) - accumulated_update_rect_.Union(update_rect); - else - accumulated_update_rect_.Union(gfx::Rect(frame->coded_size())); + if (has_valid_update_rect) { + if (!accumulated_update_rect_) { + accumulated_update_rect_ = update_rect; + } else { + accumulated_update_rect_->Union(update_rect); + } + } else { + accumulated_update_rect_ = base::nullopt; + } - DVLOG(3) << "accumulated_update_rect_ = [" << accumulated_update_rect_.x() - << ", " << accumulated_update_rect_.y() << ", " - << accumulated_update_rect_.width() << ", " - << accumulated_update_rect_.height() << "]"; + if (accumulated_update_rect_) { + DVLOG(3) << "accumulated_update_rect_ = [" << accumulated_update_rect_->x() + << ", " << accumulated_update_rect_->y() << ", " + << accumulated_update_rect_->width() << ", " + << accumulated_update_rect_->height() << "]"; + } // Calculate desired target cropping and scaling of the received frame. Note, // that the frame may already have some cropping and scaling soft-applied via @@ -132,9 +139,14 @@ frame->storage_type() != media::VideoFrame::STORAGE_GPU_MEMORY_BUFFER) { // The webrtc::VideoFrame::UpdateRect expected by WebRTC must // be relative to the |visible_rect()|. We need to translate. - const auto cropped_rect = - CropRectangle(accumulated_update_rect_, frame->visible_rect()); - DeliverFrame(std::move(frame), cropped_rect, translated_camera_time_us); + base::Optional<gfx::Rect> cropped_rect; + if (accumulated_update_rect_) { + cropped_rect = + CropRectangle(*accumulated_update_rect_, frame->visible_rect()); + } + + DeliverFrame(std::move(frame), OptionalOrNullptr(cropped_rect), + translated_camera_time_us); return; } @@ -174,9 +186,12 @@ if (video_frame->natural_size() == video_frame->visible_rect().size()) { // The webrtc::VideoFrame::UpdateRect expected by WebRTC must be // relative to the |visible_rect()|. We need to translate. - const auto cropped_rect = - CropRectangle(accumulated_update_rect_, video_frame->visible_rect()); - DeliverFrame(std::move(video_frame), cropped_rect, + base::Optional<gfx::Rect> cropped_rect; + if (accumulated_update_rect_) { + cropped_rect = + CropRectangle(*accumulated_update_rect_, frame->visible_rect()); + } + DeliverFrame(std::move(video_frame), OptionalOrNullptr(cropped_rect), translated_camera_time_us); return; } @@ -184,13 +199,15 @@ // Delay scaling if |video_frame| is backed by GpuMemoryBuffer. if (video_frame->storage_type() == media::VideoFrame::STORAGE_GPU_MEMORY_BUFFER) { - // When scaling is applied and any part of the frame has changed, we mark - // the whole frame as changed. - const auto update_rect_on_scaled = - accumulated_update_rect_.IsEmpty() - ? gfx::Rect() - : gfx::Rect(video_frame->natural_size()); - DeliverFrame(std::move(video_frame), update_rect_on_scaled, + // When scaling is applied and any part of the frame has changed, we don't + // have reliable changed rect information. + if (accumulated_update_rect_.has_value() && + !accumulated_update_rect_->IsEmpty()) { + accumulated_update_rect_ = base::nullopt; + } + + DeliverFrame(std::move(video_frame), + OptionalOrNullptr(accumulated_update_rect_), translated_camera_time_us); return; } @@ -228,14 +245,15 @@ adapted_size.width(), adapted_size.height(), libyuv::kFilterBilinear); } - // When scaling is applied and any part of the frame has changed, we mark the - // whole frame as changed. - DeliverFrame( - std::move(scaled_frame), - accumulated_update_rect_.IsEmpty() - ? gfx::Rect() - : gfx::Rect(0, 0, adapted_size.width(), adapted_size.height()), - translated_camera_time_us); + // When scaling is applied and any part of the frame has changed, we don't + // have a reliable update rect information. + if (accumulated_update_rect_.has_value() && + !accumulated_update_rect_->IsEmpty()) { + accumulated_update_rect_ = base::nullopt; + } + DeliverFrame(std::move(scaled_frame), + OptionalOrNullptr(accumulated_update_rect_), + translated_camera_time_us); } WebRtcVideoTrackSource::FrameAdaptationParams @@ -254,11 +272,13 @@ void WebRtcVideoTrackSource::DeliverFrame( scoped_refptr<media::VideoFrame> frame, - gfx::Rect update_rect, + gfx::Rect* update_rect, int64_t timestamp_us) { - DVLOG(3) << "update_rect = " - << "[" << update_rect.x() << ", " << update_rect.y() << ", " - << update_rect.width() << ", " << update_rect.height() << "]"; + if (update_rect) { + DVLOG(3) << "update_rect = " + << "[" << update_rect->x() << ", " << update_rect->y() << ", " + << update_rect->width() << ", " << update_rect->height() << "]"; + } // If the cropping or the size have changed since the previous // frame, even if nothing in the incoming coded frame content has changed, we @@ -267,27 +287,24 @@ frame->natural_size() != natural_size_of_previous_delivered_frame_) { cropping_rect_of_previous_delivered_frame_ = frame->visible_rect(); natural_size_of_previous_delivered_frame_ = frame->natural_size(); - if (frame->storage_type() == media::VideoFrame::STORAGE_GPU_MEMORY_BUFFER) { - // Use the frame natural size since we delay the scaling. - update_rect = gfx::Rect(frame->natural_size()); - } else { - update_rect = gfx::Rect(0, 0, frame->visible_rect().width(), - frame->visible_rect().height()); - } + update_rect = nullptr; } // Clear accumulated_update_rect_. accumulated_update_rect_ = gfx::Rect(); - OnFrame(webrtc::VideoFrame::Builder() - .set_video_frame_buffer( - new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame)) - .set_rotation(webrtc::kVideoRotation_0) - .set_timestamp_us(timestamp_us) - .set_update_rect(webrtc::VideoFrame::UpdateRect{ - update_rect.x(), update_rect.y(), update_rect.width(), - update_rect.height()}) - .build()); + webrtc::VideoFrame::Builder frame_builder = + webrtc::VideoFrame::Builder() + .set_video_frame_buffer( + new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame)) + .set_rotation(webrtc::kVideoRotation_0) + .set_timestamp_us(timestamp_us); + if (update_rect) { + frame_builder.set_update_rect(webrtc::VideoFrame::UpdateRect{ + update_rect->x(), update_rect->y(), update_rect->width(), + update_rect->height()}); + } + OnFrame(frame_builder.build()); } } // namespace blink
diff --git a/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.h b/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.h index bb02e3e4..9a6c26f4 100644 --- a/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.h +++ b/third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.h
@@ -58,7 +58,7 @@ // |frame->visible_rect()|) has changed since the last delivered frame, the // whole frame is marked as updated. void DeliverFrame(scoped_refptr<media::VideoFrame> frame, - gfx::Rect update_rect, + gfx::Rect* update_rect, int64_t timestamp_us); // |thread_checker_| is bound to the libjingle worker thread. @@ -72,7 +72,7 @@ // Stores the accumulated value of CAPTURE_UPDATE_RECT in case that frames // are dropped. - gfx::Rect accumulated_update_rect_; + base::Optional<gfx::Rect> accumulated_update_rect_; base::Optional<int> previous_capture_counter_; gfx::Rect cropping_rect_of_previous_delivered_frame_; gfx::Size natural_size_of_previous_delivered_frame_;
diff --git a/third_party/blink/web_tests/FlagExpectations/disable-layout-ng b/third_party/blink/web_tests/FlagExpectations/disable-layout-ng index c6c9ecd2..74c07e01d 100644 --- a/third_party/blink/web_tests/FlagExpectations/disable-layout-ng +++ b/third_party/blink/web_tests/FlagExpectations/disable-layout-ng
@@ -137,6 +137,7 @@ ### external/wpt/css/css-text/word-break/ crbug.com/591099 external/wpt/css/css-text/word-break/word-break-break-all-004.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html [ Failure ] crbug.com/1017164 external/wpt/css/css-text/word-break/word-break-break-all-inline-008.html [ Failure ] ### external/wpt/css/css-ui/
diff --git a/third_party/blink/web_tests/FlagExpectations/layout-ng-fragment-item b/third_party/blink/web_tests/FlagExpectations/layout-ng-fragment-item index 52e58f77..7b5f30b 100644 --- a/third_party/blink/web_tests/FlagExpectations/layout-ng-fragment-item +++ b/third_party/blink/web_tests/FlagExpectations/layout-ng-fragment-item
@@ -62,7 +62,6 @@ crbug.com/982194 compositing/squashing/squash-transform-repainting-transformed-child.html [ Failure ] crbug.com/982194 compositing/squashing/vertical-writing-mode-squashed.html [ Failure ] crbug.com/982194 css1/formatting_model/inline_elements.html [ Failure ] -crbug.com/982194 css2.1/20110323/eof-005.htm [ Failure Pass ] crbug.com/982194 css2.1/t040105-import-10-b.html [ Failure Pass ] crbug.com/982194 css2.1/t100801-c544-valgn-00-a-ag.html [ Failure ] crbug.com/982194 css2.1/t100801-c544-valgn-03-d-agi.html [ Failure ] @@ -206,7 +205,7 @@ crbug.com/982194 editing/selection/mouse/user-drag-element-and-user-select-none.html [ Failure ] crbug.com/982194 editing/selection/offset-from-point-complex-scripts.html [ Failure ] crbug.com/982194 editing/selection/offset-from-point.html [ Failure ] -crbug.com/591099 editing/selection/paint-hyphen.html [ Failure ] +crbug.com/591099 editing/selection/paint-hyphen.html [ Crash Failure ] crbug.com/982194 editing/selection/readonly-disabled-hittest.html [ Failure ] crbug.com/982194 editing/selection/readonly-disabled-text-selection.html [ Failure ] crbug.com/741259 editing/selection/select-bidi-run.html [ Failure ] @@ -746,7 +745,7 @@ crbug.com/982194 fast/css/hover-update.html [ Timeout ] crbug.com/982194 fast/css/invalidation-errors-2.html [ Failure ] crbug.com/982194 fast/css/invalidation-errors.html [ Failure ] -crbug.com/982194 fast/css/namespaces/003.xml [ Failure ] +crbug.com/982194 fast/css/namespaces/003.xml [ Failure Pass ] crbug.com/982194 fast/css/outline-auto-empty-rects.html [ Failure ] crbug.com/835484 fast/css/outline-narrowLine.html [ Failure ] crbug.com/982194 fast/css/pseudo-active-display-none.html [ Failure ] @@ -897,7 +896,7 @@ crbug.com/982194 fast/events/event-trusted.html [ Failure ] crbug.com/982194 fast/events/file-input-hidden-in-ondrop.html [ Timeout ] crbug.com/982194 fast/events/focus-click-on-non-mouse-focusable-element.html [ Failure ] -crbug.com/982194 fast/events/focus-event-source-device-from-mouse.html [ Crash Failure Pass ] +crbug.com/982194 fast/events/focus-event-source-device-from-mouse.html [ Crash Pass ] crbug.com/982194 fast/events/frame-click-focus.html [ Failure ] crbug.com/874695 fast/events/frame-detached-in-mousedown.html [ Timeout ] crbug.com/982194 fast/events/hit-test-counts.html [ Failure ] @@ -914,7 +913,7 @@ crbug.com/982194 fast/events/middleClickAutoscroll-drag-scrollable-iframe-div.html [ Crash ] crbug.com/982194 fast/events/middleClickAutoscroll-in-iframe.html [ Failure ] crbug.com/982194 fast/events/middleClickAutoscroll-modal-scrollable-iframe-div.html [ Crash ] -crbug.com/982194 fast/events/mouse-cursor-multiframecur.html [ Failure ] +crbug.com/982194 fast/events/mouse-cursor-multiframecur.html [ Crash Failure ] crbug.com/982194 fast/events/mouse-cursor-style-change-iframe.html [ Failure ] crbug.com/982194 fast/events/mouse-down-on-pseudo-element-remove-crash.html [ Failure ] crbug.com/982194 fast/events/mouse-drag-from-frame-to-other-frame.html [ Failure ] @@ -990,7 +989,7 @@ crbug.com/982194 fast/events/touch/gesture/gesture-tap-input-after-composition.html [ Failure ] crbug.com/982194 fast/events/touch/gesture/gesture-tap-mouse-events-between-frames.html [ Failure ] crbug.com/982194 fast/events/touch/gesture/gesture-tap-mouse-events.html [ Failure ] -crbug.com/982194 fast/events/touch/gesture/gesture-tap-near-iframe.html [ Failure ] +crbug.com/982194 fast/events/touch/gesture/gesture-tap-near-iframe.html [ Crash Failure ] crbug.com/982194 fast/events/touch/gesture/gesture-tap-result.html [ Failure ] crbug.com/982194 fast/events/touch/gesture/gesture-tap-setrangetext-with-events.html [ Failure ] crbug.com/982194 fast/events/touch/gesture/long-press-drag-drop-touch-editing-combined-in-iframe.html [ Failure ] @@ -1070,7 +1069,7 @@ crbug.com/982194 fast/forms/file/input-file-value-with-zoom.html [ Timeout ] crbug.com/982194 fast/forms/file/input-file-value.html [ Timeout ] crbug.com/982194 fast/forms/file/input-file-write-files.html [ Timeout ] -crbug.com/982194 fast/forms/file/recover-file-input-in-unposted-form.html [ Failure ] +crbug.com/982194 fast/forms/file/recover-file-input-in-unposted-form.html [ Failure Timeout ] crbug.com/982194 fast/forms/file/selected-files-from-history-state.html [ Failure ] crbug.com/982194 fast/forms/floating-textfield-relayout.html [ Failure ] crbug.com/982194 fast/forms/focus-selection-input.html [ Failure ] @@ -1458,13 +1457,12 @@ crbug.com/982194 http/tests/devtools/editor/text-editor-accessibility.js [ Failure ] crbug.com/982194 http/tests/devtools/editor/text-editor-block-indent.js [ Pass Timeout ] crbug.com/846997 http/tests/devtools/editor/text-editor-ctrl-d-1.js [ Timeout ] -crbug.com/982194 http/tests/devtools/editor/text-editor-ctrl-d-2.js [ Timeout ] +crbug.com/982194 http/tests/devtools/editor/text-editor-ctrl-d-2.js [ Pass Timeout ] crbug.com/850358 http/tests/devtools/editor/text-editor-enter-behaviour.js [ Pass ] crbug.com/846982 crbug.com/874695 http/tests/devtools/editor/text-editor-formatter.js [ Crash Pass Timeout ] -crbug.com/982194 http/tests/devtools/editor/text-editor-indent-autodetection.js [ Crash ] +crbug.com/982194 http/tests/devtools/editor/text-editor-indent-autodetection.js [ Crash Pass ] crbug.com/420008 crbug.com/749738 http/tests/devtools/editor/text-editor-word-jumps.js [ Crash Pass Timeout ] crbug.com/982194 http/tests/devtools/elements/edit/edit-dom-actions-4.js [ Pass Timeout ] -crbug.com/982194 http/tests/devtools/elements/event-listeners-framework-with-service-worker.js [ Pass Timeout ] crbug.com/596486 http/tests/devtools/elements/insert-node.js [ Pass ] crbug.com/982194 http/tests/devtools/elements/inspect-pseudo-element.js [ Failure ] crbug.com/982194 http/tests/devtools/elements/shadow/elements-panel-shadow-selection-on-refresh-1.js [ Pass Timeout ] @@ -1484,7 +1482,7 @@ crbug.com/959002 crbug.com/959042 http/tests/devtools/elements/styles-3/style-autocomplete.js [ Crash Pass Timeout ] crbug.com/938884 http/tests/devtools/elements/styles-3/styles-add-blank-property.js [ Pass Timeout ] crbug.com/945665 http/tests/devtools/elements/styles-3/styles-add-new-rule-tab.js [ Failure Timeout ] -crbug.com/945665 http/tests/devtools/elements/styles-3/styles-add-new-rule.js [ Failure ] +crbug.com/945665 http/tests/devtools/elements/styles-3/styles-add-new-rule.js [ Failure Timeout ] crbug.com/945665 http/tests/devtools/elements/styles-3/styles-change-node-while-editing.js [ Failure Pass ] crbug.com/994008 http/tests/devtools/elements/styles-3/styles-computed-trace.js [ Pass Timeout ] crbug.com/945665 http/tests/devtools/elements/styles-3/styles-disable-inherited.js [ Failure ] @@ -1492,9 +1490,8 @@ crbug.com/667560 http/tests/devtools/elements/styles-4/inline-style-sourcemap.js [ Failure Pass ] crbug.com/982194 http/tests/devtools/elements/styles-4/styles-do-not-detach-sourcemap-on-edits.js [ Pass Timeout ] crbug.com/982194 http/tests/devtools/elements/styles-4/styles-formatting.js [ Pass Timeout ] -crbug.com/982194 http/tests/devtools/elements/styles-4/styles-inline-element-style-changes-should-not-force-style-recalc.js [ Pass Timeout ] crbug.com/959002 crbug.com/959042 http/tests/devtools/elements/styles-4/styles-keyframes.js [ Crash Pass Timeout ] -crbug.com/946714 http/tests/devtools/elements/styles-4/styles-live-locations-leak.js [ Timeout ] +crbug.com/946714 http/tests/devtools/elements/styles-4/styles-live-locations-leak.js [ Pass Timeout ] crbug.com/982116 http/tests/devtools/elements/styles-4/styles-new-API.js [ Pass ] crbug.com/982194 http/tests/devtools/elements/styles-4/styles-update-links-1.js [ Pass Timeout ] crbug.com/849978 http/tests/devtools/elements/styles-4/stylesheet-source-url-comment.js [ Crash Timeout ] @@ -1521,11 +1518,10 @@ crbug.com/817167 crbug.com/874695 http/tests/devtools/oopif/oopif-cookies-refresh.js [ Crash Failure Pass Timeout ] crbug.com/818076 http/tests/devtools/oopif/oopif-elements-navigate-in.js [ Pass ] crbug.com/982194 http/tests/devtools/oopif/oopif-elements-navigate-out.js [ Failure Pass ] -crbug.com/982194 http/tests/devtools/persistence/persistence-external-change-breakpoints.js [ Crash ] +crbug.com/982194 http/tests/devtools/persistence/persistence-external-change-breakpoints.js [ Crash Timeout ] crbug.com/874695 http/tests/devtools/persistence/persistence-mimetype-on-rename.js [ Pass ] crbug.com/981267 http/tests/devtools/persistence/persistence-move-breakpoints-on-reload.js [ Crash Pass ] crbug.com/982194 http/tests/devtools/persistence/persistence-move-breakpoints.js [ Crash ] -crbug.com/982194 http/tests/devtools/persistence/persistence-sourceframe-messages.js [ Pass Timeout ] crbug.com/450493 crbug.com/971262 http/tests/devtools/profiler/live-line-level-heap-profile.js [ Crash Pass Timeout ] crbug.com/831673 http/tests/devtools/reveal-objects.js [ Pass Timeout ] crbug.com/982194 http/tests/devtools/search/source-frame-replace-2.js [ Pass Timeout ] @@ -1540,7 +1536,7 @@ crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack-mutation-observer.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack-promises.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack-web-sql.js [ Crash Pass ] -crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack-xhrs.js [ Crash Pass ] +crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack-xhrs.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/debugger-async/async-callstack.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-breakpoints/breakpoint-in-collected-function.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/debugger-breakpoints/breakpoint-manager-listeners-count.js [ Crash ] @@ -1574,7 +1570,7 @@ crbug.com/450493 http/tests/devtools/sources/debugger-frameworks/frameworks-skip-step-in.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-frameworks/frameworks-sourcemap.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-frameworks/frameworks-step-into-skips-setTimeout.js [ Crash Pass ] -crbug.com/450493 http/tests/devtools/sources/debugger-frameworks/frameworks-steppings.js [ Crash ] +crbug.com/450493 http/tests/devtools/sources/debugger-frameworks/frameworks-steppings.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/debugger-pause/debugger-change-variable.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/debugger-pause/debugger-eval-on-call-frame-inside-iframe.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/debugger-pause/debugger-eval-while-paused-throws.js [ Crash ] @@ -1630,7 +1626,7 @@ crbug.com/450493 http/tests/devtools/sources/debugger/source-frame-breakpoint-decorations.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/debugger/source-frame-inline-breakpoint-decorations.js [ Crash ] crbug.com/450493 http/tests/devtools/sources/inline-script-with-source-map.js [ Crash ] -crbug.com/450493 http/tests/devtools/sources/source-frame-toolbar-items.js [ Crash ] +crbug.com/450493 http/tests/devtools/sources/source-frame-toolbar-items.js [ Crash Pass ] crbug.com/450493 http/tests/devtools/sources/sources-pretty-print.js [ Crash ] crbug.com/450493 http/tests/devtools/startup/sources/debugger/script-formatter-breakpoints-1.js [ Crash ] crbug.com/450493 http/tests/devtools/startup/sources/debugger/script-formatter-breakpoints-4.js [ Crash ] @@ -1638,7 +1634,7 @@ crbug.com/874695 http/tests/devtools/sxg/sxg-cert-not-found.js [ Pass ] crbug.com/874695 http/tests/devtools/sxg/sxg-disable-cache.js [ Pass ] crbug.com/851363 http/tests/devtools/sxg/sxg-prefetch-fail.js [ Failure Pass ] -crbug.com/851363 http/tests/devtools/sxg/sxg-prefetch.js [ Failure Pass ] +crbug.com/851363 http/tests/devtools/sxg/sxg-prefetch.js [ Pass ] crbug.com/420008 http/tests/devtools/tracing/hit-test.js [ Failure ] crbug.com/420008 crbug.com/916975 http/tests/devtools/tracing/timeline-misc/timeline-event-causes.js [ Crash Failure Pass Timeout ] crbug.com/982194 http/tests/devtools/unit/source-frame-pretty-print.js [ Crash ] @@ -1693,7 +1689,7 @@ crbug.com/982194 http/tests/security/anchor-download-allow-sameorigin.html [ Timeout ] crbug.com/982194 http/tests/security/contentSecurityPolicy/frame-src-vs-shift-click.html [ Timeout ] crbug.com/982194 http/tests/security/cookies/third-party-cookie-blocking-user-action.html [ Timeout ] -crbug.com/982194 http/tests/security/drag-drop-different-origin.html [ Crash ] +crbug.com/982194 http/tests/security/drag-drop-different-origin.html [ Crash Pass ] crbug.com/982194 http/tests/security/drag-drop-same-unique-origin.html [ Failure ] crbug.com/982194 http/tests/security/drag-over-remote-content-iframe.html [ Failure ] crbug.com/982194 http/tests/security/frameNavigation/sandbox-ALLOWED-top-navigation-with-two-flags.html [ Timeout ] @@ -1706,7 +1702,7 @@ crbug.com/982194 http/tests/security/mixedContent/insecure-css-resources.html [ Failure Pass ] crbug.com/982194 http/tests/security/referrer-policy-redirect-link.html [ Timeout ] crbug.com/982194 http/tests/security/referrer-policy-rel-noreferrer.html [ Timeout ] -crbug.com/982194 http/tests/uri/css-href.php [ Failure ] +crbug.com/982194 http/tests/uri/css-href.php [ Failure Pass ] crbug.com/982194 ietestcenter/css3/namespaces/syntax-019.xml [ Failure ] crbug.com/982194 images/55.html [ Failure ] crbug.com/982194 images/color-profile-drag-image.html [ Failure ] @@ -1724,7 +1720,6 @@ crbug.com/982194 inspector-protocol/dom/dom-getContentQuads.js [ Failure ] crbug.com/982194 media/audio-delete-while-slider-thumb-clicked.html [ Timeout ] crbug.com/874695 crbug.com/936165 media/autoplay-muted.html [ Crash Pass Timeout ] -crbug.com/982194 media/autoplay/webaudio-audio-context-init.html [ Failure Pass ] crbug.com/908347 media/autoplay/webaudio-audio-context-resume.html [ Failure Pass ] crbug.com/982194 media/autoplay/webaudio-node-start.html [ Pass Timeout ] crbug.com/942951 media/controls/controls-layout-in-different-size.html [ Crash ] @@ -2228,6 +2223,7 @@ crbug.com/982194 external/wpt/css/css-lists/list-style-type-string-005a.html [ Failure ] crbug.com/982194 external/wpt/css/css-overflow/webkit-line-clamp-017.html [ Failure Pass ] crbug.com/982194 external/wpt/css/css-overflow/webkit-line-clamp-022.html [ Failure Pass ] +crbug.com/982194 external/wpt/css/css-overflow/webkit-line-clamp/webkit-line-clamp-with-line-height.tentative.html [ Failure ] crbug.com/982194 external/wpt/css/css-scroll-anchoring/nested-overflow-subtree-layout.html [ Failure ] crbug.com/982194 external/wpt/css/css-shapes/shape-outside/shape-image/shape-image-000.html [ Failure ] crbug.com/982194 external/wpt/css/css-shapes/shape-outside/shape-image/shape-image-013.html [ Failure ] @@ -2235,7 +2231,19 @@ crbug.com/982194 external/wpt/css/css-shapes/shape-outside/shape-image/shape-image-016.html [ Failure ] crbug.com/982194 external/wpt/css/css-shapes/shape-outside/values/shape-outside-inset-0010.html [ Failure ] crbug.com/982194 external/wpt/css/css-tables/visibility-collapse-rowspan-005.html [ Failure Pass ] +crbug.com/982194 external/wpt/css/css-text/hyphens/hyphens-overflow-001.html [ Failure ] +crbug.com/982194 external/wpt/css/css-text/hyphens/hyphens-span-001.html [ Pass ] crbug.com/982194 external/wpt/css/css-text/line-breaking/line-breaking-012.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-002.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-004.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-006.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-007.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-012.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-013.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-014.html [ Crash Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-022.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-027.html [ Failure ] +crbug.com/982194 external/wpt/css/css-ui/text-overflow-029.html [ Failure ] crbug.com/982194 external/wpt/css/css-writing-modes/float-rgt-orthog-htb-in-vrl-003.xht [ Failure ] crbug.com/982194 external/wpt/css/css-writing-modes/float-rgt-orthog-vlr-in-htb-003.xht [ Failure ] crbug.com/982194 external/wpt/css/css-writing-modes/float-rgt-orthog-vrl-in-htb-003.xht [ Failure ] @@ -2282,12 +2290,12 @@ crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemBaseHandle-postMessage-MessagePort.tentative.https.window.html [ Crash ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemBaseHandle-postMessage.tentative.https.window.html [ Crash ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-getEntries.tentative.https.any.html [ Crash Pass ] -crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-getEntries.tentative.https.any.worker.html [ Crash ] +crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-getEntries.tentative.https.any.worker.html [ Crash Pass ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-getFile.tentative.https.any.html [ Crash Pass ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-getFile.tentative.https.any.worker.html [ Crash Pass ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-removeEntry.tentative.https.any.html [ Crash Pass ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemDirectoryHandle-removeEntry.tentative.https.any.worker.html [ Crash Pass ] -crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemWriter.tentative.https.any.html [ Crash ] +crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemWriter.tentative.https.any.html [ Crash Pass ] crbug.com/982194 external/wpt/native-file-system/sandboxed_FileSystemWriter.tentative.https.any.worker.html [ Crash ] crbug.com/982194 external/wpt/speech-api/SpeechSynthesis-speak-events.html [ Failure ] crbug.com/982194 fast/block/basic/020.html [ Failure ] @@ -2339,12 +2347,30 @@ crbug.com/982194 fast/css/object-position-with-fit-cover.html [ Failure ] crbug.com/982194 fast/css/object-position-with-fit-none.html [ Failure ] crbug.com/982194 fast/css/object-position.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-bidi.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-block-with-border-and-padding.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-color.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-multiple-shadows.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-shadow-alpha.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-strict.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-text-align-center.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-text-align-justify.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-text-align-left.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-text-align-right.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-vertical-select.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis-vertical.html [ Failure ] +crbug.com/982194 fast/css/text-overflow-ellipsis.html [ Failure ] +crbug.com/982194 fast/css/vertical-text-overflow-ellipsis-text-align-center.html [ Failure ] +crbug.com/982194 fast/css/vertical-text-overflow-ellipsis-text-align-justify.html [ Failure ] +crbug.com/982194 fast/css/vertical-text-overflow-ellipsis-text-align-left.html [ Failure ] +crbug.com/982194 fast/css/vertical-text-overflow-ellipsis-text-align-right.html [ Failure ] crbug.com/982194 fast/css/word-space-extra.html [ Failure ] crbug.com/982194 fast/dynamic/002.html [ Failure ] crbug.com/982194 fast/dynamic/dirty-float-in-clean-line.html [ Failure ] crbug.com/982194 fast/dynamic/float-from-empty-line.html [ Failure ] crbug.com/982194 fast/dynamic/float-in-trailing-whitespace-after-last-line-break-2.html [ Failure ] crbug.com/982194 fast/dynamic/float-in-trailing-whitespace-after-last-line-break.html [ Failure ] +crbug.com/982194 fast/forms/button-with-ellipsis.html [ Failure ] crbug.com/982194 fast/forms/suggestion-picker/date-suggestion-picker-appearance-rtl.html [ Failure ] crbug.com/982194 fast/forms/suggestion-picker/month-suggestion-picker-appearance-rtl.html [ Failure ] crbug.com/982194 fast/forms/suggestion-picker/week-suggestion-picker-appearance-rtl.html [ Failure ] @@ -2393,7 +2419,7 @@ crbug.com/982194 http/tests/devtools/cache-storage/cache-data.js [ Pass Timeout ] crbug.com/982194 http/tests/devtools/indexeddb/database-refresh-view.js [ Pass ] crbug.com/982194 http/tests/devtools/oopif/oopif-navigator.js [ Pass Timeout ] -crbug.com/982194 http/tests/devtools/oopif/oopif-storage.js [ Pass ] +crbug.com/982194 http/tests/devtools/oopif/oopif-storage.js [ Failure Pass ] crbug.com/982194 http/tests/devtools/profiler/heap-snapshot-location.js [ Pass ] crbug.com/982194 http/tests/devtools/resource-tree/resource-tree-crafted-frame-add.js [ Pass ] crbug.com/982194 http/tests/devtools/resource-tree/resource-tree-frame-in-crafted-frame.js [ Pass ] @@ -2406,7 +2432,7 @@ crbug.com/982194 http/tests/devtools/service-workers/user-agent-override.js [ Pass ] crbug.com/982194 http/tests/devtools/sources/debugger-async/async-await/async-callstack-async-await1.js [ Crash Pass ] crbug.com/982194 http/tests/devtools/sources/debugger-async/async-callstack-events.js [ Crash Pass ] -crbug.com/982194 http/tests/devtools/sources/debugger-step/debugger-step-in-ignore-injected-script.js [ Crash Pass ] +crbug.com/982194 http/tests/devtools/sources/debugger-step/debugger-step-in.js [ Crash Pass ] crbug.com/982194 http/tests/devtools/tracing/timeline-paint/paint-profiler-update.js [ Pass ] crbug.com/982194 http/tests/devtools/tracing/timeline-style/timeline-style-recalc-with-invalidator-invalidations.js [ Pass Timeout ] crbug.com/982194 images/color-profile-svg-fill-text.html [ Failure ] @@ -2502,7 +2528,7 @@ crbug.com/982194 tables/mozilla/marvin/tables_align_right.html [ Failure ] crbug.com/982194 transforms/identity-matrix.html [ Failure ] crbug.com/982194 virtual/android/url-bar/bottom-and-top-fixed-sticks-to-top.html [ Failure ] -crbug.com/982194 virtual/audio-service/media/video-canvas-draw.html [ Failure ] +crbug.com/982194 virtual/audio-service/media/video-canvas-draw.html [ Failure Pass ] crbug.com/982194 virtual/composite-after-paint/compositing/gestures/gesture-tapHighlight-simple-scaledY.html [ Failure ] crbug.com/982194 virtual/composite-after-paint/paint/background/background-clip-text-descendants.html [ Failure ] crbug.com/982194 virtual/composite-after-paint/paint/background/scrolling-background-with-negative-z-child.html [ Pass ] @@ -2777,6 +2803,7 @@ crbug.com/982194 virtual/layout_ng_block_frag/fragmentation/fragmented-table-cell.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fragmentation/remove-unbreakable-block-in-line-float.html [ Crash ] crbug.com/982194 virtual/layout_ng_block_frag/fragmentation/transformed-clip-before-second-column.html [ Failure ] +crbug.com/982194 virtual/layout_ng_block_frag/printing/ellipsis-printing-style.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/printing/multicol-2-pages.html [ Crash ] crbug.com/591099 virtual/layout_ng_block_frag/printing/multicol.html [ Crash ] crbug.com/982194 virtual/layout_ng_block_frag/printing/page-count-layout-overflow.html [ Failure ] @@ -2871,7 +2898,7 @@ crbug.com/982194 virtual/mouseevent_fractional/fast/events/keydown-1.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/menu-key-context-menu-document-pinch-zoom.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/menu-key-context-menu-position.html [ Failure ] -crbug.com/982194 virtual/mouseevent_fractional/fast/events/menu-key-context-menu.html [ Failure ] +crbug.com/982194 virtual/mouseevent_fractional/fast/events/menu-key-context-menu.html [ Crash Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/middleClickAutoscroll-drag-scrollable-iframe-div.html [ Crash ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/middleClickAutoscroll-in-iframe.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/middleClickAutoscroll-modal-scrollable-iframe-div.html [ Crash ] @@ -2903,7 +2930,6 @@ crbug.com/722212 virtual/mouseevent_fractional/fast/events/pointerevents/mouse-pointer-event-properties.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/mouse-pointer-transition-events.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/mouse-pointer-updown-events.html [ Failure ] -crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/multi-pointer-event-in-slop-region.html [ Pass Timeout ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/pointerevent_touch-adjustment_click_target.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/touch-capture.html [ Failure ] crbug.com/982194 virtual/mouseevent_fractional/fast/events/pointerevents/touch-pointer-events.html [ Failure ] @@ -3055,7 +3081,7 @@ crbug.com/982194 virtual/scroll_customization/fast/events/touch/touch-slider-no-js-touch-listener.html [ Failure ] crbug.com/982194 virtual/scroll_customization/fast/events/touch/touch-slider.html [ Failure ] crbug.com/982194 virtual/scroll_customization/fast/scroll-behavior/subframe-interrupted-scroll.html [ Failure ] -crbug.com/982194 virtual/scroll_customization/fast/scrolling/middle-click-autoscroll-latching-clicked-node.html [ Failure ] +crbug.com/982194 virtual/scroll_customization/fast/scrolling/middle-click-autoscroll-latching-clicked-node.html [ Failure Pass ] crbug.com/982194 virtual/scroll_customization/fast/scrolling/scrollable-area-frame-overflow-hidden.html [ Failure ] crbug.com/982194 virtual/scroll_customization/fast/scrolling/scrollable-area-frame-overried-inherited-visibility-hidden.html [ Failure ] crbug.com/982194 virtual/scroll_customization/fast/scrolling/scrollable-area-frame-scrolling-yes.html [ Failure ] @@ -3091,7 +3117,63 @@ crbug.com/851363 virtual/sxg-with-network-service/http/tests/devtools/sxg/sxg-prefetch-fail.js [ Failure Pass ] crbug.com/851363 virtual/sxg-with-network-service/http/tests/devtools/sxg/sxg-prefetch.js [ Failure Pass ] crbug.com/982194 virtual/sxg-with-network-service/http/tests/loading/sxg/sxg-subresource-origin-trial.https.html [ Failure Pass ] +crbug.com/982194 virtual/text-antialias/atomic-inline-before-ellipsis.html [ Failure ] +crbug.com/982194 virtual/text-antialias/basic/014.html [ Failure ] +crbug.com/982194 virtual/text-antialias/capitalize-boundaries.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-at-edge-of-ltr-text-in-rtl-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-at-edge-of-rtl-text-in-ltr-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-in-absolute-block.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-ltr-text-in-ltr-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-ltr-text-in-ltr-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-ltr-text-in-rtl-flow-leading-space.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-ltr-text-in-rtl-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-ltr-text-in-rtl-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-mixed-text-in-ltr-flow-underline-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-mixed-text-in-ltr-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-mixed-text-in-rtl-flow-underline-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-mixed-text-in-rtl-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-platform-font-change.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-rtl-text-in-ltr-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-rtl-text-in-ltr-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-rtl-text-in-rtl-flow-underline.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-rtl-text-in-rtl-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-stroked.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-with-list-marker-in-ltr-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/ellipsis-with-list-marker-in-rtl-flow.html [ Failure ] +crbug.com/982194 virtual/text-antialias/emphasis-ellipsis-complextext.html [ Failure ] crbug.com/982194 virtual/text-antialias/emphasis-vertical.html [ Failure ] +crbug.com/982194 virtual/text-antialias/hide-atomic-inlines-after-ellipsis.html [ Failure ] +crbug.com/982194 virtual/text-antialias/hyphenate-character.html [ Failure ] +crbug.com/982194 virtual/text-antialias/hyphens/hyphens-none.html [ Failure ] +crbug.com/982194 virtual/text-antialias/hyphens/soft-hyphen-min-content.html [ Failure ] +crbug.com/982194 virtual/text-antialias/international/draw-complex-text-from-to.html [ Failure ] +crbug.com/982194 virtual/text-antialias/line-break-between-text-nodes-latin1.html [ Failure ] +crbug.com/982194 virtual/text-antialias/midword-break-after-breakable-char.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks-align-center.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks-align-justify.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks-align-left.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks-align-right.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-ellipsis-in-inline-blocks.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-center-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-center.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-justify.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-left-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-left.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-right-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks-align-right.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-mixed-ellipsis-in-inline-blocks.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks-align-center.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks-align-justify.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks-align-left.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks-align-right.html [ Failure ] +crbug.com/982194 virtual/text-antialias/place-rtl-ellipsis-in-inline-blocks.html [ Failure ] +crbug.com/982194 virtual/text-antialias/soft-hyphen-2.html [ Failure ] +crbug.com/982194 virtual/text-antialias/soft-hyphen-4.html [ Failure ] +crbug.com/982194 virtual/text-antialias/soft-hyphen-min-preferred-width.html [ Failure ] +crbug.com/982194 virtual/text-antialias/soft-hyphen-overflow.html [ Failure ] crbug.com/982194 virtual/text-antialias/softHyphen.html [ Failure ] crbug.com/982194 virtual/text-antialias/whitespace-created-when-siblings-added-back-to-front.html [ Failure ] crbug.com/982194 virtual/text-antialias/whitespace/nowrap-clear-float.html [ Failure ] @@ -3099,7 +3181,7 @@ crbug.com/982194 virtual/text-antialias/word-break.html [ Failure ] crbug.com/982194 virtual/threaded-no-composited-antialiasing/animations/inline-transform.html [ Failure ] crbug.com/982194 virtual/threaded-no-composited-antialiasing/animations/rotate-transform-equivalent.html [ Failure ] -crbug.com/982194 virtual/threaded-no-composited-antialiasing/animations/timing/animation-duration-infinite.html [ Failure ] +crbug.com/982194 virtual/threaded-no-composited-antialiasing/animations/timing/animation-duration-infinite.html [ Failure Pass ] crbug.com/982194 virtual/threaded-prefer-compositing/fast/scrolling/middle-click-autoscroll-latching-clicked-node.html [ Failure Pass ] crbug.com/982194 virtual/threaded-prefer-compositing/fast/scrolling/scrollable-area-frame-overflow-hidden.html [ Failure ] crbug.com/982194 virtual/threaded-prefer-compositing/fast/scrolling/scrollable-area-frame-overried-inherited-visibility-hidden.html [ Failure ]
diff --git a/third_party/blink/web_tests/TestExpectations b/third_party/blink/web_tests/TestExpectations index 87ebd7777..7c52b4a8 100644 --- a/third_party/blink/web_tests/TestExpectations +++ b/third_party/blink/web_tests/TestExpectations
@@ -727,7 +727,6 @@ crbug.com/591099 external/wpt/css/css-text/shaping/shaping-009.html [ Failure ] crbug.com/591099 external/wpt/css/css-text/shaping/shaping-010.html [ Failure ] crbug.com/591099 external/wpt/css/css-text/shaping/shaping-011.html [ Failure ] -crbug.com/591099 external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html [ Failure ] crbug.com/1002815 external/wpt/css/cssom-view/offsetTopLeft-trailing-space-inline.html [ Failure ] crbug.com/1012294 external/wpt/css/css-lists/list-style-type-string-003.html [ Failure ] crbug.com/1012294 external/wpt/css/css-lists/list-style-type-string-007.html [ Failure ] @@ -1024,7 +1023,6 @@ crbug.com/988015 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-dynamic-add-003.html [ Failure ] crbug.com/994172 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-dynamic-add-007.html [ Failure Crash ] crbug.com/924142 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-dynamic-add-010.html [ Crash Pass ] -crbug.com/988015 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-dynamic-add-013.html [ Failure ] crbug.com/874051 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-fieldset-001.html [ Failure ] crbug.com/874051 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-fieldset-002.html [ Failure ] crbug.com/874051 virtual/layout_ng_block_frag/external/wpt/css/css-multicol/multicol-span-all-fieldset-003.html [ Failure ] @@ -1141,6 +1139,7 @@ crbug.com/954171 virtual/layout_ng_block_frag/fast/multicol/float-with-margin-moved-by-child-line-and-unbreakable.html [ Failure Crash ] crbug.com/954171 virtual/layout_ng_block_frag/fast/multicol/float-with-margin-moved-by-child-line.html [ Failure Crash ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/float-with-margin-moved-unbreakable.html [ Failure ] +crbug.com/829028 virtual/layout_ng_block_frag/fast/multicol/focus-outline.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/forced-break-after-block-with-spanner.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/forced-break-after-empty-block-after-spanner.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/forced-break-after-last-block-before-spanner.html [ Failure ] @@ -1208,7 +1207,6 @@ crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/positive-leading.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/pushed-line-affected-by-float.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/relayout-and-push-float.html [ Failure ] -crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/rule-in-nested-with-too-tall-line.html [ Failure ] crbug.com/714962 virtual/layout_ng_block_frag/fast/multicol/scale-transform-text.html [ Failure ] crbug.com/874506 virtual/layout_ng_block_frag/fast/multicol/scrollable-basic.html [ Failure ] crbug.com/591099 virtual/layout_ng_block_frag/fast/multicol/scrolling-overflow.html [ Failure ] @@ -2047,8 +2045,6 @@ crbug.com/626703 external/wpt/css/css-text/word-break/word-break-break-all-007.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/word-break/word-break-break-all-006.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/word-break/word-break-break-all-008.html [ Failure ] -crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-004.html [ Failure ] -crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-007.html [ Failure ] crbug.com/626703 [ Linux ] external/wpt/css/css-text/word-break/word-break-normal-bo-000.html [ Failure ] crbug.com/626703 [ Win ] external/wpt/css/css-text/word-break/word-break-normal-km-000.html [ Failure ] crbug.com/626703 external/wpt/css/css-text/word-break/word-break-normal-my-000.html [ Failure ] @@ -2789,6 +2785,18 @@ crbug.com/1022141 virtual/speech-with-unified-autoplay/external/wpt/speech-api/SpeechSynthesis-speak-events.html [ Crash Timeout ] # ====== New tests from wpt-importer added here ====== +crbug.com/626703 [ Linux ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Mac10.11 ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Mac10.12 ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Mac10.13 ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Retina ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Win ] external/wpt/input-events/input-events-typing.html [ Timeout ] +crbug.com/626703 [ Linux ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] +crbug.com/626703 [ Mac10.11 ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] +crbug.com/626703 [ Mac10.12 ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] +crbug.com/626703 [ Mac10.13 ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] +crbug.com/626703 [ Retina ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] +crbug.com/626703 [ Win ] external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html [ Failure ] crbug.com/626703 external/wpt/streams/readable-byte-streams/construct-byob-request.any.sharedworker.html [ Timeout ] crbug.com/626703 [ Linux ] external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel.https.html [ Timeout ] crbug.com/626703 [ Mac ] external/wpt/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/window-iframe-messagechannel.https.html [ Timeout ] @@ -3843,10 +3851,12 @@ crbug.com/626703 [ Win ] external/wpt/css/css-writing-modes/box-offsets-rel-pos-vlr-005.xht [ Failure ] crbug.com/626703 [ Win ] external/wpt/css/css-writing-modes/box-offsets-rel-pos-vrl-004.xht [ Failure ] -crbug.com/1020749 external/wpt/css/css-text/overflow-wrap/overflow-wrap-anywhere-inline-002.html [ Failure ] -crbug.com/1020749 external/wpt/css/css-text/overflow-wrap/overflow-wrap-anywhere-inline-003.html [ Failure ] -crbug.com/1020749 external/wpt/css/css-text/word-break/word-break-break-all-inline-009.html [ Failure ] -crbug.com/1020749 external/wpt/css/css-text/word-break/word-break-break-all-inline-010.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/overflow-wrap/overflow-wrap-anywhere-inline-002.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/overflow-wrap/overflow-wrap-anywhere-inline-003.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-004.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-007.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-009.html [ Failure ] +crbug.com/964181 external/wpt/css/css-text/word-break/word-break-break-all-inline-010.html [ Failure ] # Sheriff 2019-08-19: crbug.com/626703 external/wpt/html/cross-origin-embedder-policy/none.https.html [ Failure ]
diff --git a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json index 7b43560..d9623a8 100644 --- a/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json +++ b/third_party/blink/web_tests/external/WPT_BASE_MANIFEST_6.json
@@ -5893,12 +5893,6 @@ {} ] ], - "input-events/input-events-typing-manual.html": [ - [ - "input-events/input-events-typing-manual.html", - {} - ] - ], "mediacapture-depth/dictionary-manual.https.html": [ [ "mediacapture-depth/dictionary-manual.https.html", @@ -53009,450 +53003,6 @@ {} ] ], - "css/css-intrinsic-size/intrinsic-size-001.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-001.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-001-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-002.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-002.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-002-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-003.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-003.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-003-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-004.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-004.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-004-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-005.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-005.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-004-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-006.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-006.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-006-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-007.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-007.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-007-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-008.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-008.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-008-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-009.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-009.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-009-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-010.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-010.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-010-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-011.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-011.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-011-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-012.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-012.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-012-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-013.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-013.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-013-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-014.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-014.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-014-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-015.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-015.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-015-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-016.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-016.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-016-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-017.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-017.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-017-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-018.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-018.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-018-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-019.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-019.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-019-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-020.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-020.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-020-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-021.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-021.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-021-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-022.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-022.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-022-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-023.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-023.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-023-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-024.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-024.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-024-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-025.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-025.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-025-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-026.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-026.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-026-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-001.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-auto-001.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-auto-001-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-002.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-auto-002.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-auto-002-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-003.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-auto-003.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-auto-003-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-001.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-001.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-001-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-002.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-002.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-002-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-003.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-003.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-003-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-004.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-004.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-004-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-005.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-005.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-005-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-006.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-006.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-006-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-007.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-007.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-007-ref.html", - "==" - ] - ], - {} - ] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-008.html": [ - [ - "css/css-intrinsic-size/intrinsic-size-with-legacy-008.html", - [ - [ - "/css/css-intrinsic-size/intrinsic-size-with-legacy-008-ref.html", - "==" - ] - ], - {} - ] - ], "css/css-layout-api/auto-block-size/absolute.https.html": [ [ "css/css-layout-api/auto-block-size/absolute.https.html", @@ -55433,6 +54983,18 @@ {} ] ], + "css/css-lists/ol-change-display-type.html": [ + [ + "css/css-lists/ol-change-display-type.html", + [ + [ + "/css/css-lists/ol-change-display-type-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-logical/cascading-001.html": [ [ "css/css-logical/cascading-001.html", @@ -63353,6 +62915,18 @@ {} ] ], + "css/css-pseudo/first-line-with-before-after.html": [ + [ + "css/css-pseudo/first-line-with-before-after.html", + [ + [ + "/css/css-pseudo/first-line-with-before-after-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-pseudo/first-line-with-out-of-flow.html": [ [ "css/css-pseudo/first-line-with-out-of-flow.html", @@ -64337,6 +63911,18 @@ {} ] ], + "css/css-scroll-anchoring/nested-overflow-subtree-layout.html": [ + [ + "css/css-scroll-anchoring/nested-overflow-subtree-layout.html", + [ + [ + "/css/css-scroll-anchoring/nested-overflow-subtree-layout-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-scroll-snap/scroll-target-align-001.html": [ [ "css/css-scroll-snap/scroll-target-align-001.html", @@ -66233,6 +65819,450 @@ {} ] ], + "css/css-sizing/intrinsic-size/intrinsic-size-001.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-001.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-001-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-002.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-002.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-002-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-003.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-003.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-003-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-004.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-004.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-005.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-005.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-006.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-006.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-006-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-007.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-007.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-007-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-008.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-008.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-008-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-009.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-009.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-009-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-010.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-010.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-010-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-011.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-011.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-011-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-012.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-012.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-012-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-013.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-013.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-013-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-014.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-014.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-014-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-015.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-015.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-015-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-016.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-016.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-016-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-017.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-017.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-017-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-018.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-018.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-018-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-019.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-019.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-019-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-020.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-020.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-020-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-021.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-021.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-021-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-022.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-022.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-022-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-023.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-023.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-023-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-024.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-024.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-024-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-025.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-025.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-025-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-026.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-026.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-026-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008.html": [ + [ + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008.html", + [ + [ + "/css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-sizing/orthogonal-writing-mode-float-in-inline.html": [ [ "css/css-sizing/orthogonal-writing-mode-float-in-inline.html", @@ -70305,6 +70335,318 @@ {} ] ], + "css/css-text/line-break/line-break-anywhere-017.html": [ + [ + "css/css-text/line-break/line-break-anywhere-017.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-001.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-001.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-002.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-002.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-003.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-003.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-004.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-004.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-005.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-005.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-006.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-006.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-007.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-007.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-008.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-008.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-009.html": [ + [ + "css/css-text/line-break/line-break-anywhere-and-white-space-009.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-012.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-012.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-013.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-013.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-014.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-014.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html": [ + [ + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html", + [ + [ + "/css/css-text/line-break/reference/line-break-anywhere-004-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-text/line-break/line-break-loose-011.xht": [ [ "css/css-text/line-break/line-break-loose-011.xht", @@ -71241,6 +71583,30 @@ {} ] ], + "css/css-text/overflow-wrap/overflow-wrap-anywhere-009.html": [ + [ + "css/css-text/overflow-wrap/overflow-wrap-anywhere-009.html", + [ + [ + "/css/css-text/overflow-wrap/reference/overflow-wrap-break-word-001-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/overflow-wrap/overflow-wrap-anywhere-010.html": [ + [ + "css/css-text/overflow-wrap/overflow-wrap-anywhere-010.html", + [ + [ + "/css/css-text/overflow-wrap/reference/overflow-wrap-break-word-001-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-text/overflow-wrap/overflow-wrap-anywhere-fit-content-001.html": [ [ "css/css-text/overflow-wrap/overflow-wrap-anywhere-fit-content-001.html", @@ -71409,6 +71775,30 @@ {} ] ], + "css/css-text/overflow-wrap/overflow-wrap-break-word-009.html": [ + [ + "css/css-text/overflow-wrap/overflow-wrap-break-word-009.html", + [ + [ + "/css/css-text/overflow-wrap/reference/overflow-wrap-break-word-001-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/overflow-wrap/overflow-wrap-break-word-010.html": [ + [ + "css/css-text/overflow-wrap/overflow-wrap-break-word-010.html", + [ + [ + "/css/css-text/overflow-wrap/reference/overflow-wrap-break-word-001-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-text/overflow-wrap/overflow-wrap-break-word-fit-content-001.html": [ [ "css/css-text/overflow-wrap/overflow-wrap-break-word-fit-content-001.html", @@ -76877,6 +77267,30 @@ {} ] ], + "css/css-text/word-break/word-break-break-all-029.html": [ + [ + "css/css-text/word-break/word-break-break-all-029.html", + [ + [ + "/css/css-text/word-break/reference/word-break-break-all-010-ref.html", + "==" + ] + ], + {} + ] + ], + "css/css-text/word-break/word-break-break-all-030.html": [ + [ + "css/css-text/word-break/word-break-break-all-030.html", + [ + [ + "/css/css-text/word-break/reference/word-break-break-all-010-ref.html", + "==" + ] + ], + {} + ] + ], "css/css-text/word-break/word-break-break-all-inline-001.html": [ [ "css/css-text/word-break/word-break-break-all-inline-001.html", @@ -126439,9 +126853,15 @@ "client-hints/accept-ch-cache-revalidation.https.html.headers": [ [] ], + "client-hints/accept-ch-feature-policy-navigation.https.html.headers": [ + [] + ], "client-hints/accept-ch-lifetime.tentative.https-expected.txt": [ [] ], + "client-hints/accept-ch-no-feature-policy-navigation.https.html.headers": [ + [] + ], "client-hints/accept_ch.http.html.headers": [ [] ], @@ -126490,15 +126910,27 @@ "client-hints/resources/dpr.py": [ [] ], + "client-hints/resources/expect-client-hints-headers-iframe.py": [ + [] + ], "client-hints/resources/expect_client_hints_headers.html": [ [] ], + "client-hints/resources/feature-policy-navigation.js": [ + [] + ], "client-hints/resources/http_equiv_accept_ch_lifetime.html": [ [] ], "client-hints/resources/http_equiv_accept_ch_lifetime.html.headers": [ [] ], + "client-hints/resources/iframe-accept-ch-lifetime.html": [ + [] + ], + "client-hints/resources/iframe-accept-ch-lifetime.html.headers": [ + [] + ], "client-hints/resources/sec-ch-ua.py": [ [] ], @@ -126511,9 +126943,6 @@ "client-hints/sec-ch-quotes.https.html.headers": [ [] ], - "client-hints/sec-ch-ua.https-expected.txt": [ - [] - ], "clipboard-apis/META.yml": [ [] ], @@ -126808,12 +127237,6 @@ "console/OWNERS": [ [] ], - "console/idlharness.any-expected.txt": [ - [] - ], - "console/idlharness.any.worker-expected.txt": [ - [] - ], "contacts/OWNERS": [ [] ], @@ -140479,120 +140902,6 @@ "css/css-inline/parsing/dominant-baseline-valid-expected.txt": [ [] ], - "css/css-intrinsic-size/intrinsic-size-001-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-002-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-003-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-004-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-005-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-006-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-007-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-008-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-009-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-010-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-011-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-012-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-013-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-014-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-015-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-016-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-017-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-018-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-019-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-020-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-021-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-022-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-023-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-024-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-025-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-026-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-001-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-002-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-003-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-001-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-002-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-003-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-004-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-005-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-006-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-007-ref.html": [ - [] - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-008-ref.html": [ - [] - ], - "css/css-intrinsic-size/resources/dice.png": [ - [] - ], "css/css-layout-api/META.yml": [ [] ], @@ -140803,6 +141112,9 @@ "css/css-lists/nested-marker-ref.html": [ [] ], + "css/css-lists/ol-change-display-type-ref.html": [ + [] + ], "css/css-lists/parsing/content-invalid-expected.txt": [ [] ], @@ -142243,6 +142555,9 @@ "css/css-pseudo/first-line-on-ancestor-block-ref.html": [ [] ], + "css/css-pseudo/first-line-with-before-after-ref.html": [ + [] + ], "css/css-pseudo/first-line-with-out-of-flow-ref.html": [ [] ], @@ -142384,6 +142699,9 @@ "css/css-scroll-anchoring/multicol-fragmented-anchor-expected.txt": [ [] ], + "css/css-scroll-anchoring/nested-overflow-subtree-layout-ref.html": [ + [] + ], "css/css-scroll-anchoring/opt-out-dynamic-expected.txt": [ [] ], @@ -142810,6 +143128,120 @@ "css/css-sizing/intrinsic-percent-non-replaced-005-ref.html": [ [] ], + "css/css-sizing/intrinsic-size/intrinsic-size-001-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-002-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-003-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-004-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-005-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-006-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-007-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-008-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-009-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-010-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-011-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-012-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-013-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-014-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-015-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-016-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-017-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-018-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-019-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-020-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-021-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-022-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-023-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-024-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-025-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-026-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008-ref.html": [ + [] + ], + "css/css-sizing/intrinsic-size/resources/dice.png": [ + [] + ], "css/css-sizing/parsing/height-valid-expected.txt": [ [] ], @@ -152458,9 +152890,6 @@ "css/vendor-imports/mozilla/mozilla-central-reftests/writing-modes-3/text-orientation-upright-directionality-001-ref.html": [ [] ], - "custom-elements/CustomElementRegistry-expected.txt": [ - [] - ], "custom-elements/HTMLElement-constructor-expected.txt": [ [] ], @@ -154747,6 +155176,9 @@ "feature-policy/resources/feature-policy-picture-in-picture.html": [ [] ], + "feature-policy/resources/feature-policy-report-json.js": [ + [] + ], "feature-policy/resources/feature-policy-serial-worker.html": [ [] ], @@ -155317,6 +155749,9 @@ "fetch/http-cache/resources/securedimage.py": [ [] ], + "fetch/http-cache/resources/split-origin-popup.html": [ + [] + ], "fetch/http-cache/vary-expected.txt": [ [] ], @@ -157390,6 +157825,9 @@ "html/cross-origin-opener-policy/coop-sandbox.https.html.headers": [ [] ], + "html/cross-origin-opener-policy/no-https-expected.txt": [ + [] + ], "html/cross-origin-opener-policy/no-https.html.headers": [ [] ], @@ -160267,6 +160705,9 @@ "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-worker-success.any.sharedworker-expected.txt": [ [] ], + "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-worker-success.https-expected.txt": [ + [] + ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-worker-success.https.html.headers": [ [] ], @@ -160510,12 +160951,18 @@ "html/interaction/focus/the-autofocus-attribute/resources/grand-child-autofocus.html": [ [] ], + "html/interaction/focus/the-autofocus-attribute/resources/imagemap.html": [ + [] + ], "html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html": [ [] ], "html/interaction/focus/the-autofocus-attribute/resources/utils.js": [ [] ], + "html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt": [ + [] + ], "html/obsolete/META.yml": [ [] ], @@ -162130,6 +162577,12 @@ "html/semantics/interactive-elements/the-dialog-element/centering-iframe.sub.html": [ [] ], + "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once-expected.txt": [ + [] + ], + "html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus-expected.txt": [ + [] + ], "html/semantics/interactive-elements/the-dialog-element/dialog-showModal-expected.txt": [ [] ], @@ -163879,6 +164332,18 @@ "infrastructure/expected-fail/failing-test-expected.txt": [ [] ], + "infrastructure/expected-fail/precondition-expected.txt": [ + [] + ], + "infrastructure/expected-fail/precondition-in-promise-expected.txt": [ + [] + ], + "infrastructure/expected-fail/precondition-in-setup-expected.txt": [ + [] + ], + "infrastructure/expected-fail/precondition-without-setup-expected.txt": [ + [] + ], "infrastructure/expected-fail/uncaught-exception-expected.txt": [ [] ], @@ -163909,6 +164374,18 @@ "infrastructure/metadata/infrastructure/expected-fail/failing-test.html.ini": [ [] ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-in-promise.html.ini": [ + [] + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-in-setup.html.ini": [ + [] + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-without-setup.html.ini": [ + [] + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition.html.ini": [ + [] + ], "infrastructure/metadata/infrastructure/expected-fail/timeout.html.ini": [ [] ], @@ -163993,6 +164470,9 @@ "infrastructure/metadata/infrastructure/testdriver/actions/multiDevice.html.ini": [ [] ], + "infrastructure/metadata/infrastructure/testdriver/actions/multiTouchPoints.html.ini": [ + [] + ], "infrastructure/metadata/infrastructure/testdriver/actions/pause.html.ini": [ [] ], @@ -164005,6 +164485,9 @@ "infrastructure/metadata/infrastructure/testdriver/generate_test_report.html.ini": [ [] ], + "infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini": [ + [] + ], "infrastructure/reftest-wait-ref.html": [ [] ], @@ -164050,6 +164533,9 @@ "infrastructure/testdriver/send_keys-expected.txt": [ [] ], + "infrastructure/testdriver/virtual_authenticator-expected.txt": [ + [] + ], "infrastructure/webdriver/tests/conftest.py": [ [] ], @@ -165055,6 +165541,9 @@ "mathml/relations/html5-tree/href-click-2-ref.html": [ [] ], + "mathml/relations/html5-tree/href-click-3-expected.txt": [ + [] + ], "mathml/relations/html5-tree/integration-point-1-ref.html": [ [] ], @@ -165064,6 +165553,9 @@ "mathml/relations/html5-tree/integration-point-3-ref.html": [ [] ], + "mathml/relations/html5-tree/math-global-event-handlers.tentative-expected.txt": [ + [] + ], "mathml/relations/html5-tree/required-extensions-2-ref.html": [ [] ], @@ -172021,6 +172513,9 @@ "std-toast/resources/helpers.js": [ [] ], + "storage-access-api/META.yml": [ + [] + ], "storage-access-api/helpers.js": [ [] ], @@ -176767,6 +177262,9 @@ "trusted-types/support/worker.js": [ [] ], + "trusted-types/trusted-types-duplicate-names-list-report-only.tentative.html.headers": [ + [] + ], "trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html.headers": [ [] ], @@ -177742,6 +178240,9 @@ "web-animations/animation-model/keyframe-effects/effect-value-replaced-animations-expected.txt": [ [] ], + "web-animations/idlharness.window-expected.txt": [ + [] + ], "web-animations/interfaces/Animatable/animate-expected.txt": [ [] ], @@ -178540,7 +179041,7 @@ "webgpu/suites/cts/validation/validation_test.js": [ [] ], - "webgpu/suites/cts/validation/vertex_input.spec.js": [ + "webgpu/suites/cts/validation/vertex_state.spec.js": [ [] ], "webmessaging/META.yml": [ @@ -178720,6 +179221,9 @@ "webrtc/RTCPeerConnection-helper.js": [ [] ], + "webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt": [ + [] + ], "webrtc/RTCPeerConnection-iceGatheringState-expected.txt": [ [] ], @@ -186680,6 +187184,12 @@ {} ] ], + "2dcontext/transformations/2d.transformation.getTransform.html": [ + [ + "2dcontext/transformations/2d.transformation.getTransform.html", + {} + ] + ], "2dcontext/transformations/2d.transformation.order.html": [ [ "2dcontext/transformations/2d.transformation.order.html", @@ -188855,6 +189365,38 @@ {} ] ], + "IndexedDB/idbindex_reverse_cursor.any.js": [ + [ + "IndexedDB/idbindex_reverse_cursor.any.html", + { + "script_metadata": [ + [ + "title", + "Reverse Cursor Validity" + ], + [ + "script", + "support-promises.js" + ] + ] + } + ], + [ + "IndexedDB/idbindex_reverse_cursor.any.worker.html", + { + "script_metadata": [ + [ + "title", + "Reverse Cursor Validity" + ], + [ + "script", + "support-promises.js" + ] + ] + } + ] + ], "IndexedDB/idbkeyrange-includes.htm": [ [ "IndexedDB/idbkeyrange-includes.htm", @@ -200477,6 +201019,12 @@ {} ] ], + "client-hints/accept-ch-feature-policy-navigation.https.html": [ + [ + "client-hints/accept-ch-feature-policy-navigation.https.html", + {} + ] + ], "client-hints/accept-ch-lifetime.tentative.https.html": [ [ "client-hints/accept-ch-lifetime.tentative.https.html", @@ -200485,6 +201033,12 @@ } ] ], + "client-hints/accept-ch-no-feature-policy-navigation.https.html": [ + [ + "client-hints/accept-ch-no-feature-policy-navigation.https.html", + {} + ] + ], "client-hints/accept_ch.http.html": [ [ "client-hints/accept_ch.http.html", @@ -209426,6 +209980,36 @@ {} ] ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html": [ + [ + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html", + {} + ] + ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html": [ + [ + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html", + {} + ] + ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding.html": [ + [ + "css/css-grid/alignment/grid-align-justify-margin-border-padding.html", + {} + ] + ], + "css/css-grid/alignment/grid-align-justify-overflow.html": [ + [ + "css/css-grid/alignment/grid-align-justify-overflow.html", + {} + ] + ], + "css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html": [ + [ + "css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html", + {} + ] + ], "css/css-grid/alignment/grid-align-justify-stretch.html": [ [ "css/css-grid/alignment/grid-align-justify-stretch.html", @@ -211436,102 +212020,6 @@ {} ] ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-computed.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-block-size-computed.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-invalid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-block-size-invalid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-valid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-block-size-valid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-height-computed.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-height-computed.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-height-invalid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-height-invalid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-height-valid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-height-valid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-computed.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-inline-size-computed.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-invalid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-inline-size-invalid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-valid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-inline-size-valid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-size-computed.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-size-computed.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-size-invalid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-size-invalid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-size-valid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-size-valid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-width-computed.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-width-computed.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-width-invalid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-width-invalid.html", - {} - ] - ], - "css/css-intrinsic-size/parsing/intrinsic-width-valid.html": [ - [ - "css/css-intrinsic-size/parsing/intrinsic-width-valid.html", - {} - ] - ], "css/css-layout-api/at-supports-rule.https.html": [ [ "css/css-layout-api/at-supports-rule.https.html", @@ -215036,6 +215524,102 @@ {} ] ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-computed.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-computed.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-invalid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-invalid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-valid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-valid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-computed.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-computed.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-invalid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-invalid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-valid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-valid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-computed.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-computed.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-invalid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-invalid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-valid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-valid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-computed.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-computed.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-invalid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-invalid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-valid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-valid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-computed.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-computed.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-invalid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-invalid.html", + {} + ] + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-valid.html": [ + [ + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-valid.html", + {} + ] + ], "css/css-sizing/min-max-content-orthogonal-flow-crash-001.html": [ [ "css/css-sizing/min-max-content-orthogonal-flow-crash-001.html", @@ -241701,6 +242285,12 @@ } ] ], + "fetch/http-cache/split-cache.tentative.html": [ + [ + "fetch/http-cache/split-cache.tentative.html", + {} + ] + ], "fetch/http-cache/status.html": [ [ "fetch/http-cache/status.html", @@ -251766,6 +252356,12 @@ {} ] ], + "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html": [ + [ + "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html", + {} + ] + ], "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html": [ [ "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html", @@ -251790,6 +252386,12 @@ {} ] ], + "html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html": [ + [ + "html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html", + {} + ] + ], "html/semantics/interactive-elements/the-dialog-element/dialog-open.html": [ [ "html/semantics/interactive-elements/the-dialog-element/dialog-open.html", @@ -257771,6 +258373,30 @@ {} ] ], + "infrastructure/expected-fail/precondition-in-promise.html": [ + [ + "infrastructure/expected-fail/precondition-in-promise.html", + {} + ] + ], + "infrastructure/expected-fail/precondition-in-setup.html": [ + [ + "infrastructure/expected-fail/precondition-in-setup.html", + {} + ] + ], + "infrastructure/expected-fail/precondition-without-setup.html": [ + [ + "infrastructure/expected-fail/precondition-without-setup.html", + {} + ] + ], + "infrastructure/expected-fail/precondition.html": [ + [ + "infrastructure/expected-fail/precondition.html", + {} + ] + ], "infrastructure/expected-fail/timeout.html": [ [ "infrastructure/expected-fail/timeout.html", @@ -258184,6 +258810,14 @@ } ] ], + "infrastructure/testdriver/virtual_authenticator.html": [ + [ + "infrastructure/testdriver/virtual_authenticator.html", + { + "testdriver": true + } + ] + ], "input-device-capabilities/idlharness.window.js": [ [ "input-device-capabilities/idlharness.window.html", @@ -258224,6 +258858,14 @@ {} ] ], + "input-events/input-events-typing.html": [ + [ + "input-events/input-events-typing.html", + { + "testdriver": true + } + ] + ], "intersection-observer/bounding-box.html": [ [ "intersection-observer/bounding-box.html", @@ -273959,6 +274601,12 @@ {} ] ], + "offscreen-canvas/transformations/2d.transformation.getTransform.html": [ + [ + "offscreen-canvas/transformations/2d.transformation.getTransform.html", + {} + ] + ], "offscreen-canvas/transformations/2d.transformation.order.html": [ [ "offscreen-canvas/transformations/2d.transformation.order.html", @@ -303739,9 +304387,9 @@ {} ] ], - "trusted-types/TrustedTypePolicy-name.tentative.html": [ + "trusted-types/TrustedTypePolicy-getPolicyNames.tentative.html": [ [ - "trusted-types/TrustedTypePolicy-name.tentative.html", + "trusted-types/TrustedTypePolicy-getPolicyNames.tentative.html", {} ] ], @@ -303903,6 +304551,36 @@ {} ] ], + "trusted-types/eval-csp-no-tt.tentative.html": [ + [ + "trusted-types/eval-csp-no-tt.tentative.html", + {} + ] + ], + "trusted-types/eval-csp-tt-default-policy.tentative.html": [ + [ + "trusted-types/eval-csp-tt-default-policy.tentative.html", + {} + ] + ], + "trusted-types/eval-csp-tt-no-default-policy.tentative.html": [ + [ + "trusted-types/eval-csp-tt-no-default-policy.tentative.html", + {} + ] + ], + "trusted-types/eval-no-csp-no-tt-default-policy.tentative.html": [ + [ + "trusted-types/eval-no-csp-no-tt-default-policy.tentative.html", + {} + ] + ], + "trusted-types/eval-no-csp-no-tt.tentative.html": [ + [ + "trusted-types/eval-no-csp-no-tt.tentative.html", + {} + ] + ], "trusted-types/eval-with-permissive-csp.tentative.html": [ [ "trusted-types/eval-with-permissive-csp.tentative.html", @@ -303932,6 +304610,24 @@ {} ] ], + "trusted-types/trusted-types-duplicate-names-list-report-only.tentative.html": [ + [ + "trusted-types/trusted-types-duplicate-names-list-report-only.tentative.html", + {} + ] + ], + "trusted-types/trusted-types-duplicate-names-list.tentative.html": [ + [ + "trusted-types/trusted-types-duplicate-names-list.tentative.html", + {} + ] + ], + "trusted-types/trusted-types-duplicate-names.tentative.html": [ + [ + "trusted-types/trusted-types-duplicate-names.tentative.html", + {} + ] + ], "trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html": [ [ "trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html", @@ -303998,6 +304694,14 @@ } ] ], + "uievents/click/click_events_on_input.html": [ + [ + "uievents/click/click_events_on_input.html", + { + "testdriver": true + } + ] + ], "uievents/click/mouse-dblclick-event.html": [ [ "uievents/click/mouse-dblclick-event.html", @@ -314133,7 +314837,7 @@ {} ], [ - "webgpu/cts.html?q=cts:validation/vertex_input:", + "webgpu/cts.html?q=cts:validation/vertex_state:", {} ] ], @@ -337430,6 +338134,10 @@ "6d5f8f660fa3fbc8e2b8b8710070241ccde392d0", "support" ], + "2dcontext/transformations/2d.transformation.getTransform.html": [ + "664efd50e63dc0fc9396857d957cee0fe38f6901", + "testharness" + ], "2dcontext/transformations/2d.transformation.order.html": [ "df0ab55f7dc53ee76fee70b00bab17e23f47ce7e", "testharness" @@ -337795,7 +338503,7 @@ "support" ], "CONTRIBUTING.md": [ - "baa208e30f4eca8ca10c0e9cb6f89f2d0a726f2b", + "54d963d7adbd9d0ab22ef331d0f5d56240c82e90", "support" ], "FileAPI/BlobURL/support/file_test2.txt": [ @@ -338954,6 +339662,10 @@ "bf134dff18a3bf6278b0c659b32e01652e4b984b", "testharness" ], + "IndexedDB/idbindex_reverse_cursor.any.js": [ + "0b3c767fee17cb2739bd49a05237beaea5129e20", + "testharness" + ], "IndexedDB/idbkeyrange-includes.htm": [ "aea588051aeaab63c3855a778b22d1a6932d78ff", "testharness" @@ -339639,7 +340351,7 @@ "support" ], "README.md": [ - "43cc6b862fd1ee3681b4faff8885332588679fb5", + "e3ee8551ff48a77652e2a4dc4fbc677e0812c5c5", "support" ], "WebCryptoAPI/META.yml": [ @@ -342166,6 +342878,14 @@ "05b7a4a6f6fcb91b18f2a0e767010e81c9329fb8", "support" ], + "client-hints/accept-ch-feature-policy-navigation.https.html": [ + "dff960d28709ae6888f0da0b221e93c7b160e7e6", + "testharness" + ], + "client-hints/accept-ch-feature-policy-navigation.https.html.headers": [ + "f9595a794d9c93dca09f371f5797399a9204ed53", + "support" + ], "client-hints/accept-ch-lifetime.tentative.https-expected.txt": [ "82dd11219ee834333b642eb1b283088a90c60052", "support" @@ -342174,6 +342894,14 @@ "f0b03ba0a8c311642af793a341653995fb73cbd9", "testharness" ], + "client-hints/accept-ch-no-feature-policy-navigation.https.html": [ + "5fb6c22f50873ce597e6d5ed04c1ebeef64a17c1", + "testharness" + ], + "client-hints/accept-ch-no-feature-policy-navigation.https.html.headers": [ + "7eb28a000bdde9634e618701e2ba512e4a9ebc49", + "support" + ], "client-hints/accept_ch.http.html": [ "50d77646f89aea13c212c6ecee4e7f32107007e9", "testharness" @@ -342263,7 +342991,7 @@ "support" ], "client-hints/resources/accept_ch_lifetime.html.headers": [ - "bd90f6eced08859fc8918757538c255be3b2a1db", + "370f9869226db4bdf8785c876b13d69b415e5abf", "support" ], "client-hints/resources/clear-site-data.html": [ @@ -342282,10 +343010,18 @@ "14d7d550fe28d49a63105ea966d3cf7cf59901b1", "support" ], + "client-hints/resources/expect-client-hints-headers-iframe.py": [ + "e72d77c47d9aae36c619e8e065e5685f7a9c166b", + "support" + ], "client-hints/resources/expect_client_hints_headers.html": [ "8e64b1989ab2046952f91920245423caebb2a706", "support" ], + "client-hints/resources/feature-policy-navigation.js": [ + "4487d9a447313f87dd2f230ce7d858b38008fae8", + "support" + ], "client-hints/resources/http_equiv_accept_ch_lifetime.html": [ "ab2ab9e60c8a4ee6d4fc088fb6c8d4d6d0daffd6", "support" @@ -342294,6 +343030,14 @@ "27140bf36e4dbd22b8f7190587f42a570c9d12bd", "support" ], + "client-hints/resources/iframe-accept-ch-lifetime.html": [ + "693e4f94dcc3363f0d15e7c7a18a7a598c72cf77", + "support" + ], + "client-hints/resources/iframe-accept-ch-lifetime.html.headers": [ + "8e6dc72dda620dc0508d02009e6cc58631a00e7b", + "support" + ], "client-hints/resources/sec-ch-ua.py": [ "a14a27dadf9e333784a5c636c821634b387e475f", "support" @@ -342318,10 +343062,6 @@ "e333c605301e621133ee5e6f3d01e2525d5c058a", "testharness" ], - "client-hints/sec-ch-ua.https-expected.txt": [ - "0bed3d3b8ad9e7882b8f420cd09684208bf31042", - "support" - ], "client-hints/sec-ch-ua.https.html": [ "b293745365a611475697aaa7b66a8a809cad7b3c", "testharness" @@ -342495,7 +343235,7 @@ "support" ], "common/security-features/resources/common.sub.js": [ - "f7abd3eca1e6f04ace967f5579db33a1ee76b8a7", + "b43417b417c189d1e1b3444baa286456df979bb5", "support" ], "common/security-features/resources/common.sub.js.headers": [ @@ -342950,18 +343690,10 @@ "3b9e5cea21da8e98a2bb8306ed9d5e642134ee5c", "manual" ], - "console/idlharness.any-expected.txt": [ - "fc9c75ddb20380912b05806a7a9d013f0960f414", - "support" - ], "console/idlharness.any.js": [ "1e7ba76ecddca2ad707784a7ff6edfc270428c26", "testharness" ], - "console/idlharness.any.worker-expected.txt": [ - "fc9c75ddb20380912b05806a7a9d013f0960f414", - "support" - ], "contacts/OWNERS": [ "bb162e9181809ae7f97a15c1427d0836db644222", "support" @@ -383542,6 +384274,26 @@ "fb3f7007ee19189a09de9c1f786176c317b7ee14", "testharness" ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html": [ + "9c9e944df04b58a11f0b3096d50b94ddc4f326db", + "testharness" + ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html": [ + "f7698e45df39855d53c2c205cd034fd04524568a", + "testharness" + ], + "css/css-grid/alignment/grid-align-justify-margin-border-padding.html": [ + "9cdce092cc302ccbb3d4ed7633c19696b481b241", + "testharness" + ], + "css/css-grid/alignment/grid-align-justify-overflow.html": [ + "f0d94198aff6dddb7acab1e7965e1ca9fc84c4a3", + "testharness" + ], + "css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html": [ + "c8fd340006038b1bd7addd84e2bd013da389bbed", + "testharness" + ], "css/css-grid/alignment/grid-align-justify-stretch.html": [ "9feeed3e0ef2a17b68bce2b7d71cbdb14a06ee2d", "testharness" @@ -386910,370 +387662,6 @@ "d51c759dcc5d7f7e2820751e7a5a7f39dcf91bf1", "testharness" ], - "css/css-intrinsic-size/intrinsic-size-001-ref.html": [ - "d4f0281ae48cd9ab43403fcbfc0c50d8c96e1381", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-001.html": [ - "43c18a0e670b33162b38f845dd860caee9f4efae", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-002-ref.html": [ - "ab847fc36e56155a0b3638a24f9ca90077c76b23", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-002.html": [ - "d7c34558d3b7b3291826ad9c3df4e8f7c4a25fe6", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-003-ref.html": [ - "6a2d05149894c0e7ecfc5471bab6055bc51f072d", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-003.html": [ - "da51eb3fc309dc7463a5e5ff06a468efbd0507b6", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-004-ref.html": [ - "6e710943de9957bcda6ac83985615e35f2154d1e", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-004.html": [ - "f24ffbecee80ddeaca75ec972b513a68eb0ceba0", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-005-ref.html": [ - "950f7190cac250124ba5cda419a71126e157d2e0", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-005.html": [ - "ffbfe8b1ec79b4c13121a0c22b3f2265dd52b9c2", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-006-ref.html": [ - "d545093e2db58163637e466b233cd15da40d0f7b", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-006.html": [ - "3540df2734e46bbdecdf4c48b70e9c1d69bb3a16", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-007-ref.html": [ - "6b3f63685ac07bb0e5f95570744a7b87c56158f6", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-007.html": [ - "b0ff2c89e8ea7ab6ff961b7076d798ac7aedc268", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-008-ref.html": [ - "5c6186fd48cf0dfd2ee83fd6ed2819fa6dbb0989", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-008.html": [ - "27178f67d4929e15cc823d25f81072707fa09aa2", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-009-ref.html": [ - "223e0c8a33a6832e37dc4b78de4c27b5a3abcc11", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-009.html": [ - "3d837b9b9bb8b475747a66bb6f5652fb8bade000", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-010-ref.html": [ - "eaaa0977f139938e2657814fd78d543f2bc5e0db", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-010.html": [ - "73d23c732c6775ab6948d38ee3dcf59f05da16fa", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-011-ref.html": [ - "29d1f4e2d1a108dd53c5905e45d9c7923ca9a2ba", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-011.html": [ - "d050160f7f78fb9596caeb7e48740f8d8cb64944", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-012-ref.html": [ - "ed9857aa2565762f514fe5fb73173b6a5da6494f", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-012.html": [ - "a5ba04751cd92e889c3d27892abd7d0413ff35a6", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-013-ref.html": [ - "9f8334c03d508bc1d91d0163674a28c89c77e034", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-013.html": [ - "dca4c17f7bd9822ad1db78dee371b928923b8acc", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-014-ref.html": [ - "66c10824893089e0c78dd5f6f68e167eac7438b6", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-014.html": [ - "d69f58fd2ec2ee696a4cf65e1cda9832ddad45b9", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-015-ref.html": [ - "ae65a3b5ca547b19e8bdc7b38099c8206edfa6c4", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-015.html": [ - "c7a977540dde36d40d7499ea2c3c89f3ba32a653", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-016-ref.html": [ - "f80510f630624b7bce27483fe9847cd182114fe0", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-016.html": [ - "2c1c917b4f8221096d905ced69f4e92e5172843a", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-017-ref.html": [ - "553451a7075559dad575be17e2ce08b62cb67832", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-017.html": [ - "d9d33477834bcdc00d57cbe2f465dd3538e487bc", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-018-ref.html": [ - "17261caa8af2b65f80ed331fb38bb5c2e37d5b10", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-018.html": [ - "e31b0a412eda0ad07c741c032be6f9bb0b848434", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-019-ref.html": [ - "8e55d7b02f9d1d7352ebdeeca1ee48a1009b49f4", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-019.html": [ - "571863939c57c1d37f617aca3bbb75da05d858de", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-020-ref.html": [ - "1ee5ba8376ddc7e6bb74d765755fbe89b9e33b6b", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-020.html": [ - "c4055bb09d4aff664e7d1fe89b19014f9448a2b3", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-021-ref.html": [ - "35db43fcf44a3668ae19f0d97ea7a872223fcc9c", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-021.html": [ - "93e610be7acf8353db9d63ee8cc3192b9ca24e68", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-022-ref.html": [ - "b0df199283470db4a7ecba4011a3429e8065bb7e", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-022.html": [ - "5331df38fed841d17d8a7899abe93d5193866249", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-023-ref.html": [ - "800e4ae706447004c3c8ff5bf8a530216cba1dea", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-023.html": [ - "aa946e82ac760b784f261b958e834b6540bf00c4", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-024-ref.html": [ - "02ec85a0084910bb09de2e7871b7ddd7d8a68265", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-024.html": [ - "f9fdd8848fe8942acb7b3eb3750840a0318426ec", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-025-ref.html": [ - "60d5cc9cd9aadb99620773ea11eaf9e2081b771b", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-025.html": [ - "d80b9772e5aef7be64188943ae7a3ab5cd8a74f0", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-026-ref.html": [ - "2e456b43422c014a10c62fe93c776c43ad59581a", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-026.html": [ - "fb5412bed8f18cea23b8966f7227a03d743a4f06", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-001-ref.html": [ - "99e86d0c38fd2b76745b6cbd05224dc5aa0537d6", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-001.html": [ - "41b89e3d5aae831fed4d76008867f07e12596664", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-002-ref.html": [ - "70a245469b702bb5b2348ca7698c71ac1ca99671", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-002.html": [ - "446f2154de81c5e33462e325739edb1f2c0854b5", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-003-ref.html": [ - "246a5bad51ed6155177a7f1fb11705c4ca7dd944", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-auto-003.html": [ - "c5da41152863551a6977aeed6b9cb937a77da0a1", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-001-ref.html": [ - "39c6abdcf8eba74a04c1255388ca551cf8988ed5", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-001.html": [ - "e565b56fe98d61022f5cfc184706325ad98a9101", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-002-ref.html": [ - "535915a7a7bed54142f731a21eb20a97379650a1", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-002.html": [ - "bc1141822a66c4560a6cc75f69f890f95d9d233c", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-003-ref.html": [ - "eb6394fe28464f74106c99830d67af1efa58aba4", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-003.html": [ - "78502f4bd645e47658358d760f67dae2b5a02a1e", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-004-ref.html": [ - "d5e7c9ff9bb9c4f155955065161e14f1fcbc954e", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-004.html": [ - "7187222c4ce55dfd827ea81fd3ac0e841b652b7c", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-005-ref.html": [ - "c23984f5f1a4d07c2121088987718781d00fc85c", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-005.html": [ - "0ec60fdaa3353e0a799838ce61eccd3f3ae6b264", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-006-ref.html": [ - "9b9e25d3c8da8693f82bfa7d49e87a320bb3f141", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-006.html": [ - "e4882539b82b691256e6d1af5cdb700411810502", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-007-ref.html": [ - "6894b4643ad616d4acf3a631c991718c76cdae27", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-007.html": [ - "0e749f7038c83382aa43ae152e6537714b893c73", - "reftest" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-008-ref.html": [ - "5cce190275940e70c3e3451a47ed9432025dab46", - "support" - ], - "css/css-intrinsic-size/intrinsic-size-with-legacy-008.html": [ - "973683aac4208fc6c379ec5541a56b7029c965f3", - "reftest" - ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-computed.html": [ - "e9a073ca2aacd9dd9fce6a1b0d33493498b33bac", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-invalid.html": [ - "1b6cba20f88d78f8e29d385676a261d6d78c8e67", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-block-size-valid.html": [ - "b34c73b230f50d00371811ec063180bfc249fad7", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-height-computed.html": [ - "6f95274c637a54bd88b1bf5e732b8a6aaa291e32", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-height-invalid.html": [ - "1f801124a2b5f2fe3cf96c76b9b64fe33d9f50da", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-height-valid.html": [ - "e461476211879b903e451e662ad393162a94afdd", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-computed.html": [ - "c53a77e5631068101f4d58a9a67d6db8b9c8c2a3", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-invalid.html": [ - "6ad224d11d3831ba227fc41ab90bf0c3b748be46", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-inline-size-valid.html": [ - "ad5aef95dca952785a8263a7b6447ef4e4b83e03", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-size-computed.html": [ - "29be33d4a3d9a33ec30cfe150f9c9f80d5fd796d", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-size-invalid.html": [ - "b4cb2dbffd2004762d028f092e82e5f9297655ec", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html": [ - "e70c3179223eaf220edd3993069848b8e0294dea", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-size-valid.html": [ - "7ab13c7d7986151f22e01711f34a9184effca082", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-width-computed.html": [ - "08602e5347f3de0827446875b15a29c8b6789b27", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-width-invalid.html": [ - "b89f6567ae27595ac752ece8bfe66784d16146de", - "testharness" - ], - "css/css-intrinsic-size/parsing/intrinsic-width-valid.html": [ - "e2d23eabe5da207ce82519e9f57adcbd4cf5d70c", - "testharness" - ], - "css/css-intrinsic-size/resources/dice.png": [ - "c82d01517cd056fe1b63266b00fb9a96ce6251a2", - "support" - ], "css/css-layout-api/META.yml": [ "c85c2d4ccc0b02f3e22ca444952fb7583d96e7c7", "support" @@ -388159,7 +388547,7 @@ "testharness" ], "css/css-lists/list-inside-contain.html": [ - "dc06eab97ea648bb598cdbfae5ac43d61847e8ae", + "70e25b8644e5e7c7398e734611e7dd46a4db8f2b", "testharness" ], "css/css-lists/list-item-definition-ref.html": [ @@ -388290,6 +388678,14 @@ "9627ce936ae570325b430a1ac673cd66ae7d4252", "reftest" ], + "css/css-lists/ol-change-display-type-ref.html": [ + "a10bc17899f9cfaa938d04d198598c4fc82fe3ca", + "support" + ], + "css/css-lists/ol-change-display-type.html": [ + "e711cfef5ddfd0d85914ce166f774a2ec1480f05", + "reftest" + ], "css/css-lists/parsing/content-invalid-expected.txt": [ "22f1ec89c1c6018a435f0242db81371dc747a5d2", "support" @@ -394062,6 +394458,14 @@ "6b797107df80156b511b9dc58c5ee40d6114cfc4", "reftest" ], + "css/css-pseudo/first-line-with-before-after-ref.html": [ + "fcee7995052717c0509c58a76fa1f420434ceb43", + "support" + ], + "css/css-pseudo/first-line-with-before-after.html": [ + "f91a22a4a7d65366dbd7dda3934c82c9b5776977", + "reftest" + ], "css/css-pseudo/first-line-with-out-of-flow-ref.html": [ "7193bf25eb88c5443457480f7ce27782acd9473a", "support" @@ -394675,7 +395079,7 @@ "support" ], "css/css-scroll-anchoring/README.md": [ - "8ce2a95c620b5a25c31a4d8d4bca251904d0fa32", + "78f1387bdf47e987da47861a8f0be5ddcd4fba6a", "support" ], "css/css-scroll-anchoring/abspos-containing-block-outside-scroller.html": [ @@ -394782,6 +395186,14 @@ "e1ce331f1affaf15e312f2c720a38acaa11b60a5", "testharness" ], + "css/css-scroll-anchoring/nested-overflow-subtree-layout-ref.html": [ + "77b0de7f0ba16a35398c3a8d583c5bda32bf16af", + "support" + ], + "css/css-scroll-anchoring/nested-overflow-subtree-layout.html": [ + "e7696016bb31fde98a57cd8ef2b3f78551350d40", + "reftest" + ], "css/css-scroll-anchoring/opt-out-dynamic-expected.txt": [ "8769b1c7b492b3e610729b0fe25e3017fc5e12b7", "support" @@ -396858,6 +397270,370 @@ "bce0a18be6f66e57cad2e2e90694a6f53dab71c7", "reftest" ], + "css/css-sizing/intrinsic-size/intrinsic-size-001-ref.html": [ + "d4f0281ae48cd9ab43403fcbfc0c50d8c96e1381", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-001.html": [ + "4d17602a95f91af86ef16825203e903d841e68cc", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-002-ref.html": [ + "ab847fc36e56155a0b3638a24f9ca90077c76b23", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-002.html": [ + "55f209494125e08900b60bc566b5c85d0d123d54", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-003-ref.html": [ + "6a2d05149894c0e7ecfc5471bab6055bc51f072d", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-003.html": [ + "3dd41ba1d2c001bcaaec7ea8338bcb3cce41d52e", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-004-ref.html": [ + "6e710943de9957bcda6ac83985615e35f2154d1e", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-004.html": [ + "9cce7ae25fc8f343e9a693e1ee6ef92847e71ece", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-005-ref.html": [ + "950f7190cac250124ba5cda419a71126e157d2e0", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-005.html": [ + "92b777d22e054bef9d675f00b7d67845f17081df", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-006-ref.html": [ + "d545093e2db58163637e466b233cd15da40d0f7b", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-006.html": [ + "82c6e8eef8536cb95f291828107a53a97a1d1428", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-007-ref.html": [ + "6b3f63685ac07bb0e5f95570744a7b87c56158f6", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-007.html": [ + "85fcae6cd91ba8a2f9404497992ba5b7d6411ad9", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-008-ref.html": [ + "5c6186fd48cf0dfd2ee83fd6ed2819fa6dbb0989", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-008.html": [ + "f3b344f6b0a79464090434127309f724ab4ba64e", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-009-ref.html": [ + "223e0c8a33a6832e37dc4b78de4c27b5a3abcc11", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-009.html": [ + "06a02fe78bd08602c14f890ae4bb374076807789", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-010-ref.html": [ + "eaaa0977f139938e2657814fd78d543f2bc5e0db", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-010.html": [ + "eea76ffb07325ac9268581f9b2db348f8301e4df", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-011-ref.html": [ + "29d1f4e2d1a108dd53c5905e45d9c7923ca9a2ba", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-011.html": [ + "c7888f906f8b7ec92648a7cb5b4b18df2bbeaad5", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-012-ref.html": [ + "ed9857aa2565762f514fe5fb73173b6a5da6494f", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-012.html": [ + "889b07ace922271e335054992d6731264a291c9f", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-013-ref.html": [ + "9f8334c03d508bc1d91d0163674a28c89c77e034", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-013.html": [ + "1082100012fd890d466cbea1aafe8c1101ebc945", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-014-ref.html": [ + "66c10824893089e0c78dd5f6f68e167eac7438b6", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-014.html": [ + "4dd45a2da409449d225c6768d2e19564f0b567d6", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-015-ref.html": [ + "ae65a3b5ca547b19e8bdc7b38099c8206edfa6c4", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-015.html": [ + "5ca5e49992e1d537499bc8ea314229bdfdc5bfc7", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-016-ref.html": [ + "f80510f630624b7bce27483fe9847cd182114fe0", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-016.html": [ + "ce6ac5c56e4a101fda21a46dc37d81ebee4b1dd5", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-017-ref.html": [ + "553451a7075559dad575be17e2ce08b62cb67832", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-017.html": [ + "5e2122f34ecf8e74e54c8b101772de0f9be0cdb6", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-018-ref.html": [ + "17261caa8af2b65f80ed331fb38bb5c2e37d5b10", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-018.html": [ + "68931834d630410e1ca9906db8a97317b26ee062", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-019-ref.html": [ + "8e55d7b02f9d1d7352ebdeeca1ee48a1009b49f4", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-019.html": [ + "cae8e0739fe823e82369fa5661a7f70b4dd30e0f", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-020-ref.html": [ + "1ee5ba8376ddc7e6bb74d765755fbe89b9e33b6b", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-020.html": [ + "a7286ce1054cae30cb8023cae074d9be8781fa33", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-021-ref.html": [ + "35db43fcf44a3668ae19f0d97ea7a872223fcc9c", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-021.html": [ + "04591924f659615dc22851102f5d59b4d83e5e18", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-022-ref.html": [ + "b0df199283470db4a7ecba4011a3429e8065bb7e", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-022.html": [ + "3593b9cce38f158bf96164ba1e8110c09eedbc01", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-023-ref.html": [ + "800e4ae706447004c3c8ff5bf8a530216cba1dea", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-023.html": [ + "c64ef66a03fd18b57e34ade82bd538e33578f129", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-024-ref.html": [ + "02ec85a0084910bb09de2e7871b7ddd7d8a68265", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-024.html": [ + "b11317d96b015282e9bcc043efcdbba799851bc6", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-025-ref.html": [ + "60d5cc9cd9aadb99620773ea11eaf9e2081b771b", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-025.html": [ + "ab9c56fc528ed848a200a890e0df3cc018618529", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-026-ref.html": [ + "2e456b43422c014a10c62fe93c776c43ad59581a", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-026.html": [ + "100f542b783794dbf5c07ac146f1e0ee5f481db7", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001-ref.html": [ + "99e86d0c38fd2b76745b6cbd05224dc5aa0537d6", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-001.html": [ + "9c2dac07da2b012a4e927916cd18f980a15d9e68", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002-ref.html": [ + "70a245469b702bb5b2348ca7698c71ac1ca99671", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-002.html": [ + "5b3902455bdccd8d16f8e9795e3821f5ab73799a", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003-ref.html": [ + "246a5bad51ed6155177a7f1fb11705c4ca7dd944", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-auto-003.html": [ + "07ec0326787f96e08654f9643e7032309c62bfaa", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001-ref.html": [ + "39c6abdcf8eba74a04c1255388ca551cf8988ed5", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-001.html": [ + "df662e5c7f17342a0facdf2c614689833b4a424b", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002-ref.html": [ + "535915a7a7bed54142f731a21eb20a97379650a1", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-002.html": [ + "66d008ce6cef7cfe93d097a362e6cfba57b57a7a", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003-ref.html": [ + "eb6394fe28464f74106c99830d67af1efa58aba4", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-003.html": [ + "90e4f53bf64fe4d9eb9c19036abdccea98a582bf", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004-ref.html": [ + "d5e7c9ff9bb9c4f155955065161e14f1fcbc954e", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-004.html": [ + "dfeed45d73b91e620a8d3aefe8461af2c21c3e86", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005-ref.html": [ + "c23984f5f1a4d07c2121088987718781d00fc85c", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-005.html": [ + "baf9bef3aca6ae9d9c6026d993dda9e4584e78e3", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006-ref.html": [ + "9b9e25d3c8da8693f82bfa7d49e87a320bb3f141", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-006.html": [ + "41ef1fddc19d6ba3ec3ee6c6adfce4d51d078929", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007-ref.html": [ + "6894b4643ad616d4acf3a631c991718c76cdae27", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-007.html": [ + "df2c57b5d8a7f884a31934a15cc1e1037d3a6c8e", + "reftest" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008-ref.html": [ + "5cce190275940e70c3e3451a47ed9432025dab46", + "support" + ], + "css/css-sizing/intrinsic-size/intrinsic-size-with-legacy-008.html": [ + "45b8fbdd24484d6d2637d440edad3dc3e959cadf", + "reftest" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-computed.html": [ + "e9a073ca2aacd9dd9fce6a1b0d33493498b33bac", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-invalid.html": [ + "1b6cba20f88d78f8e29d385676a261d6d78c8e67", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-block-size-valid.html": [ + "b34c73b230f50d00371811ec063180bfc249fad7", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-computed.html": [ + "6f95274c637a54bd88b1bf5e732b8a6aaa291e32", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-invalid.html": [ + "1f801124a2b5f2fe3cf96c76b9b64fe33d9f50da", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-height-valid.html": [ + "e461476211879b903e451e662ad393162a94afdd", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-computed.html": [ + "c53a77e5631068101f4d58a9a67d6db8b9c8c2a3", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-invalid.html": [ + "6ad224d11d3831ba227fc41ab90bf0c3b748be46", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-inline-size-valid.html": [ + "ad5aef95dca952785a8263a7b6447ef4e4b83e03", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-computed.html": [ + "29be33d4a3d9a33ec30cfe150f9c9f80d5fd796d", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-invalid.html": [ + "b4cb2dbffd2004762d028f092e82e5f9297655ec", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-sets-computed-dimensions.html": [ + "e70c3179223eaf220edd3993069848b8e0294dea", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-size-valid.html": [ + "7ab13c7d7986151f22e01711f34a9184effca082", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-computed.html": [ + "08602e5347f3de0827446875b15a29c8b6789b27", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-invalid.html": [ + "b89f6567ae27595ac752ece8bfe66784d16146de", + "testharness" + ], + "css/css-sizing/intrinsic-size/parsing/intrinsic-width-valid.html": [ + "e2d23eabe5da207ce82519e9f57adcbd4cf5d70c", + "testharness" + ], + "css/css-sizing/intrinsic-size/resources/dice.png": [ + "c82d01517cd056fe1b63266b00fb9a96ce6251a2", + "support" + ], "css/css-sizing/min-max-content-orthogonal-flow-crash-001.html": [ "d2617f8aa2d1c966e394abb1d1617c012ea4648e", "testharness" @@ -401830,6 +402606,110 @@ "5f80f52c6ea0c5c9c7577896b9bc5d309093c90e", "reftest" ], + "css/css-text/line-break/line-break-anywhere-017.html": [ + "a2521cbcbbe1c16e0d71d22d33b90429ae8e1ed7", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-001.html": [ + "a4158dc990798d7868332eeb245137bac74e8b87", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-002.html": [ + "2fbb53dca21179e679a1d8523ac75e8b712dbb37", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-003.html": [ + "3002dc106487187da90af9bbd39e84d7d5cfe535", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-004.html": [ + "e6e1b39787d50178bb152e6459e624c84df97e99", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-005.html": [ + "2f64d8704bac8d3ad85bad41c05b5b490a3b34de", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-006.html": [ + "c804e37126266852909a3bf2054a4446105496be", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-007.html": [ + "d9b266db9f95db5eaa45c12709125155faa46f41", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-008.html": [ + "aebd31ea6851cc3fcef469d50bf320d1914395c4", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-and-white-space-009.html": [ + "f536c907a4004ca7ff7c7fcec9e99f7c5a5cd25c", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-001.html": [ + "d18df4b38c65c3a46ba0c68e7f57a6512a2eb86a", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-002.html": [ + "1255aa14d38589dfaaa46446e3e77409910abd55", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-003.html": [ + "7fe230e890dbbb206107fc64631439c8dde26ae4", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-004.html": [ + "13706d5d9dc4bd44c40bd416051997cb43f3a3d7", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-005.html": [ + "175228d9c52ac7eb08958f22bc23f2f0aea290ce", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-006.html": [ + "9bb557e7d3b01e0af7b14ebd67726eb9666f79a7", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-007.html": [ + "7f90bfd43049337d66054804dd351f8877d73973", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-008.html": [ + "40826540c9f5de0cb135f111812cda54f579e02e", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-009.html": [ + "6d6ca3f743a7a68db65c6df70c04726c1e1d519d", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-010.html": [ + "5f152c66294e4ea8bebbc229288f7ed43d80d59d", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-011.html": [ + "2196d983f9f9fa140e2d7b71689ecf62417609ae", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-012.html": [ + "110d9cafc4c3aa98b07f9fd5e4ffecde6467ffbd", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-013.html": [ + "2cda76c5cd324ffeb0573b9c87c579f19fc4a641", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-014.html": [ + "d79efb7aee83eca68b72f33c0a6d7b00e90eaa1f", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-015.html": [ + "5eecd03da25ec0cfa2f2f22b1adb658d4c83e55c", + "reftest" + ], + "css/css-text/line-break/line-break-anywhere-overrides-uax-behavior-016.html": [ + "d4ab337a7b5d5a77063bc9ed024336f061346229", + "reftest" + ], "css/css-text/line-break/line-break-loose-011.xht": [ "604466a1f4723f5da0e74682643b4fcd746852d0", "reftest" @@ -402378,6 +403258,14 @@ "ddb95629999d3599d972de5cf19afaa9378d6d06", "reftest" ], + "css/css-text/overflow-wrap/overflow-wrap-anywhere-009.html": [ + "90f2ad3337305bc1f59194a582373851577eadaa", + "reftest" + ], + "css/css-text/overflow-wrap/overflow-wrap-anywhere-010.html": [ + "0b4b75bc1c5d3daf6ecedc146c2f693de7dc8b17", + "reftest" + ], "css/css-text/overflow-wrap/overflow-wrap-anywhere-fit-content-001.html": [ "8655b1f087df4534f59ea7c6348fe3272f84ccbf", "reftest" @@ -402438,6 +403326,14 @@ "8a0fb9959d697f9d4188a0fd49973d90d8143ab3", "reftest" ], + "css/css-text/overflow-wrap/overflow-wrap-break-word-009.html": [ + "fbbcf2233c5a2666bcccb3941bd76b6383410530", + "reftest" + ], + "css/css-text/overflow-wrap/overflow-wrap-break-word-010.html": [ + "da45dea2530dd19a2cecf3dc8ceb160d2d9a9d34", + "reftest" + ], "css/css-text/overflow-wrap/overflow-wrap-break-word-fit-content-001.html": [ "2c83c46aa50f6d51efbb4d05635d86f7c166042d", "reftest" @@ -406174,6 +407070,14 @@ "48f60a346115a576cf63c5222dd68aeeda91fb13", "reftest" ], + "css/css-text/word-break/word-break-break-all-029.html": [ + "3e0a1e14e6952d756a64e7b16a8b7b0af84dd2ff", + "reftest" + ], + "css/css-text/word-break/word-break-break-all-030.html": [ + "e6a8a0076d4bd80b7eca2a1cf7c568ccf38ac332", + "reftest" + ], "css/css-text/word-break/word-break-break-all-inline-001.html": [ "a0c7c4958bd94be3ae199e6e18f1dace4cc2d28b", "reftest" @@ -406211,7 +407115,7 @@ "reftest" ], "css/css-text/word-break/word-break-break-all-inline-010.html": [ - "875a36233c555e9b99822773d39f960b579d16f6", + "3c2df3cea296b32b4bb4972ed50e28e9d3f5427b", "reftest" ], "css/css-text/word-break/word-break-break-word-crash-001.html": [ @@ -434190,10 +435094,6 @@ "695e489df3ceb99ec911c05e99f14e1c1b1fe8fb", "reftest" ], - "custom-elements/CustomElementRegistry-expected.txt": [ - "2f827d6db402cb0dc950048dc8e3024b83785d77", - "support" - ], "custom-elements/CustomElementRegistry.html": [ "c288e8232703afbe00d355ef5b40bdc8d1fa0ac2", "testharness" @@ -436055,7 +436955,7 @@ "testharness" ], "dom/nodes/aria-element-reflection.tentative.html": [ - "7c8e690a28bbcaa1391878300f143aa1e584fe5e", + "1ee896ea1be0cae1613a880fbdea547f1894839f", "testharness" ], "dom/nodes/attributes.html": [ @@ -440947,7 +441847,7 @@ "support" ], "feature-policy/reporting/oversized-images-reporting.html": [ - "baa866d0a1c4777ab2ef6fcd894624b85ec72ae4", + "ef365e060c4e4d883051c5ad70f10ffe9139d5a2", "testharness" ], "feature-policy/reporting/oversized-images-reporting.html.headers": [ @@ -440971,7 +441871,7 @@ "support" ], "feature-policy/reporting/payment-reporting.https.html": [ - "6655210f6846b8e07a80e699cda69e4d1f11a3b2", + "80d0b0f09069e1027777afbf2ee17ff877f4dd55", "testharness" ], "feature-policy/reporting/payment-reporting.https.html.headers": [ @@ -441019,7 +441919,7 @@ "support" ], "feature-policy/reporting/sync-xhr-reporting.html": [ - "d92a68588eb847735cd9d505c186f1765a978288", + "9e526b904d4b825771b6b318677df0aded67637b", "testharness" ], "feature-policy/reporting/sync-xhr-reporting.html.headers": [ @@ -441130,6 +442030,10 @@ "2f33c449536d1b0253a9a1c0b52073bc500121f3", "support" ], + "feature-policy/resources/feature-policy-report-json.js": [ + "08a0ecaded8c5af917be1ae1287d455483205e45", + "support" + ], "feature-policy/resources/feature-policy-serial-worker.html": [ "9e6a7d02ba2b8eef1fcc12d8049af830688e6946", "support" @@ -442583,7 +443487,7 @@ "testharness" ], "fetch/http-cache/http-cache.js": [ - "3f4a2e7ed7fcc216fbc130de294eb045333ed9d5", + "ce49ad853631c3d2f88c5d4dc0fe807cbfa9e605", "support" ], "fetch/http-cache/invalidate-expected.txt": [ @@ -442611,13 +443515,21 @@ "testharness" ], "fetch/http-cache/resources/http-cache.py": [ - "e64fe6dfea0e5e9d0bd267f464aa828a0bd35342", + "351b2eb3c9eec006d8976dc5fad1f6db990cd733", "support" ], "fetch/http-cache/resources/securedimage.py": [ "445b0bdd2ec95a1ac9be08228503475b386cf961", "support" ], + "fetch/http-cache/resources/split-origin-popup.html": [ + "d94ac7f70bde7a6e7795b4412b12f2828e27bf48", + "support" + ], + "fetch/http-cache/split-cache.tentative.html": [ + "533dd6a936fef7c6036bba42fbd7d0d71222a192", + "testharness" + ], "fetch/http-cache/status.html": [ "d55d9e3cf24a496316677a8be9d1d54d21d9c3b8", "testharness" @@ -442915,7 +443827,7 @@ "testharness" ], "fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt": [ - "f6bcb6a644e174c4ff9d355088acb06d97adc0e3", + "7de9bd5483e44db3af2b121a794fb95e6b1d3b9c", "support" ], "fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub.html": [ @@ -444611,7 +445523,7 @@ "support" ], "graphics-aam/graphics-document_on_html_element-manual-expected.txt": [ - "2be084657e7fd50672e879b777bbfcfe73d7def7", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-document_on_html_element-manual.html": [ @@ -444619,7 +445531,7 @@ "manual" ], "graphics-aam/graphics-document_on_svg_element-manual-expected.txt": [ - "6a1b58d535dbc57ff27e94b83a142da3525de7f9", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-document_on_svg_element-manual.html": [ @@ -444627,7 +445539,7 @@ "manual" ], "graphics-aam/graphics-object_on_html_element-manual-expected.txt": [ - "f73591664c791683144cca2cc3acb0b87085b3b2", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-object_on_html_element-manual.html": [ @@ -444635,7 +445547,7 @@ "manual" ], "graphics-aam/graphics-object_on_svg_element-manual-expected.txt": [ - "e5649930c442892f8c19fabeeac7fdbeb1349ab2", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-object_on_svg_element-manual.html": [ @@ -444643,7 +445555,7 @@ "manual" ], "graphics-aam/graphics-symbol_on_html_element-manual-expected.txt": [ - "f57f1a03b605a9097be05eb3bbad798ce2bb984c", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-symbol_on_html_element-manual.html": [ @@ -444651,7 +445563,7 @@ "manual" ], "graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt": [ - "98a13d50378d91884a2cba6033c2b6cf28191074", + "2d3316614eda1ab25e0159cdc8943b1604364394", "support" ], "graphics-aam/graphics-symbol_on_svg_element-manual.html": [ @@ -447819,7 +448731,7 @@ "support" ], "html/cross-origin-opener-policy/coep.https-expected.txt": [ - "9d1840b5d00669c95b021589311721b923f68bcd", + "1bafd5c64254df00d9681048d3e2e3c3d6904a98", "support" ], "html/cross-origin-opener-policy/coep.https.html": [ @@ -447854,6 +448766,10 @@ "46ad58d83bf6e98913ca4c564b7acb8f19fa0093", "support" ], + "html/cross-origin-opener-policy/no-https-expected.txt": [ + "9cd8ef4d5ac82b925031ad0a6bfe876cd26e05fc", + "support" + ], "html/cross-origin-opener-policy/no-https.html": [ "014ba1f333b5e254609819bd99618ebcc6b7391b", "testharness" @@ -449055,7 +449971,7 @@ "testharness" ], "html/dom/idlharness.https_exclude=(Document_Window_HTML._)-expected.txt": [ - "3b82a104f43fb94aeff5723060a83fe9edda6dd5", + "819e356e4a5213b4ba02d2a736dc40aa06608b7c", "support" ], "html/dom/idlharness.https_include=(Document_Window)-expected.txt": [ @@ -449067,7 +449983,7 @@ "support" ], "html/dom/idlharness.worker-expected.txt": [ - "544c73866c221387f9657a96417ec5f21525ff8b", + "88f80ee37ace8c1b006bd7fd398cb365f3f24869", "support" ], "html/dom/idlharness.worker.js": [ @@ -452855,7 +453771,7 @@ "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-sharedworker-success.https-expected.txt": [ - "7b70ea298989ba1aeafd5cadeff2dd50b97c56e2", + "d6e67e08d848e33f1e01a2152763b42f5c554013", "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-sharedworker-success.https.html": [ @@ -452874,6 +453790,10 @@ "7b70ea298989ba1aeafd5cadeff2dd50b97c56e2", "support" ], + "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-worker-success.https-expected.txt": [ + "0c7bb4bfa2b87750878dbdab8e18be23445dfd94", + "support" + ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-worker-success.https.html": [ "aeee3705aea4bf54d2073392451df2d238045627", "testharness" @@ -452883,7 +453803,7 @@ "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any-expected.txt": [ - "03e29e361a979b99ae058233eededfdc13bfa7d7", + "3d3e7c3b7ea1f788899b6c5714963bd607f51bbe", "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.js": [ @@ -452891,7 +453811,7 @@ "testharness" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-coop-coep.https.any.worker-expected.txt": [ - "660041682dcbd8f3e1c7b839d86c49530fe8b20f", + "35419f631e286abf7d883b3a59650eded11250f9", "support" ], "html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/no-transferring.https.html": [ @@ -453155,7 +454075,7 @@ "support" ], "html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt": [ - "49cfaffa99e610674e3b40f6b529b2d3e2a49b0c", + "da3565ae96cfe4914316f723150e122f01bd7813", "support" ], "html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js": [ @@ -453446,6 +454366,10 @@ "88be6e0b04a99b8477925107e1f534024f021b5e", "support" ], + "html/interaction/focus/the-autofocus-attribute/resources/imagemap.html": [ + "fa3d95c81b433e8964a574148fb4310efe267082", + "support" + ], "html/interaction/focus/the-autofocus-attribute/resources/moving-autofocus-to-parent.html": [ "fc6c298a46e376cf45089f168cf841cab59ffd5c", "support" @@ -453478,8 +454402,12 @@ "22a4c3573cccf909d3a5675db2aab97a4f366bc0", "testharness" ], + "html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt": [ + "7d272ee01e172ce27ef7639148d274894884fd53", + "support" + ], "html/interaction/focus/the-autofocus-attribute/supported-elements.html": [ - "761936715a3060ba4c6cca1068612c21c465ea02", + "29b3f3fb7b6c361ac6f6435f8ddf8ac4b0302b65", "testharness" ], "html/interaction/focus/the-autofocus-attribute/update-the-rendering.html": [ @@ -460118,6 +461046,14 @@ "8df2d3052320bbfebc8184b3f426405b398dc632", "testharness" ], + "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once-expected.txt": [ + "711dc73a530c83d810f2fe9515ebcdb4001412c0", + "support" + ], + "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html": [ + "894efd59dc290d682b6732e49782606a90f4fad1", + "testharness" + ], "html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-multiple-times.html": [ "ff9ebd7d2868ca732a9f4eff8558b461fd14154c", "testharness" @@ -460134,6 +461070,14 @@ "87a130c6f0178de695a1f9ebd8c000dabf3e53c3", "testharness" ], + "html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus-expected.txt": [ + "6b55e9ffbf5e38d1b922f7a081748354e64f66ed", + "support" + ], + "html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html": [ + "2e8563f761dd5538185c988dc63008e2ecf25c0c", + "testharness" + ], "html/semantics/interactive-elements/the-dialog-element/dialog-open.html": [ "4719f63b853ded4577d09066eb7ef2cedf7cd934", "testharness" @@ -465942,12 +466886,44 @@ "249099c06f6c08e92bd1bc6752f57a436ebf9ae0", "testharness" ], + "infrastructure/expected-fail/precondition-expected.txt": [ + "55b65f4659b4c6658ed50a793c1377b5ef78d54f", + "support" + ], + "infrastructure/expected-fail/precondition-in-promise-expected.txt": [ + "4b71dc975d904e1dcf31e10a5b21c846896aab97", + "support" + ], + "infrastructure/expected-fail/precondition-in-promise.html": [ + "b2a32facad07150258cae3af857c841eb6e2cfae", + "testharness" + ], + "infrastructure/expected-fail/precondition-in-setup-expected.txt": [ + "6f2395e83faf22f586b3bd177194ac832cbdde37", + "support" + ], + "infrastructure/expected-fail/precondition-in-setup.html": [ + "071f140afb6a4b3244dc6793c2ff304d80df4891", + "testharness" + ], + "infrastructure/expected-fail/precondition-without-setup-expected.txt": [ + "a96b3ea4e820302afda6d748f4ea13e3abc7c428", + "support" + ], + "infrastructure/expected-fail/precondition-without-setup.html": [ + "12188dbdaeb516c8f67cedf78b0989720c81fdac", + "testharness" + ], + "infrastructure/expected-fail/precondition.html": [ + "2e6ddc1d02cc77d4068c1bb2997780f6a03d579d", + "testharness" + ], "infrastructure/expected-fail/timeout.html": [ "29ff348a9af645ff59d860e91af9534e64a606c5", "testharness" ], "infrastructure/expected-fail/uncaught-exception-expected.txt": [ - "1765dd9a78463a3870edf2bf464943e9b5c788f0", + "49826f883dcee8a79f6bdc523640e4dbf93cc97a", "support" ], "infrastructure/expected-fail/uncaught-exception-following-subtest-expected.txt": [ @@ -465971,7 +466947,7 @@ "testharness" ], "infrastructure/expected-fail/unhandled-rejection-expected.txt": [ - "3a828c8d0a58d7faedb6b89ef5e60c57599efad9", + "1d0b2e7630e223994a963e8220d730d77783e8a4", "support" ], "infrastructure/expected-fail/unhandled-rejection-following-subtest.html": [ @@ -466010,6 +466986,22 @@ "b954a0e9b75d79c279eed0f3205c25e5b09fdd17", "support" ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-in-promise.html.ini": [ + "7210f8dcfe616f8170b92c43b40e09bfb3b59b9c", + "support" + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-in-setup.html.ini": [ + "a33ebafe65023bf5b91834e0d203a9a82f46a14e", + "support" + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition-without-setup.html.ini": [ + "406db30a095e057d4302180455830f3abb71d067", + "support" + ], + "infrastructure/metadata/infrastructure/expected-fail/precondition.html.ini": [ + "91544eba4c44ff60ab4e51548c4052c34d0dbf9e", + "support" + ], "infrastructure/metadata/infrastructure/expected-fail/timeout.html.ini": [ "53b281f8358c4f90aab96c731076439ccb5567b4", "support" @@ -466122,6 +467114,10 @@ "baf2116bad6b5cd258e07d29e2115c6aab11e099", "support" ], + "infrastructure/metadata/infrastructure/testdriver/actions/multiTouchPoints.html.ini": [ + "c7b3482c786fc4532488f388b802930ccea8dc0e", + "support" + ], "infrastructure/metadata/infrastructure/testdriver/actions/pause.html.ini": [ "657d2a2492605557dcc62f02dca36364cf3007fd", "support" @@ -466138,6 +467134,10 @@ "3e43b63af9545f2828efd2f7ce510bbc9a87bbfc", "support" ], + "infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini": [ + "88c9bbd479951b62ffa83d900a62f7a6a019dd37", + "support" + ], "infrastructure/reftest-wait-ref.html": [ "6772c2c460e79993979688ddf46e2045b14f7d71", "support" @@ -466390,6 +467390,14 @@ "2170347c9729564f7e492009b3d20b3267422c1d", "testharness" ], + "infrastructure/testdriver/virtual_authenticator-expected.txt": [ + "51c86eaa09540ecd9d0bcac5d85e610dd1fb32da", + "support" + ], + "infrastructure/testdriver/virtual_authenticator.html": [ + "339e42665c720cd212419a956936daf10640d8af", + "testharness" + ], "infrastructure/webdriver/tests/conftest.py": [ "cbc4f83421bb4868d1e6958a0622676895eac9ca", "support" @@ -466446,9 +467454,9 @@ "7e6a59769d04717e70dbd2c736c874bda69e6583", "manual" ], - "input-events/input-events-typing-manual.html": [ - "5f81c33c7519e70b4c48892baec513b1755a9ee2", - "manual" + "input-events/input-events-typing.html": [ + "153193c3a9e7770dc15237d0c3d38e2935375e1c", + "testharness" ], "interfaces/BackgroundSync.idl": [ "f84faf7bcd3bf1e836136bfbe34b6ba68f2bd25c", @@ -466663,7 +467671,7 @@ "support" ], "interfaces/fetch.idl": [ - "9ff4aab4b148c152b4dea4bd47fa8ab1c82b6e4b", + "eacc69d8b9d1d8f7f9bdbf6f2a879d95d9d847bd", "support" ], "interfaces/filter-effects.idl": [ @@ -466875,7 +467883,7 @@ "support" ], "interfaces/resize-observer.idl": [ - "d96a348a721a62516a451c2bb58618fe48035178", + "8018fc4b22be815b0947821b72cd92d10b5892f4", "support" ], "interfaces/resource-timing.idl": [ @@ -466983,7 +467991,7 @@ "support" ], "interfaces/webauthn.idl": [ - "81728b8aba4751c6791cad274be67e4c08f505a3", + "fd35c0dfd373a6b31ae3664ca20637b07c35ecec", "support" ], "interfaces/webdriver.idl": [ @@ -467015,7 +468023,7 @@ "support" ], "interfaces/webrtc.idl": [ - "5a5eb7b10631f14245b158cc6b06a2a178ce1d20", + "d828fae6b7c85440e57cb49d5669c33df12ac9cb", "support" ], "interfaces/webusb.idl": [ @@ -468991,7 +469999,7 @@ "support" ], "mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html": [ - "ca3e679491951d9a573a0f754491cf549a565953", + "d50e69eb97db1c3741401817788054b904598491", "reftest" ], "mathml/relations/html5-tree/css-inline-style-interface.tentative.html": [ @@ -469034,8 +470042,12 @@ "c23d87c2358c296ad331fb981ff58b6bea6253e9", "reftest" ], + "mathml/relations/html5-tree/href-click-3-expected.txt": [ + "ac78ee3efe8e7356c7d2c4ee81e67ca321d91eb9", + "support" + ], "mathml/relations/html5-tree/href-click-3.html": [ - "a8475ea3ff801dfdb6f4d6d5a7e049a6eafe7c00", + "1b7f0685e65e7c939caab3d546316e7bf858f885", "testharness" ], "mathml/relations/html5-tree/html-or-foreign-element-interfaces.tentative.html": [ @@ -469070,6 +470082,10 @@ "7121db645b2761f999c9492a44601d54531d6170", "testharness" ], + "mathml/relations/html5-tree/math-global-event-handlers.tentative-expected.txt": [ + "64d81e59c5d128e31fc419f812f20937269bc795", + "support" + ], "mathml/relations/html5-tree/math-global-event-handlers.tentative.html": [ "d77aa57741c378347d08ca6cd300841bd2194c40", "testharness" @@ -470171,11 +471187,11 @@ "testharness" ], "mediacapture-record/MediaRecorder-mimetype-expected.txt": [ - "56076d5c3e2005b8a9eff6168dd432d3726b18fb", + "264518fd810458e5636453d07cd6d7482e0889c5", "support" ], "mediacapture-record/MediaRecorder-mimetype.html": [ - "ddc56e9cb750c59753e238c8ec39c6e1f128790b", + "e90bbcced989d5c5b7fa8a978821316b0150c731", "testharness" ], "mediacapture-record/MediaRecorder-pause-resume.html": [ @@ -470519,7 +471535,7 @@ "support" ], "mixed-content/README.md": [ - "407b8960cbeb108b729ba5bdc70e1ace41e944ea", + "488432d41ea61c18264c37310369dbd59ccb78ea", "support" ], "mixed-content/gen/top.http-rp/opt-in/audio-tag/cross-http.keep-scheme.https.html": [ @@ -473119,7 +474135,7 @@ "support" ], "mixed-content/generic/test-case.sub.js": [ - "9e9e169f15ff07423065c38afc8a449de6513813", + "661cff12d00e1d7cc1f8e9b2ca2f4ff2b65f4e06", "support" ], "mixed-content/generic/tools/generate.py": [ @@ -474571,11 +475587,11 @@ "testharness" ], "offscreen-canvas/conformance-requirements/2d.missingargs.html": [ - "9aa437c0cddcc55819e582307c84b64b44409fd8", + "67152573912203b64ceb94e072b869e425439862", "testharness" ], "offscreen-canvas/conformance-requirements/2d.missingargs.worker.js": [ - "8f8d00ee3a530884e6e05baedd498205e7d08ae5", + "755e881eb06e0380ffe0947c19ddf77d65bf098d", "testharness" ], "offscreen-canvas/conformance-requirements/2d.voidreturn.html": [ @@ -480067,9 +481083,13 @@ "support" ], "offscreen-canvas/tools/tests2d.yaml": [ - "6b1876d803f4e10e25d4f600372d77397d2d9bdb", + "0b346bb658e8316aa070a0bf30376c2c0cc54c93", "support" ], + "offscreen-canvas/transformations/2d.transformation.getTransform.html": [ + "b3b70ac208674c5bf249c6f58b4647b98be6d5e4", + "testharness" + ], "offscreen-canvas/transformations/2d.transformation.order.html": [ "8d70442f10814b389c649f49c3f1dc197d254923", "testharness" @@ -480719,7 +481739,7 @@ "testharness" ], "payment-handler/change-payment-method-manual.https-expected.txt": [ - "f30628bbf9f8c9b6b12d5f4d39ef73048709dcee", + "01611e85c7d3ae68207ee8ef811db5a95741965d", "support" ], "payment-handler/change-payment-method-manual.https.html": [ @@ -480727,7 +481747,7 @@ "manual" ], "payment-handler/change-shipping-address-manual.https-expected.txt": [ - "de7d40690bcabc4d58a4db268d0d969514e05a77", + "01611e85c7d3ae68207ee8ef811db5a95741965d", "support" ], "payment-handler/change-shipping-address-manual.https.html": [ @@ -480735,7 +481755,7 @@ "manual" ], "payment-handler/change-shipping-option-manual.https-expected.txt": [ - "4b23059bbc5f364d9276caf84baa7d008300b2ab", + "01611e85c7d3ae68207ee8ef811db5a95741965d", "support" ], "payment-handler/change-shipping-option-manual.https.html": [ @@ -480791,7 +481811,7 @@ "testharness" ], "payment-handler/payment-request-event-manual.https-expected.txt": [ - "a00a329711ec8f8de1e7e7aeda6704564483c9d3", + "01611e85c7d3ae68207ee8ef811db5a95741965d", "support" ], "payment-handler/payment-request-event-manual.https.html": [ @@ -480807,7 +481827,7 @@ "testharness" ], "payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt": [ - "149709f312a02ec55d70e564c13ac013e54bb947", + "01611e85c7d3ae68207ee8ef811db5a95741965d", "support" ], "payment-handler/supports-shipping-contact-delegation-manual.https.html": [ @@ -481055,7 +482075,7 @@ "testharness" ], "payment-request/payment-is-showing.https-expected.txt": [ - "f04ac0a8d657213e5143f2a0cf75098e212febfa", + "bcff8407c67d8e51f9db651a0cad51670de42052", "support" ], "payment-request/payment-is-showing.https.html": [ @@ -481071,7 +482091,7 @@ "testharness" ], "payment-request/payment-request-canmakepayment-method-protection.https-expected.txt": [ - "0f09114186bb4b3c975473f189a79237b7901944", + "bcff8407c67d8e51f9db651a0cad51670de42052", "support" ], "payment-request/payment-request-canmakepayment-method-protection.https.html": [ @@ -482947,7 +483967,7 @@ "support" ], "referrer-policy/README.md": [ - "ca9977c89ec36493bb6ec35cde30df8e8e6c187a", + "4d6eda97250a3177cb1846fd0950965519605d67", "support" ], "referrer-policy/css-integration/README.md": [ @@ -495203,7 +496223,7 @@ "testharness" ], "reporting/generateTestReport.html": [ - "e3c2735686a05eefc9bbcfb107f76ec7275b8948", + "f47ea45c9a4112f22af1f6736d271ad85f1f02e4", "testharness" ], "reporting/idlharness.any-expected.txt": [ @@ -495307,7 +496327,7 @@ "testharness" ], "resize-observer/idlharness.window-expected.txt": [ - "ad10be9c536f0fafc900900512d388cdb856c1ac", + "77658f70487f85b4717d694ef1b8f753dbbd5e72", "support" ], "resize-observer/idlharness.window.js": [ @@ -496015,7 +497035,7 @@ "support" ], "resources/chromium/nfc-mock.js": [ - "ce22a9c2cfe9c0ae460d6e1eff4aaa99fe6b24e3", + "f5666c18f5c57fdc8ee74c1572824f34e346d5ed", "support" ], "resources/chromium/sensor.mojom.js": [ @@ -496107,7 +497127,7 @@ "support" ], "resources/testdriver.js": [ - "031be1b7e5501658d412aecc6f0cba56b3444601", + "bd38e3e006afec94c23005cb1725c6d4a6e9bbe0", "support" ], "resources/testdriver.js.headers": [ @@ -496119,7 +497139,7 @@ "support" ], "resources/testharness.js": [ - "7fb1c0c8a52c1be6f2a54d9912e714f74922ee89", + "93809664ea347d575913186362d12635893ec1c3", "support" ], "resources/testharness.js.headers": [ @@ -501359,7 +502379,7 @@ "testharness" ], "sms/README.md": [ - "7cd98964c24979d427b51c095e178b0622efa971", + "1f34178beace0786a347a6b378489b3741c960d9", "support" ], "sms/idlharness.https.any.js": [ @@ -501463,11 +502483,11 @@ "manual" ], "speech-api/historical-expected.txt": [ - "07d8219a2c97c504780a4a9c9a51ab53d229d479", + "cf2f69bb0c5a5d8c6a5393a9431dab91aeca01ac", "support" ], "speech-api/historical.html": [ - "207d3e016ed1fec05d9a1256f40088c61bb05c83", + "9da70c44de9be25933d95d7e6fd2f3ae69a04333", "testharness" ], "speech-api/idlharness.window-expected.txt": [ @@ -501538,6 +502558,10 @@ "1db8620485dc459577649e0c2689194d106dcc51", "testharness" ], + "storage-access-api/META.yml": [ + "cb059fe6bb103af62e83abe2e1518011975102e2", + "support" + ], "storage-access-api/hasStorageAccess.sub.window.js": [ "c4d6e3a8b9a856007a299b7f2b1112188547ebd1", "testharness" @@ -501779,7 +502803,7 @@ "support" ], "streams/readable-byte-streams/construct-byob-request.any-expected.txt": [ - "8ec519e10cc02b3a8cbb0374726eebd34a701441", + "ba6d006b5069d56a38301041c8180002c82bc983", "support" ], "streams/readable-byte-streams/construct-byob-request.any.js": [ @@ -501787,7 +502811,7 @@ "testharness" ], "streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt": [ - "6e0da30f5ce6d430095664301cc4be4cb9beb850", + "8804b86fbc5d89953981e414412cc32a7980e454", "support" ], "streams/readable-byte-streams/construct-byob-request.any.sharedworker-expected.txt": [ @@ -501795,7 +502819,7 @@ "support" ], "streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt": [ - "8ec519e10cc02b3a8cbb0374726eebd34a701441", + "ba6d006b5069d56a38301041c8180002c82bc983", "support" ], "streams/readable-byte-streams/constructor.any-expected.txt": [ @@ -505675,7 +506699,7 @@ "support" ], "tools/requirements_flake8.txt": [ - "16e35cf5aa957755d0b171e8a86f69c208484996", + "ae35da67e53fcc348054d10c9e498e5fcbca06ed", "support" ], "tools/requirements_mypy.txt": [ @@ -509527,11 +510551,11 @@ "support" ], "tools/tox.ini": [ - "63fb8ed9832ba9d11dae965e3c335e3d26289720", + "a330d0523486ca0b3f5e7d4e00567f8a0b60200e", "support" ], "tools/webdriver/README.md": [ - "72de3b2ae8b6a25434bbfef00e49e0a0463ff247", + "2795ff1fcf39f7da98a18eb3484109b0bf7137ae", "support" ], "tools/webdriver/setup.py": [ @@ -509603,7 +510627,7 @@ "support" ], "tools/wpt/run.py": [ - "25255320fa9232286de9a779550618913d9ba7a3", + "44dfbc25fa58ca50dbfdb761f358692c2115a7a3", "support" ], "tools/wpt/testfiles.py": [ @@ -509611,7 +510635,7 @@ "support" ], "tools/wpt/tox.ini": [ - "d0dead55d9aa863dd4bd50c941f45ab462f4ede9", + "6a044473a6b74981345683abb960588de6535bfb", "support" ], "tools/wpt/update.py": [ @@ -509675,7 +510699,7 @@ "support" ], "tools/wptrunner/requirements_firefox.txt": [ - "e772b27377970aca9d46a0b6e98369e4b1d30945", + "f49102b8a89ba7bbbc809c1b4313779c31330fc4", "support" ], "tools/wptrunner/requirements_ie.txt": [ @@ -509707,7 +510731,7 @@ "support" ], "tools/wptrunner/tox.ini": [ - "5d343751c5488cdd1a73b9d3fcae94de46874a3e", + "f82dbc6b8a83556383cb26a2e7c5633f6b19da99", "support" ], "tools/wptrunner/wptrunner.default.ini": [ @@ -509811,7 +510835,7 @@ "support" ], "tools/wptrunner/wptrunner/executors/base.py": [ - "004b92b4b6639aba5ccfe46e6558640a794c18cf", + "f20f735528c16dbc72fdb41434f3511c2128dbd9", "support" ], "tools/wptrunner/wptrunner/executors/executorchrome.py": [ @@ -509855,7 +510879,7 @@ "support" ], "tools/wptrunner/wptrunner/executors/executorwebdriver.py": [ - "a2601978b578aa546fd5d38c1bb997719ae27d41", + "344debf8aa69ef0634764cdaf0e994511bbceab6", "support" ], "tools/wptrunner/wptrunner/executors/executorwebkit.py": [ @@ -509867,7 +510891,7 @@ "support" ], "tools/wptrunner/wptrunner/executors/protocol.py": [ - "77a705ffb4759c04c53ab3a8f045b50569f2598d", + "0758312d65f90043b1cbb2f536d3d31c71812ad6", "support" ], "tools/wptrunner/wptrunner/executors/pytestrunner/__init__.py": [ @@ -509959,7 +510983,7 @@ "support" ], "tools/wptrunner/wptrunner/testdriver-extra.js": [ - "9f97fac9a0cbc99ae8631ac2a1179da8bb9123a8", + "278f226dbd2cefc284ebf347c32089ea1fa5a22d", "support" ], "tools/wptrunner/wptrunner/testdriver-vendor.js": [ @@ -510095,7 +511119,7 @@ "support" ], "tools/wptrunner/wptrunner/wpttest.py": [ - "80db17a3c7284cd82145a3d20c3532a0e79c82a4", + "e5c28bc47316df6aec758459b6aa2c5053cf7a3e", "support" ], "tools/wptserve/LICENSE": [ @@ -510302,8 +511326,8 @@ "34fbf5587daf725222dd191fc941fffe2630e106", "testharness" ], - "trusted-types/TrustedTypePolicy-name.tentative.html": [ - "4b7c30c855980ef2c4e5ab548a9b8def7991de77", + "trusted-types/TrustedTypePolicy-getPolicyNames.tentative.html": [ + "d1ae9e45c0669a5aadce7c09d1e3c56360583708", "testharness" ], "trusted-types/TrustedTypePolicyFactory-constants.tentative.html": [ @@ -510327,7 +511351,7 @@ "testharness" ], "trusted-types/TrustedTypePolicyFactory-createPolicy-nameTests.tentative.html": [ - "e0aa53756d6a23fd99d0469104ca061bf7831398", + "0b1872abe5036d93618ae3849d52497511bb51b5", "testharness" ], "trusted-types/TrustedTypePolicyFactory-defaultPolicy.tentative.html": [ @@ -510359,7 +511383,7 @@ "testharness" ], "trusted-types/block-eval.tentative.html": [ - "f7d7132505fa42fb4e244a9d6e512c153e56dfbf", + "cd4f5827c5331318a86dc71a42bc9eb037eb5b95", "testharness" ], "trusted-types/block-string-assignment-to-DOMParser-parseFromString.tentative.html": [ @@ -510426,6 +511450,26 @@ "1bc33add09b4b34ce2cba21f488f8ed53345a27a", "support" ], + "trusted-types/eval-csp-no-tt.tentative.html": [ + "e8ed57708ef158d36cff2c0d0883910c84bb75e8", + "testharness" + ], + "trusted-types/eval-csp-tt-default-policy.tentative.html": [ + "8f1926d9cf26ff2f9b1be1c65e6c6784e75c24b2", + "testharness" + ], + "trusted-types/eval-csp-tt-no-default-policy.tentative.html": [ + "dc976d64abd62332366f3bee60b8915245fc437d", + "testharness" + ], + "trusted-types/eval-no-csp-no-tt-default-policy.tentative.html": [ + "84c224eac28f6b26d4c0a15d7390185a576df716", + "testharness" + ], + "trusted-types/eval-no-csp-no-tt.tentative.html": [ + "45086a1d6abdec58df8f3d5de5421bab0a2162a5", + "testharness" + ], "trusted-types/eval-with-permissive-csp.tentative.html": [ "074fe79dc93fee6563bcb9ce2db3fa708bf4ad4f", "testharness" @@ -510470,8 +511514,24 @@ "7a43b1f7b35f51d249b815a64eb26fdd90d529d1", "testharness" ], + "trusted-types/trusted-types-duplicate-names-list-report-only.tentative.html": [ + "46ca2edb6fb57b354b3a80f327dbfbe6760f21c6", + "testharness" + ], + "trusted-types/trusted-types-duplicate-names-list-report-only.tentative.html.headers": [ + "b6608515aa85a08dbb56531c46c097e179c76200", + "support" + ], + "trusted-types/trusted-types-duplicate-names-list.tentative.html": [ + "839f2ef7a3ac5e6d1bc78e3b892e8b898370de1e", + "testharness" + ], + "trusted-types/trusted-types-duplicate-names.tentative.html": [ + "e780a3d26ad6363e99316ead0d9663c9c4a613a7", + "testharness" + ], "trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html": [ - "e15ecfaa86c5b48dcc3aa9903ab7b0ab89af8474", + "7902df1c30385ef3896829c7c6f7af646b5403ed", "testharness" ], "trusted-types/trusted-types-eval-reporting-no-unsafe-eval.tentative.https.html.headers": [ @@ -510515,7 +511575,7 @@ "support" ], "trusted-types/trusted-types-reporting.tentative.https.html": [ - "70afb9745a88e6ffbce15a1d868d1f099c339e80", + "10a951fa12cb8d69249a96cb85ce34f6136e52c5", "testharness" ], "trusted-types/trusted-types-reporting.tentative.https.html.headers": [ @@ -510546,6 +511606,10 @@ "24d64dc9ac344f9c856241221d7323b162434932", "testharness" ], + "uievents/click/click_events_on_input.html": [ + "731d13934f0d38505ae19334f0fa39a130021562", + "testharness" + ], "uievents/click/mouse-dblclick-event.html": [ "31a600b3cb715e408cd4aa8920fb54fd77064e57", "testharness" @@ -510943,7 +512007,7 @@ "support" ], "upgrade-insecure-requests/README.md": [ - "516e8e262f4b18375689cb45d15f2c516c24571f", + "7b7ac65c9903410dd9e6e924b922b1961df32318", "support" ], "upgrade-insecure-requests/gen/iframe-blank-inherit.meta/unset/fetch/cross-http-downgrade.downgrade.https.html": [ @@ -514459,7 +515523,7 @@ "testharness" ], "vibration/invalid-values.html": [ - "6740a44a8ed98ac76c577636d42010c1c8c27ada", + "9381dadcc06e5d301b5531f0679ce44f943e8740", "testharness" ], "vibration/pattern-array-extra-manual.html": [ @@ -515242,6 +516306,10 @@ "a33d6d4f24676356b59b6b431968d8486df50615", "testharness" ], + "web-animations/idlharness.window-expected.txt": [ + "38f05e832f0f9f61437decd52b6365aa753dc814", + "support" + ], "web-animations/idlharness.window.js": [ "c32016280e659fe8268c87b58e4956a1eb81b399", "testharness" @@ -515719,7 +516787,7 @@ "testharness" ], "web-nfc/NDEFMessage_constructor.https.html": [ - "ce212136023058dd6597ff925fd68a73e5d2ab95", + "f32f179b95798fe590a518603eff35265cd51494", "testharness" ], "web-nfc/NDEFReader-document-hidden-manual.https-expected.txt": [ @@ -515731,11 +516799,11 @@ "manual" ], "web-nfc/NDEFReader_options.https.html": [ - "b1452c0240d176316341a0ab6857433fbc99a5b5", + "81b051e28f4723624846d25aa49d16525c81d1a9", "testharness" ], "web-nfc/NDEFReader_scan.https.html": [ - "a26a548c6392d8116e8c188d6dbbe03b4660d87f", + "7c78a1c6008429dc348efa2c02c83c47e0a565a4", "testharness" ], "web-nfc/NDEFReader_scan_iframe.https.html": [ @@ -515747,7 +516815,7 @@ "testharness" ], "web-nfc/NDEFRecord_constructor.https.html": [ - "6028e970b879b1f65dd48d64525995114b5e82e9", + "79ce8a076eda26a7657df6eba8b781f711a94abb", "testharness" ], "web-nfc/NDEFWriter-document-hidden-manual.https-expected.txt": [ @@ -515759,11 +516827,11 @@ "manual" ], "web-nfc/NDEFWriter_push.https-expected.txt": [ - "028f57198921b951e52c05e490cf0b4a04f35fc3", + "f6e5f89b45ca648014686ef06fc3f2c32bb9f39e", "support" ], "web-nfc/NDEFWriter_push.https.html": [ - "f8b461c42d5ee0265f1301458b8e92a812e650da", + "57c619f73f84a90de32d33957e4757eca1c8e464", "testharness" ], "web-nfc/OWNERS": [ @@ -515775,11 +516843,11 @@ "support" ], "web-nfc/idlharness.https.window-expected.txt": [ - "6f05c69de7629c8967c925532c7e0b1d0742de8a", + "cd7cae3db1b112167abeade6ba8b335e7a22547d", "support" ], "web-nfc/idlharness.https.window.js": [ - "f59ad9b512ed5548b22ff43b84f8404258e9e6c9", + "74ffc21b2204ea894dcea32a4aface9bc69739c1", "testharness" ], "web-nfc/nfc_insecure_context.html": [ @@ -515787,7 +516855,7 @@ "testharness" ], "web-nfc/resources/nfc-helpers.js": [ - "bdd8290d9eb7f9fcae1e46820a64fc6cef8617e5", + "f90a050c4cad93e31937bca946f3c250bb64723c", "support" ], "web-nfc/resources/support-iframe.html": [ @@ -517939,7 +519007,7 @@ "support" ], "webgpu/cts.html": [ - "b66553df983d543453ed1f35cf20add65801481f", + "13d8b7c8324a7e3c3c0c00359e729a958f715205", "testharness" ], "webgpu/framework/allowed_characters.js": [ @@ -517951,7 +519019,7 @@ "support" ], "webgpu/framework/fixture.js": [ - "127931223cb8b071606af2f08d97681c1a32f295", + "d976fa46880a30cbb1837fce30a96023875e0f87", "support" ], "webgpu/framework/gpu/implementation.js": [ @@ -517975,7 +519043,7 @@ "support" ], "webgpu/framework/logger.js": [ - "ee86919612d8725136f12879a58520004575138c", + "5536e736f069a3a013eb88233eb0d3a8c413f919", "support" ], "webgpu/framework/params/combine.js": [ @@ -518047,7 +519115,7 @@ "support" ], "webgpu/framework/version.js": [ - "154f0629b0dd367d3ef89ae4f200ce851b845f66", + "e2c91190305110d107b22dfb45e6a29739d424cd", "support" ], "webgpu/runtime/helper/options.js": [ @@ -518063,7 +519131,7 @@ "testharness" ], "webgpu/runtime/wpt.js": [ - "e078f6717471ad2364cf31587c55b4f24f2a3a00", + "fd02f09471bc656a900714dd586101d6acb28c46", "support" ], "webgpu/suites/cts/buffers/create_mapped.spec.js": [ @@ -518107,7 +519175,7 @@ "support" ], "webgpu/suites/cts/command_buffer/render/rendering.spec.js": [ - "43c4566799531fca8869500823c12feacd7d1522", + "54c627dfd35d7179d9f357c046afa77c8b9e116a", "support" ], "webgpu/suites/cts/command_buffer/render/storeop.spec.js": [ @@ -518127,11 +519195,11 @@ "support" ], "webgpu/suites/cts/gpu_test.js": [ - "272b1b831e8f42626f285b7e4bbdff3c0b6b6306", + "a324e8839e505ab4fcce98dbf49b9217bc52aa00", "support" ], "webgpu/suites/cts/index.js": [ - "33934cdd38cb51c8a00dc72c436a14965ab7aa28", + "d38bcc5b6b51cf6b5f7bc19d4a23d9f5d98b4415", "support" ], "webgpu/suites/cts/validation/createBindGroup.spec.js": [ @@ -518195,7 +519263,7 @@ "support" ], "webgpu/suites/cts/validation/setVertexBuffer.spec.js": [ - "0f47e7324eb06aeb8d52c6e744932884ba2064ee", + "ba22ee2d2a4e636e2b519003da669bbd33fead2d", "support" ], "webgpu/suites/cts/validation/setViewport.spec.js": [ @@ -518203,11 +519271,11 @@ "support" ], "webgpu/suites/cts/validation/validation_test.js": [ - "099b8202204d06b41403410f287a770a0945559d", + "dc5488e769883b99a9157567d3aaa71eafd2dd42", "support" ], - "webgpu/suites/cts/validation/vertex_input.spec.js": [ - "c5978025c9a777fd6e275fe7d2520092d3f39c8c", + "webgpu/suites/cts/validation/vertex_state.spec.js": [ + "da619181192b907f0485d71cf364616568d77f66", "support" ], "webmessaging/Channel_postMessage_Blob.htm": [ @@ -519106,8 +520174,12 @@ "dbfc41e0c375dea0711a8cf312846cbdb27c570b", "testharness" ], + "webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt": [ + "1b3bb5465db7e3f971107832f97d33b4f93e4130", + "support" + ], "webrtc/RTCPeerConnection-iceConnectionState.https.html": [ - "9dd364ed3271283d71f784c3c37abddf09e68c68", + "32f2eb9b4607121ad9aa0db99a05e3ab78750f7e", "testharness" ], "webrtc/RTCPeerConnection-iceGatheringState-expected.txt": [ @@ -519495,7 +520567,7 @@ "testharness" ], "webrtc/idlharness.https.window-expected.txt": [ - "2dedb2f47dddda86eb1f02032ddde2a019189c3a", + "5ebbb2ac5b7745bb224c0e5ecf8b35ce840c277f", "support" ], "webrtc/idlharness.https.window.js": [ @@ -520667,7 +521739,7 @@ "support" ], "websockets/unload-a-document/001-1.html": [ - "bd0c36686954938a1d2bf70918bc506da431e296", + "75d689e0b3d2e2ce3b7aa56ef33fb05409b78cb6", "support" ], "websockets/unload-a-document/001-2.html": [ @@ -520679,7 +521751,7 @@ "testharness" ], "websockets/unload-a-document/002-1.html": [ - "d151b231f250ab61103db23877e0dc0e80bd1eec", + "546de89dfee0782a916bf0ed82328bb77e92956c", "support" ], "websockets/unload-a-document/002-2.html": [
diff --git a/third_party/blink/web_tests/external/wpt/CONTRIBUTING.md b/third_party/blink/web_tests/external/wpt/CONTRIBUTING.md index baa208e3..54d963d 100644 --- a/third_party/blink/web_tests/external/wpt/CONTRIBUTING.md +++ b/third_party/blink/web_tests/external/wpt/CONTRIBUTING.md
@@ -1,4 +1,4 @@ -All contributions are licensed under the terms of the LICENSE.md file. +All contributions are licensed under the terms of the [3-Clause BSD License](LICENSE.md). Documentation -------------
diff --git a/third_party/blink/web_tests/external/wpt/README.md b/third_party/blink/web_tests/external/wpt/README.md index 43cc6b86..e3ee855 100644 --- a/third_party/blink/web_tests/external/wpt/README.md +++ b/third_party/blink/web_tests/external/wpt/README.md
@@ -20,9 +20,9 @@ - [web-platform-tests.org](https://web-platform-tests.org): the documentation website; details how to set up the project, how to write tests, how to give and receive peer review, how to serve as an administrator, and more -- [web-platform-tests.live](http://web-platform-tests.live): a public - deployment of the test suite, allowing anyone to run the tests by visiting - from an Internet-enabled browser of their choice +- [wpt.live](http://wpt.live): a public deployment of the test suite, + allowing anyone to run the tests by visiting from an + Internet-enabled browser of their choice - [wpt.fyi](https://wpt.fyi): an archive of test results collected from an array of web browsers on a regular basis - [Real-time chat room](http://irc.w3.org/?channels=testing): the @@ -227,11 +227,9 @@ Save the Web, Write Some Tests! -Absolutely everyone is welcome (and even encouraged) to contribute to -test development, so long as you fulfill the contribution requirements -detailed in the [Contributing Guidelines][contributing]. No test is -too small or too simple, especially if it corresponds to something for -which you've noted an interoperability bug in a browser. +Absolutely everyone is welcome to contribute to test development. No +test is too small or too simple, especially if it corresponds to +something for which you've noted an interoperability bug in a browser. The way to contribute is just as usual: @@ -242,7 +240,7 @@ * Make your changes. * Run `./wpt lint` as described above. * Commit locally and push that to your repo. -* Send in a pull request based on the above. +* Create a pull request based on the above. Issues with web-platform-tests ------------------------------
diff --git a/third_party/blink/web_tests/external/wpt/common/security-features/resources/common.sub.js b/third_party/blink/web_tests/external/wpt/common/security-features/resources/common.sub.js index f7abd3ec..b43417b 100644 --- a/third_party/blink/web_tests/external/wpt/common/security-features/resources/common.sub.js +++ b/third_party/blink/web_tests/external/wpt/common/security-features/resources/common.sub.js
@@ -1,5 +1,5 @@ /** - * @fileoverview Utilities for mixed-content in Web Platform Tests. + * @fileoverview Utilities for mixed-content in web-platform-tests. * @author burnik@google.com (Kristijan Burnik) * Disclaimer: Some methods of other authors are annotated in the corresponding * method's JSDoc.
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html new file mode 100644 index 0000000..9c9e944 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-lr.html
@@ -0,0 +1,240 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Grid Layout test: box model parts and alignment properties, vertical-LR writing mode</title> +<link rel="author" title="Rossana Monteriso" href="mailto:rmonteriso@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-align-3/"> +<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#propdef-writing-mode"> +<meta name="assert" content="This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-LR grids, in both LTR and RTL directions."> +<meta name="flags" content="ahem"> +<link rel="stylesheet" href="/css/support/grid.css"> +<link rel="stylesheet" href="/css/support/alignment.css"> +<link rel="stylesheet" href="/css/support/width-keyword-classes.css"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> + +<style> + +.grid { + grid-template-columns: 100px 200px; + grid-template-rows: 200px 200px; + padding: 10px 15px 20px 30px; + border-width: 5px 10px 15px 20px; + border-style: dotted; + border-color: blue; + position: relative; +} + +.cell { + width: 20px; + height: 40px; + margin: 4px 8px 12px 16px; +} +</style> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/check-layout-th.js"></script> + +<body onload="checkLayout('.grid')"> + +<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-LR grids.</p> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content verticalLR" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="46" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content verticalLR itemsCenter" data-expected-width="475" data-expected-height="350"> + <div class="firstRowFirstColumn cell" data-offset-x="124" data-offset-y="36" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="324" data-offset-y="186" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content verticalLR itemsEnd" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="202" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="402" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'left' | justify-items: 'left'</p> + <div class="grid fit-content verticalLR itemsLeft" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content verticalLR alignItemsStart justifyItemsRight" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-start' (vertical-lr) | justify-items: 'self-start' (direction: rtl)</p> + <div class="grid fit-content directionLTR verticalLR itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="46" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="246" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-end' (vertical-lr) | justify-items: 'self-end' (direction: rtl)</p> + <div class="grid fit-content directionLTR verticalLR itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="202" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="402" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionLTR verticalLR itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="246" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionLTR verticalLR itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="202" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="402" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<!-- RTL direction. --> +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content verticalLR directionRTL" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="46" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="246" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content verticalLR directionRTL itemsCenter" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="124" data-offset-y="236" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="324" data-offset-y="86" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content verticalLR directionRTL itemsEnd" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="202" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="402" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'left'</p> + <div class="grid fit-content verticalLR directionRTL alignItemsStart justifyItemsLeft" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content verticalLR directionRTL alignItemsStart justifyItemsRight" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="246" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-start' (vertical-lr) | justify-items: 'self-start' (direction: ltr)</p> + <div class="grid fit-content verticalLR directionRTL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="46" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-end' (vertical-lr) | justify-items: 'self-end' (direction: ltr)</p> + <div class="grid fit-content verticalLR directionRTL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="202" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="402" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content verticalLR directionRTL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="46" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="246" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content verticalLR directionRTL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="202" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="402" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +</body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html new file mode 100644 index 0000000..f7698e4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding-vertical-rl.html
@@ -0,0 +1,241 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Grid Layout test: box model parts and alignment properties, vertical-RL writing mode</title> +<link rel="author" title="Rossana Monteriso" href="mailto:rmonteriso@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-align-3/"> +<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#propdef-writing-mode"> +<meta name="assert" content="This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-RL grids, in both LTR and RTL directions."> +<meta name="flags" content="ahem"> +<link rel="stylesheet" href="/css/support/grid.css"> +<link rel="stylesheet" href="/css/support/alignment.css"> +<link rel="stylesheet" href="/css/support/width-keyword-classes.css"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> + +<style> + +.grid { + grid-template-columns: 100px 200px; + grid-template-rows: 200px 200px; + padding: 10px 15px 20px 30px; + border-width: 5px 10px 15px 20px; + border-style: dotted; + border-color: blue; + position: relative; +} + +.cell { + width: 20px; + height: 40px; + margin: 4px 8px 12px 16px; +} +</style> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/check-layout-th.js"></script> + +<body onload="checkLayout('.grid')"> + +<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties on vertical-RL grids.</p> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content verticalRL" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="402" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="202" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content verticalRL itemsCenter" data-expected-width="475" data-expected-height="350"> + <div class="firstRowFirstColumn cell" data-offset-x="324" data-offset-y="36" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="124" data-offset-y="186" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content verticalRL itemsEnd" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="246" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="46" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'left' | justify-items: 'left'</p> + <div class="grid fit-content verticalRL itemsLeft" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content verticalRL alignItemsStart justifyItemsRight" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-start' (vertical-rl) | justify-items: 'self-start' (direction: rtl)</p> + <div class="grid fit-content directionLTR verticalRL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="402" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="202" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-end' (vertical-rl) | justify-items: 'self-end' (direction: rtl)</p> + <div class="grid fit-content directionLTR verticalRL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="46" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionLTR verticalRL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="402" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="202" data-offset-y="114" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionLTR verticalRL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="246" data-offset-y="58" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="110" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="46" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + + +<!-- RTL direction. --> +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content directionRTL verticalRL" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="402" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="202" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content directionRTL verticalRL itemsCenter" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="324" data-offset-y="236" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="124" data-offset-y="86" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content directionRTL verticalRL itemsEnd" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="246" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'left'</p> + <div class="grid fit-content directionRTL verticalRL alignItemsStart justifyItemsLeft" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content directionRTL verticalRL alignItemsStart justifyItemsRight" data-expected-width="475" data-expected-height="350"> + <div class="cell firstRowFirstColumn" data-offset-x="402" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-start' (vertical-rl) | justify-items: 'self-start' (direction: ltr)</p> + <div class="grid fit-content directionRTL verticalRL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="402" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="202" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-end' (vertical-rl) | justify-items: 'self-end' (direction: ltr)</p> + <div class="grid fit-content directionRTL verticalRL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="246" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="46" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionRTL verticalRL itemsSelfStart" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="402" data-offset-y="258" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="202" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionRTL verticalRL itemsSelfEnd" data-expected-width="475" data-expected-height="350"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="246" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="230" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="200" data-expected-height="100"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +</body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding.html b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding.html new file mode 100644 index 0000000..9cdce09 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-margin-border-padding.html
@@ -0,0 +1,239 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Grid Layout test: box model parts and alignment properties</title> +<link rel="author" title="Rossana Monteriso" href="mailto:rmonteriso@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-align-3/"> +<meta name="assert" content="This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties, in both LTR and RTL directions."> +<meta name="flags" content="ahem"> +<link rel="stylesheet" href="/css/support/grid.css"> +<link rel="stylesheet" href="/css/support/alignment.css"> +<link rel="stylesheet" href="/css/support/width-keyword-classes.css"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> + +<style> + +.grid { + grid-template-columns: 100px 200px; + grid-template-rows: 200px 200px; + padding: 10px 15px 20px 30px; + border-width: 5px 10px 15px 20px; + border-style: dotted; + border-color: blue; + position: relative; +} + +.cell { + width: 20px; + height: 40px; + margin: 4px 8px 12px 16px; +} +</style> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/check-layout-th.js"></script> + +<body onload="checkLayout('.grid')"> + +<p>This test checks that the 'margin', 'border' and 'padding' properties are applied together correctly for 'align' and 'justify' properties.</p> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="146" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="46" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="146" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content itemsCenter" data-expected-width="375" data-expected-height="450"> + <div class="firstRowFirstColumn cell" data-offset-x="74" data-offset-y="86" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="224" data-offset-y="286" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content itemsEnd" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="102" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="302" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'start' | justify-items: 'left'</p> + <div class="grid fit-content alignItemsStart justifyItemsLeft" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="146" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content alignItemsStart justifyItemsRight" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="102" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="302" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionLTR itemsSelfStart" data-expected-width="375" data-expected-height="450"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="102" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="302" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (ortho) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionLTR itemsSelfEnd" data-expected-width="375" data-expected-height="450"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="46" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="146" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionLTR itemsSelfStart" data-expected-width="375" data-expected-height="450"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="46" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="146" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: LTR - (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionLTR itemsSelfEnd" data-expected-width="375" data-expected-height="450"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="102" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="130" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="30" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="302" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<!-- RTL direction. --> +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'auto' | justify-items: 'auto'</p> + <div class="grid fit-content directionRTL" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="302" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell firstRowSecondColumn" data-offset-x="202" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowFirstColumn" data-offset-x="302" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'center' | justify-items: 'center'</p> + <div class="grid fit-content directionRTL itemsCenter" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="274" data-offset-y="86" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="124" data-offset-y="286" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'end' | justify-items: 'end'</p> + <div class="grid fit-content directionRTL itemsEnd" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="246" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="46" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'left'</p> + <div class="grid fit-content directionRTL alignItemsStart justifyItemsLeft" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="46" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL | align-items: 'start' | justify-items: 'right'</p> + <div class="grid fit-content directionRTL alignItemsStart justifyItemsRight" data-expected-width="375" data-expected-height="450"> + <div class="cell firstRowFirstColumn" data-offset-x="302" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="cell secondRowSecondColumn" data-offset-x="202" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionRTL itemsSelfStart" data-expected-width="375" data-expected-height="450"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="246" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="46" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (ortho) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionRTL itemsSelfEnd" data-expected-width="375" data-expected-height="450"> + <div class="directionLTR cell firstRowFirstColumn" data-offset-x="302" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="directionLTR selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionLTR selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionLTR cell secondRowSecondColumn" data-offset-x="202" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-start' | justify-items: 'self-start'</p> + <div class="grid fit-content directionRTL itemsSelfStart" data-expected-width="375" data-expected-height="450"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="302" data-offset-y="14" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="202" data-offset-y="214" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +<div> + <p>border: 5px 10px 15px 20px | padding: 10px 15px 20px 30px | margin: 4px 8px 12px 16px<br> + direction: RTL (parall) | align-items: 'self-end' | justify-items: 'self-end'</p> + <div class="grid fit-content directionRTL itemsSelfEnd" data-expected-width="375" data-expected-height="450"> + <div class="directionRTL cell firstRowFirstColumn" data-offset-x="246" data-offset-y="158" data-expected-width="20" data-expected-height="40"></div> + <div class="directionRTL selfStretch firstRowSecondColumn" data-offset-x="30" data-offset-y="10" data-expected-width="200" data-expected-height="200"></div> + <div class="directionRTL selfStretch secondRowFirstColumn" data-offset-x="230" data-offset-y="210" data-expected-width="100" data-expected-height="200"></div> + <div class="directionRTL cell secondRowSecondColumn" data-offset-x="46" data-offset-y="358" data-expected-width="20" data-expected-height="40"></div> + </div> +</div> + +</body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-overflow.html b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-overflow.html new file mode 100644 index 0000000..f0d9419 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-overflow.html
@@ -0,0 +1,134 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Grid Layout Test: overflow for justify and align</title> +<link rel="author" title="Rossana Monteriso" href="mailto:rmonteriso@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-align-3/#overflow-values"> +<meta name="assert" content="This test checks that both safe and unsafe overflow positions are applied correctly for align-items and justify-items properties."> +<meta name="flags" content="ahem"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> +<link rel="stylesheet" href="/css/support/grid.css"> +<link rel="stylesheet" href="/css/support/alignment.css"> +<link rel="stylesheet" href="/css/support/width-keyword-classes.css"> + +<style> + +.grid { + grid-template-columns: 150px 150px; + grid-template-rows: 120px 120px 120px; + margin-bottom: 20px; +} +.cellOverflowWidth { + width: 180px; + height: 40px; +} +.cellOverflowHeight { + width: 50px; + height: 150px; +} +.cellWithNoOverflow { + width: 50px; + height: 40px; +} +.thirdRowFirstColumn { + background-color: green; + grid-column: 1; + grid-row: 3; +} +</style> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/check-layout-th.js"></script> + +<body onload="checkLayout('.grid')"> + +<p>This test checks that the 'overflow' keyword is applied correctly for 'align' and 'justify' properties.</p> + +<div style="position: relative"> + <div class="grid fit-content alignItemsCenter justifyItemsCenter" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowWidth firstRowFirstColumn" data-offset-x="-15" data-offset-y="40" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="50" data-offset-y="160" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="50" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="200" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowWidth secondRowSecondColumn" data-offset-x="135" data-offset-y="160" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="200" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsUnsafeCenter justifyItemsUnsafeCenter" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowHeight firstRowFirstColumn" data-offset-x="50" data-offset-y="-15" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="50" data-offset-y="160" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="50" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="200" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowHeight secondRowSecondColumn" data-offset-x="200" data-offset-y="105" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="200" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsSafeCenter justifyItemsSafeCenter" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowWidth firstRowFirstColumn" data-offset-x="0" data-offset-y="40" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="50" data-offset-y="160" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="50" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="200" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowWidth secondRowSecondColumn" data-offset-x="150" data-offset-y="160" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="200" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsSafeCenter justifyItemsSafeCenter" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowHeight firstRowFirstColumn" data-offset-x="50" data-offset-y="0" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="50" data-offset-y="160" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="50" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="200" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowHeight secondRowSecondColumn alignSelfCenterSafe justifySelfCenterSafe" data-offset-x="200" data-offset-y="120" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="200" data-offset-y="280" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsEnd justifyItemsEnd" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowWidth firstRowFirstColumn" data-offset-x="-30" data-offset-y="80" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow secondRowFirstColumn justifySelfCenter" data-offset-x="50" data-offset-y="200" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="100" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="250" data-offset-y="80" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowWidth secondRowSecondColumn" data-offset-x="120" data-offset-y="200" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="250" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsUnsafeEnd justifyItemsUnsafeEnd" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowHeight firstRowFirstColumn" data-offset-x="100" data-offset-y="-30" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="100" data-offset-y="200" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="100" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn alignSelfCenter" data-offset-x="250" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowHeight secondRowSecondColumn" data-offset-x="250" data-offset-y="90" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="250" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsSafeEnd justifyItemsSafeEnd" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowWidth firstRowFirstColumn" data-offset-x="0" data-offset-y="80" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow secondRowFirstColumn justifySelfUnsafeCenter" data-offset-x="50" data-offset-y="200" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="100" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn" data-offset-x="250" data-offset-y="80" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowWidth secondRowSecondColumn" data-offset-x="150" data-offset-y="200" data-expected-width="180" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="250" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +<div style="position: relative"> + <div class="grid fit-content alignItemsSafeEnd justifyItemsSafeEnd" data-expected-width="300" data-expected-height="360"> + <div class="cellOverflowHeight firstRowFirstColumn" data-offset-x="100" data-offset-y="0" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow secondRowFirstColumn" data-offset-x="100" data-offset-y="200" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow thirdRowFirstColumn" data-offset-x="100" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + <div class="cellWithNoOverflow firstRowSecondColumn alignSelfUnsafeCenter" data-offset-x="250" data-offset-y="40" data-expected-width="50" data-expected-height="40"></div> + <div class="cellOverflowHeight secondRowSecondColumn" data-offset-x="250" data-offset-y="120" data-expected-width="50" data-expected-height="150"></div> + <div class="cellWithNoOverflow thirdRowSecondColumn" data-offset-x="250" data-offset-y="320" data-expected-width="50" data-expected-height="40"></div> + </div> +</div> + +</body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html new file mode 100644 index 0000000..c8fd340 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-grid/alignment/grid-align-justify-stretch-with-orthogonal-flows.html
@@ -0,0 +1,124 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>CSS Grid Layout test:align stretch with orthogonal flows</title> +<link rel="author" title="Rossana Monteriso" href="mailto:rmonteriso@igalia.com"> +<link rel="help" href="https://drafts.csswg.org/css-writing-modes-4/#orthogonal-flows"> +<link rel="help" href="https://drafts.csswg.org/css-align-3/#distribution-values"> +<meta name="assert" content="This test checks that stretching alignment works as expected with orthogonal flows, in horizontal and vertical writing mode."> +<meta name="flags" content="ahem"> +<link rel="stylesheet" href="/css/support/grid.css"> +<link rel="stylesheet" href="/css/support/alignment.css"> +<link rel="stylesheet" href="/css/support/width-keyword-classes.css"> +<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" /> + +<style> + +.container { + position: relative; +} +.grid { + grid-template-columns: 100px 100px; + grid-template-rows: 150px 150px; + font: 10px/1 ahem; + margin-bottom: 20px; +} +.widthAndHeightSet { + width: 20px; + height: 40px; +} +.onlyWidthSet { width: 20px; } +.onlyHeightSet { height: 40px; } +.maxHeight { max-height: 160px; } +.maxWidth { max-width: 90px; } +.minWidth { min-width: 120px; } +.minHeight { min-height: 220px; } +.topAutoMargin { margin-top: auto; } +.bottomAutoMargin { margin-bottom: auto; } +.leftAutoMargin { margin-left: auto; } +.rightAutoMargin { margin-right: auto; } +</style> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/check-layout-th.js"></script> + +<body onload="checkLayout('.grid')"> + +<p>This test checks that stretching alignment works as expected with orthogonal flows.</p> + +<p>HORIZONTAL vs VERTICAL-RL</p> +<div class="container"> + <div class="grid fit-content" data-expected-width="200" data-expected-height="300"> + <div class="verticalRL firstRowFirstColumn selfStretch widthAndHeightSet" data-expected-width="20" data-expected-height="40">XXX</div> + <div class="verticalRL firstRowSecondColumn selfStretch onlyWidthSet" data-expected-width="20" data-expected-height="150">XXX</div> + <div class="verticalRL secondRowFirstColumn selfStretch onlyHeightSet" data-expected-width="100" data-expected-height="40">XXX</div> + <div class="verticalRL secondRowSecondColumn selfSelfStart" data-expected-width="10" data-expected-height="30">XXX</div> + </div> +</div> + +<div class="container"> + <div class="grid fit-content" data-expected-width="200" data-expected-height="300"> + <div class="verticalRL firstRowFirstColumn selfStretch bottomAutoMargin" data-expected-width="100" data-expected-height="30">XXX</div> + <div class="verticalRL firstRowSecondColumn selfStretch leftAutoMargin" data-expected-width="10" data-expected-height="150">XXX</div> + <div class="verticalRL secondRowFirstColumn selfStretch topAutoMargin" data-expected-width="100" data-expected-height="30">XXX</div> + <div class="verticalRL secondRowSecondColumn selfStretch rightAutoMargin" data-expected-width="10" data-expected-height="150">XXX</div> + </div> +</div> + +<p>HORIZONTAL vs VERTICAL-LR</p> +<div class="container"> + <div class="grid fit-content" data-expected-width="200" data-expected-height="300"> + <div class="verticalLR firstRowFirstColumn selfStretch widthAndHeightSet" data-expected-width="20" data-expected-height="40">XXX</div> + <div class="verticalLR firstRowSecondColumn selfStretch onlyWidthSet" data-expected-width="20" data-expected-height="150">XXX</div> + <div class="verticalLR secondRowFirstColumn selfStretch onlyHeightSet" data-expected-width="100" data-expected-height="40">XXX</div> + <div class="verticalLR secondRowSecondColumn selfSelfStart" data-expected-width="10" data-expected-height="30">XXX</div> + </div> +</div> +<div class="container"> + <div class="grid fit-content" data-expected-width="200" data-expected-height="300"> + <div class="verticalLR firstRowFirstColumn selfStretch bottomAutoMargin" data-expected-width="100" data-expected-height="30">XXX</div> + <div class="verticalLR firstRowSecondColumn selfStretch leftAutoMargin" data-expected-width="10" data-expected-height="150">XXX</div> + <div class="verticalLR secondRowFirstColumn selfStretch topAutoMargin" data-expected-width="100" data-expected-height="30">XXX</div> + <div class="verticalLR secondRowSecondColumn selfStretch rightAutoMargin" data-expected-width="10" data-expected-height="150">XXX</div> + </div> +</div> + +<p>VERTICAL-RL vs HORIZONTAL</p> +<div class="container"> + <div class="grid fit-content verticalRL" data-expected-width="300" data-expected-height="200"> + <div class="horizontalTB firstRowFirstColumn selfStretch widthAndHeightSet" data-expected-width="20" data-expected-height="40">XXX</div> + <div class="horizontalTB firstRowSecondColumn selfStretch onlyWidthSet" data-expected-width="20" data-expected-height="100">XXX</div> + <div class="horizontalTB secondRowFirstColumn selfStretch onlyHeightSet" data-expected-width="150" data-expected-height="40">XXX</div> + <div class="horizontalTB secondRowSecondColumn selfSelfStart" data-expected-width="30" data-expected-height="10">XXX</div> + </div> +</div> +<div class="container"> + <div class="grid fit-content verticalRL" data-expected-width="300" data-expected-height="200"> + <div class="horizontalTB firstRowFirstColumn selfStretch bottomAutoMargin" data-expected-width="150" data-expected-height="10">XXX</div> + <div class="horizontalTB firstRowSecondColumn selfStretch leftAutoMargin" data-expected-width="30" data-expected-height="100">XXX</div> + <div class="horizontalTB secondRowFirstColumn selfStretch topAutoMargin" data-expected-width="150" data-expected-height="10">XXX</div> + <div class="horizontalTB secondRowSecondColumn selfStretch rightAutoMargin" data-expected-width="30" data-expected-height="100">XXX</div> + </div> +</div> + +<p>VERTICAL-LR vs HORIZONTAL</p> +<div class="container"> + <div class="grid fit-content verticalLR" data-expected-width="300" data-expected-height="200"> + <div class="horizontalTB firstRowFirstColumn selfStretch widthAndHeightSet" data-expected-width="20" data-expected-height="40">XXX</div> + <div class="horizontalTB firstRowSecondColumn selfStretch onlyWidthSet" data-expected-width="20" data-expected-height="100">XXX</div> + <div class="horizontalTB secondRowFirstColumn selfStretch onlyHeightSet" data-expected-width="150" data-expected-height="40">XXX</div> + <div class="horizontalTB secondRowSecondColumn selfSelfStart" data-expected-width="30" data-expected-height="10">XXX</div> + </div> +</div> +<div class="container"> + <div class="grid fit-content verticalLR" data-expected-width="300" data-expected-height="200"> + <div class="horizontalTB firstRowFirstColumn selfStretch bottomAutoMargin" data-expected-width="150" data-expected-height="10">XXX</div> + <div class="horizontalTB firstRowSecondColumn selfStretch leftAutoMargin" data-expected-width="30" data-expected-height="100">XXX</div> + <div class="horizontalTB secondRowFirstColumn selfStretch topAutoMargin" data-expected-width="150" data-expected-height="10">XXX</div> + <div class="horizontalTB secondRowSecondColumn selfStretch rightAutoMargin" data-expected-width="30" data-expected-height="100">XXX</div> + </div> +</div> + +<div id="log"></div> + +</body>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain.html b/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain.html index dc06eab..70e25b8 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain.html +++ b/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain.html
@@ -14,6 +14,8 @@ </head> <script> +setup({ single_test: true }); + function changeBackground() { document.getElementById("target").style.setProperty("background", "url(data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7) no-repeat scroll top right");
diff --git a/third_party/blink/web_tests/external/wpt/css/css-position/position-absolute-dynamic-relayout-002.html b/third_party/blink/web_tests/external/wpt/css/css-position/position-absolute-dynamic-relayout-002.html new file mode 100644 index 0000000..4dc2dc0 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/css/css-position/position-absolute-dynamic-relayout-002.html
@@ -0,0 +1,14 @@ +<!DOCTYPE html> +<link rel="match" href="../reference/ref-filled-green-100px-square.xht"> +<link rel="help" href="https://www.w3.org/TR/css-position-3/" /> +<meta name="assert" content="This test checks that a dynamic change padding-box location, but no change in available-size positions correctly an absolute child correctly."/> +<p>Test passes if there is a filled green square and <strong>no red</strong>.</p> +<div id="target" style="position: relative; background: red; margin: 25px; width: 50px; height: 50px;"> + <div style="position: absolute; top: 0; left: 0; width: 50px; height: 50px; background: green;"></div> +</div> +<script> + document.body.offsetTop; + const target = document.getElementById('target'); + target.style.border = '25px solid green'; + target.style.margin = '0'; +</script>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/README.md b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/README.md index 8ce2a95..78f1387 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/README.md +++ b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/README.md
@@ -1,4 +1,4 @@ -## Scroll Anchoring Web Platform Tests +## Scroll Anchoring Test Suite Scroll anchoring adjusts the scroll position to prevent visible jumps (or "reflows") when content changes above the viewport.
diff --git a/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/nested-overflow-subtree-layout.html b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/nested-overflow-subtree-layout.html index ffa52b6..e7696016 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/nested-overflow-subtree-layout.html +++ b/third_party/blink/web_tests/external/wpt/css/css-scroll-anchoring/nested-overflow-subtree-layout.html
@@ -1,4 +1,5 @@ <!DOCTYPE html> +<html class="reftest-wait"> <head> <title>Test that subtree layout with nested overflow preserves scroll anchoring.</title> <link rel="author" title="Chris Harrelson" href="mailto:chrishtr@chromium.org"> @@ -42,7 +43,7 @@ const elem = document.createElement("p"); elem.textContent = "FAIL"; inner.insertBefore(elem, inner.firstChild); - document.documentElement.removeAttribute("class"); + takeScreenshot(); }); }); });
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/word-break/reference/word-break-break-all-inline-006-ref.html b/third_party/blink/web_tests/external/wpt/css/css-text/word-break/reference/word-break-break-all-inline-006-ref.html index 0232ecb..268536c9 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/word-break/reference/word-break-break-all-inline-006-ref.html +++ b/third_party/blink/web_tests/external/wpt/css/css-text/word-break/reference/word-break-break-all-inline-006-ref.html
@@ -5,5 +5,5 @@ .testdiv { font-family: monospace; width: 6.1ch; padding: 1px; margin: 10px; border: 1px solid silver; } </style> <div>Test passes if the two boxes are the same.</div> -<div class="testdiv">aaaabb<br>bbbbbb<br>bbbccccc</div> -<div class="testdiv">aaaabb<br>bbbbbb<br>bbbccccc</div> +<div class="testdiv">aaaabb<br>bbbbbb<br>bbb<br>ccccc</div> +<div class="testdiv">aaaabb<br>bbbbbb<br>bbb<br>ccccc</div>
diff --git a/third_party/blink/web_tests/external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html b/third_party/blink/web_tests/external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html index af2f6fb..9f9a618 100644 --- a/third_party/blink/web_tests/external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html +++ b/third_party/blink/web_tests/external/wpt/css/css-text/word-break/word-break-break-all-inline-006.html
@@ -11,4 +11,10 @@ </style> <div>Test passes if the two boxes are the same.</div> <div class="testdiv">aaaa<span class="test">bbbbbbbbbbb</span>ccccc</div> -<div class="testdiv">aaaabb<br>bbbbbb<br>bbbccccc</div> +<!-- +Some browsers may decide to break before the last 'b', which is still conformant from the spec +perspective. However, this test would fail in that case. Current spec states that behavior is +undefined in the boundaries of the inline-box. See https://github.com/web-platform-tests/wpt/issues/19903 +and https://github.com/w3c/csswg-drafts/issues/3897 for details. +--> +<div class="testdiv">aaaabb<br>bbbbbb<br>bbb<br>ccccc</div>
diff --git a/third_party/blink/web_tests/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt b/third_party/blink/web_tests/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt index 42e1de3..7de9bd54 100644 --- a/third_party/blink/web_tests/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt +++ b/third_party/blink/web_tests/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught SyntaxError: Unexpected token 'return' Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_svg_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_svg_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_svg_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-document_on_svg_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt index 42e1de3..2d33166 100644 --- a/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt +++ b/third_party/blink/web_tests/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught ReferenceError: ATTAcomm is not defined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt index c960d0d..da3565a 100644 --- a/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt +++ b/third_party/blink/web_tests/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt
@@ -7,7 +7,7 @@ PASS JS-engine-created TypeError (cross-site iframe) PASS web API-created TypeError (worker) PASS web API-created TypeError (cross-site iframe) -FAIL web API-created DOMException (worker) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1917:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined -FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1917:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined +FAIL web API-created DOMException (worker) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1931:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined +FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1931:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/resources/imagemap.html b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/resources/imagemap.html new file mode 100644 index 0000000..fa3d95c --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/resources/imagemap.html
@@ -0,0 +1,5 @@ +<!DOCTYPE html> +<body> +<img src="/media/poster.png" usemap="#map"> +<map name="map"></map> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt new file mode 100644 index 0000000..7d272ee --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements-expected.txt
@@ -0,0 +1,9 @@ +This is a testharness.js-based test. +PASS Contenteditable element should support autofocus +PASS Element with tabindex should support autofocus +PASS Non-HTMLElement should not support autofocus +PASS Host element with delegatesFocus should support autofocus +FAIL Host element with delegatesFocus including no focusable descendants should be skipped assert_equals: expected Element node <input autofocus=""></input> but got Element node <body><div autofocus=""></div><input autofocus=""></body> +PASS Area element should support autofocus +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements.html b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements.html index 7619367..29b3f3f 100644 --- a/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements.html +++ b/third_party/blink/web_tests/external/wpt/html/interaction/focus/the-autofocus-attribute/supported-elements.html
@@ -34,4 +34,50 @@ await waitUntilStableAutofocusState(w); assert_equals(w.document.activeElement.tagName, 'BODY'); }, 'Non-HTMLElement should not support autofocus'); + +promise_test(async t => { + let w = window.open('/common/blank.html'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + const host = w.document.createElement('div'); + host.autofocus = true; + const shadow = host.attachShadow({mode:'closed', delegatesFocus:true}); + shadow.appendChild(w.document.createElement('input')); + w.document.body.appendChild(host); + await waitUntilStableAutofocusState(w); + assert_equals(w.document.activeElement, host); + assert_equals(shadow.activeElement.tagName, 'INPUT'); +}, 'Host element with delegatesFocus should support autofocus'); + +promise_test(async t => { + let w = window.open('/common/blank.html'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + const host = w.document.createElement('div'); + host.autofocus = true; + host.attachShadow({mode:'closed', delegatesFocus:true}); + w.document.body.appendChild(host); + const next = w.document.createElement('input'); + next.autofocus = true; + w.document.body.appendChild(next); + await waitUntilStableAutofocusState(w); + assert_equals(w.document.activeElement, next); +}, 'Host element with delegatesFocus including no focusable descendants should be skipped'); + +promise_test(async t => { + let w = window.open('./resources/imagemap.html'); + await waitForLoad(w); + t.add_cleanup(() => { w.close(); }); + const area = w.document.createElement('area'); + area.autofocus = true; + area.shape = 'rect'; + area.coords = '1,1,99,99'; + area.href = '/common/blank.html'; + w.document.querySelector('map').appendChild(area); + await waitUntilStableAutofocusState(w); + // According to the specification, DOM anchor for an AREA shape is an IMG + // element, but major browsers don't follow it. + // See https://github.com/whatwg/html/issues/5054 + assert_equals(w.document.activeElement, area); +}, 'Area element should support autofocus'); </script>
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once-expected.txt b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once-expected.txt new file mode 100644 index 0000000..711dc73 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once-expected.txt
@@ -0,0 +1,8 @@ +This is a testharness.js-based test. +FAIL An autofocus element in a dialog element should not try to get focus twice. assert_equals: Non-dialog autofocus processing should be skipped. expected Element node <body> +<dialog open=""> +<input> +<input autofocus=""> +</di... but got Element node <input autofocus=""></input> +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html new file mode 100644 index 0000000..894efd5 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-autofocus-just-once.html
@@ -0,0 +1,24 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script> +<body> +<dialog> +<input> +<input autofocus> +</dialog> +<script> +// https://github.com/whatwg/html/issues/4788 +promise_test(async () => { + const dialog = document.querySelector('dialog'); + dialog.show(); + assert_equals(document.activeElement, dialog.querySelector('[autofocus]'), + 'dialog.show() should set focus on a descendant element with an ' + + 'autofocus attribute.'); + document.activeElement.blur(); + await waitUntilStableAutofocusState(); + assert_equals(document.activeElement, document.body, + 'Non-dialog autofocus processing should be skipped.'); +}, 'An autofocus element in a dialog element should not try to get focus twice.'); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus-expected.txt b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus-expected.txt new file mode 100644 index 0000000..6b55e9ff --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus-expected.txt
@@ -0,0 +1,7 @@ +This is a testharness.js-based test. +FAIL After showing a dialog, non-dialog autofocus processing won't work. assert_equals: Non-dialog autofocus processing should be skipped. expected Element node <body> +<input autofocus=""><dialog></dialog> +<script> +// ... but got Element node <input autofocus=""></input> +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html new file mode 100644 index 0000000..2e8563f --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/html/semantics/interactive-elements/the-dialog-element/dialog-focusing-steps-prevent-autofocus.html
@@ -0,0 +1,21 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script> +<body> +<dialog></dialog> +<script> +// https://github.com/whatwg/html/issues/4788 +promise_test(async () => { + const dialog = document.querySelector('dialog'); + dialog.show(); + dialog.close(); + const input = document.createElement('input'); + input.autofocus = true; + document.body.insertBefore(input, dialog); + await waitUntilStableAutofocusState(); + assert_equals(document.activeElement, document.body, + 'Non-dialog autofocus processing should be skipped.'); +}, 'After showing a dialog, non-dialog autofocus processing won\'t work.'); +</script> +</body>
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-expected.txt new file mode 100644 index 0000000..55b65f46 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-expected.txt
@@ -0,0 +1,8 @@ +This is a testharness.js-based test. +NOTRUN test precondition 1 +NOTRUN async_test immediate precondition 2 +NOTRUN async_test after timeout precondition 3 +NOTRUN promise_test immediate precondition 4 +NOTRUN promise_test after await precondition 5 +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise-expected.txt new file mode 100644 index 0000000..4b71dc9 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +Harness Error. harness_status.status = 3 , harness_status.message = Unhandled rejection +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise.html b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise.html new file mode 100644 index 0000000..b2a32fa --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-promise.html
@@ -0,0 +1,10 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Precondition in promise</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +new Promise(() => { + assert_precondition(false); +}); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup-expected.txt new file mode 100644 index 0000000..6f2395e8 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +Harness Error. harness_status.status = 3 , harness_status.message = Error +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup.html b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup.html new file mode 100644 index 0000000..071f140 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-in-setup.html
@@ -0,0 +1,10 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Precondition in setup</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +setup(() => { + assert_precondition(false); +}); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup-expected.txt new file mode 100644 index 0000000..a96b3ea4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +Harness Error. harness_status.status = 3 , harness_status.message = Uncaught Error +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup.html b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup.html new file mode 100644 index 0000000..12188db --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition-without-setup.html
@@ -0,0 +1,8 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Precondition without wrapping setup</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +assert_precondition(false); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition.html b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition.html new file mode 100644 index 0000000..2e6ddc1 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/precondition.html
@@ -0,0 +1,31 @@ +<!DOCTYPE html> +<meta charset=utf-8> +<title>Preconditions in tests</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(() => { + assert_precondition(false, 'precondition 1'); +}, 'test'); + +async_test((t) => { + assert_precondition(false, 'precondition 2'); + t.done(); +}, 'async_test immediate'); + +async_test((t) => { + t.step_timeout(() => { + assert_precondition(false, 'precondition 3'); + t.done(); + }, 100); +}, 'async_test after timeout'); + +promise_test(async () => { + assert_precondition(false, 'precondition 4'); +}, 'promise_test immediate'); + +promise_test(async () => { + await Promise.resolve(); + assert_precondition(false, 'precondition 5'); +}, 'promise_test after await'); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt index 42e1de3..49826f8 100644 --- a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught Error: error outside any setup or test Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt index 42e1de3..1d0b2e7 100644 --- a/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt +++ b/third_party/blink/web_tests/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: error outside any setup or test Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-promise.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-promise.html.ini new file mode 100644 index 0000000..7210f8d --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-promise.html.ini
@@ -0,0 +1,2 @@ +[precondition-in-promise.html] + expected: PRECONDITION_FAILED
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-setup.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-setup.html.ini new file mode 100644 index 0000000..a33ebaf --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-in-setup.html.ini
@@ -0,0 +1,2 @@ +[precondition-in-setup.html] + expected: PRECONDITION_FAILED
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-without-setup.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-without-setup.html.ini new file mode 100644 index 0000000..406db30a --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition-without-setup.html.ini
@@ -0,0 +1,2 @@ +[precondition-without-setup.html] + expected: PRECONDITION_FAILED
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition.html.ini new file mode 100644 index 0000000..91544eb --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/expected-fail/precondition.html.ini
@@ -0,0 +1,15 @@ +[precondition.html] + [test] + expected: PRECONDITION_FAILED + + [async_test immediate] + expected: PRECONDITION_FAILED + + [async_test after timeout] + expected: PRECONDITION_FAILED + + [promise_test immediate] + expected: PRECONDITION_FAILED + + [promise_test after await] + expected: PRECONDITION_FAILED
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/actions/multiTouchPoints.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/actions/multiTouchPoints.html.ini new file mode 100644 index 0000000..c7b3482 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/actions/multiTouchPoints.html.ini
@@ -0,0 +1,3 @@ +[multiTouchPoints.html] + expected: + if product == "firefox" or product == "safari" or product == "epiphany" or product == "webkit": ERROR
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini new file mode 100644 index 0000000..88c9bbd4 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/metadata/infrastructure/testdriver/virtual_authenticator.html.ini
@@ -0,0 +1,3 @@ +[virtual_authenticator.html] + expected: + if product == "firefox" or product == "safari" or product == "epiphany" or product == "webkit": ERROR
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator-expected.txt b/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator-expected.txt new file mode 100644 index 0000000..51c86eaa --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator-expected.txt
@@ -0,0 +1,10 @@ +This is a testharness.js-based test. +FAIL Can create an authenticator promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can add a credential promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can get the credentials promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can remove a credential promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can remove all credentials promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can set user verified promise_test: Unhandled rejection with value: object "Error: unimplemented" +FAIL Can remove a virtual authenticator promise_test: Unhandled rejection with value: object "Error: unimplemented" +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator.html b/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator.html new file mode 100644 index 0000000..339e42665 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/infrastructure/testdriver/virtual_authenticator.html
@@ -0,0 +1,81 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>TestDriver virtual authenticator methods</title> +<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> +"use strict"; + +// The example attestation private key from the U2F spec at +// https://fidoalliance.org/specs/fido-u2f-v1.2-ps-20170411/fido-u2f-raw-message-formats-v1.2-ps-20170411.html#registration-example +// PKCS.8 encoded without encryption, as a base64url string. +const private_key = + "MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQg8_zMDQDYAxlU-Q" + + "hk1Dwkf0v18GZca1DMF3SaJ9HPdmShRANCAASNYX5lyVCOZLzFZzrIKmeZ2jwU" + + "RmgsJYxGP__fWN_S-j5sN4tT15XEpN_7QZnt14YvI6uvAgO0uJEboFaZlOEB"; +let credential_id = btoa("cred-1"); +let credential = { + credentialId: credential_id, + rpId: window.location.hostname, + privateKey: private_key, + signCount: 0, + isResidentCredential: false, +}; + +let authenticator_id; + +promise_test(async t => { + authenticator_id = await test_driver.add_virtual_authenticator({ + protocol: "ctap1/u2f", + transport: "usb", + }); +}, "Can create an authenticator"); + +promise_test(async t => { + return test_driver.add_credential(authenticator_id, credential); +}, "Can add a credential"); + +promise_test(async t => { + let credentials = await test_driver.get_credentials(authenticator_id); + assert_equals(credentials.length, 1); + // The U2F REGISTER operation stores the hash of the rpId, so the rpId + // itself may not be available on the returned credential. + assert_equals(credentials[0].credentialId, credential.credentialId); + assert_equals(credentials[0].privateKey, credential.privateKey); + assert_equals(credentials[0].signCount, credential.signCount); + assert_equals(credentials[0].isResidentCredential, + credential.isResidentCredential); +}, "Can get the credentials"); + +promise_test(async t => { + await test_driver.remove_credential(authenticator_id, credential_id); + let credentials = await test_driver.get_credentials(authenticator_id); + assert_equals(credentials.length, 0); +}, "Can remove a credential"); + +promise_test(async t => { + let credential1 = credential; + let credential2 = + Object.assign({}, credential, {credentialId: btoa("cred-2")}); + await test_driver.add_credential(authenticator_id, credential1); + await test_driver.add_credential(authenticator_id, credential2); + + let credentials = await test_driver.get_credentials(authenticator_id); + assert_equals(credentials.length, 2); + + await test_driver.remove_all_credentials(authenticator_id); + credentials = await test_driver.get_credentials(authenticator_id); + assert_equals(credentials.length, 0); +}, "Can remove all credentials"); + +promise_test(async t => { + await test_driver.set_user_verified(authenticator_id, {isUserVerified: true}); + await test_driver.set_user_verified(authenticator_id, {isUserVerified: false}); +}, "Can set user verified"); + +promise_test(async t => { + await test_driver.remove_virtual_authenticator(authenticator_id); +}, "Can remove a virtual authenticator"); +</script>
diff --git a/third_party/blink/web_tests/external/wpt/input-events/input-events-typing-manual.html b/third_party/blink/web_tests/external/wpt/input-events/input-events-typing.html similarity index 74% rename from third_party/blink/web_tests/external/wpt/input-events/input-events-typing-manual.html rename to third_party/blink/web_tests/external/wpt/input-events/input-events-typing.html index 5f81c33c..153193c 100644 --- a/third_party/blink/web_tests/external/wpt/input-events/input-events-typing-manual.html +++ b/third_party/blink/web_tests/external/wpt/input-events/input-events-typing.html
@@ -3,6 +3,9 @@ <title>InputEvent have correct data/order when typing on textarea and contenteditable</title> <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="/resources/testdriver-actions.js"></script> <p>To manually run this test, please follow the steps below:<br/> 1. Focus the first box and press key 'a' and then Shift-'b'.<br/> 2. Focus the second box and press key 'c' and then Shift-'d'.<br/> @@ -56,5 +59,24 @@ })); } } -}); -</script> + document.getElementById('plain').focus(); + new test_driver.Actions() + .keyDown('a') + .keyUp('a') + .keyDown('\uE008') // Shift + .keyDown('B') + .keyUp('B') + .keyUp('\uE008') + .send() + .then(() => { + document.getElementById('rich').focus(); + new test_driver.Actions() + .keyDown('c') + .keyUp('c') + .keyDown('\uE008') // Shift + .keyDown('D') + .keyUp('D') + .keyUp('\uE008') + .send(); + }); +});</script>
diff --git a/third_party/blink/web_tests/external/wpt/interfaces/fetch.idl b/third_party/blink/web_tests/external/wpt/interfaces/fetch.idl index 9ff4aab..eacc69d8 100644 --- a/third_party/blink/web_tests/external/wpt/interfaces/fetch.idl +++ b/third_party/blink/web_tests/external/wpt/interfaces/fetch.idl
@@ -70,7 +70,7 @@ any window; // can only be set to null }; -enum RequestDestination { "", "audio", "audioworklet", "document", "embed", "font", "frame", "iframe", "image", "manifest", "object", "paintworklet", "report", "script", "sharedworker", "style", "track", "video", "worker", "xslt" }; +enum RequestDestination { "", "audio", "audioworklet", "document", "embed", "font", "image", "manifest", "object", "paintworklet", "report", "script", "sharedworker", "style", "track", "video", "worker", "xslt" }; enum RequestMode { "navigate", "same-origin", "no-cors", "cors" }; enum RequestCredentials { "omit", "same-origin", "include" }; enum RequestCache { "default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached" };
diff --git a/third_party/blink/web_tests/external/wpt/interfaces/resize-observer.idl b/third_party/blink/web_tests/external/wpt/interfaces/resize-observer.idl index d96a348a..8018fc4 100644 --- a/third_party/blink/web_tests/external/wpt/interfaces/resize-observer.idl +++ b/third_party/blink/web_tests/external/wpt/interfaces/resize-observer.idl
@@ -4,7 +4,7 @@ // Source: Resize Observer (https://drafts.csswg.org/resize-observer/) enum ResizeObserverBoxOptions { - "border-box", "content-box" + "border-box", "content-box", "device-pixel-content-box" }; dictionary ResizeObserverOptions { @@ -27,6 +27,7 @@ readonly attribute DOMRectReadOnly contentRect; readonly attribute ResizeObserverSize borderBoxSize; readonly attribute ResizeObserverSize contentBoxSize; + readonly attribute ResizeObserverSize devicePixelContentBoxSize; }; interface ResizeObserverSize {
diff --git a/third_party/blink/web_tests/external/wpt/interfaces/webauthn.idl b/third_party/blink/web_tests/external/wpt/interfaces/webauthn.idl index 81728b8..fd35c0d 100644 --- a/third_party/blink/web_tests/external/wpt/interfaces/webauthn.idl +++ b/third_party/blink/web_tests/external/wpt/interfaces/webauthn.idl
@@ -117,6 +117,7 @@ required DOMString type; required DOMString challenge; required DOMString origin; + boolean crossOrigin; TokenBinding tokenBinding; };
diff --git a/third_party/blink/web_tests/external/wpt/interfaces/webrtc.idl b/third_party/blink/web_tests/external/wpt/interfaces/webrtc.idl index 5a5eb7b..d828fae 100644 --- a/third_party/blink/web_tests/external/wpt/interfaces/webrtc.idl +++ b/third_party/blink/web_tests/external/wpt/interfaces/webrtc.idl
@@ -42,14 +42,10 @@ }; enum RTCRtcpMuxPolicy { - // At risk due to lack of implementers' interest. - "negotiate", "require" }; -dictionary RTCOfferAnswerOptions { - boolean voiceActivityDetection = true; -}; +dictionary RTCOfferAnswerOptions {}; dictionary RTCOfferOptions : RTCOfferAnswerOptions { boolean iceRestart = false; @@ -111,7 +107,6 @@ readonly attribute RTCPeerConnectionState connectionState; readonly attribute boolean? canTrickleIceCandidates; void restartIce(); - static sequence<RTCIceServer> getDefaultIceServers(); RTCConfiguration getConfiguration(); void setConfiguration(RTCConfiguration configuration); void close(); @@ -266,7 +261,6 @@ [Exposed=Window, Serializable] interface RTCCertificate { readonly attribute DOMTimeStamp expires; - static sequence<AlgorithmIdentifier> getSupportedAlgorithms(); sequence<RTCDtlsFingerprint> getFingerprints(); }; @@ -299,7 +293,6 @@ interface RTCRtpSender { readonly attribute MediaStreamTrack? track; readonly attribute RTCDtlsTransport? transport; - readonly attribute RTCDtlsTransport? rtcpTransport; static RTCRtpCapabilities? getCapabilities(DOMString kind); Promise<void> setParameters(RTCRtpSendParameters parameters); RTCRtpSendParameters getParameters(); @@ -332,20 +325,12 @@ dictionary RTCRtpDecodingParameters : RTCRtpCodingParameters {}; dictionary RTCRtpEncodingParameters : RTCRtpCodingParameters { - octet codecPayloadType; - RTCDtxStatus dtx; boolean active = true; - unsigned long ptime; unsigned long maxBitrate; double maxFramerate; double scaleResolutionDownBy; }; -enum RTCDtxStatus { - "disabled", - "enabled" -}; - enum RTCDegradationPreference { "maintain-framerate", "maintain-resolution", @@ -391,7 +376,6 @@ interface RTCRtpReceiver { readonly attribute MediaStreamTrack track; readonly attribute RTCDtlsTransport? transport; - readonly attribute RTCDtlsTransport? rtcpTransport; static RTCRtpCapabilities? getCapabilities(DOMString kind); RTCRtpReceiveParameters getParameters(); sequence<RTCRtpContributingSource> getContributingSources();
diff --git a/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html index ca3e679..d50e69e 100644 --- a/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html +++ b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/css-inline-style-dynamic.tentative.html
@@ -5,6 +5,7 @@ <title>MathML 'ElementCSSInlineStyle` Dynamic Tests</title> <link rel="help" href="https://mathml-refresh.github.io/mathml-core/#dom-and-javascript"/> <link rel="match" href="css-inline-style-dynamic.tentative-ref.html"/> + <script src="/mathml/support/feature-detection.js"></script> <style> #hidden { visibility: hidden; @@ -21,9 +22,17 @@ <script type="text/javascript"> function test() { + MathMLFeatureDetection.ensure_for_match_reftest("has_mspace"); document.body.offsetTop; // Update layout - document.getElementById("hidden").style.visibility = "visible"; - document.getElementById("red").style.backgroundColor = "green"; + + var mspace = document.getElementById("hidden"); + if (mspace.style) + mspace.style.visibility = "visible"; + + mspace = document.getElementById("red"); + if (mspace.style) + mspace.style.backgroundColor = "green"; + document.documentElement.className = ""; } </script>
diff --git a/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3-expected.txt b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3-expected.txt new file mode 100644 index 0000000..ac78ee3 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Click element with href assert_unreached: Click failed Reached unreachable code +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3.html b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3.html index a8475ea..1b7f068 100644 --- a/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3.html +++ b/third_party/blink/web_tests/external/wpt/mathml/relations/html5-tree/href-click-3.html
@@ -19,10 +19,20 @@ <mspace width="50px" height="10px" style="background: gray"></mspace> </math> </p> + <a id="badTarget" href="javascript:badHandler()">DON'T CLICK ME</a> <script> var t = async_test("Click element with href"); function handler() { t.done(); } - test_driver.click(document.getElementById("target")); + function badHandler() { + t.step(() => { assert_unreached("Bad handler executed"); }); + t.done(); + } + test_driver.click(document.getElementById("target")).then(() => { + return test_driver.click(document.getElementById("badTarget")); + }).catch(() => { + t.step(() => { assert_unreached("Click failed"); }); + t.done(); + }); </script> </body> </html>
diff --git a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype-expected.txt b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype-expected.txt index 56076d5..264518f 100644 --- a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype-expected.txt +++ b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype-expected.txt
@@ -23,8 +23,8 @@ PASS Supported MIMEType video/webm; codecs="vp9, opus" is set immediately after constructing PASS Unsupported MIMEType video/webm; codecs="av1" throws PASS Unsupported MIMEType video/webm; codecs="av1, opus" throws -FAIL MediaRecorder sets a MIMEType after start() for audio assert_regexp_match: MIMEtype has one codec expected object "/^[a-z]+\/[a-z]+; codecs=[^,]+$/" but got "audio/webm;codecs=opus" -FAIL MediaRecorder sets a MIMEType after start() for video assert_regexp_match: MIMEtype has one codec expected object "/^[a-z]+\/[a-z]+; codecs=[^,]+$/" but got "video/webm;codecs=vp8" -FAIL MediaRecorder sets a MIMEType after start() for audio/video assert_regexp_match: MIMEtype has two codecs expected object "/^[a-z]+\/[a-z]+; codecs=[^,]+,[^,]+$/" but got "video/webm;codecs=vp8,opus" +FAIL MediaRecorder sets a MIMEType after 'start' for audio assert_equals: MediaRecorder has no MIMEtype after start() for audio expected "" but got "audio/webm;codecs=opus" +FAIL MediaRecorder sets a MIMEType after 'start' for video assert_equals: MediaRecorder has no MIMEtype after start() for video expected "" but got "video/webm;codecs=vp8" +FAIL MediaRecorder sets a MIMEType after 'start' for audio/video assert_equals: MediaRecorder has no MIMEtype after start() for audio/video expected "" but got "video/webm;codecs=vp8,opus" Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype.html b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype.html index ddc56e9..e90bbcc 100644 --- a/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype.html +++ b/third_party/blink/web_tests/external/wpt/mediacapture-record/MediaRecorder-mimetype.html
@@ -12,18 +12,28 @@ <script> function createAudioStream(t) { const ac = new AudioContext(); - const {stream} = ac.createMediaStreamDestination(); - const tracks = stream.getTracks(); - t.add_cleanup(() => tracks.forEach(tr => tr.stop())); - return stream; + const dest = ac.createMediaStreamDestination(); + const osc = ac.createOscillator(); + osc.connect(dest); + osc.start(); + const [track] = dest.stream.getTracks(); + t.add_cleanup(() => track.stop()); + return dest.stream; } function createVideoStream(t) { const canvas = document.getElementById("canvas"); - canvas.getContext('2d'); + const ctx = canvas.getContext('2d'); const stream = canvas.captureStream(); - const tracks = stream.getTracks(); - t.add_cleanup(() => tracks.forEach(tr => tr.stop())); + const [track] = stream.getTracks(); + t.add_cleanup(() => track.stop()); + ctx.fillStyle = 'green'; + requestAnimationFrame(function draw() { + ctx.fillRect(0, 0, canvas.width, canvas.height); + if (track.readyState == "live") { + requestAnimationFrame(draw); + } + }); return stream; } @@ -104,44 +114,56 @@ } } -test(t => { +promise_test(async t => { const recorder = new MediaRecorder(createAudioStream(t)); recorder.start(); + assert_equals(recorder.mimeType, "", + "MediaRecorder has no MIMEtype after start() for audio"); + + await new Promise(r => recorder.onstart = r); assert_not_equals(recorder.mimeType, "", - "MediaRecorder has a MIMEtype after start() for audio"); + "MediaRecorder has a MIMEtype after 'start' for audio"); assert_regexp_match(recorder.mimeType, /^audio\//, "MIMEtype has an expected media type"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+/, "MIMEtype has a container subtype"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+; codecs=[^,]+$/, "MIMEtype has one codec"); -}, "MediaRecorder sets a MIMEType after start() for audio"); +}, "MediaRecorder sets a MIMEType after 'start' for audio"); -test(t => { +promise_test(async t => { const recorder = new MediaRecorder(createVideoStream(t)); recorder.start(); + assert_equals(recorder.mimeType, "", + "MediaRecorder has no MIMEtype after start() for video"); + + await new Promise(r => recorder.onstart = r); assert_not_equals(recorder.mimeType, "", - "MediaRecorder has a MIMEtype after start() for video"); + "MediaRecorder has a MIMEtype after 'start' for video"); assert_regexp_match(recorder.mimeType, /^video\//, "MIMEtype has an expected media type"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+/, "MIMEtype has a container subtype"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+; codecs=[^,]+$/, "MIMEtype has one codec"); -}, "MediaRecorder sets a MIMEType after start() for video"); +}, "MediaRecorder sets a MIMEType after 'start' for video"); -test(t => { +promise_test(async t => { const recorder = new MediaRecorder(createAudioVideoStream(t)); recorder.start(); + assert_equals(recorder.mimeType, "", + "MediaRecorder has no MIMEtype after start() for audio/video"); + + await new Promise(r => recorder.onstart = r); assert_not_equals(recorder.mimeType, "", - "MediaRecorder has a MIMEtype after start() for audio/video"); + "MediaRecorder has a MIMEtype after 'start' for audio/video"); assert_regexp_match(recorder.mimeType, /^video\//, "MIMEtype has an expected media type"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+/, "MIMEtype has a container subtype"); assert_regexp_match(recorder.mimeType, /^[a-z]+\/[a-z]+; codecs=[^,]+,[^,]+$/, "MIMEtype has two codecs"); -}, "MediaRecorder sets a MIMEType after start() for audio/video"); +}, "MediaRecorder sets a MIMEType after 'start' for audio/video"); </script> </body> </html>
diff --git a/third_party/blink/web_tests/external/wpt/mixed-content/README.md b/third_party/blink/web_tests/external/wpt/mixed-content/README.md index 407b896..488432d 100644 --- a/third_party/blink/web_tests/external/wpt/mixed-content/README.md +++ b/third_party/blink/web_tests/external/wpt/mixed-content/README.md
@@ -1,4 +1,4 @@ -# Mixed-content Web Platform Tests +# Mixed Content Test Suite The subdirectory `gen/` is generated using the generator at `common/security-features`. See [common/security-features/README.md](../common/security-features/README.md) for how to generate tests.
diff --git a/third_party/blink/web_tests/external/wpt/mixed-content/generic/test-case.sub.js b/third_party/blink/web_tests/external/wpt/mixed-content/generic/test-case.sub.js index 9e9e169f..661cff1 100644 --- a/third_party/blink/web_tests/external/wpt/mixed-content/generic/test-case.sub.js +++ b/third_party/blink/web_tests/external/wpt/mixed-content/generic/test-case.sub.js
@@ -1,5 +1,5 @@ /** - * @fileoverview Test case for mixed-content in Web Platform Tests. + * @fileoverview Test case for mixed-content in web-platform-tests. * @author burnik@google.com (Kristijan Burnik) */
diff --git a/third_party/blink/web_tests/external/wpt/offscreen-canvas/tools/tests2d.yaml b/third_party/blink/web_tests/external/wpt/offscreen-canvas/tools/tests2d.yaml index 6b1876d..0b346bb 100644 --- a/third_party/blink/web_tests/external/wpt/offscreen-canvas/tools/tests2d.yaml +++ b/third_party/blink/web_tests/external/wpt/offscreen-canvas/tools/tests2d.yaml
@@ -8800,7 +8800,6 @@ @assert throws TypeError ctx.transform(1, 0, 0, 1, 0); } if (ctx.setTransform) { - @assert throws TypeError ctx.setTransform(); @assert throws TypeError ctx.setTransform(1); @assert throws TypeError ctx.setTransform(1, 0); @assert throws TypeError ctx.setTransform(1, 0, 0);
diff --git a/third_party/blink/web_tests/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt index 42e1de3..01611e8 100644 --- a/third_party/blink/web_tests/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Not allowed to install this payment handler Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt index 42e1de3..01611e8 100644 --- a/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Not allowed to install this payment handler Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt index 42e1de3..01611e8 100644 --- a/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Not allowed to install this payment handler Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-handler/payment-request-event-manual.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-handler/payment-request-event-manual.https-expected.txt index 42e1de3..01611e8 100644 --- a/third_party/blink/web_tests/external/wpt/payment-handler/payment-request-event-manual.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-handler/payment-request-event-manual.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Not allowed to install this payment handler Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt index 42e1de3..01611e8 100644 --- a/third_party/blink/web_tests/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Not allowed to install this payment handler Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-request/payment-is-showing.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-request/payment-is-showing.https-expected.txt index 42e1de3..bcff8407c 100644 --- a/third_party/blink/web_tests/external/wpt/payment-request/payment-is-showing.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-request/payment-is-showing.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught TypeError: Cannot set property 'click' of undefined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt b/third_party/blink/web_tests/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt index 42e1de3..bcff8407c 100644 --- a/third_party/blink/web_tests/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt +++ b/third_party/blink/web_tests/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught TypeError: Cannot set property 'click' of undefined Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/referrer-policy/README.md b/third_party/blink/web_tests/external/wpt/referrer-policy/README.md index ca9977c..4d6eda9 100644 --- a/third_party/blink/web_tests/external/wpt/referrer-policy/README.md +++ b/third_party/blink/web_tests/external/wpt/referrer-policy/README.md
@@ -1,4 +1,4 @@ -# Referrer-Policy Web Platform Tests +# Referrer Policy Test Suite The Referrer-Policy tests are designed for testing browser implementations and conformance to the [W3 Referrer-Policy Specification](http://w3c.github.io/webappsec/specs/referrer-policy/).
diff --git a/third_party/blink/web_tests/external/wpt/resize-observer/idlharness.window-expected.txt b/third_party/blink/web_tests/external/wpt/resize-observer/idlharness.window-expected.txt index ad10be9..77658f7 100644 --- a/third_party/blink/web_tests/external/wpt/resize-observer/idlharness.window-expected.txt +++ b/third_party/blink/web_tests/external/wpt/resize-observer/idlharness.window-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 56 tests; 34 PASS, 22 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 58 tests; 34 PASS, 24 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS idl_test setup PASS idl_test validation PASS ResizeObserverEntry creator @@ -33,12 +33,14 @@ PASS ResizeObserverEntry interface: attribute contentRect FAIL ResizeObserverEntry interface: attribute borderBoxSize assert_true: The prototype object must have a property "borderBoxSize" expected true got false FAIL ResizeObserverEntry interface: attribute contentBoxSize assert_true: The prototype object must have a property "contentBoxSize" expected true got false +FAIL ResizeObserverEntry interface: attribute devicePixelContentBoxSize assert_true: The prototype object must have a property "devicePixelContentBoxSize" expected true got false PASS ResizeObserverEntry must be primary interface of entry PASS Stringification of entry PASS ResizeObserverEntry interface: entry must inherit property "target" with the proper type PASS ResizeObserverEntry interface: entry must inherit property "contentRect" with the proper type FAIL ResizeObserverEntry interface: entry must inherit property "borderBoxSize" with the proper type assert_inherits: property "borderBoxSize" not found in prototype chain FAIL ResizeObserverEntry interface: entry must inherit property "contentBoxSize" with the proper type assert_inherits: property "contentBoxSize" not found in prototype chain +FAIL ResizeObserverEntry interface: entry must inherit property "devicePixelContentBoxSize" with the proper type assert_inherits: property "devicePixelContentBoxSize" not found in prototype chain FAIL ResizeObserverSize interface: existence and properties of interface object assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing FAIL ResizeObserverSize interface object length assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing FAIL ResizeObserverSize interface object name assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing
diff --git a/third_party/blink/web_tests/external/wpt/resources/testdriver-actions.js b/third_party/blink/web_tests/external/wpt/resources/testdriver-actions.js index 292fe88..d3dc00b 100644 --- a/third_party/blink/web_tests/external/wpt/resources/testdriver-actions.js +++ b/third_party/blink/web_tests/external/wpt/resources/testdriver-actions.js
@@ -195,10 +195,16 @@ * Add a pause to the current tick * * @param {Number?} duration - Minimum length of the tick in ms. + * @param {String} sourceType - source type + * @param {String?} sourceName - Named key or pointer source to use or null for the default + * key or pointer source * @returns {Actions} */ - pause: function(duration) { - this.getSource("none").addPause(this, duration); + pause: function(duration=0, sourceType="none", {sourceName=null}={}) { + if (sourceType=="none") + this.getSource("none").addPause(this, duration); + else + this.getSource(sourceType, sourceName).addPause(this, duration); return this; }, @@ -339,6 +345,14 @@ } this.actions.set(tick, {type: "keyUp", value: key}); }, + + addPause: function(actions, duration) { + let tick = actions.tickIdx; + if (this.actions.has(tick)) { + tick = actions.addTick().tickIdx; + } + this.actions.set(tick, {type: "pause", duration: duration}); + }, }; function PointerSource(parameters={pointerType: "mouse"}) { @@ -393,6 +407,14 @@ this.actions.get(tick).duration = duration; } }, + + addPause: function(actions, duration) { + let tick = actions.tickIdx; + if (this.actions.has(tick)) { + tick = actions.addTick().tickIdx; + } + this.actions.set(tick, {type: "pause", duration: duration}); + }, }; test_driver.Actions = Actions;
diff --git a/third_party/blink/web_tests/external/wpt/resources/testdriver.js b/third_party/blink/web_tests/external/wpt/resources/testdriver.js index 031be1b..bd38e3e 100644 --- a/third_party/blink/web_tests/external/wpt/resources/testdriver.js +++ b/third_party/blink/web_tests/external/wpt/resources/testdriver.js
@@ -208,7 +208,126 @@ */ generate_test_report: function(message) { return window.test_driver_internal.generate_test_report(message); - } + }, + + /** + * Creates a virtual authenticator + * + * This function creates a virtual authenticator for use with the U2F + * and WebAuthn APIs as described in {@link + * https://w3c.github.io/webauthn/#sctn-automation-add-virtual-authenticator} + * + * @param {Object} config - an [Authenticator Configuration]{@link + * https://w3c.github.io/webauthn/#authenticator-configuration} + * object + * @returns {Promise} fulfilled after the authenticator is added, or + * rejected in the cases the WebDriver command + * errors. Returns the ID of the authenticator + */ + add_virtual_authenticator: function(config) { + return window.test_driver_internal.add_virtual_authenticator(config); + }, + + /** + * Removes a virtual authenticator + * + * This function removes a virtual authenticator that has been created + * by add_virtual_authenticator + * https://w3c.github.io/webauthn/#sctn-automation-remove-virtual-authenticator + * + * @param {String} authenticator_id - the ID of the authenticator to be + * removed. + * + * @returns {Promise} fulfilled after the authenticator is removed, or + * rejected in the cases the WebDriver command + * errors + */ + remove_virtual_authenticator: function(authenticator_id) { + return window.test_driver_internal.remove_virtual_authenticator(authenticator_id); + }, + + /** + * Adds a credential to a virtual authenticator + * + * https://w3c.github.io/webauthn/#sctn-automation-add-credential + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {Object} credential - A [Credential Parameters]{@link + * https://w3c.github.io/webauthn/#credential-parameters} + * object + * + * @returns {Promise} fulfilled after the credential is added, or + * rejected in the cases the WebDriver command + * errors + */ + add_credential: function(authenticator_id, credential) { + return window.test_driver_internal.add_credential(authenticator_id, credential); + }, + + /** + * Gets all the credentials stored in an authenticator + * + * This function retrieves all the credentials (added via the U2F API, + * WebAuthn, or the add_credential function) stored in a virtual + * authenticator + * https://w3c.github.io/webauthn/#sctn-automation-get-credentials + * + * @param {String} authenticator_id - the ID of the authenticator + * + * @returns {Promise} fulfilled after the credentials are returned, or + * rejected in the cases the WebDriver command + * errors. Returns an array of [Credential + * Parameters]{@link + * https://w3c.github.io/webauthn/#credential-parameters} + */ + get_credentials: function(authenticator_id) { + return window.test_driver_internal.get_credentials(authenticator_id); + }, + + /** + * Remove a credential stored in an authenticator + * + * https://w3c.github.io/webauthn/#sctn-automation-remove-credential + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {String} credential_id - the ID of the credential + * + * @returns {Promise} fulfilled after the credential is removed, or + * rejected in the cases the WebDriver command + * errors. + */ + remove_credential: function(authenticator_id, credential_id) { + return window.test_driver_internal.remove_credential(authenticator_id, credential_id); + }, + + /** + * Removes all the credentials stored in a virtual authenticator + * + * https://w3c.github.io/webauthn/#sctn-automation-remove-all-credentials + * + * @param {String} authenticator_id - the ID of the authenticator + * + * @returns {Promise} fulfilled after the credentials are removed, or + * rejected in the cases the WebDriver command + * errors. + */ + remove_all_credentials: function(authenticator_id) { + return window.test_driver_internal.remove_all_credentials(authenticator_id); + }, + + /** + * Sets the User Verified flag on an authenticator + * + * Sets whether requests requiring user verification will succeed or + * fail on a given virtual authenticator + * https://w3c.github.io/webauthn/#sctn-automation-set-user-verified + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {boolean} uv - the User Verified flag + */ + set_user_verified: function(authenticator_id, uv) { + return window.test_driver_internal.set_user_verified(authenticator_id, uv); + }, }; window.test_driver_internal = { @@ -306,6 +425,105 @@ */ generate_test_report: function(message) { return Promise.reject(new Error("unimplemented")); - } + }, + + /** + * Creates a virtual authenticator + * + * @param {Object} config - the authenticator configuration + * @returns {Promise} fulfilled after the authenticator is added, or + * rejected in the cases the WebDriver command + * errors. + */ + add_virtual_authenticator: function(config) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Removes a virtual authenticator + * + * @param {String} authenticator_id - the ID of the authenticator to be + * removed. + * + * @returns {Promise} fulfilled after the authenticator is removed, or + * rejected in the cases the WebDriver command + * errors + */ + remove_virtual_authenticator: function(authenticator_id) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Adds a credential to a virtual authenticator + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {Object} credential - A [Credential Parameters]{@link + * https://w3c.github.io/webauthn/#credential-parameters} + * object + * + * @returns {Promise} fulfilled after the credential is added, or + * rejected in the cases the WebDriver command + * errors + * + */ + add_credential: function(authenticator_id, credential) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Gets all the credentials stored in an authenticator + * + * @param {String} authenticator_id - the ID of the authenticator + * + * @returns {Promise} fulfilled after the credentials are returned, or + * rejected in the cases the WebDriver command + * errors. Returns an array of [Credential + * Parameters]{@link + * https://w3c.github.io/webauthn/#credential-parameters} + * + */ + get_credentials: function(authenticator_id) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Remove a credential stored in an authenticator + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {String} credential_id - the ID of the credential + * + * @returns {Promise} fulfilled after the credential is removed, or + * rejected in the cases the WebDriver command + * errors. + * + */ + remove_credential: function(authenticator_id, credential_id) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Removes all the credentials stored in a virtual authenticator + * + * @param {String} authenticator_id - the ID of the authenticator + * + * @returns {Promise} fulfilled after the credentials are removed, or + * rejected in the cases the WebDriver command + * errors. + * + */ + remove_all_credentials: function(authenticator_id) { + return Promise.reject(new Error("unimplemented")); + }, + + /** + * Sets the User Verified flag on an authenticator + * + * @param {String} authenticator_id - the ID of the authenticator + * @param {boolean} uv - the User Verified flag + * + */ + set_user_verified: function(authenticator_id, uv) { + return Promise.reject(new Error("unimplemented")); + }, }; })();
diff --git a/third_party/blink/web_tests/external/wpt/resources/testharness.js b/third_party/blink/web_tests/external/wpt/resources/testharness.js index 7fb1c0c..9380966 100644 --- a/third_party/blink/web_tests/external/wpt/resources/testharness.js +++ b/third_party/blink/web_tests/external/wpt/resources/testharness.js
@@ -792,8 +792,14 @@ function done() { if (tests.tests.length === 0) { - tests.status.status = tests.status.ERROR; - tests.status.message = "done() was called without first defining any tests"; + // `done` is invoked after handling uncaught exceptions, so if the + // harness status is already set, the corresponding message is more + // descriptive than the generic message defined here. + if (tests.status.status === null) { + tests.status.status = tests.status.ERROR; + tests.status.message = "done() was called without first defining any tests"; + } + tests.complete(); return; } @@ -1815,6 +1821,13 @@ } expose(assert_any, "assert_any"); + function assert_precondition(precondition, description) { + if (!precondition) { + throw new PreconditionFailedError(description); + } + } + expose(assert_precondition, "assert_precondition"); + function Test(name, properties) { if (tests.file_is_test && tests.tests.length) { @@ -1859,7 +1872,8 @@ PASS:0, FAIL:1, TIMEOUT:2, - NOTRUN:3 + NOTRUN:3, + PRECONDITION_FAILED:4 }; Test.prototype = merge({}, Test.statuses); @@ -1919,10 +1933,11 @@ if (this.phase >= this.phases.HAS_RESULT) { return; } + var status = e instanceof PreconditionFailedError ? this.PRECONDITION_FAILED : this.FAIL; var message = String((typeof e === "object" && e !== null) ? e.message : e); var stack = e.stack ? e.stack : null; - this.set_status(this.FAIL, message, stack); + this.set_status(status, message, stack); this.phase = this.phases.HAS_RESULT; this.done(); } @@ -2393,7 +2408,8 @@ TestsStatus.statuses = { OK:0, ERROR:1, - TIMEOUT:2 + TIMEOUT:2, + PRECONDITION_FAILED:3 }; TestsStatus.prototype = merge({}, TestsStatus.statuses); @@ -2499,7 +2515,7 @@ try { func(); } catch (e) { - this.status.status = this.status.ERROR; + this.status.status = e instanceof PreconditionFailedError ? this.status.PRECONDITION_FAILED : this.status.ERROR; this.status.message = String(e); this.status.stack = e.stack ? e.stack : null; this.complete(); @@ -3057,12 +3073,14 @@ status_text_harness[harness_status.OK] = "OK"; status_text_harness[harness_status.ERROR] = "Error"; status_text_harness[harness_status.TIMEOUT] = "Timeout"; + status_text_harness[harness_status.PRECONDITION_FAILED] = "Precondition Failed"; var status_text = {}; status_text[Test.prototype.PASS] = "Pass"; status_text[Test.prototype.FAIL] = "Fail"; status_text[Test.prototype.TIMEOUT] = "Timeout"; status_text[Test.prototype.NOTRUN] = "Not Run"; + status_text[Test.prototype.PRECONDITION_FAILED] = "Precondition Failed"; var status_number = {}; forEach(tests, @@ -3444,6 +3462,13 @@ return lines.slice(i).join("\n"); } + function PreconditionFailedError(message) + { + AssertionError.call(this, message); + } + PreconditionFailedError.prototype = Object.create(AssertionError.prototype); + expose(PreconditionFailedError, "PreconditionFailedError"); + function make_message(function_name, description, error, substitutions) { for (var p in substitutions) { @@ -3671,16 +3696,19 @@ var tests = new Tests(); if (global_scope.addEventListener) { - var error_handler = function(message, stack) { + var error_handler = function(error, message, stack) { + var precondition_failed = error instanceof PreconditionFailedError; if (tests.file_is_test) { var test = tests.tests[0]; if (test.phase >= test.phases.HAS_RESULT) { return; } - test.set_status(test.FAIL, message, stack); + var status = precondition_failed ? test.PRECONDITION_FAILED : test.FAIL; + test.set_status(status, message, stack); test.phase = test.phases.HAS_RESULT; } else if (!tests.allow_uncaught_exception) { - tests.status.status = tests.status.ERROR; + var status = precondition_failed ? tests.status.PRECONDITION_FAILED : tests.status.ERROR; + tests.status.status = status; tests.status.message = message; tests.status.stack = stack; } @@ -3702,7 +3730,7 @@ } else { stack = e.filename + ":" + e.lineno + ":" + e.colno; } - error_handler(message, stack); + error_handler(e.error, message, stack); }, false); addEventListener("unhandledrejection", function(e) { @@ -3716,7 +3744,7 @@ if (e.reason && e.reason.stack) { stack = e.reason.stack; } - error_handler(message, stack); + error_handler(e.reason, message, stack); }, false); } @@ -3754,7 +3782,7 @@ \ table#results th:first-child,\ table#results td:first-child {\ - width:4em;\ + width:8em;\ }\ \ table#results th:last-child,\ @@ -3795,7 +3823,11 @@ color:blue;\ }\ \ -.pass > td:first-child, .fail > td:first-child, .timeout > td:first-child, .notrun > td:first-child {\ +tr.preconditionfailed > td:first-child {\ + color:blue;\ +}\ +\ +.pass > td:first-child, .fail > td:first-child, .timeout > td:first-child, .notrun > td:first-child, .preconditionfailed > td:first-child {\ font-variant:small-caps;\ }\ \
diff --git a/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment-target.html b/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment-target.html index 1ef9dbba..1595d8b 100644 --- a/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment-target.html +++ b/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment-target.html
@@ -3,7 +3,8 @@ <script> function isInView(element) { let rect = element.getBoundingClientRect(); - return rect.top >= 0 && rect.top <= window.innerHeight; + return rect.top >= 0 && rect.top <= window.innerHeight + && rect.left >= 0 && rect.left <= window.innerWidth; } function checkScroll() { @@ -22,6 +23,12 @@ position = 'cross-node-context'; else if (isInView(document.getElementById('text-directive-parameters'))) position = 'text-directive-parameters'; + else if (isInView(document.getElementById('shadow-parent'))) + position = 'shadow-parent'; + else if (isInView(document.getElementById('hidden'))) + position = 'hidden'; + else if (isInView(document.getElementById('horizontal-scroll')) && window.scrollX > 0) + position = 'horizontal-scroll'; bc.postMessage({ scrollPosition: position, href: window.location.href }); bc.close(); @@ -29,40 +36,38 @@ } </script> <style> - body { - height: 6200px; + .scroll-section { + /* 1000px margin on top and bottom so only one section can be in view. */ + margin: 1000px 0px; } - #element { - position: absolute; - top: 2000px; + #hidden { + visibility: hidden; } - #text { - position: absolute; - top: 3000px; + #horizontal-scroll { + margin-left: 2000px; } - #more-text { - position: absolute; - top: 4000px; - } - #cross-node-context { - position: absolute; - top: 5000px; - } - #text-directive-parameters { - position: absolute; - top: 6000px; + #display-none { + display: none; } </style> <body onload="window.requestAnimationFrame(checkScroll)"> - <div id="element">Element</div> - <p id="text">This is a test page !$'()*+./:;=?@_~ &,- ♥</p> - <p id="more-text">More test page text</p> - <div id="cross-node-context"> + <div id="element" class="scroll-section">Element</div> + <p id="text" class="scroll-section">This is a test page !$'()*+./:;=?@_~ &,- ネコ</p> + <p id="more-text" class="scroll-section">More test page text</p> + <div id="cross-node-context" class="scroll-section"> <div> <p>prefix</p> <p>test page</p> </div> <div><p>suffix</p></div> </div> - <p id="text-directive-parameters">this,is,test,page</p> + <p id="text-directive-parameters" class="scroll-section">this,is,test,page</p> + <div id="shadow-parent" class="scroll-section"></div> + <script> + let shadow = document.getElementById("shadow-parent").attachShadow({mode: 'open'}); + shadow.innerHTML = '<p>shadow text</p>'; + </script> + <p id="hidden" class="scroll-section">hidden text</p> + <p id="horizontal-scroll" class="scroll-section">horizontally scrolled text</p> + <p id="display-none" class="scroll-section">display none</p> </body>
diff --git a/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment.html b/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment.html index b3a35f4..c0018ed 100644 --- a/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment.html +++ b/third_party/blink/web_tests/external/wpt/scroll-to-text-fragment/scroll-to-text-fragment.html
@@ -13,162 +13,207 @@ { fragment: '#', expect_position: 'top', - description: 'Empty hash' + description: 'Empty hash should scroll to top' }, { fragment: '#:~:text=this,is,test,page', expect_position: 'top', - description: 'Text directive with invalid syntax, context terms without "-"' + description: 'Text directive with invalid syntax (context terms without "-") should not parse as a text directive' }, { fragment: '#element:~:directive', expect_position: 'element', - description: 'Generic fragment directive with existing element fragment' + description: 'Generic fragment directive with existing element fragment should scroll to element' + }, + { + fragment: '#:~:TEXT=test', + expect_position: 'top', + description: 'Uppercase TEXT directive should not parse as a text directive' }, // Test exact text matching, with all combinations of context terms { fragment: '#:~:text=test', expect_position: 'text', - description: 'Exact text with no context' + description: 'Exact text with no context should match text' }, { fragment: '#:~:text=this is a-,test', expect_position: 'text', - description: 'Exact text with prefix' + description: 'Exact text with prefix should match text' }, { fragment: '#:~:text=test,-page', expect_position: 'text', - description: 'Exact text with suffix' + description: 'Exact text with suffix should match text' }, { fragment: '#:~:text=this is a-,test,-page', expect_position: 'text', - description: 'Exact text with prefix and suffix' + description: 'Exact text with prefix and suffix should match text' }, // Test text range matching, with all combinations of context terms { fragment: '#:~:text=this,page', expect_position: 'text', - description: 'Text range with no context' + description: 'Text range with no context should match text' }, { fragment: '#:~:text=this-,is,test', expect_position: 'text', - description: 'Text range with prefix' + description: 'Text range with prefix should match text' }, { fragment: '#:~:text=this,test,-page', expect_position: 'text', - description: 'Text range with suffix' + description: 'Text range with suffix should match text' }, { fragment: '#:~:text=this-,is,test,-page', expect_position: 'text', - description: 'Text range with prefix and suffix' + description: 'Text range with prefix and suffix should match text' }, // Test partially non-matching text ranges { fragment: '#:~:text=this,none', expect_position: 'top', - description: 'Text range with non-matching endText' + description: 'Text range with non-matching endText should not match' }, { fragment: '#:~:text=none,page', expect_position: 'top', - description: 'Text range with non-matching startText' + description: 'Text range with non-matching startText should not match' }, // Test non-matching context terms { fragment: '#:~:text=this-,is,page,-none', expect_position: 'top', - description: 'Text range with prefix and nonmatching suffix' + description: 'Text range with prefix and nonmatching suffix should not match' }, { fragment: '#:~:text=none-,this,test,-page', expect_position: 'top', - description: 'Text range with nonmatching prefix and matching suffix' + description: 'Text range with nonmatching prefix and matching suffix should not match' }, // Test percent encoded characters { fragment: '#:~:text=this%20is%20a%20test%20page', expect_position: 'text', - description: 'Exact text with percent encoded spaces' + description: 'Exact text with percent encoded spaces should match text' }, { fragment: '#:~:text=test%20pag', expect_position: 'top', - description: 'Non-whole-word exact text with spaces' + description: 'Non-whole-word exact text with spaces should not match' }, { fragment: '#:~:text=%26%2C%2D', expect_position: 'text', - description: 'Fragment directive with percent encoded syntactical characters "&,-"' + description: 'Fragment directive with percent encoded syntactical characters "&,-" should match text' }, { - fragment: '#:~:text=%2665', + fragment: '#:~:text=%E3%83%8D%E3%82%B3', expect_position: 'text', - description: 'Fragment directive with percent encoded non-ASCII unicode character' + description: 'Fragment directive with percent encoded non-ASCII unicode character should match text' }, { fragment: '#:~:text=!$\'()*+./:;=?@_~', expect_position: 'text', - description: 'Fragment directive with all TextMatchChars' + description: 'Fragment directive with all TextMatchChars should match text' }, // Test multiple text directives { fragment: '#:~:text=this&text=test,page', expect_position: 'text', - description: 'Multiple matching exact texts' + description: 'Multiple matching exact texts should match text' }, { fragment: '#:~:text=tes&text=age', expect_position: 'top', - description: 'Multiple non-whole-word exact texts' + description: 'Multiple non-whole-word exact texts should not match' + }, + { + fragment: '#:~:text=none&text=test%20page', + expect_position: 'text', + description: 'A non-matching text directive followed by a matching text directive should match and scroll into view the second text directive' + }, + { + fragment: '#:~:text=test%20page&directive', + expect_position: 'text', + description: 'Text directive followed by non-text directive should match text' + }, + { + fragment: '#:~:text=test&directive&text=page', + expect_position: 'text', + description: 'Multiple text directives and a non-text directive should match text' }, // Test text directive behavior when there's an element fragment identifier { fragment: '#element:~:text=test', expect_position: 'text', - description: 'Text directive with existing element fragment' + description: 'Text directive with existing element fragment should match and scroll into view text' }, { fragment: '#pagestate:~:text=test', expect_position: 'text', - description: 'Text directive with nonexistent element fragment' + description: 'Text directive with nonexistent element fragment should match and scroll into view text' }, { fragment: '#element:~:text=nomatch', expect_position: 'element', - description: 'Non-matching text directive with existing element fragment' + description: 'Non-matching text directive with existing element fragment should scroll to element' }, { fragment: '#pagestate:~:text=nomatch', expect_position: 'top', - description: 'Non-matching text directive with nonexistent element fragment' + description: 'Non-matching text directive with nonexistent element fragment should not match and not scroll' }, // Test ambiguous text matches disambiguated by context terms { fragment: '#:~:text=more-,test%20page', expect_position: 'more-text', - description: 'Multiple match text directive disambiguated by prefix' + description: 'Multiple match text directive disambiguated by prefix should match the prefixed text' }, { fragment: '#:~:text=test%20page,-text', expect_position: 'more-text', - description: 'Multiple match text directive disambiguated by suffix' + description: 'Multiple match text directive disambiguated by suffix should match the suffixed text' }, { fragment: '#:~:text=more-,test%20page,-text', expect_position: 'more-text', - description: 'Multiple match text directive disambiguated by prefix and suffix' + description: 'Multiple match text directive disambiguated by prefix and suffix should match the text with the given context' }, // Test context terms separated by node boundaries { fragment: '#:~:text=prefix-,test%20page,-suffix', expect_position: 'cross-node-context', - description: 'Text directive with context terms separated by node boundaries' + description: 'Text directive should match when context terms are separated by node boundaries' }, + // Test text directive within shadow DOM + { + fragment: '#:~:text=shadow%20text', + expect_position: 'shadow-parent', + description: 'Text directive should match text within shadow DOM' + }, + // Test text directive within hidden and display none elements. These cases should not scroll into + // view, but still "match" in that they should be highlighted or otherwise visibly indicated + // if they were to become visible. + { + fragment: '#:~:text=hidden%20text', + expect_position: 'top', + description: 'Text directive should not scroll to hidden text' + }, + { + fragment: '#:~:text=display%20none', + expect_position: 'top', + description: 'Text directive should not scroll to display none text' + }, + // Test horizontal scroll into view + { + fragment: '#:~:text=horizontally%20scrolled%20text', + expect_position: 'horizontal-scroll', + description: 'Text directive should horizontally scroll into view' + } ]; for (const test_case of test_cases) { @@ -185,7 +230,7 @@ assert_equals(data.href.indexOf(':~:'), -1, 'Expected fragment directive to be stripped from the URL.'); assert_equals(data.scrollPosition, test_case.expect_position, `Expected ${test_case.fragment} (${test_case.description}) to scroll to ${test_case.expect_position}.`); - }), `Test navigation with fragment: ${test_case.description}`); + }), `Test navigation with fragment: ${test_case.description}.`); } promise_test(t => new Promise(resolve => {
diff --git a/third_party/blink/web_tests/external/wpt/sms/README.md b/third_party/blink/web_tests/external/wpt/sms/README.md index 7cd98964..1f34178 100644 --- a/third_party/blink/web_tests/external/wpt/sms/README.md +++ b/third_party/blink/web_tests/external/wpt/sms/README.md
@@ -1,3 +1,3 @@ # SMS Receiver API -This directory contains Web platform tests of the SMS Receiver API. For more details, refer to [this README file](https://cs.chromium.org/chromium/src/content/browser/sms/README.md). +This directory contains tests for the SMS Receiver API. For more details, refer to [this README file](https://cs.chromium.org/chromium/src/content/browser/sms/README.md).
diff --git a/third_party/blink/web_tests/external/wpt/speech-api/historical-expected.txt b/third_party/blink/web_tests/external/wpt/speech-api/historical-expected.txt index 07d8219..cf2f69b 100644 --- a/third_party/blink/web_tests/external/wpt/speech-api/historical-expected.txt +++ b/third_party/blink/web_tests/external/wpt/speech-api/historical-expected.txt
@@ -5,8 +5,8 @@ FAIL webkitSpeechRecognition interface should not exist assert_false: expected false got true FAIL webkitSpeechRecognitionError interface should not exist assert_false: expected false got true FAIL webkitSpeechRecognitionEvent interface should not exist assert_false: expected false got true -PASS SpeechRecognition's serviceURI attribute should not exist -PASS SpeechRecognitionEvent's interpretation attribute should not exist -PASS SpeechRecognitionEvent's emma attribute should not exist +NOTRUN SpeechRecognition's serviceURI attribute should not exist SpeechRecognition exposed +NOTRUN SpeechRecognitionEvent's interpretation attribute should not exist SpeechRecognitionEvent exposed +NOTRUN SpeechRecognitionEvent's emma attribute should not exist SpeechRecognitionEvent exposed Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/speech-api/historical.html b/third_party/blink/web_tests/external/wpt/speech-api/historical.html index 207d3e0..9da70c4 100644 --- a/third_party/blink/web_tests/external/wpt/speech-api/historical.html +++ b/third_party/blink/web_tests/external/wpt/speech-api/historical.html
@@ -18,11 +18,7 @@ }); test(() => { - if (!window.SpeechRecognition) { - // TODO(foolip): use `t.skip()` after - // https://github.com/web-platform-tests/rfcs/pull/16 is done. - return; - } + assert_precondition('SpeechRecognition' in window, 'SpeechRecognition exposed'); assert_false("serviceURI" in SpeechRecognition.prototype); }, "SpeechRecognition's serviceURI attribute should not exist"); @@ -31,11 +27,7 @@ "emma", ].forEach(name => { test(() => { - if (!window.SpeechRecognitionEvent) { - // TODO(foolip): use `t.skip()` after - // https://github.com/web-platform-tests/rfcs/pull/16 is done. - return; - } + assert_precondition('SpeechRecognitionEvent' in window, 'SpeechRecognitionEvent exposed'); assert_false(name in SpeechRecognitionEvent.prototype); }, `SpeechRecognitionEvent's ${name} attribute should not exist`); });
diff --git a/third_party/blink/web_tests/external/wpt/storage-access-api/META.yml b/third_party/blink/web_tests/external/wpt/storage-access-api/META.yml new file mode 100644 index 0000000..cb059fe --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/storage-access-api/META.yml
@@ -0,0 +1,2 @@ +suggested_reviewers: + - Brandr0id
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt index 42e1de3..ba6d006 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught RangeError: Failed to construct 'ReadableStream': bytes type is not yet implemented Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt index 42e1de3..8804b86f 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Unhandled rejection: Failed to register a ServiceWorker for scope ('https://web-platform.test:8444/streams/readable-byte-streams/does/not/exist') with script ('https://web-platform.test:8444/streams/readable-byte-streams/construct-byob-request.any.worker.js'): ServiceWorker script evaluation failed Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt index 42e1de3..ba6d006 100644 --- a/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt +++ b/third_party/blink/web_tests/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt
@@ -1,4 +1,4 @@ This is a testharness.js-based test. -Harness Error. harness_status.status = 1 , harness_status.message = done() was called without first defining any tests +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught RangeError: Failed to construct 'ReadableStream': bytes type is not yet implemented Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/external/wpt/tools/requirements_flake8.txt b/third_party/blink/web_tests/external/wpt/tools/requirements_flake8.txt index 16e35cf..ae35da6 100644 --- a/third_party/blink/web_tests/external/wpt/tools/requirements_flake8.txt +++ b/third_party/blink/web_tests/external/wpt/tools/requirements_flake8.txt
@@ -1,4 +1,4 @@ flake8==3.7.9 pycodestyle==2.5.0 pyflakes==2.1.1 -pep8-naming==0.8.2 +pep8-naming==0.9.0
diff --git a/third_party/blink/web_tests/external/wpt/tools/tox.ini b/third_party/blink/web_tests/external/wpt/tools/tox.ini index 63fb8ed9..a330d05 100644 --- a/third_party/blink/web_tests/external/wpt/tools/tox.ini +++ b/third_party/blink/web_tests/external/wpt/tools/tox.ini
@@ -14,6 +14,7 @@ passenv = HYPOTHESIS_PROFILE PY_COLORS + TASKCLUSTER_ROOT_URL [testenv:py27-flake8] deps = -rrequirements_flake8.txt
diff --git a/third_party/blink/web_tests/external/wpt/tools/webdriver/README.md b/third_party/blink/web_tests/external/wpt/tools/webdriver/README.md index 72de3b2a..2795ff1f 100644 --- a/third_party/blink/web_tests/external/wpt/tools/webdriver/README.md +++ b/third_party/blink/web_tests/external/wpt/tools/webdriver/README.md
@@ -9,7 +9,7 @@ so that different remote end drivers can determine whether they meet the recognised standard. The client is used for the WebDriver specification tests -in the [Web Platform Tests](https://github.com/web-platform-tests/wpt). +in [web-platform-tests](https://github.com/web-platform-tests/wpt). ## Installation @@ -24,11 +24,11 @@ % cd /path/to/wdclient % python - Python 2.7.12+ (default, Aug 4 2016, 20:04:34) + Python 2.7.12+ (default, Aug 4 2016, 20:04:34) [GCC 6.1.1 20160724] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import webdriver - >>> + >>> If you are writing WebDriver specification tests for [WPT](https://github.com/web-platform-tests/wpt),
diff --git a/third_party/blink/web_tests/external/wpt/tools/wpt/run.py b/third_party/blink/web_tests/external/wpt/tools/wpt/run.py index 2525532..44dfbc2 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wpt/run.py +++ b/third_party/blink/web_tests/external/wpt/tools/wpt/run.py
@@ -347,6 +347,10 @@ kwargs["binary_args"].append("--enable-experimental-web-platform-features") # HACK(Hexcles): work around https://github.com/web-platform-tests/wpt/issues/16448 kwargs["webdriver_args"].append("--disable-build-check") + if os.getenv("TASKCLUSTER_ROOT_URL"): + # We are on Taskcluster, where our Docker container does not have + # enough capabilities to run Chrome with sandboxing. (gh-20133) + kwargs["binary_args"].append("--no-sandbox") class ChromeAndroid(BrowserSetup):
diff --git a/third_party/blink/web_tests/external/wpt/tools/wpt/tox.ini b/third_party/blink/web_tests/external/wpt/tools/wpt/tox.ini index d0dead5..6a044473 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wpt/tox.ini +++ b/third_party/blink/web_tests/external/wpt/tools/wpt/tox.ini
@@ -14,3 +14,6 @@ commands = pytest {posargs} + +passenv = + TASKCLUSTER_ROOT_URL
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/requirements_firefox.txt b/third_party/blink/web_tests/external/wpt/tools/wptrunner/requirements_firefox.txt index e772b27..f49102b 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/requirements_firefox.txt +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/requirements_firefox.txt
@@ -8,4 +8,4 @@ mozprofile==2.4.0 mozrunner==7.7.0 mozversion==2.2.0 -psutil==5.6.4 +psutil==5.6.5
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/tox.ini b/third_party/blink/web_tests/external/wpt/tools/wptrunner/tox.ini index 5d34375..f82dbc6 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/tox.ini +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/tox.ini
@@ -24,3 +24,6 @@ commands = pytest {posargs} setenv = CURRENT_TOX_ENV = {envname} + +passenv = + TASKCLUSTER_ROOT_URL
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/base.py b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/base.py index 004b92b4..f20f735 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/base.py +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/base.py
@@ -58,12 +58,14 @@ class TestharnessResultConverter(object): harness_codes = {0: "OK", 1: "ERROR", - 2: "TIMEOUT"} + 2: "TIMEOUT", + 3: "PRECONDITION_FAILED"} test_codes = {0: "PASS", 1: "FAIL", 2: "TIMEOUT", - 3: "NOTRUN"} + 3: "NOTRUN", + 4: "PRECONDITION_FAILED"} def __call__(self, test, result, extra=None): """Convert a JSON result into a (TestResult, [SubtestResult]) tuple""" @@ -597,7 +599,14 @@ "click": ClickAction(self.logger, self.protocol), "send_keys": SendKeysAction(self.logger, self.protocol), "action_sequence": ActionSequenceAction(self.logger, self.protocol), - "generate_test_report": GenerateTestReportAction(self.logger, self.protocol) + "generate_test_report": GenerateTestReportAction(self.logger, self.protocol), + "add_virtual_authenticator": AddVirtualAuthenticatorAction(self.logger, self.protocol), + "remove_virtual_authenticator": RemoveVirtualAuthenticatorAction(self.logger, self.protocol), + "add_credential": AddCredentialAction(self.logger, self.protocol), + "get_credentials": GetCredentialsAction(self.logger, self.protocol), + "remove_credential": RemoveCredentialAction(self.logger, self.protocol), + "remove_all_credentials": RemoveAllCredentialsAction(self.logger, self.protocol), + "set_user_verified": SetUserVerifiedAction(self.logger, self.protocol), } def __call__(self, result): @@ -692,3 +701,80 @@ message = payload["message"] self.logger.debug("Generating test report: %s" % message) self.protocol.generate_test_report.generate_test_report(message) + +class AddVirtualAuthenticatorAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + self.logger.debug("Adding virtual authenticator") + config = payload["config"] + authenticator_id = self.protocol.virtual_authenticator.add_virtual_authenticator(config) + self.logger.debug("Authenticator created with ID %s" % authenticator_id) + return authenticator_id + +class RemoveVirtualAuthenticatorAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + self.logger.debug("Removing virtual authenticator %s" % authenticator_id) + return self.protocol.virtual_authenticator.remove_virtual_authenticator(authenticator_id) + + +class AddCredentialAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + credential = payload["credential"] + self.logger.debug("Adding credential to virtual authenticator %s " % authenticator_id) + return self.protocol.virtual_authenticator.add_credential(authenticator_id, credential) + +class GetCredentialsAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + self.logger.debug("Getting credentials from virtual authenticator %s " % authenticator_id) + return self.protocol.virtual_authenticator.get_credentials(authenticator_id) + +class RemoveCredentialAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + credential_id = payload["credential_id"] + self.logger.debug("Removing credential %s from authenticator %s" % (credential_id, authenticator_id)) + return self.protocol.virtual_authenticator.remove_credential(authenticator_id, credential_id) + +class RemoveAllCredentialsAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + self.logger.debug("Removing all credentials from authenticator %s" % authenticator_id) + return self.protocol.virtual_authenticator.remove_all_credentials(authenticator_id) + +class SetUserVerifiedAction(object): + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + authenticator_id = payload["authenticator_id"] + uv = payload["uv"] + self.logger.debug( + "Setting user verified flag on authenticator %s to %s" % (authenticator_id, uv["isUserVerified"])) + return self.protocol.virtual_authenticator.set_user_verified(authenticator_id, uv)
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/executorwebdriver.py index a260197..344debf 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/executorwebdriver.py
@@ -22,7 +22,8 @@ SendKeysProtocolPart, ActionSequenceProtocolPart, TestDriverProtocolPart, - GenerateTestReportProtocolPart) + GenerateTestReportProtocolPart, + VirtualAuthenticatorProtocolPart) from ..testrunner import Stop import webdriver as client @@ -202,6 +203,31 @@ json_message = {"message": message} self.webdriver.send_session_command("POST", "reporting/generate_test_report", json_message) +class WebDriverVirtualAuthenticatorProtocolPart(VirtualAuthenticatorProtocolPart): + def setup(self): + self.webdriver = self.parent.webdriver + + def add_virtual_authenticator(self, config): + return self.webdriver.send_session_command("POST", "webauthn/authenticator", config) + + def remove_virtual_authenticator(self, authenticator_id): + return self.webdriver.send_session_command("DELETE", "webauthn/authenticator/%s" % authenticator_id) + + def add_credential(self, authenticator_id, credential): + return self.webdriver.send_session_command("POST", "webauthn/authenticator/%s/credential" % authenticator_id, credential) + + def get_credentials(self, authenticator_id): + return self.webdriver.send_session_command("GET", "webauthn/authenticator/%s/credentials" % authenticator_id) + + def remove_credential(self, authenticator_id, credential_id): + return self.webdriver.send_session_command("DELETE", "webauthn/authenticator/%s/credentials/%s" % (authenticator_id, credential_id)) + + def remove_all_credentials(self, authenticator_id): + return self.webdriver.send_session_command("DELETE", "webauthn/authenticator/%s/credentials" % authenticator_id) + + def set_user_verified(self, authenticator_id, uv): + return self.webdriver.send_session_command("POST", "webauthn/authenticator/%s/uv" % authenticator_id, uv) + class WebDriverProtocol(Protocol): implements = [WebDriverBaseProtocolPart, @@ -211,7 +237,8 @@ WebDriverSendKeysProtocolPart, WebDriverActionSequenceProtocolPart, WebDriverTestDriverProtocolPart, - WebDriverGenerateTestReportProtocolPart] + WebDriverGenerateTestReportProtocolPart, + WebDriverVirtualAuthenticatorProtocolPart] def __init__(self, executor, browser, capabilities, **kwargs): super(WebDriverProtocol, self).__init__(executor, browser)
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/protocol.py b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/protocol.py index 77a705ff..0758312 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/protocol.py +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/executors/protocol.py
@@ -365,3 +365,62 @@ def dump(self): """Dump coverage counters""" pass + +class VirtualAuthenticatorProtocolPart(ProtocolPart): + """Protocol part for creating and manipulating virtual authenticators""" + __metaclass__ = ABCMeta + + name = "virtual_authenticator" + + @abstractmethod + def add_virtual_authenticator(self, config): + """Add a virtual authenticator + + :param config: The Authenticator Configuration""" + pass + + @abstractmethod + def remove_virtual_authenticator(self, authenticator_id): + """Remove a virtual authenticator + + :param str authenticator_id: The ID of the authenticator to remove""" + pass + + @abstractmethod + def add_credential(self, authenticator_id, credential): + """Inject a credential onto an authenticator + + :param str authenticator_id: The ID of the authenticator to add the credential to + :param credential: The credential to inject""" + pass + + @abstractmethod + def get_credentials(self, authenticator_id): + """Get the credentials stored in an authenticator + + :param str authenticator_id: The ID of the authenticator + :returns: An array with the credentials stored on the authenticator""" + pass + + @abstractmethod + def remove_credential(self, authenticator_id, credential_id): + """Remove a credential stored in an authenticator + + :param str authenticator_id: The ID of the authenticator + :param str credential_id: The ID of the credential""" + pass + + @abstractmethod + def remove_all_credentials(self, authenticator_id): + """Remove all the credentials stored in an authenticator + + :param str authenticator_id: The ID of the authenticator""" + pass + + @abstractmethod + def set_user_verified(self, authenticator_id, uv): + """Sets the user verified flag on an authenticator + + :param str authenticator_id: The ID of the authenticator + :param bool uv: the user verified flag""" + pass
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/testdriver-extra.js b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/testdriver-extra.js index 9f97fac..278f226 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/testdriver-extra.js +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/testdriver-extra.js
@@ -108,7 +108,7 @@ else action.frame = {frame: frame}; action.origin = {selector: get_selector(action.origin)}; - } + } } } } @@ -125,4 +125,67 @@ window.__wptrunner_message_queue.push({"type": "action", "action": "generate_test_report", "message": message}); return pending_promise; }; + + window.test_driver_internal.add_virtual_authenticator = function(config) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "add_virtual_authenticator", config}); + return pending_promise; + }; + + window.test_driver_internal.remove_virtual_authenticator = function(authenticator_id) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "remove_virtual_authenticator", authenticator_id}); + return pending_promise; + }; + + window.test_driver_internal.add_credential = function(authenticator_id, credential) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "add_credential", authenticator_id, credential}); + return pending_promise; + }; + + window.test_driver_internal.get_credentials = function(authenticator_id) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "get_credentials", authenticator_id}); + return pending_promise; + }; + + window.test_driver_internal.remove_credential = function(authenticator_id, credential_id) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "remove_credential", authenticator_id, credential_id}); + return pending_promise; + }; + + window.test_driver_internal.remove_all_credentials = function(authenticator_id) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "remove_all_credentials", authenticator_id}); + return pending_promise; + }; + + window.test_driver_internal.set_user_verified = function(authenticator_id, uv) { + const pending_promise = new Promise(function(resolve, reject) { + pending_resolve = resolve; + pending_reject = reject; + }); + window.__wptrunner_message_queue.push({"type": "action", "action": "set_user_verified", authenticator_id, uv}); + return pending_promise; + }; })();
diff --git a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/wpttest.py b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/wpttest.py index 80db17a3..e5c28bc 100644 --- a/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/wpttest.py +++ b/third_party/blink/web_tests/external/wpt/tools/wptrunner/wptrunner/wpttest.py
@@ -47,12 +47,12 @@ class TestharnessResult(Result): default_expected = "OK" - statuses = {"OK", "ERROR", "INTERNAL-ERROR", "TIMEOUT", "EXTERNAL-TIMEOUT", "CRASH"} + statuses = {"OK", "ERROR", "INTERNAL-ERROR", "TIMEOUT", "EXTERNAL-TIMEOUT", "CRASH", "PRECONDITION_FAILED"} class TestharnessSubtestResult(SubtestResult): default_expected = "PASS" - statuses = {"PASS", "FAIL", "TIMEOUT", "NOTRUN"} + statuses = {"PASS", "FAIL", "TIMEOUT", "NOTRUN", "PRECONDITION_FAILED"} class ReftestResult(Result):
diff --git a/third_party/blink/web_tests/external/wpt/uievents/click/click_events_on_input.html b/third_party/blink/web_tests/external/wpt/uievents/click/click_events_on_input.html new file mode 100644 index 0000000..731d139 --- /dev/null +++ b/third_party/blink/web_tests/external/wpt/uievents/click/click_events_on_input.html
@@ -0,0 +1,65 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <title>Clicking with primary vs non-primary buttons</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-actions.js"></script> + <script src="/resources/testdriver-vendor.js"></script> + </head> + <body> + <h1>Clicking on input type=text element when placeholder changes</h1> + <input id="target" onfocus="this.placeholder = ++focusCount;" placeholder="initial"> + <input id="other"> + <script> + var focusCount = 0; + var target = document.querySelector('#target'); + document.addEventListener('contextmenu', event => { event.preventDefault(); }); + + var test_click = async_test("Test click and auxclick on input element"); + + // The test is on purpose rather vague, since auxclick handling on + // touchscreens isn't well defined. + // But at least there should be 'click' + var didGetClick = false; + async function testClick(type, mouseButton) { + return new Promise((resolve) => { + target.addEventListener(type, event => { + event.preventDefault(); + didGetClick = didGetClick || event.type == "click"; + test_click.step(() => { + assert_equals(event.type, type, 'Should have got an event.'); + }); + }, {once: true}); + + // Inject mouse click events. + var actions = new test_driver.Actions(); + document.getElementById("other").focus(); + var bounds = target.getBoundingClientRect(); + actions.pointerMove(Math.floor(bounds.width / 5), + Math.floor(bounds.height / 2), + {origin: target}) + .pointerDown({button: mouseButton}) + .pointerUp({button: mouseButton}) + .send() + .then(resolve); + }); + } + + async function testClicks() { + var buttonType = test_driver.Actions.prototype.ButtonType; + await testClick("click", buttonType.LEFT); + await testClick("auxclick", buttonType.MIDDLE); + await testClick("auxclick", buttonType.RIGHT); + test_click.step(() => { + assert_true(didGetClick, 'Should have got at least "click".'); + }); + test_click.done(); + } + + testClicks(); + </script> + </body> +</html>
diff --git a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/README.md b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/README.md index 516e8e26..7b7ac65c 100644 --- a/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/README.md +++ b/third_party/blink/web_tests/external/wpt/upgrade-insecure-requests/README.md
@@ -1,4 +1,4 @@ -# Upgrade-insecure-requests Web Platform Tests +# Upgrade Insecure Requests Test Suite The subdirectory `gen/` is generated using the generator at `common/security-features`. See [common/security-features/README.md](../common/security-features/README.md) for how to generate tests.
diff --git a/third_party/blink/web_tests/external/wpt/vibration/invalid-values.html b/third_party/blink/web_tests/external/wpt/vibration/invalid-values.html index 6740a44..9381dad 100644 --- a/third_party/blink/web_tests/external/wpt/vibration/invalid-values.html +++ b/third_party/blink/web_tests/external/wpt/vibration/invalid-values.html
@@ -8,6 +8,7 @@ <div id='log'></div> <script> test(function() { + assert_precondition(navigator.vibrate, 'navigator.vibrate exists'); assert_throws(new TypeError(), function() { navigator.vibrate(); }, 'Argument is required, so was expecting a TypeError.');
diff --git a/third_party/blink/web_tests/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html b/third_party/blink/web_tests/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html index 9dd364ed..32f2eb9 100644 --- a/third_party/blink/web_tests/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html +++ b/third_party/blink/web_tests/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https.html
@@ -371,4 +371,30 @@ assert_array_equals(pc2.iceStates, ['new', 'checking', 'connected']); }, 'Responder ICE connection state behaves as expected'); +/* + Test case for step 11 of PeerConnection.close(). + ... + 11. Set connection's ICE connection state to "closed". This does not invoke + the "update the ICE connection state" procedure, and does not fire any + event. + ... +*/ +promise_test(async t => { + const pc1 = new RTCPeerConnection(); + t.add_cleanup(() => pc1.close()); + const pc2 = new RTCPeerConnection(); + const stream = await getNoiseStream({ audio: true }); + t.add_cleanup(() => stream.getTracks().forEach(track => track.stop())); + + stream.getTracks().forEach(track => pc1.addTrack(track, stream)); + exchangeIceCandidates(pc1, pc2); + doSignalingHandshake(pc1, pc2); + await listenToIceConnected(pc2); + + pc2.oniceconnectionstatechange = t.unreached_func(); + pc2.close(); + await Promise.resolve(); + assert_true(pc2.iceConnectionState === 'closed'); +}, 'Closing a PeerConnection should not fire iceconnectionstatechange event'); + </script>
diff --git a/third_party/blink/web_tests/external/wpt/webrtc/idlharness.https.window-expected.txt b/third_party/blink/web_tests/external/wpt/webrtc/idlharness.https.window-expected.txt index 2dedb2f..5ebbb2a 100644 --- a/third_party/blink/web_tests/external/wpt/webrtc/idlharness.https.window-expected.txt +++ b/third_party/blink/web_tests/external/wpt/webrtc/idlharness.https.window-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 507 tests; 475 PASS, 32 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 499 tests; 469 PASS, 30 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS idl_test setup PASS idl_test validation PASS Test driver for asyncInitCertificate @@ -40,7 +40,6 @@ PASS RTCPeerConnection interface: attribute connectionState FAIL RTCPeerConnection interface: attribute canTrickleIceCandidates assert_true: The prototype object must have a property "canTrickleIceCandidates" expected true got false PASS RTCPeerConnection interface: operation restartIce() -FAIL RTCPeerConnection interface: operation getDefaultIceServers() assert_own_property: interface object missing static operation expected property "getDefaultIceServers" missing PASS RTCPeerConnection interface: operation getConfiguration() PASS RTCPeerConnection interface: operation setConfiguration(RTCConfiguration) PASS RTCPeerConnection interface: operation close() @@ -92,7 +91,6 @@ PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "connectionState" with the proper type FAIL RTCPeerConnection interface: new RTCPeerConnection() must inherit property "canTrickleIceCandidates" with the proper type assert_inherits: property "canTrickleIceCandidates" not found in prototype chain PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "restartIce()" with the proper type -PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getDefaultIceServers()" with the proper type PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getConfiguration()" with the proper type PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setConfiguration(RTCConfiguration)" with the proper type PASS RTCPeerConnection interface: calling setConfiguration(RTCConfiguration) on new RTCPeerConnection() with too few arguments must throw TypeError @@ -223,12 +221,10 @@ PASS RTCCertificate interface: existence and properties of interface prototype object's "constructor" property PASS RTCCertificate interface: existence and properties of interface prototype object's @@unscopables property PASS RTCCertificate interface: attribute expires -FAIL RTCCertificate interface: operation getSupportedAlgorithms() assert_own_property: interface object missing static operation expected property "getSupportedAlgorithms" missing PASS RTCCertificate interface: operation getFingerprints() PASS RTCCertificate must be primary interface of idlTestObjects.certificate PASS Stringification of idlTestObjects.certificate PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "expires" with the proper type -PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getSupportedAlgorithms()" with the proper type PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getFingerprints()" with the proper type PASS RTCRtpSender interface: existence and properties of interface object PASS RTCRtpSender interface object length @@ -238,7 +234,6 @@ PASS RTCRtpSender interface: existence and properties of interface prototype object's @@unscopables property PASS RTCRtpSender interface: attribute track PASS RTCRtpSender interface: attribute transport -PASS RTCRtpSender interface: attribute rtcpTransport PASS RTCRtpSender interface: operation getCapabilities(DOMString) FAIL RTCRtpSender interface: operation setParameters(RTCRtpSendParameters) assert_equals: property has wrong .length expected 1 but got 0 PASS RTCRtpSender interface: operation getParameters() @@ -250,7 +245,6 @@ PASS Stringification of new RTCPeerConnection().addTransceiver('audio').sender PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "track" with the proper type PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "transport" with the proper type -PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "rtcpTransport" with the proper type PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "getCapabilities(DOMString)" with the proper type PASS RTCRtpSender interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "setParameters(RTCRtpSendParameters)" with the proper type @@ -270,7 +264,6 @@ PASS RTCRtpReceiver interface: existence and properties of interface prototype object's @@unscopables property PASS RTCRtpReceiver interface: attribute track PASS RTCRtpReceiver interface: attribute transport -PASS RTCRtpReceiver interface: attribute rtcpTransport PASS RTCRtpReceiver interface: operation getCapabilities(DOMString) PASS RTCRtpReceiver interface: operation getParameters() PASS RTCRtpReceiver interface: operation getContributingSources() @@ -280,7 +273,6 @@ PASS Stringification of new RTCPeerConnection().addTransceiver('audio').receiver PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "track" with the proper type PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "transport" with the proper type -PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "rtcpTransport" with the proper type PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getCapabilities(DOMString)" with the proper type PASS RTCRtpReceiver interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').receiver with too few arguments must throw TypeError PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getParameters()" with the proper type
diff --git a/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/001-1.html b/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/001-1.html index bd0c366..75d689e 100644 --- a/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/001-1.html +++ b/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/001-1.html
@@ -6,7 +6,6 @@ <script> var controller = opener || parent; var t = controller.t; -var assert_equals = controller.asset_equals; var assert_unreached = controller.assert_unreached; var uuid = controller.uuid; t.add_cleanup(function() {delete sessionStorage[uuid];});
diff --git a/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/002-1.html b/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/002-1.html index d151b231..546de89 100644 --- a/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/002-1.html +++ b/third_party/blink/web_tests/external/wpt/websockets/unload-a-document/002-1.html
@@ -6,9 +6,9 @@ <script> var controller = opener || parent; var t = controller.t; -var assert_equals = controller.asset_equals; +var assert_equals = controller.assert_equals; var assert_unreached = controller.assert_unreached ; -var uuid = controller.token; +var uuid = controller.uuid; t.add_cleanup(function() {delete sessionStorage[uuid];}); t.step(function() { // this test can fail if the document is unloaded on navigation e.g. due to OOM
diff --git a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png index 3dab3228..8274a64 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png index 97a1af9..f604e04 100644 --- a/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/linux/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-document_on_html_element-manual-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-object_on_html_element-manual-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-object_on_svg_element-manual-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-symbol_on_html_element-manual-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/graphics-aam/graphics-symbol_on_svg_element-manual-expected.txt
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt new file mode 100644 index 0000000..c960d0d --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window-expected.txt
@@ -0,0 +1,13 @@ +This is a testharness.js-based test. +PASS page-created Error (worker) +PASS page-created Error (cross-site iframe) +PASS page-created DOMException (worker) +PASS page-created DOMException (cross-site iframe) +PASS JS-engine-created TypeError (worker) +PASS JS-engine-created TypeError (cross-site iframe) +PASS web API-created TypeError (worker) +PASS web API-created TypeError (cross-site iframe) +FAIL web API-created DOMException (worker) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:41:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1917:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:40:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined +FAIL web API-created DOMException (cross-site iframe) assert_equals: expected (string) "Error: Failed to execute 'createElement' on 'Document': The tag name provided ('') is not a valid name.\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:33:14\n at Test.<anonymous> (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:60:19)\n at Test.step (http://web-platform.test:8001/resources/testharness.js:1917:25)\n at async_test (http://web-platform.test:8001/resources/testharness.js:576:22)\n at stackTests (http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:57:3)\n at http://web-platform.test:8001/html/infrastructure/safe-passing-of-structured-data/structured-cloning-error-stack-optional.sub.window.js:31:1" but got (undefined) undefined +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt similarity index 100% rename from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt rename to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/infrastructure/expected-fail/uncaught-exception-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/infrastructure/expected-fail/unhandled-rejection-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-payment-method-manual.https-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-shipping-address-manual.https-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/change-shipping-option-manual.https-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-handler/supports-shipping-contact-delegation-manual.https-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-request/payment-is-showing.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-request/payment-is-showing.https-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/payment-request/payment-request-canmakepayment-method-protection.https-expected.txt
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/resize-observer/idlharness.window-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/resize-observer/idlharness.window-expected.txt new file mode 100644 index 0000000..ad10be9 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/resize-observer/idlharness.window-expected.txt
@@ -0,0 +1,60 @@ +This is a testharness.js-based test. +Found 56 tests; 34 PASS, 22 FAIL, 0 TIMEOUT, 0 NOTRUN. +PASS idl_test setup +PASS idl_test validation +PASS ResizeObserverEntry creator +PASS Element includes ParentNode: member names are unique +PASS Element includes NonDocumentTypeChildNode: member names are unique +PASS Element includes ChildNode: member names are unique +PASS Element includes Slotable: member names are unique +PASS ResizeObserver interface: existence and properties of interface object +PASS ResizeObserver interface object length +PASS ResizeObserver interface object name +PASS ResizeObserver interface: existence and properties of interface prototype object +PASS ResizeObserver interface: existence and properties of interface prototype object's "constructor" property +PASS ResizeObserver interface: existence and properties of interface prototype object's @@unscopables property +PASS ResizeObserver interface: operation observe(Element, ResizeObserverOptions) +PASS ResizeObserver interface: operation unobserve(Element) +PASS ResizeObserver interface: operation disconnect() +PASS ResizeObserver must be primary interface of observer +PASS Stringification of observer +PASS ResizeObserver interface: observer must inherit property "observe(Element, ResizeObserverOptions)" with the proper type +PASS ResizeObserver interface: calling observe(Element, ResizeObserverOptions) on observer with too few arguments must throw TypeError +PASS ResizeObserver interface: observer must inherit property "unobserve(Element)" with the proper type +PASS ResizeObserver interface: calling unobserve(Element) on observer with too few arguments must throw TypeError +PASS ResizeObserver interface: observer must inherit property "disconnect()" with the proper type +PASS ResizeObserverEntry interface: existence and properties of interface object +FAIL ResizeObserverEntry interface object length assert_equals: wrong value for ResizeObserverEntry.length expected 1 but got 0 +PASS ResizeObserverEntry interface object name +PASS ResizeObserverEntry interface: existence and properties of interface prototype object +PASS ResizeObserverEntry interface: existence and properties of interface prototype object's "constructor" property +PASS ResizeObserverEntry interface: existence and properties of interface prototype object's @@unscopables property +PASS ResizeObserverEntry interface: attribute target +PASS ResizeObserverEntry interface: attribute contentRect +FAIL ResizeObserverEntry interface: attribute borderBoxSize assert_true: The prototype object must have a property "borderBoxSize" expected true got false +FAIL ResizeObserverEntry interface: attribute contentBoxSize assert_true: The prototype object must have a property "contentBoxSize" expected true got false +PASS ResizeObserverEntry must be primary interface of entry +PASS Stringification of entry +PASS ResizeObserverEntry interface: entry must inherit property "target" with the proper type +PASS ResizeObserverEntry interface: entry must inherit property "contentRect" with the proper type +FAIL ResizeObserverEntry interface: entry must inherit property "borderBoxSize" with the proper type assert_inherits: property "borderBoxSize" not found in prototype chain +FAIL ResizeObserverEntry interface: entry must inherit property "contentBoxSize" with the proper type assert_inherits: property "contentBoxSize" not found in prototype chain +FAIL ResizeObserverSize interface: existence and properties of interface object assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface object length assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface object name assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface: existence and properties of interface prototype object assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface: attribute inlineSize assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObserverSize interface: attribute blockSize assert_own_property: self does not have own property "ResizeObserverSize" expected property "ResizeObserverSize" missing +FAIL ResizeObservation interface: existence and properties of interface object assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface object length assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface object name assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: existence and properties of interface prototype object assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: attribute target assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: attribute observedBox assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +FAIL ResizeObservation interface: attribute lastReportedSize assert_own_property: self does not have own property "ResizeObservation" expected property "ResizeObservation" missing +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/speech-api/historical-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/speech-api/historical-expected.txt new file mode 100644 index 0000000..07d8219 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/speech-api/historical-expected.txt
@@ -0,0 +1,12 @@ +This is a testharness.js-based test. +PASS SpeechRecognitionError interface should not exist +FAIL webkitSpeechGrammar interface should not exist assert_false: expected false got true +FAIL webkitSpeechGrammarList interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognition interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognitionError interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognitionEvent interface should not exist assert_false: expected false got true +PASS SpeechRecognition's serviceURI attribute should not exist +PASS SpeechRecognitionEvent's interpretation attribute should not exist +PASS SpeechRecognitionEvent's emma attribute should not exist +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any.serviceworker-expected.txt
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/streams/readable-byte-streams/construct-byob-request.any.worker-expected.txt
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/webrtc/idlharness.https.window-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/webrtc/idlharness.https.window-expected.txt new file mode 100644 index 0000000..2dedb2f --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.10/external/wpt/webrtc/idlharness.https.window-expected.txt
@@ -0,0 +1,519 @@ +This is a testharness.js-based test. +Found 507 tests; 475 PASS, 32 FAIL, 0 TIMEOUT, 0 NOTRUN. +PASS idl_test setup +PASS idl_test validation +PASS Test driver for asyncInitCertificate +PASS Test driver for asyncInitTransports +PASS Test driver for asyncInitMediaStreamTrack +PASS Partial dictionary RTCOfferOptions: original dictionary defined +PASS Partial dictionary RTCOfferOptions: member names are unique +PASS Partial interface RTCPeerConnection: original interface defined +PASS Partial interface RTCPeerConnection: member names are unique +PASS Partial interface RTCPeerConnection[2]: original interface defined +PASS Partial interface RTCPeerConnection[2]: member names are unique +PASS Partial interface RTCPeerConnection[3]: original interface defined +PASS Partial interface RTCPeerConnection[3]: member names are unique +PASS Partial interface RTCRtpSender: original interface defined +PASS Partial interface RTCRtpSender: member names are unique +PASS Partial interface RTCPeerConnection[4]: original interface defined +PASS Partial interface RTCPeerConnection[4]: member names are unique +PASS RTCPeerConnection interface: existence and properties of interface object +PASS RTCPeerConnection interface object length +PASS RTCPeerConnection interface object name +PASS RTCPeerConnection interface: existence and properties of interface prototype object +PASS RTCPeerConnection interface: existence and properties of interface prototype object's "constructor" property +PASS RTCPeerConnection interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCPeerConnection interface: operation createOffer(RTCOfferOptions) +PASS RTCPeerConnection interface: operation createAnswer(RTCAnswerOptions) +PASS RTCPeerConnection interface: operation setLocalDescription(RTCSessionDescriptionInit) +PASS RTCPeerConnection interface: attribute localDescription +PASS RTCPeerConnection interface: attribute currentLocalDescription +PASS RTCPeerConnection interface: attribute pendingLocalDescription +FAIL RTCPeerConnection interface: operation setRemoteDescription(RTCSessionDescriptionInit) assert_equals: property has wrong .length expected 0 but got 1 +PASS RTCPeerConnection interface: attribute remoteDescription +PASS RTCPeerConnection interface: attribute currentRemoteDescription +PASS RTCPeerConnection interface: attribute pendingRemoteDescription +FAIL RTCPeerConnection interface: operation addIceCandidate(RTCIceCandidateInit) assert_equals: property has wrong .length expected 0 but got 1 +PASS RTCPeerConnection interface: attribute signalingState +PASS RTCPeerConnection interface: attribute iceGatheringState +PASS RTCPeerConnection interface: attribute iceConnectionState +PASS RTCPeerConnection interface: attribute connectionState +FAIL RTCPeerConnection interface: attribute canTrickleIceCandidates assert_true: The prototype object must have a property "canTrickleIceCandidates" expected true got false +PASS RTCPeerConnection interface: operation restartIce() +FAIL RTCPeerConnection interface: operation getDefaultIceServers() assert_own_property: interface object missing static operation expected property "getDefaultIceServers" missing +PASS RTCPeerConnection interface: operation getConfiguration() +PASS RTCPeerConnection interface: operation setConfiguration(RTCConfiguration) +PASS RTCPeerConnection interface: operation close() +PASS RTCPeerConnection interface: attribute onnegotiationneeded +PASS RTCPeerConnection interface: attribute onicecandidate +PASS RTCPeerConnection interface: attribute onicecandidateerror +PASS RTCPeerConnection interface: attribute onsignalingstatechange +PASS RTCPeerConnection interface: attribute oniceconnectionstatechange +PASS RTCPeerConnection interface: attribute onicegatheringstatechange +PASS RTCPeerConnection interface: attribute onconnectionstatechange +PASS RTCPeerConnection interface: operation createOffer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback, RTCOfferOptions) +PASS RTCPeerConnection interface: operation setLocalDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback) +PASS RTCPeerConnection interface: operation createAnswer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback) +FAIL RTCPeerConnection interface: operation setRemoteDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback) assert_equals: property has wrong .length expected 0 but got 1 +FAIL RTCPeerConnection interface: operation addIceCandidate(RTCIceCandidateInit, VoidFunction, RTCPeerConnectionErrorCallback) assert_equals: property has wrong .length expected 0 but got 1 +PASS RTCPeerConnection interface: operation generateCertificate(AlgorithmIdentifier) +PASS RTCPeerConnection interface: operation getSenders() +PASS RTCPeerConnection interface: operation getReceivers() +PASS RTCPeerConnection interface: operation getTransceivers() +PASS RTCPeerConnection interface: operation addTrack(MediaStreamTrack, MediaStream) +PASS RTCPeerConnection interface: operation removeTrack(RTCRtpSender) +PASS RTCPeerConnection interface: operation addTransceiver([object Object],[object Object], RTCRtpTransceiverInit) +PASS RTCPeerConnection interface: attribute ontrack +PASS RTCPeerConnection interface: attribute sctp +PASS RTCPeerConnection interface: operation createDataChannel(USVString, RTCDataChannelInit) +PASS RTCPeerConnection interface: attribute ondatachannel +PASS RTCPeerConnection interface: operation getStats(MediaStreamTrack) +PASS RTCPeerConnection must be primary interface of new RTCPeerConnection() +PASS Stringification of new RTCPeerConnection() +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "createOffer(RTCOfferOptions)" with the proper type +PASS RTCPeerConnection interface: calling createOffer(RTCOfferOptions) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "createAnswer(RTCAnswerOptions)" with the proper type +PASS RTCPeerConnection interface: calling createAnswer(RTCAnswerOptions) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setLocalDescription(RTCSessionDescriptionInit)" with the proper type +PASS RTCPeerConnection interface: calling setLocalDescription(RTCSessionDescriptionInit) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "localDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "currentLocalDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "pendingLocalDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setRemoteDescription(RTCSessionDescriptionInit)" with the proper type +PASS RTCPeerConnection interface: calling setRemoteDescription(RTCSessionDescriptionInit) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "remoteDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "currentRemoteDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "pendingRemoteDescription" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "addIceCandidate(RTCIceCandidateInit)" with the proper type +PASS RTCPeerConnection interface: calling addIceCandidate(RTCIceCandidateInit) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "signalingState" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "iceGatheringState" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "iceConnectionState" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "connectionState" with the proper type +FAIL RTCPeerConnection interface: new RTCPeerConnection() must inherit property "canTrickleIceCandidates" with the proper type assert_inherits: property "canTrickleIceCandidates" not found in prototype chain +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "restartIce()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getDefaultIceServers()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getConfiguration()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setConfiguration(RTCConfiguration)" with the proper type +PASS RTCPeerConnection interface: calling setConfiguration(RTCConfiguration) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "close()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onnegotiationneeded" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onicecandidate" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onicecandidateerror" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onsignalingstatechange" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "oniceconnectionstatechange" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onicegatheringstatechange" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "onconnectionstatechange" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "createOffer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback, RTCOfferOptions)" with the proper type +PASS RTCPeerConnection interface: calling createOffer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback, RTCOfferOptions) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setLocalDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback)" with the proper type +PASS RTCPeerConnection interface: calling setLocalDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "createAnswer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback)" with the proper type +PASS RTCPeerConnection interface: calling createAnswer(RTCSessionDescriptionCallback, RTCPeerConnectionErrorCallback) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setRemoteDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback)" with the proper type +PASS RTCPeerConnection interface: calling setRemoteDescription(RTCSessionDescriptionInit, VoidFunction, RTCPeerConnectionErrorCallback) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "addIceCandidate(RTCIceCandidateInit, VoidFunction, RTCPeerConnectionErrorCallback)" with the proper type +PASS RTCPeerConnection interface: calling addIceCandidate(RTCIceCandidateInit, VoidFunction, RTCPeerConnectionErrorCallback) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "generateCertificate(AlgorithmIdentifier)" with the proper type +PASS RTCPeerConnection interface: calling generateCertificate(AlgorithmIdentifier) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getSenders()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getReceivers()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getTransceivers()" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "addTrack(MediaStreamTrack, MediaStream)" with the proper type +PASS RTCPeerConnection interface: calling addTrack(MediaStreamTrack, MediaStream) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "removeTrack(RTCRtpSender)" with the proper type +PASS RTCPeerConnection interface: calling removeTrack(RTCRtpSender) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "addTransceiver([object Object],[object Object], RTCRtpTransceiverInit)" with the proper type +PASS RTCPeerConnection interface: calling addTransceiver([object Object],[object Object], RTCRtpTransceiverInit) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "ontrack" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "sctp" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "createDataChannel(USVString, RTCDataChannelInit)" with the proper type +PASS RTCPeerConnection interface: calling createDataChannel(USVString, RTCDataChannelInit) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "ondatachannel" with the proper type +PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getStats(MediaStreamTrack)" with the proper type +PASS RTCPeerConnection interface: calling getStats(MediaStreamTrack) on new RTCPeerConnection() with too few arguments must throw TypeError +PASS RTCSessionDescription interface: existence and properties of interface object +PASS RTCSessionDescription interface object length +PASS RTCSessionDescription interface object name +PASS RTCSessionDescription interface: existence and properties of interface prototype object +PASS RTCSessionDescription interface: existence and properties of interface prototype object's "constructor" property +PASS RTCSessionDescription interface: existence and properties of interface prototype object's @@unscopables property +FAIL RTCSessionDescription interface: attribute type assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function "function set type() { [native code] }" +FAIL RTCSessionDescription interface: attribute sdp assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function "function set sdp() { [native code] }" +PASS RTCSessionDescription interface: operation toJSON() +PASS RTCSessionDescription must be primary interface of new RTCSessionDescription({ type: 'offer' }) +PASS Stringification of new RTCSessionDescription({ type: 'offer' }) +PASS RTCSessionDescription interface: new RTCSessionDescription({ type: 'offer' }) must inherit property "type" with the proper type +FAIL RTCSessionDescription interface: new RTCSessionDescription({ type: 'offer' }) must inherit property "sdp" with the proper type assert_equals: expected "string" but got "object" +PASS RTCSessionDescription interface: new RTCSessionDescription({ type: 'offer' }) must inherit property "toJSON()" with the proper type +FAIL RTCSessionDescription interface: default toJSON operation on new RTCSessionDescription({ type: 'offer' }) assert_equals: expected "string" but got "object" +PASS RTCIceCandidate interface: existence and properties of interface object +PASS RTCIceCandidate interface object length +PASS RTCIceCandidate interface object name +PASS RTCIceCandidate interface: existence and properties of interface prototype object +PASS RTCIceCandidate interface: existence and properties of interface prototype object's "constructor" property +PASS RTCIceCandidate interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCIceCandidate interface: attribute candidate +PASS RTCIceCandidate interface: attribute sdpMid +PASS RTCIceCandidate interface: attribute sdpMLineIndex +PASS RTCIceCandidate interface: attribute foundation +PASS RTCIceCandidate interface: attribute component +PASS RTCIceCandidate interface: attribute priority +PASS RTCIceCandidate interface: attribute address +PASS RTCIceCandidate interface: attribute protocol +PASS RTCIceCandidate interface: attribute port +PASS RTCIceCandidate interface: attribute type +PASS RTCIceCandidate interface: attribute tcpType +PASS RTCIceCandidate interface: attribute relatedAddress +PASS RTCIceCandidate interface: attribute relatedPort +PASS RTCIceCandidate interface: attribute usernameFragment +PASS RTCIceCandidate interface: operation toJSON() +PASS RTCIceCandidate must be primary interface of new RTCIceCandidate({ sdpMid: 1 }) +PASS Stringification of new RTCIceCandidate({ sdpMid: 1 }) +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "candidate" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "sdpMid" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "sdpMLineIndex" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "foundation" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "component" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "priority" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "address" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "protocol" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "port" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "type" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "tcpType" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "relatedAddress" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "relatedPort" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "usernameFragment" with the proper type +PASS RTCIceCandidate interface: new RTCIceCandidate({ sdpMid: 1 }) must inherit property "toJSON()" with the proper type +PASS RTCIceCandidate interface: toJSON operation on new RTCIceCandidate({ sdpMid: 1 }) +PASS RTCPeerConnectionIceEvent interface: existence and properties of interface object +PASS RTCPeerConnectionIceEvent interface object length +PASS RTCPeerConnectionIceEvent interface object name +PASS RTCPeerConnectionIceEvent interface: existence and properties of interface prototype object +PASS RTCPeerConnectionIceEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCPeerConnectionIceEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCPeerConnectionIceEvent interface: attribute candidate +FAIL RTCPeerConnectionIceEvent interface: attribute url assert_true: The prototype object must have a property "url" expected true got false +PASS RTCPeerConnectionIceEvent must be primary interface of new RTCPeerConnectionIceEvent('ice') +PASS Stringification of new RTCPeerConnectionIceEvent('ice') +PASS RTCPeerConnectionIceEvent interface: new RTCPeerConnectionIceEvent('ice') must inherit property "candidate" with the proper type +FAIL RTCPeerConnectionIceEvent interface: new RTCPeerConnectionIceEvent('ice') must inherit property "url" with the proper type assert_inherits: property "url" not found in prototype chain +PASS RTCPeerConnectionIceErrorEvent interface: existence and properties of interface object +PASS RTCPeerConnectionIceErrorEvent interface object length +PASS RTCPeerConnectionIceErrorEvent interface object name +PASS RTCPeerConnectionIceErrorEvent interface: existence and properties of interface prototype object +PASS RTCPeerConnectionIceErrorEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCPeerConnectionIceErrorEvent interface: existence and properties of interface prototype object's @@unscopables property +FAIL RTCPeerConnectionIceErrorEvent interface: attribute address assert_true: The prototype object must have a property "address" expected true got false +FAIL RTCPeerConnectionIceErrorEvent interface: attribute port assert_true: The prototype object must have a property "port" expected true got false +PASS RTCPeerConnectionIceErrorEvent interface: attribute url +PASS RTCPeerConnectionIceErrorEvent interface: attribute errorCode +PASS RTCPeerConnectionIceErrorEvent interface: attribute errorText +PASS RTCPeerConnectionIceErrorEvent must be primary interface of new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); +PASS Stringification of new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); +FAIL RTCPeerConnectionIceErrorEvent interface: new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); must inherit property "address" with the proper type assert_inherits: property "address" not found in prototype chain +FAIL RTCPeerConnectionIceErrorEvent interface: new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); must inherit property "port" with the proper type assert_inherits: property "port" not found in prototype chain +PASS RTCPeerConnectionIceErrorEvent interface: new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); must inherit property "url" with the proper type +PASS RTCPeerConnectionIceErrorEvent interface: new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); must inherit property "errorCode" with the proper type +PASS RTCPeerConnectionIceErrorEvent interface: new RTCPeerConnectionIceErrorEvent('ice-error', { errorCode: 701 }); must inherit property "errorText" with the proper type +PASS RTCCertificate interface: existence and properties of interface object +PASS RTCCertificate interface object length +PASS RTCCertificate interface object name +PASS RTCCertificate interface: existence and properties of interface prototype object +PASS RTCCertificate interface: existence and properties of interface prototype object's "constructor" property +PASS RTCCertificate interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCCertificate interface: attribute expires +FAIL RTCCertificate interface: operation getSupportedAlgorithms() assert_own_property: interface object missing static operation expected property "getSupportedAlgorithms" missing +PASS RTCCertificate interface: operation getFingerprints() +PASS RTCCertificate must be primary interface of idlTestObjects.certificate +PASS Stringification of idlTestObjects.certificate +PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "expires" with the proper type +PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getSupportedAlgorithms()" with the proper type +PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getFingerprints()" with the proper type +PASS RTCRtpSender interface: existence and properties of interface object +PASS RTCRtpSender interface object length +PASS RTCRtpSender interface object name +PASS RTCRtpSender interface: existence and properties of interface prototype object +PASS RTCRtpSender interface: existence and properties of interface prototype object's "constructor" property +PASS RTCRtpSender interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCRtpSender interface: attribute track +PASS RTCRtpSender interface: attribute transport +PASS RTCRtpSender interface: attribute rtcpTransport +PASS RTCRtpSender interface: operation getCapabilities(DOMString) +FAIL RTCRtpSender interface: operation setParameters(RTCRtpSendParameters) assert_equals: property has wrong .length expected 1 but got 0 +PASS RTCRtpSender interface: operation getParameters() +PASS RTCRtpSender interface: operation replaceTrack(MediaStreamTrack) +PASS RTCRtpSender interface: operation setStreams(MediaStream) +PASS RTCRtpSender interface: operation getStats() +PASS RTCRtpSender interface: attribute dtmf +PASS RTCRtpSender must be primary interface of new RTCPeerConnection().addTransceiver('audio').sender +PASS Stringification of new RTCPeerConnection().addTransceiver('audio').sender +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "track" with the proper type +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "transport" with the proper type +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "rtcpTransport" with the proper type +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "getCapabilities(DOMString)" with the proper type +PASS RTCRtpSender interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "setParameters(RTCRtpSendParameters)" with the proper type +PASS RTCRtpSender interface: calling setParameters(RTCRtpSendParameters) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "getParameters()" with the proper type +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "replaceTrack(MediaStreamTrack)" with the proper type +PASS RTCRtpSender interface: calling replaceTrack(MediaStreamTrack) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "setStreams(MediaStream)" with the proper type +PASS RTCRtpSender interface: calling setStreams(MediaStream) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "getStats()" with the proper type +PASS RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "dtmf" with the proper type +PASS RTCRtpReceiver interface: existence and properties of interface object +PASS RTCRtpReceiver interface object length +PASS RTCRtpReceiver interface object name +PASS RTCRtpReceiver interface: existence and properties of interface prototype object +PASS RTCRtpReceiver interface: existence and properties of interface prototype object's "constructor" property +PASS RTCRtpReceiver interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCRtpReceiver interface: attribute track +PASS RTCRtpReceiver interface: attribute transport +PASS RTCRtpReceiver interface: attribute rtcpTransport +PASS RTCRtpReceiver interface: operation getCapabilities(DOMString) +PASS RTCRtpReceiver interface: operation getParameters() +PASS RTCRtpReceiver interface: operation getContributingSources() +PASS RTCRtpReceiver interface: operation getSynchronizationSources() +PASS RTCRtpReceiver interface: operation getStats() +PASS RTCRtpReceiver must be primary interface of new RTCPeerConnection().addTransceiver('audio').receiver +PASS Stringification of new RTCPeerConnection().addTransceiver('audio').receiver +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "track" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "transport" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "rtcpTransport" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getCapabilities(DOMString)" with the proper type +PASS RTCRtpReceiver interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').receiver with too few arguments must throw TypeError +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getParameters()" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getContributingSources()" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getSynchronizationSources()" with the proper type +PASS RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getStats()" with the proper type +PASS RTCRtpTransceiver interface: existence and properties of interface object +PASS RTCRtpTransceiver interface object length +PASS RTCRtpTransceiver interface object name +PASS RTCRtpTransceiver interface: existence and properties of interface prototype object +PASS RTCRtpTransceiver interface: existence and properties of interface prototype object's "constructor" property +PASS RTCRtpTransceiver interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCRtpTransceiver interface: attribute mid +PASS RTCRtpTransceiver interface: attribute sender +PASS RTCRtpTransceiver interface: attribute receiver +PASS RTCRtpTransceiver interface: attribute direction +PASS RTCRtpTransceiver interface: attribute currentDirection +FAIL RTCRtpTransceiver interface: operation stop() assert_own_property: interface prototype object missing non-static operation expected property "stop" missing +PASS RTCRtpTransceiver interface: operation setCodecPreferences([object Object]) +PASS RTCRtpTransceiver must be primary interface of new RTCPeerConnection().addTransceiver('audio') +PASS Stringification of new RTCPeerConnection().addTransceiver('audio') +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "mid" with the proper type +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "sender" with the proper type +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "receiver" with the proper type +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "direction" with the proper type +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "currentDirection" with the proper type +FAIL RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "stop()" with the proper type assert_inherits: property "stop" not found in prototype chain +PASS RTCRtpTransceiver interface: new RTCPeerConnection().addTransceiver('audio') must inherit property "setCodecPreferences([object Object])" with the proper type +PASS RTCRtpTransceiver interface: calling setCodecPreferences([object Object]) on new RTCPeerConnection().addTransceiver('audio') with too few arguments must throw TypeError +PASS RTCDtlsTransport interface: existence and properties of interface object +PASS RTCDtlsTransport interface object length +PASS RTCDtlsTransport interface object name +PASS RTCDtlsTransport interface: existence and properties of interface prototype object +PASS RTCDtlsTransport interface: existence and properties of interface prototype object's "constructor" property +PASS RTCDtlsTransport interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCDtlsTransport interface: attribute iceTransport +PASS RTCDtlsTransport interface: attribute state +PASS RTCDtlsTransport interface: operation getRemoteCertificates() +PASS RTCDtlsTransport interface: attribute onstatechange +PASS RTCDtlsTransport interface: attribute onerror +PASS RTCDtlsTransport must be primary interface of idlTestObjects.dtlsTransport +PASS Stringification of idlTestObjects.dtlsTransport +PASS RTCDtlsTransport interface: idlTestObjects.dtlsTransport must inherit property "iceTransport" with the proper type +PASS RTCDtlsTransport interface: idlTestObjects.dtlsTransport must inherit property "state" with the proper type +PASS RTCDtlsTransport interface: idlTestObjects.dtlsTransport must inherit property "getRemoteCertificates()" with the proper type +PASS RTCDtlsTransport interface: idlTestObjects.dtlsTransport must inherit property "onstatechange" with the proper type +PASS RTCDtlsTransport interface: idlTestObjects.dtlsTransport must inherit property "onerror" with the proper type +FAIL RTCIceTransport interface: existence and properties of interface object assert_throws: interface object didn't throw TypeError when called as a constructor function "function() { + new interface_object(); + }" did not throw +PASS RTCIceTransport interface object length +PASS RTCIceTransport interface object name +PASS RTCIceTransport interface: existence and properties of interface prototype object +PASS RTCIceTransport interface: existence and properties of interface prototype object's "constructor" property +PASS RTCIceTransport interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCIceTransport interface: attribute role +FAIL RTCIceTransport interface: attribute component assert_true: The prototype object must have a property "component" expected true got false +PASS RTCIceTransport interface: attribute state +PASS RTCIceTransport interface: attribute gatheringState +PASS RTCIceTransport interface: operation getLocalCandidates() +PASS RTCIceTransport interface: operation getRemoteCandidates() +PASS RTCIceTransport interface: operation getSelectedCandidatePair() +PASS RTCIceTransport interface: operation getLocalParameters() +PASS RTCIceTransport interface: operation getRemoteParameters() +PASS RTCIceTransport interface: attribute onstatechange +PASS RTCIceTransport interface: attribute ongatheringstatechange +PASS RTCIceTransport interface: attribute onselectedcandidatepairchange +PASS RTCIceTransport must be primary interface of idlTestObjects.iceTransport +PASS Stringification of idlTestObjects.iceTransport +FAIL RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "role" with the proper type assert_equals: expected "string" but got "object" +FAIL RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "component" with the proper type assert_inherits: property "component" not found in prototype chain +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "state" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "gatheringState" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "getLocalCandidates()" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "getRemoteCandidates()" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "getSelectedCandidatePair()" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "getLocalParameters()" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "getRemoteParameters()" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "onstatechange" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "ongatheringstatechange" with the proper type +PASS RTCIceTransport interface: idlTestObjects.iceTransport must inherit property "onselectedcandidatepairchange" with the proper type +PASS RTCTrackEvent interface: existence and properties of interface object +PASS RTCTrackEvent interface object length +PASS RTCTrackEvent interface object name +PASS RTCTrackEvent interface: existence and properties of interface prototype object +PASS RTCTrackEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCTrackEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCTrackEvent interface: attribute receiver +PASS RTCTrackEvent interface: attribute track +PASS RTCTrackEvent interface: attribute streams +PASS RTCTrackEvent interface: attribute transceiver +PASS RTCTrackEvent must be primary interface of initTrackEvent() +PASS Stringification of initTrackEvent() +PASS RTCTrackEvent interface: initTrackEvent() must inherit property "receiver" with the proper type +PASS RTCTrackEvent interface: initTrackEvent() must inherit property "track" with the proper type +PASS RTCTrackEvent interface: initTrackEvent() must inherit property "streams" with the proper type +PASS RTCTrackEvent interface: initTrackEvent() must inherit property "transceiver" with the proper type +PASS RTCSctpTransport interface: existence and properties of interface object +PASS RTCSctpTransport interface object length +PASS RTCSctpTransport interface object name +PASS RTCSctpTransport interface: existence and properties of interface prototype object +PASS RTCSctpTransport interface: existence and properties of interface prototype object's "constructor" property +PASS RTCSctpTransport interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCSctpTransport interface: attribute transport +PASS RTCSctpTransport interface: attribute state +PASS RTCSctpTransport interface: attribute maxMessageSize +PASS RTCSctpTransport interface: attribute maxChannels +PASS RTCSctpTransport interface: attribute onstatechange +PASS RTCSctpTransport must be primary interface of idlTestObjects.sctpTransport +PASS Stringification of idlTestObjects.sctpTransport +PASS RTCSctpTransport interface: idlTestObjects.sctpTransport must inherit property "transport" with the proper type +PASS RTCSctpTransport interface: idlTestObjects.sctpTransport must inherit property "state" with the proper type +PASS RTCSctpTransport interface: idlTestObjects.sctpTransport must inherit property "maxMessageSize" with the proper type +PASS RTCSctpTransport interface: idlTestObjects.sctpTransport must inherit property "maxChannels" with the proper type +PASS RTCSctpTransport interface: idlTestObjects.sctpTransport must inherit property "onstatechange" with the proper type +PASS RTCDataChannel interface: existence and properties of interface object +PASS RTCDataChannel interface object length +PASS RTCDataChannel interface object name +PASS RTCDataChannel interface: existence and properties of interface prototype object +PASS RTCDataChannel interface: existence and properties of interface prototype object's "constructor" property +PASS RTCDataChannel interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCDataChannel interface: attribute label +PASS RTCDataChannel interface: attribute ordered +PASS RTCDataChannel interface: attribute maxPacketLifeTime +PASS RTCDataChannel interface: attribute maxRetransmits +PASS RTCDataChannel interface: attribute protocol +PASS RTCDataChannel interface: attribute negotiated +PASS RTCDataChannel interface: attribute id +FAIL RTCDataChannel interface: attribute priority assert_true: The prototype object must have a property "priority" expected true got false +PASS RTCDataChannel interface: attribute readyState +PASS RTCDataChannel interface: attribute bufferedAmount +PASS RTCDataChannel interface: attribute bufferedAmountLowThreshold +PASS RTCDataChannel interface: attribute onopen +PASS RTCDataChannel interface: attribute onbufferedamountlow +PASS RTCDataChannel interface: attribute onerror +FAIL RTCDataChannel interface: attribute onclosing assert_true: The prototype object must have a property "onclosing" expected true got false +PASS RTCDataChannel interface: attribute onclose +PASS RTCDataChannel interface: operation close() +PASS RTCDataChannel interface: attribute onmessage +PASS RTCDataChannel interface: attribute binaryType +PASS RTCDataChannel interface: operation send(USVString) +PASS RTCDataChannel interface: operation send(Blob) +PASS RTCDataChannel interface: operation send(ArrayBuffer) +PASS RTCDataChannel interface: operation send(ArrayBufferView) +PASS RTCDataChannel must be primary interface of new RTCPeerConnection().createDataChannel('') +PASS Stringification of new RTCPeerConnection().createDataChannel('') +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "label" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "ordered" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "maxPacketLifeTime" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "maxRetransmits" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "protocol" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "negotiated" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "id" with the proper type +FAIL RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "priority" with the proper type assert_inherits: property "priority" not found in prototype chain +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "readyState" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "bufferedAmount" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "bufferedAmountLowThreshold" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onopen" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onbufferedamountlow" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onerror" with the proper type +FAIL RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onclosing" with the proper type assert_inherits: property "onclosing" not found in prototype chain +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onclose" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "close()" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "onmessage" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "binaryType" with the proper type +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "send(USVString)" with the proper type +PASS RTCDataChannel interface: calling send(USVString) on new RTCPeerConnection().createDataChannel('') with too few arguments must throw TypeError +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "send(Blob)" with the proper type +PASS RTCDataChannel interface: calling send(Blob) on new RTCPeerConnection().createDataChannel('') with too few arguments must throw TypeError +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "send(ArrayBuffer)" with the proper type +PASS RTCDataChannel interface: calling send(ArrayBuffer) on new RTCPeerConnection().createDataChannel('') with too few arguments must throw TypeError +PASS RTCDataChannel interface: new RTCPeerConnection().createDataChannel('') must inherit property "send(ArrayBufferView)" with the proper type +PASS RTCDataChannel interface: calling send(ArrayBufferView) on new RTCPeerConnection().createDataChannel('') with too few arguments must throw TypeError +PASS RTCDataChannelEvent interface: existence and properties of interface object +PASS RTCDataChannelEvent interface object length +PASS RTCDataChannelEvent interface object name +PASS RTCDataChannelEvent interface: existence and properties of interface prototype object +PASS RTCDataChannelEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCDataChannelEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCDataChannelEvent interface: attribute channel +PASS RTCDataChannelEvent must be primary interface of new RTCDataChannelEvent('channel', { + channel: new RTCPeerConnection().createDataChannel('') + }) +PASS Stringification of new RTCDataChannelEvent('channel', { + channel: new RTCPeerConnection().createDataChannel('') + }) +PASS RTCDataChannelEvent interface: new RTCDataChannelEvent('channel', { + channel: new RTCPeerConnection().createDataChannel('') + }) must inherit property "channel" with the proper type +PASS RTCDTMFSender interface: existence and properties of interface object +PASS RTCDTMFSender interface object length +PASS RTCDTMFSender interface object name +PASS RTCDTMFSender interface: existence and properties of interface prototype object +PASS RTCDTMFSender interface: existence and properties of interface prototype object's "constructor" property +PASS RTCDTMFSender interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCDTMFSender interface: operation insertDTMF(DOMString, unsigned long, unsigned long) +PASS RTCDTMFSender interface: attribute ontonechange +PASS RTCDTMFSender interface: attribute canInsertDTMF +PASS RTCDTMFSender interface: attribute toneBuffer +PASS RTCDTMFToneChangeEvent interface: existence and properties of interface object +PASS RTCDTMFToneChangeEvent interface object length +PASS RTCDTMFToneChangeEvent interface object name +PASS RTCDTMFToneChangeEvent interface: existence and properties of interface prototype object +PASS RTCDTMFToneChangeEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCDTMFToneChangeEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCDTMFToneChangeEvent interface: attribute tone +PASS RTCStatsReport interface: existence and properties of interface object +PASS RTCStatsReport interface object length +PASS RTCStatsReport interface object name +PASS RTCStatsReport interface: existence and properties of interface prototype object +PASS RTCStatsReport interface: existence and properties of interface prototype object's "constructor" property +PASS RTCStatsReport interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCError interface: existence and properties of interface object +PASS RTCError interface object length +PASS RTCError interface object name +PASS RTCError interface: existence and properties of interface prototype object +PASS RTCError interface: existence and properties of interface prototype object's "constructor" property +PASS RTCError interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCError interface: attribute errorDetail +PASS RTCError interface: attribute sdpLineNumber +PASS RTCError interface: attribute httpRequestStatusCode +PASS RTCError interface: attribute sctpCauseCode +PASS RTCError interface: attribute receivedAlert +PASS RTCError interface: attribute sentAlert +PASS RTCErrorEvent interface: existence and properties of interface object +PASS RTCErrorEvent interface object length +PASS RTCErrorEvent interface object name +PASS RTCErrorEvent interface: existence and properties of interface prototype object +PASS RTCErrorEvent interface: existence and properties of interface prototype object's "constructor" property +PASS RTCErrorEvent interface: existence and properties of interface prototype object's @@unscopables property +PASS RTCErrorEvent interface: attribute error +FAIL RTCErrorEvent must be primary interface of new RTCErrorEvent('error') assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Failed to construct 'RTCErrorEvent': 2 arguments required, but only 1 present." +FAIL Stringification of new RTCErrorEvent('error') assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Failed to construct 'RTCErrorEvent': 2 arguments required, but only 1 present." +FAIL RTCErrorEvent interface: new RTCErrorEvent('error') must inherit property "error" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Failed to construct 'RTCErrorEvent': 2 arguments required, but only 1 present." +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png index 43cb0e1..041de2b 100644 --- a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png index 304208d..3e06b0f 100644 --- a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/omt-worker-fetch/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt similarity index 100% copy from third_party/blink/web_tests/external/wpt/css/css-lists/list-inside-contain-expected.txt copy to third_party/blink/web_tests/platform/mac-mac10.10/virtual/omt-worker-fetch/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt
diff --git a/third_party/blink/web_tests/platform/mac-mac10.10/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt new file mode 100644 index 0000000..64dbbdf --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.10/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt
@@ -0,0 +1,14 @@ +This is a testharness.js-based test. +PASS Initial iceConnectionState should be new +PASS Closing the connection should set iceConnectionState to closed +PASS connection with one data channel should eventually have connected or completed connection state +FAIL connection with one data channel should eventually have connected connection state Cannot read property 'transport' of null +PASS connection with audio track should eventually have connected connection state +PASS connection with audio and video tracks should eventually have connected connection state +FAIL ICE can connect in a recvonly usecase promise_test: Unhandled rejection with value: object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." +FAIL iceConnectionState changes at the right time, with bundle policy balanced promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'sender' of undefined" +FAIL iceConnectionState changes at the right time, with bundle policy max-bundle promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'sender' of undefined" +FAIL iceConnectionState changes at the right time, with bundle policy max-compat promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'sender' of undefined" +PASS Responder ICE connection state behaves as expected +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png new file mode 100644 index 0000000..0390c8f --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png new file mode 100644 index 0000000..a221ae1 --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-mac10.11/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png index 540d262d..0390c8f 100644 --- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png index 049096ca..a221ae1 100644 --- a/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac-mac10.12/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png new file mode 100644 index 0000000..cbcc93f --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png new file mode 100644 index 0000000..1c9626e --- /dev/null +++ b/third_party/blink/web_tests/platform/mac-retina/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png index 8f763e80..cbcc93f 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png index d6ae5a6..1c9626e 100644 --- a/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/mac/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/external/wpt/uievents/click/click_events_on_input-expected.txt b/third_party/blink/web_tests/platform/win/external/wpt/uievents/click/click_events_on_input-expected.txt new file mode 100644 index 0000000..09c2f3b8 --- /dev/null +++ b/third_party/blink/web_tests/platform/win/external/wpt/uievents/click/click_events_on_input-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +FAIL Test click and auxclick on input element assert_true: Should have got at least "click". expected true got false +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png new file mode 100644 index 0000000..b2f7868 --- /dev/null +++ b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png new file mode 100644 index 0000000..d1cc316 --- /dev/null +++ b/third_party/blink/web_tests/platform/win/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png index 5e7d6c3..188a180 100644 --- a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png +++ b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/datetimelocal-picker/datetimelocal-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png new file mode 100644 index 0000000..d1cc316 --- /dev/null +++ b/third_party/blink/web_tests/platform/win7/virtual/controls-refresh-hc/virtual/controls-refresh/color-scheme/time-picker/time-picker-appearance-expected.png Binary files differ
diff --git a/third_party/blink/web_tests/virtual/controls-refresh/time-picker/time-picker-wheel.html b/third_party/blink/web_tests/virtual/controls-refresh/time-picker/time-picker-wheel.html new file mode 100644 index 0000000..9169b4ac --- /dev/null +++ b/third_party/blink/web_tests/virtual/controls-refresh/time-picker/time-picker-wheel.html
@@ -0,0 +1,38 @@ +<!DOCTYPE html> +<script> +if (window.internals) + internals.settings.setLangAttributeAwareFormControlUIEnabled(true); +</script> +<script src="../../../resources/testharness.js"></script> +<script src="../../../resources/testharnessreport.js"></script> +<script src="../../../fast/forms/resources/common.js"></script> +<script src="../../../fast/forms/resources/picker-common.js"></script> +<script src="../../../fast/forms/calendar-picker/resources/calendar-picker-common.js"></script> +<script src="../../../fast/forms/resources/common-wheel-event.js"></script> +<input type="time" id="time" value="14:15" lang="ru"> +<script> +let t = async_test('Test scrolling in time picker.'); + +function test1() { + let hourColumn = popupWindow.global.picker.timeColumns.firstChild; + const scrollHourTopBeforeWheelEvent = hourColumn.scrollTop; + // scroll up by 2 ticks ~ 2 cells + dispatchWheelEvent(hourColumn, 0, 2); + + let minuteColumn = hourColumn.nextSibling; + const scrollMinuteTopBeforeWheelEvent = minuteColumn.scrollTop; + // scroll up by 3 ticks ~ 3 cells + dispatchWheelEvent(minuteColumn, 0, 3); + + t.step_timeout(function() { + // verify that both columns have been scrolled up. + assert_true(scrollHourTopBeforeWheelEvent > hourColumn.scrollTop); + assert_true(scrollMinuteTopBeforeWheelEvent > minuteColumn.scrollTop); + t.done(); + }, 200); +} + +openPicker(document.getElementById('time'), t.step_func(test1), t.step_func_done(() => { + assert_false(internals.runtimeFlags.formControlsRefreshEnabled, "Popup did not open."); + })); +</script> \ No newline at end of file
diff --git a/third_party/blink/web_tests/virtual/omt-worker-fetch/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt b/third_party/blink/web_tests/virtual/omt-worker-fetch/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt new file mode 100644 index 0000000..7de9bd54 --- /dev/null +++ b/third_party/blink/web_tests/virtual/omt-worker-fetch/external/wpt/fetch/metadata/sec-fetch-dest/redirect/redirect-https-downgrade.tentative.sub-expected.txt
@@ -0,0 +1,4 @@ +This is a testharness.js-based test. +Harness Error. harness_status.status = 1 , harness_status.message = Uncaught SyntaxError: Unexpected token 'return' +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/speech-with-unified-autoplay/external/wpt/speech-api/historical-expected.txt b/third_party/blink/web_tests/virtual/speech-with-unified-autoplay/external/wpt/speech-api/historical-expected.txt new file mode 100644 index 0000000..cf2f69b --- /dev/null +++ b/third_party/blink/web_tests/virtual/speech-with-unified-autoplay/external/wpt/speech-api/historical-expected.txt
@@ -0,0 +1,12 @@ +This is a testharness.js-based test. +PASS SpeechRecognitionError interface should not exist +FAIL webkitSpeechGrammar interface should not exist assert_false: expected false got true +FAIL webkitSpeechGrammarList interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognition interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognitionError interface should not exist assert_false: expected false got true +FAIL webkitSpeechRecognitionEvent interface should not exist assert_false: expected false got true +NOTRUN SpeechRecognition's serviceURI attribute should not exist SpeechRecognition exposed +NOTRUN SpeechRecognitionEvent's interpretation attribute should not exist SpeechRecognitionEvent exposed +NOTRUN SpeechRecognitionEvent's emma attribute should not exist SpeechRecognitionEvent exposed +Harness: the test ran to completion. +
diff --git a/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt b/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt index 64dbbdf..23e52b1c 100644 --- a/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt +++ b/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/RTCPeerConnection-iceConnectionState.https-expected.txt
@@ -10,5 +10,6 @@ FAIL iceConnectionState changes at the right time, with bundle policy max-bundle promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'sender' of undefined" FAIL iceConnectionState changes at the right time, with bundle policy max-compat promise_test: Unhandled rejection with value: object "TypeError: Cannot read property 'sender' of undefined" PASS Responder ICE connection state behaves as expected +PASS Closing a PeerConnection should not fire iceconnectionstatechange event Harness: the test ran to completion.
diff --git a/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window-expected.txt b/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window-expected.txt index fd9bb23..9510586b 100644 --- a/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window-expected.txt +++ b/third_party/blink/web_tests/virtual/webrtc-wpt-plan-b/external/wpt/webrtc/idlharness.https.window-expected.txt
@@ -1,5 +1,5 @@ This is a testharness.js-based test. -Found 507 tests; 406 PASS, 101 FAIL, 0 TIMEOUT, 0 NOTRUN. +Found 499 tests; 402 PASS, 97 FAIL, 0 TIMEOUT, 0 NOTRUN. PASS idl_test setup PASS idl_test validation PASS Test driver for asyncInitCertificate @@ -40,7 +40,6 @@ PASS RTCPeerConnection interface: attribute connectionState FAIL RTCPeerConnection interface: attribute canTrickleIceCandidates assert_true: The prototype object must have a property "canTrickleIceCandidates" expected true got false PASS RTCPeerConnection interface: operation restartIce() -FAIL RTCPeerConnection interface: operation getDefaultIceServers() assert_own_property: interface object missing static operation expected property "getDefaultIceServers" missing PASS RTCPeerConnection interface: operation getConfiguration() PASS RTCPeerConnection interface: operation setConfiguration(RTCConfiguration) PASS RTCPeerConnection interface: operation close() @@ -92,7 +91,6 @@ PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "connectionState" with the proper type FAIL RTCPeerConnection interface: new RTCPeerConnection() must inherit property "canTrickleIceCandidates" with the proper type assert_inherits: property "canTrickleIceCandidates" not found in prototype chain PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "restartIce()" with the proper type -PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getDefaultIceServers()" with the proper type PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "getConfiguration()" with the proper type PASS RTCPeerConnection interface: new RTCPeerConnection() must inherit property "setConfiguration(RTCConfiguration)" with the proper type PASS RTCPeerConnection interface: calling setConfiguration(RTCConfiguration) on new RTCPeerConnection() with too few arguments must throw TypeError @@ -223,12 +221,10 @@ PASS RTCCertificate interface: existence and properties of interface prototype object's "constructor" property PASS RTCCertificate interface: existence and properties of interface prototype object's @@unscopables property PASS RTCCertificate interface: attribute expires -FAIL RTCCertificate interface: operation getSupportedAlgorithms() assert_own_property: interface object missing static operation expected property "getSupportedAlgorithms" missing PASS RTCCertificate interface: operation getFingerprints() PASS RTCCertificate must be primary interface of idlTestObjects.certificate PASS Stringification of idlTestObjects.certificate PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "expires" with the proper type -PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getSupportedAlgorithms()" with the proper type PASS RTCCertificate interface: idlTestObjects.certificate must inherit property "getFingerprints()" with the proper type PASS RTCRtpSender interface: existence and properties of interface object PASS RTCRtpSender interface object length @@ -238,7 +234,6 @@ PASS RTCRtpSender interface: existence and properties of interface prototype object's @@unscopables property PASS RTCRtpSender interface: attribute track PASS RTCRtpSender interface: attribute transport -PASS RTCRtpSender interface: attribute rtcpTransport PASS RTCRtpSender interface: operation getCapabilities(DOMString) FAIL RTCRtpSender interface: operation setParameters(RTCRtpSendParameters) assert_equals: property has wrong .length expected 1 but got 0 PASS RTCRtpSender interface: operation getParameters() @@ -250,7 +245,6 @@ FAIL Stringification of new RTCPeerConnection().addTransceiver('audio').sender assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "track" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "transport" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." -FAIL RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "rtcpTransport" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "getCapabilities(DOMString)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpSender interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').sender with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpSender interface: new RTCPeerConnection().addTransceiver('audio').sender must inherit property "setParameters(RTCRtpSendParameters)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." @@ -270,7 +264,6 @@ PASS RTCRtpReceiver interface: existence and properties of interface prototype object's @@unscopables property PASS RTCRtpReceiver interface: attribute track PASS RTCRtpReceiver interface: attribute transport -PASS RTCRtpReceiver interface: attribute rtcpTransport PASS RTCRtpReceiver interface: operation getCapabilities(DOMString) PASS RTCRtpReceiver interface: operation getParameters() PASS RTCRtpReceiver interface: operation getContributingSources() @@ -280,7 +273,6 @@ FAIL Stringification of new RTCPeerConnection().addTransceiver('audio').receiver assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "track" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "transport" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." -FAIL RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "rtcpTransport" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getCapabilities(DOMString)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpReceiver interface: calling getCapabilities(DOMString) on new RTCPeerConnection().addTransceiver('audio').receiver with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'." FAIL RTCRtpReceiver interface: new RTCPeerConnection().addTransceiver('audio').receiver must inherit property "getParameters()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "InvalidStateError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': This operation is only supported in 'unified-plan'."
diff --git a/third_party/guava/BUILD.gn b/third_party/guava/BUILD.gn index 9965ef8..c0fc304c 100644 --- a/third_party/guava/BUILD.gn +++ b/third_party/guava/BUILD.gn
@@ -15,6 +15,14 @@ # Avoids dependency cycle. no_build_hooks = true + + # Depend on this to replace excluded ListenableFuture.class + deps = [ + "//third_party/android_deps:com_google_guava_listenablefuture_java", + ] + + # Avoid class conflict in com_google_guava_listenablefuture. + jar_excluded_patterns = [ "*/ListenableFuture.class" ] } java_prebuilt("guava_java") {
diff --git a/third_party/hamcrest/proguard.flags b/third_party/hamcrest/proguard.flags index 695579df..58a3665a 100644 --- a/third_party/hamcrest/proguard.flags +++ b/third_party/hamcrest/proguard.flags
@@ -1 +1 @@ --keepnames class org.hamcrest.** { *; } +-keep class org.hamcrest.** { *; }
diff --git a/third_party/wayland-protocols/unstable/remote-shell/remote-shell-unstable-v1.xml b/third_party/wayland-protocols/unstable/remote-shell/remote-shell-unstable-v1.xml index 8407d6c..946e547 100644 --- a/third_party/wayland-protocols/unstable/remote-shell/remote-shell-unstable-v1.xml +++ b/third_party/wayland-protocols/unstable/remote-shell/remote-shell-unstable-v1.xml
@@ -38,7 +38,7 @@ reset. </description> - <interface name="zcr_remote_shell_v1" version="23"> + <interface name="zcr_remote_shell_v1" version="24"> <description summary="remote_shell"> The global interface that allows clients to turn a wl_surface into a "real window" which is remotely managed but can be stacked, activated @@ -237,7 +237,7 @@ </interface> - <interface name="zcr_remote_surface_v1" version="23"> + <interface name="zcr_remote_surface_v1" version="24"> <description summary="A desktop window"> An interface that may be implemented by a wl_surface, for implementations that provide a desktop-style user interface @@ -276,6 +276,7 @@ </description> <entry name="normal" value="1" summary="normal app window"/> <entry name="system_ui" value="2" summary="window is treated as systemui"/> + <entry name="hidden_in_overview" value="3" summary="window is normal, but hidden in overview"/> </enum> <request name="destroy" type="destructor">
diff --git a/tools/android/roll/android_deps/build.gradle b/tools/android/roll/android_deps/build.gradle index e4a4cba..b043625c 100644 --- a/tools/android/roll/android_deps/build.gradle +++ b/tools/android/roll/android_deps/build.gradle
@@ -32,6 +32,7 @@ compile "androidx.appcompat:appcompat:${androidXSupportLibVersion}" compile "androidx.asynclayoutinflater:asynclayoutinflater:${androidXSupportLibVersion}" compile "androidx.cardview:cardview:${androidXSupportLibVersion}" + compile "androidx.concurrent:concurrent-futures:${androidXSupportLibVersion}" compile "androidx.collection:collection:${androidXSupportLibVersion}" compile "androidx.coordinatorlayout:coordinatorlayout:${androidXSupportLibVersion}" compile "androidx.customview:customview:${androidXSupportLibVersion}" @@ -126,6 +127,9 @@ // Matches version depended on by Dagger. buildCompile "com.squareup:javapoet:1.11.0" + compile "com.google.guava:listenablefuture:1.0" + compile "com.google.protobuf:protobuf-lite:3.0.1" + // testCompile targets have test_only = true. testCompile "androidx.test:core:1.0.0" testCompile "androidx.test:monitor:1.1.0"
diff --git a/tools/android/roll/android_deps/buildSrc/src/main/groovy/BuildConfigGenerator.groovy b/tools/android/roll/android_deps/buildSrc/src/main/groovy/BuildConfigGenerator.groovy index 038d1ad1..8ae5c28 100644 --- a/tools/android/roll/android_deps/buildSrc/src/main/groovy/BuildConfigGenerator.groovy +++ b/tools/android/roll/android_deps/buildSrc/src/main/groovy/BuildConfigGenerator.groovy
@@ -308,6 +308,12 @@ // and android_aar_prebuilt template will fail if it's not set explictly. sb.append(' extract_native_libraries = true\n') break + case 'com_google_guava_guava': + // Need to exclude class and replace it with class library as + // com_google_guava_listenablefuture has support_androids=true. + sb.append(' deps += [":com_google_guava_listenablefuture_java"]\n') + sb.append(' jar_excluded_patterns = ["*/ListenableFuture.class"]\n') + break case 'androidx_test_rules': // Target needs Android SDK deps which exist in third_party/android_sdk. sb.append("""\
diff --git a/tools/android/roll/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.groovy b/tools/android/roll/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.groovy index 120f93b8..60a97860 100644 --- a/tools/android/roll/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.groovy +++ b/tools/android/roll/android_deps/buildSrc/src/main/groovy/ChromiumDepGraph.groovy
@@ -36,6 +36,10 @@ url: "https://github.com/google/guava", licenseUrl: "https://www.apache.org/licenses/LICENSE-2.0.txt", licenseName: "Apache 2.0"), + 'com_google_guava_listenablefuture': new PropertyOverride( + url: "https://github.com/google/guava", + licenseUrl: "https://www.apache.org/licenses/LICENSE-2.0.txt", + licenseName: "Apache 2.0"), 'org_codehaus_mojo_animal_sniffer_annotations': new PropertyOverride( url: "http://www.mojohaus.org/animal-sniffer/animal-sniffer-annotations/", licenseUrl: "https://raw.githubusercontent.com/mojohaus/animal-sniffer/master/animal-sniffer-annotations/pom.xml",
diff --git a/tools/gritsettings/resource_ids b/tools/gritsettings/resource_ids index b338915..3d412b8c 100644 --- a/tools/gritsettings/resource_ids +++ b/tools/gritsettings/resource_ids
@@ -133,7 +133,8 @@ "includes": [12550], }, "chrome/browser/resources/print_preview/print_preview_resources.grd": { - "structures": [12560], + "includes": [12560], + "structures": [12660], }, "chrome/browser/resources/quota_internals/quota_internals_resources.grd": { "includes": [12750],
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 29966eb..f71ec25 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -21197,8 +21197,8 @@ <int value="1315" label="PASSWORDSPRIVATE_CHANGESAVEDPASSWORD"/> <int value="1316" label="AUTOTESTPRIVATE_SETWHITELISTEDPREF"/> <int value="1317" label="SAFEBROWSINGPRIVATE_GETREFERRERCHAIN"/> - <int value="1318" label="DECLARATIVENETREQUEST_ADDDYNAMICRULES"/> - <int value="1319" label="DECLARATIVENETREQUEST_REMOVEDYNAMICRULES"/> + <int value="1318" label="DELETED_DECLARATIVENETREQUEST_ADDDYNAMICRULES"/> + <int value="1319" label="DELETED_DECLARATIVENETREQUEST_REMOVEDYNAMICRULES"/> <int value="1320" label="DECLARATIVENETREQUEST_GETDYNAMICRULES"/> <int value="1321" label="AUTOTESTPRIVATE_GETARCSTATE"/> <int value="1322" label="AUTOTESTPRIVATE_ISTABLETMODEENABLED"/> @@ -21287,6 +21287,7 @@ <int value="1404" label="TERMINALPRIVATE_GETCROSHSETTINGS"/> <int value="1405" label="AUTOTESTPRIVATE_ENABLEASSISTANTANDWAITFORREADY"/> <int value="1406" label="INPUTMETHODPRIVATE_FINISHCOMPOSINGTEXT"/> + <int value="1407" label="DECLARATIVENETREQUEST_UPDATEDYNAMICRULES"/> </enum> <enum name="ExtensionIconState">
diff --git a/tools/perf/expectations.config b/tools/perf/expectations.config index f1ef714..0d71797 100644 --- a/tools/perf/expectations.config +++ b/tools/perf/expectations.config
@@ -123,6 +123,7 @@ crbug.com/850293 blink_perf.svg/Cowboy_transform.html [ Skip ] crbug.com/894147 [ android-nexus-5 ] blink_perf.svg/SierpinskiCarpet.html [ Skip ] crbug.com/894147 [ android-nexus-5x ] blink_perf.svg/SierpinskiCarpet.html [ Skip ] +crbug.com/1023792 [ android ] blink_perf.svg/SierpinskiCarpet.html [ Skip ] # Benchmark: jetstream crbug.com/830600 [ android-nexus-5x android-webview ] jetstream/JetStream [ Skip ]
diff --git a/tools/traffic_annotation/summary/annotations.xml b/tools/traffic_annotation/summary/annotations.xml index 8a1feb43..5b6ece5 100644 --- a/tools/traffic_annotation/summary/annotations.xml +++ b/tools/traffic_annotation/summary/annotations.xml
@@ -222,7 +222,6 @@ <item id="ranker_url_fetcher" hash_code="95682324" type="0" content_hash_code="45958626" os_list="linux,windows" file_path="components/assist_ranker/ranker_url_fetcher.cc"/> <item id="rappor_report" hash_code="44606780" type="0" content_hash_code="111287826" os_list="linux,windows" file_path="components/rappor/log_uploader.cc"/> <item id="refresh_token_annotation_request" hash_code="7433837" type="1" second_id="29188932" deprecated="2018-01-17" content_hash_code="137103383" file_path=""/> - <item id="remote_copy_message_handler" hash_code="80255301" type="0" content_hash_code="117673331" os_list="linux,windows" file_path="chrome/browser/sharing/shared_clipboard/remote_copy_message_handler.cc"/> <item id="remote_suggestions_provider" hash_code="49544361" type="0" content_hash_code="126329742" os_list="linux,windows" file_path="components/ntp_snippets/remote/cached_image_fetcher.cc"/> <item id="render_view_context_menu" hash_code="25844439" type="0" content_hash_code="69471170" os_list="linux,windows" file_path="chrome/browser/renderer_context_menu/render_view_context_menu.cc"/> <item id="renderer_initiated_download" hash_code="116443055" type="0" content_hash_code="37846436" os_list="linux,windows" file_path="content/browser/frame_host/render_frame_host_impl.cc"/>
diff --git a/ui/base/clipboard/test/test_clipboard.cc b/ui/base/clipboard/test/test_clipboard.cc index d3fdc3b..e87c196 100644 --- a/ui/base/clipboard/test/test_clipboard.cc +++ b/ui/base/clipboard/test/test_clipboard.cc
@@ -175,7 +175,7 @@ if (IsSupportedClipboardBuffer(ClipboardBuffer::kSelection)) GetStore(ClipboardBuffer::kSelection) .data[ClipboardFormatType::GetPlainTextType()] = text; - ClipboardMonitor::GetInstance()->NotifyClipboardDataChanged(); + ui::ClipboardMonitor::GetInstance()->NotifyClipboardDataChanged(); } void TestClipboard::WriteHTML(const char* markup_data, @@ -217,7 +217,6 @@ NOTREACHED() << "Unable to convert bitmap for clipboard"; return; } - ClipboardMonitor::GetInstance()->NotifyClipboardDataChanged(); } void TestClipboard::WriteData(const ClipboardFormatType& format,
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index ef01ac96..a5ed0da 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc
@@ -1208,7 +1208,7 @@ void Layer::SetDidScrollCallback( base::RepeatingCallback<void(const gfx::ScrollOffset&, const cc::ElementId&)> callback) { - cc_layer_->set_did_scroll_callback(std::move(callback)); + cc_layer_->SetDidScrollCallback(std::move(callback)); } void Layer::SetScrollable(const gfx::Size& container_bounds) { @@ -1296,8 +1296,6 @@ return name_; } -void Layer::DidChangeScrollbarsHiddenIfOverlay(bool) {} - void Layer::CollectAnimators( std::vector<scoped_refptr<LayerAnimator>>* animators) { if (animator_ && animator_->is_animating())
diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 1abb661..9b2fb765 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h
@@ -467,7 +467,6 @@ std::unique_ptr<base::trace_event::TracedValue> TakeDebugInfo( const cc::Layer* layer) override; std::string LayerDebugName(const cc::Layer* layer) const override; - void DidChangeScrollbarsHiddenIfOverlay(bool) override; // Triggers a call to SwitchToLayer. void SwitchCCLayerForTest();
diff --git a/ui/events/mobile_scroller.cc b/ui/events/mobile_scroller.cc index c6651516..01002876 100644 --- a/ui/events/mobile_scroller.cc +++ b/ui/events/mobile_scroller.cc
@@ -8,6 +8,7 @@ #include "base/lazy_instance.h" #include "base/macros.h" +#include "base/numerics/math_constants.h" namespace ui { namespace { @@ -132,10 +133,9 @@ }; float ComputeDeceleration(float friction) { - const float kGravityEarth = 9.80665f; - return kGravityEarth // g (m/s^2) - * 39.37f // inch/meter - * 160.f // pixels/inch + return base::kMeanGravityFloat // g (m/s^2) + * 39.37f // inch/meter + * 160.f // pixels/inch * friction; }
diff --git a/ui/events/ozone/evdev/event_converter_evdev.h b/ui/events/ozone/evdev/event_converter_evdev.h index cdcc807..ee01d14 100644 --- a/ui/events/ozone/evdev/event_converter_evdev.h +++ b/ui/events/ozone/evdev/event_converter_evdev.h
@@ -127,10 +127,10 @@ void OnFileCanWriteWithoutBlocking(int fd) override; // File descriptor to read. - int fd_; + const int fd_; // Path to input device. - base::FilePath path_; + const base::FilePath path_; // Input device information, including id (which uniquely identifies an // event converter) and type.
diff --git a/ui/events/ozone/evdev/event_converter_evdev_impl.h b/ui/events/ozone/evdev/event_converter_evdev_impl.h index 94e4a36..0346694 100644 --- a/ui/events/ozone/evdev/event_converter_evdev_impl.h +++ b/ui/events/ozone/evdev/event_converter_evdev_impl.h
@@ -66,7 +66,7 @@ void FlushEvents(const input_event& input); // Input device file descriptor. - base::ScopedFD input_device_fd_; + const base::ScopedFD input_device_fd_; // Input modalities for this device. bool has_keyboard_; @@ -95,10 +95,10 @@ std::bitset<kMouseButtonCount> mouse_button_state_; // Shared cursor state. - CursorDelegateEvdev* cursor_; + CursorDelegateEvdev* const cursor_; // Callbacks for dispatching events. - DeviceEventDispatcherEvdev* dispatcher_; + DeviceEventDispatcherEvdev* const dispatcher_; DISALLOW_COPY_AND_ASSIGN(EventConverterEvdevImpl); };
diff --git a/ui/events/ozone/evdev/event_converter_test_util.cc b/ui/events/ozone/evdev/event_converter_test_util.cc index a363712..c260de7 100644 --- a/ui/events/ozone/evdev/event_converter_test_util.cc +++ b/ui/events/ozone/evdev/event_converter_test_util.cc
@@ -118,7 +118,7 @@ return POST_DISPATCH_NONE; } - EventDispatchCallback callback_; + const EventDispatchCallback callback_; }; } // namespace
diff --git a/ui/events/ozone/evdev/event_factory_evdev.h b/ui/events/ozone/evdev/event_factory_evdev.h index c91f9aea..455f6ee 100644 --- a/ui/events/ozone/evdev/event_factory_evdev.h +++ b/ui/events/ozone/evdev/event_factory_evdev.h
@@ -115,10 +115,10 @@ int last_device_id_ = 0; // Interface for scanning & monitoring input devices. - DeviceManager* device_manager_; // Not owned. + DeviceManager* const device_manager_; // Not owned. // Gamepad provider to dispatch gamepad events. - GamepadProviderOzone* gamepad_provider_; + GamepadProviderOzone* const gamepad_provider_; // Proxy for input device factory (manages device I/O objects). // The real object lives on a different thread. @@ -134,7 +134,7 @@ KeyboardEvdev keyboard_; // Cursor movement. - CursorDelegateEvdev* cursor_; + CursorDelegateEvdev* const cursor_; // Object for controlling input devices. InputControllerEvdev input_controller_;
diff --git a/ui/events/ozone/evdev/gamepad_event_converter_evdev.h b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h index 603a021..b07c73b 100644 --- a/ui/events/ozone/evdev/gamepad_event_converter_evdev.h +++ b/ui/events/ozone/evdev/gamepad_event_converter_evdev.h
@@ -73,10 +73,10 @@ base::flat_set<unsigned int> pressed_buttons_; // Input device file descriptor. - base::ScopedFD input_device_fd_; + const base::ScopedFD input_device_fd_; // Callbacks for dispatching events. - DeviceEventDispatcherEvdev* dispatcher_; + DeviceEventDispatcherEvdev* const dispatcher_; DISALLOW_COPY_AND_ASSIGN(GamepadEventConverterEvdev); };
diff --git a/ui/events/ozone/evdev/input_controller_evdev.h b/ui/events/ozone/evdev/input_controller_evdev.h index fbd8664e0..77d80a2 100644 --- a/ui/events/ozone/evdev/input_controller_evdev.h +++ b/ui/events/ozone/evdev/input_controller_evdev.h
@@ -94,10 +94,10 @@ InputDeviceFactoryEvdevProxy* input_device_factory_ = nullptr; // Keyboard state. - KeyboardEvdev* keyboard_; + KeyboardEvdev* const keyboard_; // Mouse button map. - MouseButtonMapEvdev* button_map_; + MouseButtonMapEvdev* const button_map_; // Device presence. bool has_mouse_ = false;
diff --git a/ui/events/ozone/evdev/input_device_factory_evdev.h b/ui/events/ozone/evdev/input_device_factory_evdev.h index 51c52e3..a7314a3b 100644 --- a/ui/events/ozone/evdev/input_device_factory_evdev.h +++ b/ui/events/ozone/evdev/input_device_factory_evdev.h
@@ -107,10 +107,10 @@ void EnableDevices(); // Task runner for our thread. - scoped_refptr<base::TaskRunner> task_runner_; + const scoped_refptr<base::TaskRunner> task_runner_; // Cursor movement. - CursorDelegateEvdev* cursor_; + CursorDelegateEvdev* const cursor_; // Shared Palm state. const std::unique_ptr<SharedPalmDetectionFilterState> shared_palm_state_; @@ -122,7 +122,7 @@ #endif // Dispatcher for events. - std::unique_ptr<DeviceEventDispatcherEvdev> dispatcher_; + const std::unique_ptr<DeviceEventDispatcherEvdev> dispatcher_; // Number of pending device additions & device classes. int pending_device_changes_ = 0;
diff --git a/ui/events/ozone/evdev/input_injector_evdev.h b/ui/events/ozone/evdev/input_injector_evdev.h index eeda613b..a5ac732 100644 --- a/ui/events/ozone/evdev/input_injector_evdev.h +++ b/ui/events/ozone/evdev/input_injector_evdev.h
@@ -33,10 +33,10 @@ private: // Shared cursor state. - CursorDelegateEvdev* cursor_; + CursorDelegateEvdev* const cursor_; // Interface for dispatching events. - std::unique_ptr<DeviceEventDispatcherEvdev> dispatcher_; + const std::unique_ptr<DeviceEventDispatcherEvdev> dispatcher_; DISALLOW_COPY_AND_ASSIGN(InputInjectorEvdev); };
diff --git a/ui/events/ozone/evdev/input_injector_evdev_unittest.cc b/ui/events/ozone/evdev/input_injector_evdev_unittest.cc index 7fc99eb..252f8f43 100644 --- a/ui/events/ozone/evdev/input_injector_evdev_unittest.cc +++ b/ui/events/ozone/evdev/input_injector_evdev_unittest.cc
@@ -80,7 +80,7 @@ void ExpectClick(int x, int y, int button, int count); EventObserver event_observer_; - EventDispatchCallback dispatch_callback_; + const EventDispatchCallback dispatch_callback_; FakeCursorDelegateEvdev cursor_; std::unique_ptr<DeviceManager> device_manager_;
diff --git a/ui/events/ozone/evdev/keyboard_evdev.h b/ui/events/ozone/evdev/keyboard_evdev.h index 758001d..6adb4e9 100644 --- a/ui/events/ozone/evdev/keyboard_evdev.h +++ b/ui/events/ozone/evdev/keyboard_evdev.h
@@ -86,13 +86,13 @@ std::bitset<KEY_CNT> key_state_; // Callback for dispatching events. - EventDispatchCallback callback_; + const EventDispatchCallback callback_; // Shared modifier state. - EventModifiers* modifiers_; + EventModifiers* const modifiers_; // Shared layout engine. - KeyboardLayoutEngine* keyboard_layout_engine_; + KeyboardLayoutEngine* const keyboard_layout_engine_; // Key repeat handler. EventAutoRepeatHandler auto_repeat_handler_;
diff --git a/ui/events/ozone/evdev/tablet_event_converter_evdev.h b/ui/events/ozone/evdev/tablet_event_converter_evdev.h index f6bf158a..dae1b23 100644 --- a/ui/events/ozone/evdev/tablet_event_converter_evdev.h +++ b/ui/events/ozone/evdev/tablet_event_converter_evdev.h
@@ -50,16 +50,16 @@ void FlushEvents(const input_event& input); // Input device file descriptor. - base::ScopedFD input_device_fd_; + const base::ScopedFD input_device_fd_; // Controller for watching the input fd. base::MessagePumpLibevent::FdWatchController controller_; // Shared cursor state. - CursorDelegateEvdev* cursor_; + CursorDelegateEvdev* const cursor_; // Dispatcher for events. - DeviceEventDispatcherEvdev* dispatcher_; + DeviceEventDispatcherEvdev* const dispatcher_; int y_abs_location_ = 0; int x_abs_location_ = 0;
diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev.h b/ui/events/ozone/evdev/touch_event_converter_evdev.h index 9482892..9ef288b 100644 --- a/ui/events/ozone/evdev/touch_event_converter_evdev.h +++ b/ui/events/ozone/evdev/touch_event_converter_evdev.h
@@ -113,10 +113,10 @@ int NextTrackingId(); // Input device file descriptor. - base::ScopedFD input_device_fd_; + const base::ScopedFD input_device_fd_; // Dispatcher for events. - DeviceEventDispatcherEvdev* dispatcher_; + DeviceEventDispatcherEvdev* const dispatcher_; // Set if we drop events in kernel (SYN_DROPPED) or in process. bool dropped_events_ = false;
diff --git a/ui/file_manager/file_manager/foreground/elements/icons.html b/ui/file_manager/file_manager/foreground/elements/icons.html index e9e4734..1eb77a9 100644 --- a/ui/file_manager/file_manager/foreground/elements/icons.html +++ b/ui/file_manager/file_manager/foreground/elements/icons.html
@@ -36,3 +36,13 @@ </defs> </svg> </iron-iconset-svg> + +<!-- files-ng viewBox 0 0 20 20 icon set --> +<iron-iconset-svg name="files20" size="20"> + <svg> + <defs> + <g id="eject"><path d="M15 12v2H5v-2h10zm-5-8l5 6H5l5-6z"/></g> + <g id="external-link"><path d="M15 15H5V5h4V3H5C4 3 3 4 3 5v10c0 1 1 2 2 2h10c1 0 2-1 2-2v-4h-2v4zM11 3v2h2.5L7 11.5 8.5 13 15 6.5V9h2V3h-6z"/><g> + </defs> + </svg> +</iron-iconset-svg>
diff --git a/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder.svg b/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder.svg new file mode 100644 index 0000000..a3b10b4 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M16 5h-4l-2-2H4c-1.1 0-1.99.9-1.99 2L2 15c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 10H4V7h12v8z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder_shared.svg b/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder_shared.svg new file mode 100644 index 0000000..128973ba --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/filetype/filetype_folder_shared.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M10 3l2 2h4c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2l.01-10c0-1.1.89-2 1.99-2h6zm6 4H4v8h12V7zm-4 5c.9975 0 3 .4467 3 1.3333V14H9v-.6667C9 12.4467 11.0025 12 12 12zm0-3.5c.825 0 1.5.675 1.5 1.5s-.675 1.5-1.5 1.5-1.5-.675-1.5-1.5.675-1.5 1.5-1.5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/android.svg b/ui/file_manager/file_manager/foreground/images/volumes/android.svg new file mode 100644 index 0000000..c53402f --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/android.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M16.8167 9.0667l-2.55-1.45L11.8833 10l2.3834 2.3833 2.55-1.45c.4583-.2583.6833-.5916.6833-.9333s-.225-.675-.6833-.9333zM3.925 2.0417l7.0167 7.0166 2.125-2.125-8.9167-5.05C4.0917 1.85 4.0333 1.825 3.975 1.8c-.1417-.0583-.25.0417-.125.175.025.0167.05.0417.075.0667zm0 15.9166l-.0667.0667c-.125.125-.0166.2333.125.175.0584-.025.1167-.05.175-.0833l8.9084-5.05-2.125-2.125s-6 6.0083-7.0167 7.0166zM10 10L2.8167 2.8167C2.6583 2.6583 2.5 2.7583 2.5 2.975v14.05c0 .2167.1583.3167.3167.1583L10 10z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/archive.svg b/ui/file_manager/file_manager/foreground/images/volumes/archive.svg new file mode 100644 index 0000000..c176a46 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/archive.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M15 3c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H5c-1.1 0-2-.9-2-2V5c0-1.1.9-2 2-2zM8 5H5v10h10V5h-5v2H8V5zm4 6v2h-2v-2h2zm-2-2v2H8V9h2zm2-2v2h-2V7h2z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/audio.svg b/ui/file_manager/file_manager/foreground/images/volumes/audio.svg new file mode 100644 index 0000000..ccfb9f8b --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/audio.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M16 15c0 .55-.45 1-1 1h-1v-3h2v2zM6 16H5c-.55 0-1-.45-1-1v-2h2v3zM2 9v6c0 1.66 1.34 3 3 3h3v-7H4V9c0-3.87 2.13-5 6-5s6 1.13 6 5v2h-4v7h3c1.66 0 3-1.34 3-3V9c0-4.97-3.03-7-8-7-4.97 0-8 2.03-8 7z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/cd.svg b/ui/file_manager/file_manager/foreground/images/volumes/cd.svg new file mode 100644 index 0000000..a0cffdc --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/cd.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M10 2c4.416 0 8 3.584 8 8s-3.584 8-8 8-8-3.584-8-8 3.584-8 8-8zm0 4c-2.205 0-4 1.795-4 4s1.795 4 4 4 4-1.795 4-4-1.795-4-4-4zm0 1c1.6538 0 3 1.3462 3 3s-1.3462 3-3 3-3-1.3462-3-3 1.3462-3 3-3zm0 1c-1.1015 0-2 .8985-2 2 0 1.1015.8985 2 2 2 1.1015 0 2-.8985 2-2 0-1.1015-.8985-2-2-2z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/computer.svg b/ui/file_manager/file_manager/foreground/images/volumes/computer.svg new file mode 100644 index 0000000..6623421 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/computer.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"> + <path d="M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2h-4zM4 6h16v10H4V6z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/devices.svg b/ui/file_manager/file_manager/foreground/images/volumes/devices.svg new file mode 100644 index 0000000..106389b --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/devices.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M18 3c.2761 0 .5261.112.7071.2929.181.181.2929.431.2929.7071v.961L5 5.002V15h6v2H2c-.5523 0-1-.4477-1-1s.4477-1 1-1h1V4c0-.5523.4477-1 1-1h14zm-4.8333 3l4.6666.0061C18.475 6.0061 19 6.55 19 7.2222v8.5556C19 16.45 18.475 17 17.8333 17h-4.6666C12.525 17 12 16.45 12 15.7778V7.2222C12 6.55 12.525 6 13.1667 6zM17.5 7.5h-4V15h4V7.5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/downloads.svg b/ui/file_manager/file_manager/foreground/images/volumes/downloads.svg new file mode 100644 index 0000000..18c08e54 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/downloads.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M6 13v2h8v-2h2v2.375c0 .8938-.7312 1.625-1.625 1.625h-8.75C4.7313 17 4 16.2688 4 15.375V13h2zm5-10v6.2l2.5-2.7L15 8l-5 5-5-5 1.5-1.5L9 9.2V3h2z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/drive.svg b/ui/file_manager/file_manager/foreground/images/volumes/drive.svg new file mode 100644 index 0000000..a92d0d8f --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/drive.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M10 3l2 2h4c1.1 0 2 .9 2 2v8c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2l.01-10c0-1.1.89-2 1.99-2h6zm6 4H4v8h12V7zm-1 5.1053L13.8935 14H9.6613l1.1064-1.8947H15zM10.1161 8.48s1.1065 1.8979 1.1065 1.8947l-2.1161 3.6221L8 12.1053zM12.6032 8l2.213 3.7895h-2.2097l-2.2097-3.7863V8h2.2064z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/hard_drive.svg b/ui/file_manager/file_manager/foreground/images/volumes/hard_drive.svg new file mode 100644 index 0000000..c277e7a --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/hard_drive.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M15 2c1.1046 0 2 .8954 2 2v12c0 1.1046-.8954 2-2 2H5c-1.1046 0-2-.8954-2-2V4c0-1.1046.8954-2 2-2h10zm0 10H5v4h10v-4zm-2 1c.5523 0 1 .4477 1 1s-.4477 1-1 1-1-.4477-1-1 .4477-1 1-1zm2-9H5v6h10V4z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/images.svg b/ui/file_manager/file_manager/foreground/images/volumes/images.svg new file mode 100644 index 0000000..c1cc508 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/images.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M15 3H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H5V5h10v10zm-3.6667-6L9.5 12 8 10.6 6 14h8l-2.6667-5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/linux_files.svg b/ui/file_manager/file_manager/foreground/images/volumes/linux_files.svg new file mode 100644 index 0000000..0c5d7a9 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/linux_files.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M10 2c3.5056 0 5.577 2.592 6.4291 6.1657.3863.1221 1.1212.614 1.3405 1.2813.272.8277.4387 1.756-.303 2.0339-.259.097-.484.0798-.6816-.0231-.039 2.8879-1.2964 4.5267-3.258 5.335.0314.0621.0473.1343.0473.215 0 .548.2595.9922-1.6433.9922-1.3916 0-1.6266-.3033-1.6525-.6327-.0922-.0576-.185-.147-.2785-.147-.0938 0-.187.0969-.2796.1565C9.6922 17.701 9.4507 18 8.069 18c-1.9028 0-1.6433-.4443-1.6433-.9923a.5075.5075 0 0 1 .0483-.2223c-1.9598-.8128-3.216-2.4596-3.2589-5.3276-.1976.1029-.4226.1202-.6817.023-.7417-.2778-.575-1.2061-.303-2.0338.2252-.6854.9945-1.1858 1.3712-1.2905C4.4784 4.7036 6.5356 2 10 2zm0 3.7422c-.7017 0-1.212-1.5733-1.786-1.4287-1.9986.5034-3.1894 3.3091-3.1894 6.0963 0 3.3466 1.3186 5.1488 4.9754 5.1488 3.6568 0 4.9754-1.6023 4.9754-5.1488 0-2.9427-1.1993-5.6451-3.1894-6.0963-.6378-.1446-1.0843 1.4287-1.786 1.4287zm-.1677 3.3802a.3843.3843 0 0 1 .3174-.0006l1.1359.5122c.1967.0887.2854.3226.198.5224a.3965.3965 0 0 1-.0693.1073l-1.1293 1.2477a.3855.3855 0 0 1-.5746-.0008l-1.1256-1.2509a.4002.4002 0 0 1 .0248-.5592.3892.3892 0 0 1 .1036-.069zm-2.315-2.161c.457 0 .8275.3808.8275.8506 0 .4697-.3705.8505-.8276.8505-.457 0-.8275-.3808-.8275-.8505 0-.4698.3705-.8506.8275-.8506zm4.9655 0c.457 0 .8275.3808.8275.8506 0 .4697-.3705.8505-.8275.8505-.4571 0-.8276-.3808-.8276-.8505 0-.4698.3705-.8506.8276-.8506z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/my_files.svg b/ui/file_manager/file_manager/foreground/images/volumes/my_files.svg new file mode 100644 index 0000000..19fbaf036 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/my_files.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M18 15h1c.5523 0 1 .4477 1 1s-.4477 1-1 1H1c-.5523 0-1-.4477-1-1s.4477-1 1-1h1V4c0-.5523.4477-1 1-1h14c.2761 0 .5261.112.7071.2929.181.181.2929.431.2929.7071v11zm-2-3V5H4v7h12zm-8 2v1h4v-1H8z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/offline.svg b/ui/file_manager/file_manager/foreground/images/volumes/offline.svg new file mode 100644 index 0000000..ec4a74e --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/offline.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M14.8 7.76L12.24 5.2l-5.0112 5.0112H5.7312l4.0576 4.0576v-1.4976L14.8 7.76zm3.2.64l-1.28 1.28-.64-.64-4.48 4.48v2.56l-1.28 1.28-3.2-3.2L3.28 18H2v-1.28l3.84-3.84-3.2-3.2L3.92 8.4h2.56l4.48-4.48-.64-.64L11.6 2 18 8.4z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/phone.svg b/ui/file_manager/file_manager/foreground/images/volumes/phone.svg new file mode 100644 index 0000000..150f60d --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/phone.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M14 1.01L6 1c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM14 17H6v-1h8v1zm0-3H6V6h8v8zM6 4V3h8v1H6z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/plugin_vm_ng.svg b/ui/file_manager/file_manager/foreground/images/volumes/plugin_vm_ng.svg new file mode 100644 index 0000000..4ace427 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/plugin_vm_ng.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M7 13v4H4V5c0-.5523.4477-1 1-1h8c1.6569 0 3 1.3431 3 3v3c0 1.6569-1.3431 3-3 3H7zm0-6v3h5c.5523 0 1-.4477 1-1V8c0-.5523-.4477-1-1-1H7z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/recent.svg b/ui/file_manager/file_manager/foreground/images/volumes/recent.svg new file mode 100644 index 0000000..c6885b7 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/recent.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M9.992 2C5.576 2 2 5.584 2 10s3.576 8 7.992 8C14.416 18 18 14.416 18 10s-3.584-8-8.008-8zM10 16c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm3.5-3.5l-1.4142 1.4142-3.0607-2.9896L9 6h1.9475v4L13.5 12.5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/sd.svg b/ui/file_manager/file_manager/foreground/images/volumes/sd.svg new file mode 100644 index 0000000..c8dd04e5 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/sd.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M15 2c1.1046 0 2 .8954 2 2v12c0 1.1046-.8954 2-2 2H5c-1.1046 0-2-.8954-2-2V7l5-5h7zm0 2H8.8284L5 7.8284V16h10V4zm-1 2v3h-1.5V6H14zm-2.5 0v3H10V6h1.5zM9 6v3H7.5V6H9z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/service_drive.svg b/ui/file_manager/file_manager/foreground/images/volumes/service_drive.svg new file mode 100644 index 0000000..284c0d8c --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/service_drive.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M18.7333 12L13.0167 2h-5.7v.0083L13.025 12h5.7083zm-10.4583.8333l-2.8583 5H16.35l2.8583-5H8.275zM6.5917 3.2667L1.125 12.8333l2.8583 4.9917L9.45 8.2667c0 .0083-2.8583-5-2.8583-5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/shared.svg b/ui/file_manager/file_manager/foreground/images/volumes/shared.svg new file mode 100644 index 0000000..86f6a16 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/shared.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24"> + <path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/shortcut.svg b/ui/file_manager/file_manager/foreground/images/volumes/shortcut.svg new file mode 100644 index 0000000..c31951ea --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/shortcut.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M7 10c-1.1046 0-2 .8954-2 2v4H3v-4c0-2.2091 1.7909-4 4-4h7.5628l-3.0077-2.7663L12.8205 4 18 9l-5.1795 5-1.2743-1.2338L14.5628 10H7z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/smb.svg b/ui/file_manager/file_manager/foreground/images/volumes/smb.svg new file mode 100644 index 0000000..fb5c8e17 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/smb.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M2 6v11h11v2H2c-1.1 0-2-.9-2-2V6h2zm9-5l2 2.0002h5c1.1 0 2 .9784 2 1.9998v8c0 1.0214-.9 2-2 2H6c-1.1 0-2-.9786-2-2l.01-10.1429C4.01 1.8357 4.9 1 6 1h5zm7 4H6v8h12V5zm-6 1.5c1.0539 0 1.9277.7844 2.1043 1.8164C14.887 8.4 15.5 9.0724 15.5 9.9c0 .8836-.6965 1.6-1.5556 1.6h-3.5c-1.0737 0-1.9444-.8952-1.9444-2 0-1.0196.7443-1.8516 1.703-1.9752C10.582 6.9116 11.2408 6.5 12 6.5z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/team_drive.svg b/ui/file_manager/file_manager/foreground/images/volumes/team_drive.svg new file mode 100644 index 0000000..c70670b --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/team_drive.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M15 2c1.1046 0 2 .8954 2 2v12c0 1.1046-.8954 2-2 2H5c-1.1046 0-2-.8954-2-2V4c0-1.1046.8954-2 2-2h10zm0 13H5v1h10v-1zm0-11H5v9h10V4zm-3.61 5.0015L11.5 9c.7935 0 2.35.407 2.4899 1.2152l.0101.1181V11h-2.0002L12 10.3333c0-.5277-.2343-.9747-.61-1.3318L11.5 9zM8.5 9c.8313 0 2.5.4467 2.5 1.3333V11H6v-.6667C6 9.4467 7.6688 9 8.5 9zm3-2.5c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm-3 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/usb.svg b/ui/file_manager/file_manager/foreground/images/volumes/usb.svg new file mode 100644 index 0000000..fd25ef3 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/usb.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M12.5423 9.5472h.7394v1.5094H11V5.0189h1.5423L10.25 2 8 5.0189h1.5v6.0377H7.3662V9.4943c.5176-.2792.8873-.815.8873-1.4566 0-.9132-.732-1.6603-1.6267-1.6603C5.732 6.3774 5 7.1245 5 8.0377c0 .6415.3697 1.1774.8873 1.4566v1.5623c0 .8377.542 1.4434 1.3627 1.4434H9.5V15c-.525.2792-.8028.6981-.8028 1.3396 0 .9208.732 1.6604 1.6267 1.6604.8948 0 1.6268-.7396 1.6268-1.6604 0-.6415-.4257-1.0604-.9507-1.3396v-2.5h2.2817c.8208 0 1.4789-.6057 1.4789-1.4434V9.5472H15.5V6.5283h-2.9577v3.0189z"/> +</svg>
diff --git a/ui/file_manager/file_manager/foreground/images/volumes/videos.svg b/ui/file_manager/file_manager/foreground/images/volumes/videos.svg new file mode 100644 index 0000000..47142da7 --- /dev/null +++ b/ui/file_manager/file_manager/foreground/images/volumes/videos.svg
@@ -0,0 +1,3 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"> + <path d="M16 4h-2l1 3h-2l-1-3h-2l1 3H9L8 4H6l1 3H5L4 4C3 4 2 5.007 2 6v9c0 1 .9 2 2 2h12c1.1.048 2-.875 2-2V6c0-.993-1-2-2-2zm0 11H4V9h12v6z"/> +</svg>
diff --git a/ui/gfx/ipc/gfx_param_traits.cc b/ui/gfx/ipc/gfx_param_traits.cc index 08e1a0a..0923402 100644 --- a/ui/gfx/ipc/gfx_param_traits.cc +++ b/ui/gfx/ipc/gfx_param_traits.cc
@@ -68,8 +68,8 @@ void ParamTraits<gfx::SelectionBound>::Write(base::Pickle* m, const param_type& p) { WriteParam(m, static_cast<uint32_t>(p.type())); - WriteParam(m, p.edge_top()); - WriteParam(m, p.edge_bottom()); + WriteParam(m, p.edge_start()); + WriteParam(m, p.edge_end()); WriteParam(m, p.visible()); } @@ -77,18 +77,18 @@ base::PickleIterator* iter, param_type* r) { gfx::SelectionBound::Type type; - gfx::PointF edge_top; - gfx::PointF edge_bottom; + gfx::PointF edge_start; + gfx::PointF edge_end; bool visible = false; - if (!ReadParam(m, iter, &type) || !ReadParam(m, iter, &edge_top) || - !ReadParam(m, iter, &edge_bottom) || !ReadParam(m, iter, &visible)) { + if (!ReadParam(m, iter, &type) || !ReadParam(m, iter, &edge_start) || + !ReadParam(m, iter, &edge_end) || !ReadParam(m, iter, &visible)) { return false; } r->set_type(type); - r->SetEdgeTop(edge_top); - r->SetEdgeBottom(edge_bottom); + r->SetEdgeStart(edge_start); + r->SetEdgeEnd(edge_end); r->set_visible(visible); return true; } @@ -98,9 +98,9 @@ l->append("gfx::SelectionBound("); LogParam(static_cast<uint32_t>(p.type()), l); l->append(", "); - LogParam(p.edge_top(), l); + LogParam(p.edge_start(), l); l->append(", "); - LogParam(p.edge_bottom(), l); + LogParam(p.edge_end(), l); l->append(", "); LogParam(p.visible(), l); l->append(")");
diff --git a/ui/gfx/mojom/mojom_traits_unittest.cc b/ui/gfx/mojom/mojom_traits_unittest.cc index 7ee98bbe..dfe551e 100644 --- a/ui/gfx/mojom/mojom_traits_unittest.cc +++ b/ui/gfx/mojom/mojom_traits_unittest.cc
@@ -75,21 +75,21 @@ TEST_F(StructTraitsTest, SelectionBound) { const gfx::SelectionBound::Type type = gfx::SelectionBound::CENTER; - const gfx::PointF edge_top(1234.5f, 5678.6f); - const gfx::PointF edge_bottom(910112.5f, 13141516.6f); + const gfx::PointF edge_start(1234.5f, 5678.6f); + const gfx::PointF edge_end(910112.5f, 13141516.6f); const bool visible = true; gfx::SelectionBound input; input.set_type(type); - input.SetEdge(edge_top, edge_bottom); + input.SetEdge(edge_start, edge_end); input.set_visible(visible); mojo::Remote<mojom::TraitsTestService> remote = GetTraitsTestRemote(); gfx::SelectionBound output; remote->EchoSelectionBound(input, &output); EXPECT_EQ(type, output.type()); - EXPECT_EQ(edge_top, output.edge_top()); - EXPECT_EQ(edge_bottom, output.edge_bottom()); - EXPECT_EQ(input.edge_top_rounded(), output.edge_top_rounded()); - EXPECT_EQ(input.edge_bottom_rounded(), output.edge_bottom_rounded()); + EXPECT_EQ(edge_start, output.edge_start()); + EXPECT_EQ(edge_end, output.edge_end()); + EXPECT_EQ(input.edge_start_rounded(), output.edge_start_rounded()); + EXPECT_EQ(input.edge_end_rounded(), output.edge_end_rounded()); EXPECT_EQ(visible, output.visible()); }
diff --git a/ui/gfx/mojom/selection_bound.mojom b/ui/gfx/mojom/selection_bound.mojom index 42ba11291..55b56c1 100644 --- a/ui/gfx/mojom/selection_bound.mojom +++ b/ui/gfx/mojom/selection_bound.mojom
@@ -17,10 +17,10 @@ // See ui/gfx/selection_bound.h. struct SelectionBound { SelectionBoundType type; - gfx.mojom.PointF edge_top; - gfx.mojom.PointF edge_bottom; - gfx.mojom.PointF visible_edge_top; - gfx.mojom.PointF visible_edge_bottom; + gfx.mojom.PointF edge_start; + gfx.mojom.PointF edge_end; + gfx.mojom.PointF visible_edge_start; + gfx.mojom.PointF visible_edge_end; bool visible; };
diff --git a/ui/gfx/mojom/selection_bound_mojom_traits.h b/ui/gfx/mojom/selection_bound_mojom_traits.h index a869875..e001ae5 100644 --- a/ui/gfx/mojom/selection_bound_mojom_traits.h +++ b/ui/gfx/mojom/selection_bound_mojom_traits.h
@@ -53,20 +53,20 @@ return GfxSelectionBoundTypeToMojo(input.type()); } - static gfx::PointF edge_top(const gfx::SelectionBound& input) { - return input.edge_top(); + static gfx::PointF edge_start(const gfx::SelectionBound& input) { + return input.edge_start(); } - static gfx::PointF edge_bottom(const gfx::SelectionBound& input) { - return input.edge_bottom(); + static gfx::PointF edge_end(const gfx::SelectionBound& input) { + return input.edge_end(); } - static gfx::PointF visible_edge_top(const gfx::SelectionBound& input) { - return input.visible_edge_top(); + static gfx::PointF visible_edge_start(const gfx::SelectionBound& input) { + return input.visible_edge_start(); } - static gfx::PointF visible_edge_bottom(const gfx::SelectionBound& input) { - return input.visible_edge_bottom(); + static gfx::PointF visible_edge_end(const gfx::SelectionBound& input) { + return input.visible_edge_end(); } static bool visible(const gfx::SelectionBound& input) { @@ -75,16 +75,16 @@ static bool Read(gfx::mojom::SelectionBoundDataView data, gfx::SelectionBound* out) { - gfx::PointF edge_top; - gfx::PointF edge_bottom; - gfx::PointF visible_edge_top; - gfx::PointF visible_edge_bottom; - if (!data.ReadEdgeTop(&edge_top) || !data.ReadEdgeBottom(&edge_bottom) || - !data.ReadVisibleEdgeTop(&visible_edge_top) || - !data.ReadVisibleEdgeBottom(&visible_edge_bottom)) + gfx::PointF edge_start; + gfx::PointF edge_end; + gfx::PointF visible_edge_start; + gfx::PointF visible_edge_end; + if (!data.ReadEdgeStart(&edge_start) || !data.ReadEdgeEnd(&edge_end) || + !data.ReadVisibleEdgeStart(&visible_edge_start) || + !data.ReadVisibleEdgeEnd(&visible_edge_end)) return false; - out->SetEdge(edge_top, edge_bottom); - out->SetVisibleEdge(visible_edge_top, visible_edge_bottom); + out->SetEdge(edge_start, edge_end); + out->SetVisibleEdge(visible_edge_start, visible_edge_end); out->set_type(MojoSelectionBoundTypeToGfx(data.type())); out->set_visible(data.visible()); return true;
diff --git a/ui/gfx/selection_bound.cc b/ui/gfx/selection_bound.cc index 78016b8..4e34107 100644 --- a/ui/gfx/selection_bound.cc +++ b/ui/gfx/selection_bound.cc
@@ -19,53 +19,52 @@ SelectionBound::~SelectionBound() {} -void SelectionBound::SetEdgeTop(const gfx::PointF& value) { - edge_top_ = value; - edge_top_rounded_ = gfx::ToRoundedPoint(value); +void SelectionBound::SetEdgeStart(const gfx::PointF& value) { + edge_start_ = value; + edge_start_rounded_ = gfx::ToRoundedPoint(value); } -void SelectionBound::SetVisibleEdgeTop(const gfx::PointF& value) { - visible_edge_top_ = value; +void SelectionBound::SetVisibleEdgeStart(const gfx::PointF& value) { + visible_edge_start_ = value; } -void SelectionBound::SetEdgeBottom(const gfx::PointF& value) { - edge_bottom_ = value; - edge_bottom_rounded_ = gfx::ToRoundedPoint(value); +void SelectionBound::SetEdgeEnd(const gfx::PointF& value) { + edge_end_ = value; + edge_end_rounded_ = gfx::ToRoundedPoint(value); } -void SelectionBound::SetVisibleEdgeBottom(const gfx::PointF& value) { - visible_edge_bottom_ = value; +void SelectionBound::SetVisibleEdgeEnd(const gfx::PointF& value) { + visible_edge_end_ = value; } -void SelectionBound::SetEdge(const gfx::PointF& top, - const gfx::PointF& bottom) { - SetEdgeTop(top); - SetEdgeBottom(bottom); +void SelectionBound::SetEdge(const gfx::PointF& start, const gfx::PointF& end) { + SetEdgeStart(start); + SetEdgeEnd(end); } -void SelectionBound::SetVisibleEdge(const gfx::PointF& top, - const gfx::PointF& bottom) { - SetVisibleEdgeTop(top); - SetVisibleEdgeBottom(bottom); +void SelectionBound::SetVisibleEdge(const gfx::PointF& start, + const gfx::PointF& end) { + SetVisibleEdgeStart(start); + SetVisibleEdgeEnd(end); } int SelectionBound::GetHeight() const { - return edge_bottom_rounded_.y() - edge_top_rounded_.y(); + return edge_end_rounded_.y() - edge_start_rounded_.y(); } std::string SelectionBound::ToString() const { return base::StringPrintf( - "SelectionBound(%s, %s, %s, %s, %d)", edge_top_.ToString().c_str(), - edge_bottom_.ToString().c_str(), edge_top_rounded_.ToString().c_str(), - edge_bottom_rounded_.ToString().c_str(), visible_); + "SelectionBound(%s, %s, %s, %s, %d)", edge_start_.ToString().c_str(), + edge_end_.ToString().c_str(), edge_start_rounded_.ToString().c_str(), + edge_end_rounded_.ToString().c_str(), visible_); } bool operator==(const SelectionBound& lhs, const SelectionBound& rhs) { return lhs.type() == rhs.type() && lhs.visible() == rhs.visible() && - lhs.edge_top() == rhs.edge_top() && - lhs.edge_bottom() == rhs.edge_bottom() && - lhs.visible_edge_top() == rhs.visible_edge_top() && - lhs.visible_edge_bottom() == rhs.visible_edge_bottom(); + lhs.edge_start() == rhs.edge_start() && + lhs.edge_end() == rhs.edge_end() && + lhs.visible_edge_start() == rhs.visible_edge_start() && + lhs.visible_edge_end() == rhs.visible_edge_end(); } bool operator!=(const SelectionBound& lhs, const SelectionBound& rhs) { @@ -74,15 +73,15 @@ gfx::Rect RectBetweenSelectionBounds(const SelectionBound& b1, const SelectionBound& b2) { - gfx::Point top_left(b1.edge_top_rounded()); - top_left.SetToMin(b1.edge_bottom_rounded()); - top_left.SetToMin(b2.edge_top_rounded()); - top_left.SetToMin(b2.edge_bottom_rounded()); + gfx::Point top_left(b1.edge_start_rounded()); + top_left.SetToMin(b1.edge_end_rounded()); + top_left.SetToMin(b2.edge_start_rounded()); + top_left.SetToMin(b2.edge_end_rounded()); - gfx::Point bottom_right(b1.edge_top_rounded()); - bottom_right.SetToMax(b1.edge_bottom_rounded()); - bottom_right.SetToMax(b2.edge_top_rounded()); - bottom_right.SetToMax(b2.edge_bottom_rounded()); + gfx::Point bottom_right(b1.edge_start_rounded()); + bottom_right.SetToMax(b1.edge_end_rounded()); + bottom_right.SetToMax(b2.edge_start_rounded()); + bottom_right.SetToMax(b2.edge_end_rounded()); gfx::Vector2d diff = bottom_right - top_left; return gfx::Rect(top_left, gfx::Size(diff.x(), diff.y())); @@ -90,15 +89,15 @@ gfx::RectF RectFBetweenSelectionBounds(const SelectionBound& b1, const SelectionBound& b2) { - gfx::PointF top_left(b1.edge_top()); - top_left.SetToMin(b1.edge_bottom()); - top_left.SetToMin(b2.edge_top()); - top_left.SetToMin(b2.edge_bottom()); + gfx::PointF top_left(b1.edge_start()); + top_left.SetToMin(b1.edge_end()); + top_left.SetToMin(b2.edge_start()); + top_left.SetToMin(b2.edge_end()); - gfx::PointF bottom_right(b1.edge_top()); - bottom_right.SetToMax(b1.edge_bottom()); - bottom_right.SetToMax(b2.edge_top()); - bottom_right.SetToMax(b2.edge_bottom()); + gfx::PointF bottom_right(b1.edge_start()); + bottom_right.SetToMax(b1.edge_end()); + bottom_right.SetToMax(b2.edge_start()); + bottom_right.SetToMax(b2.edge_end()); gfx::Vector2dF diff = bottom_right - top_left; return gfx::RectF(top_left, gfx::SizeF(diff.x(), diff.y())); @@ -106,18 +105,18 @@ gfx::RectF RectFBetweenVisibleSelectionBounds(const SelectionBound& b1, const SelectionBound& b2) { - // The selection bound is determined by the |top| and |bottom| points. For the - // writing-mode is vertical-*, the bounds are horizontal, the |bottom| might - // be on the left side of the |top|. - gfx::PointF top_left(b1.visible_edge_top()); - top_left.SetToMin(b1.visible_edge_bottom()); - top_left.SetToMin(b2.visible_edge_top()); - top_left.SetToMin(b2.visible_edge_bottom()); + // The selection bound is determined by the |start| and |end| points. For the + // writing-mode is vertical-*, the bounds are horizontal, the |end| might + // be on the left side of the |start|. + gfx::PointF top_left(b1.visible_edge_start()); + top_left.SetToMin(b1.visible_edge_end()); + top_left.SetToMin(b2.visible_edge_start()); + top_left.SetToMin(b2.visible_edge_end()); - gfx::PointF bottom_right(b1.visible_edge_top()); - bottom_right.SetToMax(b1.visible_edge_bottom()); - bottom_right.SetToMax(b2.visible_edge_top()); - bottom_right.SetToMax(b2.visible_edge_bottom()); + gfx::PointF bottom_right(b1.visible_edge_start()); + bottom_right.SetToMax(b1.visible_edge_end()); + bottom_right.SetToMax(b2.visible_edge_start()); + bottom_right.SetToMax(b2.visible_edge_end()); gfx::Vector2dF diff = bottom_right - top_left; return gfx::RectF(top_left, gfx::SizeF(diff.x(), diff.y()));
diff --git a/ui/gfx/selection_bound.h b/ui/gfx/selection_bound.h index 3f8ceaf..150b3a0f 100644 --- a/ui/gfx/selection_bound.h +++ b/ui/gfx/selection_bound.h
@@ -26,27 +26,25 @@ Type type() const { return type_; } void set_type(Type value) { type_ = value; } - const gfx::PointF& edge_top() const { return edge_top_; } - const gfx::PointF& visible_edge_top() const { return visible_edge_top_; } - const gfx::Point& edge_top_rounded() const { return edge_top_rounded_; } - void SetEdgeTop(const gfx::PointF& value); - void SetVisibleEdgeTop(const gfx::PointF& value); + const gfx::PointF& edge_start() const { return edge_start_; } + const gfx::PointF& visible_edge_start() const { return visible_edge_start_; } + const gfx::Point& edge_start_rounded() const { return edge_start_rounded_; } + void SetEdgeStart(const gfx::PointF& value); + void SetVisibleEdgeStart(const gfx::PointF& value); - const gfx::PointF& edge_bottom() const { return edge_bottom_; } - const gfx::PointF& visible_edge_bottom() const { - return visible_edge_bottom_; - } - const gfx::Point& edge_bottom_rounded() const { return edge_bottom_rounded_; } - void SetEdgeBottom(const gfx::PointF& value); - void SetVisibleEdgeBottom(const gfx::PointF& value); + const gfx::PointF& edge_end() const { return edge_end_; } + const gfx::PointF& visible_edge_end() const { return visible_edge_end_; } + const gfx::Point& edge_end_rounded() const { return edge_end_rounded_; } + void SetEdgeEnd(const gfx::PointF& value); + void SetVisibleEdgeEnd(const gfx::PointF& value); - void SetEdge(const gfx::PointF& top, const gfx::PointF& bottom); - void SetVisibleEdge(const gfx::PointF& top, const gfx::PointF& bottom); + void SetEdge(const gfx::PointF& start, const gfx::PointF& end); + void SetVisibleEdge(const gfx::PointF& start, const gfx::PointF& end); bool visible() const { return visible_; } void set_visible(bool value) { visible_ = value; } - // Returns the vertical difference between rounded top and bottom. + // Returns the vertical difference between rounded start and end. int GetHeight() const; std::string ToString() const; @@ -55,14 +53,14 @@ Type type_; // The actual bounds of a selection end-point mgiht be invisible for // occlusion. - gfx::PointF edge_top_; - gfx::PointF edge_bottom_; + gfx::PointF edge_start_; + gfx::PointF edge_end_; // The visible bounds of a selection, which are equal to the above, when there // is no occlusion. - gfx::PointF visible_edge_top_; - gfx::PointF visible_edge_bottom_; - gfx::Point edge_top_rounded_; - gfx::Point edge_bottom_rounded_; + gfx::PointF visible_edge_start_; + gfx::PointF visible_edge_end_; + gfx::Point edge_start_rounded_; + gfx::Point edge_end_rounded_; bool visible_; };
diff --git a/ui/gfx/selection_bound_unittest.cc b/ui/gfx/selection_bound_unittest.cc index 31b558b..224ebe3 100644 --- a/ui/gfx/selection_bound_unittest.cc +++ b/ui/gfx/selection_bound_unittest.cc
@@ -16,9 +16,9 @@ b1.SetEdge(gfx::PointF(0.f, 20.f), gfx::PointF(0.f, 25.f)); b2.SetEdge(gfx::PointF(110.f, 20.f), gfx::PointF(110.f, 25.f)); gfx::Rect expected_rect( - b1.edge_top_rounded().x(), b1.edge_top_rounded().y(), - b2.edge_top_rounded().x() - b1.edge_top_rounded().x(), - b2.edge_bottom_rounded().y() - b2.edge_top_rounded().y()); + b1.edge_start_rounded().x(), b1.edge_start_rounded().y(), + b2.edge_start_rounded().x() - b1.edge_start_rounded().x(), + b2.edge_end_rounded().y() - b2.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); @@ -26,9 +26,9 @@ b1.SetVisibleEdge(gfx::PointF(10.f, 20.f), gfx::PointF(10.f, 25.f)); b2.SetVisibleEdge(gfx::PointF(100.f, 20.f), gfx::PointF(100.f, 25.f)); gfx::RectF expected_visible_rect( - b1.visible_edge_top().x(), b1.visible_edge_top().y(), - b2.visible_edge_top().x() - b1.visible_edge_top().x(), - b2.visible_edge_bottom().y() - b2.visible_edge_top().y()); + b1.visible_edge_start().x(), b1.visible_edge_start().y(), + b2.visible_edge_start().x() - b1.visible_edge_start().x(), + b2.visible_edge_end().y() - b2.visible_edge_start().y()); EXPECT_EQ(expected_visible_rect, RectFBetweenVisibleSelectionBounds(b1, b2)); EXPECT_EQ(expected_visible_rect, RectFBetweenVisibleSelectionBounds(b2, b1)); @@ -36,9 +36,9 @@ b1.SetVisibleEdge(gfx::PointF(0.f, 20.f), gfx::PointF(0.f, 25.f)); b2.SetVisibleEdge(gfx::PointF(100.f, 20.f), gfx::PointF(100.f, 25.f)); expected_visible_rect = - gfx::RectF(b1.visible_edge_top().x(), b1.visible_edge_top().y(), - b2.visible_edge_top().x() - b1.visible_edge_top().x(), - b2.visible_edge_bottom().y() - b2.visible_edge_top().y()); + gfx::RectF(b1.visible_edge_start().x(), b1.visible_edge_start().y(), + b2.visible_edge_start().x() - b1.visible_edge_start().x(), + b2.visible_edge_end().y() - b2.visible_edge_start().y()); EXPECT_EQ(expected_visible_rect, RectFBetweenVisibleSelectionBounds(b1, b2)); EXPECT_EQ(expected_visible_rect, RectFBetweenVisibleSelectionBounds(b2, b1)); @@ -46,27 +46,27 @@ b1.SetEdge(gfx::PointF(10.f, 20.f), gfx::PointF(10.f, 25.f)); b2.SetEdge(gfx::PointF(110.f, 0.f), gfx::PointF(110.f, 35.f)); expected_rect = - gfx::Rect(b1.edge_top_rounded().x(), b2.edge_top_rounded().y(), - b2.edge_top_rounded().x() - b1.edge_top_rounded().x(), - b2.edge_bottom_rounded().y() - b2.edge_top_rounded().y()); + gfx::Rect(b1.edge_start_rounded().x(), b2.edge_start_rounded().y(), + b2.edge_start_rounded().x() - b1.edge_start_rounded().x(), + b2.edge_end_rounded().y() - b2.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); b1.SetEdge(gfx::PointF(10.f, 20.f), gfx::PointF(10.f, 30.f)); b2.SetEdge(gfx::PointF(110.f, 25.f), gfx::PointF(110.f, 45.f)); expected_rect = - gfx::Rect(b1.edge_top_rounded().x(), b1.edge_top_rounded().y(), - b2.edge_top_rounded().x() - b1.edge_top_rounded().x(), - b2.edge_bottom_rounded().y() - b1.edge_top_rounded().y()); + gfx::Rect(b1.edge_start_rounded().x(), b1.edge_start_rounded().y(), + b2.edge_start_rounded().x() - b1.edge_start_rounded().x(), + b2.edge_end_rounded().y() - b1.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); b1.SetEdge(gfx::PointF(10.f, 20.f), gfx::PointF(10.f, 30.f)); b2.SetEdge(gfx::PointF(110.f, 40.f), gfx::PointF(110.f, 60.f)); expected_rect = - gfx::Rect(b1.edge_top_rounded().x(), b1.edge_top_rounded().y(), - b2.edge_top_rounded().x() - b1.edge_top_rounded().x(), - b2.edge_bottom_rounded().y() - b1.edge_top_rounded().y()); + gfx::Rect(b1.edge_start_rounded().x(), b1.edge_start_rounded().y(), + b2.edge_start_rounded().x() - b1.edge_start_rounded().x(), + b2.edge_end_rounded().y() - b1.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); @@ -74,8 +74,8 @@ b1.SetEdge(gfx::PointF(10.f, 20.f), gfx::PointF(10.f, 30.f)); b2.SetEdge(gfx::PointF(10.f, 25.f), gfx::PointF(10.f, 40.f)); expected_rect = - gfx::Rect(b1.edge_top_rounded().x(), b1.edge_top_rounded().y(), 0, - b2.edge_bottom_rounded().y() - b1.edge_top_rounded().y()); + gfx::Rect(b1.edge_start_rounded().x(), b1.edge_start_rounded().y(), 0, + b2.edge_end_rounded().y() - b1.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); @@ -83,9 +83,9 @@ b1.SetEdge(gfx::PointF(10.f, 20.f), gfx::PointF(20.f, 30.f)); b2.SetEdge(gfx::PointF(110.f, 40.f), gfx::PointF(120.f, 60.f)); expected_rect = - gfx::Rect(b1.edge_top_rounded().x(), b1.edge_top_rounded().y(), - b2.edge_bottom_rounded().x() - b1.edge_top_rounded().x(), - b2.edge_bottom_rounded().y() - b1.edge_top_rounded().y()); + gfx::Rect(b1.edge_start_rounded().x(), b1.edge_start_rounded().y(), + b2.edge_end_rounded().x() - b1.edge_start_rounded().x(), + b2.edge_end_rounded().y() - b1.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); @@ -93,9 +93,9 @@ b1.SetEdge(gfx::PointF(20.f, 30.f), gfx::PointF(0.f, 40.f)); b2.SetEdge(gfx::PointF(110.f, 30.f), gfx::PointF(120.f, 40.f)); expected_rect = - gfx::Rect(b1.edge_bottom_rounded().x(), b1.edge_top_rounded().y(), - b2.edge_bottom_rounded().x() - b1.edge_bottom_rounded().x(), - b2.edge_bottom_rounded().y() - b2.edge_top_rounded().y()); + gfx::Rect(b1.edge_end_rounded().x(), b1.edge_start_rounded().y(), + b2.edge_end_rounded().x() - b1.edge_end_rounded().x(), + b2.edge_end_rounded().y() - b2.edge_start_rounded().y()); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b1, b2)); EXPECT_EQ(expected_rect, RectBetweenSelectionBounds(b2, b1)); }
diff --git a/ui/touch_selection/touch_selection_controller.cc b/ui/touch_selection/touch_selection_controller.cc index b34c00ff..6a5f0e0 100644 --- a/ui/touch_selection/touch_selection_controller.cc +++ b/ui/touch_selection/touch_selection_controller.cc
@@ -14,7 +14,7 @@ gfx::Vector2dF ComputeLineOffsetFromBottom(const gfx::SelectionBound& bound) { gfx::Vector2dF line_offset = - gfx::ScaleVector2d(bound.edge_top() - bound.edge_bottom(), 0.5f); + gfx::ScaleVector2d(bound.edge_start() - bound.edge_end(), 0.5f); // An offset of 8 DIPs is sufficient for most line sizes. For small lines, // using half the line height avoids synthesizing a point on a line above // (or below) the intended line. @@ -90,9 +90,9 @@ if (active_status_ == SELECTION_ACTIVE) { // Bounds have the same orientation. bool need_swap = (start_selection_handle_->IsActive() && - end_.edge_bottom() == start.edge_bottom()) || + end_.edge_end() == start.edge_end()) || (end_selection_handle_->IsActive() && - end.edge_bottom() == start_.edge_bottom()); + end.edge_end() == start_.edge_end()); // Bounds have different orientation. // Specifically, for writing-mode: vertical-*, selection bounds are @@ -104,12 +104,12 @@ // - start bound is from left to right, // - end bound is from right to left. // So when previous start/end bound become current end/start bound, - // edge_top() and edge_bottom() are swapped. Therefore, we are comparing - // edge_bottom() with edge_top() here. + // edge_start() and edge_end() are swapped. Therefore, we are comparing + // edge_end() with edge_start() here. need_swap |= (start_selection_handle_->IsActive() && - end_.edge_bottom() == start.edge_top()) || + end_.edge_end() == start.edge_start()) || (end_selection_handle_->IsActive() && - end.edge_bottom() == start_.edge_top()); + end.edge_end() == start_.edge_start()); if (need_swap) start_selection_handle_.swap(end_selection_handle_); @@ -255,12 +255,12 @@ if (start_.visible() && !end_.visible()) { // This BoundingRect is actually a line unless the selection is rotated. - return gfx::BoundingRect(start_.edge_top(), start_.edge_bottom()); + return gfx::BoundingRect(start_.edge_start(), start_.edge_end()); } if (end_.visible() && !start_.visible()) { // This BoundingRect is actually a line unless the selection is rotated. - return gfx::BoundingRect(end_.edge_top(), end_.edge_bottom()); + return gfx::BoundingRect(end_.edge_start(), end_.edge_end()); } // If both handles are visible, or both are invisible, use the entire rect. @@ -321,15 +321,15 @@ if (!bound) return 0.f; - return (bound->edge_top().y() + bound->edge_bottom().y()) / 2.f; + return (bound->edge_start().y() + bound->edge_end().y()) / 2.f; } const gfx::PointF& TouchSelectionController::GetStartPosition() const { - return start_.edge_bottom(); + return start_.edge_end(); } const gfx::PointF& TouchSelectionController::GetEndPosition() const { - return end_.edge_bottom(); + return end_.edge_end(); } bool TouchSelectionController::WillHandleTouchEventImpl( @@ -492,7 +492,7 @@ const bool activated = ActivateInsertionIfNecessary(); const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated); - insertion_handle_->SetFocus(start_.edge_top(), start_.edge_bottom()); + insertion_handle_->SetFocus(start_.edge_start(), start_.edge_end()); insertion_handle_->SetVisible(GetStartVisible(), animation); UpdateHandleLayoutIfNecessary(); @@ -508,8 +508,8 @@ const TouchHandle::AnimationStyle animation = GetAnimationStyle(!activated); - start_selection_handle_->SetFocus(start_.edge_top(), start_.edge_bottom()); - end_selection_handle_->SetFocus(end_.edge_top(), end_.edge_bottom()); + start_selection_handle_->SetFocus(start_.edge_start(), start_.edge_end()); + end_selection_handle_->SetFocus(end_.edge_start(), end_.edge_end()); start_selection_handle_->SetOrientation(start_orientation_); end_selection_handle_->SetOrientation(end_orientation_);
diff --git a/ui/views/touchui/touch_selection_controller_impl.cc b/ui/views/touchui/touch_selection_controller_impl.cc index 64f79a4..e32c095 100644 --- a/ui/views/touchui/touch_selection_controller_impl.cc +++ b/ui/views/touchui/touch_selection_controller_impl.cc
@@ -140,21 +140,22 @@ int widget_left = 0; switch (bound.type()) { case gfx::SelectionBound::LEFT: - widget_left = bound.edge_top_rounded().x() - image_size.width() - + widget_left = bound.edge_start_rounded().x() - image_size.width() - kSelectionHandleHorizPadding; break; case gfx::SelectionBound::RIGHT: - widget_left = bound.edge_top_rounded().x() - kSelectionHandleHorizPadding; + widget_left = + bound.edge_start_rounded().x() - kSelectionHandleHorizPadding; break; case gfx::SelectionBound::CENTER: - widget_left = bound.edge_top_rounded().x() - widget_width / 2; + widget_left = bound.edge_start_rounded().x() - widget_width / 2; break; default: NOTREACHED() << "Undefined bound type."; break; } - return gfx::Rect( - widget_left, bound.edge_top_rounded().y(), widget_width, widget_height); + return gfx::Rect(widget_left, bound.edge_start_rounded().y(), widget_width, + widget_height); } gfx::Size GetMaxHandleImageSize() { @@ -175,28 +176,28 @@ gfx::SelectionBound ConvertFromScreen(ui::TouchEditable* client, const gfx::SelectionBound& bound) { gfx::SelectionBound result = bound; - gfx::Point edge_bottom = bound.edge_bottom_rounded(); - gfx::Point edge_top = bound.edge_top_rounded(); - client->ConvertPointFromScreen(&edge_bottom); - client->ConvertPointFromScreen(&edge_top); - result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); + gfx::Point edge_end = bound.edge_end_rounded(); + gfx::Point edge_start = bound.edge_start_rounded(); + client->ConvertPointFromScreen(&edge_end); + client->ConvertPointFromScreen(&edge_start); + result.SetEdge(gfx::PointF(edge_start), gfx::PointF(edge_end)); return result; } gfx::SelectionBound ConvertToScreen(ui::TouchEditable* client, const gfx::SelectionBound& bound) { gfx::SelectionBound result = bound; - gfx::Point edge_bottom = bound.edge_bottom_rounded(); - gfx::Point edge_top = bound.edge_top_rounded(); - client->ConvertPointToScreen(&edge_bottom); - client->ConvertPointToScreen(&edge_top); - result.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); + gfx::Point edge_end = bound.edge_end_rounded(); + gfx::Point edge_start = bound.edge_start_rounded(); + client->ConvertPointToScreen(&edge_end); + client->ConvertPointToScreen(&edge_start); + result.SetEdge(gfx::PointF(edge_start), gfx::PointF(edge_end)); return result; } gfx::Rect BoundToRect(const gfx::SelectionBound& bound) { - return gfx::BoundingRect(bound.edge_top_rounded(), - bound.edge_bottom_rounded()); + return gfx::BoundingRect(bound.edge_start_rounded(), + bound.edge_end_rounded()); } } // namespace @@ -258,7 +259,7 @@ // Distance from the point which is |kSelectionHandleVerticalDragOffset| // pixels above the bottom of the selection bound edge to the event // location (aka the touch-drag point). - drag_offset_ = selection_bound_.edge_bottom_rounded() - + drag_offset_ = selection_bound_.edge_end_rounded() - gfx::Vector2d(0, kSelectionHandleVerticalDragOffset) - event->location(); break; @@ -334,16 +335,16 @@ } if (is_visible) { - selection_bound_.SetEdge(bound.edge_top(), bound.edge_bottom()); + selection_bound_.SetEdge(bound.edge_start(), bound.edge_end()); widget_->SetBounds(GetSelectionWidgetBounds(selection_bound_)); aura::Window* window = widget_->GetNativeView(); - gfx::Point edge_top = selection_bound_.edge_top_rounded(); - gfx::Point edge_bottom = selection_bound_.edge_bottom_rounded(); - wm::ConvertPointFromScreen(window, &edge_top); - wm::ConvertPointFromScreen(window, &edge_bottom); - selection_bound_.SetEdge(gfx::PointF(edge_top), gfx::PointF(edge_bottom)); + gfx::Point edge_start = selection_bound_.edge_start_rounded(); + gfx::Point edge_end = selection_bound_.edge_end_rounded(); + wm::ConvertPointFromScreen(window, &edge_start); + wm::ConvertPointFromScreen(window, &edge_end); + selection_bound_.SetEdge(gfx::PointF(edge_start), gfx::PointF(edge_end)); } const gfx::Insets insets( @@ -432,15 +433,15 @@ ConvertToScreen(client_view_, anchor); gfx::SelectionBound screen_bound_focus = ConvertToScreen(client_view_, focus); gfx::Rect client_bounds = client_view_->GetBounds(); - if (anchor.edge_top().y() < client_bounds.y()) { - auto anchor_edge_top = gfx::PointF(anchor.edge_top_rounded()); - anchor_edge_top.set_y(client_bounds.y()); - anchor.SetEdgeTop(anchor_edge_top); + if (anchor.edge_start().y() < client_bounds.y()) { + auto anchor_edge_start = gfx::PointF(anchor.edge_start_rounded()); + anchor_edge_start.set_y(client_bounds.y()); + anchor.SetEdgeStart(anchor_edge_start); } - if (focus.edge_top().y() < client_bounds.y()) { - auto focus_edge_top = gfx::PointF(focus.edge_top_rounded()); - focus_edge_top.set_y(client_bounds.y()); - focus.SetEdgeTop(focus_edge_top); + if (focus.edge_start().y() < client_bounds.y()) { + auto focus_edge_start = gfx::PointF(focus.edge_start_rounded()); + focus_edge_start.set_y(client_bounds.y()); + focus.SetEdgeStart(focus_edge_start); } gfx::SelectionBound screen_bound_anchor_clipped = ConvertToScreen(client_view_, anchor); @@ -495,8 +496,8 @@ UpdateQuickMenu(); // Check if there is any selection at all. - if (screen_bound_anchor.edge_top() == screen_bound_focus.edge_top() && - screen_bound_anchor.edge_bottom() == screen_bound_focus.edge_bottom()) { + if (screen_bound_anchor.edge_start() == screen_bound_focus.edge_start() && + screen_bound_anchor.edge_end() == screen_bound_focus.edge_end()) { selection_handle_1_->SetWidgetVisible(false, false); selection_handle_2_->SetWidgetVisible(false, false); SetHandleBound(cursor_handle_.get(), anchor, screen_bound_anchor_clipped); @@ -547,7 +548,7 @@ : selection_bound_1_; // Find selection end points in client_view's coordinate system. - gfx::Point p2 = anchor_bound.edge_top_rounded(); + gfx::Point p2 = anchor_bound.edge_start_rounded(); p2.Offset(0, anchor_bound.GetHeight() / 2); client_view_->ConvertPointFromScreen(&p2);
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc index 98e16e4..d18ca00 100644 --- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc +++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc
@@ -48,8 +48,8 @@ // the same location. int CompareTextSelectionBounds(const gfx::SelectionBound& b1, const gfx::SelectionBound& b2) { - if (b1.edge_top().y() < b2.edge_top().y() || - b1.edge_top().x() < b2.edge_top().x()) { + if (b1.edge_start().y() < b2.edge_start().y() || + b1.edge_start().x() < b2.edge_start().x()) { return -1; } if (b1 == b2)
diff --git a/weblayer/BUILD.gn b/weblayer/BUILD.gn index f41abce..2e95ea3 100644 --- a/weblayer/BUILD.gn +++ b/weblayer/BUILD.gn
@@ -118,7 +118,6 @@ "//cc", "//components/crash/content/app", "//components/crash/content/browser", - "//components/resources", "//components/security_interstitials/content:security_interstitial_page", "//components/security_interstitials/content/renderer:security_interstitial_page_controller", "//components/security_interstitials/core",
diff --git a/weblayer/browser/navigation_browsertest.cc b/weblayer/browser/navigation_browsertest.cc index a58ab77c..f3139ce6 100644 --- a/weblayer/browser/navigation_browsertest.cc +++ b/weblayer/browser/navigation_browsertest.cc
@@ -35,6 +35,7 @@ bool is_error_page() { return is_error_page_; } Navigation::LoadError load_error() { return load_error_; } int http_status_code() { return http_status_code_; } + NavigationState navigation_state() { return navigation_state_; } private: // NavigationObserver implementation: @@ -49,6 +50,7 @@ is_error_page_ = navigation->IsErrorPage(); load_error_ = navigation->GetLoadError(); http_status_code_ = navigation->GetHttpStatusCode(); + navigation_state_ = navigation->GetState(); run_loop_.Quit(); } @@ -58,6 +60,7 @@ bool is_error_page_ = false; Navigation::LoadError load_error_ = Navigation::kNoError; int http_status_code_ = 0; + NavigationState navigation_state_ = NavigationState::kWaitingResponse; }; } // namespace @@ -76,6 +79,7 @@ EXPECT_FALSE(observer.is_error_page()); EXPECT_EQ(observer.load_error(), Navigation::kNoError); EXPECT_EQ(observer.http_status_code(), 200); + EXPECT_EQ(observer.navigation_state(), NavigationState::kComplete); } IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, HttpClientError) { @@ -90,6 +94,7 @@ EXPECT_FALSE(observer.is_error_page()); EXPECT_EQ(observer.load_error(), Navigation::kHttpClientError); EXPECT_EQ(observer.http_status_code(), 404); + EXPECT_EQ(observer.navigation_state(), NavigationState::kComplete); } IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, HttpServerError) { @@ -104,6 +109,7 @@ EXPECT_FALSE(observer.is_error_page()); EXPECT_EQ(observer.load_error(), Navigation::kHttpServerError); EXPECT_EQ(observer.http_status_code(), 500); + EXPECT_EQ(observer.navigation_state(), NavigationState::kComplete); } IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, SSLError) { @@ -124,6 +130,7 @@ EXPECT_FALSE(observer.completed()); EXPECT_TRUE(observer.is_error_page()); EXPECT_EQ(observer.load_error(), Navigation::kSSLError); + EXPECT_EQ(observer.navigation_state(), NavigationState::kFailed); } IN_PROC_BROWSER_TEST_F(NavigationBrowserTest, HttpConnectivityError) { @@ -138,6 +145,7 @@ EXPECT_FALSE(observer.completed()); EXPECT_TRUE(observer.is_error_page()); EXPECT_EQ(observer.load_error(), Navigation::kConnectivityError); + EXPECT_EQ(observer.navigation_state(), NavigationState::kFailed); } } // namespace weblayer
diff --git a/weblayer/browser/navigation_impl.cc b/weblayer/browser/navigation_impl.cc index e4c0be0..345cdc8 100644 --- a/weblayer/browser/navigation_impl.cc +++ b/weblayer/browser/navigation_impl.cc
@@ -66,7 +66,12 @@ } NavigationState NavigationImpl::GetState() { - NOTIMPLEMENTED() << "TODO: properly implement this"; + if (navigation_handle_->IsErrorPage()) + return NavigationState::kFailed; + if (navigation_handle_->HasCommitted()) + return NavigationState::kComplete; + if (navigation_handle_->GetResponseHeaders()) + return NavigationState::kReceivingBytes; return NavigationState::kWaitingResponse; }
diff --git a/weblayer/public/README.md b/weblayer/public/README.md new file mode 100644 index 0000000..0125b1e --- /dev/null +++ b/weblayer/public/README.md
@@ -0,0 +1,56 @@ +# WebLayer public API + +This directory contains the public API for WebLayer. WebLayer provides both a +C++ and Java API. + +## Java API + +In general, the Java API is a thin veneer over the C++ API. For the most part, +functionality should be added to the C++ side with the Java implementation +calling into it. Where the two APIs diverge is for platform specific +functionality. For example, the Java API uses Android Fragments, which do not +apply to the C++ side. + +The public API should follow the Android API guidelines +(https://goto.google.com/android-api-guidelines). This results in naming +differences between the C++ and Java code. For example, NewTabDelegate in C++ +vs NewTabCallback in Java. + +In the long term WebLayer will support some amount of version skew. In the +short term, we have a simple version check. See +"//weblayer/browser/java/org/chromium/weblayer_private/interfaces/WebLayerVersion.java" +for more information. + +One of the design constraints of WebLayer's Java implementation is that we do +not want embedders to ship their own copy of "//content". Instead, the +implementation is loaded from the WebView APK (not the Chrome APK, because the +WebView APK is available on more devices). This constraint results in the Java +implementation consisting of three distinct parts. + +### Java client library + +Code lives in "//weblayer/public/java". This is the code used by embedders. The +client library contains very little logic, rather it delegates to the Java +implementation over AIDL. + +This code should not have any dependencies on any other code in the chrome repo. + +### Java AIDL + +This is best thought of as WebLayer's ABI (for Java). + +The client library loads the WebLayer implementation from WebView APK and uses +AIDL for the IPC. The aidl interfaces are defined in +"//weblayer/browser/java/org/chromium/weblayer_private/interfaces". AIDL is used +to enable the implementation to be loaded using a different ClassLoader than +the embedder. + +In general, any interface ending with 'Client' means the interface is from the +implementation side to the client library. An interface without 'Client' is +from the client to the implementation. + +### Java implementation + +This is often referred to as the 'implementation' of the Java API. This is +where the bulk of the Java code lives and sits on top of the C++ API. The code +for this lives in "//weblayer/browser/java".
diff --git a/weblayer/public/java/org/chromium/weblayer/LoadError.java b/weblayer/public/java/org/chromium/weblayer/LoadError.java index 2f8d189..77b45e4 100644 --- a/weblayer/public/java/org/chromium/weblayer/LoadError.java +++ b/weblayer/public/java/org/chromium/weblayer/LoadError.java
@@ -9,6 +9,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +/** + * @hide + */ @IntDef({LoadError.NO_ERROR, LoadError.HTTP_CLIENT_ERROR, LoadError.HTTP_SERVER_ERROR, LoadError.SSL_ERROR, LoadError.CONNECTIVITY_ERROR, LoadError.OTHER_ERROR}) @Retention(RetentionPolicy.SOURCE)
diff --git a/weblayer/public/java/org/chromium/weblayer/NavigationState.java b/weblayer/public/java/org/chromium/weblayer/NavigationState.java index 1d0264a..05a6fa2 100644 --- a/weblayer/public/java/org/chromium/weblayer/NavigationState.java +++ b/weblayer/public/java/org/chromium/weblayer/NavigationState.java
@@ -18,9 +18,7 @@ public @interface NavigationState { int WAITING_RESPONSE = org.chromium.weblayer_private.interfaces.NavigationState.WAITING_RESPONSE; - int RECEIVING_BYTES = org.chromium.weblayer_private.interfaces.NavigationState.RECEIVING_BYTES; int COMPLETE = org.chromium.weblayer_private.interfaces.NavigationState.COMPLETE; - int FAILED = org.chromium.weblayer_private.interfaces.NavigationState.FAILED; }
diff --git a/weblayer/public/navigation.h b/weblayer/public/navigation.h index b5b3f5d..d5d8d01f 100644 --- a/weblayer/public/navigation.h +++ b/weblayer/public/navigation.h
@@ -16,9 +16,15 @@ // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.weblayer_private // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ImplNavigationState enum class NavigationState { + // Waiting to receive initial response data. kWaitingResponse = 0, + // Processing the response. kReceivingBytes = 1, + // The navigation succeeded. Any NavigationObservers would have had + // NavigationCompleted() called. kComplete = 2, + // The navigation failed. IsErrorPage() will return true, and any + // NavigationObservers would have had NavigationFailed() called. kFailed = 3, };
diff --git a/weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NavigationTest.java b/weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NavigationTest.java index 23bc024..d3be59c 100644 --- a/weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NavigationTest.java +++ b/weblayer/shell/android/javatests/src/org/chromium/weblayer/test/NavigationTest.java
@@ -26,6 +26,7 @@ import org.chromium.weblayer.Navigation; import org.chromium.weblayer.NavigationCallback; import org.chromium.weblayer.NavigationController; +import org.chromium.weblayer.NavigationState; import org.chromium.weblayer.shell.InstrumentationActivity; import java.util.ArrayList; @@ -55,6 +56,7 @@ private int mHttpStatusCode; private List<Uri> mRedirectChain; private @LoadError int mLoadError; + private @NavigationState int mNavigationState; public void notifyCalled(Navigation navigation) { mUri = navigation.getUri(); @@ -62,6 +64,7 @@ mHttpStatusCode = navigation.getHttpStatusCode(); mRedirectChain = navigation.getRedirectChain(); mLoadError = navigation.getLoadError(); + mNavigationState = navigation.getState(); notifyCalled(); } @@ -93,6 +96,11 @@ public int getHttpStatusCode() { return mHttpStatusCode; } + + @NavigationState + public int getNavigationState() { + return mNavigationState; + } } public static class NavigationCallbackValueRecorder { @@ -373,6 +381,7 @@ mCallback.onCompletedCallback.assertCalledWith( curCompletedCount, url, LoadError.HTTP_CLIENT_ERROR); assertEquals(mCallback.onCompletedCallback.getHttpStatusCode(), 404); + assertEquals(mCallback.onCompletedCallback.getNavigationState(), NavigationState.COMPLETE); } private void setNavigationCallback(InstrumentationActivity activity) {