mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1129567 - Revert page-mod to using the old synchronous worker. r=jsantell
This commit is contained in:
parent
d84931360e
commit
e8e0e0c2b0
@ -14,10 +14,11 @@ const { getAttachEventType, WorkerHost } = require('./content/utils');
|
||||
const { Class } = require('./core/heritage');
|
||||
const { Disposable } = require('./core/disposable');
|
||||
const { WeakReference } = require('./core/reference');
|
||||
const { Worker } = require('./content/worker');
|
||||
const { Worker } = require('./deprecated/sync-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');
|
||||
@ -113,6 +114,7 @@ const PageMod = Class({
|
||||
modContract.properties(modelFor),
|
||||
EventTarget,
|
||||
Disposable,
|
||||
WeakReference
|
||||
],
|
||||
extends: WorkerHost(workerFor),
|
||||
setup: function PageMod(options) {
|
||||
@ -189,10 +191,6 @@ 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);
|
||||
@ -215,15 +213,11 @@ function createWorker (mod, window) {
|
||||
onError: (e) => emit(mod, 'error', e)
|
||||
});
|
||||
workers.set(mod, worker);
|
||||
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());
|
||||
pipe(worker, mod);
|
||||
emit(mod, 'attach', worker);
|
||||
once(worker, 'detach', function detach() {
|
||||
worker.destroy();
|
||||
});
|
||||
}
|
||||
|
||||
function onContent (mod, window) {
|
||||
@ -262,20 +256,6 @@ 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