mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 781521 - Fix BrowserElement API. r=jlebar
This commit is contained in:
parent
ef3a2ff757
commit
2e09cc91eb
@ -28,6 +28,33 @@ function getBoolPref(prefName, def) {
|
||||
}
|
||||
}
|
||||
|
||||
function exposeAll(obj) {
|
||||
// Filter for Objects and Arrays.
|
||||
if (typeof obj !== "object" || !obj)
|
||||
return;
|
||||
|
||||
// Recursively expose our children.
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
exposeAll(obj[key]);
|
||||
});
|
||||
|
||||
// If we're not an Array, generate an __exposedProps__ object for ourselves.
|
||||
if (obj instanceof Array)
|
||||
return;
|
||||
var exposed = {};
|
||||
Object.keys(obj).forEach(function(key) {
|
||||
exposed[key] = 'rw';
|
||||
});
|
||||
obj.__exposedProps__ = exposed;
|
||||
}
|
||||
|
||||
function defineAndExpose(obj, name, value) {
|
||||
obj[name] = value;
|
||||
if (!('__exposedProps__' in obj))
|
||||
obj.__exposedProps__ = {};
|
||||
obj.__exposedProps__[name] = 'r';
|
||||
}
|
||||
|
||||
/**
|
||||
* BrowserElementParent implements one half of <iframe mozbrowser>. (The other
|
||||
* half is, unsurprisingly, BrowserElementChild.)
|
||||
@ -275,9 +302,9 @@ BrowserElementParent.prototype = {
|
||||
|
||||
if (detail.contextmenu) {
|
||||
var self = this;
|
||||
XPCNativeWrapper.unwrap(evt.detail).contextMenuItemSelected = function(id) {
|
||||
defineAndExpose(evt.detail, 'contextMenuItemSelected', function(id) {
|
||||
self._sendAsyncMsg('fire-ctx-callback', {menuitem: id});
|
||||
};
|
||||
});
|
||||
}
|
||||
// The embedder may have default actions on context menu events, so
|
||||
// we fire a context menu event even if the child didn't define a
|
||||
@ -338,9 +365,9 @@ BrowserElementParent.prototype = {
|
||||
self._sendAsyncMsg('unblock-modal-prompt', data);
|
||||
}
|
||||
|
||||
XPCNativeWrapper.unwrap(evt.detail).unblock = function() {
|
||||
defineAndExpose(evt.detail, 'unblock', function() {
|
||||
sendUnblockMsg();
|
||||
};
|
||||
});
|
||||
|
||||
this._frameElement.dispatchEvent(evt);
|
||||
|
||||
@ -355,6 +382,7 @@ BrowserElementParent.prototype = {
|
||||
// This will have to change if we ever want to send a CustomEvent with null
|
||||
// detail. For now, it's OK.
|
||||
if (detail !== undefined && detail !== null) {
|
||||
exposeAll(detail);
|
||||
return new this._window.CustomEvent('mozbrowser' + evtName,
|
||||
{ bubbles: true,
|
||||
cancelable: cancelable,
|
||||
|
@ -29,7 +29,7 @@ BrowserElementPrompt.prototype = {
|
||||
|
||||
alert: function(title, text) {
|
||||
this._browserElementChild.showModalPrompt(
|
||||
this._win, {promptType: "alert", title: title, message: text});
|
||||
this._win, {promptType: "alert", title: title, message: text, returnValue: undefined});
|
||||
},
|
||||
|
||||
alertCheck: function(title, text, checkMsg, checkState) {
|
||||
@ -40,7 +40,7 @@ BrowserElementPrompt.prototype = {
|
||||
|
||||
confirm: function(title, text) {
|
||||
return this._browserElementChild.showModalPrompt(
|
||||
this._win, {promptType: "confirm", title: title, message: text});
|
||||
this._win, {promptType: "confirm", title: title, message: text, returnValue: undefined});
|
||||
},
|
||||
|
||||
confirmCheck: function(title, text, checkMsg, checkState) {
|
||||
|
@ -21,11 +21,11 @@ function runTest() {
|
||||
mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.addMessageListener('test-success', function(msg) {
|
||||
numPendingChildTests--;
|
||||
ok(true, msg.json);
|
||||
ok(true, SpecialPowers.wrap(msg).json);
|
||||
});
|
||||
mm.addMessageListener('test-fail', function(msg) {
|
||||
numPendingChildTests--;
|
||||
ok(false, msg.json);
|
||||
ok(false, SpecialPowers.wrap(msg).json);
|
||||
});
|
||||
|
||||
// Wait for the initial load to finish, then navigate the page, then wait
|
||||
|
@ -103,6 +103,7 @@ function runTest() {
|
||||
}
|
||||
|
||||
function ctxCallbackRecieved(msg) {
|
||||
msg = SpecialPowers.wrap(msg);
|
||||
ctxCallbackEvents++;
|
||||
if (ctxCallbackEvents === 1) {
|
||||
ok(msg.json.data === 'inner2', 'Callback function got fired correctly');
|
||||
|
@ -31,6 +31,7 @@ function runTest() {
|
||||
}
|
||||
|
||||
function iframeBodyRecv(data) {
|
||||
data = SpecialPowers.wrap(data);
|
||||
var previousCount = countAcc;
|
||||
var currentCount = parseInt(data.json.data, 10);
|
||||
countAcc = currentCount;
|
||||
|
@ -28,6 +28,7 @@ function runTest() {
|
||||
document.body.appendChild(iframe1);
|
||||
|
||||
function recvVisibilityChanged(msg) {
|
||||
msg = SpecialPowers.wrap(msg);
|
||||
numEvents++;
|
||||
if (numEvents === 1) {
|
||||
ok(true, 'iframe recieved visibility changed');
|
||||
|
Loading…
Reference in New Issue
Block a user