Skip to content

Fix global variable isInternalBuild in injected client #1805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 1, 2022
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
1 change: 1 addition & 0 deletions dwds/lib/dart_web_debug_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Dwds {
extensionUri: extensionUri,
enableDevtoolsLaunch: enableDevtoolsLaunch,
emitDebugEvents: emitDebugEvents,
isInternalBuild: isInternalBuild,
);

final devHandler = DevHandler(
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/injected/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions dwds/test/handlers/injector_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,10 @@ void main() {
expect(result.body, contains('\$emitRegisterEvent'));
});

test('the injected client contains a global \$isInternalDartBuild',
() async {
test('the injected client contains a global \$isInternalBuild', () async {
final result = await http.get(Uri.parse(
'http://localhost:${server.port}/dwds/src/injected/client.js'));
expect(result.body, contains('\$isInternalDartBuild'));
expect(result.body, contains('\$isInternalBuild'));
});

test('serves the injected client', () async {
Expand Down
1 change: 1 addition & 0 deletions dwds/test/puppeteer/extension_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void main() async {
expect(debugInfo.appInstanceId, isNotNull);
expect(debugInfo.appOrigin, isNotNull);
expect(debugInfo.appUrl, isNotNull);
expect(debugInfo.isInternalBuild, isNotNull);
await appTab.close();
});

Expand Down
6 changes: 3 additions & 3 deletions dwds/web/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Future<void>? main() {
..appOrigin = window.location.origin
..appUrl = window.location.href
..extensionUrl = windowContext['\$dartExtensionUri']
..isInternalBuild = windowContext['\$isInternalDartBuild'])));
..isInternalBuild = windowContext['\$isInternalBuild'])));

dispatchEvent(CustomEvent('dart-app-ready', detail: debugInfoJson));
}, (error, stackTrace) {
Expand Down Expand Up @@ -275,7 +275,7 @@ external set emitDebugEvent(void Function(String, String) func);
@JS(r'$emitRegisterEvent')
external set emitRegisterEvent(void Function(String) func);

@JS(r'$isInternalDartBuild')
external bool get isInternalDartBuild;
@JS(r'$isInternalBuild')
external bool get isInternalBuild;

bool get _isChromium => window.navigator.vendor.contains('Google');