Skip to content

Instantly share code, notes, and snippets.

@waterplea
Last active February 10, 2020 07:50
Show Gist options
  • Save waterplea/066197d5f5978fc9e64d3c1b74fd9c47 to your computer and use it in GitHub Desktop.
Save waterplea/066197d5f5978fc9e64d3c1b74fd9c47 to your computer and use it in GitHub Desktop.
Pupeteer like browser control over devtools protocol in basic Karma
fetch('http://localhost:9222/json')
.then(response => response.json())
.then(([response]) => {
const socket = new WebSocket(response.webSocketDebuggerUrl);
socket.onopen = () => {
socket.send(
JSON.stringify({
id: 1,
method: 'Browser.grantPermissions',
params: {
origin: 'http://localhost:9876',
permissions: ['midi', 'midiSysex'],
},
}),
);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment