8000 Store frames to guest as Map by kevinsawicki · Pull Request #9287 · electron/electron · GitHub
[go: up one dir, main page]

Skip to content
8000

Store frames to guest as Map #9287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/browser/guest-window-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {isSameOrigin} = process.atomBinding('v8_util')
const parseFeaturesString = require('../common/parse-features-string')

const hasProp = {}.hasOwnProperty
const frameToGuest = {}
const frameToGuest = new Map()

// Copy attribute of |parent| to |child| if it is not defined in |child|.
const mergeOptions = function (child, parent, visited) {
Expand Down Expand Up @@ -92,18 +92,18 @@ const setupGuest = function (embedder, frameName, guest, options) {
guest.once('closed', closedByUser)
}
if (frameName) {
frameToGuest[frameName] = guest
frameToGuest.set(frameName, guest)
guest.frameName = frameName
guest.once('closed', function () {
delete frameToGuest[frameName]
frameToGuest.delete(frameName)
})
}
return guestId
}

// Create a new guest created by |embedder| with |options|.
const createGuest = function (embedder, url, frameName, options, postData) {
let guest = frameToGuest[frameName]
let guest = frameToGuest.get(frameName)
if (frameName && (guest != null)) {
guest.loadURL(url)
return guest.webContents.id
Expand Down
20 changes: 20 additions & 0 deletions spec/chromium-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,26 @@ describe('chromium feature', function () {
window.open('', '', {toString: 3})
}, /Cannot convert object to primitive value/)
})

it('sets the window title to the specified frameName', function (done) {
let b
app.once('browser-window-created', (event, createdWindow) => {
assert.equal(createdWindow.getTitle(), 'hello')
b.close()
done()
})
b = window.open('', 'hello')
})

it('does not throw an exception when the frameName is a built-in object property', function (done) {
let b
app.once('browser-window-created', (event, createdWindow) => {
assert.equal(createdWindow.getTitle(), '__proto__')
b.close()
done()
})
b = window.open('', '__proto__')
})
})

describe('window.opener', function () {
Expand Down
0