Backed out changeset 4dbabf6ae78b (bug 1234118) for m2 test failures

This commit is contained in:
Carsten "Tomcat" Book 2015-12-29 09:35:29 +01:00
parent 1c044aaf5a
commit b781218e17
4 changed files with 39 additions and 10 deletions

View File

@ -68,6 +68,15 @@ const OBSERVED_EVENTS = [
'invalid-widget'
];
const COMMAND_MAP = {
'cut': 'cmd_cut',
'copy': 'cmd_copyAndCollapseToEnd',
'copyImage': 'cmd_copyImage',
'copyLink': 'cmd_copyLink',
'paste': 'cmd_paste',
'selectall': 'cmd_selectAll'
};
/**
* The BrowserElementChild implements one half of <iframe mozbrowser>.
* (The other half is, unsurprisingly, BrowserElementParent.)
@ -269,6 +278,7 @@ BrowserElementChild.prototype = {
"activate-next-paint-listener": this._activateNextPaintListener.bind(this),
"set-input-method-active": this._recvSetInputMethodActive.bind(this),
"deactivate-next-paint-listener": this._deactivateNextPaintListener.bind(this),
"do-command": this._recvDoCommand,
"find-all": this._recvFindAll.bind(this),
"find-next": this._recvFindNext.bind(this),
"clear-match": this._recvClearMatch.bind(this),
@ -397,6 +407,15 @@ BrowserElementChild.prototype = {
}
},
_isCommandEnabled: function(cmd) {
let command = COMMAND_MAP[cmd];
if (!command) {
return false;
}
return docShell.isCommandEnabled(command);
},
/**
* Spin in a nested event loop until we receive a unblock-modal-prompt message for
* this window.
@ -1177,16 +1196,14 @@ BrowserElementChild.prototype = {
_recvFireCtxCallback: function(data) {
debug("Received fireCtxCallback message: (" + data.json.menuitem + ")");
let doCommandIfEnabled = (command) => {
if (docShell.isCommandEnabled(command)) {
docShell.doCommand(command);
}
};
if (data.json.menuitem == 'copy-image') {
doCommandIfEnabled('cmd_copyImage');
// Set command
data.json.command = 'copyImage';
this._recvDoCommand(data);
} else if (data.json.menuitem == 'copy-link') {
doCommandIfEnabled('cmd_copyLink');
// Set command
data.json.command = 'copyLink';
this._recvDoCommand(data);
} else if (data.json.menuitem in this._ctxHandlers) {
this._ctxHandlers[data.json.menuitem].click();
this._ctxHandlers = {};
@ -1365,6 +1382,12 @@ BrowserElementChild.prototype = {
docShell.contentViewer.fullZoom = data.json.zoom;
},
_recvDoCommand: function(data) {
if (this._isCommandEnabled(data.json.command)) {
docShell.doCommand(COMMAND_MAP[data.json.command]);
}
},
_recvGetAudioChannelVolume: function(data) {
debug("Received getAudioChannelVolume message: (" + data.json.id + ")");

View File

@ -30,7 +30,7 @@ var CopyPasteAssistent = {
switch (e.data.msg_name) {
case 'copypaste-do-command':
if (this._isCommandEnabled(e.data.command)) {
docShell.doCommand(this.COMMAND_MAP[e.data.command]);
docShell.doCommand(COMMAND_MAP[e.data.command]);
}
break;
}

View File

@ -250,6 +250,7 @@ function BrowserElementParent() {
this._pendingDOMFullscreen = false;
Services.obs.addObserver(this, 'oop-frameloader-crashed', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'copypaste-docommand', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'ask-children-to-execute-copypaste-command', /* ownsWeak = */ true);
Services.obs.addObserver(this, 'back-docommand', /* ownsWeak = */ true);
@ -1294,6 +1295,11 @@ BrowserElementParent.prototype = {
this._fireFatalError();
}
break;
case 'copypaste-docommand':
if (this._isAlive() && this._frameElement.isEqualNode(subject.wrappedJSObject)) {
this._sendAsyncMsg('do-command', { command: data });
}
break;
case 'ask-children-to-execute-copypaste-command':
if (this._isAlive() && this._frameElement == subject.wrappedJSObject) {
this._sendAsyncMsg('copypaste-do-command', { command: data });

View File

@ -87,7 +87,7 @@ function runTest() {
function doCommand(cmd) {
Services.obs.notifyObservers({wrappedJSObject: SpecialPowers.unwrap(iframeInner)},
'ask-children-to-execute-copypaste-command', cmd);
'copypaste-docommand', cmd);
}
function dispatchTest(e) {