Skip to content

Commit 98ff133

Browse files
authored
Merge branch 'trunk' into dotnet-cdp-readme
2 parents 2a93a1e + 7c9f000 commit 98ff133

File tree

26 files changed

+4387
-1187
lines changed

26 files changed

+4387
-1187
lines changed

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ rules_closure_toolchains()
3434

3535
http_archive(
3636
name = "rules_rust",
37-
integrity = "sha256-JLN47ZcAbx9wEr5Jiib4HduZATGLiDgK7oUi/fvotzU=",
38-
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.42.1/rules_rust-v0.42.1.tar.gz"],
37+
integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
38+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
3939
)
4040

4141
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

dotnet/src/webdriver/PrintOptions.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,27 @@ public bool ShrinkToFit
101101
}
102102

103103
/// <summary>
104-
/// Gets the dimensions for each page in the printed document.
104+
/// Gets or sets the dimensions for each page in the printed document.
105105
/// </summary>
106106
public PageSize PageDimensions
107107
{
108108
get { return pageSize; }
109+
set
110+
{
111+
pageSize = value ?? throw new ArgumentNullException(nameof(value));
112+
}
109113
}
110114

111115
/// <summary>
112-
/// Gets the margins for each page in the doucment.
116+
/// Gets or sets the margins for each page in the doucment.
113117
/// </summary>
114118
public Margins PageMargins
115119
{
116120
get { return margins; }
121+
set
122+
{
123+
margins = value ?? throw new ArgumentNullException(nameof(value));
124+
}
117125
}
118126

119127
/// <summary>

dotnet/test/common/DriverTestFixture.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public abstract class DriverTestFixture
8888
public string scrollFrameOutOfViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html");
8989
public string scrollFrameInViewport = EnvironmentManager.Instance.UrlBuilder.WhereIs("scrolling_tests/frame_with_nested_scrolling_frame.html");
9090

91+
public string printPage = EnvironmentManager.Instance.UrlBuilder.WhereIs("printPage.html");
92+
9193
protected IWebDriver driver;
9294

9395
public IWebDriver DriverInstance

dotnet/test/common/PrintTest.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using NUnit.Framework;
2+
using System;
3+
4+
namespace OpenQA.Selenium
5+
{
6+
[TestFixture]
7+
public class PrintTest : DriverTestFixture
8+
{
9+
private const string MagicString = "JVBER";
10+
private ISupportsPrint printer;
11+
12+
[SetUp]
13+
public void LocalSetUp()
14+
{
15+
Assert.That(driver, Is.InstanceOf<ISupportsPrint>(), $"Driver does not support {nameof(ISupportsPrint)}.");
16+
17+
printer = driver as ISupportsPrint;
18+
19+
driver.Navigate().GoToUrl(this.printPage);
20+
}
21+
22+
[Test]
23+
public void CanPrintPage()
24+
{
25+
var pdf = printer.Print(new PrintOptions());
26+
27+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
28+
}
29+
30+
[Test]
31+
public void CanPrintTwoPages()
32+
{
33+
var options = new PrintOptions();
34+
35+
options.AddPageRangeToPrint("1-2");
36+
37+
var pdf = printer.Print(options);
38+
39+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
40+
}
41+
42+
[Test]
43+
public void CanPrintWithMostParams()
44+
{
45+
var options = new PrintOptions()
46+
{
47+
Orientation = PrintOrientation.Landscape,
48+
ScaleFactor = 0.5,
49+
PageDimensions = new PrintOptions.PageSize { Width = 200, Height = 100 },
50+
PageMargins = new PrintOptions.Margins { Top = 1, Bottom = 1, Left = 2, Right = 2 },
51+
OutputBackgroundImages = true,
52+
ShrinkToFit = false
53+
};
54+
55+
options.AddPageRangeToPrint("1-3");
56+
57+
var pdf = printer.Print(options);
58+
59+
Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString));
60+
}
61+
62+
[Test]
63+
public void PageSizeCannotBeNull()
64+
{
65+
Assert.That(() => new PrintOptions { PageDimensions = null }, Throws.InstanceOf<ArgumentNullException>());
66+
}
67+
68+
[Test]
69+
public void MarginsCannotBeNull()
70+
{
71+
Assert.That(() => new PrintOptions { PageMargins = null }, Throws.InstanceOf<ArgumentNullException>());
72+
}
73+
}
74+
}

java/spotbugs-excludes.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,30 @@
204204
<Class name="org.openqa.selenium.remote.internal.WebElementToJsonConverter" />
205205
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
206206
</Match>
207+
208+
<Match>
209+
<Class name="org.openqa.selenium.chrome.AddHasCasting" />
210+
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
211+
</Match>
212+
213+
<Match>
214+
<Class name="org.openqa.selenium.chrome.AddHasCdp" />
215+
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
216+
</Match>
217+
218+
<Match>
219+
<Class name="org.openqa.selenium.edge.AddHasCdp" />
220+
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
221+
</Match>
222+
223+
<Match>
224+
<Class name="org.openqa.selenium.edge.AddHasCasting" />
225+
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
226+
</Match>
227+
228+
<Match>
229+
<Class name="~org.openqa.selenium.devtools.v[0-9]+\.v\w+" />
230+
<Bug pattern="NM_CLASS_NAMING_CONVENTION"/>
231+
</Match>
232+
207233
</FindBugsFilter>

java/src/org/openqa/selenium/chromium/ChromiumDriver.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ public ScriptKey pin(String script) {
212212
// Create the actual script we're going to use.
213213
String scriptToUse =
214214
String.format(
215-
"window.seleniumPinnedScript%s = function(){%s}", Math.abs(script.hashCode()), script);
215+
"window.seleniumPinnedScript%s = function(){%s}",
216+
Math.abs((long) script.hashCode()), script);
216217

217218
DevTools devTools = getDevTools();
218219
devTools.createSessionIfThereIsNotOne();

java/src/org/openqa/selenium/devtools/v127/v127Network.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedRe
127127
} catch (DevToolsException e) {
128128
// Redirects don't seem to have bodies
129129
int code = pausedReq.getResponseStatusCode().orElse(HTTP_OK);
130-
if (code < 300 && code > 399) {
130+
if (code >= 300 && code <= 399) {
131131
LOG.warning("Unable to get body for request id " + pausedReq.getRequestId());
132132
}
133133

java/src/org/openqa/selenium/devtools/v128/v128Network.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedRe
127127
} catch (DevToolsException e) {
128128
// Redirects don't seem to have bodies
129129
int code = pausedReq.getResponseStatusCode().orElse(HTTP_OK);
130-
if (code < 300 && code > 399) {
130+
if (code >= 300 && code <= 399) {
131131
LOG.warning("Unable to get body for request id " + pausedReq.getRequestId());
132132
}
133133

java/src/org/openqa/selenium/devtools/v129/v129Network.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedRe
127127
} catch (DevToolsException e) {
128128
// Redirects don't seem to have bodies
129129
int code = pausedReq.getResponseStatusCode().orElse(HTTP_OK);
130-
if (code < 300 && code > 399) {
130+
if (code >= 300 && code <= 399) {
131131
LOG.warning("Unable to get body for request id " + pausedReq.getRequestId());
132132
}
133133

java/src/org/openqa/selenium/devtools/v85/V85Network.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public Either<HttpRequest, HttpResponse> createSeMessages(RequestPaused pausedRe
137137
} catch (DevToolsException e) {
138138
// Redirects don't seem to have bodies
139139
int code = pausedReq.getResponseStatusCode().orElse(HTTP_OK);
140-
if (code < 300 && code > 399) {
140+
if (code >= 300 && code <= 399) {
141141
LOG.warning("Unable to get body for request id " + pausedReq.getRequestId());
142142
}
143143

0 commit comments

Comments
 (0)