A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/20d68b39634c1a9b9e9248f9a7b51bd7df9a6d11 below:

[java][cdp] Keep track of pinned scripts per CDP session (#11598) · SeleniumHQ/selenium@20d68b3 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+12

-5

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+12

-5

lines changed Original file line number Diff line number Diff line change

@@ -20,6 +20,7 @@

20 20

import org.openqa.selenium.devtools.Command;

21 21

import org.openqa.selenium.devtools.DevTools;

22 22

import org.openqa.selenium.devtools.Event;

23 +

import org.openqa.selenium.devtools.idealized.target.model.SessionID;

23 24

import org.openqa.selenium.internal.Require;

24 25 25 26

import java.util.HashMap;

@@ -31,7 +32,7 @@

31 32

public abstract class Javascript<SCRIPTID, BINDINGCALLED> {

32 33 33 34

private final DevTools devtools;

34 -

private final Map<String, ScriptId> pinnedScripts = new HashMap<>();

35 +

private final Map<SessionID, Map<String, ScriptId>> pinnedScripts = new HashMap<>();

35 36

private final Set<String> bindings = new HashSet<>();

36 37 37 38

public Javascript(DevTools devtools) {

@@ -42,7 +43,8 @@ public void disable() {

42 43

devtools.send(disableRuntime());

43 44

devtools.send(disablePage());

44 45 45 -

pinnedScripts.values().forEach(id -> removeScriptToEvaluateOnNewDocument(id.getActualId()));

46 +

pinnedScripts.forEach((sessionID, scriptIdMap) -> scriptIdMap.values()

47 +

.forEach(id -> removeScriptToEvaluateOnNewDocument(id.getActualId())));

46 48 47 49

pinnedScripts.clear();

48 50

}

@@ -55,8 +57,11 @@ public ScriptId pin(String exposeScriptAs, String script) {

55 57

Require.nonNull("Script name", exposeScriptAs);

56 58

Require.nonNull("Script", script);

57 59 58 -

if (pinnedScripts.containsKey(script)) {

59 -

return pinnedScripts.get(script);

60 +

if (pinnedScripts.containsKey(devtools.getCdpSession())) {

61 +

Map<String, ScriptId> scripts = pinnedScripts.get(devtools.getCdpSession());

62 +

if (scripts.containsKey(script)) {

63 +

return scripts.get(script);

64 +

}

60 65

}

61 66 62 67

devtools.send(enableRuntime());

@@ -68,7 +73,9 @@ public ScriptId pin(String exposeScriptAs, String script) {

68 73

SCRIPTID id = devtools.send(addScriptToEvaluateOnNewDocument(script));

69 74

ScriptId scriptId = new ScriptId(id);

70 75 71 -

pinnedScripts.put(script, scriptId);

76 +

Map<String, ScriptId> scripts = pinnedScripts.getOrDefault(devtools.getCdpSession(), new HashMap<>());

77 +

scripts.put(script, scriptId);

78 +

pinnedScripts.put(devtools.getCdpSession(), scripts);

72 79 73 80

return scriptId;

74 81

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4