use raw strings to avoid escaping (#50322)
This commit is contained in:
committed by
GitHub
parent
8735ab1e35
commit
b953c3e5a8
@@ -212,17 +212,18 @@ class FlutterWebConnection {
|
||||
}
|
||||
|
||||
try {
|
||||
result = await waitFor<dynamic>(() => _driver.execute('r'
|
||||
'eturn \$flutterDriverResult', <String>[]),
|
||||
matcher: isNotNull,
|
||||
timeout: duration ?? const Duration(days: 30));
|
||||
result = await waitFor<dynamic>(
|
||||
() => _driver.execute(r'return $flutterDriverResult', <String>[]),
|
||||
matcher: isNotNull,
|
||||
timeout: duration ?? const Duration(days: 30),
|
||||
);
|
||||
} catch (_) {
|
||||
// Returns null if exception thrown.
|
||||
return null;
|
||||
} finally {
|
||||
// Resets the result.
|
||||
_driver.execute('''
|
||||
\$flutterDriverResult = null
|
||||
_driver.execute(r'''
|
||||
$flutterDriverResult = null
|
||||
''', <void>[]);
|
||||
}
|
||||
return result;
|
||||
@@ -243,7 +244,7 @@ class FlutterWebConnection {
|
||||
/// Waits until extension is installed.
|
||||
Future<void> waitUntilExtensionInstalled(sync_io.WebDriver driver, Duration timeout) async {
|
||||
await waitFor<void>(() =>
|
||||
driver.execute('return typeof(window.\$flutterDriver)', <String>[]),
|
||||
driver.execute(r'return typeof(window.$flutterDriver)', <String>[]),
|
||||
matcher: 'function',
|
||||
timeout: timeout ?? const Duration(days: 365));
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ import 'dart:js_util' as js_util;
|
||||
///
|
||||
/// * [_extension_io.dart], which has the dart:io implementation
|
||||
void registerWebServiceExtension(Future<Map<String, dynamic>> Function(Map<String, String>) call) {
|
||||
js_util.setProperty(html.window, '\$flutterDriver', allowInterop((dynamic message) async {
|
||||
js_util.setProperty(html.window, r'$flutterDriver', allowInterop((dynamic message) async {
|
||||
// ignore: undefined_function, undefined_identifier
|
||||
final Map<String, String> params = Map<String, String>.from(
|
||||
jsonDecode(message as String) as Map<String, dynamic>);
|
||||
final Map<String, dynamic> result = Map<String, dynamic>.from(
|
||||
await call(params));
|
||||
context['\$flutterDriverResult'] = json.encode(result);
|
||||
context[r'$flutterDriverResult'] = json.encode(result);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ void main() {
|
||||
test('web_extension should register a function', () {
|
||||
expect(() => registerWebServiceExtension(call),
|
||||
returnsNormally);
|
||||
expect(js.context.hasProperty('\$flutterDriver'), true);
|
||||
expect(js.context.hasProperty(r'$flutterDriver'), true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user