Skip to content

Commit 8bc080f

Browse files
Add generic options object to App init (#46)
1 parent dc83b09 commit 8bc080f

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Next Release
22
-------------
3+
1.9.0
4+
------
5+
* Add generic options object to App init. #46
36

47
1.8.1
58
------

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ XFC.Provider.init({
218218
})
219219
```
220220

221+
If the app wants to transmit details to frame after authorization, it may pass in an options object.
222+
223+
```js
224+
XFC.Provider.init({
225+
acls: ['*'],
226+
options: { moreDetail: 'detail' }
227+
})
228+
```
229+
221230
### Launching Fullscreen
222231
An application may request to launch a pagelet fullscreen within the consumer application.
223232

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "xfc",
3-
"version": "1.8.1",
3+
"version": "1.9.0",
44
"description": "A Cross Frame Container that handles securely embedding web content into a 3rd party domain",
55
"author": "Cerner Corporation",
66
"license": "Apache-2.0",

src/provider/application.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ class Application extends EventEmitter {
1616
* @param options.targetSelectors A DOMString containing one or more selectors to match against.
1717
* This string must be a valid CSS selector string; if it's not,
1818
* a SyntaxError exception is thrown.
19+
* @param options.options An optional object used for App to transmit details to frame
20+
* after App is authorized.
1921
*/
20-
init({ acls = [], secret = null, onReady = null, targetSelectors = '' }) {
22+
init({ acls = [], secret = null, onReady = null, targetSelectors = '', options = {} }) {
2123
this.acls = [].concat(acls);
2224
this.secret = secret;
25+
this.options = options;
2326
this.onReady = onReady;
2427
this.targetSelectors = targetSelectors;
2528
this.resizeConfig = null;
@@ -251,7 +254,7 @@ class Application extends EventEmitter {
251254

252255
// Emit a ready event
253256
this.emit('xfc.ready');
254-
this.JSONRPC.notification('authorized', [{ url: window.location.href }]);
257+
this.JSONRPC.notification('authorized', [{ url: window.location.href, options: this.options }]);
255258

256259
// If there is an onReady callback, execute it
257260
if (typeof this.onReady === 'function') {

test/application.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,17 @@ describe('Application', () => {
209209
const notification = this.stub(application.JSONRPC, 'notification');
210210
application.authorizeConsumer();
211211

212-
sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href }]);
212+
sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: {} }]);
213+
}));
214+
215+
it("calls this.JSONRPC.notification of 'authorized' with current url and generic options object", sinon.test(function() {
216+
const options = { moreDetail: 'detail' }
217+
const application = new Application();
218+
application.init({options});
219+
const notification = this.stub(application.JSONRPC, 'notification');
220+
application.authorizeConsumer();
221+
222+
sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: { moreDetail: 'detail'} }]);
213223
}));
214224

215225
it("calls this.onReady if onReady is a function", () => {

0 commit comments

Comments
 (0)