Skip to content

"the document's URL" is ambiguous #36

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

Closed
domenic opened this issue Jun 20, 2017 · 4 comments
Closed

"the document's URL" is ambiguous #36

domenic opened this issue Jun 20, 2017 · 4 comments

Comments

@domenic
Copy link

domenic commented Jun 20, 2017

Consider the situation:

function declaredInWindow3() {
  window1.navigator.share.call(window2.navigator, { url });
}

Then navigate the frame containing window3 to window4, but save a reference to declaredInWindow3. Finally, from code in window5, call the saved function.

Which of these five documents does url get resolved relative to?

The proper pattern for this is to parse against

this Navigator object's relevant settings object's API base URL

in which case the answer will be window2.

@mgiuca
Copy link
Collaborator

mgiuca commented Jun 21, 2017

I'm still trying to get my head around all this.

The closest thing I can find is the Fetch standard:

https://fetch.spec.whatwg.org/#dom-request

That uses similar, but not identical, language to what you propose:

Let baseURL be current settings object’s API base URL.

What is the difference between "this Navigator object's relevant settings object" and "the current settings object"? Can I just use the same language as Fetch?

@domenic
Copy link
Author

domenic commented Jun 21, 2017

The reason fetch uses that is because it's inside a constructor, so it's not being invoked on any particular this---it's creating a new this, in fact. So there is no object to look at the relevant settings object of.

https://html.spec.whatwg.org/multipage/webappapis.html#realms-settings-objects-global-objects is probably the right background reading, but to skip to the punchline:

In general, web platform specifications should use the relevant concept, applied to the object being operated on (usually the this value of the current method). [...]

Note that in constructors, where there is no this value yet, the current concept is the appropriate default.

@mgiuca
Copy link
Collaborator

mgiuca commented Jun 22, 2017

OK thanks, that makes sense now.

I went with "the this value" rather than "this Navigator" because it seems to more formally capture the concept (based on the WebIDL spec which has 22 occurrences of "the this value").

mgiuca added a commit to mgiuca/web-share that referenced this issue Jun 22, 2017
@domenic
Copy link
Author

domenic commented Jun 22, 2017

Well, the Web IDL spec is different because it's writing algorithms in ECMAScript land (where "this value" is well defined), not Web IDL land (where we don't have a good definition for this concept; see https://www.w3.org/Bugs/Public/show_bug.cgi?id=27301). But yeah, until we get our story straightened out for Web IDL land, "this value" works fine there too.

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

No branches or pull requests

2 participants