Coder Social home page Coder Social logo

Comments (3)

ppaneksamsung avatar ppaneksamsung commented on May 31, 2024

For my particular case, calling ewk_context_web_storage_delete_all fixes the issue. I used following extension method:

internal static partial class Interop
{
    private static class Libraries
    {
        internal const string ChromiumEwk = "libchromium-ewk.so";
    }

    internal static partial class ChromiumEwk
    {
        [DllImport(Libraries.ChromiumEwk)]
        internal static extern bool ewk_context_web_storage_delete_all(IntPtr context);
    }
}

public static class ContextExtensions
{
    private static IntPtr GetHandle(this Context context)
    {
        var contextType = context.GetType();
        var handleField = contextType.GetField(
            "_handle",
            BindingFlags.Instance | BindingFlags.NonPublic);
        if (handleField == null)
            throw new NotSupportedException("Context doesn't have a _handle field");
        if (handleField.FieldType != typeof(IntPtr))
            throw new NotSupportedException(
                $"Unexpected field type. Expected {typeof(IntPtr)}, got {handleField.FieldType}");
        return (IntPtr) handleField.GetValue(context);
    }

    public static bool DeleteWebStorage(this Context context)
    {
        var handle = context.GetHandle();
        return Interop.ChromiumEwk.ewk_context_web_storage_delete_all(handle);
    }        
}

Consider to expose this CAPI. Another possible solution for my problem would be to launch a WebView in incognito mode, but I'm not sure if it's exposed now.

from tizenfx.

ppaneksamsung avatar ppaneksamsung commented on May 31, 2024

The problem seems to be a little bit more complex. It looks like Tizen.WebView was designed to be used as a 'singleton'. I use the AddJavaScriptMessageHandler method (https://github.com/Samsung/TizenFX/blob/master/src/Tizen.WebView/Tizen.WebView/WebView.cs#L432) and this method adds a handler to static _javaScriptMessageHandlerMap dictionary. I don't see any option to remove already registered JS message handler. This is a problem in following case:

  • create 1st WebView
  • register JS message handler with some name
  • destroy 1st WebView
  • create 2nd WebView
  • register JS message handler with the same name as for 1st WebView

Second AddJavaScriptMessageHandler call fails due to:

if (_javaScriptMessageHandlerMap.ContainsKey(name))

from tizenfx.

github-actions avatar github-actions commented on May 31, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

from tizenfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.