Skip to content

Commit

Permalink
[pdf-viewer] Do not wait for load in JS tests
Browse files Browse the repository at this point in the history
loads.

PDFExtensionTest: :RunTestsInJsModule() already ensures the actual PDF
Change-Id: I7f06343a02a116ec7f2ab6c489a6bdcbebae93fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3544246
Reviewed-by: K. Moon <kmoon@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/main@{#984402}
  • Loading branch information
Daniel Hosseinian authored and Chromium LUCI CQ committed Mar 23, 2022
1 parent bfe0c56 commit ed4e427
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 74 deletions.
9 changes: 2 additions & 7 deletions chrome/test/data/pdf/basic_plugin_test.ts
Expand Up @@ -7,7 +7,7 @@ import {PDFScriptingAPI, PDFViewerElement} from 'chrome-extension://mhjfbmdgcfjb
/**
* These tests require that the PDF plugin be available to run correctly.
*/
const tests = [
chrome.test.runTests([
/**
* Test that the page is sized to the size of the document.
*/
Expand Down Expand Up @@ -38,9 +38,4 @@ const tests = [
chrome.test.assertEq('test.pdf', document.title);
chrome.test.succeed();
},
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 3 additions & 8 deletions chrome/test/data/pdf/beep_test.ts
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {PDFScriptingAPI, PDFViewerElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {PDFViewerElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';

const tests = [
chrome.test.runTests([
/**
* Test that the JS was able to call back via "app.beep()"
*/
Expand All @@ -13,9 +13,4 @@ const tests = [
chrome.test.assertEq(1, viewer.beepCount);
chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 3 additions & 8 deletions chrome/test/data/pdf/bookmarks_test.ts
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {Bookmark, ChangePageAndXyDetail, ChangePageDetail, ChangeZoomDetail, NavigateDetail, PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {Bookmark, ChangePageAndXyDetail, ChangePageDetail, ChangeZoomDetail, NavigateDetail} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {createBookmarksForTest} from './test_util.js';
Expand All @@ -13,7 +13,7 @@ interface TestBookmarksElement extends HTMLElement {
bookmarks: Bookmark[];
}

const tests = [
chrome.test.runTests([
/**
* Test that the correct bookmarks were loaded for
* test-bookmarks-with-zoom.pdf.
Expand Down Expand Up @@ -150,9 +150,4 @@ const tests = [

chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 3 additions & 8 deletions chrome/test/data/pdf/navigator_test.ts
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {NavigatorDelegate, OpenPdfParamsParser, PdfNavigator, PDFScriptingAPI, WindowOpenDisposition} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {NavigatorDelegate, OpenPdfParamsParser, PdfNavigator, WindowOpenDisposition} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {TestBrowserProxy} from 'chrome://webui-test/test_browser_proxy.js';

import {getZoomableViewport, MockDocumentDimensions, MockElement, MockSizer, MockViewportChangedCallback} from './test_util.js';
Expand Down Expand Up @@ -99,7 +99,7 @@ async function doNavigationUrlTests(
mockViewportChangedCallback, navigatorDelegate);
}

const tests = [
chrome.test.runTests([
/**
* Test navigation within the page, opening a url in the same tab and
* opening a url in a new tab.
Expand Down Expand Up @@ -255,9 +255,4 @@ const tests = [

chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 3 additions & 8 deletions chrome/test/data/pdf/nobeep_test.ts
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {PDFScriptingAPI, PDFViewerElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {PDFViewerElement} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';

const tests = [
chrome.test.runTests([
/**
* Test that blocked JS was not able to call back via "app.beep()"
*/
Expand All @@ -13,9 +13,4 @@ const tests = [
chrome.test.assertEq(0, viewer.beepCount);
chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 3 additions & 8 deletions chrome/test/data/pdf/params_parser_test.ts
Expand Up @@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {FittingType, OpenPdfParamsParser, PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';
import {FittingType, OpenPdfParamsParser} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';


const tests = [
chrome.test.runTests([
/**
* Test named destinations.
*/
Expand Down Expand Up @@ -319,9 +319,4 @@ const tests = [

chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 2 additions & 9 deletions chrome/test/data/pdf/title_test.ts
Expand Up @@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';

const tests = [
chrome.test.runTests([
/**
* Test that the correct title is displayed for test-title.pdf.
*/
Expand All @@ -13,9 +11,4 @@ const tests = [

chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 2 additions & 9 deletions chrome/test/data/pdf/touch_handling_test.js
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';

function sendTouchStart(touches) {
let id = 0;
const touchList = touches.map(function(xy) {
Expand Down Expand Up @@ -36,7 +34,7 @@ function createContextMenuEvent() {
});
}

const tests = [
chrome.test.runTests([
// Test suppression of the context menu on single touch.
function testContextMenuSingleTouch() {
sendTouchStart([{x: 10, y: 10}]);
Expand Down Expand Up @@ -77,9 +75,4 @@ const tests = [
// // 10k is the value for the action_timeout_ms_ in Chrome test_timeouts.cc
// }, 10000);
// }
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);
11 changes: 2 additions & 9 deletions chrome/test/data/pdf/whitespace_title_test.ts
Expand Up @@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {PDFScriptingAPI} from 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/pdf_viewer_wrapper.js';

const tests = [
chrome.test.runTests([
/**
* Test that the correct title is displayed for test-whitespace-title.pdf.
*/
Expand All @@ -13,9 +11,4 @@ const tests = [

chrome.test.succeed();
}
];

const scriptingAPI = new PDFScriptingAPI(window, window);
scriptingAPI.setLoadCompleteCallback(function() {
chrome.test.runTests(tests);
});
]);

0 comments on commit ed4e427

Please sign in to comment.