| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/dom/ScriptRunner.h" | 5 #include "core/dom/ScriptRunner.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/HTMLScriptElementOrSVGScriptElement.h" | 7 #include "core/dom/MockScriptElementBase.h" |
| 8 #include "core/dom/Document.h" | |
| 9 #include "core/dom/ScriptLoader.h" | 8 #include "core/dom/ScriptLoader.h" |
| 10 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 11 #include "platform/testing/TestingPlatformSupport.h" | 10 #include "platform/testing/TestingPlatformSupport.h" |
| 12 #include "public/platform/Platform.h" | 11 #include "public/platform/Platform.h" |
| 13 #include "public/platform/WebViewScheduler.h" | 12 #include "public/platform/WebViewScheduler.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 using ::testing::Invoke; | 16 using ::testing::Invoke; |
| 18 using ::testing::ElementsAre; | 17 using ::testing::ElementsAre; |
| 19 using ::testing::Return; | 18 using ::testing::Return; |
| 20 using ::testing::WhenSorted; | 19 using ::testing::WhenSorted; |
| 21 using ::testing::ElementsAreArray; | 20 using ::testing::ElementsAreArray; |
| 22 | 21 |
| 23 namespace blink { | 22 namespace blink { |
| 24 | 23 |
| 25 class MockScriptElementBase | |
| 26 : public GarbageCollectedFinalized<MockScriptElementBase>, | |
| 27 public ScriptElementBase { | |
| 28 USING_GARBAGE_COLLECTED_MIXIN(MockScriptElementBase); | |
| 29 | |
| 30 public: | |
| 31 static MockScriptElementBase* Create() { | |
| 32 return new testing::StrictMock<MockScriptElementBase>(); | |
| 33 } | |
| 34 | |
| 35 MOCK_METHOD0(DispatchLoadEvent, void()); | |
| 36 MOCK_METHOD0(DispatchErrorEvent, void()); | |
| 37 MOCK_CONST_METHOD0(AsyncAttributeValue, bool()); | |
| 38 MOCK_CONST_METHOD0(CharsetAttributeValue, String()); | |
| 39 MOCK_CONST_METHOD0(CrossOriginAttributeValue, String()); | |
| 40 MOCK_CONST_METHOD0(DeferAttributeValue, bool()); | |
| 41 MOCK_CONST_METHOD0(EventAttributeValue, String()); | |
| 42 MOCK_CONST_METHOD0(ForAttributeValue, String()); | |
| 43 MOCK_CONST_METHOD0(IntegrityAttributeValue, String()); | |
| 44 MOCK_CONST_METHOD0(LanguageAttributeValue, String()); | |
| 45 MOCK_CONST_METHOD0(SourceAttributeValue, String()); | |
| 46 MOCK_CONST_METHOD0(TypeAttributeValue, String()); | |
| 47 | |
| 48 MOCK_METHOD0(TextFromChildren, String()); | |
| 49 MOCK_CONST_METHOD0(TextContent, String()); | |
| 50 MOCK_CONST_METHOD0(HasSourceAttribute, bool()); | |
| 51 MOCK_CONST_METHOD0(IsConnected, bool()); | |
| 52 MOCK_CONST_METHOD0(HasChildren, bool()); | |
| 53 MOCK_CONST_METHOD0(IsNonceableElement, bool()); | |
| 54 MOCK_CONST_METHOD0(InitiatorName, AtomicString()); | |
| 55 MOCK_METHOD3(AllowInlineScriptForCSP, | |
| 56 bool(const AtomicString&, | |
| 57 const WTF::OrdinalNumber&, | |
| 58 const String&)); | |
| 59 MOCK_CONST_METHOD0(GetDocument, Document&()); | |
| 60 MOCK_METHOD1(SetScriptElementForBinding, | |
| 61 void(HTMLScriptElementOrSVGScriptElement&)); | |
| 62 | |
| 63 DEFINE_INLINE_VIRTUAL_TRACE() { ScriptElementBase::Trace(visitor); } | |
| 64 }; | |
| 65 | |
| 66 class MockScriptLoader final : public ScriptLoader { | 24 class MockScriptLoader final : public ScriptLoader { |
| 67 public: | 25 public: |
| 68 static MockScriptLoader* Create() { return new MockScriptLoader(); } | 26 static MockScriptLoader* Create() { return new MockScriptLoader(); } |
| 69 ~MockScriptLoader() override {} | 27 ~MockScriptLoader() override {} |
| 70 | 28 |
| 71 MOCK_METHOD0(Execute, void()); | 29 MOCK_METHOD0(Execute, void()); |
| 72 MOCK_CONST_METHOD0(IsReady, bool()); | 30 MOCK_CONST_METHOD0(IsReady, bool()); |
| 73 | 31 |
| 74 private: | 32 private: |
| 75 explicit MockScriptLoader() | 33 explicit MockScriptLoader() |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 422 |
| 465 // m_scriptRunner is gone. We need to make sure that ScriptRunner::Task do not | 423 // m_scriptRunner is gone. We need to make sure that ScriptRunner::Task do not |
| 466 // access dead object. | 424 // access dead object. |
| 467 EXPECT_CALL(*script_loader1, Execute()).Times(0); | 425 EXPECT_CALL(*script_loader1, Execute()).Times(0); |
| 468 EXPECT_CALL(*script_loader2, Execute()).Times(0); | 426 EXPECT_CALL(*script_loader2, Execute()).Times(0); |
| 469 | 427 |
| 470 platform_->RunUntilIdle(); | 428 platform_->RunUntilIdle(); |
| 471 } | 429 } |
| 472 | 430 |
| 473 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |