| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "content/public/common/content_switches.h" | 7 #include "content/public/common/content_switches.h" |
| 8 #include "content/public/test/render_view_test.h" | 8 #include "content/public/test/render_view_test.h" |
| 9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
| 10 #include "gin/handle.h" | 10 #include "gin/handle.h" |
| 11 #include "gin/per_isolate_data.h" | 11 #include "gin/per_isolate_data.h" |
| 12 #include "gin/wrappable.h" | 12 #include "gin/wrappable.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/WebKit/public/web/WebFrame.h" | |
| 15 #include "third_party/WebKit/public/web/WebKit.h" | 14 #include "third_party/WebKit/public/web/WebKit.h" |
| 15 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 16 #include "third_party/WebKit/public/web/WebView.h" | 16 #include "third_party/WebKit/public/web/WebView.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class TestGinObject : public gin::Wrappable<TestGinObject> { | 22 class TestGinObject : public gin::Wrappable<TestGinObject> { |
| 23 public: | 23 public: |
| 24 static gin::WrapperInfo kWrapperInfo; | 24 static gin::WrapperInfo kWrapperInfo; |
| 25 | 25 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Test that garbage collection doesn't crash if a gin-wrapped object is | 58 // Test that garbage collection doesn't crash if a gin-wrapped object is |
| 59 // present. | 59 // present. |
| 60 TEST_F(GinBrowserTest, GinAndGarbageCollection) { | 60 TEST_F(GinBrowserTest, GinAndGarbageCollection) { |
| 61 LoadHTML("<!doctype html>"); | 61 LoadHTML("<!doctype html>"); |
| 62 | 62 |
| 63 bool alive = false; | 63 bool alive = false; |
| 64 | 64 |
| 65 { | 65 { |
| 66 v8::Isolate* isolate = blink::MainThreadIsolate(); | 66 v8::Isolate* isolate = blink::MainThreadIsolate(); |
| 67 v8::HandleScope handle_scope(isolate); | 67 v8::HandleScope handle_scope(isolate); |
| 68 v8::Context::Scope context_scope( | 68 v8::Context::Scope context_scope(GetMainFrame()->MainWorldScriptContext()); |
| 69 view_->GetWebView()->MainFrame()->MainWorldScriptContext()); | |
| 70 | 69 |
| 71 // We create the object inside a scope so it's not kept alive by a handle | 70 // We create the object inside a scope so it's not kept alive by a handle |
| 72 // on the stack. | 71 // on the stack. |
| 73 TestGinObject::Create(isolate, &alive); | 72 TestGinObject::Create(isolate, &alive); |
| 74 } | 73 } |
| 75 | 74 |
| 76 CHECK(alive); | 75 CHECK(alive); |
| 77 | 76 |
| 78 // Should not crash. | 77 // Should not crash. |
| 79 blink::MainThreadIsolate()->LowMemoryNotification(); | 78 blink::MainThreadIsolate()->LowMemoryNotification(); |
| 80 | 79 |
| 81 CHECK(!alive); | 80 CHECK(!alive); |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace | 83 } // namespace |
| 85 | 84 |
| 86 } // namespace content | 85 } // namespace content |
| OLD | NEW |