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

Side by Side Diff: third_party/WebKit/LayoutTests/svg/as-object/sizing/svg-in-object.js

Issue 1423093005: Split <object> tests further to reduce timeout risk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also include assert_approx_equals adjustment Created 5 years, 1 month 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
OLDNEW
1 // global async_test, assert_equals 1 // global async_test, assert_equals
2 // 2 //
3 // This test generates a couple of scenarios (each a TestData) for 3 // This test generates a couple of scenarios (each a TestData) for
4 // sizing SVG inside an inline <object> and has a simple JavaScript 4 // sizing SVG inside an inline <object> and has a simple JavaScript
5 // sizing implementation that handles the generated scenarios. It 5 // sizing implementation that handles the generated scenarios. It
6 // generates a DOM corresponding to the scenario and compares the laid 6 // generates a DOM corresponding to the scenario and compares the laid
7 // out size to the calculated size. 7 // out size to the calculated size.
8 // 8 //
9 // The tests loops through different combinations of: 9 // The tests loops through different combinations of:
10 // 10 //
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 doCombinationTestRecursive(values, {}); 379 doCombinationTestRecursive(values, {});
380 } 380 }
381 381
382 var debugHint = function(id) { return "(append ?"+id+" to debug) " }; 382 var debugHint = function(id) { return "(append ?"+id+" to debug) " };
383 var testSingleId; 383 var testSingleId;
384 if (window.location.search) { 384 if (window.location.search) {
385 testSingleId = window.location.search.substring(1); 385 testSingleId = window.location.search.substring(1);
386 debugHint = function(id) { return ""; }; 386 debugHint = function(id) { return ""; };
387 } 387 }
388 388
389 function testSVGInObjectWithPlaceholderHeightAttr(placeholderHeightAttr) { 389 function testSVGInObjectWithPlaceholder(placeholderWidthAttr, placeholderHeightA ttr) {
390 // Separated over placeholderHeightAttr so that the test count is around ~20 0
391
392 doCombinationTest( 390 doCombinationTest(
393 [["containerWidthStyle", [null, "400px"]], 391 [["containerWidthStyle", [null, "400px"]],
394 ["containerHeightStyle", [null, "400px"]], 392 ["containerHeightStyle", [null, "400px"]],
395 ["placeholderWidthAttr", [null, "100", "50%"]], 393 ["placeholderWidthAttr", [placeholderWidthAttr]],
396 ["placeholderHeightAttr", [placeholderHeightAttr]], 394 ["placeholderHeightAttr", [placeholderHeightAttr]],
397 ["svgViewBoxAttr", [ null, "0 0 100 200" ]], 395 ["svgViewBoxAttr", [ null, "0 0 100 200" ]],
398 ["svgWidthAttr", [ null, "200", "25%" ]], 396 ["svgWidthAttr", [ null, "200", "25%" ]],
399 ["svgHeightAttr", [ null, "200", "25%" ]]], 397 ["svgHeightAttr", [ null, "200", "25%" ]]],
400 function(config, id) { 398 function(config, id) {
401 if (!testSingleId || testSingleId == id) { 399 if (!testSingleId || testSingleId == id) {
402 var testData = new TestData(config); 400 var testData = new TestData(config);
403 var t = async_test(testData.name); 401 var t = async_test(testData.name);
404 402
405 var expectedRect = 403 var expectedRect =
406 testData.computeInlineReplacedSize(); 404 testData.computeInlineReplacedSize();
407 var placeholder = setupPlaceholder(testData); 405 var placeholder = setupPlaceholder(testData);
408 var container = 406 var container =
409 setupContainer(testData, placeholder); 407 setupContainer(testData, placeholder);
410 408
411 var checkSize = function() { 409 var checkSize = function() {
412 var placeholderRect = 410 var placeholderRect =
413 placeholder.getBoundingClientRect(); 411 placeholder.getBoundingClientRect();
414 412
415 try { 413 try {
416 assert_equals(placeholderRect.width, 414 assert_approx_equals(placeholderRect.width,
417 expectedRect.width, 415 expectedRect.width,
418 debugHint(id) + "Wrong width"); 416 0.5,
419 assert_equals(placeholderRect.height, 417 debugHint(id) + "Wrong width");
420 expectedRect.height, 418 assert_approx_equals(placeholderRect.height,
421 debugHint(id) + "Wrong height"); 419 expectedRect.height,
420 0.5,
421 debugHint(id) + "Wrong height");
422 } finally { 422 } finally {
423 testContainer.removeChild(container); 423 testContainer.removeChild(container);
424 if (testSingleId) 424 if (testSingleId)
425 document.body.removeChild(testContainer); 425 document.body.removeChild(testContainer);
426 } 426 }
427 t.done(); 427 t.done();
428 }; 428 };
429 429
430 t.step(function() { 430 t.step(function() {
431 placeholder.addEventListener('load', function() { 431 placeholder.addEventListener('load', function() {
(...skipping 20 matching lines...) Expand all
452 iframe.src = "data:text/html;charset=utf-8," + encodeURIComponen t(demo); 452 iframe.src = "data:text/html;charset=utf-8," + encodeURIComponen t(demo);
453 document.body.appendChild(iframe); 453 document.body.appendChild(iframe);
454 454
455 document.body.insertAdjacentHTML( 455 document.body.insertAdjacentHTML(
456 'beforeEnd', 456 'beforeEnd',
457 '<p><a href="data:application/octet-stream;charset=utf-8;bas e64,' + 457 '<p><a href="data:application/octet-stream;charset=utf-8;bas e64,' +
458 btoa(demo) + '" download="svg-in-object-test-' + pad(id, 3) + '.html">Download</a></p>'); 458 btoa(demo) + '" download="svg-in-object-test-' + pad(id, 3) + '.html">Download</a></p>');
459 } 459 }
460 }); 460 });
461 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698