|
|
|
import { strict as assert } from 'assert';
|
|
|
|
import { isPrefixedFormattedHexString } from '../../../shared/modules/network.utils';
|
|
|
|
|
|
|
|
import {
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
ENVIRONMENT_TYPE_POPUP,
|
|
|
|
ENVIRONMENT_TYPE_NOTIFICATION,
|
|
|
|
ENVIRONMENT_TYPE_FULLSCREEN,
|
|
|
|
ENVIRONMENT_TYPE_BACKGROUND,
|
|
|
|
} from '../../../shared/constants/app';
|
|
|
|
import { getEnvironmentType } from './util';
|
|
|
|
|
|
|
|
describe('app utils', function () {
|
|
|
|
describe('getEnvironmentType', function () {
|
|
|
|
it('should return popup type', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/popup.html',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return notification type', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/notification.html',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_NOTIFICATION);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return fullscreen type for home.html', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/home.html',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return fullscreen type for phishing.html', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/phishing.html',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_FULLSCREEN);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return background type', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/_generated_background_page.html',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_BACKGROUND);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return the correct type for a URL with a hash fragment', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/popup.html#hash',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return the correct type for a URL with query parameters', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/popup.html?param=foo',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP);
|
|
|
|
});
|
Close window after opening fullscreen (#6966)
* Add background environment type
The `getEnvironmentType` method now checks for the background
environment as well, instead of returning 'notification' for that case.
Instead of adding another regex for the background path, the regexes
for each environment have been replaced with the URL constructor[0].
This is the standard method of parsing URLs, and is available in all
supported browsers.
[0]: https://developer.mozilla.org/en-US/docs/Web/API/URL
* Add note regarding a missing manifest permission
The `url` parameter to `tabs.query(...)` requires the `tabs` permission,
and will be ignored otherwise. We are missing this permission, so that
call does not work.
* Close window after opening full screen
The browser behaviour when opening a new tab differs between Chrome and
Firefox. In the case of a popup, Chrome will close the popup whereas
Firefox will leave it open. In the case of the notification window,
Chrome will move the new tab to the foreground, whereas Firefox will
leave the notification window in the foreground when opening a new tab.
We always want to close the current UI (popup or notification) when
switching to a full-screen view. The only exception to this is when the
switch is triggered from the background, which has no UI.
Closes #6513, #6685
5 years ago
|
|
|
|
|
|
|
it('should return the correct type for a URL with query parameters and a hash fragment', function () {
|
|
|
|
const environmentType = getEnvironmentType(
|
|
|
|
'http://extension-id/popup.html?param=foo#hash',
|
|
|
|
);
|
|
|
|
assert.equal(environmentType, ENVIRONMENT_TYPE_POPUP);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('isPrefixedFormattedHexString', function () {
|
|
|
|
it('should return true for valid hex strings', function () {
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x1'),
|
|
|
|
true,
|
|
|
|
'should return true',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0xa'),
|
|
|
|
true,
|
|
|
|
'should return true',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0xabcd1123fae909aad87452'),
|
|
|
|
true,
|
|
|
|
'should return true',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return false for invalid hex strings', function () {
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x0'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x01'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString(' 0x1'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x1 '),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('0x1afz'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString('z'),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString(2),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString(['0x1']),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
isPrefixedFormattedHexString(),
|
|
|
|
false,
|
|
|
|
'should return false',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|