Bug 1396620 - Part 1: Remove created callback for custom elements

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-20 19:49:20 -05:00 committed by Roy Tam
commit baa035c5c4
13 changed files with 22 additions and 240 deletions

View file

@ -1,8 +1,8 @@
var proto = Object.create(HTMLElement.prototype);
proto.magicNumber = 42;
proto.createdCallback = function() {
proto.connectedCallback = function() {
finishTest(this.magicNumber === 42);
};
document.registerElement("x-foo", { prototype: proto });
document.createElement("x-foo");
document.firstChild.appendChild(document.createElement("x-foo"));

View file

@ -21,19 +21,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
<script type="application/javascript"><![CDATA[
/** Test for Bug 1130028 **/
SimpleTest.waitForExplicitFinish();
var connectedCallbackCount = 0;
var createdCallbackCount = 0;
// Callback should be called once by element created in chrome,
// and once by element created in content.
function createdCallbackCalled() {
createdCallbackCount++;
ok(true, "Created callback called, should be called twice in test.");
// Callback should be called only once by element created in content.
function connectedCallbackCalled() {
connectedCallbackCount++;
is(connectedCallbackCount, 1, "Connected callback called, should be called once in test.");
is(this.magicNumber, 42, "Callback should be able to see the custom prototype.");
if (createdCallbackCount == 2) {
SimpleTest.finish();
}
}
function startTests() {
@ -45,10 +39,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
var proto = Object.create(frame.contentWindow.HTMLElement.prototype);
proto.magicNumber = 42;
proto.createdCallback = createdCallbackCalled;
frame.contentDocument.registerElement("x-bar", { prototype: proto });
proto.connectedCallback = connectedCallbackCalled;
frame.contentDocument.createElement("x-bar");
frame.contentDocument.registerElement("x-bar", { prototype: proto });
is(connectedCallbackCount, 1, "Connected callback should be called by element created in content.");
var element = frame.contentDocument.createElement("x-bar");
is(element.magicNumber, 42, "Should be able to see the custom prototype on created element.");
}
]]></script>

View file

@ -26,8 +26,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1130028
SimpleTest.waitForExplicitFinish();
function finishTest(canSeePrototype) {
ok(true, "createdCallback called when reigsterElement was called with an extended principal.");
ok(canSeePrototype, "createdCallback should be able to see custom prototype.");
ok(true, "connectedCallback called when reigsterElement was called with an extended principal.");
ok(canSeePrototype, "connectedCallback should be able to see custom prototype.");
SimpleTest.finish();
}