@@ -428,7 +428,20 @@ pub fn BrowserContext(comptime CDP_T: type) type {
428428
429429 pub fn createIsolatedWorld (self : * Self , world_name : []const u8 , grant_universal_access : bool ) ! * IsolatedWorld {
430430 if (self .isolated_world != null ) {
431- return error .CurrentlyOnly1IsolatedWorldSupported ;
431+ // if the two world have different names, be safe and return an
432+ // error.
433+ if (std .mem .eql (u8 , self .isolated_world .? .name , world_name ) == false ) {
434+ return error .CurrentlyOnly1IsolatedWorldSupported ;
435+ }
436+
437+ // If the two worlds have the same name, reuse the existing one
438+ // but send a warning.
439+ log .warn (.cdp , "not implemented" , .{
440+ .feature = "createIsolatedWorld: Not implemented second isolated world creation" ,
441+ .info = "reuse existing isolated world with the same name" ,
442+ .world_name = world_name ,
443+ });
444+ return & self .isolated_world .? ;
432445 }
433446
434447 var executor = try self .cdp .browser .env .newExecutionWorld ();
@@ -682,7 +695,14 @@ const IsolatedWorld = struct {
682695 // This also means this pointer becomes invalid after removePage untill a new page is created.
683696 // Currently we have only 1 page/frame and thus also only 1 state in the isolate world.
684697 pub fn createContext (self : * IsolatedWorld , page : * Page ) ! void {
685- if (self .executor .js_context != null ) return error .Only1IsolatedContextSupported ;
698+ // if (self.executor.js_context != null) return error.Only1IsolatedContextSupported;
699+ if (self .executor .js_context != null ) {
700+ log .warn (.cdp , "not implemented" , .{
701+ .feature = "createContext: Not implemented second isolated context creation" ,
702+ .info = "reuse existing context" ,
703+ });
704+ return ;
705+ }
686706 _ = try self .executor .createJsContext (
687707 & page .window ,
688708 page ,
0 commit comments