Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5481)

Unified Diff: chrome/test/data/webui/webui_resource_async_browsertest.js

Issue 1635673003: MD Settings: Add helper method for responding to cr.sendWithPromise. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.cc ('k') | ui/webui/resources/js/cr.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/webui_resource_async_browsertest.js
diff --git a/chrome/test/data/webui/webui_resource_async_browsertest.js b/chrome/test/data/webui/webui_resource_async_browsertest.js
index 24baa25ac0c043f78a83e272d7cae5b9953c6a0e..3c5799811a80703f8e968e2417060e4658ace3b7 100644
--- a/chrome/test/data/webui/webui_resource_async_browsertest.js
+++ b/chrome/test/data/webui/webui_resource_async_browsertest.js
@@ -56,22 +56,39 @@ TEST_F('WebUIResourceAsyncTest', 'SendWithPromise', function() {
setup(function() {
// Simulate a WebUI handler that echoes back all parameters passed to it.
whenChromeSendCalled(CHROME_SEND_NAME).then(function(args) {
- assertEquals('cr.webUIResponse', args[0]);
- var globalCallbackArgs = args.slice(1);
- cr.webUIResponse.apply(null, globalCallbackArgs);
+ cr.webUIResponse.apply(null, args);
});
});
- test('sendWithPromise_MultipleArgs', function() {
- return cr.sendWithPromise(CHROME_SEND_NAME, 'foo', 'bar').then(
+ test('sendWithPromise_ResponseObject', function() {
+ var expectedResponse = {'foo': 'bar'};
+ return cr.sendWithPromise(CHROME_SEND_NAME, expectedResponse).then(
function(response) {
- assertEquals(['foo', 'bar'].join(), response.join());
+ assertEquals(
+ JSON.stringify(expectedResponse), JSON.stringify(response));
});
});
- test('sendWithPromise_NoArgs', function() {
+ test('sendWithPromise_ResponseArray', function() {
+ var expectedResponse = ['foo', 'bar'];
+ return cr.sendWithPromise(CHROME_SEND_NAME, expectedResponse).then(
+ function(response) {
+ assertEquals(
+ JSON.stringify(expectedResponse), JSON.stringify(response));
+ });
+ });
+
+ test('sendWithPromise_ResponsePrimitive', function() {
+ var expectedResponse = 1234;
+ return cr.sendWithPromise(CHROME_SEND_NAME, expectedResponse).then(
+ function(response) {
+ assertEquals(expectedResponse, response);
+ });
+ });
+
+ test('sendWithPromise_ResponseVoid', function() {
return cr.sendWithPromise(CHROME_SEND_NAME).then(function(response) {
- assertEquals([].join(), response.join());
+ assertEquals(undefined, response);
});
});
});
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.cc ('k') | ui/webui/resources/js/cr.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698