[Webkit-unassigned] [Bug 205113] New: can not reload a page via loadFileURL after using loadHTMLString

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Dec 11 07:14:28 PST 2019


https://bugs.webkit.org/show_bug.cgi?id=205113

            Bug ID: 205113
           Summary: can not reload a page via loadFileURL after using
                    loadHTMLString
           Product: WebKit
           Version: Safari 13
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Page Loading
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: michael.parrot at groupcs.com
                CC: beidson at apple.com

can not reload page via loadFileURL when loadHTMLString is used.

HOW TO REPRODUCE:
load demo1.html via loadFileURL:allowingReadAccessToURL:
load html string via loadFileURL:baseURL:
then request for demo2.html via loadFileURL:allowingReadAccessToURL: does not work.

See demo projet.

@interface ViewController ()
{
        NSMutableDictionary *demoFiles;
}

@end

@implementation ViewController

- (void)viewDidLoad {
        [super viewDidLoad];

        demoFiles=[NSMutableDictionary dictionary];
        NSURL *docURL=[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];

        for (NSInteger i=1;i<=2;i++)
        {
                NSString *html=[NSString stringWithFormat:@"<html>"
                                                                        "<body style=\"background-color: yellow;\">"
                                                                                "<center><h1>file url %d</h1></center>"
                                                                        "</body>"
                                                                "</html>",(int)i];

                NSURL *demoFile=[docURL URLByAppendingPathComponent:[NSString stringWithFormat:@"demo_%d.html",(int)i]];
                demoFiles[@(i)]=demoFile;

                NSError *error=nil;
                if ([html writeToURL:demoFile atomically:YES encoding:NSUTF8StringEncoding error:&error]==NO)
                        NSLog(@"ERROR %s writeToFile==NO",sel_getName(_cmd));
        }

        [self performSelector:@selector(loadFileURL:) withObject:@(1) afterDelay:0.1];
}

- (void)loadFileURL:(NSNumber*)state
{
        NSLog(@"INFO %s",sel_getName(_cmd));

        NSURL *demoFile=demoFiles[state];
        [self.webView loadFileURL:demoFile allowingReadAccessToURL:demoFile];

        if (state.integerValue==1)
                [self performSelector:@selector(loadHtmlString:) withObject:nil afterDelay:5.0];
}

- (void)loadHtmlString:(NSNumber*)state
{
        NSLog(@"INFO %s",sel_getName(_cmd));

        NSString *html=@"<html>"
                "<body style=\"background-color: red;\">"
                        "<center><h1>html string</h1></center>"
                "</body>"
        "</html>";

        [self.webView loadHTMLString:html baseURL:nil];

        [self performSelector:@selector(loadFileURL:) withObject:@(2) afterDelay:5.0];
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20191211/05818bd4/attachment-0001.htm>


More information about the webkit-unassigned mailing list