seb-win-refactoring: Popup Creation Fails

When opening a new window/tab with JavaScript, unlike all other browsers, SEB returns null in method window.open(...)'. As a result, setting the URL in the second statement does not work.

var targetWindow = window.open("","_blank");
...
targetWindow.location.href = '<the real url>';

_Originally posted by @uhensler in https://github.com/SafeExamBrowser/seb-win-refactoring/discussions/228#discussioncomment-1604061_

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 50 (28 by maintainers)

Commits related to this issue

Most upvoted comments

We have added the mentioned code of the University of Zurich to the public release of OpenOlat. This allows the use of the SEB JavaScript API.

This code does not solve the problem of opening a new window/tab on SEB for macOS. The JavaScript variable window is always null, so there is an exception. This seems to be and bug in the SEB. Can you please look into this?

In the GUI this leads to a popup with the message “Quit Safe Exam Browser: Are you sure you want to quit Safe Exam Browser?”.

There is no version 3.4 for Mac yet, the latest stable version 3.1 will be released later this week. From the above mentioned page you can get a release candidate version.

Now regarding the handlers which don’t exist for ChromiumHostControl: How exactly do I need to turn the handler methods into events?

Commit https://github.com/cefsharp/CefSharp.MinimalExample/commit/34650112db2f7f1a6e030e0c4b2846cf331630ae added a basic example to the MinimalExample.

The key parts

It’s basically:

  • Add event args class
  • Add the event to the common interface
  • Add the event and a method to your ChromiumHostControl and ChromiumWebBrowser instances (copy and paste stuff)
    • The method simply fires the event
  • Add a handler implementation that gets the relevant control instance and calls the method.

Starting at https://github.com/cefsharp/CefSharp.MinimalExample/commit/34650112db2f7f1a6e030e0c4b2846cf331630ae#diff-6e4d5ea533ed7108e6bb21e0fde5a0d7816987945c557900904aaedf05ab6864 is an actual example.

https://github.com/dbuechel/CefSharp.MinimalExample as specified in #240 (comment)

See https://github.com/cefsharp/CefSharp.MinimalExample/tree/chromiumhostcontrol for an updated example.

  • I’ve rebased and squashed your branch (best to keep upgrade commits separate, so code is easier to review)
  • Refactored winforms example to provide a more complete demo
  • Your example html above was turned into https://cefsharp.github.io/demo/openpopup.html to simplify testing.
  • Added a custom LoadingProgressChanged property to demo one option for creating common event.

For common events I’m open to adding them directly in CefSharp (they’ll need to be added to all the WinForms, WPF, WPF.HwndHost and OffScreen implementations, so there’s a bit of work there.

We’d definitely need to keep the current behavior for new windows / popups when they’re opened by e.g. target="_blank"

Not sure why you’d want the extra complexity, would it actually be necessary to create an extra code path?. If the answer is yes then that’s totally upto to you (simple enough to do).