Skip to content
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

Add detection for WebMidi and Window Placement APIs #162

Merged
merged 2 commits into from
Jul 10, 2023
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
12 changes: 12 additions & 0 deletions features/harmful-apis/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const tests = [
return ('hid' in navigator);
}
},
{
id: 'web-midi-api',
run: () => {
return ('requestMIDIAccess' in navigator);
}
},
{
id: 'accelerometer-api',
run: () => {
Expand Down Expand Up @@ -220,6 +226,12 @@ const tests = [
run: () => {
return ('joinAdInterestGroup' in navigator) || ('runAdAuction' in navigator);
}
},
{
id: 'window-placement-api',
run: () => {
return ('screen' in window && 'isExtended' in window.screen);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the multi-screen windows API? Google folks are using a different detection technique:

  "'Multi-Screen Window Placement': {regEx: /getScreenDetails\\s*\\(\\)/g, where: 'JavaScript', supported: (async () =\u003e 'getScreenDetails' in self)(), featureDetection: `(async () =\u003e 'getScreenDetails' in self)()`, documentation: 'https://developer.chrome.com/articles/multi-screen-window-placement/', blinkFeatureID: 3388},"

Not sure if that's better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both getScreenDetails and isExtended are introduced in the spec, so I guess it doesn't really matter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess their goal is to check if feature is available FULLY. We may not care about that, for us if feature is available even partially it's alrady bad.

}
}
];

Expand Down
5 changes: 3 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const ws = require('ws');
const app = express();
const port = process.env.PORT || 3000;
const host = process.env.HOST || '127.0.0.1';
kdzwinel marked this conversation as resolved.
Show resolved Hide resolved
const url = require('url');
const cmd = require('node-cmd');
const crypto = require('crypto');
Expand All @@ -20,8 +21,8 @@ function fullUrl (req) {

// Start the HTTP server. On Glitch the proxy will forward both HTTP and HTTPS
// traffic to this server.
const listener = app.listen(port, () => {
console.log(`HTTP Server listening at port ${listener.address().port}`);
const listener = app.listen(port, host, () => {
console.log(`HTTP Server listening at ${listener.address().address}:${listener.address().port}`);
});

// Start HTTPS server for https://first-party.example and https://third-party.example
Expand Down