forked from mirrors/gecko-dev
We recently accidentally broke the "Enable DRM" prompt without realising, so this adds a test that if EME is disabled and is attempted to be used we we prompt the user to enable EME. It is important we don't regress this feature as without it users with DRM disabled (which is our Linux popuation by default) may try to playback DRM protected video and it won't work and there won't be an obvious way to make it work. MozReview-Commit-ID: D4X7D4wkwRy --HG-- extra : rebase_source : d0c7bf45c0a3b4ffb517a3b7c008230bd750fc8d
67 lines
2.7 KiB
JavaScript
67 lines
2.7 KiB
JavaScript
/*
|
|
* Bug 1366167 - Tests that the "Enable DRM" prompt shows if EME is requested while EME is disabled.
|
|
*/
|
|
|
|
const TEST_URL =
|
|
getRootDirectory(gTestPath).replace("chrome://mochitests/content",
|
|
"https://example.com") + "empty_file.html";
|
|
|
|
add_task(async function() {
|
|
await BrowserTestUtils.withNewTab(TEST_URL, async function(browser) {
|
|
// Note: SpecialPowers.pushPrefEnv has problems with the "Enable DRM"
|
|
// button on the notification box toggling the prefs. So manually
|
|
// set/unset the prefs the UI we're testing toggles.
|
|
let emeWasEnabled = Services.prefs.getBoolPref("media.eme.enabled", false);
|
|
let cdmWasEnabled = Services.prefs.getBoolPref("media.gmp-widevinecdm.enabled", false);
|
|
|
|
// Restore the preferences to their pre-test state on test finish.
|
|
registerCleanupFunction(function() {
|
|
Services.prefs.setBoolPref("media.eme.enabled", emeWasEnabled);
|
|
Services.prefs.setBoolPref("media.gmp-widevinecdm.enabled", cdmWasEnabled);
|
|
});
|
|
|
|
// Turn off EME and Widevine CDM.
|
|
Services.prefs.setBoolPref("media.eme.enabled", false);
|
|
Services.prefs.setBoolPref("media.gmp-widevinecdm.enabled", false);
|
|
|
|
// Have content request access to Widevine, UI should drop down to
|
|
// prompt user to enable DRM.
|
|
let result = await ContentTask.spawn(browser, {}, async function() {
|
|
try {
|
|
let config = [{
|
|
initDataTypes: ["webm"],
|
|
videoCapabilities: [{contentType: 'video/webm; codecs="vp9"'}],
|
|
}];
|
|
await content.navigator.requestMediaKeySystemAccess("com.widevine.alpha", config);
|
|
} catch (ex) {
|
|
return {rejected: true};
|
|
}
|
|
return {rejected: false};
|
|
});
|
|
is(result.rejected, true, "EME request should be denied because EME disabled.");
|
|
|
|
// Verify the UI prompt showed.
|
|
let box = gBrowser.getNotificationBox(browser);
|
|
let notification = box.currentNotification;
|
|
|
|
ok(notification, "Notification should be visible");
|
|
is(notification.value, "drmContentDisabled",
|
|
"Should be showing the right notification");
|
|
|
|
// Verify the "Enable DRM" button is there.
|
|
let buttons = notification.querySelectorAll(".notification-button");
|
|
is(buttons.length, 1, "Should have one button.");
|
|
|
|
// Prepare a Promise that should resolve when the "Enable DRM" button's
|
|
// page reload completes.
|
|
let refreshPromise = BrowserTestUtils.browserLoaded(browser);
|
|
buttons[0].click();
|
|
|
|
// Wait for the reload to complete.
|
|
await refreshPromise;
|
|
|
|
// Verify clicking the "Enable DRM" button enabled DRM.
|
|
let enabled = Services.prefs.getBoolPref("media.eme.enabled", true);
|
|
is(enabled, true, "EME should be enabled after click on 'Enable DRM' button");
|
|
});
|
|
});
|