Remove unnecessary_ignore and fixed the AsyncXHR client (#340)
* Fix workflow permissions for publish.yaml
diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml
index afe5935..b0388b4 100644
--- a/.github/workflows/publish.yaml
+++ b/.github/workflows/publish.yaml
@@ -17,5 +17,8 @@
publish:
if: ${{ github.repository_owner == 'google' }}
uses: dart-lang/ecosystem/.github/workflows/publish.yaml@main
+ permissions:
+ id-token: write
+ pull-requests: write
with:
write-comments: false
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 97e1b77..442efbf 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -26,6 +26,7 @@
- prefer_expression_function_bodies
- prefer_final_locals
- unnecessary_breaks
+ - unnecessary_ignore
- use_enums
- use_if_null_to_convert_nulls_to_bools
- use_raw_strings
diff --git a/lib/src/async/web_driver.dart b/lib/src/async/web_driver.dart
index 4d039fb..26e9b0a 100644
--- a/lib/src/async/web_driver.dart
+++ b/lib/src/async/web_driver.dart
@@ -25,10 +25,7 @@
import '../common/utils.dart';
import '../common/webdriver_handler.dart';
import 'common.dart';
-// ignore: uri_does_not_exist
-import 'common_stub.dart'
-// ignore: uri_does_not_exist
- if (dart.library.io) 'common_io.dart';
+import 'common_stub.dart' if (dart.library.io) 'common_io.dart';
import 'cookies.dart';
import 'keyboard.dart';
import 'logs.dart';
diff --git a/lib/src/common/capabilities.dart b/lib/src/common/capabilities.dart
index 89504e8..c2708c5 100644
--- a/lib/src/common/capabilities.dart
+++ b/lib/src/common/capabilities.dart
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// ignore: avoid_classes_with_only_static_members
/// Capabilities constants.
+// ignore: avoid_classes_with_only_static_members
class Capabilities {
static const String browserName = 'browserName';
static const String browserVersion = 'browserVersion';
diff --git a/lib/src/request/async_xhr_request_client.dart b/lib/src/request/async_xhr_request_client.dart
index d5ada7d..380654a 100644
--- a/lib/src/request/async_xhr_request_client.dart
+++ b/lib/src/request/async_xhr_request_client.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:js_interop';
import 'package:web/web.dart' as web;
@@ -36,8 +37,12 @@
sendData: request.body,
mimeType: 'application/json',
);
- } on web.ProgressEvent catch (e) {
- httpRequest = e.target as web.XMLHttpRequest;
+ } catch (e) {
+ if (e.isA<web.ProgressEvent>()) {
+ httpRequest = (e as web.ProgressEvent).target as web.XMLHttpRequest;
+ } else {
+ rethrow;
+ }
} finally {
_lock.release();
}
diff --git a/lib/src/sync/web_driver.dart b/lib/src/sync/web_driver.dart
index 6b5e0db..fe9d6fd 100644
--- a/lib/src/sync/web_driver.dart
+++ b/lib/src/sync/web_driver.dart
@@ -23,10 +23,7 @@
import '../common/utils.dart';
import '../common/webdriver_handler.dart';
import 'common.dart';
-// ignore: uri_does_not_exist
-import 'common_stub.dart'
-// ignore: uri_does_not_exist
- if (dart.library.io) 'common_io.dart';
+import 'common_stub.dart' if (dart.library.io) 'common_io.dart';
import 'cookies.dart';
import 'keyboard.dart';
import 'logs.dart';
diff --git a/lib/src/sync/web_element.dart b/lib/src/sync/web_element.dart
index 473cc2e..ff193ef 100644
--- a/lib/src/sync/web_element.dart
+++ b/lib/src/sync/web_element.dart
@@ -20,10 +20,7 @@
import '../common/web_element.dart' as common;
import '../common/webdriver_handler.dart';
import 'common.dart';
-// ignore: uri_does_not_exist
-import 'common_stub.dart'
-// ignore: uri_does_not_exist
- if (dart.library.io) 'common_io.dart';
+import 'common_stub.dart' if (dart.library.io) 'common_io.dart';
import 'web_driver.dart';
/// WebDriver representation and interactions with an HTML element.
diff --git a/test/async_logs_test.dart b/test/async_logs_test.dart
index 758d3a1..6ea738a 100644
--- a/test/async_logs_test.dart
+++ b/test/async_logs_test.dart
@@ -26,7 +26,6 @@
setUp(() async {
final capabilities = <String, dynamic>{
- // ignore: deprecated_member_use_from_same_package
Capabilities.loggingPrefs: {LogType.performance: LogLevel.info}
};
diff --git a/test/async_web_driver_test.dart b/test/async_web_driver_test.dart
index dbec4c9..383cc1e 100644
--- a/test/async_web_driver_test.dart
+++ b/test/async_web_driver_test.dart
@@ -153,7 +153,6 @@
});
test('captureScreenshot', () async {
- // ignore: deprecated_member_use_from_same_package
final screenshot = await driver.captureScreenshot().toList();
expect(screenshot, hasLength(isPositive));
expect(screenshot, everyElement(isA<int>()));
diff --git a/test/support/firefox_profile_test.dart b/test/support/firefox_profile_test.dart
index c885141..60fa1d1 100644
--- a/test/support/firefox_profile_test.dart
+++ b/test/support/firefox_profile_test.dart
@@ -126,7 +126,6 @@
test('encode/decode "user.js" in-memory', () {
final profile = FirefoxProfile();
- // ignore: deprecated_member_use_from_same_package
profile.setOption(PrefsOption(Capabilities.hasNativeEvents, true));
final zipArchive = unpackArchiveData(profile.toJson());
@@ -148,7 +147,6 @@
prefs,
anyElement(
(PrefsOption o) =>
- // ignore: deprecated_member_use_from_same_package
o.name == Capabilities.hasNativeEvents && o.value == true,
),
);
@@ -157,7 +155,6 @@
test('encode/decode profile directory from disk', () {
final profile = FirefoxProfile(
profileDirectory: io.Directory('test/support/firefox_profile'));
- // ignore: deprecated_member_use_from_same_package
profile.setOption(PrefsOption(Capabilities.hasNativeEvents, true));
final zipArchive = unpackArchiveData(profile.toJson());
@@ -186,7 +183,6 @@
prefs,
anyElement(
(PrefsOption o) =>
- // ignore: deprecated_member_use_from_same_package
o.name == Capabilities.hasNativeEvents && o.value == true,
),
);
diff --git a/test/sync/logs.dart b/test/sync/logs.dart
index c4d5690..7e91e3a 100644
--- a/test/sync/logs.dart
+++ b/test/sync/logs.dart
@@ -26,7 +26,6 @@
setUp(() async {
final capabilities = <String, dynamic>{
- // ignore: deprecated_member_use_from_same_package
Capabilities.loggingPrefs: {LogType.performance: LogLevel.info}
};