Skip to content

Commit c1ae640

Browse files
committed
property navigator pdfViewerEnabled added and more tests
1 parent cff71d2 commit c1ae640

File tree

6 files changed

+197
-1
lines changed

6 files changed

+197
-1
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="4.7.0" date="November xx, 2024" description="Bugfixes, Chrome/Edge 131">
11+
<action type="add" dev="rbri">
12+
Property navigator pdfViewerEnabled added.
13+
</action>
1114
<action type="update" dev="rbri">
1215
Implementation of Plugin/PluginArray/MimeType/MimeTypeArray rewritten. The navigator properties
1316
plugins and mimeTypes returning static results in all browsers.

src/main/java/org/htmlunit/javascript/host/Navigator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ public Geolocation getGeolocation() {
297297
return geolocation;
298298
}
299299

300+
/**
301+
* @return true whether the browser supports inline display
302+
* of PDF files when navigating to them
303+
*/
304+
@JsxGetter
305+
public boolean getPdfViewerEnabled() {
306+
return true;
307+
}
308+
300309
/**
301310
* Returns the {@code buildID} property.
302311
* @return the {@code buildID} property

src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18126,4 +18126,86 @@ public void mimeTypeArray() throws Exception {
1812618126
public void mimeType() throws Exception {
1812718127
testString("", "navigator.mimeTypes[0]");
1812818128
}
18129+
18130+
/**
18131+
* Test {@link org.htmlunit.javascript.host.Navigator}.
18132+
*
18133+
* @throws Exception if an error occurs
18134+
*/
18135+
@Test
18136+
@Alerts(CHROME = "adAuctionComponents(),appCodeName[GCE],appName[GCE],appVersion[GCE],bluetooth[GCE],"
18137+
+ "canLoadAdAuctionFencedFrame(),canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),"
18138+
+ "clipboard[GCE],connection[GCE],constructor(),cookieEnabled[GCE],createAuctionNonce(),"
18139+
+ "credentials[GCE],deprecatedReplaceInURN(),deprecatedRunAdAuctionEnforcesKAnonymity[GCE],"
18140+
+ "deprecatedURNToURL(),deviceMemory[GCE],doNotTrack[GCE],geolocation[GCE],getBattery(),"
18141+
+ "getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu[GCE],hardwareConcurrency[GCE],"
18142+
+ "hid[GCE],ink[GCE],javaEnabled(),joinAdInterestGroup(),keyboard[GCE],language[GCE],languages[GCE],"
18143+
+ "leaveAdInterestGroup(),locks[GCE],login[GCE],managed[GCE],maxTouchPoints[GCE],"
18144+
+ "mediaCapabilities[GCE],mediaDevices[GCE],mediaSession[GCE],mimeTypes[GCE],onLine[GCE],"
18145+
+ "pdfViewerEnabled[GCE],permissions[GCE],platform[GCE],plugins[GCE],presentation[GCE],product[GCE],"
18146+
+ "productSub[GCE],protectedAudience[GCE],registerProtocolHandler(),requestMediaKeySystemAccess(),"
18147+
+ "requestMIDIAccess(),runAdAuction(),scheduling[GCE],sendBeacon(),serial[GCE],serviceWorker[GCE],"
18148+
+ "setAppBadge(),share(),storage[GCE],storageBuckets[GCE],unregisterProtocolHandler(),"
18149+
+ "updateAdInterestGroups(),usb[GCE],userActivation[GCE],userAgent[GCE],userAgentData[GCE],"
18150+
+ "vendor[GCE],vendorSub[GCE],vibrate(),virtualKeyboard[GCE],wakeLock[GCE],webdriver[GCE],"
18151+
+ "webkitGetUserMedia(),webkitPersistentStorage[GCE],webkitTemporaryStorage[GCE],"
18152+
+ "windowControlsOverlay[GCE],"
18153+
+ "xr[GCE]",
18154+
EDGE = "adAuctionComponents(),appCodeName[GCE],appName[GCE],appVersion[GCE],bluetooth[GCE],"
18155+
+ "canLoadAdAuctionFencedFrame(),canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),"
18156+
+ "clipboard[GCE],connection[GCE],constructor(),cookieEnabled[GCE],createAuctionNonce(),"
18157+
+ "credentials[GCE],deprecatedReplaceInURN(),deprecatedRunAdAuctionEnforcesKAnonymity[GCE],"
18158+
+ "deprecatedURNToURL(),deviceMemory[GCE],doNotTrack[GCE],geolocation[GCE],getBattery(),"
18159+
+ "getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu[GCE],hardwareConcurrency[GCE],"
18160+
+ "hid[GCE],ink[GCE],javaEnabled(),joinAdInterestGroup(),keyboard[GCE],language[GCE],languages[GCE],"
18161+
+ "leaveAdInterestGroup(),locks[GCE],login[GCE],managed[GCE],maxTouchPoints[GCE],"
18162+
+ "mediaCapabilities[GCE],mediaDevices[GCE],mediaSession[GCE],mimeTypes[GCE],onLine[GCE],"
18163+
+ "pdfViewerEnabled[GCE],permissions[GCE],platform[GCE],plugins[GCE],presentation[GCE],product[GCE],"
18164+
+ "productSub[GCE],protectedAudience[GCE],registerProtocolHandler(),requestMediaKeySystemAccess(),"
18165+
+ "requestMIDIAccess(),runAdAuction(),scheduling[GCE],sendBeacon(),serial[GCE],serviceWorker[GCE],"
18166+
+ "setAppBadge(),share(),storage[GCE],storageBuckets[GCE],unregisterProtocolHandler(),"
18167+
+ "updateAdInterestGroups(),usb[GCE],userActivation[GCE],userAgent[GCE],userAgentData[GCE],"
18168+
+ "vendor[GCE],vendorSub[GCE],vibrate(),virtualKeyboard[GCE],wakeLock[GCE],webdriver[GCE],"
18169+
+ "webkitGetUserMedia(),webkitPersistentStorage[GCE],webkitTemporaryStorage[GCE],"
18170+
+ "windowControlsOverlay[GCE],"
18171+
+ "xr[GCE]",
18172+
FF = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],clipboard[GCE],constructor(),"
18173+
+ "cookieEnabled[GCE],credentials[GCE],doNotTrack[GCE],geolocation[GCE],getAutoplayPolicy(),"
18174+
+ "getGamepads(),globalPrivacyControl[GCE],hardwareConcurrency[GCE],javaEnabled(),language[GCE],"
18175+
+ "languages[GCE],locks[GCE],maxTouchPoints[GCE],mediaCapabilities[GCE],mediaDevices[GCE],"
18176+
+ "mediaSession[GCE],mimeTypes[GCE],mozGetUserMedia(),onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],"
18177+
+ "permissions[GCE],platform[GCE],plugins[GCE],product[GCE],productSub[GCE],"
18178+
+ "registerProtocolHandler(),requestMediaKeySystemAccess(),requestMIDIAccess(),sendBeacon(),"
18179+
+ "serviceWorker[GCE],storage[GCE],taintEnabled(),userActivation[GCE],userAgent[GCE],vendor[GCE],"
18180+
+ "vendorSub[GCE],wakeLock[GCE],"
18181+
+ "webdriver[GCE]",
18182+
FF_ESR = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],clipboard[GCE],constructor(),"
18183+
+ "cookieEnabled[GCE],credentials[GCE],doNotTrack[GCE],geolocation[GCE],getAutoplayPolicy(),"
18184+
+ "getGamepads(),globalPrivacyControl[GCE],hardwareConcurrency[GCE],javaEnabled(),language[GCE],"
18185+
+ "languages[GCE],locks[GCE],maxTouchPoints[GCE],mediaCapabilities[GCE],mediaDevices[GCE],"
18186+
+ "mediaSession[GCE],mimeTypes[GCE],mozGetUserMedia(),onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],"
18187+
+ "permissions[GCE],platform[GCE],plugins[GCE],product[GCE],productSub[GCE],"
18188+
+ "registerProtocolHandler(),requestMediaKeySystemAccess(),requestMIDIAccess(),sendBeacon(),"
18189+
+ "serviceWorker[GCE],storage[GCE],taintEnabled(),userActivation[GCE],userAgent[GCE],vendor[GCE],"
18190+
+ "vendorSub[GCE],vibrate(),wakeLock[GCE],"
18191+
+ "webdriver[GCE]")
18192+
@HtmlUnitNYI(CHROME = "appCodeName[GCE],appName[GCE],appVersion[GCE],connection[GCE],constructor(),"
18193+
+ "cookieEnabled[GCE],doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],"
18194+
+ "mediaDevices[GCE],mimeTypes[GCE],onLine[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
18195+
+ "product[GCE],productSub[GCE],userAgent[GCE],vendor[GCE],vendorSub[GCE]",
18196+
EDGE = "appCodeName[GCE],appName[GCE],appVersion[GCE],connection[GCE],constructor(),"
18197+
+ "cookieEnabled[GCE],doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],"
18198+
+ "mediaDevices[GCE],mimeTypes[GCE],onLine[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
18199+
+ "product[GCE],productSub[GCE],userAgent[GCE],vendor[GCE],vendorSub[GCE]",
18200+
FF = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],constructor(),cookieEnabled[GCE],"
18201+
+ "doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],mediaDevices[GCE],"
18202+
+ "mimeTypes[GCE],onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
18203+
+ "product[GCE],productSub[GCE],taintEnabled(),userAgent[GCE],vendor[GCE],vendorSub[GCE]",
18204+
FF_ESR = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],constructor(),cookieEnabled[GCE],"
18205+
+ "doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],mediaDevices[GCE],"
18206+
+ "mimeTypes[GCE],onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
18207+
+ "product[GCE],productSub[GCE],taintEnabled(),userAgent[GCE],vendor[GCE],vendorSub[GCE]")
18208+
public void navigator() throws Exception {
18209+
testString("", "navigator");
18210+
}
1812918211
}

src/test/java/org/htmlunit/general/ElementOwnPropertySymbolsTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3264,11 +3264,25 @@ public void mimeTypeArray() throws Exception {
32643264
* @throws Exception if an error occurs
32653265
*/
32663266
@Test
3267-
@Alerts(CHROME = ",Symbol(Symbol.toStringTag) [C] [MimeType]",
3267+
@Alerts(CHROME = "Symbol(Symbol.toStringTag) [C] [MimeType]",
32683268
EDGE = "Symbol(Symbol.toStringTag) [C] [MimeType]",
32693269
FF = "Symbol(Symbol.toStringTag) [C] [MimeType]",
32703270
FF_ESR = "Symbol(Symbol.toStringTag) [C] [MimeType]")
32713271
public void mimeType() throws Exception {
32723272
testString("", "navigator.mimeTypes[0]");
32733273
}
3274+
3275+
/**
3276+
* Test {@link org.htmlunit.javascript.host.Navigator}.
3277+
*
3278+
* @throws Exception if an error occurs
3279+
*/
3280+
@Test
3281+
@Alerts(CHROME = "Symbol(Symbol.toStringTag) [C] [Navigator]",
3282+
EDGE = "Symbol(Symbol.toStringTag) [C] [Navigator]",
3283+
FF = "Symbol(Symbol.toStringTag) [C] [Navigator]",
3284+
FF_ESR = "Symbol(Symbol.toStringTag) [C] [Navigator]")
3285+
public void navigator() throws Exception {
3286+
testString("", "navigator");
3287+
}
32743288
}

src/test/java/org/htmlunit/general/ElementPropertiesTest.java

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9249,4 +9249,72 @@ public void mimeTypeArray() throws Exception {
92499249
public void mimeType() throws Exception {
92509250
testString("", "navigator.mimeTypes[0]");
92519251
}
9252+
9253+
/**
9254+
* Test {@link org.htmlunit.javascript.host.Navigator}.
9255+
*
9256+
* @throws Exception if an error occurs
9257+
*/
9258+
@Test
9259+
@Alerts(CHROME = "adAuctionComponents(),appCodeName,appName,appVersion,bluetooth,canLoadAdAuctionFencedFrame(),"
9260+
+ "canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),clipboard,connection,"
9261+
+ "cookieEnabled,createAuctionNonce(),credentials,deprecatedReplaceInURN(),"
9262+
+ "deprecatedRunAdAuctionEnforcesKAnonymity,deprecatedURNToURL(),deviceMemory,doNotTrack,"
9263+
+ "geolocation,getBattery(),getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu,"
9264+
+ "hardwareConcurrency,hid,ink,javaEnabled(),joinAdInterestGroup(),keyboard,language,languages,"
9265+
+ "leaveAdInterestGroup(),locks,login,managed,maxTouchPoints,mediaCapabilities,mediaDevices,"
9266+
+ "mediaSession,mimeTypes,onLine,pdfViewerEnabled,permissions,platform,plugins,presentation,product,"
9267+
+ "productSub,protectedAudience,registerProtocolHandler(),requestMediaKeySystemAccess(),"
9268+
+ "requestMIDIAccess(),runAdAuction(),scheduling,sendBeacon(),serial,serviceWorker,setAppBadge(),"
9269+
+ "share(),storage,storageBuckets,unregisterProtocolHandler(),updateAdInterestGroups(),usb,"
9270+
+ "userActivation,userAgent,userAgentData,vendor,vendorSub,vibrate(),virtualKeyboard,wakeLock,"
9271+
+ "webdriver,webkitGetUserMedia(),webkitPersistentStorage,webkitTemporaryStorage,"
9272+
+ "windowControlsOverlay,"
9273+
+ "xr",
9274+
EDGE = "adAuctionComponents(),appCodeName,appName,appVersion,bluetooth,canLoadAdAuctionFencedFrame(),"
9275+
+ "canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),clipboard,connection,"
9276+
+ "cookieEnabled,createAuctionNonce(),credentials,deprecatedReplaceInURN(),"
9277+
+ "deprecatedRunAdAuctionEnforcesKAnonymity,deprecatedURNToURL(),deviceMemory,doNotTrack,"
9278+
+ "geolocation,getBattery(),getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu,"
9279+
+ "hardwareConcurrency,hid,ink,javaEnabled(),joinAdInterestGroup(),keyboard,language,languages,"
9280+
+ "leaveAdInterestGroup(),locks,login,managed,maxTouchPoints,mediaCapabilities,mediaDevices,"
9281+
+ "mediaSession,mimeTypes,onLine,pdfViewerEnabled,permissions,platform,plugins,presentation,product,"
9282+
+ "productSub,protectedAudience,registerProtocolHandler(),requestMediaKeySystemAccess(),"
9283+
+ "requestMIDIAccess(),runAdAuction(),scheduling,sendBeacon(),serial,serviceWorker,setAppBadge(),"
9284+
+ "share(),storage,storageBuckets,unregisterProtocolHandler(),updateAdInterestGroups(),usb,"
9285+
+ "userActivation,userAgent,userAgentData,vendor,vendorSub,vibrate(),virtualKeyboard,wakeLock,"
9286+
+ "webdriver,webkitGetUserMedia(),webkitPersistentStorage,webkitTemporaryStorage,"
9287+
+ "windowControlsOverlay,"
9288+
+ "xr",
9289+
FF = "appCodeName,appName,appVersion,buildID,clipboard,cookieEnabled,credentials,doNotTrack,"
9290+
+ "geolocation,getAutoplayPolicy(),getGamepads(),globalPrivacyControl,hardwareConcurrency,"
9291+
+ "javaEnabled(),language,languages,locks,maxTouchPoints,mediaCapabilities,mediaDevices,"
9292+
+ "mediaSession,mimeTypes,mozGetUserMedia(),onLine,oscpu,pdfViewerEnabled,permissions,platform,"
9293+
+ "plugins,product,productSub,registerProtocolHandler(),requestMediaKeySystemAccess(),"
9294+
+ "requestMIDIAccess(),sendBeacon(),serviceWorker,storage,taintEnabled(),userActivation,userAgent,"
9295+
+ "vendor,vendorSub,wakeLock,"
9296+
+ "webdriver",
9297+
FF_ESR = "appCodeName,appName,appVersion,buildID,clipboard,cookieEnabled,credentials,doNotTrack,"
9298+
+ "geolocation,getAutoplayPolicy(),getGamepads(),globalPrivacyControl,hardwareConcurrency,"
9299+
+ "javaEnabled(),language,languages,locks,maxTouchPoints,mediaCapabilities,mediaDevices,"
9300+
+ "mediaSession,mimeTypes,mozGetUserMedia(),onLine,oscpu,pdfViewerEnabled,permissions,platform,"
9301+
+ "plugins,product,productSub,registerProtocolHandler(),requestMediaKeySystemAccess(),"
9302+
+ "requestMIDIAccess(),sendBeacon(),serviceWorker,storage,taintEnabled(),userActivation,userAgent,"
9303+
+ "vendor,vendorSub,vibrate(),wakeLock,"
9304+
+ "webdriver")
9305+
@HtmlUnitNYI(CHROME = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
9306+
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
9307+
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
9308+
EDGE = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
9309+
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
9310+
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
9311+
FF = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
9312+
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
9313+
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
9314+
FF_ESR = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
9315+
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
9316+
+ "plugins,product,productSub,userAgent,vendor,vendorSub")
9317+
public void navigator() throws Exception {
9318+
testString("", "navigator");
9319+
}
92529320
}

src/test/java/org/htmlunit/javascript/host/NavigatorTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,4 +549,24 @@ public void mediaDevices() throws Exception {
549549

550550
loadPageVerifyTitle2(html);
551551
}
552+
553+
/**
554+
* @throws Exception if the test fails
555+
*/
556+
@Test
557+
@Alerts("true")
558+
public void pdfViewerEnabled() throws Exception {
559+
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
560+
+ "<html><head>\n"
561+
+ "<script>\n"
562+
+ LOG_TITLE_FUNCTION
563+
+ " function test() {\n"
564+
+ " log(navigator.pdfViewerEnabled);\n"
565+
+ " }\n"
566+
+ "</script>\n"
567+
+ "</head><body onload='test()'>\n"
568+
+ "</body></html>";
569+
570+
loadPageVerifyTitle2(html);
571+
}
552572
}

0 commit comments

Comments
 (0)