Skip to content

Commit

Permalink
property navigator pdfViewerEnabled added and more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Nov 20, 2024
1 parent cff71d2 commit c1ae640
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="4.7.0" date="November xx, 2024" description="Bugfixes, Chrome/Edge 131">
<action type="add" dev="rbri">
Property navigator pdfViewerEnabled added.
</action>
<action type="update" dev="rbri">
Implementation of Plugin/PluginArray/MimeType/MimeTypeArray rewritten. The navigator properties
plugins and mimeTypes returning static results in all browsers.
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/htmlunit/javascript/host/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ public Geolocation getGeolocation() {
return geolocation;
}

/**
* @return true whether the browser supports inline display
* of PDF files when navigating to them
*/
@JsxGetter
public boolean getPdfViewerEnabled() {
return true;
}

/**
* Returns the {@code buildID} property.
* @return the {@code buildID} property
Expand Down
82 changes: 82 additions & 0 deletions src/test/java/org/htmlunit/general/ElementOwnPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18126,4 +18126,86 @@ public void mimeTypeArray() throws Exception {
public void mimeType() throws Exception {
testString("", "navigator.mimeTypes[0]");
}

/**
* Test {@link org.htmlunit.javascript.host.Navigator}.
*
* @throws Exception if an error occurs
*/
@Test
@Alerts(CHROME = "adAuctionComponents(),appCodeName[GCE],appName[GCE],appVersion[GCE],bluetooth[GCE],"
+ "canLoadAdAuctionFencedFrame(),canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),"
+ "clipboard[GCE],connection[GCE],constructor(),cookieEnabled[GCE],createAuctionNonce(),"
+ "credentials[GCE],deprecatedReplaceInURN(),deprecatedRunAdAuctionEnforcesKAnonymity[GCE],"
+ "deprecatedURNToURL(),deviceMemory[GCE],doNotTrack[GCE],geolocation[GCE],getBattery(),"
+ "getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu[GCE],hardwareConcurrency[GCE],"
+ "hid[GCE],ink[GCE],javaEnabled(),joinAdInterestGroup(),keyboard[GCE],language[GCE],languages[GCE],"
+ "leaveAdInterestGroup(),locks[GCE],login[GCE],managed[GCE],maxTouchPoints[GCE],"
+ "mediaCapabilities[GCE],mediaDevices[GCE],mediaSession[GCE],mimeTypes[GCE],onLine[GCE],"
+ "pdfViewerEnabled[GCE],permissions[GCE],platform[GCE],plugins[GCE],presentation[GCE],product[GCE],"
+ "productSub[GCE],protectedAudience[GCE],registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),runAdAuction(),scheduling[GCE],sendBeacon(),serial[GCE],serviceWorker[GCE],"
+ "setAppBadge(),share(),storage[GCE],storageBuckets[GCE],unregisterProtocolHandler(),"
+ "updateAdInterestGroups(),usb[GCE],userActivation[GCE],userAgent[GCE],userAgentData[GCE],"
+ "vendor[GCE],vendorSub[GCE],vibrate(),virtualKeyboard[GCE],wakeLock[GCE],webdriver[GCE],"
+ "webkitGetUserMedia(),webkitPersistentStorage[GCE],webkitTemporaryStorage[GCE],"
+ "windowControlsOverlay[GCE],"
+ "xr[GCE]",
EDGE = "adAuctionComponents(),appCodeName[GCE],appName[GCE],appVersion[GCE],bluetooth[GCE],"
+ "canLoadAdAuctionFencedFrame(),canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),"
+ "clipboard[GCE],connection[GCE],constructor(),cookieEnabled[GCE],createAuctionNonce(),"
+ "credentials[GCE],deprecatedReplaceInURN(),deprecatedRunAdAuctionEnforcesKAnonymity[GCE],"
+ "deprecatedURNToURL(),deviceMemory[GCE],doNotTrack[GCE],geolocation[GCE],getBattery(),"
+ "getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu[GCE],hardwareConcurrency[GCE],"
+ "hid[GCE],ink[GCE],javaEnabled(),joinAdInterestGroup(),keyboard[GCE],language[GCE],languages[GCE],"
+ "leaveAdInterestGroup(),locks[GCE],login[GCE],managed[GCE],maxTouchPoints[GCE],"
+ "mediaCapabilities[GCE],mediaDevices[GCE],mediaSession[GCE],mimeTypes[GCE],onLine[GCE],"
+ "pdfViewerEnabled[GCE],permissions[GCE],platform[GCE],plugins[GCE],presentation[GCE],product[GCE],"
+ "productSub[GCE],protectedAudience[GCE],registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),runAdAuction(),scheduling[GCE],sendBeacon(),serial[GCE],serviceWorker[GCE],"
+ "setAppBadge(),share(),storage[GCE],storageBuckets[GCE],unregisterProtocolHandler(),"
+ "updateAdInterestGroups(),usb[GCE],userActivation[GCE],userAgent[GCE],userAgentData[GCE],"
+ "vendor[GCE],vendorSub[GCE],vibrate(),virtualKeyboard[GCE],wakeLock[GCE],webdriver[GCE],"
+ "webkitGetUserMedia(),webkitPersistentStorage[GCE],webkitTemporaryStorage[GCE],"
+ "windowControlsOverlay[GCE],"
+ "xr[GCE]",
FF = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],clipboard[GCE],constructor(),"
+ "cookieEnabled[GCE],credentials[GCE],doNotTrack[GCE],geolocation[GCE],getAutoplayPolicy(),"
+ "getGamepads(),globalPrivacyControl[GCE],hardwareConcurrency[GCE],javaEnabled(),language[GCE],"
+ "languages[GCE],locks[GCE],maxTouchPoints[GCE],mediaCapabilities[GCE],mediaDevices[GCE],"
+ "mediaSession[GCE],mimeTypes[GCE],mozGetUserMedia(),onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],"
+ "permissions[GCE],platform[GCE],plugins[GCE],product[GCE],productSub[GCE],"
+ "registerProtocolHandler(),requestMediaKeySystemAccess(),requestMIDIAccess(),sendBeacon(),"
+ "serviceWorker[GCE],storage[GCE],taintEnabled(),userActivation[GCE],userAgent[GCE],vendor[GCE],"
+ "vendorSub[GCE],wakeLock[GCE],"
+ "webdriver[GCE]",
FF_ESR = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],clipboard[GCE],constructor(),"
+ "cookieEnabled[GCE],credentials[GCE],doNotTrack[GCE],geolocation[GCE],getAutoplayPolicy(),"
+ "getGamepads(),globalPrivacyControl[GCE],hardwareConcurrency[GCE],javaEnabled(),language[GCE],"
+ "languages[GCE],locks[GCE],maxTouchPoints[GCE],mediaCapabilities[GCE],mediaDevices[GCE],"
+ "mediaSession[GCE],mimeTypes[GCE],mozGetUserMedia(),onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],"
+ "permissions[GCE],platform[GCE],plugins[GCE],product[GCE],productSub[GCE],"
+ "registerProtocolHandler(),requestMediaKeySystemAccess(),requestMIDIAccess(),sendBeacon(),"
+ "serviceWorker[GCE],storage[GCE],taintEnabled(),userActivation[GCE],userAgent[GCE],vendor[GCE],"
+ "vendorSub[GCE],vibrate(),wakeLock[GCE],"
+ "webdriver[GCE]")
@HtmlUnitNYI(CHROME = "appCodeName[GCE],appName[GCE],appVersion[GCE],connection[GCE],constructor(),"
+ "cookieEnabled[GCE],doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],"
+ "mediaDevices[GCE],mimeTypes[GCE],onLine[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
+ "product[GCE],productSub[GCE],userAgent[GCE],vendor[GCE],vendorSub[GCE]",
EDGE = "appCodeName[GCE],appName[GCE],appVersion[GCE],connection[GCE],constructor(),"
+ "cookieEnabled[GCE],doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],"
+ "mediaDevices[GCE],mimeTypes[GCE],onLine[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
+ "product[GCE],productSub[GCE],userAgent[GCE],vendor[GCE],vendorSub[GCE]",
FF = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],constructor(),cookieEnabled[GCE],"
+ "doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],mediaDevices[GCE],"
+ "mimeTypes[GCE],onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
+ "product[GCE],productSub[GCE],taintEnabled(),userAgent[GCE],vendor[GCE],vendorSub[GCE]",
FF_ESR = "appCodeName[GCE],appName[GCE],appVersion[GCE],buildID[GCE],constructor(),cookieEnabled[GCE],"
+ "doNotTrack[GCE],geolocation[GCE],javaEnabled(),language[GCE],languages[GCE],mediaDevices[GCE],"
+ "mimeTypes[GCE],onLine[GCE],oscpu[GCE],pdfViewerEnabled[GCE],platform[GCE],plugins[GCE],"
+ "product[GCE],productSub[GCE],taintEnabled(),userAgent[GCE],vendor[GCE],vendorSub[GCE]")
public void navigator() throws Exception {
testString("", "navigator");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3264,11 +3264,25 @@ public void mimeTypeArray() throws Exception {
* @throws Exception if an error occurs
*/
@Test
@Alerts(CHROME = ",Symbol(Symbol.toStringTag) [C] [MimeType]",
@Alerts(CHROME = "Symbol(Symbol.toStringTag) [C] [MimeType]",
EDGE = "Symbol(Symbol.toStringTag) [C] [MimeType]",
FF = "Symbol(Symbol.toStringTag) [C] [MimeType]",
FF_ESR = "Symbol(Symbol.toStringTag) [C] [MimeType]")
public void mimeType() throws Exception {
testString("", "navigator.mimeTypes[0]");
}

/**
* Test {@link org.htmlunit.javascript.host.Navigator}.
*
* @throws Exception if an error occurs
*/
@Test
@Alerts(CHROME = "Symbol(Symbol.toStringTag) [C] [Navigator]",
EDGE = "Symbol(Symbol.toStringTag) [C] [Navigator]",
FF = "Symbol(Symbol.toStringTag) [C] [Navigator]",
FF_ESR = "Symbol(Symbol.toStringTag) [C] [Navigator]")
public void navigator() throws Exception {
testString("", "navigator");
}
}
68 changes: 68 additions & 0 deletions src/test/java/org/htmlunit/general/ElementPropertiesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9249,4 +9249,72 @@ public void mimeTypeArray() throws Exception {
public void mimeType() throws Exception {
testString("", "navigator.mimeTypes[0]");
}

/**
* Test {@link org.htmlunit.javascript.host.Navigator}.
*
* @throws Exception if an error occurs
*/
@Test
@Alerts(CHROME = "adAuctionComponents(),appCodeName,appName,appVersion,bluetooth,canLoadAdAuctionFencedFrame(),"
+ "canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),clipboard,connection,"
+ "cookieEnabled,createAuctionNonce(),credentials,deprecatedReplaceInURN(),"
+ "deprecatedRunAdAuctionEnforcesKAnonymity,deprecatedURNToURL(),deviceMemory,doNotTrack,"
+ "geolocation,getBattery(),getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu,"
+ "hardwareConcurrency,hid,ink,javaEnabled(),joinAdInterestGroup(),keyboard,language,languages,"
+ "leaveAdInterestGroup(),locks,login,managed,maxTouchPoints,mediaCapabilities,mediaDevices,"
+ "mediaSession,mimeTypes,onLine,pdfViewerEnabled,permissions,platform,plugins,presentation,product,"
+ "productSub,protectedAudience,registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),runAdAuction(),scheduling,sendBeacon(),serial,serviceWorker,setAppBadge(),"
+ "share(),storage,storageBuckets,unregisterProtocolHandler(),updateAdInterestGroups(),usb,"
+ "userActivation,userAgent,userAgentData,vendor,vendorSub,vibrate(),virtualKeyboard,wakeLock,"
+ "webdriver,webkitGetUserMedia(),webkitPersistentStorage,webkitTemporaryStorage,"
+ "windowControlsOverlay,"
+ "xr",
EDGE = "adAuctionComponents(),appCodeName,appName,appVersion,bluetooth,canLoadAdAuctionFencedFrame(),"
+ "canShare(),clearAppBadge(),clearOriginJoinedAdInterestGroups(),clipboard,connection,"
+ "cookieEnabled,createAuctionNonce(),credentials,deprecatedReplaceInURN(),"
+ "deprecatedRunAdAuctionEnforcesKAnonymity,deprecatedURNToURL(),deviceMemory,doNotTrack,"
+ "geolocation,getBattery(),getGamepads(),getInstalledRelatedApps(),getUserMedia(),gpu,"
+ "hardwareConcurrency,hid,ink,javaEnabled(),joinAdInterestGroup(),keyboard,language,languages,"
+ "leaveAdInterestGroup(),locks,login,managed,maxTouchPoints,mediaCapabilities,mediaDevices,"
+ "mediaSession,mimeTypes,onLine,pdfViewerEnabled,permissions,platform,plugins,presentation,product,"
+ "productSub,protectedAudience,registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),runAdAuction(),scheduling,sendBeacon(),serial,serviceWorker,setAppBadge(),"
+ "share(),storage,storageBuckets,unregisterProtocolHandler(),updateAdInterestGroups(),usb,"
+ "userActivation,userAgent,userAgentData,vendor,vendorSub,vibrate(),virtualKeyboard,wakeLock,"
+ "webdriver,webkitGetUserMedia(),webkitPersistentStorage,webkitTemporaryStorage,"
+ "windowControlsOverlay,"
+ "xr",
FF = "appCodeName,appName,appVersion,buildID,clipboard,cookieEnabled,credentials,doNotTrack,"
+ "geolocation,getAutoplayPolicy(),getGamepads(),globalPrivacyControl,hardwareConcurrency,"
+ "javaEnabled(),language,languages,locks,maxTouchPoints,mediaCapabilities,mediaDevices,"
+ "mediaSession,mimeTypes,mozGetUserMedia(),onLine,oscpu,pdfViewerEnabled,permissions,platform,"
+ "plugins,product,productSub,registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),sendBeacon(),serviceWorker,storage,taintEnabled(),userActivation,userAgent,"
+ "vendor,vendorSub,wakeLock,"
+ "webdriver",
FF_ESR = "appCodeName,appName,appVersion,buildID,clipboard,cookieEnabled,credentials,doNotTrack,"
+ "geolocation,getAutoplayPolicy(),getGamepads(),globalPrivacyControl,hardwareConcurrency,"
+ "javaEnabled(),language,languages,locks,maxTouchPoints,mediaCapabilities,mediaDevices,"
+ "mediaSession,mimeTypes,mozGetUserMedia(),onLine,oscpu,pdfViewerEnabled,permissions,platform,"
+ "plugins,product,productSub,registerProtocolHandler(),requestMediaKeySystemAccess(),"
+ "requestMIDIAccess(),sendBeacon(),serviceWorker,storage,taintEnabled(),userActivation,userAgent,"
+ "vendor,vendorSub,vibrate(),wakeLock,"
+ "webdriver")
@HtmlUnitNYI(CHROME = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
EDGE = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
FF = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
+ "plugins,product,productSub,userAgent,vendor,vendorSub",
FF_ESR = "appCodeName,appName,appVersion,connection,cookieEnabled,doNotTrack,geolocation,"
+ "javaEnabled(),language,languages,mediaDevices,mimeTypes,onLine,pdfViewerEnabled,platform,"
+ "plugins,product,productSub,userAgent,vendor,vendorSub")
public void navigator() throws Exception {
testString("", "navigator");
}
}
20 changes: 20 additions & 0 deletions src/test/java/org/htmlunit/javascript/host/NavigatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,24 @@ public void mediaDevices() throws Exception {

loadPageVerifyTitle2(html);
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("true")
public void pdfViewerEnabled() throws Exception {
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
+ "<html><head>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " function test() {\n"
+ " log(navigator.pdfViewerEnabled);\n"
+ " }\n"
+ "</script>\n"
+ "</head><body onload='test()'>\n"
+ "</body></html>";

loadPageVerifyTitle2(html);
}
}

0 comments on commit c1ae640

Please sign in to comment.