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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var tests = [
6
7 /**
8 * Test that the correct bookmarks were loaded for the basic pdf
9 */
10 function testHasCorrectBookmarks() {
11 var bookmarks = viewer.bookmarks;
12
13 // Loading all relevant bookmarks
14
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.
15 chrome.test.assertEq(2, bookmarks.length);
16 var firstBookmark = bookmarks[0];
17 var secondBookmark = bookmarks[1];
18
19 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.
20 chrome.test.assertEq(1, firstBookmark.children.length);
21 chrome.test.assertTrue(secondBookmark.hasOwnProperty('children'));
22 chrome.test.assertEq(0, secondBookmark.children.length);
23
24 var firstNestedBookmark = firstBookmark.children[0];
25
26 // Checking titles
27 // An irregular amount of '\u0000' are trailing the titles, hence the strip.
28
29 chrome.test.assertTrue(firstBookmark.hasOwnProperty('title'));
30 chrome.test.assertEq('First Section',
31 firstBookmark.title.replace(/\u0000+$/, ''));
32
33 chrome.test.assertTrue(firstNestedBookmark.hasOwnProperty('title'));
34 chrome.test.assertEq('First Subsection',
35 firstNestedBookmark.title.replace(/\u0000+$/, ''));
36
37 chrome.test.assertTrue(secondBookmark.hasOwnProperty('title'));
38 chrome.test.assertEq('Second Section',
39 secondBookmark.title.replace(/\u0000+$/, ''));
40
41 // Checking pages
42
43 chrome.test.assertTrue(firstBookmark.hasOwnProperty('page'));
44 chrome.test.assertEq(0, firstBookmark.page);
45
46 chrome.test.assertTrue(firstNestedBookmark.hasOwnProperty('page'));
47 chrome.test.assertEq(1, firstNestedBookmark.page);
48
49 chrome.test.assertTrue(secondBookmark.hasOwnProperty('page'));
50 chrome.test.assertEq(2, secondBookmark.page);
51
52 chrome.test.succeed();
53 }
54 ];
55
56 if (viewer.bookmarksLoaded) {
57 console.log('Bookmarks already loaded.');
58 chrome.test.runTests(tests);
59 } else {
60 window.addEventListener('bookmarksload', function() {
61 console.log('Bookmarks just loaded.');
62 chrome.test.runTests(tests);
63 });
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698