Commit 75ba7ff2 authored by Tim van der Lippe's avatar Tim van der Lippe Committed by Commit Bot

Fix DevTools strict mode issues

We will soon make the TestRunner run DevTools run in strict mode [1].
Some tests started failing as they were relying on sloppy mode behavior.

Fix these tests by running in strict mode. The tests are manually
verified passing with the updated TestRunner behavior.

[1]: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/1953583

Bug: 1006759
Change-Id: Ib0fdc9c044987c797929999b056cde9800142f79
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1958116
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: default avatarMathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722996}
parent 7f5c4946
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Test that each agent could be enabled/disabled separately.\n`); TestRunner.addResult(`Test that each agent could be enabled/disabled separately.\n`);
function printResult(agentName, action, errorString) { function printResult(agentName, action, errorString) {
...@@ -14,38 +15,37 @@ ...@@ -14,38 +15,37 @@
TestRunner.addResult(agentName + '.' + action + ' finished successfully'); TestRunner.addResult(agentName + '.' + action + ' finished successfully');
} }
var targets = SDK.targetManager.targets(); const targets = SDK.targetManager.targets();
for (var target of targets) { for (const target of targets) {
var agentNames = Object.keys(target._agents) const agentNames =
.filter(function(agentName) { Object.keys(target._agents)
var agent = target._agents[agentName]; .filter(function(agentName) {
return agent['enable'] && agent['disable'] const agent = target._agents[agentName];
&& agentName !== 'ServiceWorker' return agent['enable'] && agent['disable'] &&
&& agentName !== 'Security' agentName !== 'ServiceWorker' && agentName !== 'Security' &&
&& agentName !== 'Inspector' agentName !== 'Inspector' &&
&& agentName !== 'HeadlessExperimental' agentName !== 'HeadlessExperimental' &&
&& agentName !== 'Fetch' agentName !== 'Fetch' && agentName !== 'Cast' &&
&& agentName !== 'Cast' agentName !== 'BackgroundService';
&& agentName !== 'BackgroundService'; })
}) .sort();
.sort();
async function disableAgent(agentName) { async function disableAgent(agentName) {
var agent = target._agents[agentName]; const agent = target._agents[agentName];
var response = await agent.invoke_disable({}); const response = await agent.invoke_disable({});
printResult(agentName, 'disable', response[Protocol.Error]); printResult(agentName, 'disable', response[Protocol.Error]);
} }
async function enableAgent(agentName) { async function enableAgent(agentName) {
var agent = target._agents[agentName]; const agent = target._agents[agentName];
var response = await agent.invoke_enable({}); const response = await agent.invoke_enable({});
printResult(agentName, 'enable', response[Protocol.Error]); printResult(agentName, 'enable', response[Protocol.Error]);
} }
for (agentName of agentNames) for (const agentName of agentNames)
await disableAgent(agentName); await disableAgent(agentName);
for (agentName of agentNames) { for (const agentName of agentNames) {
await enableAgent(agentName); await enableAgent(agentName);
await disableAgent(agentName); await disableAgent(agentName);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`This test checks Web Inspector utilities.\n`); TestRunner.addResult(`This test checks Web Inspector utilities.\n`);
...@@ -40,8 +41,9 @@ ...@@ -40,8 +41,9 @@
var allValues = a.concat(b).concat(actual); var allValues = a.concat(b).concat(actual);
for (var i = 0; i < allValues.length; ++i) { for (var i = 0; i < allValues.length; ++i) {
var value = allValues[i]; var value = allValues[i];
expectedCount = checkOperation(count(a, value), count(b, value)); const expectedCount =
actualCount = count(actual, value); checkOperation(count(a, value), count(b, value));
const actualCount = count(actual, value);
TestRunner.assertEquals( TestRunner.assertEquals(
expectedCount, actualCount, expectedCount, actualCount,
'Incorrect result for value: ' + value + ' at [' + a + '] ' + opName + ' [' + b + '] -> [' + actual + 'Incorrect result for value: ' + value + ' at [' + a + '] ' + opName + ' [' + b + '] -> [' + actual +
...@@ -155,7 +157,7 @@ ...@@ -155,7 +157,7 @@
compareArrays( compareArrays(
middle.slice(first - left, first - left + count), actual.slice(first, first + count), middle.slice(first - left, first - left + count), actual.slice(first, first + count),
'sorted ' + left + ' ' + right + ' ' + first + ' ' + count); 'sorted ' + left + ' ' + right + ' ' + first + ' ' + count);
actualRest = actual.slice(first + count, right + 1); const actualRest = actual.slice(first + count, right + 1);
actualRest.sort(comparator); actualRest.sort(comparator);
compareArrays( compareArrays(
middle.slice(first - left + count), actualRest, middle.slice(first - left + count), actualRest,
......
...@@ -2,7 +2,7 @@ Tests that evaluating 'console.log()' in the console will have access to its out ...@@ -2,7 +2,7 @@ Tests that evaluating 'console.log()' in the console will have access to its out
Running: testSnippet1 Running: testSnippet1
console-eval-scoped.js:67 with: Object property value console-eval-scoped.js:69 with: Object property value
VM:1 eval in with: Object property value VM:1 eval in with: Object property value
Running: testSnippet2 Running: testSnippet2
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Tests that evaluating 'console.log()' in the console will have access to its outer scope variables. Bug 60547.\n` `Tests that evaluating 'console.log()' in the console will have access to its outer scope variables. Bug 60547.\n`
); );
...@@ -32,14 +33,14 @@ ...@@ -32,14 +33,14 @@
}; };
`); `);
function snippet1() { // Use `new Function` as with-statements are not allowed in strict-mode
(function(obj) { const snippet1 = new Function(`
with (obj) { (function(obj) {
console.log('with: ' + a); with (obj) {
eval("console.log('eval in with: ' + a)"); console.log('with: ' + a);
} eval("console.log('eval in with: ' + a)");
})({ a: 'Object property value' });
} }
})({ a: 'Object property value' });`);
function snippet2() { function snippet2() {
(function(a) { (function(a) {
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
}, },
function beforeFilter(next) { function beforeFilter(next) {
TestRunner.addResult(arguments.callee.name); TestRunner.addResult('beforeFilter');
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
......
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
TestRunner.runTestSuite([ TestRunner.runTestSuite([
function beforeFilter(next) { function beforeFilter(next) {
TestRunner.addResult(arguments.callee.name); TestRunner.addResult('beforeFilter');
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
...@@ -109,50 +109,43 @@ ...@@ -109,50 +109,43 @@
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkMultiTextFilter(next) function checkMultiTextFilter(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("Group /[2-3]top/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("Group /[2-3]top/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkTextUrlFilter(next) function checkTextUrlFilter(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("url:log-source"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("url:log-source");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkNegativeTextUrlFilter(next) function checkNegativeTextUrlFilter(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("-url:log-source"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("-url:log-source");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkSourceFilter(next) function checkSourceFilter(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("source:violation"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("source:violation");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkContextTextFilter(next) function checkContextTextFilter(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("context:context"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("context:context");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkStartEndLineRegex(next) function checkStartEndLineRegex(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^Hello\\s\\d$/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^Hello\\s\\d$/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
next(); next();
}, },
function checkStartEndLineRegexForAnchor(next) function checkStartEndLineRegexForAnchor(next) {
{
Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^log-source\\.js:\\d+$/"); Console.ConsoleView.instance()._filter._textFilterUI.setValue("/^log-source\\.js:\\d+$/");
Console.ConsoleView.instance()._filter._onFilterChanged(); Console.ConsoleView.instance()._filter._onFilterChanged();
dumpVisibleMessages(); dumpVisibleMessages();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests curl command generation\n`); TestRunner.addResult(`Tests curl command generation\n`);
await TestRunner.loadModule('network_test_runner'); await TestRunner.loadModule('network_test_runner');
await TestRunner.showPanel('network'); await TestRunner.showPanel('network');
...@@ -54,8 +55,11 @@ ...@@ -54,8 +55,11 @@
await dumpRequest({}, '123'); await dumpRequest({}, '123');
await dumpRequest({'Content-Type': 'application/x-www-form-urlencoded'}, '1&b'); await dumpRequest({'Content-Type': 'application/x-www-form-urlencoded'}, '1&b');
await dumpRequest({'Content-Type': 'application/json'}, '{"a":1}'); await dumpRequest({'Content-Type': 'application/json'}, '{"a":1}');
await dumpRequest({'Content-Type': 'application/binary'}, '1234\r\n\x30\x30\2\3\4\5\'"!'); await dumpRequest(
await dumpRequest({'Content-Type': 'application/binary'}, '1234\r\n\1\x30\x30\2\3\4\5\'"!'); {'Content-Type': 'application/binary'}, '1234\r\n00\x02\x03\x04\x05\'"!');
await dumpRequest(
{'Content-Type': 'application/binary'},
'1234\r\n\x0100\x02\x03\x04\x05\'"!');
await dumpRequest( await dumpRequest(
{'Content-Type': 'application/binary'}, {'Content-Type': 'application/binary'},
'%OS%\r\n%%OS%%\r\n"\\"\'$&!'); // Ensure %OS% for windows is not env evaled '%OS%\r\n%%OS%%\r\n"\\"\'$&!'); // Ensure %OS% for windows is not env evaled
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests the gutter decorations in target source code after ScriptFormatterEditorAction\n`); TestRunner.addResult(`Tests the gutter decorations in target source code after ScriptFormatterEditorAction\n`);
await TestRunner.loadModule('coverage_test_runner'); await TestRunner.loadModule('coverage_test_runner');
await TestRunner.loadHTML(` await TestRunner.loadHTML(`
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
var decoratorPromise = TestRunner.addSnifferPromise(Coverage.CoverageView.LineDecorator.prototype, '_innerDecorate'); var decoratorPromise = TestRunner.addSnifferPromise(Coverage.CoverageView.LineDecorator.prototype, '_innerDecorate');
var editorActions = await self.runtime.allInstances(Sources.SourcesView.EditorAction); var editorActions = await self.runtime.allInstances(Sources.SourcesView.EditorAction);
for (action of editorActions) { for (const action of editorActions) {
if (action instanceof Sources.ScriptFormatterEditorAction) { if (action instanceof Sources.ScriptFormatterEditorAction) {
action._toggleFormatScriptSource(); action._toggleFormatScriptSource();
break; break;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests that Elements properly populate and select after immediate updates crbug.com/829884\n`); TestRunner.addResult(`Tests that Elements properly populate and select after immediate updates crbug.com/829884\n`);
await TestRunner.loadModule('elements_test_runner'); await TestRunner.loadModule('elements_test_runner');
await TestRunner.showPanel('elements'); await TestRunner.showPanel('elements');
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
function afterExpand() { function afterExpand() {
ElementsTestRunner.selectNodeWithId('body', node => { ElementsTestRunner.selectNodeWithId('body', node => {
treeElement = node[treeOutline.treeElementSymbol()]; const treeElement = node[treeOutline.treeElementSymbol()];
TestRunner.addResult(`AFTER EXPAND: TreeElement childCount: ${treeElement.childCount()}`); TestRunner.addResult(`AFTER EXPAND: TreeElement childCount: ${treeElement.childCount()}`);
var selectedElement = treeOutline.selectedTreeElement; var selectedElement = treeOutline.selectedTreeElement;
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
function findStyleSheet() { function findStyleSheet() {
var styleSheetHeaders = TestRunner.cssModel.styleSheetHeaders(); var styleSheetHeaders = TestRunner.cssModel.styleSheetHeaders();
for (var i = 0; i < styleSheetHeaders.length; ++i) { for (var i = 0; i < styleSheetHeaders.length; ++i) {
styleSheetHeader = styleSheetHeaders[i]; const styleSheetHeader = styleSheetHeaders[i];
if (styleSheetHeader.sourceURL.indexOf('get-set-stylesheet-text.css') >= 0) { if (styleSheetHeader.sourceURL.indexOf('get-set-stylesheet-text.css') >= 0) {
foundStyleSheetHeader = styleSheetHeader; foundStyleSheetHeader = styleSheetHeader;
foundStyleSheetHeader.requestContent().then(callback); foundStyleSheetHeader.requestContent().then(callback);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
await ElementsTestRunner.selectNodeAndWaitForStylesPromise('inspected'); await ElementsTestRunner.selectNodeAndWaitForStylesPromise('inspected');
var section = ElementsTestRunner.inlineStyleSection(); var section = ElementsTestRunner.inlineStyleSection();
treeElement = section.addNewBlankProperty(0); const treeElement = section.addNewBlankProperty(0);
treeElement.startEditing(); treeElement.startEditing();
await TestRunner.addSnifferPromise(UI.TextPrompt.prototype, '_completionsReady'); await TestRunner.addSnifferPromise(UI.TextPrompt.prototype, '_completionsReady');
......
...@@ -3,11 +3,13 @@ ...@@ -3,11 +3,13 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Ensure transactions created within Promise callbacks are not deactivated due to console activity\n`); `Ensure transactions created within Promise callbacks are not deactivated due to console activity\n`);
await TestRunner.loadModule('console_test_runner'); await TestRunner.loadModule('console_test_runner');
await TestRunner.loadModule('application_test_runner'); await TestRunner.loadModule('application_test_runner');
// Note: every test that uses a storage API must manually clean-up state from previous tests. // Note: every test that uses a storage API must manually clean-up state from
// previous tests.
await ApplicationTestRunner.resetState(); await ApplicationTestRunner.resetState();
var dbname = location.href; var dbname = location.href;
...@@ -20,7 +22,7 @@ ...@@ -20,7 +22,7 @@
openRequest.onsuccess = function(event) { openRequest.onsuccess = function(event) {
var db = event.target.result; var db = event.target.result;
Promise.resolve().then(function() { Promise.resolve().then(function() {
tx = db.transaction('store'); const tx = db.transaction('store');
ConsoleTestRunner.evaluateInConsole('1 + 2'); ConsoleTestRunner.evaluateInConsole('1 + 2');
try { try {
tx.objectStore('store').get(0); tx.objectStore('store').get(0);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
TestRunner.showPanel('layers'); TestRunner.showPanel('layers');
await LayersTestRunner.requestLayers(); await LayersTestRunner.requestLayers();
var layer = LayersTestRunner.findLayerByNodeIdAttribute('layer'); var layer = LayersTestRunner.findLayerByNodeIdAttribute('layer');
initialQuads = layer.quad().toString(); const initialQuads = layer.quad().toString();
// Updating layers should not produce invalid layer to-screen transforms // Updating layers should not produce invalid layer to-screen transforms
// (see: https://crbug.com/977578). Backface visibility is changed, rather // (see: https://crbug.com/977578). Backface visibility is changed, rather
......
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
TestRunner.completeTest(); TestRunner.completeTest();
function initLayers() { function initLayers() {
layerA = LayersTestRunner.findLayerByNodeIdAttribute('a'); const layerA = LayersTestRunner.findLayerByNodeIdAttribute('a');
layerB = LayersTestRunner.findLayerByNodeIdAttribute('b'); const layerB = LayersTestRunner.findLayerByNodeIdAttribute('b');
contentRoot = LayersTestRunner.layerTreeModel().layerTree().contentRoot(); contentRoot = LayersTestRunner.layerTreeModel().layerTree().contentRoot();
layers = [ layers = [
{layer: layerA, name: 'layer a'}, {layer: layerB, name: 'layer b'}, {layer: contentRoot, name: 'content root'} {layer: layerA, name: 'layer a'}, {layer: layerB, name: 'layer b'}, {layer: contentRoot, name: 'content root'}
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Tests that modifying a rule in a stylesheet loaded from a different domain does not crash the renderer.\n`); `Tests that modifying a rule in a stylesheet loaded from a different domain does not crash the renderer.\n`);
await TestRunner.loadModule('elements_test_runner'); await TestRunner.loadModule('elements_test_runner');
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
function selectCallback() { function selectCallback() {
var idToDOMNode = TestRunner.domModel._idToDOMNode; var idToDOMNode = TestRunner.domModel._idToDOMNode;
for (var id in idToDOMNode) { for (var id in idToDOMNode) {
node = idToDOMNode[id]; const node = idToDOMNode[id];
if (node.getAttribute && node.getAttribute('id') === 'inspected') { if (node.getAttribute && node.getAttribute('id') === 'inspected') {
nodeId = parseInt(id, 10); nodeId = parseInt(id, 10);
break; break;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests to make sure the proper view is used for the data that is received in network panel.\n`); TestRunner.addResult(`Tests to make sure the proper view is used for the data that is received in network panel.\n`);
await TestRunner.loadModule('network_test_runner'); await TestRunner.loadModule('network_test_runner');
await TestRunner.showPanel('network'); await TestRunner.showPanel('network');
...@@ -78,7 +79,7 @@ ...@@ -78,7 +79,7 @@
await testPreviewer('text/foobar', 'Foo Bar', 500); await testPreviewer('text/foobar', 'Foo Bar', 500);
TestRunner.addResult('Binary Image File'); TestRunner.addResult('Binary Image File');
await testPreviewer('image/png', 'Bin\0ary\1 File\0\0', 200); await testPreviewer('image/png', 'Bin\0ary\x01 File\0\0', 200);
TestRunner.addResult('Binary Blank Image File'); TestRunner.addResult('Binary Blank Image File');
await testPreviewer('image/png', '', 200); await testPreviewer('image/png', '', 200);
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests content is available for failed image request.\n`); TestRunner.addResult(`Tests content is available for failed image request.\n`);
await TestRunner.loadModule('network_test_runner'); await TestRunner.loadModule('network_test_runner');
await TestRunner.loadModule('console_test_runner'); await TestRunner.loadModule('console_test_runner');
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
await TestRunner.evaluateInPagePromise(` await TestRunner.evaluateInPagePromise(`
function loadData() function loadData()
{ {
var image = new Image(); const image = new Image();
image.src = "resources/404.php"; image.src = "resources/404.php";
image.onerror = resourceLoaded; image.onerror = resourceLoaded;
} }
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
TestRunner.evaluateInPage('loadData()'); TestRunner.evaluateInPage('loadData()');
function step2() { function step2() {
var request1 = NetworkTestRunner.networkRequests().pop(); const request1 = NetworkTestRunner.networkRequests().pop();
TestRunner.addResult(request1.url()); TestRunner.addResult(request1.url());
TestRunner.addResult('resource.type: ' + request1.resourceType()); TestRunner.addResult('resource.type: ' + request1.resourceType());
TestRunner.assertTrue(!request1.failed, 'Resource loading failed.'); TestRunner.assertTrue(!request1.failed, 'Resource loading failed.');
...@@ -34,14 +35,14 @@ ...@@ -34,14 +35,14 @@
} }
async function step3() { async function step3() {
var requests = NetworkTestRunner.networkRequests(); const requests = NetworkTestRunner.networkRequests();
requests.sort(function(a, b) { requests.sort(function(a, b) {
return a.url().localeCompare(b.url()); return a.url().localeCompare(b.url());
}); });
TestRunner.addResult('resources count = ' + requests.length); TestRunner.addResult('resources count = ' + requests.length);
for (i = 0; i < requests.length; i++) { for (let i = 0; i < requests.length; i++) {
TestRunner.addResult(requests[i].url()); TestRunner.addResult(requests[i].url());
var { content, error, isEncoded } = await requests[i].requestContent(); const {content} = await requests[i].requestContent();
TestRunner.addResult('resource.content after requesting content: ' + content); TestRunner.addResult('resource.content after requesting content: ' + content);
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Tests how revision requests content if original content was not loaded yet. https://bugs.webkit.org/show_bug.cgi?id=63631\n`); `Tests how revision requests content if original content was not loaded yet. https://bugs.webkit.org/show_bug.cgi?id=63631\n`);
await TestRunner.loadModule('network_test_runner'); await TestRunner.loadModule('network_test_runner');
...@@ -22,7 +23,8 @@ ...@@ -22,7 +23,8 @@
Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, step2); Workspace.workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeAdded, step2);
TestRunner.evaluateInPage('loadStylesheet()'); TestRunner.evaluateInPage('loadStylesheet()');
var resource; let uiSourceCode;
function step2(event) { function step2(event) {
var eventUISourceCode = event.data; var eventUISourceCode = event.data;
if (eventUISourceCode.url().indexOf('style.css') == -1) if (eventUISourceCode.url().indexOf('style.css') == -1)
...@@ -35,7 +37,7 @@ ...@@ -35,7 +37,7 @@
uiSourceCode.requestContent().then(step3); uiSourceCode.requestContent().then(step3);
} }
function step3({ content, error, isEncoded }) { function step3({content}) {
TestRunner.addResult(uiSourceCode.url()); TestRunner.addResult(uiSourceCode.url());
TestRunner.addResult(content); TestRunner.addResult(content);
TestRunner.completeTest(); TestRunner.completeTest();
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Verify that tabs get merged when binding is added and removed.\n`); TestRunner.addResult(`Verify that tabs get merged when binding is added and removed.\n`);
await TestRunner.loadModule('sources_test_runner'); await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('bindings_test_runner'); await TestRunner.loadModule('bindings_test_runner');
...@@ -80,7 +81,7 @@ ...@@ -80,7 +81,7 @@
var openedUISourceCodes = editorContainer._tabIds.keysArray(); var openedUISourceCodes = editorContainer._tabIds.keysArray();
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url())); openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
TestRunner.addResult('Opened tabs: '); TestRunner.addResult('Opened tabs: ');
for (code of openedUISourceCodes) for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url()); TestRunner.addResult(' ' + code.url());
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Verify that a network file tab gets substituted with filesystem tab when persistence binding comes.\n`); `Verify that a network file tab gets substituted with filesystem tab when persistence binding comes.\n`);
await TestRunner.loadModule('sources_test_runner'); await TestRunner.loadModule('sources_test_runner');
...@@ -42,7 +43,7 @@ ...@@ -42,7 +43,7 @@
var openedUISourceCodes = editorContainer._tabIds.keysArray(); var openedUISourceCodes = editorContainer._tabIds.keysArray();
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url())); openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
TestRunner.addResult('Opened tabs: '); TestRunner.addResult('Opened tabs: ');
for (code of openedUISourceCodes) for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url()); TestRunner.addResult(' ' + code.url());
} }
})(); })();
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Verify that for a fileSystem UISourceCode with persistence binding TabbedEditorContainer opens filesystem UISourceCode.\n`); `Verify that for a fileSystem UISourceCode with persistence binding TabbedEditorContainer opens filesystem UISourceCode.\n`);
await TestRunner.loadModule('sources_test_runner'); await TestRunner.loadModule('sources_test_runner');
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
var openedUISourceCodes = editorContainer._tabIds.keysArray(); var openedUISourceCodes = editorContainer._tabIds.keysArray();
openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url())); openedUISourceCodes.sort((a, b) => a.url().compareTo(b.url()));
TestRunner.addResult(title); TestRunner.addResult(title);
for (code of openedUISourceCodes) for (const code of openedUISourceCodes)
TestRunner.addResult(' ' + code.url()); TestRunner.addResult(' ' + code.url());
} }
})(); })();
...@@ -13,23 +13,24 @@ ...@@ -13,23 +13,24 @@
} }
`); `);
MockedFile = function() { class MockedFile {
this._buffer = ''; constructor() {
}; this._buffer = '';
MockedFile.prototype = { }
_appendData: function(data) {
_appendData(data) {
this._buffer += data; this._buffer += data;
}, }
_data: function() { _data() {
return this._buffer; return this._buffer;
}, }
get size() { get size() {
return this._buffer.length; return this._buffer.length;
}, }
slice: function(chunkStart, chunkEnd) { slice(chunkStart, chunkEnd) {
var blob = new Blob([this._buffer], {type: 'text\/text'}); var blob = new Blob([this._buffer], {type: 'text\/text'});
return blob; return blob;
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests Statistics view of detailed heap snapshots.\n`); TestRunner.addResult(`Tests Statistics view of detailed heap snapshots.\n`);
await TestRunner.loadModule('heap_profiler_test_runner'); await TestRunner.loadModule('heap_profiler_test_runner');
await TestRunner.showPanel('heap_profiler'); await TestRunner.showPanel('heap_profiler');
...@@ -10,7 +11,7 @@ ...@@ -10,7 +11,7 @@
function createHeapSnapshot() { function createHeapSnapshot() {
var builder = new HeapProfilerTestRunner.HeapSnapshotBuilder(); var builder = new HeapProfilerTestRunner.HeapSnapshotBuilder();
var index = 0; var index = 0;
for (type in HeapProfilerTestRunner.HeapNode.Type) { for (let type in HeapProfilerTestRunner.HeapNode.Type) {
if (!HeapProfilerTestRunner.HeapNode.Type.hasOwnProperty(type)) if (!HeapProfilerTestRunner.HeapNode.Type.hasOwnProperty(type))
continue; continue;
if (type === HeapProfilerTestRunner.HeapNode.Type.synthetic) if (type === HeapProfilerTestRunner.HeapNode.Type.synthetic)
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests the nondeterministic bits of HAR conversion via the magic of hard-coded values.\n`); TestRunner.addResult(`Tests the nondeterministic bits of HAR conversion via the magic of hard-coded values.\n`);
await TestRunner.loadModule('application_test_runner'); await TestRunner.loadModule('application_test_runner');
await TestRunner.loadModule('network_test_runner'); await TestRunner.loadModule('network_test_runner');
...@@ -18,7 +19,6 @@ ...@@ -18,7 +19,6 @@
request.responseHeaders = [{name: 'Response', value: 'response-value'}]; request.responseHeaders = [{name: 'Response', value: 'response-value'}];
request.responseHeadersText = 'HTTP/1.1 200 OK\r\nResponse: headers-text'; request.responseHeadersText = 'HTTP/1.1 200 OK\r\nResponse: headers-text';
request.documentURL = 'http://example.com/inspector-test.js';
request.requestMethod = 'GET'; request.requestMethod = 'GET';
request.mimeType = 'text/html'; request.mimeType = 'text/html';
request.statusCode = 200; request.statusCode = 200;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult(`Tests scripts sorting in the scripts panel.\n`); TestRunner.addResult(`Tests scripts sorting in the scripts panel.\n`);
await TestRunner.loadModule('sources_test_runner'); await TestRunner.loadModule('sources_test_runner');
await TestRunner.loadModule('sdk_test_runner'); await TestRunner.loadModule('sdk_test_runner');
...@@ -14,8 +15,10 @@ ...@@ -14,8 +15,10 @@
return navigatorView; return navigatorView;
} }
sourcesNavigatorView = createNavigatorView(Sources.NetworkNavigatorView); const sourcesNavigatorView =
contentScriptsNavigatorView = createNavigatorView(Sources.ContentScriptsNavigatorView); createNavigatorView(Sources.NetworkNavigatorView);
const contentScriptsNavigatorView =
createNavigatorView(Sources.ContentScriptsNavigatorView);
var pageMock = new SDKTestRunner.PageMock('http://example.com'); var pageMock = new SDKTestRunner.PageMock('http://example.com');
pageMock.turnIntoWorker(); pageMock.turnIntoWorker();
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
'x', 'y.foo' 'x', 'y.foo'
]); ]);
await SourcesTestRunner.startDebuggerTestPromise(); await SourcesTestRunner.startDebuggerTestPromise();
watchExpressionsPane =
self.runtime.sharedInstance(Sources.WatchExpressionsSidebarPane);
UI.panels.sources._sidebarPaneStack.showView( UI.panels.sources._sidebarPaneStack.showView(
UI.panels.sources._watchSidebarPane); UI.panels.sources._watchSidebarPane);
TestRunner.addResult('Watches before running testFunction:'); TestRunner.addResult('Watches before running testFunction:');
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
(async function() { (async function() {
'use strict';
TestRunner.addResult( TestRunner.addResult(
`Tests breakpoints are correctly dimmed and restored in JavaScriptSourceFrame during live edit.\n`); `Tests breakpoints are correctly dimmed and restored in JavaScriptSourceFrame during live edit.\n`);
await TestRunner.loadModule('sources_test_runner'); await TestRunner.loadModule('sources_test_runner');
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
' ' + pathToFileName(breakpoints[i].url) + ':' + breakpoints[i].lineNumber + ' ' + pathToFileName(breakpoints[i].url) + ':' + breakpoints[i].lineNumber +
', enabled:' + breakpoints[i].enabled); ', enabled:' + breakpoints[i].enabled);
locations = breakpointManager.allBreakpointLocations(); const locations = breakpointManager.allBreakpointLocations();
TestRunner.addResult(' Dumping breakpoint locations'); TestRunner.addResult(' Dumping breakpoint locations');
for (var i = 0; i < locations.length; ++i) { for (var i = 0; i < locations.length; ++i) {
var uiLocation = locations[i].uiLocation; var uiLocation = locations[i].uiLocation;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment