-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bidi][java] Add methods to allow all parameters for script callFunct…
…ion and evaluate method (#13873)
- Loading branch information
Showing
8 changed files
with
908 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
java/src/org/openqa/selenium/bidi/script/CallFunctionParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.script; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class CallFunctionParameters { | ||
|
||
private final Map<String, Object> map = new HashMap<>(); | ||
|
||
public CallFunctionParameters(Target target, String functionDeclaration, boolean awaitPromise) { | ||
map.put("target", target.toMap()); | ||
map.put("functionDeclaration", functionDeclaration); | ||
map.put("awaitPromise", awaitPromise); | ||
} | ||
|
||
public CallFunctionParameters arguments(List<LocalValue> arguments) { | ||
map.put("arguments", arguments); | ||
return this; | ||
} | ||
|
||
public CallFunctionParameters resultOwnership(ResultOwnership ownership) { | ||
map.put("resultOwnership", ownership.toString()); | ||
return this; | ||
} | ||
|
||
public CallFunctionParameters serializationOptions(SerializationOptions serializationOptions) { | ||
map.put("serializationOptions", serializationOptions.toJson()); | ||
return this; | ||
} | ||
|
||
public CallFunctionParameters thisParameter(LocalValue localValue) { | ||
map.put("this", localValue.toJson()); | ||
return this; | ||
} | ||
|
||
public CallFunctionParameters userActivation(boolean userActivation) { | ||
map.put("userActivation", userActivation); | ||
return this; | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
return map; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
java/src/org/openqa/selenium/bidi/script/ContextTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.script; | ||
|
||
public class ContextTarget extends Target { | ||
public ContextTarget(String id) { | ||
super.map.put("context", id); | ||
} | ||
|
||
public ContextTarget(String id, String sandbox) { | ||
super.map.put("context", id); | ||
super.map.put("sandbox", sandbox); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
java/src/org/openqa/selenium/bidi/script/EvaluateParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.script; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class EvaluateParameters { | ||
|
||
private final Map<String, Object> map = new HashMap<>(); | ||
|
||
public EvaluateParameters(Target target, String expression, boolean awaitPromise) { | ||
map.put("target", target.toMap()); | ||
map.put("expression", expression); | ||
map.put("awaitPromise", awaitPromise); | ||
} | ||
|
||
public EvaluateParameters resultOwnership(ResultOwnership ownership) { | ||
map.put("resultOwnership", ownership.toString()); | ||
return this; | ||
} | ||
|
||
public EvaluateParameters serializationOptions(SerializationOptions serializationOptions) { | ||
map.put("serializationOptions", serializationOptions.toJson()); | ||
return this; | ||
} | ||
|
||
public EvaluateParameters userActivation(boolean userActivation) { | ||
map.put("userActivation", userActivation); | ||
return this; | ||
} | ||
|
||
public Map<String, Object> toMap() { | ||
return map; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.script; | ||
|
||
public class RealmTarget extends Target { | ||
|
||
public RealmTarget(String id) { | ||
super.map.put("realm", id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.bidi.script; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class Target { | ||
protected final Map<String, Object> map = new HashMap<>(); | ||
|
||
public Map<String, Object> toMap() { | ||
return this.map; | ||
} | ||
} |
Oops, something went wrong.