mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 434a86b48ee0 (bug 1129567) because it wasn't meant to land on trunk.
This commit is contained in:
parent
e8e0e0c2b0
commit
5f7e590a4b
@ -14,11 +14,10 @@ const { getAttachEventType, WorkerHost } = require('./content/utils');
|
||||
const { Class } = require('./core/heritage');
|
||||
const { Disposable } = require('./core/disposable');
|
||||
const { WeakReference } = require('./core/reference');
|
||||
const { Worker } = require('./deprecated/sync-worker');
|
||||
const { Worker } = require('./content/worker');
|
||||
const { EventTarget } = require('./event/target');
|
||||
const { on, emit, once, setListeners } = require('./event/core');
|
||||
const { on: domOn, removeListener: domOff } = require('./dom/events');
|
||||
const { pipe } = require('./event/utils');
|
||||
const { isRegExp, isUndefined } = require('./lang/type');
|
||||
const { merge } = require('./util/object');
|
||||
const { windowIterator } = require('./deprecated/window-utils');
|
||||
@ -114,7 +113,6 @@ const PageMod = Class({
|
||||
modContract.properties(modelFor),
|
||||
EventTarget,
|
||||
Disposable,
|
||||
WeakReference
|
||||
],
|
||||
extends: WorkerHost(workerFor),
|
||||
setup: function PageMod(options) {
|
||||
@ -191,6 +189,10 @@ function applyOnExistingDocuments (mod) {
|
||||
getTabs().forEach(tab => {
|
||||
// Fake a newly created document
|
||||
let window = getTabContentWindow(tab);
|
||||
// on startup with e10s, contentWindow might not exist yet,
|
||||
// in which case we will get notified by "document-element-inserted".
|
||||
if (!window || !window.frames)
|
||||
return;
|
||||
let uri = getTabURI(tab);
|
||||
if (has(mod.attachTo, "top") && modMatchesURI(mod, uri))
|
||||
onContent(mod, window);
|
||||
@ -213,11 +215,15 @@ function createWorker (mod, window) {
|
||||
onError: (e) => emit(mod, 'error', e)
|
||||
});
|
||||
workers.set(mod, worker);
|
||||
pipe(worker, mod);
|
||||
emit(mod, 'attach', worker);
|
||||
once(worker, 'detach', function detach() {
|
||||
worker.destroy();
|
||||
});
|
||||
worker.on('*', (event, ...args) => {
|
||||
// worker's "attach" event passes a window as the argument
|
||||
// page-mod's "attach" event needs a worker
|
||||
if (event === 'attach')
|
||||
emit(mod, event, worker)
|
||||
else
|
||||
emit(mod, event, ...args);
|
||||
})
|
||||
once(worker, 'detach', () => worker.destroy());
|
||||
}
|
||||
|
||||
function onContent (mod, window) {
|
||||
@ -256,6 +262,20 @@ function onContent (mod, window) {
|
||||
return;
|
||||
domOff(window, eventName, onReady, true);
|
||||
createWorker(mod, window);
|
||||
|
||||
// Attaching is asynchronous so if the document is already loaded we will
|
||||
// miss the pageshow event so send a synthetic one.
|
||||
if (window.document.readyState == "complete") {
|
||||
mod.on('attach', worker => {
|
||||
try {
|
||||
worker.send('pageshow');
|
||||
emit(worker, 'pageshow');
|
||||
}
|
||||
catch (e) {
|
||||
// This can fail if an earlier attach listener destroyed the worker
|
||||
}
|
||||
});
|
||||
}
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user