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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp

Issue 2848653003: Add a DevTools command to create an isolated world for a given frame (Closed)
Patch Set: Changed so we don't pass in the id Created 3 years, 8 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: third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
index 8f03da4fe08d79e3a69f87743a86a5ce465c4aad..a3b05cb65202906b239b01a79cc2075f763fbd3b 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp
@@ -60,6 +60,7 @@
#include "platform/instrumentation/tracing/TraceEvent.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "platform/wtf/CurrentTime.h"
+#include "platform/wtf/HashSet.h"
#include "platform/wtf/StdLibExtras.h"
#include "platform/wtf/StringExtras.h"
#include "platform/wtf/text/CString.h"
@@ -371,4 +372,29 @@ void ScriptController::ExecuteScriptInIsolatedWorld(
}
}
+int ScriptController::CreateNewIsolatedWorld(const String& world_name) {
+ // Find an unused id, unfortunately there doesn't seem to be a better way of
+ // doing this because DOMWrapperWorld::Create doesn't support isolated worlds.
+ Vector<RefPtr<DOMWrapperWorld>> worlds;
+ DOMWrapperWorld::AllWorldsInCurrentThread(worlds);
+ WTF::HashSet<int> existingWorlds;
+ for (const auto& world : worlds) {
+ if (!world->IsIsolatedWorld())
+ continue;
+ existingWorlds.insert(world->GetWorldId());
+ }
+ int world_id = 1;
caseq 2017/04/28 21:41:30 I think allocating ids like this is going to bring
Sami 2017/05/02 09:47:19 Is there some registry of world ids? Should we jus
alex clarke (OOO till 29th) 2017/05/02 10:00:06 OK do you have any suggestions for what else we mi
+ while (existingWorlds.Contains(world_id)) {
+ world_id++;
+ }
+ DCHECK_LT(world_id, DOMWrapperWorld::kEmbedderWorldIdLimit);
+ RefPtr<DOMWrapperWorld> world =
+ DOMWrapperWorld::EnsureIsolatedWorld(GetIsolate(), world_id);
+
+ DOMWrapperWorld::SetIsolatedWorldHumanReadableName(world_id, world_name);
+ // Make sure the execution context exists.
+ WindowProxy(*world);
+ return world_id;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698