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

Unified Diff: content/shell/renderer/layout_test/layout_test_content_renderer_client.cc

Issue 2402293002: Add a Javascript wrapper for InterfaceRegistry. (Closed)
Patch Set: Created 4 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/renderer/layout_test/layout_test_content_renderer_client.cc
diff --git a/content/shell/renderer/layout_test/layout_test_content_renderer_client.cc b/content/shell/renderer/layout_test/layout_test_content_renderer_client.cc
index 2fa9df9a9b55aeddad2fe02f0f139d4e7372d40d..11e0338cf6b5f2b4683d307e223274d074e65955 100644
--- a/content/shell/renderer/layout_test/layout_test_content_renderer_client.cc
+++ b/content/shell/renderer/layout_test/layout_test_content_renderer_client.cc
@@ -16,17 +16,20 @@
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_frame.h"
+#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h"
#include "content/public/test/layouttest_support.h"
#include "content/shell/common/layout_test/layout_test_switches.h"
#include "content/shell/common/shell_switches.h"
#include "content/shell/renderer/layout_test/blink_test_helpers.h"
#include "content/shell/renderer/layout_test/blink_test_runner.h"
+#include "content/shell/renderer/layout_test/interface_registry_js_wrapper.h"
#include "content/shell/renderer/layout_test/layout_test_render_frame_observer.h"
#include "content/shell/renderer/layout_test/layout_test_render_thread_observer.h"
#include "content/shell/renderer/layout_test/test_media_stream_renderer_factory.h"
#include "content/shell/renderer/shell_render_view_observer.h"
#include "content/test/mock_webclipboard_impl.h"
+#include "gin/modules/module_registry.h"
#include "ppapi/shared_impl/ppapi_switches.h"
#include "third_party/WebKit/public/platform/WebMediaStreamCenter.h"
#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerClient.h"
@@ -249,6 +252,33 @@ void LayoutTestContentRendererClient::DidInitializeWorkerContextOnWorkerThread(
blink::WebTestingSupport::injectInternalsObject(context);
}
+void LayoutTestContentRendererClient::RunScriptsAtDocumentEnd(
+ RenderFrame* render_frame) {
+ v8::Isolate* isolate = blink::mainThreadIsolate();
+ v8::HandleScope handle_scope(isolate);
+ blink::WebLocalFrame* frame = render_frame->GetWebFrame();
+ v8::Local<v8::Context> context = frame->mainWorldScriptContext();
+ v8::Context::Scope context_scope(context);
+
+ gin::ModuleRegistry* registry = gin::ModuleRegistry::From(context);
+ if (registry->available_modules().count(
+ InterfaceRegistryJsWrapper::kPerFrameModuleName)) {
+ return;
+ }
+
+ registry->AddBuiltinModule(
+ isolate, InterfaceRegistryJsWrapper::kPerFrameModuleName,
+ InterfaceRegistryJsWrapper::Create(isolate, context,
+ render_frame->GetInterfaceRegistry())
+ .ToV8());
+ registry->AddBuiltinModule(
+ isolate, InterfaceRegistryJsWrapper::kPerProcessModuleName,
+ InterfaceRegistryJsWrapper::Create(
+ isolate, context, RenderThread::Get()->GetInterfaceRegistry())
+ .ToV8());
+ registry->AttemptToLoadMoreModules(isolate);
+}
+
void LayoutTestContentRendererClient::
SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
// We always expose GC to layout tests.

Powered by Google App Engine
This is Rietveld 408576698