diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index fe5789155ffc..809eb4ae953d 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -483,6 +483,9 @@ function updateAboutMemoryFromReporters() } // Increment this if the JSON format changes. +// +// If/when this changes to 2, the beLenient() function and its use can be +// removed. var gCurrentFileFormatVersion = 1; /** @@ -958,8 +961,29 @@ function getPCollsByProcess(aProcessReports) "non-sentence explicit description"); } else { - assertInput(gSentenceRegExp.test(aDescription), - "non-sentence other description"); + const kLenientPrefixes = + ['rss/', 'pss/', 'size/', 'swap/', 'compartments/', 'ghost-windows/']; + let beLenient = function(aUnsafePath) { + for (let i = 0; i < kLenientPrefixes.length; i++) { + if (aUnsafePath.startsWith(kLenientPrefixes[i])) { + return true; + } + } + return false; + } + + // In general, non-explicit reports should have a description that is a + // complete sentence. However, we want to be able to read old saved + // reports, so we are lenient in a couple of situations where we used to + // allow non-sentence descriptions: + // - smaps reports (which were removed in bug 912165); + // - compartment and ghost-window reports (which had empty descriptions + // prior to bug 911641). + if (!beLenient(aUnsafePath)) { + assertInput(gSentenceRegExp.test(aDescription), + "non-sentence other description: " + aUnsafePath + ", " + + aDescription); + } } assert(aPresence === undefined || diff --git a/toolkit/components/aboutmemory/tests/memory-reports-good.json b/toolkit/components/aboutmemory/tests/memory-reports-good.json index 8c5c2412a54f..f3ec6ff4b003 100644 --- a/toolkit/components/aboutmemory/tests/memory-reports-good.json +++ b/toolkit/components/aboutmemory/tests/memory-reports-good.json @@ -7,6 +7,13 @@ {"process": "Main Process (pid NNN)", "path": "other/a", "kind": 2, "units": 0, "amount": 209715, "description": "Other a."}, {"process": "Main Process (pid NNN)", "path": "explicit/a/b", "kind": 1, "units": 0, "amount": 52428800, "description": "A b."}, + {"process": "Main Process (pid NNN)", "path": "size/a", "kind": 1, "units": 0, "amount": 1024, "description": "non-sentence"}, + {"process": "Main Process (pid NNN)", "path": "rss/a", "kind": 1, "units": 0, "amount": 1024, "description": "non-sentence"}, + {"process": "Main Process (pid NNN)", "path": "pss/a", "kind": 1, "units": 0, "amount": 1024, "description": "non-sentence"}, + {"process": "Main Process (pid NNN)", "path": "swap/a", "kind": 1, "units": 0, "amount": 1024, "description": "non-sentence"}, + {"process": "Main Process (pid NNN)", "path": "compartments/system/a", "kind": 1, "units": 0, "amount": 1024, "description": ""}, + {"process": "Main Process (pid NNN)", "path": "ghost-windows/a", "kind": 1, "units": 0, "amount": 1024, "description": ""}, + {"process": "Explicit-only process", "path": "explicit/a/b", "kind": 1, "units": 0, "amount": 100000, "description": "A b."}, {"process": "Other-only process", "path": "a/b", "kind": 1, "units": 0, "amount": 100000, "description": "A b."}, diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul index 38c55f7d858b..a99a1c175e89 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory3.xul @@ -213,10 +213,28 @@ Explicit Allocations\n\ \n\ Other Measurements\n\ \n\ +1,024 B (100.0%) -- compartments\n\ +└──1,024 B (100.0%) ── system/a\n\ +\n\ +1,024 B (100.0%) -- ghost-windows\n\ +└──1,024 B (100.0%) ── a\n\ +\n\ 314,572 B (100.0%) -- other\n\ ├──209,715 B (66.67%) ── a\n\ └──104,857 B (33.33%) ── b\n\ \n\ +1,024 B (100.0%) -- pss\n\ +└──1,024 B (100.0%) ── a\n\ +\n\ +1,024 B (100.0%) -- rss\n\ +└──1,024 B (100.0%) ── a\n\ +\n\ +1,024 B (100.0%) -- size\n\ +└──1,024 B (100.0%) ── a\n\ +\n\ +1,024 B (100.0%) -- swap\n\ +└──1,024 B (100.0%) ── a\n\ +\n\ 262,144,000 B ── heap-allocated\n\ \n\ Other-only process\n\ @@ -309,12 +327,13 @@ Other Measurements\n\ // This loads a pre-existing file that is valid. { filename: "memory-reports-good.json", expected: expectedGood, dumpFirst: false }, - // This dumps to a file and then reads it back in. The output is the same as the first test. + // This dumps to a file and then reads it back in. { filename: "memory-reports-dumped.json.gz", expected: expectedGood2, dumpFirst: true }, // This loads a pre-existing file that is invalid. { filename: "memory-reports-bad.json", expected: expectedBad, dumpFirst: false }, + // This loads a pre-existing diff file. { filename: "memory-reports-diff1.json", filename2: "memory-reports-diff2.json", expected: expectedDiff, dumpFirst: false } ]; diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul index 22ce18777e4d..000711a36ae4 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory4.xul @@ -108,10 +108,28 @@ Explicit Allocations\n\ \n\ Other Measurements\n\ \n\ +0.00 MB (100.0%) -- compartments\n\ +└──0.00 MB (100.0%) ── system/a\n\ +\n\ +0.00 MB (100.0%) -- ghost-windows\n\ +└──0.00 MB (100.0%) ── a\n\ +\n\ 0.30 MB (100.0%) -- other\n\ ├──0.20 MB (66.67%) ── a\n\ └──0.10 MB (33.33%) ── b\n\ \n\ +0.00 MB (100.0%) -- pss\n\ +└──0.00 MB (100.0%) ── a\n\ +\n\ +0.00 MB (100.0%) -- rss\n\ +└──0.00 MB (100.0%) ── a\n\ +\n\ +0.00 MB (100.0%) -- size\n\ +└──0.00 MB (100.0%) ── a\n\ +\n\ +0.00 MB (100.0%) -- swap\n\ +└──0.00 MB (100.0%) ── a\n\ +\n\ 250.00 MB ── heap-allocated\n\ \n\ Other-only process\n\