| Index: third_party/WebKit/LayoutTests/inspector/coverage/segments-merge.html
|
| diff --git a/third_party/WebKit/LayoutTests/inspector/coverage/segments-merge.html b/third_party/WebKit/LayoutTests/inspector/coverage/segments-merge.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..912e224a197f5e81b6ca0e165907ff30857cf846
|
| --- /dev/null
|
| +++ b/third_party/WebKit/LayoutTests/inspector/coverage/segments-merge.html
|
| @@ -0,0 +1,64 @@
|
| +<html>
|
| +<head>
|
| +<script src="../../http/tests/inspector/inspector-test.js"></script>
|
| +<script>
|
| +function initialize_SegmentsMerge() {
|
| +
|
| +InspectorTest.preloadModule("coverage");
|
| +
|
| +}
|
| +
|
| +function test()
|
| +{
|
| + testAndDump([], []);
|
| + testAndDump([{end: 10, count: 1, depth: 1}], []);
|
| + testAndDump([{end: 10, count: 1, depth: 1}], [{end: 10, count: 1, depth: 1}]);
|
| + testAndDump([{end: 10, count: 1, depth: 1}], [{end: 20, count: 1, depth: 1}]);
|
| + testAndDump([{end: 10, count: 1, depth: 1}, {end: 20, count: 1, depth: 1}], []);
|
| + testAndDump([{end: 30, count: 1, depth: 1}], [{end: 10, count: undefined, depth: 0}, {end: 20, count: 2, depth: 1}]);
|
| + testAndDump([{end: 30, count: undefined, depth: 0}], [{end: 10, count: undefined, depth: 0}, {end: 20, count: 2, depth: 1}]);
|
| +
|
| + InspectorTest.completeTest();
|
| +
|
| + function testAndDump(a, b)
|
| + {
|
| + dumpSegments("A: ", a);
|
| + dumpSegments("B: ", b);
|
| +
|
| + var mergedAB = Coverage.CoverageInfo._mergeCoverage(a, b);
|
| + dumpSegments("merged: ", mergedAB);
|
| + var mergedBA = Coverage.CoverageInfo._mergeCoverage(b, a);
|
| + if (!rangesEqual(mergedAB, mergedBA))
|
| + dumpSegments("FAIL, merge(b, a) != merge(a, b): ", mergedBA);
|
| + }
|
| +
|
| + function dumpSegments(prefix, arr)
|
| + {
|
| + InspectorTest.addResult((prefix || "") + JSON.stringify(arr));
|
| + }
|
| +
|
| + function rangesEqual(a, b)
|
| + {
|
| + if (a.length !== b.length)
|
| + return false;
|
| +
|
| + for (var i = 0; i < a.length; i++) {
|
| + if (a[i].end !== b[i].end)
|
| + return false;
|
| + if (a[i].count !== b[i].count)
|
| + return false;
|
| + if (a[i].depth !== b[i].depth)
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| +}
|
| +
|
| +</script>
|
| +</head>
|
| +
|
| +<body onload="runTest()">
|
| +<p>Tests the merge of disjoint segment lists in CoverageModel.</p>
|
| +
|
| +</body>
|
| +</html>
|
|
|