Changeset 106619 in webkit
- Timestamp:
- Feb 2, 2012 7:33:10 PM (12 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r106613 r106619 1 2012-02-02 Shinya Kawanaka <shinyak@google.com> 2 3 Refactoring: Share test drivers of shadow content tests. 4 https://bugs.webkit.org/show_bug.cgi?id=77584 5 6 Extracts shared test code from content-element-move.html and content-element-select-dynamic.html. 7 This test framework will be used a few more times. 8 9 Reviewed by Hajime Morita. 10 11 * fast/dom/resources/shadow-test-driver.js: Added. 12 (log): 13 (cleanUp): 14 (removeContainerLines): 15 (check): 16 (createSpanWithText): 17 (createContentWithSelect): 18 (appendShadow): 19 (appendShadowDeep): 20 (doTestIfLeft.callIfDone): 21 (doneTest): 22 (doTest): 23 * fast/dom/shadow/content-element-move.html: 24 * fast/dom/shadow/content-element-select-dynamic.html: 25 1 26 2012-02-02 Shinya Kawanaka <shinyak@google.com> 2 27 -
trunk/LayoutTests/fast/dom/shadow/content-element-move.html
r106465 r106619 14 14 } 15 15 </style> 16 <script src="../resources/shadow-test-driver.js"></script> 16 17 <script> 17 function log(message) {18 document.getElementById('console').innerHTML += (message + "\n");19 }20 21 function removeAllChildren(elem) {22 while (elem.firstChild)23 elem.removeChild(elem.firstChild);24 }25 26 function cleanUp() {27 removeAllChildren(document.getElementById('actual-container'));28 removeAllChildren(document.getElementById('expect-container'));29 }30 31 function removeContainerLines(text) {32 var lines = text.split('\n');33 lines.splice(0, 2);34 return lines.join('\n');35 }36 37 function check() {38 var refContainerRenderTree = internals.elementRenderTreeAsText(document.getElementById('expect-container'));39 var refRenderTree = removeContainerLines(refContainerRenderTree);40 41 var targetContainerRenderTree = internals.elementRenderTreeAsText(document.getElementById('actual-container'));42 var targetRenderTree = removeContainerLines(targetContainerRenderTree);43 44 if (targetRenderTree == refRenderTree)45 log("PASS");46 else {47 log("FAIL");48 log("Expected: ");49 log(refRenderTree);50 log("Actual: ");51 log(targetRenderTree);52 }53 }54 55 function createSpanWithText(text) {56 var span = document.createElement('span');57 span.appendChild(document.createTextNode(text));58 return span;59 }60 61 function createContentWithSelect(select, fallback) {62 var content = internals.createContentElement(document);63 content.setAttribute('select', select);64 if (!fallback)65 content.appendChild(createSpanWithText("FALLBACK"));66 67 return content;68 }69 70 function appendShadow(target, select) {71 var root = internals.ensureShadowRoot(target);72 73 var content = internals.createContentElement(document);74 content.setAttribute('select', select);75 content.appendChild(createSpanWithText("FALLBACK"));76 77 root.appendChild(document.createTextNode("{SHADOW: "));78 root.appendChild(content);79 root.appendChild(document.createTextNode("}"));80 }81 82 function appendShadowDeep(target, select) {83 var root = internals.ensureShadowRoot(target);84 85 var child = document.createElement("span");86 {87 var content = internals.createContentElement(document);88 content.setAttribute('select', select);89 content.appendChild(createSpanWithText("FALLBACK"));90 91 child.appendChild(document.createTextNode("{INNER: "));92 child.appendChild(content);93 child.appendChild(document.createTextNode("}"));94 }95 96 root.appendChild(document.createTextNode("{SHADOW: "));97 root.appendChild(child);98 root.appendChild(document.createTextNode("}"));99 }100 101 // ----------------------------------------------------------------------102 // Test Functions.103 104 18 function testRemoveContent(callIfDone) { 105 19 var root = document.createElement('div'); … … 444 358 setTimeout(f, 0); 445 359 } 446 447 // ----------------------------------------------------------------------448 // Test Drivers.449 360 450 361 var testFuncs = [ … … 462 373 ]; 463 374 464 function doTestIfLeft() {465 var test = testFuncs.shift();466 if (test == null)467 return doneTest();468 469 var callIfDone = function() {470 setTimeout(function() {471 check();472 cleanUp();473 doTestIfLeft();474 }, 0);475 };476 477 log(test.name);478 test(callIfDone);479 }480 481 function doneTest() {482 log("TEST COMPLETED");483 layoutTestController.notifyDone();484 }485 486 function doTest() {487 if (window.layoutTestController) {488 layoutTestController.waitUntilDone();489 layoutTestController.dumpAsText();490 }491 492 cleanUp();493 doTestIfLeft();494 }495 375 </script> 496 376 </head> 497 <body onload="doTest( )">377 <body onload="doTest(testFuncs)"> 498 378 499 379 <div id="actual-container" class="container"></div> -
trunk/LayoutTests/fast/dom/shadow/content-element-select-dynamic.html
r106527 r106619 14 14 } 15 15 </style> 16 <script src="../resources/shadow-test-driver.js"></script> 16 17 <script> 17 function log(message) {18 document.getElementById('console').innerHTML += (message + "\n");19 }20 21 function removeAllChildren(elem) {22 while (elem.firstChild)23 elem.removeChild(elem.firstChild);24 }25 26 function cleanUp() {27 removeAllChildren(document.getElementById('actual-container'));28 removeAllChildren(document.getElementById('expect-container'));29 }30 31 function removeContainerLines(text) {32 var lines = text.split('\n');33 lines.splice(0, 2);34 return lines.join('\n');35 }36 37 function check() {38 var refContainerRenderTree = internals.elementRenderTreeAsText(document.getElementById('expect-container'));39 var refRenderTree = removeContainerLines(refContainerRenderTree);40 41 var targetContainerRenderTree = internals.elementRenderTreeAsText(document.getElementById('actual-container'));42 var targetRenderTree = removeContainerLines(targetContainerRenderTree);43 44 if (targetRenderTree == refRenderTree)45 log("PASS");46 else {47 log("FAIL");48 log("Expected: ");49 log(refRenderTree);50 log("Actual: ");51 log(targetRenderTree);52 }53 }54 55 function createSpanWithText(text) {56 var span = document.createElement('span');57 span.appendChild(document.createTextNode(text));58 return span;59 }60 61 function createContentWithSelect(select, fallback) {62 var content = internals.createContentElement(document);63 content.setAttribute('select', select);64 if (!fallback)65 content.appendChild(createSpanWithText("FALLBACK"));66 67 return content;68 }69 70 function appendShadow(target, select) {71 var root = internals.ensureShadowRoot(target);72 73 var content = internals.createContentElement(document);74 content.setAttribute('select', select);75 content.appendChild(createSpanWithText("FALLBACK"));76 77 root.appendChild(document.createTextNode("{SHADOW: "));78 root.appendChild(content);79 root.appendChild(document.createTextNode("}"));80 }81 82 function appendShadowDeep(target, select) {83 var root = internals.ensureShadowRoot(target);84 85 var child = document.createElement("span");86 {87 var content = internals.createContentElement(document);88 content.setAttribute('select', select);89 content.appendChild(createSpanWithText("FALLBACK"));90 91 child.appendChild(document.createTextNode("{INNER: "));92 child.appendChild(content);93 child.appendChild(document.createTextNode("}"));94 }95 96 root.appendChild(document.createTextNode("{SHADOW: "));97 root.appendChild(child);98 root.appendChild(document.createTextNode("}"));99 }100 101 // ----------------------------------------------------------------------102 // Test Functions.103 104 18 function testChangeSelect1(callIfDone) { 105 19 document.getElementById('expect-container').innerHTML = … … 246 160 } 247 161 248 // ----------------------------------------------------------------------249 // Test Drivers.250 251 162 var testFuncs = [ 252 163 testChangeSelect1, … … 257 168 ]; 258 169 259 function doTestIfLeft() {260 var test = testFuncs.shift();261 if (test == null)262 return doneTest();263 264 var callIfDone = function() {265 setTimeout(function() {266 check();267 cleanUp();268 doTestIfLeft();269 }, 0);270 };271 272 log(test.name);273 test(callIfDone);274 }275 276 function doneTest() {277 log("TEST COMPLETED");278 layoutTestController.notifyDone();279 }280 281 function doTest() {282 if (window.layoutTestController) {283 layoutTestController.waitUntilDone();284 layoutTestController.dumpAsText();285 }286 287 cleanUp();288 doTestIfLeft();289 }290 170 </script> 291 171 </head> 292 <body onload="doTest( )">172 <body onload="doTest(testFuncs)"> 293 173 294 174 <div id="actual-container" class="container"></div>
Note: See TracChangeset
for help on using the changeset viewer.