Search in sources :

Example 1 with WindowProxy

use of com.gargoylesoftware.htmlunit.javascript.host.WindowProxy in project htmlunit by HtmlUnit.

the class MessageEvent method jsConstructor.

/**
 * JavaScript constructor.
 *
 * @param type the event type
 * @param details the event details (optional)
 */
@Override
@JsxConstructor({ CHROME, EDGE, FF, FF_ESR })
public void jsConstructor(final String type, final ScriptableObject details) {
    super.jsConstructor(type, details);
    if (getBrowserVersion().hasFeature(EVENT_ONMESSAGE_DEFAULT_DATA_NULL)) {
        data_ = null;
    }
    String origin = "";
    String lastEventId = "";
    if (details != null && !Undefined.isUndefined(details)) {
        data_ = details.get("data");
        final String detailOrigin = (String) details.get(HttpHeader.ORIGIN_LC);
        if (detailOrigin != null) {
            origin = detailOrigin;
        }
        final Object detailLastEventId = details.get("lastEventId");
        if (detailLastEventId != null) {
            lastEventId = Context.toString(detailLastEventId);
        }
        source_ = null;
        final Object detailSource = details.get("source");
        if (detailSource instanceof Window) {
            source_ = (Window) detailSource;
        } else if (detailSource instanceof WindowProxy) {
            source_ = ((WindowProxy) detailSource).getDelegee();
        }
        ports_ = details.get("ports");
    }
    origin_ = origin;
    lastEventId_ = lastEventId;
}
Also used : Window(com.gargoylesoftware.htmlunit.javascript.host.Window) WindowProxy(com.gargoylesoftware.htmlunit.javascript.host.WindowProxy) ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) JsxConstructor(com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor)

Aggregations

JsxConstructor (com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor)1 Window (com.gargoylesoftware.htmlunit.javascript.host.Window)1 WindowProxy (com.gargoylesoftware.htmlunit.javascript.host.WindowProxy)1 ScriptableObject (net.sourceforge.htmlunit.corejs.javascript.ScriptableObject)1