use of com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException in project htmlunit by HtmlUnit.
the class HTMLMediaElement method play.
/**
* Begins playback of the media.
*
* @return a {@link Promise} which is fulfilled when playback has been started,
* or is rejected if for any reason playback cannot be started
*/
@JsxFunction
public Object play() {
if (getBrowserVersion().hasFeature(JS_PROMISE)) {
final Scriptable scope = ScriptableObject.getTopLevelScope(this);
final LambdaConstructor ctor = (LambdaConstructor) getProperty(scope, "Promise");
final LambdaFunction reject = (LambdaFunction) getProperty(ctor, "reject");
return reject.call(Context.getCurrentContext(), this, ctor, new Object[] { new DOMException("HtmlUnit does not support media play().", DOMException.NOT_FOUND_ERR) });
}
return Undefined.instance;
}
use of com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException in project htmlunit by HtmlUnit.
the class XMLDocument method loadXML.
/**
* Loads an XML document using the supplied string.
*
* @param strXML A string containing the XML string to load into this XML document object
* This string can contain an entire XML document or a well-formed fragment.
* @return true if the load succeeded; false if the load failed
*/
public boolean loadXML(final String strXML) {
final WebWindow webWindow = getWindow().getWebWindow();
try {
if (StringUtils.isEmpty(strXML) && getBrowserVersion().hasFeature(JS_DOMPARSER_EMPTY_STRING_IS_ERROR)) {
throw new IOException("Error parsing XML '" + strXML + "'");
}
final WebResponse webResponse = new StringWebResponse(strXML, webWindow.getEnclosedPage().getUrl());
final XmlPage page = new XmlPage(webResponse, webWindow, false);
setDomNode(page);
return true;
} catch (final IOException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Error parsing XML\n" + strXML, e);
}
if (getBrowserVersion().hasFeature(JS_DOMPARSER_EXCEPTION_ON_ERROR)) {
throw asJavaScriptException(new DOMException("Syntax Error", DOMException.SYNTAX_ERR));
}
if (getBrowserVersion().hasFeature(JS_DOMPARSER_PARSERERROR_ON_ERROR)) {
try {
final XmlPage page = createParserErrorXmlPage("Syntax Error", webWindow);
setDomNode(page);
} catch (final IOException eI) {
LOG.error("Could not handle ParserError", e);
}
}
return false;
}
}
use of com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException in project htmlunit by HtmlUnit.
the class MediaDevices method getUserMedia.
@JsxFunction
public Object getUserMedia() {
final Scriptable scope = ScriptableObject.getTopLevelScope(this);
final LambdaConstructor ctor = (LambdaConstructor) getProperty(scope, "Promise");
final LambdaFunction reject = (LambdaFunction) getProperty(ctor, "reject");
return reject.call(Context.getCurrentContext(), this, ctor, new Object[] { new DOMException("HtmlUnit does not support media streaming.", DOMException.NOT_FOUND_ERR) });
}
use of com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException in project htmlunit by HtmlUnit.
the class SubtleCrypto method notImplemented.
private Object notImplemented() {
final Scriptable scope = ScriptableObject.getTopLevelScope(this);
final LambdaConstructor ctor = (LambdaConstructor) getProperty(scope, "Promise");
final LambdaFunction reject = (LambdaFunction) getProperty(ctor, "reject");
return reject.call(Context.getCurrentContext(), this, ctor, new Object[] { new DOMException("Operation is not supported", DOMException.NOT_SUPPORTED_ERR) });
}
Aggregations