1.1 --- a/json-tck/src/main/java/net/java/html/js/tests/JavaScriptBodyTest.java Tue Jan 14 16:14:08 2014 +0100
1.2 +++ b/json-tck/src/main/java/net/java/html/js/tests/JavaScriptBodyTest.java Mon Jan 20 11:02:01 2014 +0100
1.3 @@ -42,8 +42,10 @@
1.4 */
1.5 package net.java.html.js.tests;
1.6
1.7 +import java.io.StringReader;
1.8 import java.util.Arrays;
1.9 import java.util.concurrent.Callable;
1.10 +import org.apidesign.html.boot.spi.Fn;
1.11 import org.apidesign.html.json.tck.KOTest;
1.12
1.13 /**
1.14 @@ -272,6 +274,18 @@
1.15 assert r == 6 : "Sum is six: " + r;
1.16 }
1.17
1.18 + @KOTest public void callLater() throws Exception{
1.19 + Fn.activePresenter().loadScript(new StringReader(
1.20 + "if (typeof window === 'undefined') window = {};"
1.21 + ));
1.22 + Later l = new Later();
1.23 + l.register();
1.24 + Fn.activePresenter().loadScript(new StringReader(
1.25 + "window.later();"
1.26 + ));
1.27 + assert l.call == 42 : "Method was called: " + l.call;
1.28 + }
1.29 +
1.30 private static class R implements Runnable {
1.31 int cnt;
1.32 private final Thread initThread;
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/json-tck/src/main/java/net/java/html/js/tests/Later.java Mon Jan 20 11:02:01 2014 +0100
2.3 @@ -0,0 +1,65 @@
2.4 +/*
2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2.6 + *
2.7 + * Copyright 2014 Oracle and/or its affiliates. All rights reserved.
2.8 + *
2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
2.10 + * Other names may be trademarks of their respective owners.
2.11 + *
2.12 + * The contents of this file are subject to the terms of either the GNU
2.13 + * General Public License Version 2 only ("GPL") or the Common
2.14 + * Development and Distribution License("CDDL") (collectively, the
2.15 + * "License"). You may not use this file except in compliance with the
2.16 + * License. You can obtain a copy of the License at
2.17 + * http://www.netbeans.org/cddl-gplv2.html
2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
2.19 + * specific language governing permissions and limitations under the
2.20 + * License. When distributing the software, include this License Header
2.21 + * Notice in each file and include the License file at
2.22 + * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
2.23 + * particular file as subject to the "Classpath" exception as provided
2.24 + * by Oracle in the GPL Version 2 section of the License file that
2.25 + * accompanied this code. If applicable, add the following below the
2.26 + * License Header, with the fields enclosed by brackets [] replaced by
2.27 + * your own identifying information:
2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
2.29 + *
2.30 + * If you wish your version of this file to be governed by only the CDDL
2.31 + * or only the GPL Version 2, indicate your decision by adding
2.32 + * "[Contributor] elects to include this software in this distribution
2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
2.34 + * single choice of license, a recipient has the option to distribute
2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
2.36 + * to extend the choice of license to its licensees as provided above.
2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
2.38 + * Version 2 license, then the option applies only if the new code is
2.39 + * made subject to such option by the copyright holder.
2.40 + *
2.41 + * Contributor(s):
2.42 + *
2.43 + * Portions Copyrighted 2014 Sun Microsystems, Inc.
2.44 + */
2.45 +
2.46 +package net.java.html.js.tests;
2.47 +
2.48 +import net.java.html.js.JavaScriptBody;
2.49 +
2.50 +/**
2.51 + *
2.52 + * @author Jaroslav Tulach <jtulach@netbeans.org>
2.53 + */
2.54 +public final class Later {
2.55 + int call;
2.56 +
2.57 + @JavaScriptBody(args = { }, javacall = true, body =
2.58 + "var self = this;"
2.59 + + "window.later = function() {"
2.60 + + " self.@net.java.html.js.tests.Later::call(I)(42);"
2.61 + + "};"
2.62 + )
2.63 + native void register();
2.64 +
2.65 + void call(int value) {
2.66 + this.call = value;
2.67 + }
2.68 +}