Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: third_party/WebKit/Source/core/dom/ScriptRunnerTest.cpp

Issue 1428883002: Oilpan: fix webkit unit tests following r356852. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "config.h" 5 #include "config.h"
6 #include "core/dom/ScriptRunner.h" 6 #include "core/dom/ScriptRunner.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/Element.h" 9 #include "core/dom/Element.h"
10 #include "core/dom/ScriptLoader.h" 10 #include "core/dom/ScriptLoader.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 class MockPlatform : public Platform, private WebScheduler { 97 class MockPlatform : public Platform, private WebScheduler {
98 public: 98 public:
99 MockPlatform() 99 MockPlatform()
100 : m_mockWebThread(this) 100 : m_mockWebThread(this)
101 , m_mockWebTaskRunner(&m_tasks) 101 , m_mockWebTaskRunner(&m_tasks)
102 { 102 {
103 } 103 }
104 104
105 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride { } 105 void cryptographicallyRandomValues(unsigned char* buffer, size_t length) ove rride { }
106 106
107 const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) o verride
108 {
109 static const unsigned char tracingIsDisabled = 0;
110 return &tracingIsDisabled;
111 }
112
107 WebThread* currentThread() override { return &m_mockWebThread; } 113 WebThread* currentThread() override { return &m_mockWebThread; }
108 114
109 WebTaskRunner* loadingTaskRunner() override 115 WebTaskRunner* loadingTaskRunner() override
110 { 116 {
111 return &m_mockWebTaskRunner; 117 return &m_mockWebTaskRunner;
112 } 118 }
113 119
114 WebTaskRunner* timerTaskRunner() override 120 WebTaskRunner* timerTaskRunner() override
115 { 121 {
116 ASSERT_NOT_REACHED(); 122 ASSERT_NOT_REACHED();
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 523
518 // At this moment all tasks can be already executed. Make sure that we do no t crash here. 524 // At this moment all tasks can be already executed. Make sure that we do no t crash here.
519 m_scriptRunner->notifyScriptReady(scriptLoader2.get(), ScriptRunner::IN_ORDE R_EXECUTION); 525 m_scriptRunner->notifyScriptReady(scriptLoader2.get(), ScriptRunner::IN_ORDE R_EXECUTION);
520 m_platform.runAllTasks(); 526 m_platform.runAllTasks();
521 527
522 EXPECT_THAT(m_order, ElementsAre(1, 2)); 528 EXPECT_THAT(m_order, ElementsAre(1, 2));
523 } 529 }
524 530
525 TEST_F(ScriptRunnerTest, TasksWithDeadScriptRunner) 531 TEST_F(ScriptRunnerTest, TasksWithDeadScriptRunner)
526 { 532 {
527 OwnPtrWillBeRawPtr<MockScriptLoader> scriptLoader1 = MockScriptLoader::creat e(m_element.get()); 533 OwnPtrWillBePersistent<MockScriptLoader> scriptLoader1 = MockScriptLoader::c reate(m_element.get());
528 OwnPtrWillBeRawPtr<MockScriptLoader> scriptLoader2 = MockScriptLoader::creat e(m_element.get()); 534 OwnPtrWillBePersistent<MockScriptLoader> scriptLoader2 = MockScriptLoader::c reate(m_element.get());
529 535
530 EXPECT_CALL(*scriptLoader1, isReady()).WillRepeatedly(Return(true)); 536 EXPECT_CALL(*scriptLoader1, isReady()).WillRepeatedly(Return(true));
531 EXPECT_CALL(*scriptLoader2, isReady()).WillRepeatedly(Return(true)); 537 EXPECT_CALL(*scriptLoader2, isReady()).WillRepeatedly(Return(true));
532 538
533 m_scriptRunner->queueScriptForExecution(scriptLoader1.get(), ScriptRunner::A SYNC_EXECUTION); 539 m_scriptRunner->queueScriptForExecution(scriptLoader1.get(), ScriptRunner::A SYNC_EXECUTION);
534 m_scriptRunner->queueScriptForExecution(scriptLoader2.get(), ScriptRunner::A SYNC_EXECUTION); 540 m_scriptRunner->queueScriptForExecution(scriptLoader2.get(), ScriptRunner::A SYNC_EXECUTION);
535 541
536 m_scriptRunner->notifyScriptReady(scriptLoader1.get(), ScriptRunner::ASYNC_E XECUTION); 542 m_scriptRunner->notifyScriptReady(scriptLoader1.get(), ScriptRunner::ASYNC_E XECUTION);
537 m_scriptRunner->notifyScriptReady(scriptLoader2.get(), ScriptRunner::ASYNC_E XECUTION); 543 m_scriptRunner->notifyScriptReady(scriptLoader2.get(), ScriptRunner::ASYNC_E XECUTION);
538 544
539 m_scriptRunner.release(); 545 m_scriptRunner.release();
540 546
547 #if ENABLE(OILPAN)
548 Heap::collectAllGarbage();
549 #endif
550
541 // m_scriptRunner is gone. We need to make sure that ScriptRunner::Task do n ot access dead object. 551 // m_scriptRunner is gone. We need to make sure that ScriptRunner::Task do n ot access dead object.
542 EXPECT_CALL(*scriptLoader1, execute()).Times(0); 552 EXPECT_CALL(*scriptLoader1, execute()).Times(0);
543 EXPECT_CALL(*scriptLoader2, execute()).Times(0); 553 EXPECT_CALL(*scriptLoader2, execute()).Times(0);
544 554
545 m_platform.runAllTasks(); 555 m_platform.runAllTasks();
546 } 556 }
547 557
548 } // namespace blink 558 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698