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

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

Issue 2402873002: Add check for file:-navigations from PDFs (Closed)
Patch Set: Put logic at single location, add test Created 4 years, 2 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
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/pdf/navigator_test.js
diff --git a/chrome/test/data/pdf/navigator_test.js b/chrome/test/data/pdf/navigator_test.js
index f589016547a0f0f01df07237ae5d3f9784a45478..dd990d998377c3d7b7ea318536544055085db979 100644
--- a/chrome/test/data/pdf/navigator_test.js
+++ b/chrome/test/data/pdf/navigator_test.js
@@ -12,16 +12,16 @@ function MockNavigatorDelegate() {
MockNavigatorDelegate.prototype = {
navigateInCurrentTab: function(url) {
this.navigateInCurrentTabCalled = true;
- this.url = url;
+ this.url = url || '<called, but no url set>';
},
navigateInNewTab: function(url) {
this.navigateInNewTabCalled = true;
- this.url = url;
+ this.url = url || '<called, but no url set>';
},
navigateInNewWindow: function(url) {
this.navigateInNewWindowCalled = true;
- this.url = url;
+ this.url = url || '<called, but no url set>';
},
reset: function() {
this.navigateInCurrentTabCalled = false;
@@ -48,6 +48,10 @@ function doNavigationUrlTest(
navigatorDelegate.reset();
navigator.navigate(url, disposition);
chrome.test.assertFalse(viewportChangedCallback.wasCalled);
+ chrome.test.assertEq(expectedResultUrl, navigatorDelegate.url);
+ if (expectedResultUrl === undefined) {
+ return;
raymes 2016/10/13 00:11:34 Can we assert navigatorDelegate.navigateInCurrent
robwu 2016/10/13 07:22:35 That is not needed, because url is undefined iff t
+ }
switch (disposition) {
case Navigator.WindowOpenDisposition.CURRENT_TAB:
chrome.test.assertTrue(navigatorDelegate.navigateInCurrentTabCalled);
@@ -61,7 +65,6 @@ function doNavigationUrlTest(
default:
break;
}
- chrome.test.assertEq(expectedResultUrl, navigatorDelegate.url);
}
/**
@@ -253,6 +256,38 @@ var tests = [
'file:///foodotcom/bar.pdf');
chrome.test.succeed();
+ },
+
+ function testNavigateInvalidUrls() {
+ var url = 'https://example.com/some-web-document.pdf';
+
+ // From non-file: to file:
+ doNavigationUrlTests(
+ url,
+ 'file:///bar.pdf',
+ undefined);
+
+ doNavigationUrlTests(
+ url,
+ 'chrome://version',
+ undefined);
+
+ doNavigationUrlTests(
+ url,
+ 'javascript:// this is not a document.pdf',
+ undefined);
+
+ doNavigationUrlTests(
+ url,
+ 'this-is-not-a-valid-scheme://path.pdf',
+ undefined);
+
+ doNavigationUrlTests(
+ url,
+ '',
+ undefined);
+
+ chrome.test.succeed();
}
];
« no previous file with comments | « chrome/browser/resources/pdf/pdf.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698