| Index: third_party/WebKit/Source/devtools/scripts/npm_test.js
|
| diff --git a/third_party/WebKit/Source/devtools/scripts/npm_test.js b/third_party/WebKit/Source/devtools/scripts/npm_test.js
|
| index 37a93acd4e29e00dbf17c33c56179b5d49b11565..08bbdc61405f45a940f5c9755e8cee6bd5e8693a 100644
|
| --- a/third_party/WebKit/Source/devtools/scripts/npm_test.js
|
| +++ b/third_party/WebKit/Source/devtools/scripts/npm_test.js
|
| @@ -13,10 +13,16 @@ var Flags = {
|
| DEBUG_DEVTOOLS: "--debug-devtools",
|
| DEBUG_DEVTOOLS_SHORTHAND: "-d",
|
| FETCH_CONTENT_SHELL: "--fetch-content-shell",
|
| + COMPAT_PROTOCOL: "--compat-protocol",
|
| +};
|
| +
|
| +var COMPAT_URL_MAPPING = {
|
| + "1.2": "https://storage.googleapis.com/content-shell-devtools-compat/content_shell_417361.zip",
|
| };
|
|
|
| var IS_DEBUG_ENABLED = utils.includes(process.argv, Flags.DEBUG_DEVTOOLS) ||
|
| utils.includes(process.argv, Flags.DEBUG_DEVTOOLS_SHORTHAND);
|
| +var COMPAT_PROTOCOL = utils.parseArgs(process.argv)[Flags.COMPAT_PROTOCOL];
|
| var IS_FETCH_CONTENT_SHELL = utils.includes(process.argv, Flags.FETCH_CONTENT_SHELL);
|
|
|
| var CONTENT_SHELL_ZIP = "content-shell.zip";
|
| @@ -31,6 +37,14 @@ var CACHE_PATH = path.resolve(__dirname, "..", ".test_cache");
|
| var SOURCE_PATH = path.resolve(__dirname, "..", "front_end");
|
|
|
| function main(){
|
| + if (!utils.isDir(CACHE_PATH))
|
| + fs.mkdirSync(CACHE_PATH);
|
| + deleteOldContentShells();
|
| +
|
| + if (COMPAT_PROTOCOL) {
|
| + runCompatibilityTests();
|
| + return;
|
| + }
|
| var hasUserCompiledContentShell = utils.isFile(getContentShellBinaryPath(RELEASE_PATH));
|
| if (!IS_FETCH_CONTENT_SHELL && hasUserCompiledContentShell) {
|
| var outDir = path.resolve(RELEASE_PATH, "..");
|
| @@ -40,9 +54,7 @@ function main(){
|
| runTests(outDir, IS_DEBUG_ENABLED);
|
| return;
|
| }
|
| - if (!utils.isDir(CACHE_PATH))
|
| - fs.mkdirSync(CACHE_PATH);
|
| - deleteOldContentShells();
|
| +
|
| findPreviousUploadedPosition(findMostRecentChromiumCommit())
|
| .then(onUploadedCommitPosition)
|
| .catch(onError);
|
| @@ -54,6 +66,26 @@ function main(){
|
| }
|
| main();
|
|
|
| +function runCompatibilityTests()
|
| +{
|
| + const folder = `compat-protocol-${COMPAT_PROTOCOL}`;
|
| + compileFrontend();
|
| + var outPath = path.resolve(CACHE_PATH, folder, "out");
|
| + var contentShellDirPath = path.resolve(outPath, "Release");
|
| + var hasCachedContentShell = utils.isFile(getContentShellBinaryPath(contentShellDirPath));
|
| + if (hasCachedContentShell) {
|
| + console.log(`Using cached content shell at: ${outPath}`);
|
| + copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH);
|
| + runTests(outPath, IS_DEBUG_ENABLED);
|
| + return;
|
| + }
|
| + prepareContentShellDirectory(folder)
|
| + .then(() => downloadContentShell(COMPAT_URL_MAPPING[COMPAT_PROTOCOL], folder))
|
| + .then(extractContentShell)
|
| + .then(() => copyFrontendToCompatBuildPath(contentShellDirPath, RELEASE_PATH))
|
| + .then(() => runTests(outPath, IS_DEBUG_ENABLED));
|
| +}
|
| +
|
| function compileFrontend()
|
| {
|
| console.log("Compiling devtools frontend");
|
| @@ -78,13 +110,24 @@ function onUploadedCommitPosition(commitPosition)
|
| copyFrontend(contentShellResourcesPath);
|
| return runTests(contentShellPath, true);
|
| }
|
| + var url = `http://commondatastorage.googleapis.com/chromium-browser-snapshots/${PLATFORM}/${commitPosition}/${CONTENT_SHELL_ZIP}`;
|
| return prepareContentShellDirectory(commitPosition)
|
| - .then(downloadContentShell)
|
| + .then(() => downloadContentShell(url, commitPosition))
|
| .then(extractContentShell)
|
| .then(() => copyFrontend(contentShellResourcesPath))
|
| .then(() => runTests(contentShellPath, true));
|
| }
|
|
|
| +function copyFrontendToCompatBuildPath(compatBuildPath, latestBuildPath)
|
| +{
|
| + var customDevtoolsResourcesPath = path.resolve(compatBuildPath, "resources");
|
| + var latestDevtoolsInspectorPath = path.resolve(latestBuildPath, "resources", "inspector");
|
| + var copiedFrontendPath = path.resolve(customDevtoolsResourcesPath, "inspector");
|
| + if (utils.isDir(copiedFrontendPath))
|
| + utils.removeRecursive(copiedFrontendPath);
|
| + utils.copyRecursive(latestDevtoolsInspectorPath, customDevtoolsResourcesPath);
|
| +}
|
| +
|
| function copyFrontend(contentShellResourcesPath)
|
| {
|
| var devtoolsResourcesPath = path.resolve(contentShellResourcesPath, "inspector");
|
| @@ -170,18 +213,17 @@ function findPreviousUploadedPosition(commitPosition)
|
| }
|
| }
|
|
|
| -function prepareContentShellDirectory(contentShellCommitPosition)
|
| +function prepareContentShellDirectory(folder)
|
| {
|
| - var contentShellPath = path.join(CACHE_PATH, contentShellCommitPosition);
|
| + var contentShellPath = path.join(CACHE_PATH, folder);
|
| if (utils.isDir(contentShellPath))
|
| utils.removeRecursive(contentShellPath);
|
| fs.mkdirSync(contentShellPath);
|
| - return Promise.resolve(contentShellCommitPosition);
|
| + return Promise.resolve(folder);
|
| }
|
|
|
| -function downloadContentShell(commitPosition)
|
| +function downloadContentShell(url, folder)
|
| {
|
| - var url = `http://commondatastorage.googleapis.com/chromium-browser-snapshots/${PLATFORM}/${commitPosition}/${CONTENT_SHELL_ZIP}`;
|
| console.log("Downloading content shell from:", url);
|
| console.log("NOTE: Download is ~35-65 MB depending on OS");
|
| return utils.fetch(url)
|
| @@ -191,7 +233,7 @@ function downloadContentShell(commitPosition)
|
| function writeZip(buffer)
|
| {
|
| console.log("Completed download of content shell");
|
| - var contentShellZipPath = path.join(CACHE_PATH, commitPosition, CONTENT_SHELL_ZIP);
|
| + var contentShellZipPath = path.join(CACHE_PATH, folder, CONTENT_SHELL_ZIP);
|
| fs.writeFileSync(contentShellZipPath, buffer);
|
| return contentShellZipPath;
|
| }
|
| @@ -247,6 +289,9 @@ function runTests(buildDirectoryPath, useDebugDevtools)
|
| } else {
|
| console.log("TIP: You can debug a test using: npm run debug-test inspector/test-name.html")
|
| }
|
| + if (COMPAT_PROTOCOL) {
|
| + testArgs.push(`--platform=linux-devtools-${COMPAT_PROTOCOL}`);
|
| + }
|
| if (IS_DEBUG_ENABLED) {
|
| testArgs.push("--additional-driver-flag=--remote-debugging-port=9222");
|
| testArgs.push("--time-out-ms=6000000");
|
| @@ -265,7 +310,10 @@ function getTestFlags()
|
| var flagValues = Object.keys(Flags).map(key => Flags[key]);
|
| return process.argv
|
| .slice(2)
|
| - .filter(arg => !utils.includes(flagValues, arg) && !utils.includes(arg, "inspector"));
|
| + .filter(arg => {
|
| + var flagName = utils.includes(arg, "=") ? arg.slice(0, arg.indexOf('=')) : arg;
|
| + return !utils.includes(flagValues, flagName) && !utils.includes(arg, "inspector")
|
| + });
|
| }
|
|
|
| function getInspectorTests()
|
|
|