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

Side by Side Diff: LayoutTests/inspector/profiler/heap-snapshot-test.js

Issue 211273005: Do not override data getter in heap snapshot grid nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed unused parameter from findRow Created 6 years, 9 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
OLDNEW
1 var initialize_HeapSnapshotTest = function() { 1 var initialize_HeapSnapshotTest = function() {
2 2
3 InspectorTest.createHeapSnapshotMockFactories = function() { 3 InspectorTest.createHeapSnapshotMockFactories = function() {
4 4
5 InspectorTest.createJSHeapSnapshotMockObject = function() 5 InspectorTest.createJSHeapSnapshotMockObject = function()
6 { 6 {
7 return { 7 return {
8 _rootNodeIndex: 0, 8 _rootNodeIndex: 0,
9 _nodeTypeOffset: 0, 9 _nodeTypeOffset: 0,
10 _nodeNameOffset: 1, 10 _nodeNameOffset: 1,
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 }; 474 };
475 475
476 InspectorTest.checkArrayIsSorted = function(contents, sortType, sortOrder) 476 InspectorTest.checkArrayIsSorted = function(contents, sortType, sortOrder)
477 { 477 {
478 function simpleComparator(a, b) 478 function simpleComparator(a, b)
479 { 479 {
480 return a < b ? -1 : (a > b ? 1 : 0); 480 return a < b ? -1 : (a > b ? 1 : 0);
481 } 481 }
482 function parseSize(size) 482 function parseSize(size)
483 { 483 {
484 if (size.substr(0, 1) === '"') size = JSON.parse(size);
485 // Remove thousands separator. 484 // Remove thousands separator.
486 return parseInt(size.replace(/[\u2009,]/g, "")); 485 return parseInt(size.replace(/[\u2009,]/g, ""), 10);
487 }
488 function extractField(data, field)
489 {
490 if (data.substr(0, 1) !== "{") return data;
491 data = JSON.parse(data);
492 if (!data[field])
493 InspectorTest.addResult("No " + field + " field in " + JSON.stringif y(data));
494 return data[field];
495 }
496 function extractId(data)
497 {
498 return parseInt(extractField(data, "nodeId"));
499 } 486 }
500 var extractor = { 487 var extractor = {
501 text: function (data) { return extractField(data, "value"); }, 488 text: function (data) { data; },
502 number: function (data) { return parseInt(data, 10); }, 489 number: function (data) { return parseInt(data, 10); },
503 size: function (data) { return parseSize(data); }, 490 size: parseSize,
504 name: function (data) { return extractField(data, "name"); }, 491 name: function (data) { return data; },
505 id: function (data) { return extractId(data); } 492 id: function (data) { return parseInt(data, 10); }
506 }[sortType]; 493 }[sortType];
507 var acceptableComparisonResult = { 494 var acceptableComparisonResult = {
508 ascending: -1, 495 ascending: -1,
509 descending: 1 496 descending: 1
510 }[sortOrder]; 497 }[sortOrder];
511 498
512 if (!extractor) { 499 if (!extractor) {
513 InspectorTest.addResult("Invalid sort type: " + sortType); 500 InspectorTest.addResult("Invalid sort type: " + sortType);
514 return; 501 return;
515 } 502 }
516 if (!acceptableComparisonResult) { 503 if (!acceptableComparisonResult) {
517 InspectorTest.addResult("Invalid sort order: " + sortOrder); 504 InspectorTest.addResult("Invalid sort order: " + sortOrder);
518 return; 505 return;
519 } 506 }
520 507
521 for (var i = 0; i < contents.length - 1; ++i) { 508 for (var i = 0; i < contents.length - 1; ++i) {
522 var a = extractor(contents[i]); 509 var a = extractor(contents[i]);
523 var b = extractor(contents[i + 1]); 510 var b = extractor(contents[i + 1]);
524 var result = simpleComparator(a, b); 511 var result = simpleComparator(a, b);
525 if (result !== 0 && result !== acceptableComparisonResult) 512 if (result !== 0 && result !== acceptableComparisonResult) {
526 InspectorTest.addResult("Elements " + i + " and " + (i + 1) + " are out of order: " + a + " " + b + " (" + sortOrder + ")"); 513 InspectorTest.addResult("Elements " + i + " and " + (i + 1) + " are out of order: " + a + " " + b + " (" + sortOrder + ")");
514 }
527 } 515 }
528 }; 516 };
529 517
530 InspectorTest.clickColumn = function(column, callback) 518 InspectorTest.clickColumn = function(column, callback)
531 { 519 {
532 callback = InspectorTest.safeWrap(callback); 520 callback = InspectorTest.safeWrap(callback);
533 var cell = this._currentGrid()._headerTableHeaders[column.identifier]; 521 var cell = this._currentGrid()._headerTableHeaders[column.identifier];
534 var event = { target: { enclosingNodeOrSelfWithNodeName: function() { return cell; } } }; 522 var event = { target: { enclosingNodeOrSelfWithNodeName: function() { return cell; } } };
535 523
536 function sortingComplete() 524 function sortingComplete()
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 574
587 InspectorTest.columnContents = function(column, row) 575 InspectorTest.columnContents = function(column, row)
588 { 576 {
589 // Make sure invisible nodes are removed from the view port. 577 // Make sure invisible nodes are removed from the view port.
590 this._currentGrid().updateVisibleNodes(); 578 this._currentGrid().updateVisibleNodes();
591 var result = []; 579 var result = [];
592 var parent = row || this._currentGrid().rootNode(); 580 var parent = row || this._currentGrid().rootNode();
593 for (var node = parent.children[0]; node; node = node.traverseNextNode(true, parent, true)) { 581 for (var node = parent.children[0]; node; node = node.traverseNextNode(true, parent, true)) {
594 if (!node.selectable) 582 if (!node.selectable)
595 continue; 583 continue;
596 var data = node.data[column.identifier]; 584 var cell = node.element.children[column.ordinal];
597 if (typeof data === "object") 585 var content = cell.firstElementChild;
598 data = JSON.stringify(data); 586 // Do not inlcude percents
599 result.push(data); 587 if (content.firstElementChild)
588 content = content.firstElementChild;
589 result.push(content.textContent);
600 } 590 }
601 return result; 591 return result;
602 }; 592 };
603 593
604 InspectorTest.countDataRows = function(row, filter) 594 InspectorTest.countDataRows = function(row, filter)
605 { 595 {
606 var result = 0; 596 var result = 0;
607 filter = filter || function(node) { return node.selectable; }; 597 filter = filter || function(node) { return node.selectable; };
608 for (var node = row.children[0]; node; node = node.traverseNextNode(true, ro w, true)) { 598 for (var node = row.children[0]; node; node = node.traverseNextNode(true, ro w, true)) {
609 if (filter(node)) 599 if (filter(node))
(...skipping 30 matching lines...) Expand all
640 }; 630 };
641 631
642 InspectorTest.findAndExpandWindow = function(callback) 632 InspectorTest.findAndExpandWindow = function(callback)
643 { 633 {
644 InspectorTest.findAndExpandRow("Window", callback); 634 InspectorTest.findAndExpandRow("Window", callback);
645 }; 635 };
646 636
647 InspectorTest.findAndExpandRow = function(name, callback) 637 InspectorTest.findAndExpandRow = function(name, callback)
648 { 638 {
649 callback = InspectorTest.safeWrap(callback); 639 callback = InspectorTest.safeWrap(callback);
650 function propertyMatcher(data) 640 var row = InspectorTest.findRow(name);
651 {
652 return data.value === name;
653 }
654 var row = InspectorTest.findRow("object", propertyMatcher);
655 InspectorTest.assertEquals(true, !!row, '"' + name + '" row'); 641 InspectorTest.assertEquals(true, !!row, '"' + name + '" row');
656 InspectorTest.expandRow(row, callback); 642 InspectorTest.expandRow(row, callback);
657 }; 643 };
658 644
659 InspectorTest.findButtonsNode = function(row, startNode) 645 InspectorTest.findButtonsNode = function(row, startNode)
660 { 646 {
661 var result = 0; 647 var result = 0;
662 for (var node = startNode || row.children[0]; node; node = node.traverseNext Node(true, row, true)) { 648 for (var node = startNode || row.children[0]; node; node = node.traverseNext Node(true, row, true)) {
663 if (!node.selectable && node.showNext) 649 if (!node.selectable && node.showNext)
664 return node; 650 return node;
665 } 651 }
666 return null; 652 return null;
667 }; 653 };
668 654
669 InspectorTest.findRow = function(columnIdentifier, matcher, parent) 655 InspectorTest.findRow = function(name, parent)
656 {
657 function matcher(x)
658 {
659 return x._name === name;
660 };
661 return InspectorTest.findMatchingRow(matcher, parent);
662 };
663
664 InspectorTest.findMatchingRow = function(matcher, parent)
670 { 665 {
671 parent = parent || this._currentGrid().rootNode(); 666 parent = parent || this._currentGrid().rootNode();
672 if (typeof matcher !== "function") {
673 var value = matcher;
674 matcher = function(x) { return x === value; };
675 }
676 for (var node = parent.children[0]; node; node = node.traverseNextNode(true, parent, true)) { 667 for (var node = parent.children[0]; node; node = node.traverseNextNode(true, parent, true)) {
677 if (matcher(node.data[columnIdentifier])) 668 if (matcher(node))
678 return node; 669 return node;
679 } 670 }
680 return null; 671 return null;
681 };
682
683 InspectorTest.findRow2 = function(matcher, parent)
684 {
685 parent = parent || this._currentGrid().rootNode();
686 for (var node = parent.children[0]; node; node = node.traverseNextNode(true, parent, true)) {
687 if (matcher(node.data))
688 return node;
689 }
690 return null;
691 }; 672 };
692 673
693 InspectorTest.switchToView = function(title, callback) 674 InspectorTest.switchToView = function(title, callback)
694 { 675 {
695 callback = InspectorTest.safeWrap(callback); 676 callback = InspectorTest.safeWrap(callback);
696 var view = WebInspector.panels.profiles.visibleView; 677 var view = WebInspector.panels.profiles.visibleView;
697 view._changePerspectiveAndWait(title, callback); 678 view._changePerspectiveAndWait(title, callback);
698 // Increase the grid container height so the viewport don't limit the number of nodes. 679 // Increase the grid container height so the viewport don't limit the number of nodes.
699 InspectorTest._currentGrid().scrollContainer.style.height = "10000px"; 680 InspectorTest._currentGrid().scrollContainer.style.height = "10000px";
700 }; 681 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 function sortingComplete() 725 function sortingComplete()
745 { 726 {
746 dataGrid.removeEventListener(WebInspector.HeapSnapshotSortableDataGr id.Events.SortingComplete, sortingComplete, null); 727 dataGrid.removeEventListener(WebInspector.HeapSnapshotSortableDataGr id.Events.SortingComplete, sortingComplete, null);
747 callback(); 728 callback();
748 } 729 }
749 dataGrid.addEventListener(WebInspector.HeapSnapshotSortableDataGrid.Even ts.SortingComplete, sortingComplete, null); 730 dataGrid.addEventListener(WebInspector.HeapSnapshotSortableDataGrid.Even ts.SortingComplete, sortingComplete, null);
750 } 731 }
751 }; 732 };
752 733
753 }; 734 };
OLDNEW
« no previous file with comments | « LayoutTests/inspector/profiler/heap-snapshot-summary-sorting-instances.html ('k') | Source/devtools/front_end/HeapSnapshot.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698