New issue
Advanced search Search tips

Issue 799960 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

[OriginTrialEnabled] interfaces are not exposed correctly in AudioWorklet module scripts

Project Member Reported by cha...@chromium.org, Jan 8 2018

Issue description

Split off from  bug 799092 .

Relevant detail from there:

First problem was that origin trial tokens were not processed in WorkletGlobalScope. This was first addressed in patch 2, here:
https://chromium-review.googlesource.com/c/chromium/src/+/849254/2

With these changes, the layout test in the above CL would fail with the runtime flag disabled for AudioWorklet. The main problem seemed to be with this code in the test:
  realtimeContext.audioWorklet.addModule('../../webaudio/audio-worklet/dummy-processor.js')

Which results in this error:
Uncaught ReferenceError: AudioWorkletProcessor is not defined

After investigating, I believe it's a timing problem with when the origin trial bindings are installed. In debugging, it looks like the bindings for AudioWorkletProcessor are installed, but it happens after the addModule() call to create the processor.
 

Comment 1 by cha...@chromium.org, Jan 11 2018

Further investigation reveals that the problem is that tokens were not being validated successfully within the WorkletGlobalScope. It boils down to WorkletGlobalScopes having a unique origin (as spec'd), which causes the token validation to fail on both not a secure context, and origin not matching the value in the tokens.
This rationale make sense:

> For the purposes of origin trials, we believe it is sufficient to consider the
context of the document that created the worklet. If the document is secure, and
has valid token(s), the origin trial should be enabled.

Worklets have a unique opaque origin, but they are created from a document with an origin which can be matched against trial tokens, and the worklets are essentially an extension of that document[1], regardless of whether the actual script content is loaded same- or cross-origin. It makes sense in that case to allow them to inherit the origin trials enabled by the owner document (assuming any of them are relevant in the worklet global scope)

Relevant discussions:
https://github.com/whatwg/html/issues/3109
https://github.com/whatwg/fetch/pull/527
https://github.com/w3c/css-houdini-drafts/issues/473

[1] Per mkwst in https://github.com/whatwg/fetch/pull/527#issuecomment-335439478: "they're basically scripts executing in the same origin as the document (basically weirdly-behaved <script> elements)."
Project Member

Comment 3 by bugdroid1@chromium.org, Jan 30 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/362fee3f74ae13fa415e4618bcc9f19264f018a5

commit 362fee3f74ae13fa415e4618bcc9f19264f018a5
Author: Jason Chase <chasej@chromium.org>
Date: Tue Jan 30 21:58:13 2018

Allow origin trials to be enabled in worklets

As first seen in  bug 799092 , the AudioWorklet trial uncovered problems where
[OriginTrialEnabled] interfaces were not being exposed for module scripts in
worklets.

The root cause is that WorkletGlobalScopes are defined to have a unique, opaque
origin. This defeats the trial token validation which requires both a secure
context, and that the origin for the context matches the origin in the token.

For the purposes of origin trials, we believe it is sufficient to consider the
context of the document that created the worklet. If the document is secure, and
has valid token(s), the origin trial should be enabled. Analogous to this thread:
https://github.com/whatwg/fetch/pull/527#issuecomment-335677387

This CL changes so that any tokens from the document are passed along to the
worklet, and the origin of the document is used to validate any tokens. This
applies to all types of worklets, although the problem was initially found for
AudioWorklet.

As well the AudioWorkletProcessor interface has the [OriginTrialEnabled]
attribute reinstated (was removed in a previous CL as a short-term workaround).

Bug:  799960 
Change-Id: I98cca05a7710e463a10dcd8c17f302f311f531b3
Reviewed-on: https://chromium-review.googlesource.com/862257
Commit-Queue: Jason Chase <chasej@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533035}
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/exported/WebSharedWorkerImpl.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/layout/custom/LayoutWorkletGlobalScopeProxy.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/loader/modulescript/ModuleScriptLoaderTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/origin_trials/OriginTrialContext.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/DedicatedWorker.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/DedicatedWorkerTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/GlobalScopeCreationParams.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/GlobalScopeCreationParams.h
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/MainThreadWorkletTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/ThreadedWorkletMessagingProxy.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/ThreadedWorkletTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/WorkerThreadTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/WorkletGlobalScope.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/core/workers/WorkletGlobalScope.h
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/animationworklet/AnimationWorkletGlobalScopeTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/animationworklet/AnimationWorkletThreadTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/csspaint/PaintWorkletGlobalScopeProxy.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/exported/WebEmbeddedWorkerImpl.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/webaudio/AudioWorkletGlobalScopeTest.cpp
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/webaudio/AudioWorkletProcessor.idl
[modify] https://crrev.com/362fee3f74ae13fa415e4618bcc9f19264f018a5/third_party/WebKit/Source/modules/webaudio/AudioWorkletThreadTest.cpp

Comment 4 by cha...@chromium.org, Jan 31 2018

Status: Fixed (was: Available)

Sign in to add a comment