From defca93e1a762bce396f57e1de04c4ccaf5ba3e7 Mon Sep 17 00:00:00 2001 From: Manuel Blanco Date: Wed, 11 Oct 2023 03:29:19 -0300 Subject: [PATCH] [java][bidi] Add validation for browsing context id (#12920) Co-authored-by: Diego Molina Co-authored-by: Titus Fortner Co-authored-by: Puja Jagani --- .../selenium/bidi/browsingcontext/BrowsingContext.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java index 2ef7538529394..a4d3864597644 100644 --- a/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java +++ b/java/src/org/openqa/selenium/bidi/browsingcontext/BrowsingContext.java @@ -76,6 +76,8 @@ public BrowsingContext(WebDriver driver, String id) { throw new IllegalArgumentException("WebDriver instance must support BiDi protocol"); } + Require.precondition(!id.isEmpty(), "Browsing Context id cannot be empty"); + this.bidi = ((HasBiDi) driver).getBiDi(); this.id = id; } @@ -94,6 +96,9 @@ public BrowsingContext(WebDriver driver, WindowType type) { public BrowsingContext(WebDriver driver, WindowType type, String referenceContextId) { Require.nonNull("WebDriver", driver); Require.nonNull("Reference browsing context id", referenceContextId); + + Require.precondition(!referenceContextId.isEmpty(), "Reference Context id cannot be empty"); + if (!(driver instanceof HasBiDi)) { throw new IllegalArgumentException("WebDriver instance must support BiDi protocol"); }