mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 831367 - Simplify SpecialPowersAPI.bindDOMWindowUtils(), r=ted
This commit is contained in:
parent
f452feed2b
commit
d5e9be97ab
@ -54,7 +54,7 @@ function getRandomView(size)
|
|||||||
|
|
||||||
function getBlob(type, view)
|
function getBlob(type, view)
|
||||||
{
|
{
|
||||||
return utils.getBlob([view], {type: type});
|
return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomBlob(size)
|
function getRandomBlob(size)
|
||||||
|
@ -179,7 +179,7 @@ function compareBuffers(buffer1, buffer2)
|
|||||||
|
|
||||||
function getBlob(type, buffer)
|
function getBlob(type, buffer)
|
||||||
{
|
{
|
||||||
return utils.getBlob([buffer], {type: type});
|
return SpecialPowers.unwrap(utils.getBlob([buffer], {type: type}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomBlob(size)
|
function getRandomBlob(size)
|
||||||
@ -189,5 +189,5 @@ function getRandomBlob(size)
|
|||||||
|
|
||||||
function getFileId(blob)
|
function getFileId(blob)
|
||||||
{
|
{
|
||||||
return utils.getFileId(blob);
|
return SpecialPowers.unwrap(utils.getFileId(blob));
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,12 @@ function compareBuffers(buffer1, buffer2)
|
|||||||
|
|
||||||
function getBlob(type, view)
|
function getBlob(type, view)
|
||||||
{
|
{
|
||||||
return utils.getBlob([view], {type: type});
|
return SpecialPowers.unwrap(utils.getBlob([view], {type: type}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFile(name, type, view)
|
function getFile(name, type, view)
|
||||||
{
|
{
|
||||||
return utils.getFile(name, [view], {type: type});
|
return SpecialPowers.unwrap(utils.getFile(name, [view], {type: type}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomBlob(size)
|
function getRandomBlob(size)
|
||||||
|
@ -85,7 +85,8 @@ function testElementFromPoint() {
|
|||||||
moveEl.style.left = moveX + "px";
|
moveEl.style.left = moveX + "px";
|
||||||
moveEl.style.top = moveY + "px";
|
moveEl.style.top = moveY + "px";
|
||||||
}
|
}
|
||||||
let found = domWindowUtils.elementFromPoint(x, y, ignoreScroll, flushLayout);
|
let found = SpecialPowers.unwrap(domWindowUtils.elementFromPoint(
|
||||||
|
x, y, ignoreScroll, flushLayout));
|
||||||
is(found, expected, "at index " + i + " for data " + testData[i][0].toSource());
|
is(found, expected, "at index " + i + " for data " + testData[i][0].toSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,43 +32,9 @@ function bindDOMWindowUtils(aWindow) {
|
|||||||
if (!aWindow)
|
if (!aWindow)
|
||||||
return
|
return
|
||||||
|
|
||||||
var util = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
var util = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Components.interfaces.nsIDOMWindowUtils);
|
.getInterface(Ci.nsIDOMWindowUtils);
|
||||||
// This bit of magic brought to you by the letters
|
return wrapPrivileged(util);
|
||||||
// B Z, and E, S and the number 5.
|
|
||||||
//
|
|
||||||
// Take all of the properties on the nsIDOMWindowUtils-implementing
|
|
||||||
// object, and rebind them onto a new object with a stub that uses
|
|
||||||
// apply to call them from this privileged scope. This way we don't
|
|
||||||
// have to explicitly stub out new methods that appear on
|
|
||||||
// nsIDOMWindowUtils.
|
|
||||||
//
|
|
||||||
// Note that this will be a chrome object that is (possibly) exposed to
|
|
||||||
// content. Make sure to define __exposedProps__ for each property to make
|
|
||||||
// sure that it gets through the security membrane.
|
|
||||||
var proto = Object.getPrototypeOf(util);
|
|
||||||
var target = { __exposedProps__: {} };
|
|
||||||
function rebind(desc, prop) {
|
|
||||||
if (prop in desc && typeof(desc[prop]) == "function") {
|
|
||||||
var oldval = desc[prop];
|
|
||||||
try {
|
|
||||||
desc[prop] = function() {
|
|
||||||
return oldval.apply(util, arguments);
|
|
||||||
};
|
|
||||||
} catch (ex) {
|
|
||||||
dump("WARNING: Special Powers failed to rebind function: " + desc + "::" + prop + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (var i in proto) {
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(proto, i);
|
|
||||||
rebind(desc, "get");
|
|
||||||
rebind(desc, "set");
|
|
||||||
rebind(desc, "value");
|
|
||||||
Object.defineProperty(target, i, desc);
|
|
||||||
target.__exposedProps__[i] = 'rw';
|
|
||||||
}
|
|
||||||
return target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRawComponents(aWindow) {
|
function getRawComponents(aWindow) {
|
||||||
|
Loading…
Reference in New Issue
Block a user