зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563597 - Support nsGlobalWindowOuter as observer notification's subject; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D39029 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6b2b3d2faa
Коммит
5bed95bf3d
|
@ -155,10 +155,10 @@ dictionary WindowActorChildOptions : WindowActorSidedOptions {
|
|||
* An array of observer topics to listen to. An observer will be added for each
|
||||
* topic in the list.
|
||||
*
|
||||
* Observer notifications in the list use nsGlobalWindowInner object as their
|
||||
* subject, and the events will only be dispatched to the corresponding window
|
||||
* actor. If additional observer notification's subjects are needed, please
|
||||
* file a bug for that.
|
||||
* Observer notifications in the list use nsGlobalWindowInner or
|
||||
* nsGlobalWindowOuter object as their subject, and the events will only be
|
||||
* dispatched to the corresponding window actor. If additional observer
|
||||
* notification's subjects are needed, please file a bug for that.
|
||||
**/
|
||||
sequence<ByteString> observers;
|
||||
};
|
||||
|
|
|
@ -204,11 +204,18 @@ NS_IMETHODIMP JSWindowActorProtocol::Observe(nsISupports* aSubject,
|
|||
const char* aTopic,
|
||||
const char16_t* aData) {
|
||||
nsCOMPtr<nsPIDOMWindowInner> inner = do_QueryInterface(aSubject);
|
||||
if (NS_WARN_IF(!inner)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
RefPtr<WindowGlobalChild> wgc;
|
||||
|
||||
if (!inner) {
|
||||
nsCOMPtr<nsPIDOMWindowOuter> outer = do_QueryInterface(aSubject);
|
||||
if (NS_WARN_IF(!outer) || NS_WARN_IF(!outer->GetCurrentInnerWindow())) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
wgc = outer->GetCurrentInnerWindow()->GetWindowGlobalChild();
|
||||
} else {
|
||||
wgc = inner->GetWindowGlobalChild();
|
||||
}
|
||||
|
||||
RefPtr<WindowGlobalChild> wgc = inner->GetWindowGlobalChild();
|
||||
if (NS_WARN_IF(!wgc)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
|
@ -12,6 +12,9 @@ skip-if = fission
|
|||
fail-if = fission
|
||||
[browser_observer_notification.js]
|
||||
skip-if = fission
|
||||
support-files=
|
||||
file_mediaPlayback.html
|
||||
audio.ogg
|
||||
[browser_registerWindowActor.js]
|
||||
skip-if = fission
|
||||
[browser_sendAsyncMessage.js]
|
||||
|
|
|
@ -62,3 +62,26 @@ declTest("observers don't notify with wrong window", {
|
|||
});
|
||||
},
|
||||
});
|
||||
|
||||
declTest("observers notify with audio-playback", {
|
||||
url: "http://example.com/browser/dom/ipc/tests/JSWindowActor/file_mediaPlayback.html",
|
||||
|
||||
async test(browser) {
|
||||
await ContentTask.spawn(browser, {}, async function() {
|
||||
let audio = content.document.querySelector("audio");
|
||||
audio.play();
|
||||
|
||||
let child = content.window.getWindowGlobalChild();
|
||||
let actorChild = child.getActor("Test");
|
||||
ok(actorChild, "JSWindowActorChild should have value.");
|
||||
|
||||
let observePromise = new Promise(resolve => {
|
||||
actorChild.done = ({subject, topic, data}) => resolve({subject, topic, data});
|
||||
});
|
||||
|
||||
let {subject, topic, data} = await observePromise;
|
||||
is(topic, "audio-playback", "Topic matches");
|
||||
is(data, "active", "Data matches");
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<audio src="audio.ogg" controls loop>
|
|
@ -18,7 +18,7 @@ let windowActorOptions = {
|
|||
mozshowdropdown: {},
|
||||
},
|
||||
|
||||
observers: ["test-js-window-actor-child-observer"],
|
||||
observers: ["test-js-window-actor-child-observer", "audio-playback"],
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -37,7 +37,14 @@ class TestChild extends JSWindowActorChild {
|
|||
}
|
||||
|
||||
observe(subject, topic, data) {
|
||||
this.lastObserved = { subject, topic, data };
|
||||
switch (topic) {
|
||||
case "audio-playback":
|
||||
this.done({subject, topic, data});
|
||||
break;
|
||||
default:
|
||||
this.lastObserved = { subject, topic, data };
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
show() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче