From 2ec01342d456828078115ea534e9c9309821220d Mon Sep 17 00:00:00 2001 From: Colin Alworth Date: Tue, 29 Oct 2024 09:46:46 -0500 Subject: [PATCH] Remove all user agent checks for MSIE or documentMode (#10014) 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. --- .../gwt/core/ext/linker/impl/devmode.js | 11 ---- .../gwt/core/ext/linker/impl/hosted.html | 11 ---- .../google/gwt/dom/client/DOMImplWebkit.java | 16 ----- .../user/client/ui/impl/HyperlinkImplIE.java | 65 ------------------- .../rebind/UserAgentPropertyGenerator.java | 5 +- .../google/gwt/emul/java/lang/Throwable.java | 5 -- .../google/gwt/dom/client/ElementTest.java | 35 ++-------- .../gwt/http/client/RequestBuilderTest.java | 11 +--- .../typedarrays/client/ClientSupportTest.java | 19 ------ 9 files changed, 8 insertions(+), 170 deletions(-) delete mode 100644 user/src/com/google/gwt/user/client/ui/impl/HyperlinkImplIE.java diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/devmode.js b/dev/core/src/com/google/gwt/core/ext/linker/impl/devmode.js index c6e4c59104b..89b8b562fe1 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/devmode.js +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/devmode.js @@ -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 + "]"; } diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html b/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html index 81d6943d739..fdc33b55c0a 100644 --- a/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html +++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/hosted.html @@ -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 + "]"; } diff --git a/user/src/com/google/gwt/dom/client/DOMImplWebkit.java b/user/src/com/google/gwt/dom/client/DOMImplWebkit.java index 8433a5bb117..ebcdb3eb8fc 100644 --- a/user/src/com/google/gwt/dom/client/DOMImplWebkit.java +++ b/user/src/com/google/gwt/dom/client/DOMImplWebkit.java @@ -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. diff --git a/user/src/com/google/gwt/user/client/ui/impl/HyperlinkImplIE.java b/user/src/com/google/gwt/user/client/ui/impl/HyperlinkImplIE.java deleted file mode 100644 index 42e83a3d32f..00000000000 --- a/user/src/com/google/gwt/user/client/ui/impl/HyperlinkImplIE.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2008 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -package com.google.gwt.user.client.ui.impl; - -import com.google.gwt.user.client.Event; - -/** - * IE version of HyperlinkImpl. IE6 and IE7 actually have different - * behavior; both have special behavior for shift-click, but IE7 also opens - * in a new tab on ctrl-click. IE6 treats ctrl-click as a standard click. - */ -public class HyperlinkImplIE extends HyperlinkImpl { - - private static boolean ctrlisModifier = (getInternetExplorerVersion() >= 7); - - /** - * Returns the version of Internet Explorer or a -1, (indicating the use of - * another browser). Based on code from MSDN. - * http://msdn2.microsoft.com/en-us/library/ms537509.aspx - */ - private static native int getInternetExplorerVersion() /*-{ - var rv = -1; // Assume that we're not IE. - - if (navigator.appName == 'Microsoft Internet Explorer') { - var ua = navigator.userAgent; - var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); - if (re.exec(ua) != null) - rv = parseFloat( RegExp.$1 ); - } - - return rv; - }-*/; - - @Override - public boolean handleAsClick(Event event) { - int mouseButtons = event.getButton(); - boolean ctrl = event.getCtrlKey(); - boolean shift = event.getShiftKey(); - boolean middle = mouseButtons == Event.BUTTON_MIDDLE; - boolean right = mouseButtons == Event.BUTTON_RIGHT; - boolean modifiers; - - if (ctrlisModifier) { - modifiers = shift || ctrl; - } else { - modifiers = shift; - } - - return !modifiers && !middle && !right; - } -} diff --git a/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java b/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java index c7d3bd6311e..71546be029b 100644 --- a/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java +++ b/user/src/com/google/gwt/useragent/rebind/UserAgentPropertyGenerator.java @@ -37,12 +37,10 @@ public class UserAgentPropertyGenerator implements PropertyProviderGenerator { * {@code UserAgent.gwt.xml}. *

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}. - *

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; @@ -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 diff --git a/user/super/com/google/gwt/emul/java/lang/Throwable.java b/user/super/com/google/gwt/emul/java/lang/Throwable.java index 1492bb0f003..dca97d0ca14 100644 --- a/user/super/com/google/gwt/emul/java/lang/Throwable.java +++ b/user/super/com/google/gwt/emul/java/lang/Throwable.java @@ -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: { diff --git a/user/test/com/google/gwt/dom/client/ElementTest.java b/user/test/com/google/gwt/dom/client/ElementTest.java index 717448b7a9b..b476824733f 100644 --- a/user/test/com/google/gwt/dom/client/ElementTest.java +++ b/user/test/com/google/gwt/dom/client/ElementTest.java @@ -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()); } }); } @@ -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()); } /** @@ -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; - }-*/; } diff --git a/user/test/com/google/gwt/http/client/RequestBuilderTest.java b/user/test/com/google/gwt/http/client/RequestBuilderTest.java index 5eeb801bcbe..ca84829ca46 100644 --- a/user/test/com/google/gwt/http/client/RequestBuilderTest.java +++ b/user/test/com/google/gwt/http/client/RequestBuilderTest.java @@ -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 @@ -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 diff --git a/user/test/com/google/gwt/typedarrays/client/ClientSupportTest.java b/user/test/com/google/gwt/typedarrays/client/ClientSupportTest.java index 8033fc93f90..d34fed20613 100644 --- a/user/test/com/google/gwt/typedarrays/client/ClientSupportTest.java +++ b/user/test/com/google/gwt/typedarrays/client/ClientSupportTest.java @@ -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; @@ -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); } @@ -74,7 +58,4 @@ private static native String getUserAgent() /*-{ return navigator.userAgent.toLowerCase(); }-*/; - private static native int getIeDocumentMode() /*-{ - return $doc.documentMode || 0; - }-*/; }