Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: LayoutTests/fast/dom/custom/element-upgrade.html

Issue 14626005: Upgrade elements that are created before a custom element definition is registered (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback+test Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/dom/custom/element-upgrade-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../js/resources/js-test-pre.js"></script>
3 <div id="container"></div>
4 <script>
5 description('Tests the element upgrade algorithm.');
6
7 // "Element Upgrade" is the processing of custom elements which were
8 // created before their definition was available, when the definition
9 // becomes available. The following scenarios cover a lot but are not
10 // exhaustive.
11
12 // Scenario A: Custom tag; upgrade candidate is not in the document;
13 // upgrade candidate did not have a JavaScript wrapper at upgrade
14 // time; custom element does not have a ready callback.
15 var host = document.createElement('div');
16 host.innerHTML = '<x-a></x-a>'; // Using innerHTML avoids wrapping x-a
17 var A = document.webkitRegister('x-a', {prototype: Object.create(HTMLElement.pro totype)});
18 shouldBeTrue('host.firstChild instanceof A');
19
20 // Scenario B: Type extension; upgrade candidate is in the document;
21 // upgrade candidate did have a JavaScript wrapper at upgrade time;
22 // custom element has a ready callback.
23 var element = document.createElement('span', 'x-b');
24 var proto = Object.create(HTMLSpanElement.prototype);
25 var callCount = 0;
26 proto.readyCallback = function () {
27 callCount++;
28 };
29 var B = document.webkitRegister('x-b', {prototype: proto});
30 shouldBeTrue('element instanceof B');
31 shouldBe('callCount', '1');
32
33 // Scenario C: The candidate is a custom tag but the definition is a
34 // type extension. Upgrade should not happen.
35 element = document.createElement('x-c');
36 var C = document.webkitRegister('x-c', {prototype: Object.create(HTMLSpanElement .prototype)});
37 shouldBeFalse('element instanceof C');
38 shouldBe('Object.getPrototypeOf(element)', 'HTMLElement.prototype');
39
40 // Scenario D: The candidate is a type extension, but the definition
41 // extends a different tag. Upgrade should not happen.
42 document.body.appendChild(host);
43 host.innerHTML = '<span is="x-d"></span>';
44 var D = document.webkitRegister('x-d', {prototype: Object.create(HTMLDivElement. prototype)});
45 shouldBeFalse('host.firstChild instanceof D');
46 shouldBe('document.querySelector(":unresolved")', 'host.firstChild');
47
48 successfullyParsed = true;
49 </script>
50 <script src="../../js/resources/js-test-post.js"></script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/custom/element-upgrade-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698