Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #13375 from brave/fix/disable-webusb
Browse files Browse the repository at this point in the history
disable webusb and bluetooth API explicitly
  • Loading branch information
diracdeltas authored Mar 7, 2018
2 parents 43232e0 + 027f15f commit 5143bd3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/extensions/brave/content/scripts/navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ chrome.webFrame.setGlobal("navigator.getBattery", function () {
return new Promise((resolve, reject) => { reject(new Error('navigator.getBattery not supported.')) })
})

// bluetooth is not currently supported
executeScript("window.Navigator.prototype.__defineGetter__('bluetooth', () => { return undefined })")
// webusb also not supported yet
executeScript("window.Navigator.prototype.__defineGetter__('usb', () => { return undefined })")

if (chrome.contentSettings.doNotTrack == 'allow') {
executeScript("window.Navigator.prototype.__defineGetter__('doNotTrack', () => { return 1 })")
}
Expand Down
16 changes: 16 additions & 0 deletions test/contents/contentLoadingTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,20 @@ describe('content loading', function () {
.windowByUrl(Brave.browserWindowUrl)
.waitForTextValue('[data-test-id="tabTitle"]', 'fail')
})

it('does not support bluetooth API', function * () {
const page1 = Brave.fixtureUrl('navigator.html')
yield this.app.client
.tabByIndex(0)
.url(page1)
.waitForTextValue('#bluetooth', 'undefined')
})

it('does not support webusb API', function * () {
const page1 = Brave.fixtureUrl('navigator.html')
yield this.app.client
.tabByIndex(0)
.url(page1)
.waitForTextValue('#webusb', 'undefined')
})
})
12 changes: 12 additions & 0 deletions test/fixtures/navigator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<div id='bluetooth'>
testing...
</div>
<div id='webusb'>
testing...
</div>
<script>
bluetooth.innerText = navigator.bluetooth
webusb.innerText = navigator.usb
</script>
</html>

0 comments on commit 5143bd3

Please sign in to comment.