Beispiel #1
0
Response InspectorEmulationAgent::setTouchEmulationEnabled(
    bool enabled,
    Maybe<String> configuration) {
  m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled);
  webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled);
  return Response::OK();
}
WebViewImpl* WebViewHelper::initializeAndLoad(const std::string& url, bool enableJavascript, WebFrameClient* webFrameClient, WebViewClient* webViewClient, void (*updateSettingsFunc)(WebSettings*))
{
    initialize(enableJavascript, webFrameClient, webViewClient, updateSettingsFunc);

    loadFrame(webView()->mainFrame(), url);
    Platform::current()->unitTestSupport()->serveAsynchronousMockedRequests();

    return webViewImpl();
}
Beispiel #3
0
Response InspectorEmulationAgent::forceViewport(double x,
                                                double y,
                                                double scale) {
  if (x < 0 || y < 0)
    return Response::Error("Coordinates must be non-negative");

  if (scale <= 0)
    return Response::Error("Scale must be positive");

  m_state->setBoolean(EmulationAgentState::forcedViewportEnabled, true);
  m_state->setDouble(EmulationAgentState::forcedViewportX, x);
  m_state->setDouble(EmulationAgentState::forcedViewportY, y);
  m_state->setDouble(EmulationAgentState::forcedViewportScale, scale);

  webViewImpl()->devToolsEmulator()->forceViewport(WebFloatPoint(x, y), scale);
  return Response::OK();
}
TEST_F(ScrollingCoordinatorTest, fastScrollingCanBeDisabledWithSetting)
{
    navigateTo("about:blank");
    webViewImpl()->settings()->setThreadedScrollingEnabled(false);
    forceFullCompositingUpdate();

    // Make sure the scrolling coordinator is active.
    FrameView* frameView = frame()->view();
    Page* page = frame()->page();
    ASSERT_TRUE(page->scrollingCoordinator());
    ASSERT_TRUE(page->scrollingCoordinator()->coordinatesScrollingForFrameView(frameView));

    // Main scrolling should be enabled with the setting override.
    WebLayer* rootScrollLayer = getRootScrollLayer();
    ASSERT_TRUE(rootScrollLayer->scrollable());
    ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread());
}
TEST_F(ScrollingCoordinatorTest, fractionalScrollingNonLayerFixedPosition)
{
    registerMockedHttpURLLoad("fractional-scroll-fixed-position.html");
    navigateTo(m_baseURL + "fractional-scroll-fixed-position.html");
    // Prevent fixed-position element from getting its own layer.
    webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false);
    forceFullCompositingUpdate();

    FrameView* frameView = frame()->view();
    frameView->scrollTo(DoublePoint(1.5, 1.5));
    WebLayer* rootScrollLayer = getRootScrollLayer();
    // Scroll on main if there is non-composited fixed position element.
    // And the containing scroll layer should not get fractional scroll offset.
    ASSERT_TRUE(rootScrollLayer->shouldScrollOnMainThread());
    ASSERT_EQ(1.0, rootScrollLayer->scrollPositionDouble().x);
    ASSERT_EQ(1.0, rootScrollLayer->scrollPositionDouble().y);
    ASSERT_EQ(0.0, rootScrollLayer->position().x);
    ASSERT_EQ(0.0, rootScrollLayer->position().y);
}
TEST_F(ScrollingCoordinatorTest, FixedPositionLosingBackingShouldTriggerMainThreadScroll)
{
    webViewImpl()->settings()->setPreferCompositingToLCDTextEnabled(false);
    registerMockedHttpURLLoad("fixed-position-losing-backing.html");
    navigateTo(m_baseURL + "fixed-position-losing-backing.html");
    forceFullCompositingUpdate();

    WebLayer* scrollLayer = frame()->page()->deprecatedLocalMainFrame()->view()->layerForScrolling()->platformLayer();
    Document* document = frame()->document();
    Element* fixedPos = document->getElementById("fixed");

    EXPECT_TRUE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->layer()->hasCompositedLayerMapping());
    EXPECT_FALSE(scrollLayer->shouldScrollOnMainThread());

    fixedPos->setInlineStyleProperty(CSSPropertyTransform, CSSValueNone);
    forceFullCompositingUpdate();

    EXPECT_FALSE(static_cast<LayoutBoxModelObject*>(fixedPos->layoutObject())->layer()->hasCompositedLayerMapping());
    EXPECT_TRUE(scrollLayer->shouldScrollOnMainThread());
}
void InspectorEmulationAgent::setScriptExecutionDisabled(ErrorString*, bool value)
{
    m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value);
    webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value);
}
void InspectorEmulationAgent::setPageScaleFactor(ErrorString*, double pageScaleFactor)
{
    webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor));
}
void InspectorEmulationAgent::resetPageScaleFactor(ErrorString*)
{
    webViewImpl()->resetScaleStateImmediately();
}
 void forceFullCompositingUpdate() {
   webViewImpl()->updateAllLifecyclePhases();
 }
 void navigateTo(const String& url) {
   FrameTestHelpers::loadFrame(webViewImpl()->mainFrame(), url.utf8().data());
 }
 void SetUp() override {
   m_helper.initialize(true, nullptr, &m_mockWebViewClient, nullptr,
                       &configureSettings);
   webViewImpl()->resize(IntSize(320, 240));
 }
void InspectorEmulationAgent::setTouchEmulationEnabled(ErrorString*, bool enabled, const Maybe<String>& configuration)
{
    m_state->setBoolean(EmulationAgentState::touchEventEmulationEnabled, enabled);
    webViewImpl()->devToolsEmulator()->setTouchEventEmulationEnabled(enabled);
}
Beispiel #14
0
Response InspectorEmulationAgent::setEmulatedMedia(const String& media) {
  m_state->setString(EmulationAgentState::emulatedMedia, media);
  webViewImpl()->page()->settings().setMediaTypeOverride(media);
  return Response::OK();
}
Beispiel #15
0
Response InspectorEmulationAgent::resetPageScaleFactor() {
  webViewImpl()->resetScaleStateImmediately();
  return Response::OK();
}
Beispiel #16
0
Response InspectorEmulationAgent::setScriptExecutionDisabled(bool value) {
  m_state->setBoolean(EmulationAgentState::scriptExecutionDisabled, value);
  webViewImpl()->devToolsEmulator()->setScriptExecutionDisabled(value);
  return Response::OK();
}
Beispiel #17
0
Response InspectorEmulationAgent::setPageScaleFactor(double pageScaleFactor) {
  webViewImpl()->setPageScaleFactor(static_cast<float>(pageScaleFactor));
  return Response::OK();
}
void InspectorEmulationAgent::setEmulatedMedia(ErrorString*, const String& media)
{
    m_state->setString(EmulationAgentState::emulatedMedia, media);
    webViewImpl()->page()->settings().setMediaTypeOverride(media);
}
Beispiel #19
0
Response InspectorEmulationAgent::resetViewport() {
  m_state->setBoolean(EmulationAgentState::forcedViewportEnabled, false);
  webViewImpl()->devToolsEmulator()->resetViewport();
  return Response::OK();
}