| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <script src="test-harness-utils.js"></script> | 4 <script src="test-harness-utils.js"></script> |
| 5 <body> | 5 <body> |
| 6 <script> | 6 <script> |
| 7 function TestRegistrationContextSharing(window, documentA, documentB) { | 7 function TestRegistrationContextSharing(window, documentA, documentB) { |
| 8 this.window = window; | 8 this.window = window; |
| 9 this.documentA = documentA; | 9 this.documentA = documentA; |
| 10 this.documentB = documentB; | 10 this.documentB = documentB; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 var div = this.documentB.createElement('div'); | 59 var div = this.documentB.createElement('div'); |
| 60 div.innerHTML = '<x-v data-name="document B element V"></x-v>'; | 60 div.innerHTML = '<x-v data-name="document B element V"></x-v>'; |
| 61 assert_array_equals( | 61 assert_array_equals( |
| 62 invocations, | 62 invocations, |
| 63 ['created document B element V with prototype tagged V'], | 63 ['created document B element V with prototype tagged V'], |
| 64 'the created callback should have been called for the x-v element'); | 64 'the created callback should have been called for the x-v element'); |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 (function () { | 67 (function () { |
| 68 | 68 |
| 69 var t = async_test('registration context is shared with DOMImplementation-' + | 69 var t = async_test('registration context is shared with some ' + |
| 70 'created documents'); | 70 'DOMImplementation-created documents'); |
| 71 | 71 |
| 72 withFrame(t.step_func(function (frame) { | 72 withFrame(t.step_func(function (frame) { |
| 73 var documentA = frame.contentDocument; | 73 var documentA = frame.contentDocument; |
| 74 var documentB = documentA.implementation.createHTMLDocument(); | 74 var documentB = documentA.implementation.createHTMLDocument(); |
| 75 var tester = new TestRegistrationContextSharing( | 75 var tester = new TestRegistrationContextSharing( |
| 76 frame.contentWindow, documentA, documentB); | 76 frame.contentWindow, documentA, documentB); |
| 77 tester.testRegistrationContextIsShared(); | 77 tester.testRegistrationContextIsShared(); |
| 78 frame.remove(); | 78 frame.remove(); |
| 79 })); | 79 })); |
| 80 | 80 |
| 81 withFrame(t.step_func(function (frame) { | 81 withFrame(t.step_func(function (frame) { |
| 82 var documentA = frame.contentDocument; | 82 var documentA = frame.contentDocument; |
| 83 var documentB = documentA.implementation.createDocument( | 83 var documentB = documentA.implementation.createDocument( |
| 84 'http://www.w3.org/1999/xhtml', 'html'); | 84 'http://www.w3.org/1999/xhtml', 'html'); |
| 85 var tester = new TestRegistrationContextSharing( | 85 var tester = new TestRegistrationContextSharing( |
| 86 frame.contentWindow, documentA, documentB); | 86 frame.contentWindow, documentA, documentB); |
| 87 tester.testRegistrationContextIsShared(); | 87 tester.testRegistrationContextIsShared(); |
| 88 frame.remove(); | 88 frame.remove(); |
| 89 })); | 89 })); |
| 90 | 90 |
| 91 withFrame(t.step_func(function (frame) { | 91 withFrame(t.step_func(function (frame) { |
| 92 // Test transitively sharing a registration context through multiple | |
| 93 // createDocument/createHTMLDocument steps. | |
| 94 | |
| 95 var documentA = frame.contentDocument; | 92 var documentA = frame.contentDocument; |
| 96 | 93 var documentB = documentA.implementation.createDocument( |
| 97 // This document is not HTML, XHTML; it will not process custom elements. | 94 'http://www.w3.org/1999/xhtml', 'html'); |
| 98 var documentB = documentA.implementation.createDocument(null, ''); | |
| 99 | |
| 100 // This document *will* process custom elements, in a new context. | |
| 101 var documentC = documentB.implementation.createHTMLDocument(); | 95 var documentC = documentB.implementation.createHTMLDocument(); |
| 102 | |
| 103 var documentD = documentC.implementation.createDocument( | |
| 104 'http://www.w3.org/1999/xhtml', 'html'); | |
| 105 | |
| 106 var documentE = documentD.implementation.createDocument( | |
| 107 'http://www.w3.org/1999/xhtml', 'html'); | |
| 108 | |
| 109 var tester = new TestRegistrationContextSharing( | 96 var tester = new TestRegistrationContextSharing( |
| 110 frame.contentWindow, documentC, documentE); | 97 frame.contentWindow, documentA, documentC); |
| 111 tester.testRegistrationContextIsShared(); | 98 tester.testRegistrationContextIsShared(); |
| 112 frame.remove(); | 99 frame.remove(); |
| 113 t.done(); | 100 t.done(); |
| 114 })); | 101 })); |
| 115 | 102 |
| 116 })(); | 103 })(); |
| 117 | 104 |
| 118 (function () { | 105 (function () { |
| 119 | 106 |
| 120 var t = async_test('registration context is shared with imported documents'); | 107 var t = async_test('registration context is shared with imported documents'); |
| 121 var link; | 108 var link; |
| 122 var documentA; | 109 var documentA; |
| 123 | 110 |
| 124 t.step(function () { | 111 withFrame(t.step_func(function (frame) { |
| 125 // FIXME: When inserting a <link> within a frame triggers an import, | 112 documentA = frame.contentDocument; |
| 126 // run this part of the test in isolation within a frame. | |
| 127 documentA = document; | |
| 128 | 113 |
| 129 link = documentA.createElement('link'); | 114 link = documentA.createElement('link'); |
| 130 link.rel = 'import'; | 115 link.rel = 'import'; |
| 131 link.href = 'resources/empty-document.html'; | 116 link.href = 'resources/empty-document.html'; |
| 132 link.onload = t.step_func(function () { | 117 link.onload = t.step_func(function () { |
| 133 var documentB = link.import; | 118 var documentB = link.import; |
| 134 var tester = new TestRegistrationContextSharing(window, | 119 var tester = new TestRegistrationContextSharing(window, |
| 135 documentA, documentB); | 120 documentA, documentB); |
| 136 tester.testRegistrationContextIsShared(); | 121 tester.testRegistrationContextIsShared(); |
| 137 t.done(); | 122 t.done(); |
| 138 }); | 123 }); |
| 139 | 124 |
| 140 documentA.head.appendChild(link); | 125 documentA.head.appendChild(link); |
| 141 }); | 126 })); |
| 142 | 127 |
| 143 })(); | 128 })(); |
| 144 | 129 |
| 145 </script> | 130 </script> |
| OLD | NEW |