# HG changeset patch # User Jaroslav Tulach # Date 1417360887 -3600 # Node ID 5ab1cb07a530d239089ad4105ec3a80496ea60cc # Parent 212379f827b61b819e71b7631f7ae0d97f7bfe61 Better to not do any processign as '...*/*...' string can break our simple check. Keep comments in and let obfuscator remove them diff -r 212379f827b6 -r 5ab1cb07a530 rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java --- a/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java Thu Nov 27 20:31:17 2014 +0100 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/vmtest/impl/HtmlAnnotationsTest.java Sun Nov 30 16:21:27 2014 +0100 @@ -31,7 +31,7 @@ private void assertMulNotDefinedForTheFirstTime() { if (firstCheck++ == 0) { - Object mul = windowMul(); + Object mul = window("mul"); assert mul == null : "htmlannotations.js should not be processed before first call to HtmlAnnotations class"; } } @@ -70,6 +70,14 @@ assertEquals(HtmlAnnotations.onError(instance, 42.0), 42.0); } + @BrwsrTest public void quotedStar() throws Exception { + assertMulNotDefinedForTheFirstTime(); + HtmlAnnotations.empty(); + Object fn = window("all"); + String msg = invoke(fn); + assert "*/*".equals(msg) : "String '*/*' as expected: " + msg; + } + private static void assertEquals(double real, double exp) { if (real - exp < 0.01) { return; @@ -81,8 +89,10 @@ assert obj != null : msg; } - @JavaScriptBody(args = {}, body = "return window.mul ? window.mul : null;") - private static native Object windowMul(); + @JavaScriptBody(args = { "n" }, body = "return window[n] ? window[n] : null;") + private static native Object window(String name); + @JavaScriptBody(args = { "fn" }, body = "return fn();") + private static native String invoke(Object fn); @Factory public static Object[] create() { return VMTest.create(HtmlAnnotationsTest.class); diff -r 212379f827b6 -r 5ab1cb07a530 rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js --- a/rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js Thu Nov 27 20:31:17 2014 +0100 +++ b/rt/emul/compacttest/src/test/resources/org/apidesign/bck2brwsr/vmtest/impl/htmlannotations.js Sun Nov 30 16:21:27 2014 +0100 @@ -17,4 +17,6 @@ */ function mul(x, y) { return x * y; } +function all() { return '*/*'; } window.mul = mul; +window.all = all; diff -r 212379f827b6 -r 5ab1cb07a530 rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Thu Nov 27 20:31:17 2014 +0100 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/VM.java Sun Nov 30 16:21:27 2014 +0100 @@ -263,7 +263,9 @@ if (emul == null) { throw new IOException("Can't find " + resource); } + append("\n// resource from ").append(resource).append("\n"); readResource(emul, this); + append("\n"); } private static void readResource(InputStream emul, Appendable out) throws IOException { @@ -277,35 +279,7 @@ if (ch < 0 || ch > 255) { throw new IOException("Invalid char in emulation " + ch); } - switch (state) { - case 0: - if (ch == '/') { - state = 1; - } else { - out.append((char)ch); - } - break; - case 1: - if (ch == '*') { - state = 2; - } else { - out.append('/').append((char)ch); - state = 0; - } - break; - case 2: - if (ch == '*') { - state = 3; - } - break; - case 3: - if (ch == '/') { - state = 0; - } else { - state = 2; - } - break; - } + out.append((char)ch); } } finally { emul.close();