OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/canvas/HTMLCanvasElementModule.h" |
| 6 |
| 7 #include "core/frame/FrameView.h" |
| 8 #include "core/html/HTMLCanvasElement.h" |
| 9 #include "core/html/HTMLDocument.h" |
| 10 #include "core/loader/EmptyClients.h" |
| 11 #include "core/testing/DummyPageHolder.h" |
| 12 #include "modules/offscreencanvas/OffscreenCanvas.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class HTMLCanvasElementModuleTest : public ::testing::Test { |
| 18 protected: |
| 19 virtual void SetUp() |
| 20 { |
| 21 Page::PageClients pageClients; |
| 22 fillWithEmptyClients(pageClients); |
| 23 OwnPtr<DummyPageHolder> m_dummyPageHolder = DummyPageHolder::create(IntS
ize(800, 600), &pageClients); |
| 24 RefPtrWillBePersistent<HTMLDocument> m_document = toHTMLDocument(&m_dumm
yPageHolder->document()); |
| 25 m_document->documentElement()->setInnerHTML("<body><canvas id='c'></canv
as></body>", ASSERT_NO_EXCEPTION); |
| 26 m_document->view()->updateAllLifecyclePhases(); |
| 27 m_canvasElement = toHTMLCanvasElement(m_document->getElementById("c")); |
| 28 } |
| 29 |
| 30 HTMLCanvasElement& canvasElement() const { return *m_canvasElement; } |
| 31 private: |
| 32 RefPtrWillBePersistent<HTMLCanvasElement> m_canvasElement; |
| 33 }; |
| 34 |
| 35 TEST_F(HTMLCanvasElementModuleTest, TransferControlToOffscreen) |
| 36 { |
| 37 NonThrowableExceptionState exceptionState; |
| 38 OffscreenCanvas* offscreenCanvas = HTMLCanvasElementModule::transferControlT
oOffscreen(canvasElement(), exceptionState); |
| 39 HTMLCanvasElement* canvas = offscreenCanvas->getAssociatedCanvas(); |
| 40 EXPECT_EQ(canvas, canvasElement()); |
| 41 } |
| 42 |
| 43 } // namespace blink |
OLD | NEW |