Commit 8feec9c6 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions Cleanup] Remove old js-bindings errors branches

Some tests still had handling for either js-bindings or native
bindings.  Since native bindings have been shipped for a long time,
remove the old js bindings errors.

Bug: None
Change-Id: Icd39d40d7be67a17842a2f2242ecc16b43b9be74
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2334991Reviewed-by: default avatarDavid Bertoni <dbertoni@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794365}
parent 5fdca8b6
...@@ -39,15 +39,10 @@ function test() { ...@@ -39,15 +39,10 @@ function test() {
assertRuntimeIsRegistered(); assertRuntimeIsRegistered();
assertStorageIsRegistered(); assertStorageIsRegistered();
var jsBindingsError =
"'storage' requires a different Feature that is not present.";
var nativeBindingsError =
"'storage.get' is not available in this context.";
var regexp = new RegExp(nativeBindingsError + '|' + jsBindingsError);
// Although storage should throw an error on use since it's removed. // Although storage should throw an error on use since it's removed.
chrome.test.assertThrows( chrome.test.assertThrows(
chrome.storage.local.get, chrome.storage.local, [function(){}], chrome.storage.local.get, chrome.storage.local, [function(){}],
regexp); `'storage.get' is not available in this context.`);
chrome.test.succeed(); chrome.test.succeed();
})); }));
......
...@@ -176,13 +176,9 @@ chrome.test.getConfig(function(config) { ...@@ -176,13 +176,9 @@ chrome.test.getConfig(function(config) {
})); }));
assertTrue(typeof chrome.bookmarks == 'object' && assertTrue(typeof chrome.bookmarks == 'object' &&
chrome.bookmarks != null); chrome.bookmarks != null);
var nativeBindingsError = assertThrows(
"'bookmarks.getTree' is not available in this context."; chrome.bookmarks.getTree, [function(){}],
var jsBindingsError = `'bookmarks.getTree' is not available in this context.`);
"'bookmarks' requires a different Feature that is not present.";
var regexp =
new RegExp(nativeBindingsError + '|' + jsBindingsError);
assertThrows(chrome.bookmarks.getTree, [function(){}], regexp);
} }
)); ));
}, },
...@@ -270,12 +266,8 @@ chrome.test.getConfig(function(config) { ...@@ -270,12 +266,8 @@ chrome.test.getConfig(function(config) {
function(permissions) { function(permissions) {
assertTrue(typeof chrome.bookmarks == 'object' && assertTrue(typeof chrome.bookmarks == 'object' &&
chrome.bookmarks != null); chrome.bookmarks != null);
var nativeBindingsError = assertThrows(chrome.bookmarks.getTree, [function(){}],
"'bookmarks.getTree' is not available in this context."; `'bookmarks.getTree' is not available in this context.`);
var jsBindingsError =
"'bookmarks' requires a different Feature that is not present.";
var regexp = new RegExp(nativeBindingsError + '|' + jsBindingsError);
assertThrows(chrome.bookmarks.getTree, [function(){}], regexp);
}); });
chrome.permissions.request( chrome.permissions.request(
......
...@@ -36,10 +36,7 @@ chrome.test.runTests([ ...@@ -36,10 +36,7 @@ chrome.test.runTests([
}, },
function audibleUpdateAttemptShouldFail() { function audibleUpdateAttemptShouldFail() {
var expectedJsBindingsError = var expectedError =
'Invalid value for argument 2. Property \'audible\': ' +
'Unexpected property.';
var expectedNativeBindingsError =
'Error in invocation of tabs.update(' + 'Error in invocation of tabs.update(' +
'optional integer tabId, object updateProperties, ' + 'optional integer tabId, object updateProperties, ' +
'optional function callback): Error at parameter ' + 'optional function callback): Error at parameter ' +
...@@ -50,9 +47,7 @@ chrome.test.runTests([ ...@@ -50,9 +47,7 @@ chrome.test.runTests([
chrome.test.fail('Updated audible property via chrome.tabs.update'); chrome.test.fail('Updated audible property via chrome.tabs.update');
}); });
} catch (e) { } catch (e) {
assertTrue(e.message == expectedJsBindingsError || assertEq(expectedError, e.message);
e.message == expectedNativeBindingsError,
e.message);
chrome.test.succeed(); chrome.test.succeed();
} }
}, },
......
...@@ -183,10 +183,7 @@ chrome.test.runTests([ ...@@ -183,10 +183,7 @@ chrome.test.runTests([
// Make sure we don't crash when the index is out of range. // Make sure we don't crash when the index is out of range.
function moveToInvalidTab() { function moveToInvalidTab() {
var expectedJsBindingsError = var expectedError =
'Invalid value for argument 2. Property \'index\': ' +
'Value must not be less than -1.';
var expectedNativeBindingsError =
'Error in invocation of tabs.move(' + 'Error in invocation of tabs.move(' +
'[integer|array] tabIds, object moveProperties, ' + '[integer|array] tabIds, object moveProperties, ' +
'optional function callback): Error at parameter \'moveProperties\': ' + 'optional function callback): Error at parameter \'moveProperties\': ' +
...@@ -197,8 +194,7 @@ chrome.test.runTests([ ...@@ -197,8 +194,7 @@ chrome.test.runTests([
chrome.test.fail("Moved a tab to an invalid index"); chrome.test.fail("Moved a tab to an invalid index");
}); });
} catch (e) { } catch (e) {
assertTrue(e.message == expectedJsBindingsError || assertEq(expectedError, e.message);
e.message == expectedNativeBindingsError, e.message);
caught = true; caught = true;
} }
assertTrue(caught); assertTrue(caught);
......
...@@ -6,11 +6,9 @@ function check_overflow_check(value) { ...@@ -6,11 +6,9 @@ function check_overflow_check(value) {
try { try {
chrome.windows.create({ "left": value }, function() { }); chrome.windows.create({ "left": value }, function() { });
} catch (e) { } catch (e) {
var jsBindingsError = 'Value must fit in a 32-bit signed integer.'; var expectedError = 'Invalid type: expected integer, found number.';
var nativeBindingsError = 'Invalid type: expected integer, found number.';
chrome.test.assertTrue( chrome.test.assertTrue(
e.message.indexOf(jsBindingsError) != -1 || e.message.indexOf(expectedError) != -1,
e.message.indexOf(nativeBindingsError) != -1,
e.message); e.message);
chrome.test.succeed(); chrome.test.succeed();
return; return;
......
...@@ -45,16 +45,10 @@ chrome.test.sendMessage('loaded', function(test) { ...@@ -45,16 +45,10 @@ chrome.test.sendMessage('loaded', function(test) {
setTimeout(callback.bind(null, 'OK'), 0); setTimeout(callback.bind(null, 'OK'), 0);
break; break;
case 'INVALID_VALUE': case 'INVALID_VALUE':
var jsBindingsError = var expectedError =
'Invalid value for argument 1. ' +
'Value must be one of: ' +
'\\[OK, FAILED, INVALID_TICKET, INVALID_DATA\\].';
var nativeBindingsError =
'Error at parameter \'result\': Value must be one of ' + 'Error at parameter \'result\': Value must be one of ' +
'FAILED, INVALID_DATA, INVALID_TICKET, OK.'; 'FAILED, INVALID_DATA, INVALID_TICKET, OK.';
chrome.test.assertThrows( chrome.test.assertThrows(callback, ['XXX'], expectedError);
callback, ['XXX'],
new RegExp(jsBindingsError + '|' + nativeBindingsError));
break; break;
case 'FAILED': case 'FAILED':
case 'INVALID_TICKET': case 'INVALID_TICKET':
......
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
function eitherError(error1, error2) {
return new RegExp(error1 + '|' + error2);
}
chrome.test.sendMessage('loaded', function(test) { chrome.test.sendMessage('loaded', function(test) {
chrome.test.runTests([function printTest() { chrome.test.runTests([function printTest() {
if (test == 'NO_LISTENER') { if (test == 'NO_LISTENER') {
...@@ -35,18 +31,10 @@ chrome.test.sendMessage('loaded', function(test) { ...@@ -35,18 +31,10 @@ chrome.test.sendMessage('loaded', function(test) {
} }
if (test == 'NOT_ARRAY') { if (test == 'NOT_ARRAY') {
var jsBindingsError = chrome.test.assertThrows(callback, ['XXX'],
'Invalid value for argument 1. ' + 'No matching signature.');
'Expected \'array\' but got \'string\'.'
var nativeBindingsError = 'No matching signature';
chrome.test.assertThrows(
callback, ['XXX'],
eitherError(jsBindingsError, nativeBindingsError));
} else if (test == 'INVALID_PRINTER_TYPE') { } else if (test == 'INVALID_PRINTER_TYPE') {
var jsBindingsError = var expectedError =
'Invalid value for argument 1. ' +
'Property \'.1\': Expected \'object\' but got \'string\'.';
var nativeBindingsError =
'Error at parameter \'printerInfo\': Error at index 1: ' + 'Error at parameter \'printerInfo\': Error at index 1: ' +
'Invalid type: expected printerProvider.PrinterInfo, ' + 'Invalid type: expected printerProvider.PrinterInfo, ' +
'found string.'; 'found string.';
...@@ -57,12 +45,9 @@ chrome.test.sendMessage('loaded', function(test) { ...@@ -57,12 +45,9 @@ chrome.test.sendMessage('loaded', function(test) {
name: 'Printer 1', name: 'Printer 1',
description: 'Test printer' description: 'Test printer'
}, 'printer2']], }, 'printer2']],
eitherError(jsBindingsError, nativeBindingsError)); expectedError);
} else if (test == 'INVALID_PRINTER') { } else if (test == 'INVALID_PRINTER') {
var jsBindingsError = var expectedError =
'Invalid value for argument 1. ' +
'Property \'.0.unsupported\': Unexpected property.';
var nativeBindingsError =
'Error at parameter \'printerInfo\': ' + 'Error at parameter \'printerInfo\': ' +
'Error at index 0: Unexpected property: \'unsupported\'.'; 'Error at index 0: Unexpected property: \'unsupported\'.';
chrome.test.assertThrows( chrome.test.assertThrows(
...@@ -73,7 +58,7 @@ chrome.test.sendMessage('loaded', function(test) { ...@@ -73,7 +58,7 @@ chrome.test.sendMessage('loaded', function(test) {
description: 'Test printer', description: 'Test printer',
unsupported: 'print' unsupported: 'print'
}]], }]],
eitherError(jsBindingsError, nativeBindingsError)); expectedError);
} else { } else {
chrome.test.assertEq('OK', test); chrome.test.assertEq('OK', test);
callback([{ callback([{
......
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