Adrià Vilanova MartÃnez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame^] | 1 | // Copyright 2016 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * @fileoverview Tests for framework-ajax.js. |
| 7 | */ |
| 8 | |
| 9 | var CS_env; |
| 10 | |
| 11 | function setUp() { |
| 12 | CS_env = {'token': 'd34db33f'}; |
| 13 | } |
| 14 | |
| 15 | function testPostData() { |
| 16 | assertEquals( |
| 17 | 'token=d34db33f', |
| 18 | CS_postData({})); |
| 19 | assertEquals( |
| 20 | 'token=d34db33f', |
| 21 | CS_postData({}, true)); |
| 22 | assertEquals( |
| 23 | '', |
| 24 | CS_postData({}, false)); |
| 25 | assertEquals( |
| 26 | 'a=5&b=foo&token=d34db33f', |
| 27 | CS_postData({a: 5, b: 'foo'})); |
| 28 | |
| 29 | let unescaped = {}; |
| 30 | unescaped['f oo?'] = 'b&ar'; |
| 31 | assertEquals( |
| 32 | 'f%20oo%3F=b%26ar', |
| 33 | CS_postData(unescaped, false)); |
| 34 | } |