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