-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
10 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
java/client/src/org/openqa/selenium/devtools/inspector/Inspector.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,43 @@ | ||
// 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.inspector; | ||
|
||
import static org.openqa.selenium.devtools.ConverterFunctions.map; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
|
||
import org.openqa.selenium.Beta; | ||
import org.openqa.selenium.devtools.Command; | ||
import org.openqa.selenium.devtools.Event; | ||
|
||
@Beta | ||
public class Inspector { | ||
|
||
/** Enables inspector domain notifications. */ | ||
public static Command<Void> enable() { | ||
return new Command<>("Inspector.enable", ImmutableMap.of()); | ||
} | ||
|
||
/** Disables inspector domain notifications. */ | ||
public static Command<Void> disable() { | ||
return new Command<>("Inspector.disable", ImmutableMap.of()); | ||
} | ||
/** Fired when remote debugging connection is about to be terminated. Contains detach reason. */ | ||
public static Event<String> detached() { | ||
return new Event<>("Inspector.detached", map("reason", String.class)); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
java/client/test/org/openqa/selenium/devtools/ChromeDevToolsInspectorTest.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,52 @@ | ||
// 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; | ||
|
||
import static org.openqa.selenium.devtools.inspector.Inspector.detached; | ||
import static org.openqa.selenium.devtools.inspector.Inspector.disable; | ||
import static org.openqa.selenium.devtools.inspector.Inspector.enable; | ||
import static org.openqa.selenium.devtools.target.Target.attachToTarget; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.openqa.selenium.devtools.target.Target; | ||
import org.openqa.selenium.devtools.target.model.SessionId; | ||
import org.openqa.selenium.devtools.target.model.TargetInfo; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class ChromeDevToolsInspectorTest extends DevToolsTestBase { | ||
@Test | ||
public void inspectDetached() { | ||
devTools.addListener(detached(), Assert::assertNotNull); | ||
devTools.send(enable()); | ||
List<TargetInfo> targetInfos = devTools.send(Target.getTargets()); | ||
targetInfos.stream() | ||
.forEach( | ||
targetInfo -> { | ||
SessionId sessionId = | ||
devTools.send(attachToTarget(targetInfo.getTargetId(), Optional.of(false))); | ||
devTools.send( | ||
Target.sendMessageToTarget( | ||
"{\"method\":\"Page.crash\"}", | ||
Optional.of(sessionId), | ||
Optional.of(targetInfo.getTargetId()))); | ||
}); | ||
devTools.send(disable()); | ||
} | ||
} |
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