Backed out 2 changesets (bug 1642804, bug 1642803) for perma failures on browser_devices_get_user_media_in_xorigin_frame.js. CLOSED TREE

Backed out changeset 48f9a72a27a0 (bug 1642803)
Backed out changeset 53ec379c8e0e (bug 1642804)
This commit is contained in:
Razvan Maries 2020-06-09 18:57:29 +03:00
Родитель caec984d54
Коммит 9f0ce65335
5 изменённых файлов: 72 добавлений и 304 удалений

Просмотреть файл

@ -416,16 +416,6 @@ function updateIndicators(aSubject, aTopic, aData) {
if (actor) {
let tabState = getTabStateForContentWindow(contentWindow, false);
tabState.windowId = getInnerWindowIDForWindow(contentWindow);
// If we were silencing DOM notifications before, but we've updated
// state such that we're no longer sharing one of our displays, then
// reset the silencing state.
if (actor.suppressNotifications) {
if (!tabState.screen && !tabState.window && !tabState.browser) {
actor.suppressNotifications = false;
}
}
tabState.suppressNotifications = actor.suppressNotifications;
actor.sendAsyncMessage("webrtc:UpdateIndicators", tabState);

Просмотреть файл

@ -1121,8 +1121,7 @@ function prompt(aActor, aBrowser, aRequest) {
if (shouldShowAlwaysRemember()) {
// Disable the permanent 'Allow' action if the connection isn't secure, or for
// screen/audio sharing (because we can't guess which window the user wants to
// share without prompting). Note that we never enter this block for private
// browsing windows.
// share without prompting).
let reasonForNoPermanentAllow = "";
if (sharingScreen) {
reasonForNoPermanentAllow =
@ -1135,41 +1134,38 @@ function prompt(aActor, aBrowser, aRequest) {
"getUserMedia.reasonForNoPermanentAllow.insecure";
}
options.checkbox = {
label: stringBundle.getString("getUserMedia.remember"),
checked: principal.isAddonOrExpandedAddonPrincipal,
checkedState: reasonForNoPermanentAllow
? {
disableMainAction: true,
warningLabel: stringBundle.getFormattedString(
reasonForNoPermanentAllow,
[productName]
),
}
: undefined,
};
}
if (notificationSilencingEnabled && sharingScreen) {
let [
silenceNotifications,
silenceNotificationsWarning,
] = localization.formatMessagesSync([
{ id: "popup-silence-notifications-checkbox" },
{ id: "popup-silence-notifications-checkbox-warning" },
]);
// If the notification silencing feature is enabled and we're sharing a
// screen, then the checkbox for the permission panel is what controls
// notification silencing.
if (notificationSilencingEnabled && sharingScreen) {
let [
silenceNotifications,
silenceNotificationsWarning,
] = localization.formatMessagesSync([
{ id: "popup-silence-notifications-checkbox" },
{ id: "popup-silence-notifications-checkbox-warning" },
]);
options.checkbox = {
label: silenceNotifications.value,
checked: false,
checkedState: {
disableMainAction: false,
warningLabel: silenceNotificationsWarning.value,
},
};
options.checkbox = {
label: silenceNotifications.value,
checked: false,
checkedState: {
disableMainAction: false,
warningLabel: silenceNotificationsWarning.value,
},
};
} else {
options.checkbox = {
label: stringBundle.getString("getUserMedia.remember"),
checked: principal.isAddonOrExpandedAddonPrincipal,
checkedState: reasonForNoPermanentAllow
? {
disableMainAction: true,
warningLabel: stringBundle.getFormattedString(
reasonForNoPermanentAllow,
[productName]
),
}
: undefined,
};
}
}
let iconType = "Devices";

Просмотреть файл

@ -32,7 +32,6 @@ skip-if = (os == 'linux') # Bug 1503991
[browser_devices_get_user_media_unprompted_access_tear_off_tab.js]
skip-if = (os == "win" && bits == 64) # win8: bug 1334752
[browser_devices_get_user_media_unprompted_access_queue_request.js]
[browser_notification_silencing.js]
[browser_tab_switch_warning.js]
[browser_webrtc_hooks.js]
[browser_devices_get_user_media_queue_request.js]

Просмотреть файл

@ -1,216 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_ROOT = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content/",
"https://example.com/"
);
const TEST_PAGE = TEST_ROOT + "get_user_media.html";
/**
* Tests that the screen / window sharing permission popup offers the ability
* for users to silence DOM notifications while sharing.
*/
/**
* Helper function that exercises a specific browser to test whether or not the
* user can silence notifications via the display sharing permission panel.
*
* First, we ensure that notification silencing is disabled by default. Then, we
* request screen sharing from the browser, and check the checkbox that
* silences notifications. Once screen sharing is established, then we ensure
* that notification silencing is enabled. Then we stop sharing, and ensure that
* notification silencing is disabled again.
*
* @param {<xul:browser>} aBrowser - The window to run the test on. This browser
* should have TEST_PAGE loaded.
* @return Promise
* @resolves undefined - When the test on the browser is complete.
*/
async function testNotificationSilencing(aBrowser) {
let window = aBrowser.ownerGlobal;
let alertsService = Cc["@mozilla.org/alerts-service;1"]
.getService(Ci.nsIAlertsService)
.QueryInterface(Ci.nsIAlertsDoNotDisturb);
Assert.ok(alertsService, "Alerts Service implements nsIAlertsDoNotDisturb");
Assert.ok(
!alertsService.suppressForScreenSharing,
"Should not be silencing notifications to start."
);
let observerPromise = expectObserverCalled(
"getUserMedia:request",
1,
aBrowser
);
let promise = promisePopupNotificationShown(
"webRTC-shareDevices",
null,
window
);
await promiseRequestDevice(false, true, null, "screen", aBrowser);
await promise;
await observerPromise;
checkDeviceSelectors(false, false, true, window);
let document = window.document;
// Select one of the windows / screens. It doesn't really matter which.
let menulist = document.getElementById("webRTC-selectWindow-menulist");
menulist.getItemAtIndex(menulist.itemCount - 1).doCommand();
let notification = window.PopupNotifications.panel.firstElementChild;
Assert.ok(
notification.hasAttribute("warninghidden"),
"Notification silencing warning message is hidden by default"
);
let checkbox = notification.checkbox;
Assert.ok(!!checkbox, "Notification silencing checkbox is present");
Assert.ok(!checkbox.checked, "checkbox is not checked by default");
checkbox.click();
Assert.ok(checkbox.checked, "checkbox now checked");
// The orginal behaviour of the checkbox disabled the Allow button. Let's
// make sure we're not still doing that.
Assert.ok(!notification.button.disabled, "Allow button is not disabled");
Assert.ok(
!notification.hasAttribute("warninghidden"),
"warning message is shown"
);
let observerPromise1 = expectObserverCalled(
"getUserMedia:response:allow",
1,
aBrowser
);
let observerPromise2 = expectObserverCalled(
"recording-device-events",
1,
aBrowser
);
await promiseMessage(
"ok",
() => {
notification.button.click();
},
1,
aBrowser
);
await observerPromise1;
await observerPromise2;
Assert.ok(
alertsService.suppressForScreenSharing,
"Should now be silencing notifications"
);
await stopSharing("screen", true, aBrowser, window);
Assert.ok(
!alertsService.suppressForScreenSharing,
"Should no longer be silencing notifications"
);
}
add_task(async function setup() {
// Set prefs so that permissions prompts are shown and loopback devices
// are not used. To test the chrome we want prompts to be shown, and
// these tests are flakey when using loopback devices (though it would
// be desirable to make them work with loopback in future). See bug 1643711.
let prefs = [
[PREF_PERMISSION_FAKE, true],
[PREF_AUDIO_LOOPBACK, ""],
[PREF_VIDEO_LOOPBACK, ""],
[PREF_FAKE_STREAMS, true],
[PREF_FOCUS_SOURCE, false],
];
await SpecialPowers.pushPrefEnv({ set: prefs });
});
/**
* Tests notification silencing in a normal browser window.
*/
add_task(async function testNormalWindow() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: TEST_PAGE,
},
async browser => {
await testNotificationSilencing(browser);
}
);
});
/**
* Tests notification silencing in a private browser window.
*/
add_task(async function testPrivateWindow() {
let privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
await BrowserTestUtils.withNewTab(
{
gBrowser: privateWindow.gBrowser,
url: TEST_PAGE,
},
async browser => {
await testNotificationSilencing(browser);
}
);
await BrowserTestUtils.closeWindow(privateWindow);
});
/**
* Tests notification silencing when sharing a screen while already
* sharing the microphone. Alone ensures that if we stop sharing the
* screen, but continue sharing the microphone, that notification
* silencing ends.
*/
add_task(async function testWhileSharingMic() {
await BrowserTestUtils.withNewTab(
{
gBrowser,
url: TEST_PAGE,
},
async browser => {
let promise = promisePopupNotificationShown("webRTC-shareDevices");
let observerPromise = expectObserverCalled("getUserMedia:request");
await promiseRequestDevice(true, true);
await promise;
await observerPromise;
let indicator = promiseIndicatorWindow();
let observerPromise1 = expectObserverCalled(
"getUserMedia:response:allow"
);
let observerPromise2 = expectObserverCalled("recording-device-events");
promise = promiseMessage("ok", () => {
PopupNotifications.panel.firstElementChild.button.click();
});
await observerPromise1;
await observerPromise2;
await promise;
Assert.deepEqual(
await getMediaCaptureState(),
{ audio: true, video: true },
"expected camera and microphone to be shared"
);
await indicator;
await checkSharingUI({ audio: true, video: true });
await testNotificationSilencing(browser);
await closeStream();
}
);
});

Просмотреть файл

@ -321,50 +321,46 @@ function expectObserverCalledOnClose(
});
}
function promiseMessage(
aMessage,
aAction,
aCount = 1,
browser = gBrowser.selectedBrowser
) {
let promise = ContentTask.spawn(browser, [aMessage, aCount], async function([
expectedMessage,
expectedCount,
]) {
return new Promise(resolve => {
function listenForMessage({ data }) {
if (
(!expectedMessage || data == expectedMessage) &&
--expectedCount == 0
) {
content.removeEventListener("message", listenForMessage);
resolve(data);
function promiseMessage(aMessage, aAction, aCount = 1) {
let promise = ContentTask.spawn(
gBrowser.selectedBrowser,
[aMessage, aCount],
async function([expectedMessage, expectedCount]) {
return new Promise(resolve => {
function listenForMessage({ data }) {
if (
(!expectedMessage || data == expectedMessage) &&
--expectedCount == 0
) {
content.removeEventListener("message", listenForMessage);
resolve(data);
}
}
}
content.addEventListener("message", listenForMessage);
});
});
content.addEventListener("message", listenForMessage);
});
}
);
if (aAction) {
aAction();
}
return promise;
}
function promisePopupNotificationShown(aName, aAction, aWindow = window) {
function promisePopupNotificationShown(aName, aAction) {
return new Promise(resolve => {
// In case the global webrtc indicator has stolen focus (bug 1421724)
aWindow.focus();
window.focus();
aWindow.PopupNotifications.panel.addEventListener(
PopupNotifications.panel.addEventListener(
"popupshown",
function() {
ok(
!!aWindow.PopupNotifications.getNotification(aName),
!!PopupNotifications.getNotification(aName),
aName + " notification shown"
);
ok(aWindow.PopupNotifications.isPanelOpen, "notification panel open");
ok(PopupNotifications.isPanelOpen, "notification panel open");
ok(
!!aWindow.PopupNotifications.panel.firstElementChild,
!!PopupNotifications.panel.firstElementChild,
"notification panel populated"
);
@ -515,17 +511,22 @@ async function getMediaCaptureState() {
async function stopSharing(
aType = "camera",
aShouldKeepSharing = false,
aFrameBC,
aWindow = window
aFrameBC
) {
// If the observers are listening to other frames, listen for a notification
// on the right subframe.
let frameBCToObserve;
if (gBrowserContextsToObserve.length > 1) {
frameBCToObserve = aFrameBC;
}
let promiseRecordingEvent = expectObserverCalled(
"recording-device-events",
1,
aFrameBC
frameBCToObserve
);
aWindow.gIdentityHandler._identityBox.click();
let doc = aWindow.document;
let permissions = doc.getElementById("identity-popup-permission-list");
gIdentityHandler._identityBox.click();
let permissions = document.getElementById("identity-popup-permission-list");
let cancelButton = permissions.querySelector(
".identity-popup-permission-icon." +
aType +
@ -535,7 +536,7 @@ async function stopSharing(
let observerPromise1 = expectObserverCalled(
"getUserMedia:revoke",
1,
aFrameBC
frameBCToObserve
);
// If we are stopping screen sharing and expect to still have another stream,
@ -545,13 +546,12 @@ async function stopSharing(
observerPromise2 = expectObserverCalled(
"recording-window-ended",
1,
aFrameBC
frameBCToObserve
);
}
cancelButton.click();
aWindow.gIdentityHandler._identityPopup.hidden = true;
gIdentityHandler._identityPopup.hidden = true;
await promiseRecordingEvent;
await observerPromise1;
await observerPromise2;
@ -660,8 +660,7 @@ async function reloadAndAssertClosedStreams() {
await checkNotSharing();
}
function checkDeviceSelectors(aAudio, aVideo, aScreen, aWindow = window) {
let document = aWindow.document;
function checkDeviceSelectors(aAudio, aVideo, aScreen) {
let micSelector = document.getElementById("webRTC-selectMicrophone");
if (aAudio) {
ok(!micSelector.hidden, "microphone selector visible");
@ -890,7 +889,7 @@ async function runTests(tests, options = {}) {
// Set prefs so that permissions prompts are shown and loopback devices
// are not used. To test the chrome we want prompts to be shown, and
// these tests are flakey when using loopback devices (though it would
// be desirable to make them work with loopback in future). See bug 1643711.
// be desirable to make them work with loopback in future).
let prefs = [
[PREF_PERMISSION_FAKE, true],
[PREF_AUDIO_LOOPBACK, ""],