Open and-nord opened 4 years ago
I found a connection between the current window and the parent. And I was able to get the instance with the variables of the parent window. var oParent = Window->Document->Context->Parent->Current; next get instance from document ...\AngleSharp.Js\v.0.14.0\src\AngleSharp.Js\JsScriptingService.cs (line 104) internal EngineInstance GetOrCreateInstance(IDocument document) { var objectContext = document.DefaultView;
if (!_contexts.TryGetValue(objectContext, out var instance))
{
var libs = GetAssemblies(document.Context).ToArray();
instance = new EngineInstance(objectContext, _external, libs);
_contexts.Add(objectContext, instance);
}
return instance;
}
It's on my knee, but I would like to get a competent code
I'll try to look into it! Just quite under water right now...
Bug Report
Prerequisites
AngleSharp.Css
for CSS support)For more information, see the
CONTRIBUTING
guide.Description
I am parsing Kyocera FS-3040MFP+ Index page have frame set
frameset border=0 cols= frameborder=NO framespacing=0 rows=1, frame name=topframe noResize scrolling=no src="../top.htm" frame name=main src="../start/start.htm"
and javascript that have same vars
When run start.htm that have into javascript where set var: Line 45: parent.FaxNum = FaxNum; Line 48: parent.CipherCheck = 1; Line 50: parent.CipherCheck = 0; etc
As result Script parsing stops with an error "ReferenceError: parent is not defined"
Steps to Reproduce
[First Step] var srvJsScripting = new JsScriptingService(); var srvNavigator = new Navigator(); var config = Configuration.Default.WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true }).With(srvNavigator) .WithLocaleBasedEncoding().WithCulture("ru-ru").With(srvJsScripting); var context = BrowsingContext.New(config); var queryDocument = context.OpenAsync("http://mfu01.al.loc").Result;
[Second Step] When page start.htm is was processed throw exception "ReferenceError: parent is not defined" and treatment of script is stopped and run next script where into have "parent.Var = " and this have the same error
[and so on...]
Expected behavior: I want to get variables from the environment of the parent window, read and write data from the child window Actual behavior: throw exception "ReferenceError: parent is not defined" Environment details: VS 2019, last version of AngleSharp.JS
Possible Solution
Add a property "parent" to the object "Window" to have access to the variables of the parent page https://developer.mozilla.org/en-US/docs/Web/API/Window/parent