Index: chrome/test/data/extensions/api_test/gcm/functions/send.js |
diff --git a/chrome/test/data/extensions/api_test/gcm/functions/send.js b/chrome/test/data/extensions/api_test/gcm/functions/send.js |
deleted file mode 100644 |
index 2ea2c17ff4eaa946914f10c26709220f8ade1a5e..0000000000000000000000000000000000000000 |
--- a/chrome/test/data/extensions/api_test/gcm/functions/send.js |
+++ /dev/null |
@@ -1,137 +0,0 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-onload = function() { |
- function createMessage() { |
- return { |
- messageId: "message-id", |
- destinationId: "destination-id", |
- timeToLive: 2419200, |
- data: { |
- "key1": "value1", |
- "key2": "value" |
- } |
- }; |
- } |
- |
- function successfulSend(message) { |
- chrome.gcm.send(message, function(messageId) { |
- chrome.test.assertEq(message.messageId, messageId); |
- chrome.test.succeed(); |
- }); |
- } |
- |
- function unsuccessfulSend(message) { |
- try { |
- chrome.gcm.send(message, function(messageId) { |
- chrome.test.fail(message); |
- }); |
- } catch(e) { |
- chrome.test.succeed(); |
- } |
- } |
- |
- function scenario(messageMutations, send) { |
- var message = createMessage(); |
- messageMutations.forEach(function(mutation) { |
- mutation(message); |
- }); |
- send(message); |
- } |
- |
- function expectSuccessWhen() { |
- scenario(Array.prototype.slice.call(arguments), successfulSend); |
- } |
- |
- function expectFailureWhen() { |
- scenario(Array.prototype.slice.call(arguments), unsuccessfulSend); |
- } |
- |
- chrome.test.runTests([ |
- function successWhenHappyPath() { |
- expectSuccessWhen(/* no changes to message here */); |
- }, |
- function successWhenTtlIsZero() { |
- expectSuccessWhen(function(message) { message.timeToLive = 0; }); |
- }, |
- function successWhenTtlIsMissing() { |
- expectSuccessWhen(function(message) { delete message.timeToLive; }); |
- }, |
- function failureWhenTtlIsNegative() { |
- expectFailureWhen(function(message) { message.timeToLive = -1; }); |
- }, |
- function failureWhenTtlIsTooLarge() { |
- expectFailureWhen(function(message) { message.timeToLive = 24192001; }); |
- }, |
- function failureWhenMessageIdMissing() { |
- expectFailureWhen(function(message) { delete message.messageId; }); |
- }, |
- function failureWhenMessageIdIsEmpty() { |
- expectFailureWhen(function(message) { message.messageId = ""; }); |
- }, |
- function failureWhenDestinationIdMissing() { |
- expectFailureWhen(function(message) { delete message.destinationId; }); |
- }, |
- function failureWhenDestinationIdIsEmpty() { |
- expectFailureWhen(function(message) { message.destinationId = ""; }); |
- }, |
- function failureWhenDataIsMissing() { |
- expectFailureWhen(function(message) { delete message.data; }); |
- }, |
- function failureWhenDataIsEmpty() { |
- expectFailureWhen(function(message) { message.data = {}; }); |
- }, |
- function failureWhenDataKeyIsEmpty() { |
- expectFailureWhen(function(message) { message.data[""] = "value"; }); |
- }, |
- function successWhenDataKeyHasGoogDotInIt() { |
- expectSuccessWhen(function(message) { |
- message.data["something.goog."] = "value"; |
- }); |
- }, |
- function failureWhenDataKeyIsGoogDot() { |
- expectFailureWhen(function(message) { message.data["goog."] = "value"; }); |
- }, |
- function failureWhenDataKeyIsGoogDotPrefixed() { |
- expectFailureWhen(function(message) { |
- message.data["goog.something"] = "value"; |
- }); |
- }, |
- function successWhenDataKeyHasGoogleInIt() { |
- expectSuccessWhen(function(message) { |
- message.data["somthing.google"] = "value"; |
- }); |
- }, |
- function failureWhenDataKeyIsGoogle() { |
- expectFailureWhen(function(message) { |
- message.data["google"] = "value"; |
- }); |
- }, |
- function failureWhenDataKeyIsGooglePrefixed() { |
- expectFailureWhen(function(message) { |
- message.data["googleSomething"] = "value"; |
- }); |
- }, |
- function failureWhenMessageIsTooLarge() { |
- expectFailureWhen(function(message) { |
- function generateString(base, len) { |
- // Generates a string of size |len| by concatenating |base| multiple |
- // times and trimming to |len|. |
- while (base.length < len) base += base; |
- return base.substring(0, len); |
- } |
- |
- var source = "abcdefghijklmnopqrstuvwxyz"; |
- // Creates 8 * (256 + 256) == 4096 bytes of message data which together |
- // with data put in by default is more than allowed max. |
- var entries = 8; |
- while (entries > 0) { |
- var s = generateString(source + entries, 256); |
- message.data[s] = s; |
- --entries; |
- } |
- }); |
- } |
- ]); |
-}; |