Bug 1265526 - Correctly categorize blob URLs and wasm frames as user content; r=julienw

asm.js and wasm frames were not being correctly identified as user
content in the perf devtool. This patch correctly finds blob urls that
were being mis-identified as platform content, and wasm frames, which do
not have any identifying information other than their function name
containing wasm-function.

MozReview-Commit-ID: 4DjqATCKBK0
This commit is contained in:
Greg Tatum
2017-05-26 18:07:56 -05:00
parent c8531bcb4f
commit d2bc691147
3 changed files with 51 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ const UNKNOWN_SOURCE_STRING = l10n.getStr("frame.unknownSource");
// Character codes used in various parsing helper functions.
const CHAR_CODE_A = "a".charCodeAt(0);
const CHAR_CODE_B = "b".charCodeAt(0);
const CHAR_CODE_C = "c".charCodeAt(0);
const CHAR_CODE_D = "d".charCodeAt(0);
const CHAR_CODE_E = "e".charCodeAt(0);
@@ -19,13 +20,17 @@ const CHAR_CODE_I = "i".charCodeAt(0);
const CHAR_CODE_J = "j".charCodeAt(0);
const CHAR_CODE_L = "l".charCodeAt(0);
const CHAR_CODE_M = "m".charCodeAt(0);
const CHAR_CODE_N = "n".charCodeAt(0);
const CHAR_CODE_O = "o".charCodeAt(0);
const CHAR_CODE_P = "p".charCodeAt(0);
const CHAR_CODE_R = "r".charCodeAt(0);
const CHAR_CODE_S = "s".charCodeAt(0);
const CHAR_CODE_T = "t".charCodeAt(0);
const CHAR_CODE_U = "u".charCodeAt(0);
const CHAR_CODE_W = "w".charCodeAt(0);
const CHAR_CODE_COLON = ":".charCodeAt(0);
const CHAR_CODE_DASH = "-".charCodeAt(0);
const CHAR_CODE_L_SQUARE_BRACKET = "[".charCodeAt(0);
const CHAR_CODE_SLASH = "/".charCodeAt(0);
const CHAR_CODE_CAP_S = "S".charCodeAt(0);
@@ -248,6 +253,18 @@ function isContentScheme(location, i = 0) {
}
return false;
// "blob:"
case CHAR_CODE_B:
if (
location.charCodeAt(++i) == CHAR_CODE_L &&
location.charCodeAt(++i) == CHAR_CODE_O &&
location.charCodeAt(++i) == CHAR_CODE_B &&
location.charCodeAt(++i) == CHAR_CODE_COLON
) {
return isContentScheme(location, i + 1);
}
return false;
default:
return false;
}
@@ -299,6 +316,26 @@ function isChromeScheme(location, i = 0) {
}
}
function isWASM(location, i = 0) {
return (
// "wasm-function["
location.charCodeAt(i) === CHAR_CODE_W &&
location.charCodeAt(++i) === CHAR_CODE_A &&
location.charCodeAt(++i) === CHAR_CODE_S &&
location.charCodeAt(++i) === CHAR_CODE_M &&
location.charCodeAt(++i) === CHAR_CODE_DASH &&
location.charCodeAt(++i) === CHAR_CODE_F &&
location.charCodeAt(++i) === CHAR_CODE_U &&
location.charCodeAt(++i) === CHAR_CODE_N &&
location.charCodeAt(++i) === CHAR_CODE_C &&
location.charCodeAt(++i) === CHAR_CODE_T &&
location.charCodeAt(++i) === CHAR_CODE_I &&
location.charCodeAt(++i) === CHAR_CODE_O &&
location.charCodeAt(++i) === CHAR_CODE_N &&
location.charCodeAt(++i) === CHAR_CODE_L_SQUARE_BRACKET
);
}
/**
* A utility method to get the file name from a sourcemapped location
* The sourcemap location can be in any form. This method returns a
@@ -324,5 +361,6 @@ exports.getSourceNames = getSourceNames;
exports.isScratchpadScheme = isScratchpadScheme;
exports.isChromeScheme = isChromeScheme;
exports.isContentScheme = isContentScheme;
exports.isWASM = isWASM;
exports.isDataScheme = isDataScheme;
exports.getSourceMappedFile = getSourceMappedFile;