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

proposed change for #402 #407

Closed
wants to merge 6 commits into from
Closed

proposed change for #402 #407

wants to merge 6 commits into from

Conversation

ShijunS
Copy link
Contributor

@ShijunS ShijunS commented Oct 6, 2016

the first attempt to fix #402

the first attempt to fix #402
Copy link
Member

@jan-ivar jan-ivar left a comment

Choose a reason for hiding this comment

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

WFM with some changes, primarily to not lose the permission requirement outright, except in the active tab with focus. I've added language suggestions

<p>When new media input and/or output devices are made available, and if either the
<a data-lt="retrieve the permission state">permission state</a> of the
"list-devices" permission is "granted" or any of the local devices are
attached to an active MediaStream in the current browsing context, then
Copy link
Member

@jan-ivar jan-ivar Oct 6, 2016

Choose a reason for hiding this comment

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

This removes all permission requirements for the devicechange event, which I don't think we agreed to.

I think we need to keep this, and an exception for the active tab that has input focus. Something like:

", or the active document in the current browsing context is fully active and has focus, then"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-ivar, I'll update this part based on your input.

Copy link
Contributor

Choose a reason for hiding this comment

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

I still haven't figured out a situation where protecting the devicechange event gives any real protection (see previous discussion). Until I see such a scenario, I am in favor of removing all coupling between the devicechange event and the deviceinfo permission.

Copy link
Member

@jan-ivar jan-ivar Oct 14, 2016

Choose a reason for hiding this comment

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

@alvestrand arguing for going further than this PR, is not a reason to hold up this PR I think.

This PR removes permission for the active tab and aligns enumerateDevices with the firing of the event, like we do with other events.

Copy link
Member

Choose a reason for hiding this comment

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

@alvestrand I would be against going further. If I have, say, 100 tabs open across 3 separate brand browsers, and pull out my USB device, and we signal all tabs about that immediately, that's a fairly strong timing signal to all those tabs' JS that I might be the same user, in spite of every other precaution I might have taken to be anonymous (including using separate browsers, VPNs, denying cookies, and any tracking-protecting private browsing modes).

Copy link
Member

Choose a reason for hiding this comment

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

I should add virtual machines to that list, if they have USB hooked up.

the User Agent MUST run the following steps:</p>
<ol>
<li>
<p>If <var>storedDeviceList</var> exists, then delete <var>storedDeviceList</var>.</p>
Copy link
Member

@jan-ivar jan-ivar Oct 6, 2016

Choose a reason for hiding this comment

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

Needs to be a [[storedDeviceList]] internal slot on the global object in the current realm I think, and set to an empty array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-ivar, thought about that, an "empty" list is still a valid list, i.e. before the event is fired.

Copy link
Member

Choose a reason for hiding this comment

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

@ShijunS Good point. Let's initialize it to undefined then, as "existence" can be ambiguous.

@@ -3018,6 +3023,10 @@
<p>Run the following steps in parallel:</p>
<ol>
<li>
<p>If <var>storedDeviceList</var> exists, then let <var>resultList</var>
Copy link
Member

@jan-ivar jan-ivar Oct 6, 2016

Choose a reason for hiding this comment

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

[[storedDeviceList]] is not undefined,

@@ -3018,6 +3023,10 @@
<p>Run the following steps in parallel:</p>
<ol>
<li>
<p>If <var>storedDeviceList</var> exists, then let <var>resultList</var>
be a copy of <var>storedDeviceList</var>, and skip steps 2-5 below.</p>
Copy link
Member

@jan-ivar jan-ivar Oct 6, 2016

Choose a reason for hiding this comment

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

Since step 5 sets storedDeviceList to resultList, I think we can invert this condition and say:

"If [[storedDeviceList]] is empty, then execute the following steps:"

and move steps 2-5 in to be conditional sub-steps this step which culminate in setting [[storedDeviceList]].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-ivar, if storedDeviceList exists, we still need to copy storedDeviceList to resultList. We might need more changes if we want to move 2-5 to sub-steps.

Copy link
Member

@jan-ivar jan-ivar Oct 7, 2016

Choose a reason for hiding this comment

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

Or s/resultList/storedDeviceList/ in step 8 and 9.

Copy link
Member

Choose a reason for hiding this comment

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

I would prefer not to have explicit step numbers in the algorithms, since they need to be updated when a new step is added. You could either use a label and jump to it (see Permission Failure: in the gUM() steps), or restructure as @jan-ivar suggests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @adam-be for the feedback. I made a few more edits, PTAL.

update based on input from @jan-ivar
as suggested by @jan-ivar, replacing "exists" with "is not undefined"
the User Agent MUST run the following steps:</p>
<ol>
<li>
<p>If <var>storedDeviceList</var> exists, then delete <var>storedDeviceList</var>.</p>
<p>If <var>storedDeviceList</var> is not undefined, then delete <var>storedDeviceList</var>
Copy link
Member

Choose a reason for hiding this comment

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

The scope of storedDeviceList isn't clear here IMHO. Usually, var refers to local vars made in-algorithm with let.

I still think it needs to be an internal slot, which we now have several of.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-ivar, not sure if that is absolutely needed here given storedDeviceList is not tied directly to any JavaScript object. And, not sure how to reset an internal slot to undefined either. Let's get comment from other experts, @adam-be?

Copy link
Member

Choose a reason for hiding this comment

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

What is it tied to then? As I understand it, an internal slot can be set to undefined just like any other value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we need to tie this to an object, the MediaDevices will be the best match. @jan-ivar, any suggestion on at what point an internal slot could be allocated for MediaDevices?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I put mine on page load here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan-ivar, please take another look with the new commit. I also replaced "undefined" with "null" to indicate the absence of a usable value.

Copy link
Member

@jan-ivar jan-ivar left a comment

Choose a reason for hiding this comment

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

Great! I'd still flip the condition and inline steps as I mentioned earlier, but let's see what @adam-be says.

<p>If <var>storedDeviceList</var> is not undefined, then delete <var>storedDeviceList</var>
so it becomes undefined.</p>
<p>If [[\storedDeviceList]] is not null, then set [[\storedDeviceList]]
to null.</p>
Copy link
Member

Choose a reason for hiding this comment

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

Or maybe just: "Set [[storedDeviceList]] to null." ?

@@ -3093,7 +3099,7 @@
</ol>
</li>
<li>
<p>Update <var>storedDeviceList</var> to be same as
<p>Update [[\storedDeviceList]] to be same as
Copy link
Member

Choose a reason for hiding this comment

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

Or maybe: "set [[storedDeviceList]] to resultList." ?

relevant global object</a>, run the following steps:</p>
<ol>
<li>
<p>create three internal slots: [[\devicesLiveMap]], [[\devicesAccessibleMap]], and
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/create/Create/

<code><a>MediaDevices</a></code> object. The User Agent MAY fire just a
<p>When new media input and/or output devices are made available, if either the
<a data-lt="retrieve the permission state">permission state</a> of the
"list-devices" permission is "granted", or any of the local devices are
Copy link
Member

Choose a reason for hiding this comment

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

#410 replaces "list-devices" with "device-info". I don't know which will be merged first, but we should make sure it's not forgotten.

Copy link
Member

Choose a reason for hiding this comment

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

#410 is merged now. Please update this PR accordingly.

s/list-devices/device-info/
s/create/Create
replace step numbers with a label
@stefhak
Copy link
Contributor

stefhak commented Oct 20, 2016

This LGTM now. Time to merge?

@stefhak
Copy link
Contributor

stefhak commented Oct 20, 2016

@ShijunS can you resolve the conflicts? We'll then merge.

@ShijunS
Copy link
Contributor Author

ShijunS commented Oct 21, 2016

I had problem when resolving merge conflict in this PR patch, so replacing with PR #412.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow ondevicechange to be fired before permission is granted or any device is opened
5 participants