Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(687)

Delta Between Two Patch Sets: tests/com/google/caja/plugin/es53-test-domado-dom-guest.html

Issue 6827077: Mitigate top-level vars and typeof differences between ES5 and ES5/3 with rewriting (Closed) Base URL: http://google-caja.googlecode.com/svn/trunk/
Left Patch Set: Mitigate top-level vars and typeof differences between ES5 and ES5/3 with rewriting Created 11 years, 3 months ago
Right Patch Set: Mitigate top-level vars and typeof differences between ES5 and ES5/3 with rewriting Created 11 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 <!-- 1 <!--
2 - Copyright (C) 2011 Google Inc. 2 - Copyright (C) 2011 Google Inc.
3 - 3 -
4 - Licensed under the Apache License, Version 2.0 (the "License"); 4 - Licensed under the Apache License, Version 2.0 (the "License");
5 - you may not use this file except in compliance with the License. 5 - you may not use this file except in compliance with the License.
6 - You may obtain a copy of the License at 6 - You may obtain a copy of the License at
7 - 7 -
8 - http://www.apache.org/licenses/LICENSE-2.0 8 - http://www.apache.org/licenses/LICENSE-2.0
9 - 9 -
10 - Unless required by applicable law or agreed to in writing, software 10 - Unless required by applicable law or agreed to in writing, software
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 + '<div>' 323 + '<div>'
324 + '<p>Written afterwards</p>' 324 + '<p>Written afterwards</p>'
325 + '<p>More written afterwards</p>' 325 + '<p>More written afterwards</p>'
326 + '</div>', 326 + '</div>',
327 canonInnerHtml(el.innerHTML)); 327 canonInnerHtml(el.innerHTML));
328 } 328 }
329 pass('testDocumentWrite'); 329 pass('testDocumentWrite');
330 }); 330 });
331 </script> 331 </script>
332 332
333 <!-- Test that relatively obscure entities (not in the &lt;&gt;&amp; short list)
334 work. The acutes in particular test case-sensitivity. &plonk; is unknown.
335 -->
336 <div id="testEntities" class="testcontainer"
337 >&larr;&AMP;&eacute;&Eacute;&plonk;</div>
338 <script type="text/javascript">
339 jsunitRegister('testEntities',
340 function testEntities() {
341 var el = document.getElementById('testEntities');
342 var decoded = '\u2190&\u00E9\u00C9&plonk;';
343
344 assertEquals(decoded, el.textContent);
345
346 // dynamic case -- uses html-sanitizer
347 el.innerHTML += '&larr;&AMP;&eacute;&Eacute;&plonk;';
348 assertEquals(decoded + decoded, el.textContent);
349
350 pass('testEntities');
351 });
352 </script>
353
333 <p id="testWindowMutable" class="testcontainer"> 354 <p id="testWindowMutable" class="testcontainer">
334 <script type="text/javascript">window.myProp = 1234;</script> 355 <script type="text/javascript">window.myProp = 1234;</script>
335 </p> 356 </p>
336 <script type="text/javascript"> 357 <script type="text/javascript">
337 jsunitRegister('testWindowMutable', 358 jsunitRegister('testWindowMutable',
338 function testWindowMutable() { 359 function testWindowMutable() {
339 function contains(arr, el) { 360 function contains(arr, el) {
340 for (var i = arr.length; --i >= 0;) { 361 for (var i = arr.length; --i >= 0;) {
341 if (el === arr[i]) { return true; } 362 if (el === arr[i]) { return true; }
342 } 363 }
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 <p class="aaa bbb">AAA BBB</p> 780 <p class="aaa bbb">AAA BBB</p>
760 <div class="aaa">AAA</div> 781 <div class="aaa">AAA</div>
761 <p class="bbb ccc">BBB CCC</p> 782 <p class="bbb ccc">BBB CCC</p>
762 </div> 783 </div>
763 <script type="text/javascript"> 784 <script type="text/javascript">
764 jsunitRegister('testGetElementsByClassName', 785 jsunitRegister('testGetElementsByClassName',
765 function testGetElementsByClassName() { 786 function testGetElementsByClassName() {
766 function assertNodeListTextContent(classes, textContent) { 787 function assertNodeListTextContent(classes, textContent) {
767 var nodeList = document.getElementsByClassName(classes); 788 var nodeList = document.getElementsByClassName(classes);
768 var len = nodeList.length; 789 var len = nodeList.length;
769 assertEquals(textContent.length, len); 790 assertEquals('expected length for ' + classes, textContent.length, len);
770 for (var i = 0; i < len; ++i) { 791 for (var i = 0; i < len; ++i) {
771 assertEquals(textContent[i], canonInnerHtml(nodeList[i].innerHTML)); 792 assertEquals(classes + ' (result ' + i + ')',
793 textContent[i], canonInnerHtml(nodeList[i].innerHTML));
772 } 794 }
773 } 795 }
774 796
775 assertNodeListTextContent('aaa', ['AAA BBB', 'AAA']); 797 assertNodeListTextContent('aaa', ['AAA BBB', 'AAA']);
776 assertNodeListTextContent('ccc bbb', ['BBB CCC']); 798 assertNodeListTextContent('ccc bbb', ['BBB CCC']);
777 assertNodeListTextContent('bbb ccc', ['BBB CCC']); 799 assertNodeListTextContent('bbb ccc', ['BBB CCC']);
778 assertNodeListTextContent(' bbb \tccc ', ['BBB CCC']); 800 assertNodeListTextContent(' bbb \tccc ', ['BBB CCC']);
779 assertNodeListTextContent('aaa,bbb', []); 801 assertNodeListTextContent('aaa,bbb', []);
780 802
781 pass('testGetElementsByClassName'); 803 pass('testGetElementsByClassName');
804 });
805 </script>
806
807 <div id="testQuerySelector" class="testcontainer">
808 <p class="testQuerySelector-ac" id="testQuerySelector-ai">a</p>
809 <p class="testQuerySelector-bc" id="testQuerySelector-bi">b</p>
810 </div>
811 <script type="text/javascript">
812 // TODO(kpreid): Disable this test if host browser does not provide
813 // querySelector.
814 jsunitRegister('testQuerySelector',
815 function testQuerySelector() {
816 var container = document.getElementById('testQuerySelector');
817 function assertQueryResult(selectors, textContent) {
818 var nodeList = document.querySelectorAll(selectors);
819 var nodeList2 = container.querySelectorAll(selectors);
820 var single = document.querySelector(selectors);
821 var single2 = container.querySelector(selectors);
822 var len = nodeList.length;
823 assertEquals('expected length for ' + selectors, textContent.length, len);
824 assertEquals('expected same length for ' + selectors, len,
825 nodeList2.length);
826 for (var i = 0; i < len; ++i) {
827 assertEquals(selectors + ' (result ' + i + ' on document)',
828 textContent[i], canonInnerHtml(nodeList[i].innerHTML));
829 assertEquals(selectors + ' (result ' + i + ' on element)',
830 textContent[i], canonInnerHtml(nodeList2[i].innerHTML));
831 }
832 assertEquals(selectors + ' (querySelector)',
833 len === 0 ? null : nodeList[0], single);
834 }
835
836 assertQueryResult('.testQuerySelector-ac', ['a']);
837 assertQueryResult('.testQuerySelector-bc', ['b']);
838 assertQueryResult('#testQuerySelector-ai', ['a']);
839 assertQueryResult('#testQuerySelector-ai, #testQuerySelector-bi',
840 ['a', 'b']);
841 assertQueryResult('#testQuerySelector p', ['a', 'b']);
842 assertEquals('scoped query', 2, container.querySelectorAll('p').length);
843 expectFailure(function() {
844 document.querySelector(',');
845 }, 'syntax error');
846
847 // test non-liveness
848 var list = container.querySelectorAll('p');
849 assertEquals('length before change', 2, list.length);
850 container.appendChild(document.createElement('p')).textContent = 'added';
851 assertEquals('length after change', 2, list.length);
852
853 pass('testQuerySelector');
782 }); 854 });
783 </script> 855 </script>
784 856
785 <p id="testClassSetByEmitter" class="testcontainer"></p> 857 <p id="testClassSetByEmitter" class="testcontainer"></p>
786 <script type="text/javascript"> 858 <script type="text/javascript">
787 jsunitRegister('testClassSetByEmitter', 859 jsunitRegister('testClassSetByEmitter',
788 function testClassSetByEmitter() { 860 function testClassSetByEmitter() {
789 // Make sure that the HTML emitter correctly sets the class. 861 // Make sure that the HTML emitter correctly sets the class.
790 // A testcontainer node should be yellow until it has been marked as having 862 // A testcontainer node should be yellow until it has been marked as having
791 // passed. 863 // passed.
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // Note: The rewritten URI appearing here is not a desirable thing, but we 1285 // Note: The rewritten URI appearing here is not a desirable thing, but we
1214 // simply don't support preserving original URIs in general. 1286 // simply don't support preserving original URIs in general.
1215 // What is being tested for here is: 1287 // What is being tested for here is:
1216 // * general correctness of innerHTML output 1288 // * general correctness of innerHTML output
1217 // * that target='_blank' does not appear 1289 // * that target='_blank' does not appear
1218 // TODO(kpreid): said funny whitespace probably ought to be canceled out 1290 // TODO(kpreid): said funny whitespace probably ought to be canceled out
1219 // by some other whitespace processing we're not implementing. 1291 // by some other whitespace processing we're not implementing.
1220 assertEquals( 1292 assertEquals(
1221 '\n' + 1293 '\n' +
1222 ' <a href="http://example.com/?effect=NEW_DOCUMENT&amp;loader=' + 1294 ' <a href="http://example.com/?effect=NEW_DOCUMENT&amp;loader=' +
1223 'UNSANDBOXED&amp;uri=http%3A%2F%2Flocalhost%3A8000%2Fant-testlib%2F' + 1295 'UNSANDBOXED&amp;uri=http%3A%2F%2F' + location.hostname +
1296 '%3A8000%2Fant-testlib%2F' +
1224 'com%2Fgoogle%2Fcaja%2Fplugin%2Ffoo">bar</a>\n' + 1297 'com%2Fgoogle%2Fcaja%2Fplugin%2Ffoo">bar</a>\n' +
1225 ' <span>Hello world</span>\n' + 1298 ' <span>Hello world</span>\n' +
1226 ' ', 1299 ' ',
1227 document.getElementById('testGetInnerHTML').innerHTML); 1300 document.getElementById('testGetInnerHTML').innerHTML);
1228 ···· 1301 ····
1229 // textarea with specific children, per HTML5 1302 // textarea with specific children, per HTML5
1230 var container = document.createElement('form'); 1303 var container = document.createElement('form');
1231 container.appendChild(document.createElement('textarea')); 1304 container.appendChild(document.createElement('textarea'));
1232 // none 1305 // none
1233 assertEquals("<textarea></textarea>", container.innerHTML); 1306 assertEquals("<textarea></textarea>", container.innerHTML);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 assertEquals("wrong inner.offsetParent: " + inner.offsetParent, 1390 assertEquals("wrong inner.offsetParent: " + inner.offsetParent,
1318 outer, inner.offsetParent); 1391 outer, inner.offsetParent);
1319 assertEquals("wrong outer.offsetParent: " + outer.offsetParent, 1392 assertEquals("wrong outer.offsetParent: " + outer.offsetParent,
1320 document.body, outer.offsetParent); 1393 document.body, outer.offsetParent);
1321 assertEquals("wrong body.offsetParent: " + document.body.offsetParent, 1394 assertEquals("wrong body.offsetParent: " + document.body.offsetParent,
1322 null, document.body.offsetParent); 1395 null, document.body.offsetParent);
1323 pass('testOffsetParent'); 1396 pass('testOffsetParent');
1324 }); 1397 });
1325 </script> 1398 </script>
1326 1399
1327 <p id="testDimensionProperties" class="testcontainer" 1400 <div id="testDimensionProperties" class="testcontainer"
1328 style="position: relative; height: 120px /* for viewing, not tests */;"> 1401 style="position: relative; height: 120px /* for viewing, not tests */;">
1329 <div id="testDimensionProperties-a" style=" 1402 <div id="testDimensionProperties-a" style="
1330 border: solid brown; 1403 border: solid brown;
1331 border-width: 1px 2px; 1404 border-width: 1px 2px;
1332 padding: 10px 20px; 1405 padding: 10px 20px;
1333 height: 100px; width: 200px; 1406 height: 100px; width: 200px;
1334 ······ 1407 ······
1335 position: absolute; 1408 position: absolute;
1336 top: 30px; 1409 top: 30px;
1337 left: 60px; 1410 left: 60px;
1338 "> 1411 ">
1339 testDimensionProperties 1412 testDimensionProperties
1340 </div> 1413 </div>
1341 <div id="testDimensionProperties-scroll" style=" 1414 <div id="testDimensionProperties-scroll" style="
1342 border: solid brown; 1415 border: solid brown;
1343 border-width: 1px 2px; 1416 border-width: 1px 2px;
1344 padding: 10px 20px; 1417 padding: 10px 20px;
1345 height: 100px; width: 200px; 1418 height: 100px; width: 200px;
1346 overflow: scroll; 1419 overflow: scroll;
1347 ······ 1420 ······
1348 position: absolute; 1421 position: absolute;
1349 top: 30px; 1422 top: 30px;
1350 left: 400px; 1423 left: 400px;
1351 "> 1424 ">
1352 <div style="height: 1000px; width: 2000px;"> 1425 <div style="height: 1000px; width: 2000px;">
1353 (scrolling) 1426 (scrolling)
1354 </div> 1427 </div>
1355 </div> 1428 </div>
1356 </p> 1429 </div>
1357 <script type="text/javascript"> 1430 <script type="text/javascript">
1358 function assertPropEq(value, object, name, opt_tolerance) { 1431 function assertPropEq(value, object, name, opt_tolerance) {
1359 if (opt_tolerance) { 1432 if (opt_tolerance) {
1360 assertRoughlyEquals(object.id + '.' + name, value, object[name], 1433 assertRoughlyEquals(object.id + '.' + name, value, object[name],
1361 opt_tolerance); 1434 opt_tolerance);
1362 } else { 1435 } else {
1363 assertEquals(object.id + '.' + name, value, object[name]); 1436 assertEquals(object.id + '.' + name, value, object[name]);
1364 } 1437 }
1365 } 1438 }
1366 1439
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
2040 assertEquals(60, el.offsetHeight); 2113 assertEquals(60, el.offsetHeight);
2041 2114
2042 pass('testSizeProperties'); 2115 pass('testSizeProperties');
2043 }); 2116 });
2044 </script> 2117 </script>
2045 2118
2046 <p id="testDefaultView" class="testcontainer">Test document.defaultView</p> 2119 <p id="testDefaultView" class="testcontainer">Test document.defaultView</p>
2047 <script type="text/javascript"> 2120 <script type="text/javascript">
2048 jsunitRegister('testDefaultView', 2121 jsunitRegister('testDefaultView',
2049 function testDefaultView() { 2122 function testDefaultView() {
2050 assertNotEquals(window, document.defaultView); 2123 // We used to have a defaultView distinct from window on capability grounds:
2124 // window is also the global environment, so it contains all authority of
2125 // the guest. However, we are in general not providing a
2126 // capability-structured guest environment (e.g. we do not inhibit DOM
2127 // .parentNode) so this separation is not particularly interesting.
2128 assertEquals(window, document.defaultView);
2051 pass('testDefaultView'); 2129 pass('testDefaultView');
2052 }); 2130 });
2053 </script> 2131 </script>
2054 2132
2055 <p id="testDocumentElement" class="testcontainer">Test Document Element</p> 2133 <p id="testDocumentElement" class="testcontainer">Test Document Element</p>
2056 <script type="text/javascript"> 2134 <script type="text/javascript">
2057 // Note: When this test was written, Domado provided a "pseudo" DOM 2135 // Note: When this test was written, Domado provided a "pseudo" DOM
2058 // structure which was not backed by real DOM nodes; thus this test was 2136 // structure which was not backed by real DOM nodes; thus this test was
2059 // used to confirm that the emulation was correct. 2137 // used to confirm that the emulation was correct.
2060 jsunitRegister('testDocumentElement', 2138 jsunitRegister('testDocumentElement',
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 }); 2389 });
2312 </script> 2390 </script>
2313 2391
2314 <div id="testImageElement" class="testcontainer" > 2392 <div id="testImageElement" class="testcontainer" >
2315 <img id="testImageElement-image" src="test-image-41x13.png"> 2393 <img id="testImageElement-image" src="test-image-41x13.png">
2316 </div> 2394 </div>
2317 <script type="text/javascript"> 2395 <script type="text/javascript">
2318 jsunitRegister('testImageElement', 2396 jsunitRegister('testImageElement',
2319 function testImageElement() { 2397 function testImageElement() {
2320 var img = document.getElementById('testImageElement-image'); 2398 var img = document.getElementById('testImageElement-image');
2321 assertEquals(41, img.width); 2399 assertEquals('width', 41, img.width);
2322 assertEquals(13, img.height); 2400 assertEquals('height', 13, img.height);
2323 img.width = 10; 2401 img.width = 10;
2324 img.height = 20; 2402 img.height = 20;
2325 assertEquals(10, img.width); 2403 assertEquals(10, img.width);
2326 assertEquals(20, img.height); 2404 assertEquals(20, img.height);
2327 assertEquals('10px', window.getComputedStyle(img, null).width); 2405 assertEquals('10px', window.getComputedStyle(img, null).width);
2328 if ('naturalWidth' in img) { 2406 if (directAccess.feralFeatureTest(img, 'naturalWidth')) {
2329 assertEquals(41, img.naturalWidth); 2407 assertEquals('naturalWidth', 41, img.naturalWidth);
2330 assertEquals(13, img.naturalHeight); 2408 assertEquals('naturalHeight', 13, img.naturalHeight);
2331 } else { 2409 } else {
2332 assertFalse('naturalWidth' in img); 2410 assertFalse('naturalWidth' in img);
2333 assertFalse('naturalHeight' in img); 2411 assertFalse('naturalHeight' in img);
2334 } 2412 }
2335 if ('complete' in img) { 2413 if (directAccess.feralFeatureTest(img, 'complete')) {
2336 assertEquals(true, img.complete); 2414 assertEquals(true, img.complete);
2337 } else { 2415 } else {
2338 assertFalse('complete' in img); 2416 assertFalse('complete' in img);
2339 } 2417 }
2340 pass('testImageElement'); 2418 pass('testImageElement');
2341 }); 2419 });
2342 </script> 2420 </script>
2343 2421
2344 <div id="testTableElements" class="testcontainer" > 2422 <div id="testTableElements" class="testcontainer" >
2345 <table id='testTableElements-table'> 2423 <table id='testTableElements-table'>
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2468 pass('testRowCell'); 2546 pass('testRowCell');
2469 } 2547 }
2470 }); 2548 });
2471 </script> 2549 </script>
2472 2550
2473 2551
2474 <div id="testIframeShim" class="testcontainer">Test Iframe Shim</div> 2552 <div id="testIframeShim" class="testcontainer">Test Iframe Shim</div>
2475 <script type="text/javascript"> 2553 <script type="text/javascript">
2476 jsunitRegister('testIframeShim', 2554 jsunitRegister('testIframeShim',
2477 function testIframeShim() { 2555 function testIframeShim() {
2556 // Tests that iframes can be used as visual layout tools, as some HTML in
2557 // the wild does. Historical note: This test was written to test a
2558 // specialized attribute-blacklisting case for HTMLIFrameElement, which no
2559 // longer exists; all of this is now the default behavior for
2560 // non-whitelisted attributes, but as it is important to security this
2561 // specific test remains.
2478 var ifr = document.createElement('iframe'); 2562 var ifr = document.createElement('iframe');
2479 ifr.height = 5; 2563 ifr.height = 5;
2480 ifr.width = 6; 2564 ifr.width = 6;
2481 ifr.frameBorder = 1; 2565 ifr.frameBorder = 1;
2482 ifr.name = 'test'; 2566 ifr.name = 'test';
2483 ifr.src = 'http://www.google.com'; 2567 ifr.src = 'http://www.google.com';
2484 ifr.setAttribute('application', 'yes'); 2568 ifr.setAttribute('application', 'yes');
2485 document.getElementById('testIframeShim').appendChild(ifr); 2569 document.getElementById('testIframeShim').appendChild(ifr);
2486 assertEquals('5', ifr.getAttribute('height')); 2570 assertEquals('5', ifr.getAttribute('height'));
2487 assertEquals('6', ifr.getAttribute('width')); 2571 assertEquals('6', ifr.getAttribute('width'));
2488 assertEquals('1', ifr.getAttribute('frameBorder')); 2572 assertEquals('1', ifr.getAttribute('frameBorder'));
2489 assertEquals(null, ifr.getAttribute('name')); 2573 // Hazardous attributes are virtualized normally...
2490 assertEquals(null, ifr.getAttribute('src')); 2574 assertEquals('test', ifr.getAttribute('name'));
2491 assertEquals(void 0, ifr.name); 2575 assertEquals('http://www.google.com', ifr.getAttribute('src'));
2492 assertEquals(void 0, ifr.src); 2576 // ...but do not actually get set.
2577 assertEquals(null, directAccess.getAttribute(ifr, 'name'));
2578 assertEquals(null, directAccess.getAttribute(ifr, 'src'));
2493 pass('testIframeShim'); 2579 pass('testIframeShim');
2580 });
2581 </script>
2582
2583 <div id="testIframeDocument" class="testcontainer">Test Iframe Document</div>
2584 <script type="text/javascript">
2585 jsunitRegister('testIframeDocument',
2586 function testIframeDocument() {
2587 var container = document.getElementById('testIframeDocument');
2588 var ifr = document.createElement('iframe');
2589 container.appendChild(ifr);
2590
2591 // existence
2592 assertEvaluatesToTrue('contentDocument', ifr.contentDocument);
2593 assertEvaluatesToTrue('contentWindow', ifr.contentWindow);
2594
2595 // functionality and distinctness from container
2596 ifr.contentDocument.body.innerHTML =
2597 '<p class="testcontainer">Hello framed world</p>';
2598 var elems = ifr.contentDocument.getElementsByClassName('testcontainer');
2599 assertEquals(1, elems.length);
2600 ····
2601 // document.write (will reopen the document)
2602 ifr.contentDocument.write('');
2603 assertEquals(0, ifr.contentDocument.childNodes.length);
2604 ifr.contentDocument.write('replacement');
2605 assertEquals(1, ifr.contentDocument.childNodes.length);
2606 assertEquals('<head></head><body>replacement</body>',
2607 ifr.contentDocument.documentElement.innerHTML);
2608
2609 // regression test: lack of editability due to a policy bug w/
2610 // container-node-is-document vdocs
2611 ifr.contentDocument.body.appendChild(
2612 ifr.contentDocument.createElement('p'));
2613
2614 pass('testIframeDocument');
2494 }); 2615 });
2495 </script> 2616 </script>
2496 2617
2497 <!-- this sequence of interleaved html/text/script triggers bug 1060 --> 2618 <!-- this sequence of interleaved html/text/script triggers bug 1060 -->
2498 <div id="testEmitterIe" class="testcontainer"> 2619 <div id="testEmitterIe" class="testcontainer">
2499 <div id="testEmitterIe-0">duck-0</div>duck-2 2620 <div id="testEmitterIe-0">duck-0</div>duck-2
2500 <script type="text/javascript">1</script> 2621 <script type="text/javascript">1</script>
2501 <div id="testEmitterIe-1">duck-1</div>duck-3 2622 <div id="testEmitterIe-1">duck-1</div>duck-3
2502 <script type="text/javascript">2</script> 2623 <script type="text/javascript">2</script>
2503 duck-4 2624 duck-4
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 assertEquals('normal', s('testBodyClassesDyn-no').fontStyle); 2706 assertEquals('normal', s('testBodyClassesDyn-no').fontStyle);
2586 pass('testBodyClasses'); 2707 pass('testBodyClasses');
2587 }); 2708 });
2588 </script> 2709 </script>
2589 2710
2590 <p id="testUsemap" class="testcontainer" 2711 <p id="testUsemap" class="testcontainer"
2591 ><map name="foo"><area href="areatarget.html" 2712 ><map name="foo"><area href="areatarget.html"
2592 ></map 2713 ></map
2593 ><img usemap="#foo" src="mappic.gif"></p> 2714 ><img usemap="#foo" src="mappic.gif"></p>
2594 <script type="text/javascript"> 2715 <script type="text/javascript">
2595 // TODO(kpreid): Enable for ES5 and debug; base URL is not being applied.
2596 jsunitRegister('testUsemap', 2716 jsunitRegister('testUsemap',
2597 function testUsemap() { 2717 function testUsemap() {
2598 var el = document.getElementById('testUsemap'); 2718 var el = document.getElementById('testUsemap');
2599 assertEquals( 2719 assertEquals(
2600 ('' 2720 (''
2601 + '<map name="foo-' + directAccess.getIdSuffix() + '">' 2721 + '<map name="foo-' + directAccess.getIdSuffix() + '">'
2602 + '<area href="http://example.com/' 2722 + '<area href="http://example.com/'
2603 + '?effect=NEW_DOCUMENT&amp;loader=UNSANDBOXED' 2723 + '?effect=NEW_DOCUMENT&amp;loader=UNSANDBOXED'
2604 + '&amp;uri=(base)/areatarget.html" target="_blank">' 2724 + '&amp;uri=(base)/areatarget.html" target="_blank">'
2605 + '</map>' 2725 + '</map>'
(...skipping 18 matching lines...) Expand all
2624 <script type="text/javascript"> 2744 <script type="text/javascript">
2625 jsunitRegister('testUsemapFragment', 2745 jsunitRegister('testUsemapFragment',
2626 function testUsemapFragment() { 2746 function testUsemapFragment() {
2627 var el = document.getElementById('testUsemapFragment'); 2747 var el = document.getElementById('testUsemapFragment');
2628 el.setAttribute('usemap', '#foo'); 2748 el.setAttribute('usemap', '#foo');
2629 assertEquals('#foo', el.getAttribute('usemap')); 2749 assertEquals('#foo', el.getAttribute('usemap'));
2630 pass('testUsemapFragment'); 2750 pass('testUsemapFragment');
2631 }); 2751 });
2632 </script> 2752 </script>
2633 2753
2634 <p class="testcontainer" id="testToString">Non-toxic toString</p> 2754 <p class="testcontainer" id="testToString"><!--Test comment-->
2755 Non-toxic toString</p>
2635 <script type="text/javascript"> 2756 <script type="text/javascript">
2636 jsunitRegister('testToString', 2757 jsunitRegister('testToString',
2637 function testToString() { 2758 function testToString() {
2638 // Remove once we get ot ES53 or fix 1290 2759 // These all used to throw a "toxic function" exception in ES5/3.
2639 if (false) { 2760 assertEquals('[domado object HTMLBodyElement BODY]',
2640 // These all used to throw a "toxic function" exception in ES5/3. 2761 document.body.toString());
2641 assertEquals('<BODY>', document.body.toString()); 2762 assertEquals('[domado object Text #text]',
2642 assertEquals('#text', document.createTextNode('').toString()); 2763 document.createTextNode('').toString());
2643 // comment node 2764 assertEquals('[domado object Comment #comment]',
2644 assertEquals( 2765 document.createComment('').toString());
2645 '#comment', 2766 assertEquals('[domado object HTMLDivElement DIV]',
2646 document.getElementById('test-opaque-nodes').firstChild.toString()); 2767 document.createElement('div').toString());
2647 assertEquals('<DIV>', document.createElement('div').toString()); 2768 assertEquals('[domado object HTMLDocument #document]',
2648 assertEquals('[Fake Document]', document.toString()); 2769 document.toString());
2649 }
2650 pass('testToString'); 2770 pass('testToString');
2771 });
2772 </script>
2773
2774 <p class="testcontainer" id="testInterfaceGlobals">
2775 testInterfaceGlobals (/classes/constructors/whatever) &mdash;
2776 Do objects have their expected "types"?</p>
2777 <script type="text/javascript">
2778 jsunitRegister('testInterfaceGlobals',
2779 function testInterfaceGlobals() {
2780 function assertInstanceof(className, object) {
2781 assertTrue('Class ' + className + ' exists',
2782 className in window);
2783 assertTrue('Object ' + object + ' (for ' + className + ') is an object',
2784 typeof object === 'object');
2785 assertTrue(object + ' instanceof ' + className,
2786 object instanceof window[className]);
2787 }
2788
2789 assertInstanceof('Attr', document.getElementById('testInterfaceGlobals')
2790 .getAttributeNode('class'));
2791 assertInstanceof('Comment', document.createComment('foo'));
2792 //assertInstanceof('CanvasRenderingContext2D', // TODO(kpreid): should work
2793 // document.createElement('canvas').getContext('2d'));
2794 assertInstanceof('Document', document);
2795 //assertInstanceof('DocumentFragment', document.createDocumentFragment());
2796 //assertInstanceof('DocumentType', document.doctype);
2797 assertInstanceof('HTMLElement', document.body);
2798 assertInstanceof('HTMLElement', document.getElementsByTagName('p')[0]);
2799 assertInstanceof('HTMLDocument', document);
2800 assertInstanceof('Element', document.body);
2801 assertInstanceof('Element', document.getElementsByTagName('p')[0]);
2802 assertInstanceof('Event', document.createEvent('HTMLEvents'));
2803 assertInstanceof('Node', document.body);
2804 assertInstanceof('Node', document.getElementsByTagName('p')[0]);
2805 assertInstanceof('Text', document.createTextNode('foo'));
2806 assertInstanceof('Window', window);
2807 assertInstanceof('XMLHttpRequest', new XMLHttpRequest());
2808
2809 pass('testInterfaceGlobals');
2651 }); 2810 });
2652 </script> 2811 </script>
2653 2812
2654 <div id="testLocation" class="testcontainer"> 2813 <div id="testLocation" class="testcontainer">
2655 testLocation 2814 testLocation
2656 </div> 2815 </div>
2657 <script type="text/javascript"> 2816 <script type="text/javascript">
2658 jsunitRegister('testLocation', 2817 jsunitRegister('testLocation',
2659 function testLocation() { 2818 function testLocation() {
2660 assertEquals( 2819 assertEquals(
2661 window.location.host, 2820 window.location.host,
2662 window.location.hostname + ':' + window.location.port); 2821 window.location.hostname + ':' + window.location.port);
2663 assertEquals( 2822 assertEquals(
2664 window.location.href, 2823 window.location.href,
2665 window.location.protocol + '//' + window.location.hostname 2824 window.location.protocol + '//' + window.location.hostname
2666 + ':' + window.location.port + window.location.pathname 2825 + ':' + window.location.port + window.location.pathname
2667 + window.location.search + window.location.hash); 2826 + window.location.search + window.location.hash);
2668 assertEquals( 2827 assertEquals(
2669 'http://localhost:8000' 2828 'http://' + window.location.hostname + ':8000'
2670 + '/ant-testlib/com/google/caja/plugin/' 2829 + '/ant-testlib/com/google/caja/plugin/'
2671 + 'es53-test-domado-dom-guest.html', 2830 + 'es53-test-domado-dom-guest.html',
2672 window.location.href); 2831 window.location.href);
2673 assertEquals( 2832 assertEquals(
2674 '', 2833 '',
2675 window.location.hash); 2834 window.location.hash);
2676 assertEquals( 2835 assertEquals(
2677 'localhost:8000', 2836 window.location.hostname + ':8000',
2678 window.location.host); 2837 window.location.host);
2679 assertEquals(
2680 'localhost',
2681 window.location.hostname);
2682 assertEquals('' 2838 assertEquals(''
2683 + '/ant-testlib/com/google/caja/plugin/' 2839 + '/ant-testlib/com/google/caja/plugin/'
2684 + 'es53-test-domado-dom-guest.html', 2840 + 'es53-test-domado-dom-guest.html',
2685 window.location.pathname); 2841 window.location.pathname);
2686 assertEquals( 2842 assertEquals(
2687 '8000', 2843 '8000',
2688 window.location.port); 2844 window.location.port);
2689 assertEquals( 2845 assertEquals(
2690 'http:', 2846 'http:',
2691 window.location.protocol); 2847 window.location.protocol);
2692 assertEquals( 2848 assertEquals(
2693 '', 2849 '',
2694 window.location.search); 2850 window.location.search);
2695 // TODO(jasvir): Uncomment after wiring up document.domain 2851 // TODO(jasvir): Uncomment after wiring up document.domain
2696 // by untangling the cyclic dependence between 2852 // by untangling the cyclic dependence between
2697 // TameWindow and TameDocument 2853 // TameWindow and TameDocument
2698 // assertEquals( 2854 // assertEquals(
2699 // window.location.hostname, 2855 // window.location.hostname,
2700 // document.domain); 2856 // document.domain);
2701 ···· 2857 ····
2702 // document.location is an identical property to window.location 2858 // document.location is an identical property to window.location
2703 assertTrue('document.location', window.location === document.location); 2859 assertTrue('document.location', window.location === document.location);
2704 ···· 2860 ····
2705 pass('testLocation'); 2861 pass('testLocation');
2706 }); 2862 });
2707 </script> 2863 </script>
2708 2864
2709 <div id="testNavigator" class="testcontainer"></div> 2865 <div id="testNavigator" class="testcontainer">testNavigator </div>
2710 <script type="text/javascript"> 2866 <script type="text/javascript">
2711 jsunitRegister('testNavigator', 2867 jsunitRegister('testNavigator',
2712 function testNavigator() { 2868 function testNavigator() {
2713 assertNotNull(window.navigator.userAgent); 2869 assertNotNull(window.navigator.userAgent);
2714 assert("navigator is not a string", 2870 assert("navigator is not a string",
2715 "string" === typeof window.navigator.userAgent); 2871 "string" === typeof window.navigator.userAgent);
2716 pass('testNavigator'); 2872 pass('testNavigator');
2873 });
2874 </script>
2875
2876 <div id="testNoops" class="testcontainer">testNoops </div>
2877 <script type="text/javascript">
2878 jsunitRegister('testNoops',
2879 function testNoops() {
2880 [
2881 'blur', 'focus',
2882 'close',
2883 'moveBy', 'moveTo',
2884 'print',
2885 'stop'
2886 ].forEach(function(name) {
2887 assertEquals('typeof ' + name, 'function', typeof window[name]);
2888
2889 // Fail if this function turns into something non-noopish unexpectedly
2890 assertTrue('name ' + name,
2891 /^function domadoNoop/.test(String(window[name])));
2892
2893 window[name](); // should not fail
2894 });
2895
2896 ['locationbar', 'personalbar', 'menubar', 'scrollbars', 'statusbar',
2897 'toolbar'].forEach(function(name) {
2898 assertEquals('typeof ' + name, 'object', typeof window[name]);
2899 assertTrue('also on defaultView ' + name,
2900 window[name] === document.defaultView[name]);
2901 assertEquals('visible ' + name, false, window[name].visible);
2902 });
2903
2904 pass('testNoops');
2717 }); 2905 });
2718 </script> 2906 </script>
2719 2907
2720 <p id="testUnknownElements" class="testcontainer"> 2908 <p id="testUnknownElements" class="testcontainer">
2721 <!-- Issue 1239: A Twitter widget script expects to be able to create 2909 <!-- Issue 1239: A Twitter widget script expects to be able to create
2722 an element with a novel name. Modern browsers don't mind; we shouldn't. 2910 an element with a novel name. Modern browsers don't mind; we shouldn't.
2723 --> 2911 -->
2724 <twitter id="testUnknownElements-a">I am a static unknown element.</twitter> 2912 <twitter id="testUnknownElements-a">I am a static unknown element.</twitter>
2725 </p> 2913 </p>
2726 <script type="text/javascript"> 2914 <script type="text/javascript">
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2803 //assertEquals('#foo', a.href.substr(-4)); 2991 //assertEquals('#foo', a.href.substr(-4));
2804 a.hash = '#bar'; 2992 a.hash = '#bar';
2805 assertEquals('#bar', a.hash); 2993 assertEquals('#bar', a.hash);
2806 // setting a.hash forces a.getAttribute('href') to be a resolved url 2994 // setting a.hash forces a.getAttribute('href') to be a resolved url
2807 // TODO(felix8a): maybe this should succeed? 2995 // TODO(felix8a): maybe this should succeed?
2808 //assertEquals('#bar', a.href.substr(-4)); 2996 //assertEquals('#bar', a.href.substr(-4));
2809 pass('testHash'); 2997 pass('testHash');
2810 }); 2998 });
2811 </script> 2999 </script>
2812 3000
3001 <div class="testcontainer" id="testBaseURI"></div>
3002 <script type="text/javascript">
3003 jsunitRegister('testBaseURI', function testHash() {
3004 // http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-baseURI
3005 assertEquals('http://localhost:8000/ant-testlib/com/google/caja/plugin/' +
3006 'es53-test-domado-dom-guest.html',
3007 document.getElementById('testBaseURI').baseURI);
3008 pass('testBaseURI');
3009 });
3010 </script>
3011
2813 <p class="testcontainer" id="testDocumentBodyAppendChild" 3012 <p class="testcontainer" id="testDocumentBodyAppendChild"
2814 >I should be the last element until something is appended to document.body</p> 3013 >I should be the last element until something is appended to document.body</p>
2815 <script type="text/javascript"> 3014 <script type="text/javascript">
2816 jsunitRegister('testDocumentBodyAppendChild', 3015 jsunitRegister('testDocumentBodyAppendChild',
2817 function testDocumentBodyAppendChild() { 3016 function testDocumentBodyAppendChild() {
2818 var notWhitespaceRe = new RegExp('\\S'); 3017 var notWhitespaceRe = new RegExp('\\S');
2819 function getPrevNonWhitespace(prev) { 3018 function getPrevNonWhitespace(prev) {
2820 while (prev.nodeType === 3 && !notWhitespaceRe.test(prev.nodeValue)) { 3019 while (prev.nodeType === 3 && !notWhitespaceRe.test(prev.nodeValue)) {
2821 prev = prev.previousSibling; 3020 prev = prev.previousSibling;
2822 } 3021 }
(...skipping 23 matching lines...) Expand all
2846 assertEquals('parent is not body', lastest.parentNode, body); 3045 assertEquals('parent is not body', lastest.parentNode, body);
2847 pass('testDocumentBodyAppendChild'); 3046 pass('testDocumentBodyAppendChild');
2848 }); 3047 });
2849 </script> 3048 </script>
2850 3049
2851 <script type="text/javascript"> 3050 <script type="text/javascript">
2852 // jsunitRun('testPropertyAttributeInteraction'); 3051 // jsunitRun('testPropertyAttributeInteraction');
2853 </script> 3052 </script>
2854 3053
2855 </body> 3054 </body>
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b