Skip to content

Commit

Permalink
[Extensions Bindings] Update tabs tests to accept new error messages
Browse files Browse the repository at this point in the history
Certain tabs API tests expect errors for passing invalid arguments.
Update the tests to accept the errors from the native bindings system.

BUG=653596
TEST=ExtensionApiTabTest.TabAudible --native-crx-bindings=1,
     ExtensionApiTabTest.TabMove --native-crx-bindings=1

Review-Url: https://codereview.chromium.org/2901403003
Cr-Commit-Position: refs/heads/master@{#474899}
  • Loading branch information
rdcronin authored and Commit bot committed May 26, 2017
1 parent dbe2894 commit 4ff9a59
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
22 changes: 14 additions & 8 deletions chrome/test/data/extensions/api_test/tabs/basics/audible.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,23 @@ chrome.test.runTests([
},

function audibleUpdateAttemptShouldFail() {
var error_msg = "Invalid value for argument 2. Property 'audible': " +
"Unexpected property.";
var expectedJsBindingsError =
'Invalid value for argument 2. Property \'audible\': ' +
'Unexpected property.';
var expectedNativeBindingsError =
'Error in invocation of tabs.update(' +
'optional integer tabId, object updateProperties, ' +
'optional function callback): Error at parameter ' +
'\'updateProperties\': Unexpected property: \'audible\'.';

try
{
try {
chrome.tabs.update(testTabId_, {audible: true}, function(tab) {
chrome.test.fail("Updated audible property via chrome.tabs.update");
chrome.test.fail('Updated audible property via chrome.tabs.update');
});
} catch (e)
{
assertEq(error_msg, e.message);
} catch (e) {
assertTrue(e.message == expectedJsBindingsError ||
e.message == expectedNativeBindingsError,
e.message);
chrome.test.succeed();
}
},
Expand Down
16 changes: 13 additions & 3 deletions chrome/test/data/extensions/api_test/tabs/basics/move.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,25 @@ chrome.test.runTests([

// Make sure we don't crash when the index is out of range.
function moveToInvalidTab() {
var error_msg = "Invalid value for argument 2. Property 'index': " +
"Value must not be less than -1.";
var expectedJsBindingsError =
'Invalid value for argument 2. Property \'index\': ' +
'Value must not be less than -1.';
var expectedNativeBindingsError =
'Error in invocation of tabs.move(' +
'[integer|array] tabIds, object moveProperties, ' +
'optional function callback): Error at parameter \'moveProperties\': ' +
'Error at property \'index\': Value must be at least -1.';
var caught = false;
try {
chrome.tabs.move(moveTabIds['b'], {"index": -2}, function(tab) {
chrome.test.fail("Moved a tab to an invalid index");
});
} catch (e) {
assertEq(error_msg, e.message);
assertTrue(e.message == expectedJsBindingsError ||
e.message == expectedNativeBindingsError, e.message);
caught = true;
}
assertTrue(caught);
chrome.tabs.move(moveTabIds['b'], {"index": 10000}, pass(function(tabB) {
assertEq(2, tabB.index);
}));
Expand Down

0 comments on commit 4ff9a59

Please sign in to comment.