Skip to content

Commit

Permalink
Dev tools Network and Performance (#7212)
Browse files Browse the repository at this point in the history
Expose CDP primitives for Network and Performance domains.
  • Loading branch information
adiohana authored and shs96c committed May 20, 2019
1 parent a8e1a2b commit 6d4ebac
Show file tree
Hide file tree
Showing 72 changed files with 7,068 additions and 60 deletions.
14 changes: 14 additions & 0 deletions common/src/web/postForm.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html>
<body>

<form method="post" action="resultPage.html">
<select id="redirect" name="redirect" onchange="javascript:changePage();">
<option selected="selected" value="one">One</option>
<option id="changeme" value="two">Two</option>
</select>

<input type="submit" />
</form>

</body>
</html>
5 changes: 3 additions & 2 deletions java/client/src/org/openqa/selenium/devtools/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
java_library(
name = "devtools",
srcs = glob(["*.java"]),
srcs = glob(["**/*.java"]),
deps = [
"//java/client/src/org/openqa/selenium:selenium",
"//java/client/src/org/openqa/selenium/json:json",
Expand All @@ -9,5 +9,6 @@ java_library(
],
visibility = [
"//java/client/src/org/openqa/selenium/remote:",
"//java/client/test/...",
],
)
)
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/devtools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
java_library(
name = "devtools",
srcs = glob(["*.java"]),
srcs = glob(["**/*.java"]),
visibility = [
"//java/client/src/org/openqa/selenium/chrome:__pkg__",
"//java/client/src/org/openqa/selenium/remote:__pkg__",
Expand Down
1 change: 0 additions & 1 deletion java/client/src/org/openqa/selenium/devtools/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.lang.reflect.Type;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.function.Function;

public class Command<X> {
Expand Down
4 changes: 4 additions & 0 deletions java/client/src/org/openqa/selenium/devtools/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ private static Timestamp fromJson(long timestamp) {
return new Timestamp(timestamp);
}

public static Timestamp fromJson(Number timestamp) {
return fromJson(timestamp.longValue());
}

private long toJson() {
return epochMillis;
}
Expand Down
611 changes: 611 additions & 0 deletions java/client/src/org/openqa/selenium/devtools/network/Network.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// 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.devtools.network.model;

import static java.util.Objects.requireNonNull;

import org.openqa.selenium.json.JsonInput;

public class AuthChallenge {

/**
* Origin of the challenger.
*/
private String origin;
/**
* The realm of the challenge. May be empty.
*/
private String realm;
/**
* The authentication scheme used, such as basic or digest
*/
private String scheme;
/**
* Source of the authentication challenge.
* Optional
*/
private Source source;

public static AuthChallenge parseRequest(JsonInput input) {
AuthChallenge authChallenge = new AuthChallenge();
input.beginObject();
while (input.hasNext()){
switch (input.nextName()) {
case "origin" :
authChallenge.setOrigin(input.nextString());
break;
case "realm" :
authChallenge.setRealm(input.nextString());
break;
case "scheme" :
authChallenge.setScheme(input.nextString());
break;
case "source" :
authChallenge.setSource(Source.getSource(input.nextString()));
break;
default:
input.skipValue();
break;
}
}
input.endObject();
return authChallenge;
}


public String getScheme() {
return scheme;
}

private void setScheme(String scheme) {
requireNonNull(origin, "'scheme' is mandatory for AuthChallenge");
this.scheme = scheme;
}

public String getOrigin() {
return origin;
}

public void setOrigin(String origin) {
requireNonNull(origin, "'origin' is mandatory for AuthChallenge");
this.origin = origin;
}

public String getRealm() {
return realm;
}

private void setRealm(String realm) {
requireNonNull(origin, "'realm' is mandatory for AuthChallenge");
this.realm = realm;
}

public Source getSource() {
return source;
}

public void setSource(Source source) {
this.source = source;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// 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.devtools.network.model;

import java.util.Objects;

/**
* Response to an AuthChallenge
*/
public class AuthChallengeResponse {

/**
* The decision on what to do in response to the authorization challenge. Default means deferring to the default behavior of the net stack,
* which will likely either the Cancel authentication or display a popup dialog box
*/
private final String response;

/**
* The username to provide, possibly empty. Should only be set if response is ProvideCredentials
*/
private final String username;

/**
* The password to provide, possibly empty. Should only be set if response is ProvideCredentials
*/
private final String password;

public AuthChallengeResponse(String response, String username, String password) {
this.response = Objects.requireNonNull(response, "response must be set.");
this.username = username;
this.password = password;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AuthChallengeResponse that = (AuthChallengeResponse) o;
return Objects.equals(response, that.response) &&
Objects.equals(username, that.username) &&
Objects.equals(password, that.password);
}

@Override
public int hashCode() {

return Objects.hash(response, username, password);
}

@Override
public String toString() {
return "AuthChallengeResponse{" +
"response='" + response + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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.devtools.network.model;

/**
* The reason why request was blocked
*/
public enum BlockedReason {

other("other"),
csp("csp"),
mixedContent("mixed-content"),
origin("origin"),
inspector("inspector"),
subresourceFilter("subresource-filter"),
contentType("content-type"),
collapsedbyClient("collapsed-by-client");

private String reason;

BlockedReason(String reason) {
this.reason = reason;
}

public String getReason() {
return reason;
}

public static BlockedReason fromString(String s) {
for (BlockedReason b : BlockedReason.values()) {
if (b.getReason().equalsIgnoreCase(s)) {
return b;
}
}
return null;
}

}
Loading

0 comments on commit 6d4ebac

Please sign in to comment.