-
-
Notifications
You must be signed in to change notification settings - Fork 818
Connected Mode #823
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
Connected Mode #823
Conversation
Fixed side-runner foreach command
Fixed the for each test.
Fixed failed test for Foreach bug fix
merge last version of V3
V3 update
Fixed typo. Action reference should be Actions reference to avoid cas…
Hello @corevo here is the modifications I have done for the connected mode feature. |
pauseNotificationSent = false | ||
@observable | ||
isControlledBy = { | ||
connectionId: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we need connectionId
we can use the extensionId
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make it more flexible to the user, if there are multiple instance within the same extension ID you want the user to be able to control what instance is talking to Selenium IDE.
|
||
router.post('/register', (req, res) => { | ||
if (req.connectionId != UiState.isControlledBy.connectionId) | ||
throw new Error('Another connection is established') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can register other plugins, we should just block requests to /control
so only one can control it, thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the idea is to block everything but /control. When Selenium is controlled by a specific extension, no other extension should be listening to events for security purposes. On the other hand, the only way to interrupt the connection is to request control through the /control call. If the user accepts to change the connection, the new extension will have control, and all the plugins will be unplugged.
}) | ||
router.post( | ||
'/register', | ||
controlledOnly((req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only block other extensions from calling /control
right?
If the extension is in controlled mode, other plugins should still work, what do you think?
Connected Mode Implementation Fixed check for connection ID bug Fixed prettier bug and changed description of pop up Fixed prettier bug Fixed prettier bug Plugin Manager Fix, modified dialog, window focus addition Closure Prettier Prettier Prettier Restart to welcome sccreen when entering connected mode Prettier Prettier Prettier Prettier Prettier Prettier Prettier debug travis fail restart capabiulity everytime is starting a connection prettier travis bugs travis bugs
325573b
to
081f824
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had concern of the selenium IDE's extension id. For now third party plugin need to use a hardcoded string as extension id to send message to Selenium IDE. Selenium IDE's extension id could change when manifest file changes. Shall we have a way of storing the extension id to a special key in local storage whenever the IDE extension's background or contentScript is executed. So third party extension can look for that key to always get the right extension id.
@corevo Thoughts?
|
||
const router = new Router() | ||
|
||
const controlledOnly = apiFn => { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
if ( | ||
(Manager.controller && | ||
Manager.controller.connectionId != req.connectionId) || | ||
!Manager.controller |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when manager.controller is undefined it only means that there is no assisted control yet. This scenario is directed to the case when there is a connected mode but the connection id is a different one or when there is not connected mode and there is a potential for connecting.
if ( | ||
message.control && | ||
message.controller.connectionId && | ||
message.controller.id |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the senders. Thant is how the plugin manifesto works. The sender (or extension Id) turn out to be the plugin id.
Changing errors to response with error code
Connected Mode Implementation Fixed check for connection ID bug Fixed prettier bug and changed description of pop up Fixed prettier bug Fixed prettier bug Plugin Manager Fix, modified dialog, window focus addition Closure Prettier Prettier Prettier Restart to welcome sccreen when entering connected mode Prettier Prettier Prettier Prettier Prettier Prettier Prettier debug travis fail restart capabiulity everytime is starting a connection prettier travis bugs travis bugs documentation of connected mode deleted end connection
Nbansal/connected mode4
Nbansal/connected mode3
… into nbansal/connectedMode3
Nbansal/connected mode3
All the changes are done in our side. current state of the connected Mode PR is thoroughly tested by our testing team, including 10+ different corner cases are covered and all work as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good & clean.
let payload = message.payload | ||
|
||
payload.sender = sender.id | ||
if (message.uri === '/_connect' || message.uri === '/_close') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have an internal API that starts with /private
instead of prefixing with _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds good. I will do these changes and push them to PR
} else if (UiState.isControlled) { | ||
return ( | ||
<div className="connected-mode"> | ||
<div className="connected-mode"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why both div
s have the same class attached?
Also controlled-banner
instead of connected-mode
.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
return this.plugins.find(p => p.id === pluginId) | ||
} | ||
|
||
unregisterAllPlugins() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary
Fixed.
docs/api/plugins/system.md
Outdated
``` | ||
### `POST /control` | ||
|
||
Start a connection with a specific connection Id from another chrome extension. When this connection is accepted by the user, Selenium IDE restarts and registers the caller, and the extension takes exclusive control of Selenium IDE until user closes Selenium IDE or another connection is accepted. When this mode is on, the save to computer functionality gets overritten by sending the side file to the extension controlling Selenium IDE. When in this mode, the user needs to add connectionId variable to make other API calls such as `POST /project`, `GET /project`, `POST /log`, `POST /register`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use connectionId
instead of using the controller extension ID? seems less secure since this is a user-generated token rather than a browser secure token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, we can switch to use sender id.
}, | ||
} | ||
|
||
function checkControl(req) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function name is very ambiguous.
The function returns true in 2 cases
- Extension is not controlled by anyone
- Extension is controlled, and the request is sent by the controller
While returning false in 1 case
- Extension is controlled by someone else
So I think we should split this function (and the decorator) into two that would be more readable
isControlled
- would return true/false if the IDE is under control of any extension
isControlledByThisExtension
- would return true only if the current extension is the controller
Then we can compose the decorators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can make the name to be more clear. Split to more decorators sounds OK but we are never going to used the sparated decorators in other places. So rather keep it in a single function to simply the call hierarchy. Is that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it is hard to think a good name for it. I'll just do split.
conflictAction: 'overwrite', | ||
}) | ||
return UiState.isControlled | ||
? Promise.resolve() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not silently fail, we should send a message to the controller that the user requested to save.
Look at PlaybackState to get an idea of how to send an event over to an extension.
I was thinking of something like:
{
action: 'event',
event: 'saveProject',
options: {
project
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already send the plugin with the emit of the project entity. Do we expect to send another event here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emit project is something else, in controlled mode we shouldn't emit to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So to clarify.
You want in control mode, IDE will send a saveProject event, do you still want to keep the emit? I guess we should still keep it for consistency between control and non-control mode?
* resolve review comments. * Fix some indention issue. * Fix the max-width of banner.
… into nbansal/feedbackchanges
Nbansal/feedbackchanges
indentation changes to fix build
fixing css indentation issues
delete payload.restart | ||
|
||
const newMessage = { | ||
uri: '/privateConnect', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant /private/connect
and use the /private/
prefix in general for internal IDE messages.
Also keep things lower cased.
changing private apis to /private/ sending project in message on save
X
in the preceding checkbox, I verify that I have signed the Contributor License Agreement