Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions dotnet/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ _logger.Debug("diagnostic: request details for debugging");
[Obsolete("Use NewMethod instead")]
public void OldMethod() { }
```
When code inside the assembly must still reference an obsolete member (e.g. a field
or method the obsolete API is built on), wrap just that usage to keep the build
warning-clean (see `UserPromptHandler.cs`):
```csharp
#pragma warning disable CS0618 // Type or member is obsolete
this.legacyThing.DoWork();
#pragma warning restore CS0618 // Type or member is obsolete
```

### Async patterns
The codebase is migrating to async
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/webdriver/Firefox/FirefoxExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace OpenQA.Selenium.Firefox;
/// <summary>
/// Provides the ability to install extensions into a <see cref="FirefoxProfile"/>.
/// </summary>
[Obsolete("Use FirefoxDriver.InstallAddOnFromFile instead.")]
public class FirefoxExtension
{
private const string EmNamespaceUri = "http://www.mozilla.org/2004/em-rdf#";
Expand Down
7 changes: 7 additions & 0 deletions dotnet/src/webdriver/Firefox/FirefoxProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public class FirefoxProfile
private readonly string? sourceProfileDir;
private readonly bool deleteSource;
private readonly Preferences profilePreferences;
#pragma warning disable CS0618 // Type or member is obsolete
private readonly Dictionary<string, FirefoxExtension> extensions = new Dictionary<string, FirefoxExtension>();
#pragma warning restore CS0618 // Type or member is obsolete

/// <summary>
/// Initializes a new instance of the <see cref="FirefoxProfile"/> class.
Expand Down Expand Up @@ -103,11 +105,14 @@ public static FirefoxProfile FromBase64String(string base64)
/// </summary>
/// <param name="extensionToInstall">The path to the new extension</param>
/// <exception cref="ArgumentNullException">If <paramref name="extensionToInstall"/> is <see langword="null"/>.</exception>
[Obsolete("Use FirefoxDriver.InstallAddOnFromFile instead.")]
public void AddExtension(string extensionToInstall)
{
ArgumentNullException.ThrowIfNull(extensionToInstall);

#pragma warning disable CS0618 // Type or member is obsolete
this.extensions.Add(Path.GetFileNameWithoutExtension(extensionToInstall), new FirefoxExtension(extensionToInstall));
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
Expand Down Expand Up @@ -236,10 +241,12 @@ private void DeleteLockFiles(string profileDirectory)
/// </summary>
private void InstallExtensions(string profileDirectory)
{
#pragma warning disable CS0618 // Type or member is obsolete
foreach (string extensionKey in this.extensions.Keys)
{
this.extensions[extensionKey].Install(profileDirectory);
}
#pragma warning restore CS0618 // Type or member is obsolete
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions java/src/org/openqa/selenium/firefox/ClasspathExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.FileHandler;

/**
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public class ClasspathExtension implements Extension {
private final Class<?> loadResourcesUsing;
private final String loadFrom;
Expand Down
4 changes: 4 additions & 0 deletions java/src/org/openqa/selenium/firefox/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import java.io.File;
import java.io.IOException;

/**
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public interface Extension {
void writeTo(File parentDirectory) throws IOException;
}
4 changes: 4 additions & 0 deletions java/src/org/openqa/selenium/firefox/FileExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
import org.w3c.dom.Document;
import org.w3c.dom.Node;

/**
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public class FileExtension implements Extension {
private static final String EM_NAMESPACE_URI = "http://www.mozilla.org/2004/em-rdf#";

Expand Down
22 changes: 22 additions & 0 deletions java/src/org/openqa/selenium/firefox/FirefoxProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public class FirefoxProfile {
private static final String ACCEPT_UNTRUSTED_CERTS_PREF = "webdriver_accept_untrusted_certs";
private static final String ASSUME_UNTRUSTED_ISSUER_PREF = "webdriver_assume_untrusted_issuer";
private final Preferences additionalPrefs;

@SuppressWarnings("deprecation")
private final Map<String, Extension> extensions = new HashMap<>();

private @Nullable final File model;
private boolean loadNoFocusLib;
private boolean acceptUntrustedCerts;
Expand Down Expand Up @@ -145,6 +148,10 @@ public boolean containsWebDriverExtension() {
return extensions.containsKey("webdriver");
}

/**
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public void addExtension(Class<?> loadResourcesUsing, String loadFrom) {
// Is loadFrom a file?
File file = new File(loadFrom);
Expand All @@ -160,11 +167,17 @@ public void addExtension(Class<?> loadResourcesUsing, String loadFrom) {
* Attempt to add an extension to install into this instance.
*
* @param extensionToInstall File pointing to the extension
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public void addExtension(File extensionToInstall) {
addExtension(extensionToInstall.getName(), new FileExtension(extensionToInstall));
}

/**
* @deprecated Use {@link HasExtensions#installExtension} instead.
*/
@Deprecated(forRemoval = true)
public void addExtension(String key, Extension extension) {
String name = deriveExtensionName(key);
extensions.put(name, extension);
Expand Down Expand Up @@ -248,7 +261,9 @@ public void deleteExtensionsCacheIfItExists(File profileDir) {
* even if native events are disabled.
*
* @return Whether the no focus library should always be loaded for Firefox on Linux.
* @deprecated Native events are no longer supported.
*/
@Deprecated(forRemoval = true)
public boolean shouldLoadNoFocusLib() {
return loadNoFocusLib;
}
Expand All @@ -257,7 +272,9 @@ public boolean shouldLoadNoFocusLib() {
* Sets whether the no focus library should always be loaded on Linux.
*
* @param loadNoFocusLib Whether to always load the no focus library.
* @deprecated Native events are no longer supported.
*/
@Deprecated(forRemoval = true)
public FirefoxProfile setAlwaysLoadNoFocusLib(boolean loadNoFocusLib) {
this.loadNoFocusLib = loadNoFocusLib;
return this;
Expand All @@ -268,7 +285,9 @@ public FirefoxProfile setAlwaysLoadNoFocusLib(boolean loadNoFocusLib) {
* authority or are generally untrusted. This is set to true by default.
*
* @param acceptUntrustedSsl Whether untrusted SSL certificates should be accepted.
* @deprecated Use {@link FirefoxOptions#setAcceptInsecureCerts(boolean)} instead.
*/
@Deprecated(forRemoval = true)
public FirefoxProfile setAcceptUntrustedCertificates(boolean acceptUntrustedSsl) {
this.acceptUntrustedCerts = acceptUntrustedSsl;
return this;
Expand All @@ -287,7 +306,9 @@ public FirefoxProfile setAcceptUntrustedCertificates(boolean acceptUntrustedSsl)
* production certificate served in a testing environment) set this to false.
*
* @param untrustedIssuer whether to assume untrusted issuer or not.
* @deprecated Use {@link FirefoxOptions#setAcceptInsecureCerts(boolean)} instead.
*/
@Deprecated(forRemoval = true)
public FirefoxProfile setAssumeUntrustedCertificateIssuer(boolean untrustedIssuer) {
this.untrustedCertIssuer = untrustedIssuer;
return this;
Expand Down Expand Up @@ -347,6 +368,7 @@ protected void copyModel(@Nullable File sourceDir, File profileDir) throws IOExc
FileHandler.copy(sourceDir, profileDir);
}

@SuppressWarnings("deprecation")
protected void installExtensions(File parentDir) throws IOException {
File extensionsDir = new File(parentDir, "extensions");

Expand Down
1 change: 1 addition & 0 deletions javascript/selenium-webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ class Options extends Capabilities {
*
* @param {...string} paths The paths to the extension XPI files to install.
* @return {!Options} A self reference.
* @deprecated Use {@link Driver#installAddon} instead.
*/
addExtensions(...paths) {
this.profile_().addExtensions(paths)
Expand Down
18 changes: 13 additions & 5 deletions rb/lib/selenium/webdriver/firefox/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class Profile
LOCK_FILES = %w[.parentlock parent.lock lock].freeze

attr_reader :name, :log_file
attr_writer :secure_ssl, :load_no_focus_lib

class << self
def ini
Expand Down Expand Up @@ -110,19 +109,28 @@ def []=(key, value)
end

def port=(port)
WebDriver.logger.deprecate('Firefox::Profile#port=', 'the Service class', id: :firefox_profile)
self[WEBDRIVER_PREFS[:port]] = port
end

def secure_ssl=(value)
WebDriver.logger.deprecate('Firefox::Profile#secure_ssl=', id: :firefox_profile)
@secure_ssl = value
end

def load_no_focus_lib=(value)
WebDriver.logger.deprecate('Firefox::Profile#load_no_focus_lib=', id: :firefox_profile)
@load_no_focus_lib = value
end

def log_file=(file)
@log_file = file
self[WEBDRIVER_PREFS[:log_file]] = file
end

#
# Add the extension (directory, .zip or .xpi) at the given path to the profile.
#

def add_extension(path, name = extension_name_for(path))
WebDriver.logger.deprecate('Firefox::Profile#add_extension', 'Driver#install_addon',
id: :firefox_profile)
@extensions[name] = Extension.new(path)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ module Firefox
end
end
end

it 'ships preferences from an existing profile directory' do
reset_driver!(profile: described_class.new(profile.layout_on_disk)) do |driver|
expect { wait(5).until { driver.find_element(id: 'oneline') } }.not_to raise_error
end
end
end
end # Firefox
end # WebDriver
Expand Down
22 changes: 0 additions & 22 deletions rb/spec/unit/selenium/webdriver/firefox/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,28 +122,6 @@ def read_generated_prefs(from = nil)

expect(read_generated_prefs).to include('user_pref("network.proxy.type", 4)')
end

it 'can install extension' do
firebug = File.expand_path('../../../../../../third_party/firebug/firebug-1.5.0-fx.xpi', __dir__)
profile.add_extension(firebug)
extension_directory = File.expand_path('extensions/firebug@software.joehewitt.com', profile.layout_on_disk)
expect(Dir.exist?(extension_directory)).to be(true)
end

it 'can install web extension without id' do
mooltipass = File.expand_path('../../../../../../third_party/firebug/mooltipass-1.1.87.xpi', __dir__)
profile.add_extension(mooltipass)
extension_directory = File.expand_path('extensions/MooltipassExtension@1.1.87', profile.layout_on_disk)
expect(Dir.exist?(extension_directory)).to be(true)
end

it 'can install web extension with id' do
ext = File.expand_path('../../../../../../third_party/firebug/favourite_colour-1.1-an+fx.xpi', __dir__)
profile.add_extension(ext)
extension_directory = File.expand_path('extensions/favourite-colour-examples@mozilla.org',
profile.layout_on_disk)
expect(Dir.exist?(extension_directory)).to be(true)
end
end
end # Firefox
end # WebDriver
Expand Down
Loading