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

Unified Diff: chrome/test/data/extensions/api_test/instance_id/delete_id/delete_id.js

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android build Created 5 years, 7 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
Index: chrome/test/data/extensions/api_test/instance_id/delete_id/delete_id.js
diff --git a/chrome/test/data/extensions/api_test/instance_id/delete_id/delete_id.js b/chrome/test/data/extensions/api_test/instance_id/delete_id/delete_id.js
new file mode 100644
index 0000000000000000000000000000000000000000..236285c0d2c254e03d4cb82631268fd8e736d907
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/instance_id/delete_id/delete_id.js
@@ -0,0 +1,56 @@
+// Copyright 2015 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.
+
+function deleteIDWithoutCallback() {
+ try {
+ chrome.instanceID.deleteID();
+ chrome.test.fail(
+ "Calling deleteID without callback should fail.");
+ } catch (e) {
+ chrome.test.succeed();
+ };
+}
+
+function deleteIDWithCallback() {
+ chrome.instanceID.deleteID(function() {
+ if (chrome.runtime.lastError) {
+ chrome.test.fail(
+ "chrome.runtime.lastError: " + chrome.runtime.lastError.message);
+ return;
+ }
+
+ chrome.test.succeed();
+ });
+}
+
+var oldID;
+function deleteAfterGetID() {
+ chrome.instanceID.getID(function(id) {
+ if (!id) {
fgorski 2015/05/07 19:59:53 nit: does it make sense to add || chrome.runtime.l
jianli 2015/05/07 20:47:01 Done.
+ chrome.test.fail("ID should not be zero.");
fgorski 2015/05/07 19:59:53 nit: s/zero/empty/
jianli 2015/05/07 20:47:01 Done.
+ return;
+ }
+ oldID = id;
+ chrome.instanceID.deleteID(function(creationTime) {
+ if (chrome.runtime.lastError) {
+ chrome.test.fail(
+ "chrome.runtime.lastError: " + chrome.runtime.lastError.message);
+ return;
+ }
+ chrome.instanceID.getID(function(id) {
+ if (!id || id == oldID) {
+ chrome.test.fail("Different ID should be returned after deleteID.");
+ return;
+ }
+ chrome.test.succeed();
+ });
+ });
+ });
+}
+
+chrome.test.runTests([
+ deleteIDWithoutCallback,
+ deleteIDWithCallback,
+ deleteAfterGetID,
+]);

Powered by Google App Engine
This is Rietveld 408576698