Throw custom error when WebView API is unavailable
This commit is contained in:
parent
6bc48ba123
commit
8cacd0b931
2 changed files with 8 additions and 5 deletions
|
@ -404,10 +404,13 @@ var registerWebViewElement = function() {
|
||||||
// Forward proto.foo* method calls to WebViewImpl.foo*.
|
// Forward proto.foo* method calls to WebViewImpl.foo*.
|
||||||
createBlockHandler = function(m) {
|
createBlockHandler = function(m) {
|
||||||
return function() {
|
return function() {
|
||||||
var args, internal, ref1;
|
var args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
var internal = v8Util.getHiddenValue(this, 'internal');
|
||||||
internal = v8Util.getHiddenValue(this, 'internal');
|
if (internal.webContents) {
|
||||||
return (ref1 = internal.webContents)[m].apply(ref1, args);
|
return internal.webContents[m].apply(internal.webContents, args);
|
||||||
|
} else {
|
||||||
|
throw new Error('Cannot call ' + m + ' before the dom-ready event is emitted')
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
for (i = 0, len = methods.length; i < len; i++) {
|
for (i = 0, len = methods.length; i < len; i++) {
|
||||||
|
|
|
@ -570,7 +570,7 @@ describe('<webview> tag', function() {
|
||||||
readyError = error;
|
readyError = error;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.equal(readyError.message, 'stop can only be called after the dom-ready event is emitted');
|
assert.equal(readyError.message, 'Cannot call stop before the dom-ready event is emitted');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue