From 2a8c5f624bfa30a6a2bf2ba1b09ea6b676ab9574 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Tue, 14 Jan 2014 15:13:52 -0800 Subject: [PATCH] Add multiple insert test for attachedCallback --- test/js/customElements.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/js/customElements.js b/test/js/customElements.js index 092b4e6..55bdfd8 100644 --- a/test/js/customElements.js +++ b/test/js/customElements.js @@ -173,7 +173,6 @@ assert.equal(xbooboo.style.fontSize, '32pt'); }); - test('document.register [created|attached|detached]Callbacks in prototype', function(done) { var ready, inserted, removed; var XBooPrototype = Object.create(HTMLElement.prototype); @@ -243,7 +242,30 @@ xboo.setAttribute('foo', 'zot'); }); -test('document.register detachedCallbacks in prototype', function(done) { + test('document.register attachedCallbacks in prototype', function(done) { + var inserted = 0; + var XBooPrototype = Object.create(HTMLElement.prototype); + XBooPrototype.attachedCallback = function() { + inserted++; + }; + var XBoo = document.registerElement('x-boo-at', { + prototype: XBooPrototype + }); + var xboo = new XBoo(); + assert.equal(inserted, 0, 'inserted must be 0'); + work.appendChild(xboo); + CustomElements.takeRecords(); + assert.equal(inserted, 1, 'inserted must be 1'); + work.removeChild(xboo); + CustomElements.takeRecords(); + assert(!xboo.parentNode); + work.appendChild(xboo); + CustomElements.takeRecords(); + assert.equal(inserted, 2, 'inserted must be 2'); + done(); + }); + + test('document.register detachedCallbacks in prototype', function(done) { var ready, inserted, removed; var XBooPrototype = Object.create(HTMLElement.prototype); XBooPrototype.detachedCallback = function() {