Remove Frame.isMainFrame()

This patch removes redundant frame.isMainFrame() method. The suggested
way to check for main frame is:

```js
frame === page.mainFrame()
```

Fixes #120.
This commit is contained in:
Andrey Lushnikov 2017-07-24 21:25:54 -07:00
parent 91cbe561ba
commit 236acec228
2 changed files with 1 additions and 14 deletions

View File

@ -87,7 +87,6 @@
+ [frame.evaluate(pageFunction, ...args)](#frameevaluatepagefunction-args) + [frame.evaluate(pageFunction, ...args)](#frameevaluatepagefunction-args)
+ [frame.hover(selector)](#framehoverselector) + [frame.hover(selector)](#framehoverselector)
+ [frame.isDetached()](#frameisdetached) + [frame.isDetached()](#frameisdetached)
+ [frame.isMainFrame()](#frameismainframe)
+ [frame.name()](#framename) + [frame.name()](#framename)
+ [frame.parentFrame()](#frameparentframe) + [frame.parentFrame()](#frameparentframe)
+ [frame.url()](#frameurl) + [frame.url()](#frameurl)
@ -837,11 +836,6 @@ browser.newPage().then(async page =>
Returns `true` if the frame has being detached, or `false` otherwise. Returns `true` if the frame has being detached, or `false` otherwise.
#### frame.isMainFrame()
- returns: <[boolean]>
Returns `true` is the frame is page's main frame, or `false` otherwise.
#### frame.name() #### frame.name()
- returns: <[string]> - returns: <[string]>

View File

@ -162,7 +162,7 @@ class FrameManager extends EventEmitter {
*/ */
async _evaluateOnFrame(frame, expression) { async _evaluateOnFrame(frame, expression) {
let contextId = undefined; let contextId = undefined;
if (!frame.isMainFrame()) { if (frame !== this._mainFrame) {
contextId = this._frameIdToExecutionContextId.get(frame._id); contextId = this._frameIdToExecutionContextId.get(frame._id);
console.assert(contextId, 'Frame does not have default context to evaluate in!'); console.assert(contextId, 'Frame does not have default context to evaluate in!');
} }
@ -244,13 +244,6 @@ class Frame {
return Array.from(this._childFrames); return Array.from(this._childFrames);
} }
/**
* @return {boolean}
*/
isMainFrame() {
return !this._detached && !this._parentFrame;
}
/** /**
* @return {boolean} * @return {boolean}
*/ */