Skip to content

Commit

Permalink
Bug 1592166 - part5 : add test case to check that activating child's …
Browse files Browse the repository at this point in the history
…frame would also activate parent's frame. r=jya

Increase test cases of activating child frame would also activate its parent frame, no matter the child frame is cross-origin or not.

Differential Revision: https://phabricator.services.mozilla.com/D51691

--HG--
extra : moz-landing-system : lando
  • Loading branch information
alastor0325 committed Nov 6, 2019
1 parent 9f6063e commit 42e3159
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions dom/media/test/file_autoplay_policy_activation_frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
(event) => {
if (event.data == "click") {
SpecialPowers.wrap(document).notifyUserGestureActivation();
event.source.postMessage("activated", "*");
} else if (event.data == "play-audible") {
playAndPostResult(false, event.source);
} else if (event.data == "play-muted") {
Expand Down
5 changes: 3 additions & 2 deletions dom/media/test/file_autoplay_policy_activation_window.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
return frame;
}

function activateDocument(testInfo) {
async function activateDocument(testInfo) {
// Click the window to activate if appropriate.
if (testInfo.activated_from == "parent") {
info(`activate parent's document`);
SpecialPowers.wrap(document).notifyUserGestureActivation();
} else if (testInfo.activated_from == "child") {
info(`activate child's document`);
testInfo.childFrame.contentWindow.postMessage("click", "*");
is((await nextWindowMessage()).data, "activated", "has activated child frame.");
}
}

Expand All @@ -61,7 +62,7 @@
testInfo.parentWindow = event.source;
testInfo.childFrame = await createChildFrame(testInfo);

activateDocument(testInfo);
await activateDocument(testInfo);
switch (testInfo.play_from) {
case "parent":
testAutoplayInWindow(testInfo);
Expand Down
18 changes: 18 additions & 0 deletions dom/media/test/test_autoplay_policy_activation.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@
should_play: false,
},

{
name: "audible playback in activated document (via cross-origin child) -> allowed",
muted: false,
same_origin_child: false,
activated_from: "child",
play_from: "parent",
should_play: true,
},

{
name: "audible playback in activated document (via same-origin child) -> allowed",
muted: false,
same_origin_child: true,
activated_from: "child",
play_from: "parent",
should_play: true,
},

{
name: "inaudible playback in activated document -> allowed",
muted: true,
Expand Down

0 comments on commit 42e3159

Please sign in to comment.