From: <rb...@us...> - 2018-04-14 17:32:41
|
Revision: 15237 http://sourceforge.net/p/htmlunit/code/15237 Author: rbri Date: 2018-04-14 17:32:36 +0000 (Sat, 14 Apr 2018) Log Message: ----------- use a different rhino language level for the IE we have removed a HtmlUnit feature from our Rhino fork, because this is no longer required Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/HtmlUnitContextFactory.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeObjectTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/HtmlUnitContextFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/HtmlUnitContextFactory.java 2018-04-14 11:46:24 UTC (rev 15236) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/HtmlUnitContextFactory.java 2018-04-14 17:32:36 UTC (rev 15237) @@ -19,8 +19,8 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ENUM_NUMBERS_FIRST; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ERROR_STACK; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FUNCTION_DECLARED_FORWARD_IN_BLOCK; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_PROTOTYPE_OF_STRING; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_IGNORES_LAST_LINE_CONTAINING_UNCOMMENTED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_PRE_WIDTH_STRING; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_PROPERTY_DESCRIPTOR_NAME; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_PROPERTY_DESCRIPTOR_NEW_LINE; @@ -267,7 +267,12 @@ @Override protected Context makeContext() { final TimeoutContext cx = new TimeoutContext(this); - cx.setLanguageVersion(Context.VERSION_ES6); + if (browserVersion_.hasFeature(JS_PRE_WIDTH_STRING)) { + cx.setLanguageVersion(Context.VERSION_1_8); + } + else { + cx.setLanguageVersion(Context.VERSION_ES6); + } // Use pure interpreter mode to get observeInstructionCount() callbacks. cx.setOptimizationLevel(-1); @@ -344,8 +349,6 @@ return browserVersion_.hasFeature(JS_FUNCTION_DECLARED_FORWARD_IN_BLOCK); case Context.FEATURE_HTMLUNIT_ENUM_NUMBERS_FIRST: return browserVersion_.hasFeature(JS_ENUM_NUMBERS_FIRST); - case Context.FEATURE_HTMLUNIT_GET_PROTOTYPE_OF_STRING: - return browserVersion_.hasFeature(JS_GET_PROTOTYPE_OF_STRING); case Context.FEATURE_HTMLUNIT_MEMBERBOX_NAME: return browserVersion_.hasFeature(JS_PROPERTY_DESCRIPTOR_NAME); case Context.FEATURE_HTMLUNIT_MEMBERBOX_NEWLINE: Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeObjectTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeObjectTest.java 2018-04-14 11:46:24 UTC (rev 15236) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeObjectTest.java 2018-04-14 17:32:36 UTC (rev 15237) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript; -import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.FF; import static com.gargoylesoftware.htmlunit.BrowserRunner.TestedBrowser.IE; @@ -239,15 +238,15 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "", + @Alerts(DEFAULT = "true", IE = "exception") - public void getPrototypeOf() throws Exception { + public void getPrototypeOfString() throws Exception { final String html = "" + "<html><head>\n" + "<script>\n" + " function test() {\n" + " try {\n" - + " alert(Object.getPrototypeOf(''));\n" + + " alert(String.prototype === Object.getPrototypeOf(''));\n" + " } catch(e) {alert('exception')}\n" + " }\n" + "</script>\n" @@ -262,7 +261,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "0", + @Alerts(DEFAULT = "true", IE = "exception") public void getPrototypeOfNumber() throws Exception { final String html = "" @@ -270,7 +269,7 @@ + "<script>\n" + " function test() {\n" + " try {\n" - + " alert(Object.getPrototypeOf(1));\n" + + " alert(Number.prototype === Object.getPrototypeOf(1));\n" + " } catch(e) {alert('exception')}\n" + " }\n" + "</script>\n" @@ -285,9 +284,31 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "true", + IE = "exception") + public void getPrototypeOfBoolean() throws Exception { + final String html = "" + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " try {\n" + + " alert(Boolean.prototype === Object.getPrototypeOf(true));\n" + + " } catch(e) {alert('exception')}\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = "object", IE = "exception") - @NotYetImplemented({CHROME, FF}) public void getTypeOfPrototypeOfNumber() throws Exception { final String html = "" + "<html><head>\n" |