Skip to content

Commit

Permalink
Remove all user agent checks for MSIE or documentMode (#10014)
Browse files Browse the repository at this point in the history
This removes all checks of MSIE in the user agent string, and all checks
of documentMode to verify which IE version is being used, as these
browsers are long since unsupported.

Most of these changes are specific to tests or devmode, but there is
also a change to simplify Throwable slightly (allowing it to work in
node.js and other non-browser environments), and simplification of
startup user agent checks.
  • Loading branch information
niloc132 authored Oct 29, 2024
1 parent 0056242 commit 2ec0134
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 170 deletions.
11 changes: 0 additions & 11 deletions dev/core/src/com/google/gwt/core/ext/linker/impl/devmode.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,6 @@ function __gwt_displayGlassMessage(summary, details) {
// Steal focus.
glass.focus();

if ((navigator.userAgent.indexOf("MSIE") >= 0) && (topDoc.compatMode == "BackCompat")) {
// IE quirks mode doesn't support right/bottom, but does support this.
glassStyle.width = "125%";
glassStyle.height = "100%";
} else if (navigator.userAgent.indexOf("MSIE 6") >= 0) {
// IE6 doesn't have a real standards mode, so we have to use hacks.
glassStyle.width = "125%"; // Get past scroll bar area.
// Nasty CSS; onresize would be better but the outer window won't let us add a listener IE.
glassStyle.setExpression("height", "document.documentElement.clientHeight");
}

$doc.title = summary + " [" + $doc.title + "]";
}

Expand Down
11 changes: 0 additions & 11 deletions dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,6 @@
// Steal focus.
glass.focus();

if ((navigator.userAgent.indexOf("MSIE") >= 0) && (topDoc.compatMode == "BackCompat")) {
// IE quirks mode doesn't support right/bottom, but does support this.
glassStyle.width = "125%";
glassStyle.height = "100%";
} else if (navigator.userAgent.indexOf("MSIE 6") >= 0) {
// IE6 doesn't have a real standards mode, so we have to use hacks.
glassStyle.width = "125%"; // Get past scroll bar area.
// Nasty CSS; onresize would be better but the outer window won't let us add a listener IE.
glassStyle.setExpression("height", "document.documentElement.clientHeight");
}

$doc.title = summary + " [" + $doc.title + "]";
}

Expand Down
16 changes: 0 additions & 16 deletions user/src/com/google/gwt/dom/client/DOMImplWebkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@
*/
class DOMImplWebkit extends DOMImplStandardBase {

/**
* Return true if using Webkit 525.x (Safari 3) or earlier.
*
* @return true if using Webkit 525.x (Safari 3) or earlier.
*/
private static native boolean isWebkit525OrBefore() /*-{
var result = /safari\/([\d.]+)/.exec(navigator.userAgent.toLowerCase());
if (result) {
var version = (parseFloat(result[1]));
if (version < 526) {
return true;
}
}
return false;
}-*/;

/**
* Webkit events sometimes target the text node inside of the element instead
* of the element itself, so we need to get the parent of the text node.
Expand Down
65 changes: 0 additions & 65 deletions user/src/com/google/gwt/user/client/ui/impl/HyperlinkImplIE.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ public class UserAgentPropertyGenerator implements PropertyProviderGenerator {
* {@code UserAgent.gwt.xml}.
* <p>Note that the order of enums matter as the script selection is based on running
* these predicates in order and matching the first one that returns {@code true}.
* <p> Also note that, {@code docMode < 11} in predicates for older IEs exists to
* ensures we never choose them for IE11 (we know that they will not work for IE11).
*/
private enum UserAgent {
safari("return (ua.indexOf('webkit') != -1);"),
gecko1_8("return (ua.indexOf('gecko') != -1 || docMode >= 11);");
gecko1_8("return (ua.indexOf('gecko') != -1);");

private final String predicateBlock;

Expand Down Expand Up @@ -70,7 +68,6 @@ static void writeUserAgentPropertyJavaScript(SourceWriter body,

// write preamble
body.println("var ua = navigator.userAgent.toLowerCase();");
body.println("var docMode = $doc.documentMode;");

for (UserAgent userAgent : UserAgent.values()) {
// write only selected user agents
Expand Down
5 changes: 0 additions & 5 deletions user/super/com/google/gwt/emul/java/lang/Throwable.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,11 @@ private void setBackingJsObject(Object backingJsObject) {
}

private native void linkBack(Object error) /*-{
if (error instanceof Object) {
try {
// This may throw exception in strict mode.
error.__java$exception = this;
if (navigator.userAgent.toLowerCase().indexOf("msie") != -1 && $doc.documentMode < 9) {
return;
}
var throwable = this;
Object.defineProperties(error, {
cause: {
Expand Down
35 changes: 6 additions & 29 deletions user/test/com/google/gwt/dom/client/ElementTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,10 @@ public void execute() {
assertEquals(absLeft, elem.getAbsoluteLeft());
assertEquals(absTop, elem.getAbsoluteTop());

if (isIE6or7() && !doc.isCSS1Compat()) {
// In IE/quirk, the interior decorations are considered part of the
// width/height, so there's no need to account for them here.
assertEquals(absLeft + width, elem.getAbsoluteRight());
assertEquals(absTop + height, elem.getAbsoluteBottom());
} else {
assertEquals(absLeft + width + interiorDecorations,
elem.getAbsoluteRight());
assertEquals(absTop + height + interiorDecorations,
elem.getAbsoluteBottom());
}
assertEquals(absLeft + width + interiorDecorations,
elem.getAbsoluteRight());
assertEquals(absTop + height + interiorDecorations,
elem.getAbsoluteBottom());
}
});
}
Expand Down Expand Up @@ -338,12 +331,8 @@ public void testGetAbsolutePositionWhenBodyScrolled() {

// Ensure that the 'position:fixed' div's absolute position includes the
// body's scroll position.
//
// Don't do this on IE6/7, which doesn't support position:fixed.
if (!isIE6or7()) {
assertTrue(fixedDiv.getAbsoluteLeft() >= body.getScrollLeft());
assertTrue(fixedDiv.getAbsoluteTop() >= body.getScrollTop());
}
assertTrue(fixedDiv.getAbsoluteLeft() >= body.getScrollLeft());
assertTrue(fixedDiv.getAbsoluteTop() >= body.getScrollTop());
}

/**
Expand Down Expand Up @@ -751,16 +740,4 @@ public void testStyleCamelCase() {
private native JavaScriptObject createTrivialJSO() /*-{
return {};
}-*/;

// Stolen from UserAgentPropertyGenerator
private native boolean isIE6or7() /*-{
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf("msie") != -1) {
if ($doc.documentMode >= 8) {
return false;
}
return true;
}
return false;
}-*/;
}
11 changes: 1 addition & 10 deletions user/test/com/google/gwt/http/client/RequestBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ private static String getTestBaseURL() {
return GWT.getModuleBaseURL() + "testRequestBuilder/";
}

/**
* HACK: Part of a work around for IE's failure to throw an exception when an
* XmlHttpRequest that violates the same origin policy is made.
*/
private static native boolean isIE() /*-{
var ua = navigator.userAgent.toLowerCase();
return ua.indexOf("msie") != -1;
}-*/;

/**
* HACK: Part of a work around for Safari 2.0.4's failure to throw an
* exception when an XmlHttpRequest that violates the same origin policy is
Expand Down Expand Up @@ -138,7 +129,7 @@ public void onResponseReceived(Request request, Response response) {
}
});

if (isIE() || isSafari() || isFirefox35()) {
if (isSafari() || isFirefox35()) {
/*
* HACK: Safari 2.0.4 will not throw an exception for XHR's that violate
* the same-origin policy. It appears to silently ignore them so we do
Expand Down
19 changes: 0 additions & 19 deletions user/test/com/google/gwt/typedarrays/client/ClientSupportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ public String getModuleName() {
public void testSupported() {
boolean isSupported = TypedArrays.isSupported();
String ua = getUserAgent();
if (ua.contains("msie")) {
if (getIeDocumentMode() <= 9) {
assertFalse("IE9 and below do not support typed array", isSupported);
} else {
// TODO(dankurka) change this once we get type array support in for ie10
assertFalse("IE10 does support typed array, but GWT still uses old implementation",
isSupported);
}
return;
}
if (ua.contains("firefox/")) {
int idx = ua.indexOf("firefox/") + 8;
int endIdx = idx;
Expand All @@ -60,12 +50,6 @@ public void testSupported() {
return;
}

// IE11 - choosing the gecko permutation
if (ua.contains("trident/7.0")) {
assertTrue(isSupported);
return;
}

assertFalse("Unknown browser (" + ua + ") assumed not to support typed arrays",
isSupported);
}
Expand All @@ -74,7 +58,4 @@ private static native String getUserAgent() /*-{
return navigator.userAgent.toLowerCase();
}-*/;

private static native int getIeDocumentMode() /*-{
return $doc.documentMode || 0;
}-*/;
}

0 comments on commit 2ec0134

Please sign in to comment.