summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/testing
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/testing')
-rw-r--r--chromium/third_party/blink/renderer/core/testing/DEPS2
-rw-r--r--chromium/third_party/blink/renderer/core/testing/callback_function_test.h4
-rw-r--r--chromium/third_party/blink/renderer/core/testing/data/fixed-position-losing-backing.html17
-rw-r--r--chromium/third_party/blink/renderer/core/testing/data/test_touch_link_highlight.html21
-rw-r--r--chromium/third_party/blink/renderer/core/testing/data/wheel-event-handler.html2
-rw-r--r--chromium/third_party/blink/renderer/core/testing/dictionary_test.cc6
-rw-r--r--chromium/third_party/blink/renderer/core/testing/dummy_modulator.cc16
-rw-r--r--chromium/third_party/blink/renderer/core/testing/dummy_modulator.h33
-rw-r--r--chromium/third_party/blink/renderer/core/testing/dummy_page_holder.cc16
-rw-r--r--chromium/third_party/blink/renderer/core/testing/internals.cc83
-rw-r--r--chromium/third_party/blink/renderer/core/testing/internals.h10
-rw-r--r--chromium/third_party/blink/renderer/core/testing/internals.idl30
-rw-r--r--chromium/third_party/blink/renderer/core/testing/null_execution_context.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/testing/page_test_base.cc2
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.cc29
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.h14
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.cc28
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.h27
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_network.cc16
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_network.h15
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_request.cc95
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_request.h52
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_test.cc51
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_test.h21
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc32
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h41
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc40
-rw-r--r--chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h49
-rw-r--r--chromium/third_party/blink/renderer/core/testing/v8/web_core_test_support.cc6
29 files changed, 334 insertions, 426 deletions
diff --git a/chromium/third_party/blink/renderer/core/testing/DEPS b/chromium/third_party/blink/renderer/core/testing/DEPS
index 1cd6cecba86..982d4f4ce4e 100644
--- a/chromium/third_party/blink/renderer/core/testing/DEPS
+++ b/chromium/third_party/blink/renderer/core/testing/DEPS
@@ -3,7 +3,7 @@ include_rules = [
# TODO(crbug.com/838693): Test harnesses use LayerTreeView
# from content instead of a fake WebLayerTreeView implementation, so
# that the Web abstraction can go away.
- "+content/renderer/gpu",
+ "+content/renderer/compositor",
"+content/test",
"+gpu/command_buffer/client/gles2_interface.h",
]
diff --git a/chromium/third_party/blink/renderer/core/testing/callback_function_test.h b/chromium/third_party/blink/renderer/core/testing/callback_function_test.h
index 035b0d2978e..a20bc0fd3bf 100644
--- a/chromium/third_party/blink/renderer/core/testing/callback_function_test.h
+++ b/chromium/third_party/blink/renderer/core/testing/callback_function_test.h
@@ -24,7 +24,9 @@ class CallbackFunctionTest final : public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
- static CallbackFunctionTest* Create() { return new CallbackFunctionTest(); }
+ static CallbackFunctionTest* Create() {
+ return MakeGarbageCollected<CallbackFunctionTest>();
+ }
String testCallback(V8TestCallback*,
const String&,
diff --git a/chromium/third_party/blink/renderer/core/testing/data/fixed-position-losing-backing.html b/chromium/third_party/blink/renderer/core/testing/data/fixed-position-losing-backing.html
deleted file mode 100644
index b4c0712c3a3..00000000000
--- a/chromium/third_party/blink/renderer/core/testing/data/fixed-position-losing-backing.html
+++ /dev/null
@@ -1,17 +0,0 @@
-<!DOCTYPE html>
-<style>
-#fixed {
- position: fixed;
- width: 100px;
- height: 100px;
- /* Using transparent background color so that fixed position element is not automatically promoted. */
- background-color: rgba(255, 255, 0, 0.5);
- transform: translateZ(0);
-}
-
-#bloat {
- height: 10000px;
-}
-</style>
-<div id="fixed"></div>
-<div id="bloat"></div>
diff --git a/chromium/third_party/blink/renderer/core/testing/data/test_touch_link_highlight.html b/chromium/third_party/blink/renderer/core/testing/data/test_touch_link_highlight.html
index 9669936483b..9254ca5b07d 100644
--- a/chromium/third_party/blink/renderer/core/testing/data/test_touch_link_highlight.html
+++ b/chromium/third_party/blink/renderer/core/testing/data/test_touch_link_highlight.html
@@ -29,20 +29,11 @@
<div style="position: absolute; left: 20px; top: 260px; width: 200px;">
<input type="text"> <!-- This will have an I-beam cursor. -->
</div>
- <a href="http://www.test.com" style="position: absolute; left: 20px; top: 300px; width: 400px;">One link to highlight</a>
- <a href="http://www.test.com" style="position: absolute; left: 20px; top: 320px; width: 400px;">Another link to highlight simultaneously</a>
-<!-- The following is the text for the iframe tag below:
-<html>
-<body>
-<a href="http://www.test.com" position: absolute; left: 50px; top: 30px>
-This is going to be a very long link to force the scrollbars to activate on the iFrame that will contain this page.
-</a>
-</body>
-</html>
--->
-<!--
- <iframe style="scrolling: yes; width : 400px; height : 100px; position: absolute; left: 20px; top: 210px;"
- src="data:text/html,%3Chtml%3E%0A%3Cbody%3E%0A%3Ca%20href%3D%22http%3A%2F%2Fwww.test.com%22%20position%3A%20absolute%3B%20left%3A%2050px%3B%20top%3A%2030px%3E%0AThis%20is%20going%20to%20be%20a%20very%20long%20link%20to%20force%20the%20scrollbars%20to%20activate%20on%20the%20iFrame%20that%20will%20contain%20this%20page.%0A%3C%2Fa%3E%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E"></iframe>
--->
+ <div style="position: absolute; left: 20px; top: 300px; width: 400px; height: 50px; columns: 2">
+ <a href="http://www.test.com">
+ <div style="display: inline-block; width: 200px; height: 50px">Link in column 1</div>
+ <div style="display: inline-block; width: 200px; height: 50px">Link in column 2</div>
+ </a>
+ </div>
</body>
</html>
diff --git a/chromium/third_party/blink/renderer/core/testing/data/wheel-event-handler.html b/chromium/third_party/blink/renderer/core/testing/data/wheel-event-handler.html
index 7e450a4ece6..51e39d0e625 100644
--- a/chromium/third_party/blink/renderer/core/testing/data/wheel-event-handler.html
+++ b/chromium/third_party/blink/renderer/core/testing/data/wheel-event-handler.html
@@ -3,7 +3,7 @@
<head>
<script type="text/javascript">
window.addEventListener('mousewheel', function(event) {
- });
+ }, {passive: false});
</script>
</head>
diff --git a/chromium/third_party/blink/renderer/core/testing/dictionary_test.cc b/chromium/third_party/blink/renderer/core/testing/dictionary_test.cc
index 3f725f36690..368c08dd3a3 100644
--- a/chromium/third_party/blink/renderer/core/testing/dictionary_test.cc
+++ b/chromium/third_party/blink/renderer/core/testing/dictionary_test.cc
@@ -178,8 +178,10 @@ String DictionaryTest::stringFromIterable(
result.Append(',');
v8::Local<v8::Value> value;
- if (iterator.GetValue().ToLocal(&value))
- result.Append(ToCoreString(value->ToString(script_state->GetIsolate())));
+ if (iterator.GetValue().ToLocal(&value)) {
+ result.Append(ToCoreString(
+ value->ToString(script_state->GetContext()).ToLocalChecked()));
+ }
}
return result.ToString();
diff --git a/chromium/third_party/blink/renderer/core/testing/dummy_modulator.cc b/chromium/third_party/blink/renderer/core/testing/dummy_modulator.cc
index 7c2d2064f42..74459e34c21 100644
--- a/chromium/third_party/blink/renderer/core/testing/dummy_modulator.cc
+++ b/chromium/third_party/blink/renderer/core/testing/dummy_modulator.cc
@@ -35,7 +35,8 @@ class EmptyScriptModuleResolver final : public ScriptModuleResolver {
} // namespace
-DummyModulator::DummyModulator() : resolver_(new EmptyScriptModuleResolver()) {}
+DummyModulator::DummyModulator()
+ : resolver_(MakeGarbageCollected<EmptyScriptModuleResolver>()) {}
DummyModulator::~DummyModulator() = default;
@@ -63,7 +64,7 @@ base::SingleThreadTaskRunner* DummyModulator::TaskRunner() {
};
void DummyModulator::FetchTree(const KURL&,
- FetchClientSettingsObjectSnapshot*,
+ ResourceFetcher*,
mojom::RequestContextType,
const ScriptFetchOptions&,
ModuleScriptCustomFetchType,
@@ -72,18 +73,17 @@ void DummyModulator::FetchTree(const KURL&,
}
void DummyModulator::FetchSingle(const ModuleScriptFetchRequest&,
- FetchClientSettingsObjectSnapshot*,
+ ResourceFetcher*,
ModuleGraphLevel,
ModuleScriptCustomFetchType,
SingleModuleClient*) {
NOTREACHED();
}
-void DummyModulator::FetchDescendantsForInlineScript(
- ModuleScript*,
- FetchClientSettingsObjectSnapshot* fetch_client_settings_object,
- mojom::RequestContextType,
- ModuleTreeClient*) {
+void DummyModulator::FetchDescendantsForInlineScript(ModuleScript*,
+ ResourceFetcher*,
+ mojom::RequestContextType,
+ ModuleTreeClient*) {
NOTREACHED();
}
diff --git a/chromium/third_party/blink/renderer/core/testing/dummy_modulator.h b/chromium/third_party/blink/renderer/core/testing/dummy_modulator.h
index ae6477c7567..de1a0c91ba5 100644
--- a/chromium/third_party/blink/renderer/core/testing/dummy_modulator.h
+++ b/chromium/third_party/blink/renderer/core/testing/dummy_modulator.h
@@ -34,24 +34,21 @@ class DummyModulator : public Modulator {
ScriptState* GetScriptState() override;
bool IsScriptingDisabled() const override;
- void FetchTree(
- const KURL&,
- FetchClientSettingsObjectSnapshot* fetch_client_settings_object,
- mojom::RequestContextType destination,
- const ScriptFetchOptions&,
- ModuleScriptCustomFetchType,
- ModuleTreeClient*) override;
- void FetchSingle(
- const ModuleScriptFetchRequest&,
- FetchClientSettingsObjectSnapshot* fetch_client_settings_object,
- ModuleGraphLevel,
- ModuleScriptCustomFetchType,
- SingleModuleClient*) override;
- void FetchDescendantsForInlineScript(
- ModuleScript*,
- FetchClientSettingsObjectSnapshot* fetch_client_settings_object,
- mojom::RequestContextType destination,
- ModuleTreeClient*) override;
+ void FetchTree(const KURL&,
+ ResourceFetcher*,
+ mojom::RequestContextType destination,
+ const ScriptFetchOptions&,
+ ModuleScriptCustomFetchType,
+ ModuleTreeClient*) override;
+ void FetchSingle(const ModuleScriptFetchRequest&,
+ ResourceFetcher*,
+ ModuleGraphLevel,
+ ModuleScriptCustomFetchType,
+ SingleModuleClient*) override;
+ void FetchDescendantsForInlineScript(ModuleScript*,
+ ResourceFetcher*,
+ mojom::RequestContextType destination,
+ ModuleTreeClient*) override;
ModuleScript* GetFetchedModuleScript(const KURL&) override;
KURL ResolveModuleSpecifier(const String&, const KURL&, String*) override;
bool HasValidContext() override;
diff --git a/chromium/third_party/blink/renderer/core/testing/dummy_page_holder.cc b/chromium/third_party/blink/renderer/core/testing/dummy_page_holder.cc
index 8c9bfdb5aab..343b8797ba5 100644
--- a/chromium/third_party/blink/renderer/core/testing/dummy_page_holder.cc
+++ b/chromium/third_party/blink/renderer/core/testing/dummy_page_holder.cc
@@ -43,6 +43,20 @@
namespace blink {
+namespace {
+
+class DummyLocalFrameClient : public EmptyLocalFrameClient {
+ public:
+ DummyLocalFrameClient() = default;
+
+ private:
+ std::unique_ptr<WebURLLoaderFactory> CreateURLLoaderFactory() override {
+ return Platform::Current()->CreateDefaultURLLoaderFactory();
+ }
+};
+
+} // namespace
+
std::unique_ptr<DummyPageHolder> DummyPageHolder::Create(
const IntSize& initial_view_size,
Page::PageClients* page_clients,
@@ -69,7 +83,7 @@ DummyPageHolder::DummyPageHolder(
local_frame_client_ = local_frame_client;
if (!local_frame_client_)
- local_frame_client_ = EmptyLocalFrameClient::Create();
+ local_frame_client_ = MakeGarbageCollected<DummyLocalFrameClient>();
frame_ = LocalFrame::Create(local_frame_client_.Get(), *page_, nullptr);
frame_->SetView(LocalFrameView::Create(*frame_, initial_view_size));
diff --git a/chromium/third_party/blink/renderer/core/testing/internals.cc b/chromium/third_party/blink/renderer/core/testing/internals.cc
index 2e5b06872aa..2b0889e0e5a 100644
--- a/chromium/third_party/blink/renderer/core/testing/internals.cc
+++ b/chromium/third_party/blink/renderer/core/testing/internals.cc
@@ -120,6 +120,7 @@
#include "third_party/blink/renderer/core/page/scrolling/root_scroller_controller.h"
#include "third_party/blink/renderer/core/page/scrolling/scroll_state.h"
#include "third_party/blink/renderer/core/page/scrolling/scrolling_coordinator_context.h"
+#include "third_party/blink/renderer/core/page/spatial_navigation_controller.h"
#include "third_party/blink/renderer/core/page/viewport_description.h"
#include "third_party/blink/renderer/core/paint/compositing/composited_layer_mapping.h"
#include "third_party/blink/renderer/core/paint/compositing/graphics_layer_tree_as_text.h"
@@ -267,6 +268,15 @@ void Internals::ResetToConsistentState(Page* page) {
// call.
page->SetDefaultPageScaleLimits(1, 4);
page->SetPageScaleFactor(1);
+
+ // Ensure timers are reset so timers such as EventHandler's |hover_timer_| do
+ // not cause additional lifecycle updates.
+ for (Frame* frame = page->MainFrame(); frame;
+ frame = frame->Tree().TraverseNext()) {
+ if (frame->IsLocalFrame())
+ ToLocalFrame(frame)->GetEventHandler().Clear();
+ }
+
LocalFrame* frame = page->DeprecatedLocalMainFrame();
frame->View()->LayoutViewport()->SetScrollOffset(ScrollOffset(),
kProgrammaticScroll);
@@ -363,6 +373,9 @@ unsigned Internals::hitTestCount(Document* doc,
return 0;
}
+ if (!doc->GetLayoutView())
+ return 0;
+
return doc->GetLayoutView()->HitTestCount();
}
@@ -374,6 +387,9 @@ unsigned Internals::hitTestCacheHits(Document* doc,
return 0;
}
+ if (!doc->GetLayoutView())
+ return 0;
+
return doc->GetLayoutView()->HitTestCacheHits();
}
@@ -471,6 +487,15 @@ int Internals::getResourcePriority(const String& url, Document* document) {
return static_cast<int>(resource->GetResourceRequest().Priority());
}
+bool Internals::doesWindowHaveUrlFragment(DOMWindow* window) {
+ if (window->IsRemoteDOMWindow())
+ return false;
+ return ToLocalFrame(window->GetFrame())
+ ->GetDocument()
+ ->Url()
+ .HasFragmentIdentifier();
+}
+
String Internals::getResourceHeader(const String& url,
const String& header,
Document* document) {
@@ -847,7 +872,7 @@ DOMWindow* Internals::pagePopupWindow() const {
LocalDOMWindow* popup =
ToLocalDOMWindow(page->GetChromeClient().PagePopupWindowForTesting());
if (popup) {
- // We need to make the popup same origin so layout tests can access it.
+ // We need to make the popup same origin so web tests can access it.
popup->document()->UpdateSecurityOrigin(
document_->GetMutableSecurityOrigin());
}
@@ -1674,7 +1699,8 @@ static unsigned EventHandlerCount(
unsigned Internals::wheelEventHandlerCount(Document* document) const {
DCHECK(document);
return EventHandlerCount(*document,
- EventHandlerRegistry::kWheelEventBlocking);
+ EventHandlerRegistry::kWheelEventBlocking) +
+ EventHandlerCount(*document, EventHandlerRegistry::kWheelEventPassive);
}
unsigned Internals::scrollEventHandlerCount(Document* document) const {
@@ -1904,7 +1930,7 @@ HitTestLayerRectList* Internals::touchEventTargetLayerRects(
return nullptr;
}
- if (RuntimeEnabledFeatures::SlimmingPaintV2Enabled()) {
+ if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
auto* pac = document->View()->GetPaintArtifactCompositorForTesting();
pac->EnableExtraDataForTesting();
document->View()->UpdateAllLifecyclePhases(
@@ -1917,7 +1943,8 @@ HitTestLayerRectList* Internals::touchEventTargetLayerRects(
const cc::TouchActionRegion& touch_action_region =
layer->touch_action_region();
if (!touch_action_region.region().IsEmpty()) {
- IntRect layer_rect(RoundedIntPoint(FloatPoint(layer->position())),
+ const auto& offset = layer->offset_to_transform_parent();
+ IntRect layer_rect(RoundedIntPoint(FloatPoint(offset.x(), offset.y())),
IntSize(layer->bounds()));
Vector<IntRect> layer_hit_test_rects;
@@ -3067,14 +3094,14 @@ namespace {
class AddOneFunction : public ScriptFunction {
public:
static v8::Local<v8::Function> CreateFunction(ScriptState* script_state) {
- AddOneFunction* self = new AddOneFunction(script_state);
+ AddOneFunction* self = MakeGarbageCollected<AddOneFunction>(script_state);
return self->BindToV8Function();
}
- private:
explicit AddOneFunction(ScriptState* script_state)
: ScriptFunction(script_state) {}
+ private:
ScriptValue Call(ScriptValue value) override {
v8::Local<v8::Value> v8_value = value.V8Value();
DCHECK(v8_value->IsNumber());
@@ -3191,6 +3218,23 @@ bool Internals::ignoreLayoutWithPendingStylesheets(Document* document) {
return document->IgnoreLayoutWithPendingStylesheets();
}
+Element* Internals::interestedElement() {
+ if (!GetFrame() || !GetFrame()->GetPage())
+ return nullptr;
+
+ if (!RuntimeEnabledFeatures::FocuslessSpatialNavigationEnabled()) {
+ return ToLocalFrame(
+ GetFrame()->GetPage()->GetFocusController().FocusedOrMainFrame())
+ ->GetDocument()
+ ->ActiveElement();
+ }
+
+ return GetFrame()
+ ->GetPage()
+ ->GetSpatialNavigationController()
+ .GetInterestedElement();
+}
+
void Internals::setNetworkConnectionInfoOverride(
bool on_line,
const String& type,
@@ -3389,8 +3433,9 @@ ScriptPromise Internals::observeUseCounter(ScriptState* script_state,
return promise;
}
- loader->GetUseCounter().AddObserver(new UseCounterObserverImpl(
- resolver, static_cast<WebFeature>(use_counter_feature)));
+ loader->GetUseCounter().AddObserver(
+ MakeGarbageCollected<UseCounterObserverImpl>(
+ resolver, static_cast<WebFeature>(use_counter_feature)));
return promise;
}
@@ -3402,24 +3447,6 @@ String Internals::unscopableMethod() {
return "unscopableMethod";
}
-DOMRectList* Internals::focusRingRects(Element* element) {
- Vector<LayoutRect> rects;
- if (element && element->GetLayoutObject()) {
- element->GetLayoutObject()->AddOutlineRects(
- rects, LayoutPoint(), NGOutlineType::kIncludeBlockVisualOverflow);
- }
- return DOMRectList::Create(rects);
-}
-
-DOMRectList* Internals::outlineRects(Element* element) {
- Vector<LayoutRect> rects;
- if (element && element->GetLayoutObject()) {
- element->GetLayoutObject()->AddOutlineRects(
- rects, LayoutPoint(), NGOutlineType::kDontIncludeBlockVisualOverflow);
- }
- return DOMRectList::Create(rects);
-}
-
void Internals::setCapsLockState(bool enabled) {
KeyboardEventManager::SetCurrentCapsLockState(
enabled ? OverrideCapsLockState::kOn : OverrideCapsLockState::kOff);
@@ -3445,6 +3472,10 @@ double Internals::monotonicTimeToZeroBasedDocumentTime(
.InSecondsF();
}
+int64_t Internals::currentTimeTicks() {
+ return base::TimeTicks::Now().since_origin().InMicroseconds();
+}
+
String Internals::getScrollAnimationState(Node* node) const {
if (ScrollableArea* scrollable_area = ScrollableAreaForNode(node))
return scrollable_area->GetScrollAnimator().RunStateAsText();
diff --git a/chromium/third_party/blink/renderer/core/testing/internals.h b/chromium/third_party/blink/renderer/core/testing/internals.h
index 3d69d29d086..dd463b87721 100644
--- a/chromium/third_party/blink/renderer/core/testing/internals.h
+++ b/chromium/third_party/blink/renderer/core/testing/internals.h
@@ -108,6 +108,8 @@ class Internals final : public ScriptWrappable {
int getResourcePriority(const String& url, Document*);
String getResourceHeader(const String& url, const String& header, Document*);
+ bool doesWindowHaveUrlFragment(DOMWindow*);
+
CSSStyleDeclaration* computedStyleIncludingVisitedInfo(Node*) const;
void setBrowserControlsState(float top_height,
@@ -493,6 +495,8 @@ class Internals final : public ScriptWrappable {
bool ignoreLayoutWithPendingStylesheets(Document*);
+ Element* interestedElement();
+
void setNetworkConnectionInfoOverride(bool,
const String&,
const String&,
@@ -546,9 +550,6 @@ class Internals final : public ScriptWrappable {
String unscopableAttribute();
String unscopableMethod();
- DOMRectList* focusRingRects(Element*);
- DOMRectList* outlineRects(Element*);
-
void setCapsLockState(bool enabled);
bool setScrollbarVisibilityInScrollableArea(Node*, bool visible);
@@ -557,6 +558,9 @@ class Internals final : public ScriptWrappable {
// document time in seconds
double monotonicTimeToZeroBasedDocumentTime(double, ExceptionState&);
+ // Returns the current time ticks (in microseconds).
+ int64_t currentTimeTicks();
+
// Returns the run state of the node's scroll animator (see
// ScrollAnimatorCompositorCoordinater::RunState), or -1 if the node does not
// have a scrollable area.
diff --git a/chromium/third_party/blink/renderer/core/testing/internals.idl b/chromium/third_party/blink/renderer/core/testing/internals.idl
index 8c575f90721..7099cd94a72 100644
--- a/chromium/third_party/blink/renderer/core/testing/internals.idl
+++ b/chromium/third_party/blink/renderer/core/testing/internals.idl
@@ -44,6 +44,8 @@ enum EffectiveConnectionType {
unsigned long getResourcePriority (DOMString url, Document document);
DOMString getResourceHeader (DOMString url, DOMString header, Document document);
+ bool doesWindowHaveUrlFragment(Window window);
+
CSSStyleDeclaration computedStyleIncludingVisitedInfo(Node node);
ShadowRoot createUserAgentShadowRoot(Element host);
@@ -307,15 +309,15 @@ enum EffectiveConnectionType {
[RaisesException] void setShouldRevealPassword(Element element, boolean reveal);
- [CallWith=ScriptState] Promise createResolvedPromise(any value);
- [CallWith=ScriptState] Promise createRejectedPromise(any reason);
- [CallWith=ScriptState] Promise addOneToPromise(Promise promise);
- [CallWith=ScriptState, RaisesException] Promise promiseCheck(long arg1, boolean arg2, object arg3, DOMString arg4, sequence<DOMString> arg5);
- [CallWith=ScriptState] Promise promiseCheckWithoutExceptionState(object arg1, DOMString arg2, DOMString... variadic);
- [CallWith=ScriptState] Promise promiseCheckRange([EnforceRange] octet arg1);
- [CallWith=ScriptState] Promise promiseCheckOverload(Location arg1);
- [CallWith=ScriptState] Promise promiseCheckOverload(Document arg1);
- [CallWith=ScriptState] Promise promiseCheckOverload(Location arg1, long arg2, long arg3);
+ [CallWith=ScriptState] Promise<any> createResolvedPromise(any value);
+ [CallWith=ScriptState] Promise<any> createRejectedPromise(any reason);
+ [CallWith=ScriptState] Promise<any> addOneToPromise(Promise<any> promise);
+ [CallWith=ScriptState, RaisesException] Promise<any> promiseCheck(long arg1, boolean arg2, object arg3, DOMString arg4, sequence<DOMString> arg5);
+ [CallWith=ScriptState] Promise<any> promiseCheckWithoutExceptionState(object arg1, DOMString arg2, DOMString... variadic);
+ [CallWith=ScriptState] Promise<any> promiseCheckRange([EnforceRange] octet arg1);
+ [CallWith=ScriptState] Promise<any> promiseCheckOverload(Location arg1);
+ [CallWith=ScriptState] Promise<any> promiseCheckOverload(Document arg1);
+ [CallWith=ScriptState] Promise<any> promiseCheckOverload(Location arg1, long arg2, long arg3);
void setValueForUser(HTMLInputElement element, DOMString value);
@@ -324,6 +326,11 @@ enum EffectiveConnectionType {
boolean ignoreLayoutWithPendingStylesheets(Document document);
+ // When the FocuslessSpatialNavigation feature is enabled, spatial
+ // navigation moves "interest" around a page, rather than focus. This
+ // attribute returns the currently interested element on the page.
+ readonly attribute Element? interestedElement;
+
// These functions are for testing NetInfo. You must call clearNetworkConnectionInfoOverride() at the end.
[RaisesException] void setNetworkConnectionInfoOverride(boolean onLine, DOMString type, EffectiveConnectionType effective_type, unsigned long http_rtt_msec, double downlink_max_mbps);
void setSaveDataEnabled(boolean enabled);
@@ -371,8 +378,6 @@ enum EffectiveConnectionType {
[Unscopable] readonly attribute DOMString unscopableAttribute;
[Unscopable] DOMString unscopableMethod();
- DOMRectList focusRingRects(Element element);
- DOMRectList outlineRects(Element element);
void setCapsLockState(boolean enabled);
// Returns whether the scrollbar was able to be shown or hidden; not all platforms
@@ -380,6 +385,7 @@ enum EffectiveConnectionType {
boolean setScrollbarVisibilityInScrollableArea(Node node, boolean visible);
[RaisesException] double monotonicTimeToZeroBasedDocumentTime(double platformTime);
+ long long currentTimeTicks();
DOMString getScrollAnimationState(Node node);
@@ -414,7 +420,7 @@ enum EffectiveConnectionType {
// Disable the 'delay' option for IntersectionObserver, so that observations
// are recomputed on every frame. This eliminates the need to add
- // setTimeout(..., delay_ms) calls to layout tests to wait for notifications
+ // setTimeout(..., delay_ms) calls to web tests to wait for notifications
// to be generated.
void DisableIntersectionObserverThrottleDelay();
diff --git a/chromium/third_party/blink/renderer/core/testing/null_execution_context.cc b/chromium/third_party/blink/renderer/core/testing/null_execution_context.cc
index 1fdf44f8e33..6bcc92f3a60 100644
--- a/chromium/third_party/blink/renderer/core/testing/null_execution_context.cc
+++ b/chromium/third_party/blink/renderer/core/testing/null_execution_context.cc
@@ -30,7 +30,7 @@ bool NullExecutionContext::IsSecureContext(String& error_message) const {
void NullExecutionContext::SetUpSecurityContext() {
ContentSecurityPolicy* policy = ContentSecurityPolicy::Create();
SecurityContext::SetSecurityOrigin(SecurityOrigin::Create(url_));
- policy->BindToExecutionContext(this);
+ policy->BindToDelegate(GetContentSecurityPolicyDelegate());
SecurityContext::SetContentSecurityPolicy(policy);
}
diff --git a/chromium/third_party/blink/renderer/core/testing/page_test_base.cc b/chromium/third_party/blink/renderer/core/testing/page_test_base.cc
index 6f4e35bb4e0..5698d8f08e3 100644
--- a/chromium/third_party/blink/renderer/core/testing/page_test_base.cc
+++ b/chromium/third_party/blink/renderer/core/testing/page_test_base.cc
@@ -11,7 +11,7 @@
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/html_element.h"
-#include "third_party/blink/renderer/platform/loader/fetch/substitute_data.h"
+#include "third_party/blink/renderer/platform/shared_buffer.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
namespace blink {
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.cc
index 8ea1b96e428..29217bb4175 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.cc
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.cc
@@ -87,35 +87,6 @@ void SimCanvas::onDrawImageRect(const SkImage* image,
SkCanvas::onDrawImageRect(image, src, dst, paint, constraint);
}
-void SimCanvas::onDrawText(const void* text,
- size_t byte_length,
- SkScalar x,
- SkScalar y,
- const SkPaint& paint) {
- DrawScope scope;
- AddCommand(CommandType::kText, paint.getColor());
- SkCanvas::onDrawText(text, byte_length, x, y, paint);
-}
-
-void SimCanvas::onDrawPosText(const void* text,
- size_t byte_length,
- const SkPoint pos[],
- const SkPaint& paint) {
- DrawScope scope;
- AddCommand(CommandType::kText, paint.getColor());
- SkCanvas::onDrawPosText(text, byte_length, pos, paint);
-}
-
-void SimCanvas::onDrawPosTextH(const void* text,
- size_t byte_length,
- const SkScalar xpos[],
- SkScalar const_y,
- const SkPaint& paint) {
- DrawScope scope;
- AddCommand(CommandType::kText, paint.getColor());
- SkCanvas::onDrawPosTextH(text, byte_length, xpos, const_y, paint);
-}
-
void SimCanvas::onDrawTextBlob(const SkTextBlob* blob,
SkScalar x,
SkScalar y,
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.h
index 4c40108a576..cf086d59a8d 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.h
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_canvas.h
@@ -62,20 +62,6 @@ class SimCanvas : public SkCanvas {
SrcRectConstraint) override;
// Text
- void onDrawText(const void* text,
- size_t byte_length,
- SkScalar x,
- SkScalar y,
- const SkPaint&) override;
- void onDrawPosText(const void* text,
- size_t byte_length,
- const SkPoint pos[],
- const SkPaint&) override;
- void onDrawPosTextH(const void* text,
- size_t byte_length,
- const SkScalar xpos[],
- SkScalar const_y,
- const SkPaint&) override;
void onDrawTextBlob(const SkTextBlob*,
SkScalar x,
SkScalar y,
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.cc
index becc31a0700..0affb2c7d69 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.cc
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.cc
@@ -29,11 +29,18 @@ SimCompositor::~SimCompositor() {
LocalFrameView::SetInitialTracksPaintInvalidationsForTesting(false);
}
-void SimCompositor::SetWebView(WebViewImpl& web_view,
- content::LayerTreeView& layer_tree_view) {
+void SimCompositor::SetWebView(
+ WebViewImpl& web_view,
+ content::LayerTreeView& layer_tree_view,
+ frame_test_helpers::TestWebViewClient& view_client,
+ frame_test_helpers::TestWebWidgetClient& widget_client) {
web_view_ = &web_view;
layer_tree_view_ = &layer_tree_view;
DCHECK_EQ(&layer_tree_view, web_view_->LayerTreeView());
+ test_web_view_client_ = &view_client;
+ DCHECK_EQ(test_web_view_client_, web_view_->Client());
+ test_web_widget_client_ = &widget_client;
+ DCHECK_EQ(test_web_widget_client_, web_view_->WidgetClient());
// SimCompositor starts with defer commits enabled, but uses synchronous
// compositing which does not use defer commits anyhow, it only uses it for
@@ -44,9 +51,13 @@ void SimCompositor::SetWebView(WebViewImpl& web_view,
SimCanvas::Commands SimCompositor::BeginFrame(double time_delta_in_seconds) {
DCHECK(web_view_);
DCHECK(!layer_tree_view_->layer_tree_host()->defer_main_frame_update());
- DCHECK(layer_tree_view_->layer_tree_host()->RequestedMainFramePending());
+ // Verify that the need for a BeginMainFrame has been registered, and would
+ // have caused the compositor to schedule one if we were using its scheduler.
+ DCHECK(NeedsBeginFrame());
DCHECK_GT(time_delta_in_seconds, 0);
+ test_web_widget_client_->ClearAnimationScheduled();
+
last_frame_time_ += base::TimeDelta::FromSecondsD(time_delta_in_seconds);
SimCanvas::Commands commands;
@@ -65,18 +76,19 @@ SimCanvas::Commands SimCompositor::PaintFrame() {
auto* frame = web_view_->MainFrameImpl()->GetFrame();
DocumentLifecycle::AllowThrottlingScope throttling_scope(
frame->GetDocument()->Lifecycle());
+ frame->View()->UpdateAllLifecyclePhases(DocumentLifecycle::kTest);
PaintRecordBuilder builder;
- auto infinite_rect = LayoutRect::InfiniteIntRect();
- frame->View()->Paint(builder.Context(), kGlobalPaintFlattenCompositingLayers,
- CullRect(infinite_rect));
+ frame->View()->PaintOutsideOfLifecycle(builder.Context(),
+ kGlobalPaintFlattenCompositingLayers);
+ auto infinite_rect = LayoutRect::InfiniteIntRect();
SimCanvas canvas(infinite_rect.Width(), infinite_rect.Height());
builder.EndRecording()->Playback(&canvas);
return canvas.GetCommands();
}
void SimCompositor::ApplyViewportChanges(const ApplyViewportChangesArgs& args) {
- web_view_->ApplyViewportChanges(args);
+ web_view_->MainFrameWidget()->ApplyViewportChanges(args);
}
void SimCompositor::RequestNewLayerTreeFrameSink(
@@ -89,7 +101,7 @@ void SimCompositor::RequestNewLayerTreeFrameSink(
void SimCompositor::BeginMainFrame(base::TimeTicks frame_time) {
// There is no WebWidget like RenderWidget would have..? So go right to the
// WebViewImpl.
- web_view_->BeginFrame(last_frame_time_);
+ web_view_->MainFrameWidget()->BeginFrame(last_frame_time_);
web_view_->MainFrameWidget()->UpdateAllLifecyclePhases(
WebWidget::LifecycleUpdateReason::kTest);
*paint_commands_ = PaintFrame();
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.h
index 784300e12da..466733ea188 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.h
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_compositor.h
@@ -7,7 +7,7 @@
#include "base/time/time.h"
#include "cc/trees/layer_tree_host.h"
-#include "content/renderer/gpu/layer_tree_view.h"
+#include "content/renderer/compositor/layer_tree_view.h"
#include "content/test/stub_layer_tree_view_delegate.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/testing/sim/sim_canvas.h"
@@ -39,7 +39,16 @@ class SimCompositor final : public content::StubLayerTreeViewDelegate {
// to composite the WebViewImpl is passed separately as the underlying
// content::LayerTreeView type, in order to bypass the Web* API surface
// provided to blink.
- void SetWebView(WebViewImpl&, content::LayerTreeView&);
+ // The WebWidget client is overridden (via the WebViewClient) to control
+ // BeginMainFrame scheduling since this test suite does not use the
+ // compositor's scheduler. The SimCompositor wants to monitor and verify
+ // expectations around this scheduling, so receives the WebViewClient. We
+ // pass it here explicitly to provide type safety, though it is the client
+ // available on the WebViewImpl as well.
+ void SetWebView(WebViewImpl&,
+ content::LayerTreeView&,
+ frame_test_helpers::TestWebViewClient&,
+ frame_test_helpers::TestWebWidgetClient&);
// Executes the BeginMainFrame processing steps, an approximation of what
// cc::ThreadProxy::BeginMainFrame would do.
@@ -57,9 +66,13 @@ class SimCompositor final : public content::StubLayerTreeViewDelegate {
// Helpers to query the state of the compositor from tests.
//
// Returns true if a main frame has been requested from blink, until the
- // BeginFrame() step occurs.
+ // BeginFrame() step occurs. The AnimationScheduled() checks if an explicit
+ // requet for BeginFrame() was made, vs an implicit one by making changes
+ // to the compositor's state.
bool NeedsBeginFrame() const {
- return layer_tree_view_->layer_tree_host()->RequestedMainFramePending();
+ cc::LayerTreeHost* layer_tree_host = layer_tree_view_->layer_tree_host();
+ return test_web_widget_client_->AnimationScheduled() ||
+ layer_tree_host->RequestedMainFramePendingForTesting();
}
// Returns true if commits are deferred in the compositor. Since these tests
// use synchronous compositing through BeginFrame(), the deferred state has no
@@ -87,14 +100,16 @@ class SimCompositor final : public content::StubLayerTreeViewDelegate {
void BeginMainFrame(base::TimeTicks frame_time) override;
WebViewImpl* web_view_ = nullptr;
+ content::LayerTreeView* layer_tree_view_ = nullptr;
+ frame_test_helpers::TestWebViewClient* test_web_view_client_ = nullptr;
+ frame_test_helpers::TestWebWidgetClient* test_web_widget_client_ = nullptr;
+
base::TimeTicks last_frame_time_;
// During BeginFrame(), painting is done, and the result is stored here to
// be returned from BeginFrame().
SimCanvas::Commands* paint_commands_;
- content::LayerTreeView* layer_tree_view_ = nullptr;
-
std::unique_ptr<cc::ScopedDeferMainFrameUpdate>
scoped_defer_main_frame_update_;
};
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_network.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_network.cc
index 45df1df2fcb..22767b377c4 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_network.cc
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_network.cc
@@ -41,7 +41,7 @@ void SimNetwork::ServePendingRequests() {
void SimNetwork::DidReceiveResponse(WebURLLoaderClient* client,
const WebURLResponse& response) {
- auto it = requests_.find(response.Url().GetString());
+ auto it = requests_.find(response.CurrentRequestUrl().GetString());
if (it == requests_.end()) {
client->DidReceiveResponse(response);
return;
@@ -86,12 +86,18 @@ void SimNetwork::DidFinishLoading(WebURLLoaderClient* client,
current_request_ = nullptr;
}
-void SimNetwork::AddRequest(SimRequest& request) {
- requests_.insert(request.Url(), &request);
+void SimNetwork::AddRequest(SimRequestBase& request) {
+ requests_.insert(request.url_.GetString(), &request);
+ WebURLResponse response(request.url_);
+ response.SetMIMEType(request.mime_type_);
+ response.SetHTTPStatusCode(200);
+ Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(request.url_,
+ response, "");
}
-void SimNetwork::RemoveRequest(SimRequest& request) {
- requests_.erase(request.Url());
+void SimNetwork::RemoveRequest(SimRequestBase& request) {
+ requests_.erase(request.url_);
+ Platform::Current()->GetURLLoaderMockFactory()->UnregisterURL(request.url_);
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_network.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_network.h
index aadd07b7dfe..bce0ac07522 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_network.h
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_network.h
@@ -13,26 +13,27 @@
namespace blink {
-class SimRequest;
+class SimRequestBase;
class WebURLLoaderClient;
class WebURLResponse;
// Simulates a network with precise flow control so you can make requests
// return, write data, and finish in a specific order in a unit test. One of
-// these must be created before using the SimRequest to issue requests.
+// these must be created before using the SimRequestBase to issue requests.
class SimNetwork final : public WebURLLoaderTestDelegate {
public:
SimNetwork();
~SimNetwork() override;
private:
- friend class SimRequest;
+ friend class SimRequestBase;
+ friend class SimSubresourceRequest;
static SimNetwork& Current();
void ServePendingRequests();
- void AddRequest(SimRequest&);
- void RemoveRequest(SimRequest&);
+ void AddRequest(SimRequestBase&);
+ void RemoveRequest(SimRequestBase&);
// WebURLLoaderTestDelegate
void DidReceiveResponse(WebURLLoaderClient*, const WebURLResponse&) override;
@@ -50,8 +51,8 @@ class SimNetwork final : public WebURLLoaderTestDelegate {
int64_t total_encoded_body_length,
int64_t total_decoded_body_length) override;
- SimRequest* current_request_;
- HashMap<String, SimRequest*> requests_;
+ SimRequestBase* current_request_;
+ HashMap<String, SimRequestBase*> requests_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_request.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_request.cc
index 29db248cf73..4d718251177 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_request.cc
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_request.cc
@@ -4,65 +4,69 @@
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
-#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/web_url_loader_client.h"
-#include "third_party/blink/public/platform/web_url_loader_mock_factory.h"
#include "third_party/blink/renderer/core/testing/sim/sim_network.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
namespace blink {
-SimRequest::SimRequest(String url, String mime_type)
+SimRequestBase::SimRequestBase(String url,
+ String mime_type,
+ bool start_immediately)
: url_(url),
+ mime_type_(mime_type),
+ start_immediately_(start_immediately),
+ started_(false),
client_(nullptr),
- total_encoded_data_length_(0),
- is_ready_(false) {
- KURL full_url(url);
- WebURLResponse response(full_url);
- response.SetMIMEType(mime_type);
- response.SetHTTPStatusCode(200);
- Platform::Current()->GetURLLoaderMockFactory()->RegisterURL(full_url,
- response, "");
+ total_encoded_data_length_(0) {
SimNetwork::Current().AddRequest(*this);
}
-SimRequest::~SimRequest() {
- DCHECK(!is_ready_);
+SimRequestBase::~SimRequestBase() {
+ DCHECK(!client_);
}
-void SimRequest::DidReceiveResponse(WebURLLoaderClient* client,
- const WebURLResponse& response) {
+void SimRequestBase::DidReceiveResponse(WebURLLoaderClient* client,
+ const WebURLResponse& response) {
client_ = client;
response_ = response;
- is_ready_ = true;
+ started_ = false;
+ if (start_immediately_)
+ StartInternal();
}
-void SimRequest::DidFail(const WebURLError& error) {
+void SimRequestBase::DidFail(const WebURLError& error) {
error_ = error;
}
-void SimRequest::Start() {
- SimNetwork::Current().ServePendingRequests();
- DCHECK(is_ready_);
+void SimRequestBase::StartInternal() {
+ DCHECK(!started_);
+ started_ = true;
client_->DidReceiveResponse(response_);
}
-void SimRequest::Write(const String& data) {
- DCHECK(is_ready_);
+void SimRequestBase::Write(const String& data) {
+ if (!started_)
+ ServePending();
+ DCHECK(started_);
DCHECK(!error_);
total_encoded_data_length_ += data.length();
client_->DidReceiveData(data.Utf8().data(), data.length());
}
-void SimRequest::Write(const Vector<char>& data) {
- DCHECK(is_ready_);
+void SimRequestBase::Write(const Vector<char>& data) {
+ if (!started_)
+ ServePending();
+ DCHECK(started_);
DCHECK(!error_);
total_encoded_data_length_ += data.size();
client_->DidReceiveData(data.data(), data.size());
}
-void SimRequest::Finish() {
- DCHECK(is_ready_);
+void SimRequestBase::Finish() {
+ if (!started_)
+ ServePending();
+ DCHECK(started_);
if (error_) {
client_->DidFail(*error_, total_encoded_data_length_,
total_encoded_data_length_, total_encoded_data_length_);
@@ -76,26 +80,49 @@ void SimRequest::Finish() {
Reset();
}
-void SimRequest::Complete(const String& data) {
- Start();
+void SimRequestBase::Complete(const String& data) {
+ if (!started_)
+ ServePending();
+ if (!started_)
+ StartInternal();
if (!data.IsEmpty())
Write(data);
Finish();
}
-void SimRequest::Complete(const Vector<char>& data) {
- Start();
+void SimRequestBase::Complete(const Vector<char>& data) {
+ if (!started_)
+ ServePending();
+ if (!started_)
+ StartInternal();
if (!data.IsEmpty())
Write(data);
Finish();
}
-void SimRequest::Reset() {
- is_ready_ = false;
+void SimRequestBase::Reset() {
+ started_ = false;
client_ = nullptr;
- Platform::Current()->GetURLLoaderMockFactory()->UnregisterURL(KURL(url_));
-
SimNetwork::Current().RemoveRequest(*this);
}
+void SimRequestBase::ServePending() {
+ SimNetwork::Current().ServePendingRequests();
+}
+
+SimRequest::SimRequest(String url, String mime_type)
+ : SimRequestBase(url, mime_type, true /* start_immediately */) {}
+
+SimRequest::~SimRequest() = default;
+
+SimSubresourceRequest::SimSubresourceRequest(String url, String mime_type)
+ : SimRequestBase(url, mime_type, false /* start_immediately */) {}
+
+SimSubresourceRequest::~SimSubresourceRequest() = default;
+
+void SimSubresourceRequest::Start() {
+ ServePending();
+ StartInternal();
+}
+
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_request.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_request.h
index 073d0dccafe..e757460d5c0 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_request.h
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_request.h
@@ -8,6 +8,7 @@
#include "base/optional.h"
#include "third_party/blink/public/platform/web_url_error.h"
#include "third_party/blink/public/platform/web_url_response.h"
+#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
@@ -17,18 +18,11 @@ class SimNetwork;
class WebURLLoaderClient;
// Simulates a single request for a resource from the server. Requires a
-// SimNetwork to have been created first. Use the start(), write() and finish()
-// methods to simulate the response from the server. Note that all started
-// requests must be finished.
-class SimRequest final {
+// SimNetwork to have been created first. Use the Write(), Finish() and
+// Complete() methods to simulate the response from the server.
+// Note that all requests must be finished.
+class SimRequestBase {
public:
- SimRequest(String url, String mime_type);
- ~SimRequest();
-
- // Starts the response from the server, this is as if the headers and 200 OK
- // reply had been received but no response body yet.
- void Start();
-
// Write a chunk of the response body.
void Write(const String& data);
void Write(const Vector<char>& data);
@@ -40,8 +34,12 @@ class SimRequest final {
void Complete(const String& data = String());
void Complete(const Vector<char>& data);
- const String& Url() const { return url_; }
- const WebURLResponse& GetResponse() const { return response_; }
+ protected:
+ SimRequestBase(String url, String mime_type, bool start_immediately);
+ ~SimRequestBase();
+
+ void StartInternal();
+ void ServePending();
private:
friend class SimNetwork;
@@ -52,12 +50,36 @@ class SimRequest final {
void DidReceiveResponse(WebURLLoaderClient*, const WebURLResponse&);
void DidFail(const WebURLError&);
- String url_;
+ KURL url_;
+ String mime_type_;
+ bool start_immediately_;
+ bool started_;
WebURLResponse response_;
base::Optional<WebURLError> error_;
WebURLLoaderClient* client_;
unsigned total_encoded_data_length_;
- bool is_ready_;
+};
+
+// This request can be used as a main resource request for navigation.
+// It does not allow starting asynchronously, because that's not how
+// navigations work in reality.
+// TODO(dgozman): rename this to SimNavigationRequest or something.
+class SimRequest final : public SimRequestBase {
+ public:
+ SimRequest(String url, String mime_type);
+ ~SimRequest();
+};
+
+// This request can be started asynchronously, suited for simulating
+// delayed load of subresources.
+class SimSubresourceRequest final : public SimRequestBase {
+ public:
+ SimSubresourceRequest(String url, String mime_type);
+ ~SimSubresourceRequest();
+
+ // Starts the response from the server, this is as if the headers and 200 OK
+ // reply had been received but no response body yet.
+ void Start();
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_test.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_test.cc
index ab8aff7cf46..3414e80c210 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_test.cc
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_test.cc
@@ -11,6 +11,7 @@
#include "third_party/blink/renderer/core/exported/web_view_impl.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
+#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/web_test_support.h"
@@ -18,11 +19,10 @@
namespace blink {
SimTest::SimTest()
- : web_frame_client_(*this),
- // SimCompositor overrides the LayerTreeViewDelegate to respond to
- // BeginMainFrame(), which will update and paint the WebViewImpl given to
- // SetWebView().
- web_view_client_(&compositor_) {
+ : // SimCompositor overrides the LayerTreeViewDelegate to respond to
+ // BeginMainFrame(), which will update and paint the main frame of the
+ // WebViewImpl given to SetWebView().
+ web_widget_client_(&compositor_) {
Document::SetThreadedParsingEnabledForTesting(false);
// Use the mock theme to get more predictable code paths, this also avoids
// the OS callbacks in ScrollAnimatorMac which can schedule frames
@@ -55,17 +55,22 @@ SimTest::~SimTest() {
void SimTest::SetUp() {
Test::SetUp();
- web_view_helper_.Initialize(&web_frame_client_, &web_view_client_);
- compositor_.SetWebView(WebView(), *web_view_client_.layer_tree_view());
+ web_view_helper_.Initialize(&web_frame_client_, &web_view_client_,
+ &web_widget_client_);
+ compositor_.SetWebView(WebView(), *web_widget_client_.layer_tree_view(),
+ web_view_client_, web_widget_client_);
page_.SetPage(WebView().GetPage());
}
-void SimTest::LoadURL(const String& url) {
- WebURLRequest request{KURL(url)};
- WebView().MainFrameImpl()->CommitNavigation(
- request, WebFrameLoadType::kStandard, WebHistoryItem(), false,
- base::UnguessableToken::Create(), nullptr /* navigation_params */,
- nullptr /* extra_data */);
+void SimTest::LoadURL(const String& url_string) {
+ KURL url(url_string);
+ frame_test_helpers::LoadFrameDontWait(WebView().MainFrameImpl(), url);
+ if (DocumentLoader::WillLoadUrlAsEmpty(url) || url.ProtocolIsData()) {
+ // Empty documents and data urls are not using mocked out SimRequests,
+ // but instead load data directly.
+ frame_test_helpers::PumpPendingRequestsForFrameToLoad(
+ WebView().MainFrameImpl());
+ }
}
LocalDOMWindow& SimTest::Window() {
@@ -88,22 +93,24 @@ WebLocalFrameImpl& SimTest::MainFrame() {
return *WebView().MainFrameImpl();
}
-const SimWebViewClient& SimTest::WebViewClient() const {
+frame_test_helpers::TestWebViewClient& SimTest::WebViewClient() {
return web_view_client_;
}
-SimCompositor& SimTest::Compositor() {
- return compositor_;
+frame_test_helpers::TestWebWidgetClient& SimTest::WebWidgetClient() {
+ return web_widget_client_;
+}
+
+frame_test_helpers::TestWebFrameClient& SimTest::WebFrameClient() {
+ return web_frame_client_;
}
-void SimTest::SetEffectiveConnectionTypeForTesting(
- WebEffectiveConnectionType effective_connection_type) {
- web_frame_client_.SetEffectiveConnectionTypeForTesting(
- effective_connection_type);
+SimCompositor& SimTest::Compositor() {
+ return compositor_;
}
-void SimTest::AddConsoleMessage(const String& message) {
- console_messages_.push_back(message);
+Vector<String>& SimTest::ConsoleMessages() {
+ return web_frame_client_.ConsoleMessages();
}
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_test.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_test.h
index 1d446c0bdad..fc3f6dc848c 100644
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_test.h
+++ b/chromium/third_party/blink/renderer/core/testing/sim/sim_test.h
@@ -11,8 +11,6 @@
#include "third_party/blink/renderer/core/testing/sim/sim_compositor.h"
#include "third_party/blink/renderer/core/testing/sim/sim_network.h"
#include "third_party/blink/renderer/core/testing/sim/sim_page.h"
-#include "third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h"
-#include "third_party/blink/renderer/core/testing/sim/sim_web_view_client.h"
namespace blink {
@@ -38,26 +36,21 @@ class SimTest : public testing::Test {
Document& GetDocument();
WebViewImpl& WebView();
WebLocalFrameImpl& MainFrame();
- const SimWebViewClient& WebViewClient() const;
+ frame_test_helpers::TestWebViewClient& WebViewClient();
+ frame_test_helpers::TestWebWidgetClient& WebWidgetClient();
+ frame_test_helpers::TestWebFrameClient& WebFrameClient();
SimCompositor& Compositor();
- Vector<String>& ConsoleMessages() { return console_messages_; }
-
- void SetEffectiveConnectionTypeForTesting(WebEffectiveConnectionType);
+ Vector<String>& ConsoleMessages();
private:
- friend class SimWebFrameClient;
-
- void AddConsoleMessage(const String&);
-
SimNetwork network_;
SimCompositor compositor_;
- SimWebFrameClient web_frame_client_;
- SimWebViewClient web_view_client_;
+ frame_test_helpers::TestWebFrameClient web_frame_client_;
+ frame_test_helpers::TestWebWidgetClient web_widget_client_;
+ frame_test_helpers::TestWebViewClient web_view_client_;
SimPage page_;
frame_test_helpers::WebViewHelper web_view_helper_;
-
- Vector<String> console_messages_;
};
} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc
deleted file mode 100644
index 9ede2eb44a9..00000000000
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-#include "third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h"
-
-#include "third_party/blink/public/web/web_console_message.h"
-#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
-
-namespace blink {
-
-SimWebFrameClient::SimWebFrameClient(SimTest& test)
- : test_(&test),
- effective_connection_type_(WebEffectiveConnectionType::kTypeUnknown) {}
-
-void SimWebFrameClient::DidAddMessageToConsole(const WebConsoleMessage& message,
- const WebString& source_name,
- unsigned source_line,
- const WebString& stack_trace) {
- test_->AddConsoleMessage(message.text);
-}
-
-WebEffectiveConnectionType SimWebFrameClient::GetEffectiveConnectionType() {
- return effective_connection_type_;
-}
-
-void SimWebFrameClient::SetEffectiveConnectionTypeForTesting(
- WebEffectiveConnectionType effective_connection_type) {
- effective_connection_type_ = effective_connection_type;
-}
-
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h
deleted file mode 100644
index c18530954fa..00000000000
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_frame_client.h
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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.
-
-#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_FRAME_CLIENT_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_FRAME_CLIENT_H_
-
-#include "third_party/blink/public/platform/web_effective_connection_type.h"
-#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
-#include "third_party/blink/renderer/core/testing/fake_web_plugin.h"
-
-namespace blink {
-
-class SimTest;
-
-class SimWebFrameClient final : public frame_test_helpers::TestWebFrameClient {
- public:
- explicit SimWebFrameClient(SimTest&);
-
- // WebLocalFrameClient overrides:
- void DidAddMessageToConsole(const WebConsoleMessage&,
- const WebString& source_name,
- unsigned source_line,
- const WebString& stack_trace) override;
-
- WebEffectiveConnectionType GetEffectiveConnectionType() override;
- void SetEffectiveConnectionTypeForTesting(
- WebEffectiveConnectionType) override;
-
- WebPlugin* CreatePlugin(const WebPluginParams& params) override {
- return new FakeWebPlugin(params);
- }
-
- private:
- SimTest* test_;
- WebEffectiveConnectionType effective_connection_type_;
-};
-
-} // namespace blink
-
-#endif
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc b/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc
deleted file mode 100644
index f4d26638ed2..00000000000
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2015 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 "third_party/blink/renderer/core/testing/sim/sim_web_view_client.h"
-
-#include "third_party/blink/public/web/web_local_frame.h"
-
-namespace blink {
-
-SimWebViewClient::SimWebViewClient(content::LayerTreeViewDelegate* delegate)
- : frame_test_helpers::TestWebViewClient(delegate) {}
-
-void SimWebViewClient::DidMeaningfulLayout(
- WebMeaningfulLayout meaningful_layout) {
- switch (meaningful_layout) {
- case WebMeaningfulLayout::kVisuallyNonEmpty:
- visually_non_empty_layout_count_++;
- break;
- case WebMeaningfulLayout::kFinishedParsing:
- finished_parsing_layout_count_++;
- break;
- case WebMeaningfulLayout::kFinishedLoading:
- finished_loading_layout_count_++;
- break;
- }
-}
-
-WebView* SimWebViewClient::CreateView(WebLocalFrame* opener,
- const WebURLRequest&,
- const WebWindowFeatures&,
- const WebString& name,
- WebNavigationPolicy,
- bool,
- WebSandboxFlags,
- const SessionStorageNamespaceId&) {
- return web_view_helper_.InitializeWithOpener(opener);
-}
-
-} // namespace blink
diff --git a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h b/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h
deleted file mode 100644
index c38e6a7b735..00000000000
--- a/chromium/third_party/blink/renderer/core/testing/sim/sim_web_view_client.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2015 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 THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_VIEW_CLIENT_H_
-#define THIRD_PARTY_BLINK_RENDERER_CORE_TESTING_SIM_SIM_WEB_VIEW_CLIENT_H_
-
-#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
-
-namespace blink {
-
-class SimWebViewClient final : public frame_test_helpers::TestWebViewClient {
- public:
- explicit SimWebViewClient(content::LayerTreeViewDelegate* delegate);
-
- int VisuallyNonEmptyLayoutCount() const {
- return visually_non_empty_layout_count_;
- }
- int FinishedParsingLayoutCount() const {
- return finished_parsing_layout_count_;
- }
- int FinishedLoadingLayoutCount() const {
- return finished_loading_layout_count_;
- }
-
- // WebViewClient implementation.
- WebView* CreateView(WebLocalFrame* opener,
- const WebURLRequest&,
- const WebWindowFeatures&,
- const WebString& name,
- WebNavigationPolicy,
- bool,
- WebSandboxFlags,
- const SessionStorageNamespaceId&) override;
-
- private:
- // WebWidgetClient overrides.
- void DidMeaningfulLayout(WebMeaningfulLayout) override;
-
- int visually_non_empty_layout_count_ = 0;
- int finished_parsing_layout_count_ = 0;
- int finished_loading_layout_count_ = 0;
-
- frame_test_helpers::WebViewHelper web_view_helper_;
-};
-
-} // namespace blink
-
-#endif
diff --git a/chromium/third_party/blink/renderer/core/testing/v8/web_core_test_support.cc b/chromium/third_party/blink/renderer/core/testing/v8/web_core_test_support.cc
index 71933f2ffab..f8aca2875f8 100644
--- a/chromium/third_party/blink/renderer/core/testing/v8/web_core_test_support.cc
+++ b/chromium/third_party/blink/renderer/core/testing/v8/web_core_test_support.cc
@@ -92,7 +92,7 @@ void InstallOriginTrialFeaturesForTesting(
ExecutionContext* execution_context = ExecutionContext::From(script_state);
- if (type == &V8OriginTrialsTest::wrapper_type_info) {
+ if (type == V8OriginTrialsTest::GetWrapperTypeInfo()) {
if (origin_trials::OriginTrialsSampleAPIEnabled(execution_context)) {
V8OriginTrialsTest::InstallOriginTrialsSampleAPI(
script_state->GetIsolate(), script_state->World(),
@@ -136,7 +136,7 @@ void InstallPendingOriginTrialFeatureForTesting(
if (feature == origin_trials::kOriginTrialsSampleAPITrialName) {
if (script_state->PerContextData()
->GetExistingConstructorAndPrototypeForType(
- &V8OriginTrialsTest::wrapper_type_info, &prototype_object,
+ V8OriginTrialsTest::GetWrapperTypeInfo(), &prototype_object,
&interface_object)) {
V8OriginTrialsTest::InstallOriginTrialsSampleAPI(
script_state->GetIsolate(), script_state->World(),
@@ -147,7 +147,7 @@ void InstallPendingOriginTrialFeatureForTesting(
if (feature == origin_trials::kOriginTrialsSampleAPIImpliedTrialName) {
if (script_state->PerContextData()
->GetExistingConstructorAndPrototypeForType(
- &V8OriginTrialsTest::wrapper_type_info, &prototype_object,
+ V8OriginTrialsTest::GetWrapperTypeInfo(), &prototype_object,
&interface_object)) {
V8OriginTrialsTest::InstallOriginTrialsSampleAPIImplied(
script_state->GetIsolate(), script_state->World(),