Re: [ServiceWorker] Foreign fetch (#751)

> +      <h1><code>event.registerForeignFetchScopes(<var>subScopes</var>, <var>origins</var>)</code></h1>
> +
> +      <p><code><a href="#install-event-register-foreign-fetch-scopes-method">registerForeignFetchScopes(<var>subScopes</var>, <var>origins</var>)</a></code> registers this service worker to handle foreign fetches from certain origins for certain sub scopes.</p>
> +
> +      <p><dfn id="install-event-register-foreign-fetch-scopes-method"><code>registerForeignFetchScopes(<var>subScopes</var>, <var>origins</var>)</code></dfn> method <em class="rfc2119" title="MUST">must</em> run these steps or their <a href="#dfn-processing-equivalence">equivalent</a>:</p>
> +      <spec-algorithm>
> +      <ol>
> +        <li>If the <a href="https://dom.spec.whatwg.org/#dispatch-flag">dispatch flag</a> is unset, then:
> +          <ol>
> +            <li><a href="http://heycam.github.io/webidl/#dfn-throw">Throw</a> an "<code><a href="http://heycam.github.io/webidl/#invalidstateerror">InvalidStateError</a></code>" exception.</li>
> +            <li>Abort these steps.</li>
> +          </ol>
> +        </li>
> +        <li>If <var>origins</var> is empty <a href="http://heycam.github.io/webidl/#dfn-throw">throw</a> a <code>TypeError</code> and abort these steps.</li>
> +        <li>Let <var>originURLs</var> be an empty list of <a href="https://url.spec.whatwg.org/#concept-url">URLs</a>.</li>
> +        <li>If the value of <var>origins</var> is not a single string equal to a single U+002A ASTERISK character (*):

> Make registerForeignFetchScopes() accept a dictionary. That'll be better going forward.

Not sure I agree with this. Sure, every method in every API could just have a single dictionary argument with possibly required fields in the dictionary, but that is not how most APIs are written. Many APIs do have an optional dictionary parameter with optional extra arguments, where I fully agree that a dictionary is the way to go, I just don't think that here with an API where the arguments are in no way interchangeable (no subscope should be a valid origin, and no origin would be a valid subscope), and are always required would really be better if it used a dictionary.

> Both subScopes and origins should just take a sequence I think. No need to get fancy. Wrapping the string in [ and ] is not hard.

Okay, made that change.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/pull/751/files#r51961242

Received on Friday, 5 February 2016 00:35:07 UTC