Coder Social home page Coder Social logo

Comments (11)

beaufortfrancois avatar beaufortfrancois commented on July 30, 2024 2

@jyasskin Does that include potential service workers and web workers?

from web-bluetooth.

jyasskin avatar jyasskin commented on July 30, 2024 1

@beaufortfrancois I haven't thought about workers yet, but I think that, because you can't assign objects directly into a worker, they won't be affected by this sort of difficulty. Cloning and transfering objects results in them having the "right" global, so they probably won't be affected by the old global getting closed.

from web-bluetooth.

marcoscaceres avatar marcoscaceres commented on July 30, 2024

Hopefully don't need to write anything as WebIDL should take care of it - though we probably need to check with public-script-coord. When objects are created, they are bound to a "Realm" (the JS context they are created in). Using an object outside of its realm will generally result in a security error (or something like a Wrong Document DOM exception or just a straight up security exception).

from web-bluetooth.

marcoscaceres avatar marcoscaceres commented on July 30, 2024

//cc @domenic, who knows more about this...

from web-bluetooth.

domenic avatar domenic commented on July 30, 2024

Using an object outside of its realm will generally result in a security error

I don't think that's quite accurate. In most cases the objects just work (although whatever you do with them will only apply to their originator, not the place you use them).

That seems fine for Bluetooth as well?

from web-bluetooth.

marcoscaceres avatar marcoscaceres commented on July 30, 2024

Could be. @jyasskin what are you trying to prevent exactly?

from web-bluetooth.

jyasskin avatar jyasskin commented on July 30, 2024

Say a web page calls requestDevice() to get permission to access a device, uses the device for a bit without doing anything tricky to pass a reference to another document, and then the user closes the tab. If the user later re-opens a tab to the same origin, should the origin have access to the device?

I believe @adrifelt is going to recommend, based on some user studies, that we persistently pair all devices returned from requestDevice() with the origin (until the user revokes/unpairs them), in which case I think it's straightforward to implement what @domenic suggested. (Right @scheib?) It sounds like this is also the default for the spec, although we might want to make it explicit in a note so implementers don't think they have the freedom to change it.

If we instead wanted to grant only temporary permission to access a device, we'd have a couple choices about when that permission expires:

  1. When the original tab is closed: we could specify that the BluetoothDevice object can only be used from its original Document.
  2. When the last reference to the BluetoothDevice expires: @scheib thinks this is tricky to implement in Blink.

from web-bluetooth.

scheib avatar scheib commented on July 30, 2024

Yes, from a Blink implementation point of view persistent access and explicit removal of that access is easier to implement.

from web-bluetooth.

adrifelt avatar adrifelt commented on July 30, 2024

+1 to the idea of persistent access for an origin until revocation, although sadly I do not have any specific studies about Bluetooth in my back pocket

from web-bluetooth.

jyasskin avatar jyasskin commented on July 30, 2024

Beyond the permission story (where we're going with persistent grants unless someone comes up with an argument otherwise), it's looking like the Chrome implementation is going to have trouble keeping connections open after the originating document/frame/Realm is closed. I'm currently inclined to specify that when the originating document's closed any still-alive objects using that document's global object get disconnected.

@g-ortuno FYI for your implementation patches.

from web-bluetooth.

reillyeon avatar reillyeon commented on July 30, 2024

Discussed at 2019 TPAC F2F. Persistent permissions have been specified and are being implemented, which resolves the brunt of this issue. Actual transferring ownership of an object between contexts is technically complex and can be avoided with the use of a shared worker or service worker. Closing this in favor of #422.

from web-bluetooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.