Bug 1360715 - Part 3: Remove remaining cross-context instanceof from tests r=edgar

Differential Revision: https://phabricator.services.mozilla.com/D106663
This commit is contained in:
Kagami Sascha Rosylight 2021-03-04 22:03:58 +00:00
Родитель a9417a719e
Коммит e9a7261412
6 изменённых файлов: 23 добавлений и 17 удалений

Просмотреть файл

@ -6,7 +6,7 @@ function expectException(func, exceptionCode) {
func();
} catch (ex) {
threw = true;
ok(ex instanceof DOMException, "Expect a DOM exception");
is(ex.constructor.name, "DOMException", "Expect a DOM exception");
is(ex.code, exceptionCode, "Expect the correct exception code");
}
ok(threw, "The exception was thrown");

Просмотреть файл

@ -129,7 +129,7 @@ async function runTests() {
`${aDescription}"beforeinput" event at ${aTestData.action} must be trusted`);
is(aEvent.target, eventTarget,
`${aDescription}"beforeinput" event at ${aTestData.action} is fired on unexpected element: ${aEvent.target.tagName}`);
ok(aEvent instanceof InputEvent,
is(aEvent.constructor.name, "InputEvent",
`${aDescription}"beforeinput" event at ${aTestData.action} should be dispatched with InputEvent interface`);
ok(aEvent.bubbles,
`${aDescription}"beforeinput" event at ${aTestData.action} must be bubbles`);
@ -148,7 +148,7 @@ async function runTests() {
`${aDescription}"input" event at ${aTestData.action} must be trusted`);
is(aEvent.target, eventTarget,
`${aDescription}"input" event at ${aTestData.action} is fired on unexpected element: ${aEvent.target.tagName}`);
ok(aEvent instanceof InputEvent,
is(aEvent.constructor.name, "InputEvent",
`${aDescription}"input" event at ${aTestData.action} should be dispatched with InputEvent interface`);
ok(!aEvent.cancelable,
`${aDescription}"input" event at ${aTestData.action} must not be cancelable`);

Просмотреть файл

@ -202,7 +202,11 @@ function getTargetRect(aTarget) {
// If the target is the root content window, its origin relative
// to the visual viewport is (0, 0).
if (aTarget instanceof Window) {
// FIXME: Assert that it's not an iframe window.
return rect;
}
if (aTarget.Window && aTarget instanceof aTarget.Window) {
// iframe window
// FIXME: Compute proper rect against the root content window
return rect;
}

Просмотреть файл

@ -13,7 +13,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870423
/** Test for cross-scope instanceof. **/
SimpleTest.waitForExplicitFinish();
function go() {
async function go() {
await SpecialPowers.pushPrefEnv({ set: [["dom.webidl.crosscontext_hasinstance.enabled", false]] });
var sowin = $('soifr').contentWindow;
var xowin = $('xoifr').contentWindow;
var xosswin = $('xossifr').contentWindow;
@ -23,21 +25,21 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=870423
check(window, sowin, 'Window', function(win) { return win; });
check(window, sowin, 'Location', function(win) { return win.location; });
ok(xowin instanceof Window, "Cross-origin instanceof should work");
ok(xowin.location instanceof Location, "Cross-origin instanceof should work");
ok(!(xowin instanceof Window), "Cross-origin instanceof should fail");
ok(!(xowin.location instanceof Location), "Cross-origin instanceof should fail");
// cross-origin same-site.
ok(xosswin instanceof Window, "Cross-origin instanceof should work");
ok(xosswin.location instanceof Location, "Cross-origin instanceof should work");
ok(!(xosswin instanceof Window), "Cross-origin instanceof should fail");
ok(!(xosswin.location instanceof Location), "Cross-origin instanceof should fail");
SimpleTest.finish();
}
function check(win1, win2, constructorName, getInstance) {
ok(getInstance(win1) instanceof win2[constructorName],
"Cross-Scope instanceof works: " + constructorName + ", " + win1.location + ", " + win2.location);
ok(getInstance(win2) instanceof win1[constructorName],
"Cross-Scope instanceof works: " + constructorName + ", " + win2.location + ", " + win1.location);
ok(!(getInstance(win1) instanceof win2[constructorName]),
"Cross-Scope instanceof fails: " + constructorName + ", " + win1.location + ", " + win2.location);
ok(!(getInstance(win2) instanceof win1[constructorName]),
"Cross-Scope instanceof fails: " + constructorName + ", " + win2.location + ", " + win1.location);
}
</script>

Просмотреть файл

@ -22,9 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916945
// Both same-origin and cross-origin names should be visible if they're set
// on the iframe element.
ok('winA' in window, "same-origin named access works");
ok(winA instanceof Window, "same-origin named access works");
ok(winA instanceof winA.Window, "same-origin named access works");
ok('winB' in window, "cross-origin named access works when iframe name matches");
ok(winB instanceof Window, "cross-origin named access works when iframe name matches");
is(winB.parent, window, "cross-origin named access works when iframe name matches");
// Setting the 'name' attribute should propagate to the docshell.
var ifrB = document.getElementById('ifrB');
@ -39,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=916945
'attribute sets propagate to the docshell');
});
ok('foo' in window, "names are dynamic if updated via setAttribute");
ok(foo instanceof Window, "names are dynamic if updated via setAttribute");
is(foo.parent, window, "names are dynamic if updated via setAttribute");
// Setting window.name on the subframe should not propagate to the attribute.
await SpecialPowers.spawn(ifrB, [], () => {

Просмотреть файл

@ -202,7 +202,7 @@ function addLevels(walker, buf, indent) {
// In the case of template elements, children do not get inserted as
// children of the template element, instead they are inserted
// as children of the template content (which is a document fragment).
if (walker.currentNode instanceof HTMLTemplateElement) {
if (walker.currentNode.constructor.name === "HTMLTemplateElement") {
buf += indent + " content\n";
// Walk through the template content.
var templateWalker = createFragmentWalker(walker.currentNode.content);