Skip to content

Commit

Permalink
Add generic options object to App init (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
divyaashritha authored Jun 3, 2020
1 parent dc83b09 commit 8bc080f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Next Release
-------------
1.9.0
------
* Add generic options object to App init. #46

1.8.1
------
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ XFC.Provider.init({
})
```

If the app wants to transmit details to frame after authorization, it may pass in an options object.

```js
XFC.Provider.init({
acls: ['*'],
options: { moreDetail: 'detail' }
})
```

### Launching Fullscreen
An application may request to launch a pagelet fullscreen within the consumer application.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xfc",
"version": "1.8.1",
"version": "1.9.0",
"description": "A Cross Frame Container that handles securely embedding web content into a 3rd party domain",
"author": "Cerner Corporation",
"license": "Apache-2.0",
Expand Down
7 changes: 5 additions & 2 deletions src/provider/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ class Application extends EventEmitter {
* @param options.targetSelectors A DOMString containing one or more selectors to match against.
* This string must be a valid CSS selector string; if it's not,
* a SyntaxError exception is thrown.
* @param options.options An optional object used for App to transmit details to frame
* after App is authorized.
*/
init({ acls = [], secret = null, onReady = null, targetSelectors = '' }) {
init({ acls = [], secret = null, onReady = null, targetSelectors = '', options = {} }) {
this.acls = [].concat(acls);
this.secret = secret;
this.options = options;
this.onReady = onReady;
this.targetSelectors = targetSelectors;
this.resizeConfig = null;
Expand Down Expand Up @@ -251,7 +254,7 @@ class Application extends EventEmitter {

// Emit a ready event
this.emit('xfc.ready');
this.JSONRPC.notification('authorized', [{ url: window.location.href }]);
this.JSONRPC.notification('authorized', [{ url: window.location.href, options: this.options }]);

// If there is an onReady callback, execute it
if (typeof this.onReady === 'function') {
Expand Down
12 changes: 11 additions & 1 deletion test/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,17 @@ describe('Application', () => {
const notification = this.stub(application.JSONRPC, 'notification');
application.authorizeConsumer();

sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href }]);
sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: {} }]);
}));

it("calls this.JSONRPC.notification of 'authorized' with current url and generic options object", sinon.test(function() {
const options = { moreDetail: 'detail' }
const application = new Application();
application.init({options});
const notification = this.stub(application.JSONRPC, 'notification');
application.authorizeConsumer();

sinon.assert.calledWith(notification, 'authorized', [{ url: window.location.href, options: { moreDetail: 'detail'} }]);
}));

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

0 comments on commit 8bc080f

Please sign in to comment.