EME: close() will return undefined if already closed |
||||
Issue descriptionChrome Version: 56.0.2924.87 and 58.0.3004.3 OS: Linux What steps will reproduce the problem? (1) Create EME session and generate request. (2) Close session, wait until closed. (3) Call session.close() again. What is the expected result? Second call to close() (when already closed) should return a resolved Promise. What happens instead? Returns undefined. Repro: https://jsfiddle.net/4qd6jrgv/
,
Feb 10 2017
There is already an existing test (encrypted-media-session-multiple-close.html) that calls close() multiple times, but does so as: return Promise.all([mediaKeySession.close(), mediaKeySession.close(), mediaKeySession.close()]); There doesn't appear to be a test that calls them sequentially.
,
Feb 10 2017
I changed the code in the repro to end with:
.then(() => { var p = session.close(); console.log(p); return p; })
.then(() => { var p = session.close(); console.log(p); return p; })
.then(() => { var p = session.close(); console.log(p); return p; });
In the console I see:
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
undefined
undefined
So it acts like a resolved promise, even if it doesn't look like one.
The code in MediaKeySession.cpp, if the session is already closed, simply uses ScriptPromise::cast() to create a resolved promise:
return ScriptPromise::cast(scriptState, ScriptValue());
I changed it to create and resolve one of the EME promise wrappers directly:
SimpleResultPromise* result = new SimpleResultPromise(scriptState, this);
ScriptPromise promise = result->promise();
result->complete();
return promise;
Running that I now see:
Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: undefined}
Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: undefined}
yhirano, haraken: Should ScriptPromise::cast() not return an object that looks like a promise?
(Note: running the repro on ToT requires the second parameter to requestMediaKeySystemAccess() to be "[{audioCapabilities: [{contentType: 'audio/webm; codecs=vorbis'}]}]", as otherwise it fails with "None of the requested configurations were supported.")
,
Feb 10 2017
Please don't pass an empty ScriptValue to ScriptPromise::cast. You can use ScriptPromise::castUndefined.
,
Feb 10 2017
yhirano: Thanks. That fixes it.
,
Feb 11 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/665c048b2e508b5cc566810816a77bfd4bfdb9db commit 665c048b2e508b5cc566810816a77bfd4bfdb9db Author: jrummell <jrummell@chromium.org> Date: Sat Feb 11 00:25:25 2017 EME: close() should return a resolved promise if session already closed BUG= 690664 TEST=new test passes Review-Url: https://codereview.chromium.org/2688263002 Cr-Commit-Position: refs/heads/master@{#449804} [add] https://crrev.com/665c048b2e508b5cc566810816a77bfd4bfdb9db/third_party/WebKit/LayoutTests/media/encrypted-media/encrypted-media-session-multiple-close-sequential.html [modify] https://crrev.com/665c048b2e508b5cc566810816a77bfd4bfdb9db/third_party/WebKit/Source/modules/encryptedmedia/MediaKeySession.cpp
,
Feb 11 2017
|
||||
►
Sign in to add a comment |
||||
Comment 1 by xhw...@chromium.org
, Feb 9 2017Owner: jrumm...@chromium.org
Status: Assigned (was: Untriaged)