in JS you would do:
var myDocument = app.activeDocument;
myDocument.documentPreferences.pageSize = "A4"; // I dont know if this requires a preset of the name A4 to exist, else use pageHeight and pageSize instead.
Is this also resize the text frames?
No it will not resize any content - I think you should have a look at the option found in Indesign under "Layout -> Layout adjustment", i guess this is what you are looking for.
I have not tested, but perhaps enabling the layout adjustment, will also take effekt when changing doc size from scripting.
Try it :-)
app.activeDocument.layoutAdjustmentPreferences.enableLayoutAdjustment = true;
Change the camelCase where necessary