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

Unified Diff: chrome/test/data/pdf/bookmarks_test.js

Issue 840493002: Introduce new test for bookmark loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks-minimal
Patch Set: Created 5 years, 11 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/pdf/bookmarks_test.js
diff --git a/chrome/test/data/pdf/bookmarks_test.js b/chrome/test/data/pdf/bookmarks_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..f242b8db1dd7f8658d6fff3d20b246eba56acdf9
--- /dev/null
+++ b/chrome/test/data/pdf/bookmarks_test.js
@@ -0,0 +1,64 @@
+// 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.
+
+var tests = [
+
+ /**
+ * Test that the correct bookmarks were loaded for the basic pdf
+ */
+ function testHasCorrectBookmarks() {
+ var bookmarks = viewer.bookmarks;
+
+ // Loading all relevant bookmarks
+
raymes 2015/01/06 05:52:29 nit: here and below, remove a bunch of blink lines
Alexandre Carlton 2015/01/15 05:01:42 Done.
+ chrome.test.assertEq(2, bookmarks.length);
+ var firstBookmark = bookmarks[0];
+ var secondBookmark = bookmarks[1];
+
+ chrome.test.assertTrue(firstBookmark.hasOwnProperty('children'));
raymes 2015/01/06 05:52:29 you can probably get rid of all the hasOwnProperty
Alexandre Carlton 2015/01/15 05:01:42 Done.
+ chrome.test.assertEq(1, firstBookmark.children.length);
+ chrome.test.assertTrue(secondBookmark.hasOwnProperty('children'));
+ chrome.test.assertEq(0, secondBookmark.children.length);
+
+ var firstNestedBookmark = firstBookmark.children[0];
+
+ // Checking titles
+ // An irregular amount of '\u0000' are trailing the titles, hence the strip.
+
+ chrome.test.assertTrue(firstBookmark.hasOwnProperty('title'));
+ chrome.test.assertEq('First Section',
+ firstBookmark.title.replace(/\u0000+$/, ''));
+
+ chrome.test.assertTrue(firstNestedBookmark.hasOwnProperty('title'));
+ chrome.test.assertEq('First Subsection',
+ firstNestedBookmark.title.replace(/\u0000+$/, ''));
+
+ chrome.test.assertTrue(secondBookmark.hasOwnProperty('title'));
+ chrome.test.assertEq('Second Section',
+ secondBookmark.title.replace(/\u0000+$/, ''));
+
+ // Checking pages
+
+ chrome.test.assertTrue(firstBookmark.hasOwnProperty('page'));
+ chrome.test.assertEq(0, firstBookmark.page);
+
+ chrome.test.assertTrue(firstNestedBookmark.hasOwnProperty('page'));
+ chrome.test.assertEq(1, firstNestedBookmark.page);
+
+ chrome.test.assertTrue(secondBookmark.hasOwnProperty('page'));
+ chrome.test.assertEq(2, secondBookmark.page);
+
+ chrome.test.succeed();
+ }
+];
+
+if (viewer.bookmarksLoaded) {
+ console.log('Bookmarks already loaded.');
+ chrome.test.runTests(tests);
+} else {
+ window.addEventListener('bookmarksload', function() {
+ console.log('Bookmarks just loaded.');
+ chrome.test.runTests(tests);
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698