Commit 9efc6c3e authored by John Rummell's avatar John Rummell Committed by Commit Bot

Reland "Update BrowsingDataRemoverBrowserTest to include MediaLicenses"

Original change's description:
> MediaLicenses can be cleared from the ClearBrowsingData dialog, so update the
> BrowsingDataRemoverBrowserTest to check them as well. This uses the test-only
> External Clear Key CDM to store the license in the file system, if it is
> available.
>
> The original CL was flaky due to Mac's only saving file timestamps to
> second granularity. As a result it was possible for the newly created license
> to be saved with a timestamp prior to the current actual time, and deleting
> "old" licenses would include it in the deletion. Change is to wait for some
> time on Macs only to ensure that the "new" license has a later timestamp.

This reverts commit b6bfa2b7.

BUG=808690
TEST=new browser_tests pass

Change-Id: Iad919ec23bf157a9bc4af3e6d54af2b28fdc217e
Reviewed-on: https://chromium-review.googlesource.com/c/1354498Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612301}
parent fb0cacc9
<html>
<script>
function success_() {
domAutomationController.send(true);
}
function failure_() {
domAutomationController.send(false);
}
// EME creates session IDs dynamically, so we have no idea what it will be.
// As the tests only need to create a single session, keep track of the
// last session ID created.
var savedSessionId = 'UnknownSessionId';
function createPersistentSession() {
// This function creates a persistent-license type session, and resolves
// with the created session object on success.
return navigator.requestMediaKeySystemAccess(
'org.chromium.externalclearkey', [{
initDataTypes: ['keyids'],
audioCapabilities: [
// Include a set of codecs that should cover all user agents.
{contentType: 'audio/mp4; codecs="mp4a.40.2"'},
{contentType: 'audio/webm; codecs="opus"'}
],
persistentState: 'required',
sessionTypes: ['persistent-license'],
}])
.then(function(access) {
return access.createMediaKeys();
})
.then(function(mediaKeys) {
return mediaKeys.createSession('persistent-license');
});
}
function handleMessageEvent(e) {
var session = e.target;
var te = new TextEncoder();
var license = te.encode(
'{"keys":[{"kty":"oct","k":"tQ0bJVWb6b0KPL6KtZIy_A","kid":"LwVHf8JLtPrv2GUXFW2v_A"}],"type":"persistent-license"}');
savedSessionId = session.sessionId;
session.update(license).then(success_, failure_);
}
function setMediaLicense() {
var te = new TextEncoder();
var initData = te.encode('{"kids":["LwVHf8JLtPrv2GUXFW2v_A"]}');
createPersistentSession().then(function(session) {
// generateRequest() will trigger a 'message' event, which we need to
// wait for in order to call update() which provides the license.
session.addEventListener('message', handleMessageEvent, false);
return session.generateRequest('keyids', initData);
})
// Success is reported from handleMessageEvent().
.catch(failure_);
}
function hasMediaLicense() {
createPersistentSession().then(function(session) {
return session.load(savedSessionId);
})
.then(function(result) {
// |result| is a boolean, indicating if the session was loaded or not.
domAutomationController.send(result);
})
.catch(failure_);
}
</script>
<body>
This page is used to test creation and deletion of Media Licenses.
The functions are called from BrowsingDataRemoverBrowserTest::HasDataForType
and BrowsingDataRemoverBrowserTest::SetDataForType.
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment