Skip to content

Commit

Permalink
squash 'resources/unpacked/devtools' changes from f2e60ca..791c2d1
Browse files Browse the repository at this point in the history
791c2d1 [DevTools] Use InspectorFrontendHost.readyForTest for layout tests.
0d7fb63 [DevTools] Improve DOMPropertiesExpanded user metric
711d90c DevTools: Add functionName to FunctionCall event.
4700678 [DevTools] Remove websocket frontend API.
b1cd0d9 DevTools: introduce SourceMap editable capability
475db6a DevTools: Introduce WI.SourceMap interface
664ebfb DevTools: Fix a deopt in FlameChart.timeToPosition
3486490 DevTools: Use live location for line level profile presentation.
082b570 DevTools: make sure scope variables do not throw exception
e0662b3 [DevTools] Introduce InspectorFrontendHost.readyForTest.
651cc1b update label in styles pane
9d7fa42 DevTools: use WebInspector namespace instead of FormatterWorker
d4b28e4 Reland of DevTools: Select max resource size in NetworkResourcesData depending on device capabilities. (patchset #1 id:1 of https://codereview.chromium.org/1825033002/ )
2b55c82 Revert of DevTools: Select max resource size in NetworkResourcesData depending on device capabilities. (patchset #1 id:1 of https://codereview.chromium.org/1817523003/ )
82aee18 Devtools: Remove duplicated shortcut for go to member in Sources
da43a0c Devtools: Don't show color swatch for variables like var(--blue)
958ed98 Devtools: Reduce indentation in elements tree
b2914d1 Devtools: Hide popover arrow when not able to position next to anchor
029d653 DevTools: fix breakpoints rendering
7e004a7 DevTools: split formatter worker into files
7b474d9 DevTools: [SASS] get rid of CSS/SASS words inside WI.ASTSourceMap
ae67858 DevTools: simplify formatting of mixed HTML
8daf994 DevTools: mapify WI.DOMNode._markers
8fcdc3c DevTools: update ViewportDataGrid resizers when scrollbar visibility changes
cfce0bb DevTools: Tooltip is shown wrong on hovering the mouse over element state marker in Elements tab.
401a88a Devtools: Fix command menu scoring
77c134b DevTools: Select max resource size in NetworkResourcesData depending on device capabilities.

git-subtree-dir: resources/unpacked/devtools
git-subtree-split: 791c2d1
  • Loading branch information
darwin committed Mar 24, 2016
1 parent 6e6f974 commit 0e854f4
Show file tree
Hide file tree
Showing 52 changed files with 1,345 additions and 1,284 deletions.
31 changes: 15 additions & 16 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ visibility = [ "//third_party/WebKit/*" ]
group("devtools_frontend_resources") {
public_deps = [
":build_applications",
":copy_compatibility_scripts",
":copy_embedder_scripts",
":copy_emulated_devices_images",
":copy_inspector_images",
":devtools_extension_api",
Expand All @@ -85,8 +85,8 @@ group("devtools_frontend_resources") {
]
}

copy("copy_compatibility_scripts") {
sources = gypi_values.devtools_compatibility_scripts
copy("copy_embedder_scripts") {
sources = gypi_values.devtools_embedder_scripts
outputs = [
resources_out_dir + "{{source_file_part}}",
]
Expand All @@ -113,7 +113,7 @@ action("generate_devtools_grd") {
":devtools_frontend_resources",
]
inputs = gypi_values.devtools_image_files + all_devtools_files
inputs += gypi_values.devtools_compatibility_scripts
inputs += gypi_values.devtools_embedder_scripts

if (debug_devtools) {
# Debug: all files are picked as-is.
Expand Down Expand Up @@ -181,18 +181,17 @@ action("generate_devtools_grd") {
"front_end",
]

args =
rebase_path(generated_files, root_build_dir) +
rebase_path(generated_files, root_build_dir) +
rebase_path(gypi_values.devtools_compatibility_scripts, root_build_dir) +
static_files_args + [ "--relative_path_dirs" ] +
rebase_path(relative_path_dirs, root_build_dir) +
[
"--images",
rebase_path(images_path, root_build_dir),
"--output",
rebase_path(outfile, root_build_dir),
]
args = rebase_path(generated_files, root_build_dir) +
rebase_path(generated_files, root_build_dir) +
rebase_path(gypi_values.devtools_embedder_scripts, root_build_dir) +
static_files_args + [ "--relative_path_dirs" ] +
rebase_path(relative_path_dirs, root_build_dir) +
[
"--images",
rebase_path(images_path, root_build_dir),
"--output",
rebase_path(outfile, root_build_dir),
]
}

action("devtools_extension_api") {
Expand Down
10 changes: 5 additions & 5 deletions devtools.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{
'destination': '<(PRODUCT_DIR)/resources/inspector/',
'files': [
'<@(devtools_compatibility_scripts)',
'<@(devtools_embedder_scripts)',
],
},
],
Expand Down Expand Up @@ -132,7 +132,7 @@
'inputs': [
'<@(_script_name)',
'<@(_static_files)',
'<@(devtools_compatibility_scripts)',
'<@(devtools_embedder_scripts)',
'<@(_generated_files)',
'<@(devtools_image_files)',
'<(_devtools_static_files_list)',
Expand All @@ -141,7 +141,7 @@
'front_end/Images',
],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd'],
'action': ['python', '<@(_script_name)', '<@(_generated_files)', '<@(devtools_compatibility_scripts)', '--static_files_list', '<(_devtools_static_files_list)', '--relative_path_dirs', '<@(_relative_path_dirs)', '--images', '<@(_images_path)', '--output', '<@(_outputs)'],
'action': ['python', '<@(_script_name)', '<@(_generated_files)', '<@(devtools_embedder_scripts)', '--static_files_list', '<(_devtools_static_files_list)', '--relative_path_dirs', '<@(_relative_path_dirs)', '--images', '<@(_images_path)', '--output', '<@(_outputs)'],
}],
},
{
Expand Down Expand Up @@ -170,7 +170,7 @@
'inputs': [
'<@(_script_name)',
'<@(_static_files)',
'<@(devtools_compatibility_scripts)',
'<@(devtools_embedder_scripts)',
'<@(_generated_files)',
'<@(devtools_image_files)',
'<(_devtools_static_files_list)',
Expand All @@ -180,7 +180,7 @@
],
# Note that other files are put under /devtools directory, together with declared devtools_resources.grd
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/devtools/devtools_resources.grd'],
'action': ['python', '<@(_script_name)', '<@(_generated_files)', '<@(devtools_compatibility_scripts)', '--static_files_list', '<(_devtools_static_files_list)', '--relative_path_dirs', '<@(_relative_path_dirs)', '--images', '<@(_images_path)', '--output', '<@(_outputs)'],
'action': ['python', '<@(_script_name)', '<@(_generated_files)', '<@(devtools_embedder_scripts)', '--static_files_list', '<(_devtools_static_files_list)', '--relative_path_dirs', '<@(_relative_path_dirs)', '--images', '<@(_images_path)', '--output', '<@(_outputs)'],
}],
}],
],
Expand Down
12 changes: 7 additions & 5 deletions devtools.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
'<@(devtools_ui_js_files)',
'<@(devtools_workspace_js_files)',
],
'devtools_compatibility_scripts': [
'devtools_embedder_scripts': [
'front_end/devtools.js',
'front_end/Tests.js',
],
'devtools_core_base_files': [
'front_end/inspector.js',
Expand All @@ -73,7 +74,6 @@
'front_end/common/StaticContentProvider.js',
'front_end/common/OutputStream.js',
'front_end/common/SegmentedRange.js',
'front_end/common/TestBase.js',
'front_end/common/Text.js',
'front_end/common/TextDictionary.js',
'front_end/common/TextRange.js',
Expand Down Expand Up @@ -122,6 +122,7 @@
'front_end/sass/ASTSourceMap.js',
'front_end/sass/SASSProcessor.js',
'front_end/sass/SASSSupport.js',
'front_end/sass/SASSSourceMapFactory.js',
],
'devtools_screencast_js_files': [
'front_end/screencast/screencastView.css',
Expand Down Expand Up @@ -307,12 +308,10 @@
'front_end/main/renderingOptions.css',
'front_end/main/targetCrashedScreen.css',
'front_end/main/Connections.js',
'front_end/main/FrontendWebSocketAPI.js',
'front_end/main/Main.js',
'front_end/main/OverlayController.js',
'front_end/main/RenderingOptions.js',
'front_end/main/SimpleApp.js',
'front_end/main/Tests.js',
],
'devtools_module_json_files': [
'front_end/accessibility/module.json',
Expand Down Expand Up @@ -598,14 +597,17 @@
'front_end/acorn/acorn.js',
'front_end/cm/css.js',
'front_end/cm/headlesscodemirror.js',
'front_end/cm/htmlmixed.js',
'front_end/cm/xml.js',
'front_end/es_tree/AcornTokenizer.js',
'front_end/es_tree/ESTreeWalker.js',
'front_end/platform/utilities.js',
'front_end/formatter_worker/CSSFormatter.js',
'front_end/formatter_worker/FormattedContentBuilder.js',
'front_end/formatter_worker/JavaScriptFormatter.js',
'front_end/formatter_worker/CSSRuleParser.js',
'front_end/formatter_worker/HTMLFormatter.js',
'front_end/formatter_worker/IdentityFormatter.js',
'front_end/formatter_worker/JavaScriptOutline.js',
'front_end/formatter_worker/FormatterWorker.js',
],
'devtools_settings_js_files': [
Expand Down
207 changes: 194 additions & 13 deletions front_end/main/Tests.js → front_end/Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,210 @@
* FIXME: change field naming style to use trailing underscore.
*/

function createTestSuite(domAutomationController)
(function createTestSuite(window)
{

/**
* Test suite for interactive UI tests.
* @constructor
* @param {Object} domAutomationController DomAutomationController instance.
*/
function TestSuite()
function TestSuite(domAutomationController)
{
WebInspector.TestBase.call(this, domAutomationController);
this.domAutomationController_ = domAutomationController;
this.controlTaken_ = false;
this.timerId_ = -1;
this._asyncInvocationId = 0;
}

/**
* Reports test failure.
* @param {string} message Failure description.
*/
TestSuite.prototype.fail = function(message)
{
if (this.controlTaken_)
this.reportFailure_(message);
else
throw message;
};


/**
* Equals assertion tests that expected === actual.
* @param {!Object|boolean} expected Expected object.
* @param {!Object|boolean} actual Actual object.
* @param {string} opt_message User message to print if the test fails.
*/
TestSuite.prototype.assertEquals = function(expected, actual, opt_message)
{
if (expected !== actual) {
var message = "Expected: '" + expected + "', but was '" + actual + "'";
if (opt_message)
message = opt_message + "(" + message + ")";
this.fail(message);
}
};


/**
* True assertion tests that value == true.
* @param {!Object} value Actual object.
* @param {string} opt_message User message to print if the test fails.
*/
TestSuite.prototype.assertTrue = function(value, opt_message)
{
this.assertEquals(true, !!value, opt_message);
};


/**
* Takes control over execution.
*/
TestSuite.prototype.takeControl = function()
{
this.controlTaken_ = true;
// Set up guard timer.
var self = this;
this.timerId_ = setTimeout(function() {
self.reportFailure_("Timeout exceeded: 20 sec");
}, 20000);
};


/**
* Releases control over execution.
*/
TestSuite.prototype.releaseControl = function()
{
if (this.timerId_ !== -1) {
clearTimeout(this.timerId_);
this.timerId_ = -1;
}
this.controlTaken_ = false;
this.reportOk_();
};


/**
* Async tests use this one to report that they are completed.
*/
TestSuite.prototype.reportOk_ = function()
{
this.domAutomationController_.send("[OK]");
};


/**
* Async tests use this one to report failures.
*/
TestSuite.prototype.reportFailure_ = function(error)
{
if (this.timerId_ !== -1) {
clearTimeout(this.timerId_);
this.timerId_ = -1;
}
this.domAutomationController_.send("[FAILED] " + error);
};


/**
* Run specified test on a fresh instance of the test suite.
* @param {Array<string>} args method name followed by its parameters.
*/
TestSuite.prototype.dispatchOnTestSuite = function(args)
{
var methodName = args.shift();
try {
this[methodName].apply(this, args);
if (!this.controlTaken_)
this.reportOk_();
} catch (e) {
this.reportFailure_(e);
}
};

TestSuite.prototype = {
__proto__: WebInspector.TestBase.prototype

/**
* Wrap an async method with TestSuite.{takeControl(), releaseControl()}
* and invoke TestSuite.reportOk_ upon completion.
* @param {Array<string>} args method name followed by its parameters.
*/
TestSuite.prototype.waitForAsync = function(var_args)
{
var args = Array.prototype.slice.call(arguments);
this.takeControl();
args.push(this.releaseControl.bind(this));
this.dispatchOnTestSuite(args);
};

/**
* Overrides the method with specified name until it's called first time.
* @param {!Object} receiver An object whose method to override.
* @param {string} methodName Name of the method to override.
* @param {!Function} override A function that should be called right after the
* overridden method returns.
* @param {?boolean} opt_sticky Whether restore original method after first run
* or not.
*/
TestSuite.prototype.addSniffer = function(receiver, methodName, override, opt_sticky)
{
var orig = receiver[methodName];
if (typeof orig !== "function")
this.fail("Cannot find method to override: " + methodName);
var test = this;
receiver[methodName] = function(var_args) {
try {
var result = orig.apply(this, arguments);
} finally {
if (!opt_sticky)
receiver[methodName] = orig;
}
// In case of exception the override won't be called.
try {
override.apply(this, arguments);
} catch (e) {
test.fail("Exception in overriden method '" + methodName + "': " + e);
}
return result;
};
};

/**
* Waits for current throttler invocations, if any.
* @param {!WebInspector.Throttler} throttler
* @param {function()} callback
*/
TestSuite.prototype.waitForThrottler = function(throttler, callback)
{
var test = this;
var scheduleShouldFail = true;
test.addSniffer(throttler, "schedule", onSchedule);

function hasSomethingScheduled()
{
return throttler._isRunningProcess || throttler._process;
}

function checkState()
{
if (!hasSomethingScheduled()) {
scheduleShouldFail = false;
callback();
return;
}

test.addSniffer(throttler, "_processCompletedForTests", checkState);
}

function onSchedule()
{
if (scheduleShouldFail)
test.fail("Unexpected Throttler.schedule");
}

checkState();
};

/**
* @param {string} panelName Name of the panel to show.
Expand Down Expand Up @@ -888,11 +1075,5 @@ TestSuite.createKeyEvent = function(keyIdentifier)
return evt;
};

return new TestSuite();

}

if (window.uiTests) {
WebInspector.notifications.addEventListener(WebInspector.NotificationService.Events.InspectorAgentEnabledForTests,
window.uiTests.testSuiteReady.bind(null, createTestSuite));
}
window.uiTests = new TestSuite(window.domAutomationController);
})(window);
Loading

0 comments on commit 0e854f4

Please sign in to comment.