OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function createMessage() { | 5 function createMessage() { |
6 return { | 6 return { |
7 messageId: "message-id", | 7 messageId: "message-id", |
8 destinationId: "destination-id", | 8 destinationId: "destination-id", |
9 timeToLive: 2419200, | 9 timeToLive: 2419200, |
10 data: { | 10 data: { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 }); | 90 }); |
91 }, | 91 }, |
92 function failureWhenDataKeyIsGoogDot() { | 92 function failureWhenDataKeyIsGoogDot() { |
93 expectFailureWhen(function(message) { message.data["goog."] = "value"; }); | 93 expectFailureWhen(function(message) { message.data["goog."] = "value"; }); |
94 }, | 94 }, |
95 function failureWhenDataKeyIsGoogDotPrefixed() { | 95 function failureWhenDataKeyIsGoogDotPrefixed() { |
96 expectFailureWhen(function(message) { | 96 expectFailureWhen(function(message) { |
97 message.data["goog.something"] = "value"; | 97 message.data["goog.something"] = "value"; |
98 }); | 98 }); |
99 }, | 99 }, |
| 100 function failureWhenDataKeyIsGoogDotMixedCasedPrefixed() { |
| 101 expectFailureWhen(function(message) { |
| 102 message.data["GoOg.something"] = "value"; |
| 103 }); |
| 104 }, |
100 function successWhenDataKeyHasGoogleInIt() { | 105 function successWhenDataKeyHasGoogleInIt() { |
101 expectSuccessWhen(function(message) { | 106 expectSuccessWhen(function(message) { |
102 message.data["somthing.google"] = "value"; | 107 message.data["somthing.google"] = "value"; |
103 }); | 108 }); |
104 }, | 109 }, |
105 function failureWhenDataKeyIsGoogle() { | 110 function failureWhenDataKeyIsGoogle() { |
106 expectFailureWhen(function(message) { | 111 expectFailureWhen(function(message) { |
107 message.data["google"] = "value"; | 112 message.data["google"] = "value"; |
108 }); | 113 }); |
109 }, | 114 }, |
| 115 function failureWhenDataKeyIsMixedCasedGoogle() { |
| 116 expectFailureWhen(function(message) { |
| 117 message.data["GoOgLe"] = "value"; |
| 118 }); |
| 119 }, |
110 function failureWhenDataKeyIsGooglePrefixed() { | 120 function failureWhenDataKeyIsGooglePrefixed() { |
111 expectFailureWhen(function(message) { | 121 expectFailureWhen(function(message) { |
112 message.data["googleSomething"] = "value"; | 122 message.data["googleSomething"] = "value"; |
113 }); | 123 }); |
114 }, | 124 }, |
| 125 function failureWhenDataKeyIsCollapeKey() { |
| 126 expectFailureWhen(function(message) { |
| 127 message.data["collapse_key"] = "value"; |
| 128 }); |
| 129 }, |
115 function failureWhenMessageIsTooLarge() { | 130 function failureWhenMessageIsTooLarge() { |
116 expectFailureWhen(function(message) { | 131 expectFailureWhen(function(message) { |
117 function generateString(base, len) { | 132 function generateString(base, len) { |
118 // Generates a string of size |len| by concatenating |base| multiple | 133 // Generates a string of size |len| by concatenating |base| multiple |
119 // times and trimming to |len|. | 134 // times and trimming to |len|. |
120 while (base.length < len) base += base; | 135 while (base.length < len) base += base; |
121 return base.substring(0, len); | 136 return base.substring(0, len); |
122 } | 137 } |
123 | 138 |
124 var source = "abcdefghijklmnopqrstuvwxyz"; | 139 var source = "abcdefghijklmnopqrstuvwxyz"; |
125 // Creates 8 * (256 + 256) == 4096 bytes of message data which together | 140 // Creates 8 * (256 + 256) == 4096 bytes of message data which together |
126 // with data put in by default is more than allowed max. | 141 // with data put in by default is more than allowed max. |
127 var entries = 8; | 142 var entries = 8; |
128 while (entries > 0) { | 143 while (entries > 0) { |
129 var s = generateString(source + entries, 256); | 144 var s = generateString(source + entries, 256); |
130 message.data[s] = s; | 145 message.data[s] = s; |
131 --entries; | 146 --entries; |
132 } | 147 } |
133 }); | 148 }); |
134 } | 149 } |
135 ]); | 150 ]); |
OLD | NEW |