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

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

Issue 1128123003: Implement InstanceID API functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test 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/get_id/get_id.js
diff --git a/chrome/test/data/extensions/api_test/instance_id/get_id/get_id.js b/chrome/test/data/extensions/api_test/instance_id/get_id/get_id.js
new file mode 100644
index 0000000000000000000000000000000000000000..53bd36fd314e901ce09939e513335643887ed3c2
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/instance_id/get_id/get_id.js
@@ -0,0 +1,53 @@
+// 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 getIDWithoutCallback() {
+ try {
+ chrome.instanceID.getID();
+ chrome.test.fail("Calling getID without callback should fail.");
+ } catch (e) {
+ chrome.test.succeed();
+ };
+}
+
+function getIDWithCallback() {
+ chrome.instanceID.getID(function(id) {
+ if (chrome.runtime.lastError) {
+ chrome.test.fail(
+ "chrome.runtime.lastError: " + chrome.runtime.lastError.message);
+ return;
+ }
+ if (id == "") {
+ chrome.test.fail("Empty ID returned.");
+ return;
+ }
+
+ chrome.test.succeed();
+ });
+}
+
+var oldID;
+function getIDTwice() {
+ chrome.instanceID.getID(function(id) {
+ if (!id) {
+ chrome.test.fail("ID should not be zero.");
+ return;
+ }
+ oldID = id;
+
+ chrome.instanceID.getID(function(id) {
+ if (!id || id != oldID) {
+ chrome.test.fail("Same ID should be returned.");
+ return;
+ }
+ chrome.test.succeed();
+ });
+ });
+}
+
+chrome.test.runTests([
+ getIDWithoutCallback,
+ getIDWithCallback,
+ getIDTwice,
+]);

Powered by Google App Engine
This is Rietveld 408576698