Merge lp:~abreu-alexandre/oxide/content-script-injection-main-world into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Alexandre Abreu
Status: Merged
Approved by: Chris Coulson
Approved revision: 774
Merged at revision: 786
Proposed branch: lp:~abreu-alexandre/oxide/content-script-injection-main-world
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 522 lines (+288/-19)
12 files modified
qt/tests/qmltests/core/tst_WebView_scriptMainWorld.html (+12/-0)
qt/tests/qmltests/core/tst_WebView_scriptMainWorld.qml (+112/-0)
qt/tests/qmltests/core/tst_WebView_scriptMainWorld_user_script.js (+10/-0)
shared/common/oxide_constants.cc (+5/-0)
shared/common/oxide_constants.h (+5/-0)
shared/renderer/oxide_isolated_world_map.cc (+8/-0)
shared/renderer/oxide_script_message_dispatcher_renderer.cc (+17/-8)
shared/renderer/oxide_script_message_dispatcher_renderer.h (+2/-0)
shared/renderer/oxide_script_message_manager.cc (+24/-11)
shared/renderer/oxide_script_message_manager.h (+4/-0)
shared/renderer/oxide_user_script_slave.cc (+84/-0)
shared/renderer/oxide_user_script_slave.h (+5/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/oxide/content-script-injection-main-world
Reviewer Review Type Date Requested Status
Chris Coulson Needs Fixing
Maxim Ermilov (community) Needs Fixing
Review via email: mp+210674@code.launchpad.net

Commit message

Enable *under some circumstances* content scripts to be injected:

1. in the main js world,
2. with an access to the oxide messaging API.

The Oxide QML API itself is not changed to achieve that. This is achieved through some declarative header extensions made to greasemonkey like scripts support in Oxide and a specific world Id used to referrence the messages coming in and out of those scripts.

In order to achieve the features listed in 1 and 2, what would be needed is then:

- have a greasemonkey script,
- have the script obviously be declared as emulateGreasemonkey,
- use a specific context for the messaging ("oxide://main-world"),

As long as one has the proper context name the script is injected in the main world, but only scripts marked as gm scripts will have the additional oxide api,

Description of the change

Enable *under some circumstances* content scripts to be injected:

1. in the main js world,
2. with an access to the oxide messaging API.

The Oxide QML API itself is not changed to achieve that. This is achieved through some declarative header extensions made to greasemonkey like scripts support in Oxide and a specific world Id used to referrence the messages coming in and out of those scripts.

In order to achieve the features listed in 1 and 2, what would be needed is then:

- have a greasemonkey script,
- have the script obviously be declared as emulateGreasemonkey,
- use a specific context for the messaging ("oxide://main-world"),

As long as one has the proper context name the script is injected in the main world, but only scripts marked as gm scripts will have the additional oxide api,

To post a comment you must log in.
417. By Chris Coulson

Merge network-callbacks branch. This adds the following:
- WebContextDelegateWorker, which is basically a worker script that exposes entry points
  for processing callbacks from Chromium's IO thread.
- WebContext.networkRequestDelegate, which allows applications to modify HTTP request URL's and
  modify HTTP headers, using WebContextDelegateWorker
- WebContext.storageAccessPermissionDelegate, which allows applicatons to override the default
  permissions for storage accesses, using WebContextDelegateWorker. This is currently only called
  for cookies, but will be expanded to local storage, appcache, indexeddb and webdb.
- WebContext.userAgentOverrideDelegate, which allows applications to override navigator.userAgent for
  specific URL's, using WebContextDelegateWorker. Technically, this could have been handled on the UI
  thread without WebContextDelegateWorker, but it's assumed that this will be used in conjunction
  with networkRequestDelegate for overriding the User-Agent header. Using WebContextDelegateWorker
  allows the application to keep all user-agent override data in one script engine.
- WebContext.cookiePolicy for setting the default cookie policy, and supporting third-party
  cookie blocking

418. By Chris Coulson

Add some missing compile-time asserts

419. By Chris Coulson

UserScript.onScriptWillBeDeleted isn't meant to be public

420. By Chris Coulson

Fix a typo

421. By Chris Coulson

WebContext.addUserScript should probably always take ownership of an unowned UserScript

422. By Chris Coulson

WebView.addMessageHandler and WebFrame.addMessageHandler should behave like WebContext.networkRequestDelegateWorker etc, and fail to add a handler that's already in use by another message target. Also, add a test to verify that deleting a ScriptMessageHandler removes it from its message target

423. By Chris Coulson

Update to Chromium 35.0.1897.2

424. By Chris Coulson

Omit the mojo bits for now - from http://src.chromium.org/viewvc/chrome?view=revision&revision=257587, it looks like it should be disabled anyway, but we still get a dependency on mojo_system. We need to install the shared lib for this to work

425. By Chris Coulson

Rename IOThreadDelegate to IOThreadGlobals. This makes more sense, and we have an IOThreadDelegate now in Qt glue, with a more appropriate use for that name

426. By Chris Coulson

Make IOThreadGlobals a proper singleton. Calling BrowserProcessMain::CreateIOThreadGlobals was always a bit weird

427. By Chris Coulson

Add URLRequestContextFactory

428. By Chris Coulson

Create URLRequestContext in URLRequestContextGetter

429. By Chris Coulson

Move common parts of URLRequestContext initialization in to URLRequestContextGetter

430. By Chris Coulson

Add a system URL request context

431. By Chris Coulson

Assert that InitializeRequestContext is only called once

432. By Chris Coulson

Use net::TransportSecurityPersister so that we have permanent storage for HSTS. Also, make this available in read-only mode to off-the-record contexts

433. By Chris Coulson

Add BrowserContext::Params

434. By Chris Coulson

Fix a double free on shutdown

435. By Chris Coulson

BrowserContext::GetCachePath() and BrowserContext::GetPath() no longer return an empty path for OTR contexts, and BrowserContext::IsOffTheRecord() always returns false for the main context, since r432

436. By Olivier Tilloy

Implement a dummy AccessTokenStore to prevent geolocation requests from crashing the renderer.

437. By Chris Coulson

Update exclude list for tarball

438. By Chris Coulson

This provides some improvements to the changes in r425-r431. It:
- Makes IOThreadGlobals::Data publically available as Globals, and renames
  IOThreadGlobals to IOThread. This provides a proper API split for accessing
  things that belong to the IO thread
- Reverts the change that made IOThread a singleton - we want to control when
  to destroy it
- Destroys the system URL request context before the IO thread has gone away
  (fixes LP: #1296668)
- Gets rid of URLRequestContextInitializer - this was overcomplicated. Now, we
  subclass URLRequestContextGetter instead
- Move the initialization for common paramters out of URLRequestContextGetter
  in to the constructor for URLRequestContext so that we don't need to rely
  on URLRequestContextGetter to create the request context. This was a bit
  weird anyway

439. By Olivier Tilloy

Implement the JavaScriptDialogManager interface.

440. By Chris Coulson

Update to Chromium 35.0.1908.4

441. By Chris Coulson

Fix some issues with WebPopupMenu:
- Ensure WebPopupMenu::RenderViewHostDeleted() only responds to the appropriate host (LP: #1257663)
- Make sure that Hide() coming from Chromium hides the popup
- Take in to account that WebPopupMenu deletion is asynchronous, so a previous one may still
  exist when a new one is created (assert that the old one is hidden)
- Move all of this stuff in to WebView while we're at it

442. By Chris Coulson

Delete WebFrameAdapterPrivate

443. By Chris Coulson

Remove footgun (webSecurityEnabled). It seems this is only for testing purposes in Chromium, and we have no need for it

444. By Chris Coulson

Remove the smooth scrolling pref - this is currently controlled in Chromium by a temporary command line switch. I suspect it will go away at some point

445. By Chris Coulson

The oxide::WebFrame destructor reenters virtual functions implemented by derived classes - add back a Destroy() method and make its destructor private

446. By Chris Coulson

When our RenderViewHost is swapped out, Chromium attaches the new RVH to the frame tree before notifying us of the swap. This means that the FrameTreeNode's corresponding to our WebFrame's have been deleted when we delete our frame tree, resulting in WebFrame::frame_tree_node_ being left dangling. Modify WebFrame to not store a pointer to its corresponding FrameTreeNode. This fixes a memory corruption bug

447. By Chris Coulson

Fix an invalid read in keyboard event handling

448. By Chris Coulson

Don't set GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB and GLX_LOSE_CONTEXT_ON_RESET_ARB even if supported. Qt doesn't set those, and all GL contexts within a share group must be created with identical attributes

449. By Chris Coulson

Merge from lp:~chrisccoulson/oxide/window-opening

450. By Chris Coulson

Merge from lp:~mardy/oxide/lp1298264

451. By Chris Coulson

Add WebContext.sessionCookieMode

452. By Chris Coulson

Don't build blink debug symbols on native ARM builds, because we're still hitting OOM conditions despite throwing it every memory optimization that I can think of. We already turn them off for Chromium builds

453. By Chris Coulson

Change API version to 1.0

454. By Chris Coulson

When initializing a newly created WebView, ensure we sync the actual WebView size and visibility to its newly adopted WebContents

455. By Chris Coulson

Add code for creating new WebView's with the opener set (but disabled by default until we figure out a safe way of deciding what to do)

456. By Chris Coulson

For the navigation case, create WebContents after we have a new WebView

457. By Chris Coulson

Don't abort for unhandled dispositions, but do an early exit instead

458. By Olivier Tilloy

Send fake keydown and keyup events when composing text with an input method.

459. By Chris Coulson

Update to Chromium 35.0.1916.6

460. By Chris Coulson

Try to make sure we don't create multiple contexts with the same storage location when running the tests

461. By Chris Coulson

Lazy init WebContext (LP: #1297552 part 1)

462. By Chris Coulson

Expose the default WebContext with Oxide.defaultWebContext(), and get rid of all of the proxy properties from the Oxide singleton (LP: #1297552 part 2)

463. By Chris Coulson

Ignore changes to WebContext.sessionCookieMode when there is no data path

464. By Chris Coulson

Use qWarning in qt/core/glue

465. By Chris Coulson

Give UserScript.url a NOTIFY signal

466. By Chris Coulson

Change LoadEvent.error to LoadEvent.errorDomain, expose the raw error code as LoadEvent.errorCode and ensure we cover the full range of Chromium net errors

467. By Chris Coulson

Fix a race in tst_WebView_newViewRequested.qml

468. By Chris Coulson

Make use of net::IsCertificateError

469. By Chris Coulson

Don't duplicate the URL on WebFrame

470. By Alexandre Abreu

fixes

471. By Olivier Tilloy

Use the EGL vendor string to infer the form factor.
This will prevent application confinement from getting in the way.

472. By Chris Coulson

Dispatch WebView.navigationRequested for all window.open() calls or clicks on links with target="_blank". Applications should use this to deny requests to open a new view. Dispatch WebView.newViewRequested when a view should be created and shown. Applications that implement this are expected to create a new WebView here - it shouldn't be used for policy. Hence, NewViewRequest.url and NewViewRequest.userGesture are gone

473. By Chris Coulson

If we can't create new windows, coerce the navigation to a CURRENT_TAB navigation

474. By Chris Coulson

Fix a typo

475. By Chris Coulson

Add bug number

476. By Chris Coulson

Get rid of the hack that registers all resource context when the ResourceDispatcherHost is created - this is cruft left over from earlier days

477. By Chris Coulson

Build Chromium with toolkit_views: 0 and enable_plugins: 0

478. By Chris Coulson

Subframe navigations with a disposition other than CURRENT_TAB in a view that can't create new windows should be redirected to the main frame

479. By Chris Coulson

Make that last commit actually work

480. By Chris Coulson

Add an option for enabling proprietary codecs

481. By Chris Coulson

Build and ship the l10n pak files

482. By Chris Coulson

Add file picker support

483. By Chris Coulson

Add missing resources

484. By Chris Coulson

Only send left, middle and right mouse button events to the renderer. Allow extra mouse buttons to bubble up

485. By Chris Coulson

Unbreak mouse move events

486. By Chris Coulson

Add cursor support

487. By Chris Coulson

Use QQuickItem::setCursor

488. By Chris Coulson

Rework RenderViewItem resizing

489. By Chris Coulson

Make sure the locale pak files get installed

490. By Chris Coulson

Reimplement RenderSandboxHostLinux to run the SandboxIPCProcess in a proper child process (created with fork + exec), as opposed to just forking the browser process and running the helper without exec'ing. Chromium can do this because it fork's the browser process early on before any threads are created, whereas when we fork with Oxide, we already have a full QML application and many running threads. There is a risk of deadlock with this and concerns about memory consumption too, so it's safer to exec a new process image to run the sandbox IPC helper

491. By Chris Coulson

Update to Chromium 35.0.1916.27

492. By Chris Coulson

Ensure that the compositing configuration uses the GpuDataManager (although, we currently don't load any gpu info)

493. By Chris Coulson

Drop remove-broken-gcc-option.patch and add the fix to common.gypi

494. By Chris Coulson

Add a comment to oxide_sandbox_ipc_process.cc

495. By Chris Coulson

Delete unused patch for now

496. By Chris Coulson

Make force compositing mode work correctly

497. By Chris Coulson

In the non-compositing path, handle the case where Chromium gives us a backing store with an out of date size

498. By Chris Coulson

Get rid of RenderWidgetHostViewDelegatePrivate again

499. By Chris Coulson

Ensure we actually composite during resizes

500. By Chris Coulson

Fix a resize crash caused by sending more than one acknowledge for a buffer swap

501. By Chris Coulson

Don't unconditionally build with proprietary_codecs=1, as this causes us to advertise all codecs even when we don't build support for them

502. By Chris Coulson

Update Chromium to 36.0.1933.0

503. By Chris Coulson

Ensure WebPreferences.touchEnabled is not ignored

504. By Chris Coulson

The focus related methods on WebContentsView aren't called by content, but by the embedder for managing focus of views between tab changes. We don't need these, so assert that they aren't called

505. By Chris Coulson

WebView should be a focus scope

506. By Chris Coulson

Add experimental support for the Google Talk PPAPI plugin, required for Google Hangouts (hidden behind a build-time flag at the moment)

507. By Olivier Tilloy

Set no_javascript_access in ContentBrowserClient::CanCreateWindow(…).

508. By Olivier Tilloy

Improve error handling in form factor detection code.

509. By Chris Coulson

GpuChildThread is not thread safe, so store the global pointer in TLS. Provide a static function for accessing a thread safe MessageLoopProxy to dispatch tasks to the GPU thread

510. By Chris Coulson

Optimise the texture resource loading a bit, so that we batch loads in a single task

511. By Chris Coulson

Ensure we have a current GL context when deleting textures

512. By Chris Coulson

Make sure we use the correct MailboxManager to lookup the textures we get from Chromium's compositor

513. By Chris Coulson

Make ENABLE_PLUGINS the default and hide the Google Talk plugin support behind an environment variable

514. By Chris Coulson

Also make ENABLE_OXIDEQMLSCENE the default

515. By Chris Coulson

Add OXIDE_ALLOW_SANDBOX_DEBUGGING to make renderers dumpable

516. By Chris Coulson

Don't call prctl(PR_SET_NO_NEW_PRIVS) after forking the sandbox IPC process, as this prevents the suid sandbox from gaining enough privileges to map inode numbers to PID's on behalf of the zygote

517. By Chris Coulson

Move constants that are only used in one place from oxide_constants.h

518. By Chris Coulson

Turn the environment variable for GTalk in to a command line switch, so that the sandbox doesn't remove it

519. By Chris Coulson

Make sure we only enable options defined in the environment when they are set to "1"

520. By Chris Coulson

Update to Chromium 36.0.1941.0

521. By Chris Coulson

Add support for fullscreen API

522. By Chris Coulson

Make oxide::WebView::{Get,Set}URL and oxide::WebView::{,Set}IsFullscreen work correctly before Init is called (moving the url part from WebViewAdapter

523. By Chris Coulson

Fix a crash on Google Plus when frames are detached before we've done the idle script inject

524. By Chris Coulson

Merge the rendering-updates branch so that we can update Chromium. This removes support for the old 2D drawing mode and async compositing mode, and uses the software compositing and mailbox compositing modes (as an interim solution)

525. By Chris Coulson

Add back the ENABLE_COMPOSITING guard in updatePolish

526. By Chris Coulson

Don't hold pointers to pixel data or texture handles between frames, as those might go stale

527. By Chris Coulson

GpuUtils::GetAcceleratedFrameHandle is racy - the GPU thread task can run before we've incremented the reference count on the main thread, meaning that we can return an already deleted object. Enesure the main thread has a reference before dispatching any task to the GPU thread, and always return an object with a reference count already added

528. By Chris Coulson

Don't disable viewport in software compositing mode

529. By Chris Coulson

Get rid of BrowserProcessMain::flags and just do the form factor customizations in ContentMainDelegate

530. By Chris Coulson

Don't change compositing preferences now that compositing is always used

531. By Chris Coulson

Apply some Android-style customizations when on tablet and phone form factors. In particular, setShrinksViewportContentToFit prevents sites from being zoomed out sufficiently to not fit the display width

532. By Chris Coulson

Drop the form factor check in UpdateCursor, as it's not needed

533. By Chris Coulson

Set a wait cursor when loading

534. By Chris Coulson

We don't plan to implement InitAsPopup and InitAsFullscreen, as we have no use for popup RWHV's

535. By Chris Coulson

Deprecate WebPreferences.touchEnabled and WebPreferences.databasesEnabled, as both of these are runtime-wide settings in blink

536. By Chris Coulson

When fetching the texture ID, we wait on a sync point in the GL command stream. We block the Qt render thread until this has been fetched, which works with minimal overhead on the desktop. However, when running fairly heavy webgl demo's on mobile we sometimes have to wait in excess of 25ms, which means that the frame rate for the whole application falls through the floor. Mitigate against this in a couple of ways:
- Don't post a task to the GPU thread event queue to add a sync point callback. Instead, implement a task observer that processes these after every task
- Don't dispatch SwapAcceleratedFrame until we have a texture ID. Unfortunately, this does mean posting one extra task to the UI thread per frame. Not sure if there's another way to do that

537. By Chris Coulson

Update Chromium to 36.0.1951.5

538. By Chris Coulson

Fix the comment - BrowserProcessMain isn't reference counted anymore

539. By Chris Coulson

Add a couple of extra options that are used on Chrome for Android

540. By Olivier Tilloy

Fix a safety check in debug builds.

541. By Chris Coulson

Merge ninja-build branch. We now build the Chromium parts with ninja rather than make

542. By Chris Coulson

Unbreak checkouts when the release_deps URL changes

543. By Chris Coulson

Update to Chromium 36.0.1964.2

544. By Alexandre Abreu

merge trunk

545. By Alexandre Abreu

merge trunk

546. By Chris Coulson

linux_use_tcmalloc is deprecated

547. By Olivier Tilloy

Provide a Qt implementation of the default system LocationProvider.

548. By Chris Coulson

Add WebView.geolocationPermissionRequested API

549. By Chris Coulson

Update to Chromium 36.0.1976.2

550. By Chris Coulson

Update Chromium to 36.0.1985.8

551. By Chris Coulson

Omit WebContentsViewAura and RenderWidgetHostViewAura from the build, and save on a patch

552. By Chris Coulson

Make sure that unhandled keyboard events are passed to parent items. Thanks to Arthur Mello for starting this work

553. By Chris Coulson

Remove a superfluous include and member function prototype

554. By Chris Coulson

Stop using an internal blink header for keycodes, and add some missing codes

555. By Chris Coulson

We shouldn't generate keypress events with unmodified text on the web side for control characters. This makes Oxide behave like Chrome

556. By Chris Coulson

Add a compile assert that WebKeyboardEvent::text and WebKeyboardEvent::unmodifiedText are the same size, as we assume that they are

557. By Chris Coulson

Use ui::VKEY_PROCESSKEY in sendFakeCompositionKeyEvent

558. By Chris Coulson

Make sure we honour skip_in_browser in WebView::HandleKeyboardEvent

559. By Chris Coulson

Stop using blink::WebInputEvent::KeyDown. Aura and Android both use RawKeyDown + Char

560. By Olivier Tilloy

Add a loadHtml slot to the QML webview.

561. By Chris Coulson

Update Chromium to 36.0.1985.18

562. By Chris Coulson

Make BrowserContext::SetCookiePolicy work the same as BrowserContext::SetUserAgent

563. By Chris Coulson

Bump version to 1.1

564. By Chris Coulson

Don't abort in debug mode on key events

565. By Chris Coulson

Mouse, key and IM events are accepted by default in QtQuick, and we don't need to explicitly accept focus events

566. By Chris Coulson

Make sure we set the correct state on ignored mouse events

567. By Chris Coulson

HandleMouseEvent expects a pre-accepted mouse event

568. By Alexandre Abreu

fix win8 exclusion

569. By Olivier Tilloy

Fix FTBFS with Qt 5.3.

570. By Chris Coulson

Update Chromium to 37.0.2008.2

571. By Chris Coulson

Delete WebContents asynchronously in AddNewContents

572. By Chris Coulson

All handlers of WebView.newViewRequested must create a web view

573. By Chris Coulson

Change the popup blocker preferences after doing the page load in tst_NavigationRequest.qml. For some reason, the popup blocker preferences aren't picked up by the time we generate the click event otherwise

574. By Chris Coulson

Add a critical message to the console if an embedder doesn't create a new webview when requested. All of the tests are fixed now

575. By Chris Coulson

test_NavigationRequest3_reject relies on a timeout and debug builds are sufficiently slow to make this fail intermittently. Rearrange the test a little to make it a bit less susceptible

576. By Chris Coulson

Update the error message to point out the consequences of misbehaving

577. By Chris Coulson

Drop the hidden .channel file, as it's fairly pointless right now

578. By Olivier Tilloy

Add an 'icon' property to the QML WebView.

579. By Chris Coulson

Start decoupling some of our logic around WebContents out of WebView and in to a new class (WebViewContentsHelper). This will allow us to ensure we can observe events from a WebContents that doesn't yet have a corresponding WebView

580. By Chris Coulson

Update to Chromium 37.0.2017.2. This also removes our own implementations of SandboxIPCHandler and RenderSandboxHostLinux, as this has been reimplemented as a browser process thread in Chromium which is fine for Oxide

581. By Chris Coulson

ProcessObserver -> RenderProcessObserver

582. By Chris Coulson

Get rid of unused message declaration

583. By Chris Coulson

Stop using WebContents::SetUserAgentOverride to set the user agent string, as this is unreliable in some circumstances. Instead, have a child-process-global user agent string

584. By Chris Coulson

Use a command line switch for telling a render process that it is an incognito process. Having a dedicated IPC message is silly, because it never changes

585. By Chris Coulson

Make the form factor detection work in single process mode

586. By Chris Coulson

Refactor BrowserProcessMain to get rid of the static initializer, and also make Start() infallible. As we already CHECK() in various places that Chromium is running, allowing BrowserProcessMain::Start() to fail is fairly pointless

587. By Chris Coulson

Move GetNativeDisplay() from ContentClient. It should only be used from the browser process and it never changes, so make it an initialization parameter for BrowserProcessMain

588. By Chris Coulson

Add the shutdown hook when we start Chromium

589. By Chris Coulson

Stop tracking visibility in RenderWidgetHostView

590. By Chris Coulson

Update the RWH visibility when creating a view

591. By Chris Coulson

Loosen platform detection to recognise any platform name starting wth "ubuntu"

592. By Chris Coulson

Update warning

593. By Olivier Tilloy

Fix syntax error.

594. By Olivier Tilloy

Add a unit test for HTTP redirections to verify that the 'url' property of the WebView is updated in between the two load events.

595. By Chris Coulson

Update Chromium to 37.0.2024.2

596. By Olivier Tilloy

Fix FTBFS with Qt 5.3.

597. By Chris Coulson

The display handle is always EGL_DEFAULT_DISPLAY (ie, NULL) with Android EGL

598. By Chris Coulson

Implement ContentClient::GetDataResource (and GetDataResourceBytes for good measure) so that blink can get the images used in the media player UI

599. By Chris Coulson

Now that getting the default native display handle from Qt doesn't rely on having a ContentClient instance, use the proper display handle in IsUbuntuPhoneOrTablet() rather than EGL_DEFAULT_DISPLAY, which fails on mesa-egl in Unity 8 (where the compiled in default display is an X11 one)

600. By Chris Coulson

Support surfaceless EGL

601. By Chris Coulson

Work around a lack of pbuffer support in the Mir EGL mesa backend

602. By Chris Coulson

Select GLES when binding and creating EGL contexts. The Ubuntu QPA plugin selects OpenGL on desktop, but we depend on GLES for surfaceless contexts

603. By Chris Coulson

Don't call eglTerminate in IsUbuntuPhoneOrTablet(), as this terminates a display initialized by Qt, resulting in a crash later on

604. By Chris Coulson

Don't crash in the copy constructor for NativeWebKeyboardEvent when we don't have an OS event

605. By Chris Coulson

Back out r599 for causing a regression when resizing in Unity 7 desktop

606. By Chris Coulson

Bail out of IsUbuntuPhoneOrTablet() early when running on X

607. By Chris Coulson

Now that getting the default native display handle from Qt doesn't rely on having a ContentClient instance, use the proper display handle in IsUbuntuPhoneOrTablet() rather than EGL_DEFAULT_DISPLAY, which fails on mesa-egl in Unity 8 (where the compiled in default display is an X11 one)

608. By Chris Coulson

Bump Chromium rev to 37.0.2031.2

609. By Chris Coulson

Back out r559 for causing LP: #1328000

610. By Chris Coulson

Stop using blink::WebInputEvent::KeyDown. Aura and Android both use RawKeyDown + Char

611. By Chris Coulson

Fix a regression in unhandled key event handling

612. By Olivier Tilloy

Implement the power save blocker interface using the powerd D-Bus API where available.

613. By Chris Coulson

Bump Chromium rev to 37.0.2041.4

614. By Chris Coulson

GetViewBounds() only works when a RenderViewItem is added to a scene

615. By Chris Coulson

Actually make onWindowChanged a slot

616. By Chris Coulson

Bump Chromium rev to 37.0.2054.3

617. By Chris Coulson

Force Qt focus object changed events when the oxide focused node changes

618. By Alexandre Abreu

add devtools support

619. By Chris Coulson

Expose a Flickable-like API on the QML WebView, with content{Width,Height,X,Y} and viewport{Width,Height} attributes

620. By Chris Coulson

Stop using deprecated compositing paths by using a delegating renderer compositor alongside a synchronous browser compositor. Eventually we will delegate this to the Qml scenegraph compositor, although the extra browser compositor will still be useful for a fallback path (and for other ports of Oxide, should they happen)

621. By Chris Coulson

Evict the delegated frame and front buffer for hidden webviews

622. By Chris Coulson

Remove spurious printf

623. By Chris Coulson

Don't crash on shutdown when devtools isn't enabled

624. By Chris Coulson

Bump Chromium rev to 37.0.2062.0

625. By Chris Coulson

Get rid of a new static constructor

626. By Chris Coulson

Back out r617 for now because it causes a crash

627. By Chris Coulson

Force Qt focus object changed events when the oxide focused node changes

628. By Alexandre Abreu

add download api support

629. By Chris Coulson

Set the timeout to 5 seconds rather than 5000 seconds. It seems this was committed by accident

630. By Chris Coulson

Move the webview contents and input event handling from RenderViewItem to WebView, and delete RenderViewItem / qt::RenderWidgetHostView

631. By Chris Coulson

Bump Chromium rev to 37.0.2062.3

632. By Alexandre Abreu

Make sure to keep the default behavior for external protocol (not handled)

633. By Chris Coulson

Clear the counter between tests else the second test always fails

634. By Chris Coulson

The sandbox is not Qt-specific, so it should come out of qt/qt.gypi

635. By Chris Coulson

Make sure we notify the input method of updates to the cursor and anchor positions, and selection text

636. By Chris Coulson

It looks like ImTextBeforeCursor and ImTextAfterCursor only exist in Qt 5.3

637. By Chris Coulson

An empty preedit string doesn't mean we should do a commit. Fixes an issue where pressing the backspace key to delete the last character of a composition doesn't actually delete it

638. By Olivier Tilloy

Ensure that viewport{Width,Height} and content{Width,Height,X,Y} are integer values and that they add up correctly on devices where the device scale factor and page scale factor are floating-point numbers.

639. By Olivier Tilloy

Fix a couple of harmless compiler warnings.

640. By Chris Coulson

Don't exclude .git/index. It's required by angle, at least

641. By Chris Coulson

Don't crash when destroying a visible RWHV (happens when a render process crashes)

642. By Chris Coulson

Bump qt version to 1.2

643. By Chris Coulson

Update ContentBrowserClient::CanCreateWindow so its prototype matches that of the base class impl

644. By Chris Coulson

Don't patch Chromium's EGL code to bind GLES when creating contexts and calling eglMakeCurrent. As the bound API is thread local and the thread default is GLES, binding GLES is only necessary during initialization (which happens on the main thread where the embedder could have selected a different API)

645. By Chris Coulson

Drop add-frame-attached-to-web-contents-observer.patch. We can do this with existing content API

646. By Chris Coulson

Add WebFrame::FromRenderFrameHost

647. By Olivier Tilloy

Update the power save blocker to use the new Unity.Screen D-Bus API on touch devices.

648. By Chris Coulson

Support double-tap-to-zoom

649. By Chris Coulson

Now we are not using the GestureRecognizer, tweak ui::ScaleGestureDetector::Config::min_pinch_update_span_delta to get rid of the coarseness when pinching

650. By Chris Coulson

Get rid of a compiler warning

651. By Chris Coulson

Don't generate touch events for stationary touch points

652. By Chris Coulson

Configure the gesture detection to be closer to Android Chrome

653. By Chris Coulson

Synthesize pending touch ACK's when swapping views

654. By Olivier Tilloy

Delay the loading of data until the webview has been initialized.

655. By Chris Coulson

Don't mix up "double tap touch slop" and "double tap slop" from Android's ViewConfiguration when picking Oxide defaults

656. By Chris Coulson

Make IdAllocator non-copyable, and add some comments to it

657. By Chris Coulson

Don't crash on Qt platforms that don't implement QPlatformNativeInterface. As lack of this prevents us from getting a native display handle, also don't allow any GL implementations and guard against accesses to BrowserProcessMain::GetNativeDisplay()

658. By Chris Coulson

Use the --enable-smooth-scrolling flag rather than setting enable_scroll_animator manually

659. By Alexandre Abreu

add chrome driver support/build

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

I updated the MR, I'd happily get your feedback on this

660. By Chris Coulson

Bump Chromium rev to 37.0.2062.20

661. By Chris Coulson

Bump Chromium rev to 38.0.2096.0

Revision history for this message
Maxim Ermilov (zaspire) wrote :

"oxide" object is not injected after opening another uri in same webview.

review: Needs Fixing
662. By Chris Coulson

Bump Chromium rev to 38.0.2101.0

663. By Chris Coulson

Include the correct UI assets so that the scrollbars work again

664. By Chris Coulson

Add OXIDE_DISABLE_SETUID_SANDBOX and OXIDE_DISABLE_SECCOMP_FILTER_SANDBOX environment variables

665. By Chris Coulson

Assert we have a QGuiApplication on startup

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks for working on this. So, I mentioned on Tuesday that there is potentially another approach to this which effectively eliminates the main problem with the current approach (that we're adding an API that makes oxide fundamentally unsafe).

When injecting user scripts, we have the option of emulating greasemonkey (UserScript.emulateGreasemonkey) where the script is injected in to a private scope. We achieve this in Oxide by basically running the following code within the global scope:

"(function(unsafeWindow) {" + script + "})(window)"

(see shared/renderer/oxide_user_script_slave.cc). Potentially, we could extend this to pass in the privileged oxide API for user scripts that are injected in to the main world (it wouldn't be needed for others as we make it available in the global scope). Obviously, you would only be able to do this for scripts in the main world that use UserScript.emulateGreasemonkey - as scripts that don't use this should be injected in to the global scope.

To achieve this, we need changes in a few places:
- ScriptMessageDispatcherRenderer::DidCreateScriptContext() will need to create a ScriptMessageManager for the main world
- ScriptMessageManager shouldn't add the oxide API to the global object when it's associated with the main world
- ScriptMessageManager would need an accessor for returning the oxide API
- We probably need a way to translate between a WebFrame + world ID to a ScriptMessageManager and V8 context
- For this particular case (greasemonkey emulated script in the main world), UserScriptSlave::InjectScripts() would need to be modified to construct a Function object that will run the existing script code, and use blink::WebFrame::callFunctionEvenIfScriptDisabled() to run the function with the oxide API as its argument (see how ScriptMessageManager::OxideLazyGetterInner() works).

How does this sound? I can probably help out with some of these - particularly with any refactoring of the existing code to make this possible

Revision history for this message
Maxim Ermilov (zaspire) wrote :

> we're adding an API that makes oxide fundamentally unsafe
exaggeration.
this api will be used only with trusted html code (embedded webview case).
+ applications will run with apparmor profile.

So It's bad reason to over complicate api.

666. By Chris Coulson

Stop using ContentMainRunner for starting the browser code - it messes with process global stuff that is unexpected in a public library (eg, clearing the SIGCHLD handler)

667. By Chris Coulson

Bump Chromium rev to 38.0.2107.2

668. By Chris Coulson

Add USE_GCC_VERSION option for the cross-compile toolchain file

669. By Chris Coulson

Revert r668 because of an unrelated change

670. By Chris Coulson

Add USE_GCC_VERSION option for the cross-compile toolchain file

671. By Chris Coulson

Unbreak fresh builds with the current Chromium version

672. By Chris Coulson

Fix an arm link failure caused by a recent webrtc change

673. By Chris Coulson

Tidy up the inconsistent BrowserProcessMain interface where we have a mixture of static and non-static functions

674. By Chris Coulson

CHECK that CommandLine::Init doesn't fail

675. By Chris Coulson

BrowserMainRunner should really be deleted before AtExitManager - it is in Chrome

676. By Chris Coulson

Remove comment about moving the MessageLoopForUI::Stop call to BrowserMainParts - it's ok where it is

677. By Chris Coulson

Bump Chromium rev to 38.0.2107.3

678. By Chris Coulson

CHECK that SIGCHLD isn't being ignored, and ignore SIGPIPE if the application hasn't overridden the default handler for it

679. By Olivier Tilloy

Ensure files returned by the file picker exist.

680. By Chris Coulson

Bump Chromium rev to 38.0.2114.2

681. By Chris Coulson

Don't send a URL longer than content::GetMaxURLChars() when fetching the override for navigator.userAgent, as this fails to deserialize in the browser process, causing it to abort the renderer

682. By Chris Coulson

Make sure tst_bug1349510 doesn't trigger a different bug (we'll track the issue with FrameHostMsg_OpenURL separately)

683. By Alexandre Abreu

cookie manager api

684. By Alexandre Abreu

Add bind ip to devtools API

685. By Chris Coulson

Bump Chromium rev to 38.0.2121.3

686. By Chris Coulson

Strip down BrowserContextImpl / OTRBrowserContextImpl by introducing 2 new structs for data members shared between a BrowserContext pair (BrowserContextSharedData and BrowserContextSharedIOData), which allows us to drop all of the virtual methods that proxy calls between the 2 BrowserContexts

687. By Chris Coulson

Guard BrowserContext entry points to ensure they are only called on the UI thread, and also return a strong reference from BrowserContext::Create so that ownership is explicit now

688. By Chris Coulson

Use DCHECK_CURRENTLY_ON where appropriate

689. By Alexandre Abreu

Add accept language translation support

690. By Alexandre Abreu

update pos

691. By Chris Coulson

Bump Chromium rev to 38.0.2125.0

692. By Chris Coulson

Build with host_clang == 0

693. By Chris Coulson

Fixes for WebContext + WebContextDelegateWorker threading:
- IODelegate is no longer owned by WebContextAdapterPrivate with a raw pointer in OxideQQuickWebContextPrivate. It is now owned by OxideQQuickWebContextPrivate with a weak pointer in WebContextAdapterPrivate.
- UIThreadController is merged in to OxideQQuickWebContextDelegateWorkerPrivate
- IOThreadController is now accessed via QSharedPointer rather than owning this in OxideQQuickWebContextDelegateWorkerPrivate and accessing it from WebContextIODelegate through a raw pointer. This avoids us having to hold a lock for the entire duration of calls in to the worker on Chromium's IO thread, ensuring that setting a new worker or deleting an existing one will no longer block the UI thread if the IO thread is calling in to the existing worker.
- HelperThreadController is shared between IOThreadController and OxideQQuickWebContextDelegateWorkerPrivate, ensuring it remains alive as long as either the UI thread or IO thread entry points remain accessible.
- Add assertions in various places that we are on the correct thread.

694. By Chris Coulson

Rename run_qmlscene.sh to run_qmlapp.sh and allow it to run any QML app

695. By Chris Coulson

Drop the random operator overloads for allowing bitwise operations on FrameMetadataChangeFlags. Instead, use QFlags in the qml plugin and introduce a new macro for creating bitwise operator overloads for enums (OXIDE_MAKE_ENUM_BITWISE_OPERATORS), partly modelled on Mozilla's MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS

696. By Chris Coulson

Don't leak the default WebPreferences when setting a new one

697. By Chris Coulson

Make revocation checking work by ensuring that NSS has a MessageLoop and URLRequestContext. This is required for Extended Validation to work correctly, and also fixes a bunch of console warnings: "No URLRequestContext for NSS HTTP handler"

698. By Chris Coulson

Bump Chromium rev to 38.0.2125.8

699. By Chris Coulson

Don't leak GeolocationPermissionRequest if there are no handlers on WebView.geolocationPermissionRequested

700. By Chris Coulson

Update for the Chromium GIT migration

701. By Chris Coulson

Revert r700 - it breaks the current checkout and doesn't make it possible to check out 38.0.2125.24 either

702. By Chris Coulson

Update for the Chromium GIT migration

703. By Chris Coulson

Make sure we fetch branch heads

704. By Chris Coulson

Bump depot_tools to 8f93f79bcee79072a70cf9c8c392ad140f0cecf1

705. By Chris Coulson

Bump Chromium rev to 38.0.2125.24

706. By Chris Coulson

Add WebView.securityStatus, WebView.blockedContent, WebView.setCanTemporarilyDisplayInsecureContent, WebView.setCanTemporarilyRunInsecureContent, SecurityStatus, CertificateError and SslCertificate API's. I'm still working on tests for these API's, but this shouldn't block webbrowser-app work

707. By Chris Coulson

Fix various issues with the CookieManager code:
- getNextRequestId() always returns zero
- getNextRequestId() depends on undefined beahviour (signed integer overflow)
- CookieMonster calls the callbacks synchronously if nothing needs to be loaded from permanent storage. This means that the behaviour of setting one cookie and waiting for the callback to run before setting the next causes the stack to grow depending on the amount of cookies being set (and also means lots of reentry). Rework it to prevent this behaviour.
- Ensure that the responses at the API level always do happen asynchronously.
- Setting a session cookie always fails because the undefined expiry date gets interpreted as a date far in the past, so Chromium considers the cookie expired.
- Ensure that session cookies returned from the API don't have an expiry date way in the past.

There are a few minor changes to the API too:
- CookieManager.gotCookies does not return a status code now. The only possible errors when reading cookies occur synchronously (ie, the CookieStore is unavailable), so the API just returns an invalid request ID now.
- The addition of CookieManager.getCookies(), which allows you to retrieve all cookies for a URL.
- The expirationdate attribute now works with the built-in Date type rather than having to give it the expiry in milliseconds since the epoch.

The tests have been improved as well to actually test the various cases rather than just calling in to the API and making sure we get a response back

708. By Chris Coulson

Set the gettext domain to oxide-qt rather than oxide

709. By Chris Coulson

Bump qt version to 1.3

710. By Chris Coulson

Bump Chromium rev to 39.0.2138.3

711. By Chris Coulson

Some minor tweaks to the CookieManager API:
- Bring back setNetworkCookies as this is being used from C++ code in webbrowser-app. Note that the url parameter is no longer a QString though (it's a QUrl)
- Remove the status parameter entirely from the response to setCookies/setNetworkCookies - the problem with this is that it provides no way to know which cookies failed and which ones were set successfully. Instead, replace it by a new parameter (failedCookies) which returns a list of cookies that failed to set.
- Having setCookies + cookiesSet and getCookies + gotCookies is a bit confusing. These are now changed to setCookies + setCookiesResponse and getCookies + getCookiesResponse.

712. By Chris Coulson

Add back support for ms since epoch for the expirationdate, as well as ISO8601 strings

713. By Chris Coulson

Clear the temporary mixed content blocker settings for navigations that aren't within the same page (ie, where more than the URL fragment changes) and aren't due to a content-initiated reload. The last one is needed to avoid ending up in an infinite loop

714. By Chris Coulson

Don't initialize NSS with a user DB

715. By Chris Coulson

Add CookieManager.deleteAllCookies and use this in place of clear-test-cookies-hack.py

716. By Chris Coulson

Get rid of run-qmltests.cmake - just use run_qmlapp.sh for this instead

717. By Chris Coulson

Add @run-at document-start to TestUtilsSlave.js to hopefully fix some random test failures that look like a race

718. By Chris Coulson

Bump Chromium rev to 39.0.2145.4

719. By Chris Coulson

Split the event loop implementation in runtests.py in to its own module

720. By Chris Coulson

Tidy up the cmake files a bit. The include files are gone - they aren't needed anyway and it wasn't really obvious where new variables should go. The changes also fix a problem where running cmake in a cross-compile set up with a cache file already seems to fail

721. By Chris Coulson

Give each test its own datadir. Should hopefully fix LP: #1278315

722. By Chris Coulson

Split the HTTP server in to its own module

723. By Chris Coulson

Move mock plugin to out/plugins

724. By Chris Coulson

OxideQQuickGlobals -> OxideQQuickGlobal

725. By Chris Coulson

Add tests for WebView.securityStatus, SecurityStatus and SslCertificate

726. By Chris Coulson

Add some tests for navigating away from a HTTPS URL

727. By Chris Coulson

ssl-api => ssl

728. By Chris Coulson

Revert accidental commit

729. By Chris Coulson

Split the certificate tests in to their own test

730. By Chris Coulson

Remove bogus chunk from patch

731. By Chris Coulson

Verify the certificate fingerprint in tst_SecurityStatus.qml. Whilst we test the SslCertificate API in a separate test, SslCertificate objects have 2 sources in Oxide and we should verify that both of these create them correctly

732. By Chris Coulson

Add tests for CertificateError

733. By Chris Coulson

Revert accidental change again

734. By Chris Coulson

Add tests for WebPreferences.can{Display,Run}InsecureContent

735. By Chris Coulson

Make sure we add some checks for WebView.blockedContent

736. By Chris Coulson

Ensure WebView.blockedContent is set appropriately after a reload

737. By Chris Coulson

Add tests for WebView.setCanTemporarily{Display,Run}InsecureContent() API's

738. By Chris Coulson

B'ah, I keep committing this change

739. By Chris Coulson

Fix a nullptr deref with non-overridable certificate errors

740. By Chris Coulson

Make all subframe and subresource SSL errors non-overridable, as overriding them currently doesn't always result in the security status API indicating a degraded security level

741. By Chris Coulson

Add WebContext.hostMappingRules API and add a set of mappings in TestWebContext. This allows us to load content from different domains (that get mapped to localhost), and made it possible to discover bug 1368385

742. By Chris Coulson

Test SecurityStatus for insecure content in subframes

743. By Chris Coulson

Merge tst_CertificateError_allow/tst_CertificateError_denial

744. By Chris Coulson

Test CertificateError.isCancelled

745. By Chris Coulson

Sigh...

746. By Chris Coulson

Test the mixed content preferences with subframes

747. By Chris Coulson

Add subframe tests for the mixed content override

748. By Chris Coulson

Fix a regression on clean builds introduced by r720

749. By Chris Coulson

Append to QML2_IMPORT_PATH, as Qt adds these in order to the import path list, and the most recently added is used first

750. By Chris Coulson

Fix various issues with make package

751. By Chris Coulson

Fix a rounding error when calculating the view size in DIP which results in one axis overflowing by a pixel and the other axis underflowing by a pixel

752. By Chris Coulson

Back out r751 because it breaks window.screen{X,Y}

753. By Chris Coulson

Fix a rounding error when calculating the view size in DIP which results in one axis overflowing by a pixel and the other axis underflowing by a pixel

754. By Alexandre Abreu

Make the gesttext domain oxide-qt a proper define

755. By Chris Coulson

Bump Chromium rev to 39.0.2159.4

756. By Chris Coulson

Fix undefined variable error when running cmake

Revision history for this message
Maxim Ermilov (zaspire) wrote :

any news ?

757. By Chris Coulson

Auto scroll the focused editable node in to view when the input method appears

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

> any news ?
about to update the branch soon

758. By Chris Coulson

Make sure we can set domain cookies

759. By Chris Coulson

Deprecate WebView.loadingChanged, introduce WebView.loadEvent for delivering LoadEvents and WebView.loadingStateChanged for notifying of changes to WebView.loading

760. By Chris Coulson

Add LoadEvent.TypeCommitted, as this is when the security origin of the page changes. It could be useful for clearing any context an application might, related to the security origin of the page

761. By Chris Coulson

Don't save "cachedir = None" in .client.cfg when --cache-dir isn't specified, as it breaks checkouts

762. By Alexandre Abreu

Merge trunk

763. By Alexandre Abreu

fix

764. By Alexandre Abreu

small fix

765. By Alexandre Abreu

fix crasher w/ gm script compilation; fix issue when reloading

766. By Alexandre Abreu

fix tests

767. By Alexandre Abreu

remove clutter

768. By Alexandre Abreu

allow the handle to escape the scope

769. By Alexandre Abreu

fix tests and main frame injection

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

should be ready to review

770. By Alexandre Abreu

small fix

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks for working on this. Some general comments:
- The special URL "oxide-private://main-world-private" would be fine as just "oxide://main-world"

- I'm not sure using greasemonkey metadata for this is a good idea. Scripts that define @inject_in_main_world in their header effectively change the behaviour of the UserScript.context API (it looks like it would be ignored if UserScript.emulateGreasemonkey is true). Also, @inject_in_main_world behaves differently depending on whether UserScript.emulateGreasemonkey is set or not.

Not only that, but the design is inherently unsafe - imagine the webbrowser grows the ability to install and run custom user scripts in the way that Chrome can with extensions. At the moment, the browser can safely isolate scripts based on their source by injecting them in to their own world (like Chrome, which gives each extension ID its own world). Having this additional metadata in the script header means that scripts can bypass this mechanism entirely.

We should drop this additional metadata and probably just rely on the special URL for UserScript.context. That would also mean you wouldn't need the additional accessors on oxide::UserScript. If UserScript.context is set to the special URL, the script should be injected in to the main world regardless of the state of UserScript.emulateGreasemonkey (but obviously, they wouldn't get the privileged API if UserScript.emulateGreasemonkey isn't set).

Note, this would also require a test to verify that scripts injected in to the main world don't have access to oxide.sendMessage if UserScript.emulateGreasemonkey is set to false.

- For tests in qt/tests/qmltests/api, I try to name them as close as possible to the API or class that they are testing. tst_WebView_scriptMainWorld doesn't really make much sense here - it would probably be better off in qt/tests/qmltests/core (and there are already some related tests there).

There are some additional comments inline too.

review: Needs Fixing
771. By Alexandre Abreu

updates

772. By Alexandre Abreu

fix small but important piece that had to be removed

773. By Alexandre Abreu

fixes

774. By Alexandre Abreu

move test file to core/

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

Updated,

There is one thing that in the inline comments I did not do (since I did not necessarily agree), it is about the specialized ScriptMessageManagerForWorldId for the main world along w/ a dedicated variable, I have the impression that it will complicate the code a bit and I find it relevant (eventhough it is only used from one context at this point) to have a very dedicated member function there,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'qt/tests/qmltests/core/tst_WebView_scriptMainWorld.html'
2--- qt/tests/qmltests/core/tst_WebView_scriptMainWorld.html 1970-01-01 00:00:00 +0000
3+++ qt/tests/qmltests/core/tst_WebView_scriptMainWorld.html 2014-10-08 13:23:51 +0000
4@@ -0,0 +1,12 @@
5+<html>
6+
7+<script>
8+</script>
9+
10+<body>
11+ <h1>SCRIPT MAIN WORLD test</h1>
12+ <iframe src="empty.html"></iframe>
13+ <div id="result"></div>
14+</body>
15+</html>
16+
17
18=== added file 'qt/tests/qmltests/core/tst_WebView_scriptMainWorld.qml'
19--- qt/tests/qmltests/core/tst_WebView_scriptMainWorld.qml 1970-01-01 00:00:00 +0000
20+++ qt/tests/qmltests/core/tst_WebView_scriptMainWorld.qml 2014-10-08 13:23:51 +0000
21@@ -0,0 +1,112 @@
22+import QtQuick 2.0
23+import QtTest 1.0
24+import com.canonical.Oxide 1.0
25+import com.canonical.Oxide.Testing 1.0
26+
27+TestWebView {
28+ id: webView
29+ focus: true
30+ width: 200
31+ height: 200
32+
33+ property var addedScript: null
34+
35+ Component {
36+ id: userScript
37+ UserScript {}
38+ }
39+
40+ Component {
41+ id: scriptMessageHandler
42+ ScriptMessageHandler {}
43+ }
44+
45+ TestCase {
46+ name: "WebView_scriptMainWorld"
47+ when: windowShown
48+
49+ function init() {
50+ if (webView.addedScript) {
51+ webView.context.removeUserScript(addedScript)
52+ webView.addedScript = null
53+ }
54+ }
55+
56+ function resultUpdated(testapi) {
57+ var res;
58+ try {
59+ res = testapi.evaluateCode("\
60+ var el = document.getElementById(\"result\");\
61+ if (!el) throw Exception();\
62+ return el.innerHTML;", true);
63+ } catch(e) {
64+ fail("#result not found: " + JSON.stringify(e));
65+ }
66+ return res;
67+ }
68+
69+ function test_WebView_canInjectInMainWorldWithOxideApi() {
70+ webView.addedScript = userScript.createObject(null, {
71+ context: "oxide://main-world",
72+ emulateGreasemonkey: true,
73+ url: "tst_WebView_scriptMainWorld_user_script.js"});
74+ webView.context.addUserScript(webView.addedScript);
75+
76+ webView.url = "http://testsuite/tst_WebView_scriptMainWorld.html";
77+ verify(webView.waitForLoadSucceeded(),
78+ "Timed out waiting for successful load");
79+
80+ var testApi = webView.getTestApi();
81+ var res = webView.waitFor(function () { return resultUpdated(testApi); })
82+
83+ compare(res, "Main world content script found oxide.sendMessage",
84+ "Unexpected result message");
85+ }
86+
87+ function test_WebView_verifyRegularMainWorldScriptDoesNotHaveAccessToOxideApi() {
88+ webView.addedScript = userScript.createObject(null, {
89+ context: "oxide://main-world",
90+ url: "tst_WebView_scriptMainWorld_user_script.js"});
91+ webView.context.addUserScript(webView.addedScript);
92+
93+ webView.url = "http://testsuite/tst_WebView_scriptMainWorld.html";
94+ verify(webView.waitForLoadSucceeded(),
95+ "Timed out waiting for successful load");
96+
97+ var testApi = webView.getTestApi();
98+ var res = webView.waitFor(function () { return resultUpdated(testApi); })
99+
100+ compare(res, "Main world content script DID NOT found oxide.sendMessage",
101+ "Unexpected result message");
102+ }
103+
104+ function test_WebView_receiveMessageFromMainWorldUserscript() {
105+ webView.addedScript = userScript.createObject(null, {
106+ context: "oxide://main-world",
107+ emulateGreasemonkey: true,
108+ url: "tst_WebView_scriptMainWorld_user_script.js"});
109+
110+ var received = null;
111+ var frame = webView.rootFrame;
112+ var handler = scriptMessageHandler.createObject(null, {
113+ msgId: "from-user-script",
114+ contexts: ["oxide://main-world"],
115+ callback: function(msg, frame) {
116+ received = msg.args;
117+ }
118+ });
119+
120+ frame.addMessageHandler(handler);
121+
122+ webView.context.addUserScript(webView.addedScript);
123+ webView.url = "http://testsuite/tst_WebView_scriptMainWorld.html";
124+
125+ verify(webView.waitForLoadSucceeded(),
126+ "Timed out waiting for successful load");
127+
128+ verify(received != null, "Did not receive message from the main frame's userscript");
129+ compare(received.data, "mydata" , "Did not receive message from the main frame's userscript");
130+ }
131+ }
132+}
133+
134
135=== added file 'qt/tests/qmltests/core/tst_WebView_scriptMainWorld_user_script.js'
136--- qt/tests/qmltests/core/tst_WebView_scriptMainWorld_user_script.js 1970-01-01 00:00:00 +0000
137+++ qt/tests/qmltests/core/tst_WebView_scriptMainWorld_user_script.js 2014-10-08 13:23:51 +0000
138@@ -0,0 +1,10 @@
139+try {
140+ oxide.sendMessage("from-user-script", {"data": "mydata", "values": [1, 2, 3]});
141+ oxide.addMessageHandler("from-user-script", function(msg) {});
142+ document.getElementById("result").innerHTML =
143+ "Main world content script found oxide.sendMessage";
144+} catch(e) {
145+ document.getElementById("result").innerHTML =
146+ "Main world content script DID NOT found oxide.sendMessage";
147+}
148+
149
150=== modified file 'shared/common/oxide_constants.cc'
151--- shared/common/oxide_constants.cc 2014-06-02 15:35:10 +0000
152+++ shared/common/oxide_constants.cc 2014-10-08 13:23:51 +0000
153@@ -27,3 +27,8 @@
154 const char kIncognito[] = "incognito";
155
156 } // namespace switches
157+
158+namespace oxide {
159+const int kMainWorldId = 0;
160+const char kMainWorldContextUrl[] = "oxide://main-world";
161+} // namespace oxide
162
163=== modified file 'shared/common/oxide_constants.h'
164--- shared/common/oxide_constants.h 2014-06-02 15:35:10 +0000
165+++ shared/common/oxide_constants.h 2014-10-08 13:23:51 +0000
166@@ -29,4 +29,9 @@
167
168 } // namespace switches
169
170+namespace oxide {
171+extern const int kMainWorldId;
172+extern const char kMainWorldContextUrl[];
173+}
174+
175 #endif // _OXIDE_SHARED_COMMON_CONSTANTS_H_
176
177=== modified file 'shared/renderer/oxide_isolated_world_map.cc'
178--- shared/renderer/oxide_isolated_world_map.cc 2014-02-21 17:37:53 +0000
179+++ shared/renderer/oxide_isolated_world_map.cc 2014-10-08 13:23:51 +0000
180@@ -22,6 +22,8 @@
181 #include "base/lazy_instance.h"
182 #include "base/logging.h"
183
184+#include "shared/common/oxide_constants.h"
185+
186 namespace oxide {
187
188 namespace {
189@@ -39,6 +41,9 @@
190 int IsolatedWorldMap::IDFromURL(const GURL& url) {
191 CHECK(url.is_valid());
192
193+ if (url == GURL(kMainWorldContextUrl))
194+ return kMainWorldId;
195+
196 WorldIDMapIterator it = g_isolated_world_map.Get().find(url);
197 if (it != g_isolated_world_map.Get().end()) {
198 return it->second;
199@@ -52,6 +57,9 @@
200
201 // static
202 GURL IsolatedWorldMap::URLFromID(int id) {
203+ if (id == kMainWorldId)
204+ return GURL(kMainWorldContextUrl);
205+
206 for (WorldIDMapIterator it = g_isolated_world_map.Get().begin();
207 it != g_isolated_world_map.Get().end(); ++it) {
208 if (it->second == id) {
209
210=== modified file 'shared/renderer/oxide_script_message_dispatcher_renderer.cc'
211--- shared/renderer/oxide_script_message_dispatcher_renderer.cc 2014-09-09 22:43:03 +0000
212+++ shared/renderer/oxide_script_message_dispatcher_renderer.cc 2014-10-08 13:23:51 +0000
213@@ -24,11 +24,15 @@
214 #include "base/memory/ref_counted.h"
215 #include "content/public/renderer/render_frame.h"
216 #include "content/public/renderer/render_thread.h"
217+#include "content/public/renderer/render_view.h"
218 #include "ipc/ipc_message.h"
219 #include "ipc/ipc_message_macros.h"
220+#include "third_party/WebKit/public/web/WebLocalFrame.h"
221 #include "third_party/WebKit/public/web/WebFrame.h"
222+#include "third_party/WebKit/public/web/WebView.h"
223 #include "url/gurl.h"
224
225+#include "shared/common/oxide_constants.h"
226 #include "shared/common/oxide_messages.h"
227 #include "shared/common/oxide_script_message_request.h"
228
229@@ -50,10 +54,6 @@
230 void ScriptMessageDispatcherRenderer::WillReleaseScriptContext(
231 v8::Handle<v8::Context> context,
232 int world_id) {
233- if (world_id < 1) {
234- return;
235- }
236-
237 v8::HandleScope handle_scope(context->GetIsolate());
238
239 for (ScriptMessageManagerVector::iterator it = script_message_managers_.begin();
240@@ -159,6 +159,19 @@
241 CHECK(rv.second);
242 }
243
244+linked_ptr<ScriptMessageManager>
245+ScriptMessageDispatcherRenderer::ScriptMessageManagerForWorldId(int world_id) {
246+ linked_ptr<ScriptMessageManager> message_manager;
247+ for (ScriptMessageManagerVector::iterator it = script_message_managers_.begin();
248+ it != script_message_managers_.end();
249+ ++it) {
250+ if ((*it)->frame() == render_frame() && (*it)->world_id() == world_id) {
251+ message_manager = *it;
252+ }
253+ }
254+ return message_manager;
255+}
256+
257 ScriptMessageDispatcherRenderer::~ScriptMessageDispatcherRenderer() {
258 // RenderFrameObserver has already cleared it's pointer to our RenderFrame
259 for (ScriptMessageDispatcherMap::iterator it = g_dispatcher_map.Get().begin();
260@@ -182,10 +195,6 @@
261 void ScriptMessageDispatcherRenderer::DidCreateScriptContext(
262 v8::Handle<v8::Context> context,
263 int world_id) {
264- if (world_id < 1) {
265- return;
266- }
267-
268 script_message_managers_.push_back(
269 linked_ptr<ScriptMessageManager>(new ScriptMessageManager(render_frame(),
270 context,
271
272=== modified file 'shared/renderer/oxide_script_message_dispatcher_renderer.h'
273--- shared/renderer/oxide_script_message_dispatcher_renderer.h 2014-05-01 15:25:31 +0000
274+++ shared/renderer/oxide_script_message_dispatcher_renderer.h 2014-10-08 13:23:51 +0000
275@@ -45,6 +45,8 @@
276
277 static ScriptMessageDispatcherRenderer* FromWebFrame(blink::WebFrame* frame);
278
279+ linked_ptr<ScriptMessageManager> ScriptMessageManagerForWorldId(int world_id);
280+
281 void DidCreateScriptContext(v8::Handle<v8::Context> context,
282 int world_id);
283
284
285=== modified file 'shared/renderer/oxide_script_message_manager.cc'
286--- shared/renderer/oxide_script_message_manager.cc 2014-09-15 10:45:20 +0000
287+++ shared/renderer/oxide_script_message_manager.cc 2014-10-08 13:23:51 +0000
288@@ -29,6 +29,8 @@
289 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
290 #include "ui/base/resource/resource_bundle.h"
291
292+#include "shared/common/oxide_constants.h"
293+
294 #include "oxide_isolated_world_map.h"
295 #include "oxide_script_message_handler_renderer.h"
296 #include "oxide_script_message_request_impl_renderer.h"
297@@ -94,11 +96,9 @@
298 mm->Value())->OxideLazyGetterInner(property, info);
299 }
300
301-void ScriptMessageManager::OxideLazyGetterInner(
302- v8::Local<v8::String> property,
303- const v8::PropertyCallbackInfo<v8::Value>& info) {
304- v8::Isolate* isolate = info.GetIsolate();
305- v8::HandleScope handle_scope(isolate);
306+v8::Handle<v8::Object> ScriptMessageManager::GetOxideApiObject(
307+ v8::Isolate* isolate) {
308+ v8::EscapableHandleScope handle_scope(isolate);
309
310 base::StringPiece raw_src(
311 ui::ResourceBundle::GetSharedInstance().GetRawDataResource(
312@@ -121,7 +121,7 @@
313 v8::Local<v8::Function> function(script->Run().As<v8::Function>());
314 if (try_catch.HasCaught()) {
315 LOG(ERROR) << "Caught exception when running script";
316- return;
317+ return v8::Handle<v8::Object>();
318 }
319
320 v8::Local<v8::External> local_data(closure_data_.NewHandle(isolate));
321@@ -152,9 +152,20 @@
322 }
323 if (try_catch.HasCaught()) {
324 LOG(ERROR) << "Caught exception when running script function";
325- return;
326+ return v8::Handle<v8::Object>();
327 }
328
329+ return handle_scope.Escape(exports);
330+}
331+
332+void ScriptMessageManager::OxideLazyGetterInner(
333+ v8::Local<v8::String> property,
334+ const v8::PropertyCallbackInfo<v8::Value>& info) {
335+ v8::Isolate* isolate = info.GetIsolate();
336+ v8::HandleScope handle_scope(isolate);
337+
338+ v8::Handle<v8::Object> exports(GetOxideApiObject(isolate));
339+
340 v8::Handle<v8::Value> val = info.This();
341 if (val->IsObject()) {
342 v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(val);
343@@ -347,10 +358,12 @@
344 closure_data_.reset(isolate(), v8::External::New(isolate(), this));
345 v8::Local<v8::External> local_data(closure_data_.NewHandle(isolate()));
346
347- v8::Local<v8::Object> global(context->Global());
348- global->SetAccessor(v8::String::NewFromUtf8(isolate(), "oxide"),
349- OxideLazyGetter, NULL,
350- local_data);
351+ if (world_id_ != kMainWorldId) {
352+ v8::Local<v8::Object> global(context->Global());
353+ global->SetAccessor(v8::String::NewFromUtf8(isolate(), "oxide"),
354+ OxideLazyGetter, NULL,
355+ local_data);
356+ }
357 }
358
359 ScriptMessageManager::~ScriptMessageManager() {}
360
361=== modified file 'shared/renderer/oxide_script_message_manager.h'
362--- shared/renderer/oxide_script_message_manager.h 2014-02-28 12:53:41 +0000
363+++ shared/renderer/oxide_script_message_manager.h 2014-10-08 13:23:51 +0000
364@@ -56,6 +56,8 @@
365
366 GURL GetContextURL() const;
367
368+ int world_id() const { return world_id_; }
369+
370 content::RenderFrame* frame() const { return frame_; }
371
372 v8::Isolate* isolate() const { return isolate_; }
373@@ -70,6 +72,8 @@
374
375 ScriptMessageHandlerRenderer* GetHandlerForMsgID(const std::string& msg_id);
376
377+ v8::Handle<v8::Object> GetOxideApiObject(v8::Isolate* isolate);
378+
379 private:
380 friend class ScriptMessageRequestImplRenderer;
381 typedef std::map<std::string, linked_ptr<ScriptMessageHandlerRenderer> > ScriptMessageHandlerMap;
382
383=== modified file 'shared/renderer/oxide_user_script_slave.cc'
384--- shared/renderer/oxide_user_script_slave.cc 2014-06-02 15:35:10 +0000
385+++ shared/renderer/oxide_user_script_slave.cc 2014-10-08 13:23:51 +0000
386@@ -29,15 +29,19 @@
387 #include "third_party/WebKit/public/platform/WebURLRequest.h"
388 #include "third_party/WebKit/public/web/WebDataSource.h"
389 #include "third_party/WebKit/public/web/WebLocalFrame.h"
390+#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
391 #include "third_party/WebKit/public/web/WebScriptSource.h"
392 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
393 #include "url/gurl.h"
394+#include "v8/include/v8.h"
395
396 #include "shared/common/oxide_constants.h"
397 #include "shared/common/oxide_messages.h"
398 #include "shared/common/oxide_user_script.h"
399
400 #include "oxide_isolated_world_map.h"
401+#include "oxide_script_message_dispatcher_renderer.h"
402+#include "oxide_script_message_manager.h"
403
404 namespace oxide {
405
406@@ -105,6 +109,76 @@
407 content::RenderThread::Get()->RemoveObserver(this);
408 }
409
410+void UserScriptSlave::InjectGreaseMonkeyScriptInMainWorld(
411+ blink::WebLocalFrame* frame,
412+ const blink::WebScriptSource& script_source) {
413+
414+ ScriptMessageDispatcherRenderer * dispatcher_renderer =
415+ ScriptMessageDispatcherRenderer::FromWebFrame(frame);
416+ DCHECK(dispatcher_renderer != NULL);
417+
418+ linked_ptr<ScriptMessageManager> message_manager =
419+ dispatcher_renderer->ScriptMessageManagerForWorldId(kMainWorldId);
420+ DCHECK(message_manager != NULL);
421+ if (!message_manager.get()) {
422+ LOG(ERROR) << "Could not get a proper message manager for frame: "
423+ << frame
424+ << " while trying to inject script in main world";
425+ return;
426+ }
427+
428+ v8::Isolate* isolate = message_manager->isolate();
429+ v8::HandleScope handle_scope(isolate);
430+ v8::Context::Scope context_scope(message_manager->GetV8Context());
431+
432+ v8::Local<v8::String> wrapped_script_head(v8::String::NewFromUtf8(
433+ isolate,
434+ "(function(oxide) {\n"
435+ ));
436+
437+ v8::Local<v8::String> src(
438+ v8::String::NewFromUtf8(
439+ isolate,
440+ script_source.code.utf8().c_str()));
441+ DCHECK(!src.IsEmpty() && src->Length() > 0);
442+
443+ v8::Local<v8::String> wrapped_script_tail(
444+ v8::String::NewFromUtf8(isolate, "\n})"));
445+
446+ v8::Local<v8::String> wrapped_src(
447+ v8::String::Concat(wrapped_script_head,
448+ v8::String::Concat(src, wrapped_script_tail)));
449+
450+ v8::Local<v8::Script> script(
451+ v8::Script::Compile(wrapped_src));
452+
453+ v8::TryCatch try_catch;
454+ v8::Local<v8::Function> function(script->Run().As<v8::Function>());
455+ if (try_catch.HasCaught()) {
456+ LOG(ERROR) << "Caught exception when running script: "
457+ << *v8::String::Utf8Value(try_catch.Message()->Get());
458+ return;
459+ }
460+
461+ v8::Handle<v8::Value> argv[] = {
462+ message_manager->GetOxideApiObject(message_manager->isolate())
463+ };
464+
465+ {
466+ blink::WebScopedMicrotaskSuppression mts;
467+ frame->callFunctionEvenIfScriptDisabled(
468+ function,
469+ message_manager->GetV8Context()->Global(),
470+ arraysize(argv),
471+ argv);
472+ }
473+ if (try_catch.HasCaught()) {
474+ LOG(ERROR) << "Caught exception when calling script: "
475+ << *v8::String::Utf8Value(try_catch.Message()->Get());
476+ return;
477+ }
478+}
479+
480 void UserScriptSlave::InjectScripts(blink::WebLocalFrame* frame,
481 UserScript::RunLocation location) {
482 blink::WebDataSource* data_source = frame->provisionalDataSource() ?
483@@ -151,6 +225,16 @@
484 }
485
486 blink::WebScriptSource source(blink::WebString::fromUTF8(content));
487+
488+ if (script->context() == GURL(kMainWorldContextUrl)) {
489+ if (script->emulate_greasemonkey()) {
490+ InjectGreaseMonkeyScriptInMainWorld(frame, source);
491+ } else {
492+ frame->executeScript(source);
493+ }
494+ continue;
495+ }
496+
497 int id = GetIsolatedWorldID(script->context(), frame);
498 frame->executeScriptInIsolatedWorld(id, &source, 1, 0);
499 }
500
501=== modified file 'shared/renderer/oxide_user_script_slave.h'
502--- shared/renderer/oxide_user_script_slave.h 2014-04-17 12:57:07 +0000
503+++ shared/renderer/oxide_user_script_slave.h 2014-10-08 13:23:51 +0000
504@@ -32,6 +32,7 @@
505
506 namespace blink {
507 class WebLocalFrame;
508+class WebScriptSource;
509 }
510
511 namespace oxide {
512@@ -57,6 +58,10 @@
513 blink::WebLocalFrame* frame);
514 void OnUpdateUserScripts(base::SharedMemoryHandle handle);
515
516+ void InjectGreaseMonkeyScriptInMainWorld(
517+ blink::WebLocalFrame* frame,
518+ const blink::WebScriptSource& script_source);
519+
520 Vector user_scripts_;
521
522 DISALLOW_COPY_AND_ASSIGN(UserScriptSlave);

Subscribers

People subscribed via source and target branches