зеркало из https://github.com/mozilla/pjs.git
Bug 666643 - convert snapshotWindow to SpecialPowers. r=ted
This commit is contained in:
Родитель
745e6620dc
Коммит
4e805ec92d
|
@ -20,7 +20,7 @@
|
|||
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok" ];
|
||||
var imports = [ "SimpleTest", "is", "isnot", "ok", "SpecialPowers" ];
|
||||
for each (var name in imports) {
|
||||
window[name] = window.opener.wrappedJSObject[name];
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var gWindowUtils;
|
||||
|
||||
try {
|
||||
gWindowUtils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
gWindowUtils = SpecialPowers.getDOMWindowUtils(window);
|
||||
if (gWindowUtils && !gWindowUtils.compareCanvases)
|
||||
gWindowUtils = null;
|
||||
} catch (e) {
|
||||
|
@ -11,28 +9,13 @@ try {
|
|||
}
|
||||
|
||||
function snapshotWindow(win, withCaret) {
|
||||
// drawWindow requires privileges, as might innerWidth/innerHeight if it's
|
||||
// a cross domain window
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var el = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
el.width = win.innerWidth;
|
||||
el.height = win.innerHeight;
|
||||
|
||||
var ctx = el.getContext("2d");
|
||||
ctx.drawWindow(win, win.scrollX, win.scrollY,
|
||||
win.innerWidth, win.innerHeight,
|
||||
"rgb(255,255,255)",
|
||||
withCaret ? ctx.DRAWWINDOW_DRAW_CARET : 0);
|
||||
return el;
|
||||
return SpecialPowers.snapshotWindow(win, withCaret);
|
||||
}
|
||||
|
||||
// If the two snapshots don't compare as expected (true for equal, false for
|
||||
// unequal), returns their serializations as data URIs. In all cases, returns
|
||||
// whether the comparison was as expected.
|
||||
function compareSnapshots(s1, s2, expected) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
|
||||
var s1Str, s2Str;
|
||||
var correct = false;
|
||||
if (gWindowUtils) {
|
||||
|
|
|
@ -662,5 +662,19 @@ SpecialPowersAPI.prototype = {
|
|||
getService(Components.interfaces.nsIClipboardHelper);
|
||||
cbHelperSvc.copyString(preExpectedVal);
|
||||
},
|
||||
|
||||
snapshotWindow: function (win, withCaret) {
|
||||
var el = this.window.document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
el.width = win.innerWidth;
|
||||
el.height = win.innerHeight;
|
||||
var ctx = el.getContext("2d");
|
||||
var flags = 0;
|
||||
|
||||
ctx.drawWindow(win, win.scrollX, win.scrollY,
|
||||
win.innerWidth, win.innerHeight,
|
||||
"rgb(255,255,255)",
|
||||
withCaret ? ctx.DRAWWINDOW_DRAW_CARET : 0);
|
||||
return el;
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче