mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 829872 - Fix up tests that depend on contentDocument being non-null. r=imelven
These almost universally depend on some sort of special privileges, so I don't think they're representative of any use-cases we might find on the web.
This commit is contained in:
parent
9b90be6731
commit
d02fa60c1c
@ -21,10 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=364677
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
// Need privs because the feed seems to have an about:feeds principal or some
|
||||
// such. It's not same-origin with us in any case.
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
is($("testFrame").contentDocument.documentElement.id, "feedHandler",
|
||||
is(SpecialPowers.wrap($("testFrame")).contentDocument.documentElement.id, "feedHandler",
|
||||
"Feed served as text/xml without a channel/link should have been sniffed");
|
||||
});
|
||||
addLoadEvent(SimpleTest.finish);
|
||||
|
@ -20,8 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=436801
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function () {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var doc = $("testFrame").contentDocument;
|
||||
var doc = SpecialPowers.wrap($("testFrame")).contentDocument;
|
||||
|
||||
checkNode(doc.getElementById("feedTitleText"), [
|
||||
"ELEMENT", "h1", { "xml:base": "http://www.example.com/foo/bar/" }, [
|
||||
|
@ -21,8 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=494328
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
var links = $("testFrame").contentDocument.getElementById("feedContent").querySelectorAll("div.enclosure > a");
|
||||
var links = SpecialPowers.wrap($("testFrame")).contentDocument.getElementById("feedContent").querySelectorAll("div.enclosure > a");
|
||||
is(links[0].textContent, "Episode 1", "filename decoded incorrectly");
|
||||
is(links[1].textContent, "Episode #2", "filename decoded incorrectly");
|
||||
is(links[2].textContent, "http://www.example.com/podcasts/Episode #3/", "filename decoded incorrectly");
|
||||
|
@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=589543
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
addLoadEvent(function() {
|
||||
var doc = SpecialPowers.wrap($("testFrame").contentDocument);
|
||||
var doc = SpecialPowers.wrap($("testFrame")).contentDocument;
|
||||
var daddy = doc.getElementById("feedSubscribeLine");
|
||||
var popup = doc.getAnonymousElementByAttribute(daddy, "anonid", "handlersMenuPopup");
|
||||
isnot(popup, null, "Feed preview should have a handlers popup");
|
||||
|
@ -15,19 +15,16 @@
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
function examiner() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var obsvc = Components.classes['@mozilla.org/observer-service;1']
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
obsvc.addObserver(this, "http-on-examine-response", false);
|
||||
SpecialPowers.addObserver(this, "http-on-examine-response", false);
|
||||
}
|
||||
examiner.prototype = {
|
||||
observe: function(subject, topic, data) {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
subject = SpecialPowers.wrap(subject);
|
||||
if(!subject.QueryInterface)
|
||||
return;
|
||||
|
||||
if (topic == "http-on-examine-response") {
|
||||
var chan = subject.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
var chan = subject.QueryInterface(SpecialPowers.Ci.nsIHttpChannel);
|
||||
var uri = chan.URI
|
||||
if (!uri.path.match(/^\/tests\/content\/base\/test\/file_x-frame-options_page\.sjs/))
|
||||
return;
|
||||
@ -43,10 +40,7 @@ examiner.prototype = {
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var obsvc = Components.classes['@mozilla.org/observer-service;1']
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
obsvc.removeObserver(this, "http-on-examine-response");
|
||||
SpecialPowers.removeObserver(this, "http-on-examine-response");
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +49,7 @@ window.examiner = new examiner();
|
||||
var path = "/tests/content/base/test/";
|
||||
|
||||
var testFramesLoaded = function() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var harness = document.getElementById("harness");
|
||||
var harness = SpecialPowers.wrap(document).getElementById("harness");
|
||||
|
||||
// iframe from same origin, no X-F-O header - should load
|
||||
var frame = harness.contentDocument.getElementById("control1");
|
||||
|
@ -198,16 +198,18 @@ function doIf10TestPart1() {
|
||||
if (firstPrincipal != "")
|
||||
return;
|
||||
|
||||
// use SpecialPowers to get the principal of if_10
|
||||
// use SpecialPowers to get the principal of if_10.
|
||||
// NB: We stringify here and below because special-powers wrapping doesn't
|
||||
// preserve identity.
|
||||
var if_10 = document.getElementById('if_10');
|
||||
firstPrincipal = SpecialPowers.getNodePrincipal(if_10.contentDocument);
|
||||
firstPrincipal = SpecialPowers.wrap(if_10).contentDocument.nodePrincipal.origin;
|
||||
if_10.src = 'file_iframe_sandbox_d_if10.html';
|
||||
|
||||
}
|
||||
function doIf10TestPart2() {
|
||||
var if_10 = document.getElementById('if_10');
|
||||
// use SpecialPowers to get the principal of if_10
|
||||
secondPrincipal = SpecialPowers.getNodePrincipal(if_10.contentDocument);
|
||||
secondPrincipal = SpecialPowers.wrap(if_10).contentDocument.nodePrincipal.origin;
|
||||
ok_wrapper(firstPrincipal != secondPrincipal, "documents should NOT have the same principal if they are sandboxed without" +
|
||||
" allow-same-origin and the first document is navigated to the second");
|
||||
}
|
||||
|
@ -5,7 +5,10 @@
|
||||
var embed = document.getElementsByTagName('embed')[0];
|
||||
if (undefined === embed)
|
||||
embed = document.getElementsByTagName('object')[0];
|
||||
try {
|
||||
|
||||
// In the file:// URI case, this ends up being cross-origin.
|
||||
// Skip these checks in that case.
|
||||
if (testframe.contentDocument) {
|
||||
var content = testframe.contentDocument.body.innerHTML;
|
||||
if (!content.length)
|
||||
return;
|
||||
@ -14,7 +17,7 @@
|
||||
embed.getAttribute("geturl") ||
|
||||
embed.getAttribute("geturlnotify") ||
|
||||
embed.getAttribute("data");
|
||||
|
||||
|
||||
var req = new XMLHttpRequest();
|
||||
req.open('GET', filename, false);
|
||||
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
@ -23,18 +26,7 @@
|
||||
is(content, req.responseText.replace(/\r\n/g, "\n"),
|
||||
"content doesn't match");
|
||||
}
|
||||
catch (e) {
|
||||
// For file:// url's, such as we get during the NPN_NewStream test,
|
||||
// attempting to access the frame content throws an exception.
|
||||
// For this case, we just verify the onload event is called.
|
||||
|
||||
// XXXbent Need to fix the underlying change to this message here! Should
|
||||
// the message include 'file://'? Message needs to be localized
|
||||
// and include both origins in the error console too!
|
||||
ok(e.message.indexOf("Permission denied") > -1 &&
|
||||
e.message.indexOf("access property 'body'") > -1,
|
||||
"Unexpected exception thrown: " + e.message);
|
||||
}
|
||||
is(embed.getError(), "pass", "plugin reported error");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -23,7 +23,10 @@ window.addEventListener("message", function () { gen.next() }, false);
|
||||
function go() {
|
||||
var ifr = $('ifr');
|
||||
try {
|
||||
document.createTreeWalker(ifr.contentDocument, 0, null);
|
||||
// NB: the contentDocument getter now returns null for cross-origin
|
||||
// frames, so use SpecialPowers to get a security wrapper to the document.
|
||||
var xdoc = SpecialPowers.unwrap(SpecialPowers.wrap(ifr).contentDocument)
|
||||
document.createTreeWalker(xdoc, 0, null);
|
||||
ok(false, "should have thrown a security exception");
|
||||
} catch (e) {
|
||||
ok(/NS_ERROR_XPC_SECURITY_MANAGER_VETO/.test(e) ||
|
||||
|
@ -130,13 +130,12 @@ function startTest1() {
|
||||
}
|
||||
|
||||
function checkTest3() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
ok(true, "checkTest3 starting");
|
||||
ok(didDialog, "handleDialog was invoked");
|
||||
|
||||
// check contents of iframe1 fields
|
||||
var u = iframe1.contentDocument.getElementById("userfield");
|
||||
var p = iframe1.contentDocument.getElementById("passfield");
|
||||
var u = SpecialPowers.wrap(iframe1).contentDocument.getElementById("userfield");
|
||||
var p = SpecialPowers.wrap(iframe1).contentDocument.getElementById("passfield");
|
||||
is(u.value, "user1", "checking expected user to have been filled in");
|
||||
is(p.value, "pass1", "checking expected pass to have been filled in");
|
||||
|
||||
@ -155,13 +154,12 @@ function checkTest3() {
|
||||
}
|
||||
|
||||
function checkTest4A() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
ok(true, "checkTest4A starting");
|
||||
ok(didDialog, "handleDialog was invoked");
|
||||
|
||||
// check contents of iframe1 fields
|
||||
var u = iframe1.contentDocument.getElementById("userfield");
|
||||
var p = iframe1.contentDocument.getElementById("passfield");
|
||||
var u = SpecialPowers.wrap(iframe1).contentDocument.getElementById("userfield");
|
||||
var p = SpecialPowers.wrap(iframe1).contentDocument.getElementById("passfield");
|
||||
is(u.value, "", "checking expected empty user");
|
||||
is(p.value, "", "checking expected empty pass");
|
||||
|
||||
@ -178,14 +176,13 @@ function checkTest4A() {
|
||||
}
|
||||
|
||||
function checkTest4B() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
ok(true, "checkTest4B starting");
|
||||
// iframe2 should load without having triggered a MP prompt (because one
|
||||
// is already waiting)
|
||||
|
||||
// check contents of iframe2 fields
|
||||
var u = iframe2.contentDocument.getElementById("userfield");
|
||||
var p = iframe2.contentDocument.getElementById("passfield");
|
||||
var u = SpecialPowers.wrap(iframe2).contentDocument.getElementById("userfield");
|
||||
var p = SpecialPowers.wrap(iframe2).contentDocument.getElementById("passfield");
|
||||
is(u.value, "", "checking expected empty user");
|
||||
is(p.value, "", "checking expected empty pass");
|
||||
|
||||
@ -199,7 +196,6 @@ function checkTest4B() {
|
||||
}
|
||||
|
||||
function checkTest4C() {
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
// iframe1 finally loads after the MP entry.
|
||||
ok(true, "checkTest4C starting");
|
||||
ok(didDialog, "handleDialog was invoked");
|
||||
@ -211,14 +207,14 @@ function checkTest4C() {
|
||||
ok(pwcrypt.isLoggedIn, "should be logged in");
|
||||
|
||||
// check contents of iframe1 fields
|
||||
var u = iframe1.contentDocument.getElementById("userfield");
|
||||
var p = iframe1.contentDocument.getElementById("passfield");
|
||||
var u = SpecialPowers.wrap(iframe1).contentDocument.getElementById("userfield");
|
||||
var p = SpecialPowers.wrap(iframe1).contentDocument.getElementById("passfield");
|
||||
is(u.value, "user2", "checking expected user to have been filled in");
|
||||
is(p.value, "pass2", "checking expected pass to have been filled in");
|
||||
|
||||
// check contents of iframe2 fields
|
||||
u = iframe2.contentDocument.getElementById("userfield");
|
||||
p = iframe2.contentDocument.getElementById("passfield");
|
||||
u = SpecialPowers.wrap(iframe2).contentDocument.getElementById("userfield");
|
||||
p = SpecialPowers.wrap(iframe2).contentDocument.getElementById("passfield");
|
||||
is(u.value, "user1", "checking expected user to have been filled in");
|
||||
is(p.value, "pass1", "checking expected pass to have been filled in");
|
||||
|
||||
|
@ -87,8 +87,8 @@ function checkTest() {
|
||||
|
||||
// The document generated from formsubmit.sjs contains the user/pass it
|
||||
// received inside <span id="blah">value</span>
|
||||
var gotUser = iframe.contentDocument.getElementById("user").textContent;
|
||||
var gotPass = iframe.contentDocument.getElementById("pass").textContent;
|
||||
var gotUser = SpecialPowers.wrap(iframe).contentDocument.getElementById("user").textContent;
|
||||
var gotPass = SpecialPowers.wrap(iframe).contentDocument.getElementById("pass").textContent;
|
||||
|
||||
|
||||
switch(testNum) {
|
||||
|
Loading…
Reference in New Issue
Block a user