@atlassian/atlassian-connect-js 5.3.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.depcheckrc.json +16 -0
- package/.editorconfig +9 -0
- package/.envrc +5 -0
- package/.eslintignore +12 -0
- package/.eslintrc +31 -0
- package/.husky/pre-commit +11 -0
- package/.lintstagedrc.js +6 -0
- package/.netrc +1 -0
- package/.npmrc-public +4 -0
- package/.nvmrc +1 -0
- package/LICENSE +3 -0
- package/README.md +281 -0
- package/bitbucket-pipelines.yml +33 -0
- package/build/bin/bin-helper.js +29 -0
- package/build/bin/npm-postinstall.js +9 -0
- package/build/configs/append-sourcemapping.js +13 -0
- package/build/configs/availabletasks.js +15 -0
- package/build/configs/clean.js +12 -0
- package/build/configs/concat.js +44 -0
- package/build/configs/copy.js +32 -0
- package/build/configs/index.js +19 -0
- package/build/configs/jshint.js +9 -0
- package/build/configs/karma.js +11 -0
- package/build/configs/replace.js +10 -0
- package/build/configs/requirejs.js +187 -0
- package/build/configs/saucelabs-launchers.js +30 -0
- package/build/configs/shell.js +24 -0
- package/build/configs/uglify.js +15 -0
- package/build/configs/watch.js +45 -0
- package/build/end.frag +13 -0
- package/build/start.frag +18 -0
- package/bundlesize.config.json +14 -0
- package/dist/connect-host.css +225 -0
- package/dist/connect-host.js +13908 -0
- package/dist/connect-host.min.css +1 -0
- package/dist/iframe-fedramp.js +13663 -0
- package/dist/iframe.js +13663 -0
- package/dist/legacy-text-colors.css +245 -0
- package/dist/surfaces.css +11 -0
- package/dist/themes/atlaskit-tokens_dark-future.css +6 -0
- package/dist/themes/atlaskit-tokens_dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-dark.css +394 -0
- package/dist/themes/atlaskit-tokens_legacy-light.css +394 -0
- package/dist/themes/atlaskit-tokens_light-future.css +6 -0
- package/dist/themes/atlaskit-tokens_light.css +394 -0
- package/dist/themes/atlaskit-tokens_shape.css +14 -0
- package/dist/themes/atlaskit-tokens_spacing.css +26 -0
- package/dist/themes/atlaskit-tokens_typography-adg3.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-modernized.css +25 -0
- package/dist/themes/atlaskit-tokens_typography-refreshed.css +25 -0
- package/gulpfile.js +204 -0
- package/memleak-check/app.html +10 -0
- package/memleak-check/index.html +31 -0
- package/memleak-check/index.js +33 -0
- package/package.json +102 -0
- package/renovate.json +11 -0
- package/security-assistant.yml +2 -0
- package/spec/.eslintrc +10 -0
- package/spec/config/karma.base.conf.js +200 -0
- package/spec/config/karma.conf.js +20 -0
- package/spec/fixtures/base_dialog_component_tests.js +180 -0
- package/spec/mocks/mock_feature_flag.js +23 -0
- package/spec/tests/amd_spec.js +122 -0
- package/spec/tests/analytics_dispatcher_spec.js +429 -0
- package/spec/tests/analytics_performance_spec.js +41 -0
- package/spec/tests/button_spec.js +143 -0
- package/spec/tests/dialog_extension_spec.js +59 -0
- package/spec/tests/dialog_module_provider_spec.js +499 -0
- package/spec/tests/dialog_module_spec.js +395 -0
- package/spec/tests/dialog_spec.js +296 -0
- package/spec/tests/dialog_webitem_spec.js +183 -0
- package/spec/tests/dropdown_module_spec.js +77 -0
- package/spec/tests/env_module_spec.js +153 -0
- package/spec/tests/events_spec.js +77 -0
- package/spec/tests/extension_configuration_options_store_spec.js +25 -0
- package/spec/tests/flag_module_provider_spec.js +79 -0
- package/spec/tests/flag_module_spec.js +118 -0
- package/spec/tests/flag_spec.js +243 -0
- package/spec/tests/host-api_spec.js +220 -0
- package/spec/tests/iframe-create_spec.js +43 -0
- package/spec/tests/iframe_container_spec.js +19 -0
- package/spec/tests/iframe_spec.js +265 -0
- package/spec/tests/inline_dialog_spec.js +41 -0
- package/spec/tests/inline_dialog_webitem_spec.js +331 -0
- package/spec/tests/loading_indicator_spec.js +48 -0
- package/spec/tests/messages_module_spec.js +108 -0
- package/spec/tests/meta_spec.js +71 -0
- package/spec/tests/module_args_spec.js +52 -0
- package/spec/tests/observe_spec.js +73 -0
- package/spec/tests/public_events.spec.js +102 -0
- package/spec/tests/scroll_position_spec.js +109 -0
- package/spec/tests/theming_spec.js +594 -0
- package/spec/tests/util_spec.js +55 -0
- package/spec/tests/utils/base64_spec.js +20 -0
- package/spec/tests/utils/button_spec.js +11 -0
- package/spec/tests/utils/cookie_spec.js +19 -0
- package/spec/tests/utils/deprecate_spec.js +22 -0
- package/spec/tests/utils/dialog_spec.js +297 -0
- package/spec/tests/utils/host_util_spec.js +45 -0
- package/spec/tests/utils/iframe_spec.js +41 -0
- package/spec/tests/utils/jwt_spec.js +135 -0
- package/spec/tests/utils/url_spec.js +37 -0
- package/spec/tests/utils/waitUntilReadyNextTick.js +5 -0
- package/spec/tests/utils/webitem.js +219 -0
- package/spec/tests/webitem_spec.js +131 -0
- package/src/css/host/dialog.css +144 -0
- package/src/css/host/flags.css +5 -0
- package/src/css/host/host.css +64 -0
- package/src/css/host/messages.css +12 -0
- package/src/css/plugin/legacy-text-colors.less +55 -0
- package/src/css/plugin/surfaces.css +11 -0
- package/src/host/ACJSFrameworkAdaptor.js +44 -0
- package/src/host/actions/analytics_action.js +35 -0
- package/src/host/actions/button_actions.js +21 -0
- package/src/host/actions/dialog_actions.js +27 -0
- package/src/host/actions/dialog_extension_actions.js +25 -0
- package/src/host/actions/dom_event_actions.js +32 -0
- package/src/host/actions/dropdown_actions.js +12 -0
- package/src/host/actions/env_actions.js +57 -0
- package/src/host/actions/event_actions.js +33 -0
- package/src/host/actions/flag_actions.js +22 -0
- package/src/host/actions/iframe_actions.js +27 -0
- package/src/host/actions/inline_dialog_actions.js +26 -0
- package/src/host/actions/inline_dialog_webitem_actions.js +10 -0
- package/src/host/actions/jwt_actions.js +51 -0
- package/src/host/actions/loading_indicator_actions.js +10 -0
- package/src/host/actions/module_actions.js +14 -0
- package/src/host/actions/webitem_actions.js +29 -0
- package/src/host/components/button.js +112 -0
- package/src/host/components/dialog.js +447 -0
- package/src/host/components/dialog_extension.js +106 -0
- package/src/host/components/dialog_webitem.js +69 -0
- package/src/host/components/flag.js +102 -0
- package/src/host/components/iframe.js +130 -0
- package/src/host/components/iframe_container.js +38 -0
- package/src/host/components/inline_dialog.js +108 -0
- package/src/host/components/inline_dialog_webitem.js +157 -0
- package/src/host/components/loading_indicator.js +110 -0
- package/src/host/components/webitem.js +227 -0
- package/src/host/deprecate.js +20 -0
- package/src/host/dispatchers/analytics_dispatcher.js +512 -0
- package/src/host/dispatchers/event_dispatcher.js +46 -0
- package/src/host/dollar.js +8 -0
- package/src/host/host-api.js +325 -0
- package/src/host/iframe-create.js +7 -0
- package/src/host/index.js +108 -0
- package/src/host/module-providers.js +13 -0
- package/src/host/modules/_featureFlag.js +42 -0
- package/src/host/modules/_performance.js +54 -0
- package/src/host/modules/analytics.js +17 -0
- package/src/host/modules/dialog.js +496 -0
- package/src/host/modules/dropdown.js +255 -0
- package/src/host/modules/env.js +156 -0
- package/src/host/modules/events.js +28 -0
- package/src/host/modules/flag.js +170 -0
- package/src/host/modules/host.js +19 -0
- package/src/host/modules/inline-dialog.js +33 -0
- package/src/host/modules/messages.js +309 -0
- package/src/host/modules/page.js +29 -0
- package/src/host/modules/scroll-position.js +102 -0
- package/src/host/modules/theming.js +114 -0
- package/src/host/stores/extension_configuration_options_store.js +24 -0
- package/src/host/util.js +98 -0
- package/src/host/utils/access-narrowing-context.js +18 -0
- package/src/host/utils/base64.js +22 -0
- package/src/host/utils/button.js +10 -0
- package/src/host/utils/cookie.js +14 -0
- package/src/host/utils/dialog.js +239 -0
- package/src/host/utils/feature-flag.js +27 -0
- package/src/host/utils/iframe.js +23 -0
- package/src/host/utils/jwt.js +60 -0
- package/src/host/utils/observe.js +34 -0
- package/src/host/utils/removal-observer.js +30 -0
- package/src/host/utils/simplexdm.js +58 -0
- package/src/host/utils/url.js +23 -0
- package/src/host/utils/webitem.js +214 -0
- package/src/plugin/amd.js +115 -0
- package/src/plugin/analytics.js +84 -0
- package/src/plugin/deprecate.js +16 -0
- package/src/plugin/dialog.js +197 -0
- package/src/plugin/dollar.js +77 -0
- package/src/plugin/events-instance.js +2 -0
- package/src/plugin/events.js +246 -0
- package/src/plugin/extension_configuration_options_store.js +27 -0
- package/src/plugin/featureFlag.js +8 -0
- package/src/plugin/index.js +118 -0
- package/src/plugin/meta.js +14 -0
- package/src/plugin/public-events.js +73 -0
- package/src/plugin/theming.js +211 -0
- package/src/plugin/util.js +104 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import DialogWebitem from 'src/host/components/dialog_webitem';
|
|
2
|
+
import 'src/host/components/webitem';
|
|
3
|
+
import WebItemActions from 'src/host/actions/webitem_actions';
|
|
4
|
+
import 'src/host/components/dialog_extension';
|
|
5
|
+
import EventDispatcher from 'src/host/dispatchers/event_dispatcher';
|
|
6
|
+
import baseDialogComponentTests from 'fixtures/base_dialog_component_tests';
|
|
7
|
+
import { waitUntilReadyNextTick } from './utils/waitUntilReadyNextTick';
|
|
8
|
+
|
|
9
|
+
describe('Dialog Webitem', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
$('.aui-dialog2').remove();
|
|
12
|
+
$('.aui-blanket').remove();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var webitemButton;
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
window._AP = {
|
|
19
|
+
dialogOptions: {}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
$('.aui-dialog2').remove();
|
|
23
|
+
webitemButton = $('<a />').attr('href', 'https://www.example.com?a.x=b#' + encodeURI(JSON.stringify({productCtx:'{"a.x":"b"}'})));
|
|
24
|
+
webitemButton.text('i am a webitem');
|
|
25
|
+
webitemButton.addClass('ap-dialog ap-plugin-key-my-plugin ap-module-key-key ap-link-webitem');
|
|
26
|
+
webitemButton.appendTo('body');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
window._AP = {};
|
|
31
|
+
webitemButton.remove();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('rendering', () => {
|
|
35
|
+
function waitAndClickDialog(){
|
|
36
|
+
// The page is already loaded so this fires immediately
|
|
37
|
+
// However, the MutationObserver callback that adds the handler won't fire until the next tick
|
|
38
|
+
waitUntilReadyNextTick(() => $('.ap-dialog').click());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
it('renders a dialog', (done) => {
|
|
42
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
43
|
+
expect($('.aui-dialog2').length).toBe(1);
|
|
44
|
+
done();
|
|
45
|
+
});
|
|
46
|
+
waitAndClickDialog();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('contains and iframe container', (done) => {
|
|
50
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
51
|
+
expect($('.aui-dialog2 .ap-iframe-container').length).toBe(1);
|
|
52
|
+
done();
|
|
53
|
+
});
|
|
54
|
+
waitAndClickDialog();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('chromed dialog', (done) => {
|
|
58
|
+
var extension = {
|
|
59
|
+
addon_key: 'my-plugin',
|
|
60
|
+
key: 'key'
|
|
61
|
+
};
|
|
62
|
+
var options = baseDialogComponentTests.getChromeOptions();
|
|
63
|
+
window._AP.dialogOptions[extension.addon_key + '__' + extension.key] = options;
|
|
64
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
65
|
+
baseDialogComponentTests.testChrome(options);
|
|
66
|
+
done();
|
|
67
|
+
});
|
|
68
|
+
waitAndClickDialog();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('renders a chromed dialog with dimensions', (done) => {
|
|
72
|
+
var extension = {
|
|
73
|
+
addon_key: 'my-plugin',
|
|
74
|
+
key: 'key'
|
|
75
|
+
};
|
|
76
|
+
var options = baseDialogComponentTests.getChromeOptions();
|
|
77
|
+
delete options.size;
|
|
78
|
+
options.width = '123px';
|
|
79
|
+
options.height = '100px';
|
|
80
|
+
window._AP.dialogOptions[extension.addon_key + '__' + extension.key] = options;
|
|
81
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
82
|
+
baseDialogComponentTests.testChrome(options);
|
|
83
|
+
done();
|
|
84
|
+
});
|
|
85
|
+
waitAndClickDialog();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('renders a chromeless dialog', (done) => {
|
|
89
|
+
var extension = {
|
|
90
|
+
addon_key: 'my-plugin',
|
|
91
|
+
key: 'key'
|
|
92
|
+
};
|
|
93
|
+
var options = baseDialogComponentTests.getChromelessOptions();
|
|
94
|
+
window._AP.dialogOptions[extension.addon_key + '__' + extension.key] = options;
|
|
95
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
96
|
+
baseDialogComponentTests.testChromeless(options);
|
|
97
|
+
done();
|
|
98
|
+
});
|
|
99
|
+
waitAndClickDialog();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('renders a chromeless dialog with dimensions', (done) => {
|
|
103
|
+
var extension = {
|
|
104
|
+
addon_key: 'my-plugin',
|
|
105
|
+
key: 'key'
|
|
106
|
+
};
|
|
107
|
+
var options = baseDialogComponentTests.getChromelessOptions();
|
|
108
|
+
delete options.size;
|
|
109
|
+
options.width = '123px';
|
|
110
|
+
options.height = '100px';
|
|
111
|
+
window._AP.dialogOptions[extension.addon_key + '__' + extension.key] = options;
|
|
112
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
113
|
+
baseDialogComponentTests.testChromeless(options);
|
|
114
|
+
done();
|
|
115
|
+
});
|
|
116
|
+
waitAndClickDialog();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('renders a dialog without changing original dialog options', (done) => {
|
|
120
|
+
var extension = {
|
|
121
|
+
addon_key: 'my-plugin',
|
|
122
|
+
key: 'key'
|
|
123
|
+
};
|
|
124
|
+
var options = baseDialogComponentTests.getChromeOptions();
|
|
125
|
+
delete options.size;
|
|
126
|
+
options.width = '123px';
|
|
127
|
+
options.height = '100px';
|
|
128
|
+
window._AP.dialogOptions[extension.addon_key + '__' + extension.key] = options;
|
|
129
|
+
EventDispatcher.registerOnce('after:webitem-invoked:dialog', function(){
|
|
130
|
+
expect(window._AP.dialogOptions['my-plugin__key']).toEqual(options);
|
|
131
|
+
done();
|
|
132
|
+
});
|
|
133
|
+
waitAndClickDialog();
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('triggers', () => {
|
|
139
|
+
beforeEach(() => {
|
|
140
|
+
window._AP = {
|
|
141
|
+
_convertConnectOptions: function(data){
|
|
142
|
+
return {
|
|
143
|
+
options: {
|
|
144
|
+
productContext: JSON.parse(data.productCtx)
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
afterEach(() => {
|
|
152
|
+
delete window._AP._convertConnectOptions;
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('is set to be triggered by click', () => {
|
|
156
|
+
expect(DialogWebitem.getWebItem().triggers).toEqual(['click']);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('responds to a click event', (done) => {
|
|
160
|
+
var spy = jasmine.createSpy('spy');
|
|
161
|
+
spyOn(WebItemActions, 'webitemInvoked');
|
|
162
|
+
waitUntilReadyNextTick(() => {
|
|
163
|
+
$('.ap-dialog').click();
|
|
164
|
+
expect(WebItemActions.webitemInvoked.calls.count()).toEqual(1);
|
|
165
|
+
done();
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('includes product context', (done) => {
|
|
170
|
+
var spy = jasmine.createSpy('spy');
|
|
171
|
+
spyOn(WebItemActions, 'webitemInvoked');
|
|
172
|
+
waitUntilReadyNextTick(() => {
|
|
173
|
+
$('.ap-dialog').click();
|
|
174
|
+
var extensionObj = WebItemActions.webitemInvoked.calls.first().args[1].extension;
|
|
175
|
+
expect(extensionObj.options.productContext).toEqual({'a.x': 'b'});
|
|
176
|
+
done();
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import DropdownModule from 'src/host/modules/dropdown';
|
|
2
|
+
import EventDispatcher from 'src/host/dispatchers/event_dispatcher';
|
|
3
|
+
import EventActions from 'src/host/actions/event_actions';
|
|
4
|
+
import HostApi from 'src/host/host-api';
|
|
5
|
+
|
|
6
|
+
describe('dropdown api module', () => {
|
|
7
|
+
const frameworkAdaptor = HostApi.getFrameworkAdaptor();
|
|
8
|
+
|
|
9
|
+
const fakeCallback = function(){};
|
|
10
|
+
fakeCallback._context = {
|
|
11
|
+
extension: {
|
|
12
|
+
extension_id: 'some-extension-id'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const providerSpy = jasmine.createSpyObj('moduleProvider', [
|
|
17
|
+
'registerItemNotifier',
|
|
18
|
+
'create',
|
|
19
|
+
'hide',
|
|
20
|
+
'showAt',
|
|
21
|
+
'itemActivated',
|
|
22
|
+
'itemDisabled'
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
let dropdownProvider = {
|
|
26
|
+
getModuleRegistrationName: function() {
|
|
27
|
+
return 'dropdown';
|
|
28
|
+
},
|
|
29
|
+
isEnabled: function() {
|
|
30
|
+
return true;
|
|
31
|
+
},
|
|
32
|
+
getProvider: function(){
|
|
33
|
+
return providerSpy;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
frameworkAdaptor.registerModule(dropdownProvider);
|
|
37
|
+
|
|
38
|
+
beforeEach(() => {
|
|
39
|
+
providerSpy.registerItemNotifier.calls.reset();
|
|
40
|
+
providerSpy.create.calls.reset();
|
|
41
|
+
providerSpy.hide.calls.reset();
|
|
42
|
+
providerSpy.showAt.calls.reset();
|
|
43
|
+
providerSpy.itemActivated.calls.reset();
|
|
44
|
+
providerSpy.itemDisabled.calls.reset();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('create', () => {
|
|
48
|
+
|
|
49
|
+
it('formats sections', () => {
|
|
50
|
+
let options = {
|
|
51
|
+
dropdownId: 'some-dropdown-id',
|
|
52
|
+
list: [{
|
|
53
|
+
heading: 'section heading',
|
|
54
|
+
list: [
|
|
55
|
+
{text: 'one'},
|
|
56
|
+
{text: 'two'}
|
|
57
|
+
]
|
|
58
|
+
}]
|
|
59
|
+
};
|
|
60
|
+
let formattedOptions = DropdownModule.create(Object.assign({}, options), fakeCallback);
|
|
61
|
+
expect(formattedOptions).toEqual({
|
|
62
|
+
dropdownId: options.dropdownId,
|
|
63
|
+
dropdownGroups: [{
|
|
64
|
+
heading: options.list[0].heading,
|
|
65
|
+
items: [
|
|
66
|
+
{content: options.list[0].list[0].text},
|
|
67
|
+
{content: options.list[0].list[1].text}
|
|
68
|
+
]
|
|
69
|
+
}],
|
|
70
|
+
dropdownItemNotifier: jasmine.any(Function)
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import envModule from 'src/host/modules/env';
|
|
2
|
+
import EventDispatcher from 'src/host/dispatchers/event_dispatcher';
|
|
3
|
+
import {Flags} from '../../src/host/utils/feature-flag';
|
|
4
|
+
|
|
5
|
+
describe('env module', () => {
|
|
6
|
+
|
|
7
|
+
xdescribe('sizeToParent', () => {
|
|
8
|
+
afterEach(function(){
|
|
9
|
+
$('.tempiframe').remove();
|
|
10
|
+
$('.ac-content-page').remove();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('disables resize function', (done) => {
|
|
14
|
+
var callback = function(){};
|
|
15
|
+
var $el = $('<iframe class="tempiframe" id="d32idas" />');
|
|
16
|
+
callback._context = {
|
|
17
|
+
extension_id: 'd32idas',
|
|
18
|
+
extension: {
|
|
19
|
+
id: 'd32idas',
|
|
20
|
+
$el: $el,
|
|
21
|
+
options: {
|
|
22
|
+
isFullPage: true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
$('body').append($el);
|
|
28
|
+
expect(envModule.resize('10px','10px', callback)).toEqual(true);
|
|
29
|
+
var resizeSpy = (data) => {
|
|
30
|
+
if(data.extensionId === callback._context.extension_id) {
|
|
31
|
+
expect(envModule.resize('10px','10px', callback)).toEqual(false);
|
|
32
|
+
done();
|
|
33
|
+
EventDispatcher.unregister('after:iframe-size-to-parent', resizeSpy);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
EventDispatcher.register('after:iframe-size-to-parent', resizeSpy);
|
|
37
|
+
envModule.sizeToParent(true, callback);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('changes the dimensions of the iframe to fill the rest of the page', (done) => {
|
|
41
|
+
var $contentPage = $('<div class="ac-content-page" />');
|
|
42
|
+
var $nav = $('<nav />').css('height', '23px');
|
|
43
|
+
var $header = $('<header id="header"></header>').append($nav);
|
|
44
|
+
var callback = function(){};
|
|
45
|
+
var $el = $('<iframe class="tempiframe" id="zxy123" />').css({
|
|
46
|
+
border: 0,
|
|
47
|
+
padding: 0,
|
|
48
|
+
margin: 0
|
|
49
|
+
});
|
|
50
|
+
callback._context = {
|
|
51
|
+
extension_id: 'zxy123',
|
|
52
|
+
extension: {
|
|
53
|
+
id: 'zxy123',
|
|
54
|
+
$el: $el,
|
|
55
|
+
options: {
|
|
56
|
+
isFullPage: true
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
$contentPage.append($header);
|
|
62
|
+
$contentPage.append($el);
|
|
63
|
+
$('body').append($contentPage);
|
|
64
|
+
// full height - header - 1px border = scrollbar only on iframe
|
|
65
|
+
var correctIframeHeight = $(window).height() - 23 - 1;
|
|
66
|
+
function spy (data){
|
|
67
|
+
if(data.$el.attr('id') === callback._context.extension_id) {
|
|
68
|
+
expect($el.height()).toEqual(correctIframeHeight);
|
|
69
|
+
expect($el.attr('class')).toContain('sized-to-parent');
|
|
70
|
+
expect($el.css('display')).toEqual('block');
|
|
71
|
+
EventDispatcher.unregister('iframe-resize', spy);
|
|
72
|
+
done();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
EventDispatcher.register('iframe-resize', spy);
|
|
76
|
+
envModule.sizeToParent(false, callback);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('resize', () => {
|
|
81
|
+
|
|
82
|
+
afterEach(function(){
|
|
83
|
+
$('.tempiframe').remove();
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('triggers the resize function', (done) => {
|
|
87
|
+
var width = '100px';
|
|
88
|
+
var height = '120px';
|
|
89
|
+
var callback = function(){};
|
|
90
|
+
var $el = $('<iframe class="tempiframe" id="xabc123" />');
|
|
91
|
+
callback._context = {
|
|
92
|
+
extension_id: 'xabc123',
|
|
93
|
+
extension: {
|
|
94
|
+
id: 'xabc123',
|
|
95
|
+
$el: $el
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
$('body').append($el);
|
|
99
|
+
function resizeSpy(data){
|
|
100
|
+
if(data.extension && data.extension.id === callback._context.extension.id){
|
|
101
|
+
expect(data.width).toEqual(width);
|
|
102
|
+
expect(data.height).toEqual(height);
|
|
103
|
+
expect(data.extension.id).toEqual(callback._context.extension.id);
|
|
104
|
+
EventDispatcher.unregister('after:iframe-resize', resizeSpy);
|
|
105
|
+
done();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
EventDispatcher.register('after:iframe-resize', resizeSpy);
|
|
109
|
+
envModule.resize(width, height, callback);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('triggers the resize function once per add-on', (done) => {
|
|
113
|
+
var width = '110px';
|
|
114
|
+
var height = '130px';
|
|
115
|
+
var $el1= $('<iframe class="tempiframe" id="abc1234" />');
|
|
116
|
+
var callback1 = function(){};
|
|
117
|
+
callback1._context = {
|
|
118
|
+
extension_id: 'abc1234',
|
|
119
|
+
extension: {
|
|
120
|
+
id: 'abc1234',
|
|
121
|
+
$el: $el1
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
var $el2 = $('<iframe class="tempiframe" id="xyz123" />');
|
|
126
|
+
var callback2 = function(){};
|
|
127
|
+
callback2._context = {
|
|
128
|
+
extension_id: 'xyz123',
|
|
129
|
+
extension: {
|
|
130
|
+
id: 'xyz123',
|
|
131
|
+
$el: $el2
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var spy = jasmine.createSpy('validator');
|
|
136
|
+
EventDispatcher.register('iframe-resize', spy);
|
|
137
|
+
$('body').append($el1);
|
|
138
|
+
$('body').append($el2);
|
|
139
|
+
envModule.resize(width, height, callback1);
|
|
140
|
+
envModule.resize(width, height, callback1);
|
|
141
|
+
envModule.resize(width, height, callback2);
|
|
142
|
+
envModule.resize(width, height, callback2);
|
|
143
|
+
|
|
144
|
+
setTimeout(function(){
|
|
145
|
+
expect(spy.calls.count()).toEqual(2);
|
|
146
|
+
expect(spy.calls.argsFor(0)[0].extension.id).toEqual('abc1234');
|
|
147
|
+
expect(spy.calls.argsFor(1)[0].extension.id).toEqual('xyz123');
|
|
148
|
+
EventDispatcher.unregister('iframe-resize', spy);
|
|
149
|
+
}, 500);
|
|
150
|
+
done();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import AP from 'simple-xdm/plugin';
|
|
2
|
+
AP._data.origin = '*'; // prevent AP._registerOnUnload() from failing
|
|
3
|
+
|
|
4
|
+
import Events from 'src/plugin/events';
|
|
5
|
+
import EventActions from 'src/host/actions/event_actions';
|
|
6
|
+
|
|
7
|
+
const targetSpecNoDialogs = EventActions.targetSpecNoDialogs;
|
|
8
|
+
|
|
9
|
+
describe('Plugin events shim', function(){
|
|
10
|
+
var events = new Events();
|
|
11
|
+
beforeEach(function(){
|
|
12
|
+
events._events = {};
|
|
13
|
+
});
|
|
14
|
+
it('on binds an event', function(){
|
|
15
|
+
var spy = jasmine.createSpy('spy');
|
|
16
|
+
events.on('something', spy);
|
|
17
|
+
expect(events._events['something'][0]).toEqual(spy);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('off unbinds an event', function(){
|
|
21
|
+
var spy = jasmine.createSpy('spy');
|
|
22
|
+
events.on('something', spy);
|
|
23
|
+
events.off('something', spy);
|
|
24
|
+
expect(events._events['something']).toEqual(undefined);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('once only emits the event once', function(){
|
|
28
|
+
var spy = jasmine.createSpy('spy');
|
|
29
|
+
var eventName = 'zxy';
|
|
30
|
+
expect(events._events[eventName]).toEqual(undefined);
|
|
31
|
+
events.once(eventName, spy);
|
|
32
|
+
expect(events._events[eventName].length).toEqual(1);
|
|
33
|
+
events._events[eventName][0].apply(null, {});
|
|
34
|
+
expect(events._events[eventName]).toEqual(undefined);
|
|
35
|
+
expect(spy).toHaveBeenCalled();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('onAny binds on to any trigger', function(){
|
|
39
|
+
var spy = jasmine.createSpy('spy');
|
|
40
|
+
expect(events._events[events.ANY_PREFIX]).not.toContain(spy);
|
|
41
|
+
events.onAny(spy);
|
|
42
|
+
expect(events._events[events.ANY_PREFIX]).toContain(spy);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('offAll unbinds all events with the specified name', function(){
|
|
46
|
+
var eventName = 'abc123';
|
|
47
|
+
expect(events._events[eventName]).toEqual(undefined);
|
|
48
|
+
events.on(eventName, jasmine.createSpy('spy'));
|
|
49
|
+
events.on(eventName, jasmine.createSpy('spy'));
|
|
50
|
+
expect(events._events[eventName].length).toEqual(2);
|
|
51
|
+
events.offAll(eventName);
|
|
52
|
+
expect(events._events[eventName]).toEqual(undefined);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('targetSpecNoDialogs filters events from dialog modules', function(){
|
|
56
|
+
const registration = {
|
|
57
|
+
extension: {
|
|
58
|
+
options: {
|
|
59
|
+
moduleType: 'dialogs',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
expect(targetSpecNoDialogs(registration)).toEqual(false);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('targetSpecNoDialogs does not filter events from non-dialog modules', function(){
|
|
67
|
+
const registration = {
|
|
68
|
+
extension: {
|
|
69
|
+
options: {
|
|
70
|
+
moduleType: 'anything',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
expect(targetSpecNoDialogs(registration)).toEqual(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ExtensionConfigurationOptionsStore from 'src/host/stores/extension_configuration_options_store';
|
|
2
|
+
import SimpleXdmUtils from 'src/host/utils/simplexdm';
|
|
3
|
+
|
|
4
|
+
describe('Extension Configuration Options Store', () => {
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
ExtensionConfigurationOptionsStore.store = {};
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('sets an option that is added to the iframe', () => {
|
|
11
|
+
ExtensionConfigurationOptionsStore.set('crev', '1.2.3.4.5');
|
|
12
|
+
var simpleXdmExtension = SimpleXdmUtils.createSimpleXdmExtension({
|
|
13
|
+
addon_key: 'abc123',
|
|
14
|
+
key: 'some-module-key',
|
|
15
|
+
url: 'http://www.example.com',
|
|
16
|
+
options: {
|
|
17
|
+
noDOM: true
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
expect(simpleXdmExtension.extension.options.globalOptions).toEqual({'crev': '1.2.3.4.5'});
|
|
21
|
+
var parsedIframeName = JSON.parse(simpleXdmExtension.iframeAttributes.name);
|
|
22
|
+
expect(parsedIframeName.options.globalOptions.crev).toEqual('1.2.3.4.5');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import FlagModule from 'src/host/modules/flag';
|
|
2
|
+
import ModuleProviders from 'src/host/module-providers';
|
|
3
|
+
import EventActions from 'src/host/actions/event_actions';
|
|
4
|
+
import { acjsFrameworkAdaptor } from 'src/host/ACJSFrameworkAdaptor';
|
|
5
|
+
|
|
6
|
+
const callback = () => {};
|
|
7
|
+
callback._id = 'some-extension-id';
|
|
8
|
+
callback._context = {
|
|
9
|
+
extension: {
|
|
10
|
+
addon_key: 'some-addon-key',
|
|
11
|
+
key: 'some-module-key',
|
|
12
|
+
options: jasmine.objectContaining({})
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const appProviderSpy = {
|
|
17
|
+
registerUnmountCallback: jasmine.createSpy('registerUnmountCallback')
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const flagProviderSpy = {
|
|
21
|
+
create: jasmine.createSpy('create'),
|
|
22
|
+
close: jasmine.createSpy('close')
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
class FlagModuleSpy {
|
|
26
|
+
constructor(providerSpy) {
|
|
27
|
+
this.providerSpy = flagProviderSpy;
|
|
28
|
+
}
|
|
29
|
+
isEnabled() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
getModuleRegistrationName() {
|
|
33
|
+
return 'flag';
|
|
34
|
+
}
|
|
35
|
+
getProvider() {
|
|
36
|
+
return this.providerSpy;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
acjsFrameworkAdaptor.registerModule(new FlagModuleSpy(flagProviderSpy));
|
|
41
|
+
|
|
42
|
+
describe('AP.flag', () => {
|
|
43
|
+
|
|
44
|
+
const flagOptions = {
|
|
45
|
+
type: 'some type',
|
|
46
|
+
title: 'some title',
|
|
47
|
+
body: 'some body',
|
|
48
|
+
actions: {
|
|
49
|
+
key: 'some action text'
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
flagProviderSpy.create.calls.reset();
|
|
55
|
+
flagProviderSpy.close.calls.reset();
|
|
56
|
+
appProviderSpy.registerUnmountCallback.calls.reset();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('.create()', () => {
|
|
60
|
+
it('does not invoke registerUnmountCallback if provider not registered', () => {
|
|
61
|
+
ModuleProviders.registerProvider('addon', null);
|
|
62
|
+
new FlagModule.create.constructor(flagOptions, callback);
|
|
63
|
+
expect(appProviderSpy.registerUnmountCallback).not.toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('does not invoke registerUnmountCallback if not implemented in provider', () => {
|
|
67
|
+
ModuleProviders.registerProvider('addon', {});
|
|
68
|
+
new FlagModule.create.constructor(flagOptions, callback);
|
|
69
|
+
expect(appProviderSpy.registerUnmountCallback).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('invokes registerUnmountCallback if available', () => {
|
|
73
|
+
ModuleProviders.registerProvider('addon', appProviderSpy);
|
|
74
|
+
new FlagModule.create.constructor(flagOptions, callback);
|
|
75
|
+
expect(appProviderSpy.registerUnmountCallback.calls.count()).toEqual(1);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
});
|