forked from mirrors/gecko-dev
		
	Differential Revision: https://phabricator.services.mozilla.com/D11650 --HG-- rename : browser/components/customizableui/content/.eslintrc.js => browser/components/translation/content/.eslintrc.js rename : browser/components/translation/jar.mn => browser/components/translation/content/jar.mn rename : browser/components/translation/microsoft-translator-attribution.png => browser/components/translation/content/microsoft-translator-attribution.png rename : browser/components/customizableui/content/moz.build => browser/components/translation/content/moz.build rename : browser/components/translation/translation-infobar.xml => browser/components/translation/content/translation-notification.js extra : rebase_source : 598396d2da96b04782413946976f7bb9fb6be75f
		
			
				
	
	
		
			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.getAttribute("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");
 | 
						|
  });
 | 
						|
});
 |